From 58f8be580039b0575b197b9573a1c92745d96d30 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 17 Jan 2017 20:25:09 +0100 Subject: New upstream version 1.5.90 --- src/Makefile.am | 663 --- src/Makefile.in | 2803 ---------- src/NetworkManager.ver | 20 - src/NetworkManagerUtils.c | 10 +- src/devices/Makefile.am | 1 - src/devices/Makefile.in | 781 --- src/devices/adsl/Makefile.am | 46 - src/devices/adsl/Makefile.in | 853 ---- src/devices/adsl/exports.ver | 6 - src/devices/adsl/nm-atm-manager.c | 63 +- src/devices/adsl/nm-atm-manager.h | 37 - src/devices/adsl/nm-device-adsl.c | 198 +- src/devices/adsl/nm-device-adsl.h | 12 +- src/devices/bluetooth/Makefile.am | 82 - src/devices/bluetooth/Makefile.in | 887 ---- src/devices/bluetooth/exports.ver | 6 - src/devices/bluetooth/nm-bluez-common.h | 3 +- src/devices/bluetooth/nm-bluez-device.c | 290 +- src/devices/bluetooth/nm-bluez-device.h | 14 +- src/devices/bluetooth/nm-bluez-manager.c | 119 +- src/devices/bluetooth/nm-bluez-manager.h | 39 - src/devices/bluetooth/nm-bluez4-adapter.c | 194 +- src/devices/bluetooth/nm-bluez4-adapter.h | 17 +- src/devices/bluetooth/nm-bluez4-manager.c | 72 +- src/devices/bluetooth/nm-bluez4-manager.h | 17 +- src/devices/bluetooth/nm-bluez5-manager.c | 73 +- src/devices/bluetooth/nm-bluez5-manager.h | 17 +- src/devices/bluetooth/nm-bt-enum-types.c | 35 - src/devices/bluetooth/nm-bt-enum-types.h | 19 - src/devices/bluetooth/nm-device-bt.c | 291 +- src/devices/bluetooth/nm-device-bt.h | 29 +- src/devices/nm-arping-manager.c | 114 +- src/devices/nm-arping-manager.h | 8 +- src/devices/nm-device-bond.c | 75 +- src/devices/nm-device-bond.h | 4 +- src/devices/nm-device-bridge.c | 46 +- src/devices/nm-device-bridge.h | 4 +- src/devices/nm-device-ethernet.c | 380 +- src/devices/nm-device-ethernet.h | 2 +- src/devices/nm-device-factory.c | 241 +- src/devices/nm-device-factory.h | 133 +- src/devices/nm-device-generic.c | 139 +- src/devices/nm-device-generic.h | 13 +- src/devices/nm-device-infiniband.c | 146 +- src/devices/nm-device-infiniband.h | 16 +- src/devices/nm-device-ip-tunnel.c | 395 +- src/devices/nm-device-ip-tunnel.h | 11 +- src/devices/nm-device-logging.h | 2 +- src/devices/nm-device-macsec.c | 1009 ++++ src/devices/nm-device-macsec.h | 54 + src/devices/nm-device-macvlan.c | 307 +- src/devices/nm-device-macvlan.h | 8 +- src/devices/nm-device-private.h | 31 +- src/devices/nm-device-tun.c | 196 +- src/devices/nm-device-tun.h | 4 +- src/devices/nm-device-veth.c | 95 +- src/devices/nm-device-vlan.c | 307 +- src/devices/nm-device-vlan.h | 8 +- src/devices/nm-device-vxlan.c | 409 +- src/devices/nm-device-vxlan.h | 8 +- src/devices/nm-device.c | 1840 +++++-- src/devices/nm-device.h | 54 +- src/devices/nm-lldp-listener.c | 27 +- src/devices/nm-lldp-listener.h | 8 +- src/devices/team/Makefile.am | 55 - src/devices/team/Makefile.in | 850 ---- src/devices/team/exports.ver | 6 - src/devices/team/nm-device-team.c | 138 +- src/devices/team/nm-device-team.h | 6 +- src/devices/team/nm-team-factory.c | 54 +- src/devices/team/nm-team-factory.h | 35 - src/devices/tests/Makefile.am | 55 - src/devices/tests/Makefile.in | 1273 ----- src/devices/tests/test-arping.c | 6 +- src/devices/tests/test-lldp.c | 10 +- src/devices/wifi/Makefile.am | 58 - src/devices/wifi/Makefile.in | 982 ---- src/devices/wifi/exports.ver | 6 - src/devices/wifi/nm-device-olpc-mesh.c | 165 +- src/devices/wifi/nm-device-olpc-mesh.h | 19 +- src/devices/wifi/nm-device-wifi.c | 486 +- src/devices/wifi/nm-device-wifi.h | 9 +- src/devices/wifi/nm-wifi-ap-utils.c | 785 --- src/devices/wifi/nm-wifi-ap-utils.h | 44 - src/devices/wifi/nm-wifi-ap.c | 758 +-- src/devices/wifi/nm-wifi-ap.h | 118 +- src/devices/wifi/nm-wifi-factory.c | 51 +- src/devices/wifi/nm-wifi-utils.c | 786 +++ src/devices/wifi/nm-wifi-utils.h | 42 + src/devices/wifi/tests/Makefile.am | 28 - src/devices/wifi/tests/Makefile.in | 1175 ----- src/devices/wifi/tests/test-general.c | 1502 ++++++ src/devices/wifi/tests/test-wifi-ap-utils.c | 1502 ------ src/devices/wwan/Makefile.am | 96 - src/devices/wwan/Makefile.in | 921 ---- src/devices/wwan/exports.ver | 6 - src/devices/wwan/libnm-wwan.ver | 30 + src/devices/wwan/nm-device-modem.c | 268 +- src/devices/wwan/nm-device-modem.h | 12 +- src/devices/wwan/nm-modem-broadband.c | 355 +- src/devices/wwan/nm-modem-broadband.h | 14 +- src/devices/wwan/nm-modem-enum-types.c | 87 - src/devices/wwan/nm-modem-enum-types.h | 23 - src/devices/wwan/nm-modem-manager.c | 154 +- src/devices/wwan/nm-modem-manager.h | 22 +- src/devices/wwan/nm-modem-ofono.c | 93 +- src/devices/wwan/nm-modem-ofono.h | 9 +- src/devices/wwan/nm-modem.c | 478 +- src/devices/wwan/nm-modem.h | 31 +- src/devices/wwan/nm-wwan-factory.c | 65 +- src/devices/wwan/nm-wwan-factory.h | 35 - src/devices/wwan/wwan-exports.ver | 30 - src/dhcp-manager/Makefile.am | 17 - src/dhcp-manager/Makefile.in | 822 --- src/dhcp-manager/nm-dhcp-client-logging.h | 77 - src/dhcp-manager/nm-dhcp-client.c | 967 ---- src/dhcp-manager/nm-dhcp-client.h | 174 - src/dhcp-manager/nm-dhcp-dhclient-utils.c | 755 --- src/dhcp-manager/nm-dhcp-dhclient-utils.h | 54 - src/dhcp-manager/nm-dhcp-dhclient.c | 683 --- src/dhcp-manager/nm-dhcp-dhclient.h | 42 - src/dhcp-manager/nm-dhcp-dhcpcd.c | 246 - src/dhcp-manager/nm-dhcp-dhcpcd.h | 42 - src/dhcp-manager/nm-dhcp-helper-api.h | 36 - src/dhcp-manager/nm-dhcp-helper.c | 221 - src/dhcp-manager/nm-dhcp-listener.c | 329 -- src/dhcp-manager/nm-dhcp-listener.h | 36 - src/dhcp-manager/nm-dhcp-manager.c | 451 -- src/dhcp-manager/nm-dhcp-manager.h | 89 - src/dhcp-manager/nm-dhcp-systemd.c | 1050 ---- src/dhcp-manager/nm-dhcp-systemd.h | 42 - src/dhcp-manager/nm-dhcp-utils.c | 739 --- src/dhcp-manager/nm-dhcp-utils.h | 43 - src/dhcp-manager/tests/Makefile.am | 50 - src/dhcp-manager/tests/Makefile.in | 1213 ----- src/dhcp-manager/tests/leases/basic.leases | 31 - src/dhcp-manager/tests/leases/malformed1.leases | 15 - src/dhcp-manager/tests/leases/malformed2.leases | 15 - src/dhcp-manager/tests/leases/malformed3.leases | 15 - .../tests/test-dhclient-commented-duid.leases | 2 - src/dhcp-manager/tests/test-dhclient-duid.leases | 2 - src/dhcp-manager/tests/test-dhcp-dhclient.c | 876 ---- src/dhcp-manager/tests/test-dhcp-utils.c | 748 --- src/dhcp/nm-dhcp-client-logging.h | 77 + src/dhcp/nm-dhcp-client.c | 997 ++++ src/dhcp/nm-dhcp-client.h | 185 + src/dhcp/nm-dhcp-dhclient-utils.c | 775 +++ src/dhcp/nm-dhcp-dhclient-utils.h | 54 + src/dhcp/nm-dhcp-dhclient.c | 706 +++ src/dhcp/nm-dhcp-dhcpcd.c | 265 + src/dhcp/nm-dhcp-helper-api.h | 36 + src/dhcp/nm-dhcp-helper.c | 227 + src/dhcp/nm-dhcp-listener.c | 345 ++ src/dhcp/nm-dhcp-listener.h | 36 + src/dhcp/nm-dhcp-manager.c | 442 ++ src/dhcp/nm-dhcp-manager.h | 89 + src/dhcp/nm-dhcp-systemd.c | 1070 ++++ src/dhcp/nm-dhcp-utils.c | 779 +++ src/dhcp/nm-dhcp-utils.h | 45 + src/dhcp/tests/leases/basic.leases | 31 + src/dhcp/tests/leases/malformed1.leases | 15 + src/dhcp/tests/leases/malformed2.leases | 15 + src/dhcp/tests/leases/malformed3.leases | 15 + src/dhcp/tests/test-dhclient-commented-duid.leases | 2 + src/dhcp/tests/test-dhclient-duid.leases | 2 + src/dhcp/tests/test-dhcp-dhclient.c | 915 ++++ src/dhcp/tests/test-dhcp-utils.c | 748 +++ src/dns-manager/nm-dns-dnsmasq.c | 697 --- src/dns-manager/nm-dns-dnsmasq.h | 44 - src/dns-manager/nm-dns-manager.c | 1800 ------- src/dns-manager/nm-dns-manager.h | 117 - src/dns-manager/nm-dns-plugin.c | 310 -- src/dns-manager/nm-dns-plugin.h | 111 - src/dns-manager/nm-dns-unbound.c | 80 - src/dns-manager/nm-dns-unbound.h | 42 - src/dns/nm-dns-dnsmasq.c | 672 +++ src/dns/nm-dns-dnsmasq.h | 38 + src/dns/nm-dns-manager.c | 2116 ++++++++ src/dns/nm-dns-manager.h | 123 + src/dns/nm-dns-plugin.c | 316 ++ src/dns/nm-dns-plugin.h | 106 + src/dns/nm-dns-systemd-resolved.c | 428 ++ src/dns/nm-dns-systemd-resolved.h | 39 + src/dns/nm-dns-unbound.c | 91 + src/dns/nm-dns-unbound.h | 37 + src/dnsmasq-manager/nm-dnsmasq-manager.c | 388 -- src/dnsmasq-manager/nm-dnsmasq-manager.h | 61 - src/dnsmasq-manager/nm-dnsmasq-utils.c | 78 - src/dnsmasq-manager/nm-dnsmasq-utils.h | 31 - src/dnsmasq-manager/tests/Makefile.am | 24 - src/dnsmasq-manager/tests/Makefile.in | 1141 ----- src/dnsmasq-manager/tests/test-dnsmasq-utils.c | 99 - src/dnsmasq/nm-dnsmasq-manager.c | 395 ++ src/dnsmasq/nm-dnsmasq-manager.h | 55 + src/dnsmasq/nm-dnsmasq-utils.c | 78 + src/dnsmasq/nm-dnsmasq-utils.h | 31 + src/dnsmasq/tests/test-dnsmasq-utils.c | 99 + src/main-utils.c | 15 +- src/main.c | 34 +- src/ndisc/nm-fake-ndisc.c | 412 ++ src/ndisc/nm-fake-ndisc.h | 81 + src/ndisc/nm-lndp-ndisc.c | 629 +++ src/ndisc/nm-lndp-ndisc.h | 48 + src/ndisc/nm-ndisc-private.h | 78 + src/ndisc/nm-ndisc.c | 1235 +++++ src/ndisc/nm-ndisc.h | 189 + src/ndisc/tests/test-ndisc-fake.c | 483 ++ src/ndisc/tests/test-ndisc-linux.c | 86 + src/nm-act-request.c | 606 +++ src/nm-act-request.h | 77 + src/nm-activation-request.c | 571 --- src/nm-activation-request.h | 84 - src/nm-active-connection.c | 218 +- src/nm-active-connection.h | 4 + src/nm-audit-manager.c | 71 +- src/nm-audit-manager.h | 10 +- src/nm-auth-manager.c | 111 +- src/nm-auth-manager.h | 11 +- src/nm-auth-subject.c | 32 +- src/nm-auth-utils.c | 15 +- src/nm-bus-manager.c | 217 +- src/nm-bus-manager.h | 18 +- src/nm-checkpoint-manager.c | 30 +- src/nm-checkpoint-manager.h | 2 +- src/nm-checkpoint.c | 325 +- src/nm-checkpoint.h | 7 +- src/nm-config-data.c | 342 +- src/nm-config-data.h | 10 +- src/nm-config.c | 612 ++- src/nm-config.h | 55 +- src/nm-connectivity.c | 151 +- src/nm-connectivity.h | 9 +- src/nm-core-utils.c | 831 ++- src/nm-core-utils.h | 79 +- src/nm-dcb.c | 2 +- src/nm-default-route-manager.c | 64 +- src/nm-default-route-manager.h | 9 +- src/nm-dhcp4-config.c | 101 +- src/nm-dhcp4-config.h | 13 +- src/nm-dhcp6-config.c | 99 +- src/nm-dhcp6-config.h | 13 +- src/nm-dispatcher.c | 87 +- src/nm-dispatcher.h | 2 + src/nm-enum-types.c | 729 --- src/nm-enum-types.h | 70 - src/nm-exported-object.c | 66 +- src/nm-exported-object.h | 5 + src/nm-firewall-manager.c | 94 +- src/nm-firewall-manager.h | 25 +- src/nm-iface-helper.c | 286 +- src/nm-ip4-config.c | 233 +- src/nm-ip4-config.h | 2 +- src/nm-ip6-config.c | 163 +- src/nm-ip6-config.h | 1 + src/nm-logging.c | 281 +- src/nm-logging.h | 22 + src/nm-manager.c | 367 +- src/nm-manager.h | 11 +- src/nm-multi-index.c | 10 +- src/nm-pacrunner-manager.c | 468 ++ src/nm-pacrunner-manager.h | 45 + src/nm-policy.c | 465 +- src/nm-policy.h | 12 +- src/nm-proxy-config.c | 187 + src/nm-proxy-config.h | 57 + src/nm-rfkill-manager.c | 60 +- src/nm-rfkill-manager.h | 21 +- src/nm-route-manager.c | 68 +- src/nm-route-manager.h | 14 +- src/nm-session-monitor.c | 77 +- src/nm-session-monitor.h | 17 +- src/nm-sleep-monitor.c | 35 +- src/nm-sleep-monitor.h | 7 +- src/nm-types.h | 7 +- src/platform/Makefile.am | 1 - src/platform/Makefile.in | 781 --- src/platform/nm-fake-platform.c | 184 +- src/platform/nm-fake-platform.h | 13 +- src/platform/nm-linux-platform.c | 579 ++- src/platform/nm-linux-platform.h | 17 +- src/platform/nm-platform-utils.c | 370 +- src/platform/nm-platform-utils.h | 51 +- src/platform/nm-platform.c | 567 ++- src/platform/nm-platform.h | 85 +- src/platform/nmp-netns.c | 77 +- src/platform/nmp-netns.h | 17 +- src/platform/nmp-object.c | 138 +- src/platform/nmp-object.h | 15 +- src/platform/tests/Makefile.am | 132 - src/platform/tests/Makefile.in | 2068 -------- src/platform/tests/monitor.c | 2 +- src/platform/tests/test-address.c | 2 + src/platform/tests/test-cleanup.c | 2 + src/platform/tests/test-common.c | 114 +- src/platform/tests/test-common.h | 26 +- src/platform/tests/test-general.c | 10 +- src/platform/tests/test-link.c | 262 +- src/platform/tests/test-nmp-object.c | 10 +- src/platform/tests/test-route.c | 16 +- src/platform/wifi/wifi-utils-nl80211.c | 2 +- src/platform/wifi/wifi-utils-wext.c | 17 +- src/platform/wifi/wifi-utils.c | 28 +- src/platform/wifi/wifi-utils.h | 2 +- src/ppp-manager/Makefile.am | 28 - src/ppp-manager/Makefile.in | 835 --- src/ppp-manager/nm-ppp-manager.c | 1245 ----- src/ppp-manager/nm-ppp-manager.h | 83 - src/ppp-manager/nm-ppp-status.h | 43 - src/ppp-manager/nm-pppd-plugin.c | 417 -- src/ppp-manager/nm-pppd-plugin.h | 34 - src/ppp/nm-ppp-manager-call.c | 142 + src/ppp/nm-ppp-manager-call.h | 43 + src/ppp/nm-ppp-manager.c | 1296 +++++ src/ppp/nm-ppp-manager.h | 34 + src/ppp/nm-ppp-plugin-api.h | 46 + src/ppp/nm-ppp-plugin.ver | 6 + src/ppp/nm-ppp-status.h | 43 + src/ppp/nm-pppd-plugin.c | 417 ++ src/ppp/nm-pppd-plugin.h | 34 + src/rdisc/Makefile.am | 1 - src/rdisc/Makefile.in | 781 --- src/rdisc/nm-fake-rdisc.c | 396 -- src/rdisc/nm-fake-rdisc.h | 88 - src/rdisc/nm-lndp-rdisc.c | 434 -- src/rdisc/nm-lndp-rdisc.h | 47 - src/rdisc/nm-rdisc-private.h | 77 - src/rdisc/nm-rdisc.c | 1073 ---- src/rdisc/nm-rdisc.h | 170 - src/rdisc/tests/Makefile.am | 36 - src/rdisc/tests/Makefile.in | 1164 ----- src/rdisc/tests/test-rdisc-fake.c | 483 -- src/rdisc/tests/test-rdisc-linux.c | 85 - src/settings/nm-agent-manager.c | 153 +- src/settings/nm-agent-manager.h | 12 +- src/settings/nm-inotify-helper.c | 56 +- src/settings/nm-inotify-helper.h | 20 +- src/settings/nm-secret-agent.c | 104 +- src/settings/nm-secret-agent.h | 10 +- src/settings/nm-settings-connection.c | 164 +- src/settings/nm-settings-connection.h | 5 +- src/settings/nm-settings.c | 246 +- src/settings/nm-settings.h | 8 +- src/settings/plugins/Makefile.am | 19 - src/settings/plugins/Makefile.in | 788 --- src/settings/plugins/ibft/Makefile.am | 37 - src/settings/plugins/ibft/Makefile.in | 979 ---- src/settings/plugins/ibft/nm-ibft-connection.c | 67 - src/settings/plugins/ibft/nm-ibft-connection.h | 46 - src/settings/plugins/ibft/nms-ibft-connection.c | 77 + src/settings/plugins/ibft/nms-ibft-connection.h | 41 + src/settings/plugins/ibft/nms-ibft-plugin.c | 206 + src/settings/plugins/ibft/nms-ibft-plugin.h | 36 + src/settings/plugins/ibft/nms-ibft-reader.c | 549 ++ src/settings/plugins/ibft/nms-ibft-reader.h | 34 + src/settings/plugins/ibft/plugin.c | 197 - src/settings/plugins/ibft/plugin.h | 45 - src/settings/plugins/ibft/reader.c | 547 -- src/settings/plugins/ibft/reader.h | 35 - src/settings/plugins/ibft/tests/Makefile.am | 52 - src/settings/plugins/ibft/tests/Makefile.in | 1184 ----- src/settings/plugins/ibft/tests/test-ibft.c | 16 +- src/settings/plugins/ifcfg-rh/Makefile.am | 74 - src/settings/plugins/ifcfg-rh/Makefile.in | 1062 ---- src/settings/plugins/ifcfg-rh/common.h | 82 - .../plugins/ifcfg-rh/nm-ifcfg-connection.c | 566 --- .../plugins/ifcfg-rh/nm-ifcfg-connection.h | 59 - .../plugins/ifcfg-rh/nms-ifcfg-rh-common.h | 82 + .../plugins/ifcfg-rh/nms-ifcfg-rh-connection.c | 575 +++ .../plugins/ifcfg-rh/nms-ifcfg-rh-connection.h | 54 + .../plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c | 1085 ++++ .../plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h | 39 + .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 5361 ++++++++++++++++++++ .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.h | 42 + src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c | 365 ++ src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h | 58 + .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 2965 +++++++++++ .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.h | 39 + src/settings/plugins/ifcfg-rh/plugin.c | 1080 ---- src/settings/plugins/ifcfg-rh/plugin.h | 48 - src/settings/plugins/ifcfg-rh/reader.c | 5260 ------------------- src/settings/plugins/ifcfg-rh/reader.h | 42 - src/settings/plugins/ifcfg-rh/shvar.c | 1218 +++-- src/settings/plugins/ifcfg-rh/shvar.h | 26 +- src/settings/plugins/ifcfg-rh/tests/Makefile.am | 56 - src/settings/plugins/ifcfg-rh/tests/Makefile.in | 1371 ----- .../ifcfg-rh/tests/network-scripts/Makefile.am | 170 - .../ifcfg-rh/tests/network-scripts/Makefile.in | 776 --- .../network-scripts/ifcfg-test-misc-variables | 1 + .../network-scripts/ifcfg-test-read-proxy-basic | 15 + .../tests/network-scripts/ifcfg-test-wifi-wpa-psk | 2 +- .../ifcfg-test-wired-auto-negotiate-on | 22 + .../ifcfg-test-wired-dhcpv6-hostname-fallback | 12 + .../ifcfg-test-wired-unknown-ethtool-opt | 22 + .../network-scripts/ifcfg-test-write-unknown-1 | 8 + .../ifcfg-test-write-unknown-1.expected | 12 + .../network-scripts/ifcfg-test-write-unknown-2 | 3 + .../ifcfg-test-write-unknown-2.expected | 4 + .../network-scripts/ifcfg-test-write-unknown-3 | 3 + .../ifcfg-test-write-unknown-3.expected | 5 + .../network-scripts/ifcfg-test-write-unknown-4 | 36 + .../ifcfg-test-write-unknown-4.expected | 31 + .../tests/network-scripts/keys-test-wifi-wpa-psk-2 | 2 +- .../plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c | 155 - .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 2256 ++++---- src/settings/plugins/ifcfg-rh/utils.c | 446 -- src/settings/plugins/ifcfg-rh/utils.h | 62 - src/settings/plugins/ifcfg-rh/writer.c | 2970 ----------- src/settings/plugins/ifcfg-rh/writer.h | 40 - src/settings/plugins/ifnet/Makefile.am | 41 - src/settings/plugins/ifnet/Makefile.in | 987 ---- src/settings/plugins/ifnet/connection_parser.c | 2966 ----------- src/settings/plugins/ifnet/connection_parser.h | 53 - src/settings/plugins/ifnet/net_parser.c | 734 --- src/settings/plugins/ifnet/net_parser.h | 42 - src/settings/plugins/ifnet/net_utils.c | 826 --- src/settings/plugins/ifnet/net_utils.h | 70 - src/settings/plugins/ifnet/nm-ifnet-connection.c | 223 - src/settings/plugins/ifnet/nm-ifnet-connection.h | 50 - .../plugins/ifnet/nms-ifnet-connection-parser.c | 2967 +++++++++++ .../plugins/ifnet/nms-ifnet-connection-parser.h | 55 + src/settings/plugins/ifnet/nms-ifnet-connection.c | 238 + src/settings/plugins/ifnet/nms-ifnet-connection.h | 46 + src/settings/plugins/ifnet/nms-ifnet-net-parser.c | 734 +++ src/settings/plugins/ifnet/nms-ifnet-net-parser.h | 42 + src/settings/plugins/ifnet/nms-ifnet-net-utils.c | 830 +++ src/settings/plugins/ifnet/nms-ifnet-net-utils.h | 71 + src/settings/plugins/ifnet/nms-ifnet-plugin.c | 514 ++ src/settings/plugins/ifnet/nms-ifnet-plugin.h | 38 + src/settings/plugins/ifnet/nms-ifnet-wpa-parser.c | 583 +++ src/settings/plugins/ifnet/nms-ifnet-wpa-parser.h | 41 + src/settings/plugins/ifnet/plugin.c | 502 -- src/settings/plugins/ifnet/plugin.h | 45 - src/settings/plugins/ifnet/tests/Makefile.am | 50 - src/settings/plugins/ifnet/tests/Makefile.in | 1234 ----- src/settings/plugins/ifnet/tests/test-ifnet.c | 20 +- src/settings/plugins/ifnet/wpa_parser.c | 581 --- src/settings/plugins/ifnet/wpa_parser.h | 41 - src/settings/plugins/ifupdown/Makefile.am | 36 - src/settings/plugins/ifupdown/Makefile.in | 979 ---- src/settings/plugins/ifupdown/interface_parser.c | 413 -- src/settings/plugins/ifupdown/interface_parser.h | 56 - .../plugins/ifupdown/nm-ifupdown-connection.c | 80 - .../plugins/ifupdown/nm-ifupdown-connection.h | 50 - .../plugins/ifupdown/nms-ifupdown-connection.c | 96 + .../plugins/ifupdown/nms-ifupdown-connection.h | 45 + .../ifupdown/nms-ifupdown-interface-parser.c | 404 ++ .../ifupdown/nms-ifupdown-interface-parser.h | 56 + .../plugins/ifupdown/nms-ifupdown-parser.c | 724 +++ .../plugins/ifupdown/nms-ifupdown-parser.h | 36 + .../plugins/ifupdown/nms-ifupdown-plugin.c | 527 ++ .../plugins/ifupdown/nms-ifupdown-plugin.h | 41 + src/settings/plugins/ifupdown/parser.c | 726 --- src/settings/plugins/ifupdown/parser.h | 35 - src/settings/plugins/ifupdown/plugin.c | 561 -- src/settings/plugins/ifupdown/plugin.h | 49 - src/settings/plugins/ifupdown/tests/Makefile.am | 39 - src/settings/plugins/ifupdown/tests/Makefile.in | 1188 ----- .../plugins/ifupdown/tests/test-ifupdown.c | 5 +- src/settings/plugins/keyfile/Makefile.am | 48 - src/settings/plugins/keyfile/Makefile.in | 925 ---- .../plugins/keyfile/nm-keyfile-connection.c | 167 - .../plugins/keyfile/nm-keyfile-connection.h | 48 - .../plugins/keyfile/nms-keyfile-connection.c | 180 + .../plugins/keyfile/nms-keyfile-connection.h | 43 + src/settings/plugins/keyfile/nms-keyfile-plugin.c | 662 +++ src/settings/plugins/keyfile/nms-keyfile-plugin.h | 39 + src/settings/plugins/keyfile/nms-keyfile-reader.c | 143 + src/settings/plugins/keyfile/nms-keyfile-reader.h | 29 + src/settings/plugins/keyfile/nms-keyfile-utils.c | 170 + src/settings/plugins/keyfile/nms-keyfile-utils.h | 41 + src/settings/plugins/keyfile/nms-keyfile-writer.c | 328 ++ src/settings/plugins/keyfile/nms-keyfile-writer.h | 40 + src/settings/plugins/keyfile/plugin.c | 648 --- src/settings/plugins/keyfile/plugin.h | 44 - src/settings/plugins/keyfile/reader.c | 140 - src/settings/plugins/keyfile/reader.h | 29 - src/settings/plugins/keyfile/tests/Makefile.am | 38 - src/settings/plugins/keyfile/tests/Makefile.in | 1317 ----- .../plugins/keyfile/tests/keyfiles/Makefile.am | 46 - .../plugins/keyfile/tests/keyfiles/Makefile.in | 647 --- .../keyfile/tests/keyfiles/Test_dcb_connection | 33 + src/settings/plugins/keyfile/tests/test-keyfile.c | 977 ++-- src/settings/plugins/keyfile/utils.c | 169 - src/settings/plugins/keyfile/utils.h | 42 - src/settings/plugins/keyfile/writer.c | 385 -- src/settings/plugins/keyfile/writer.h | 40 - src/supplicant-manager/nm-supplicant-config.c | 1128 ---- src/supplicant-manager/nm-supplicant-config.h | 83 - src/supplicant-manager/nm-supplicant-interface.c | 1663 ------ src/supplicant-manager/nm-supplicant-interface.h | 167 - src/supplicant-manager/nm-supplicant-manager.c | 410 -- src/supplicant-manager/nm-supplicant-manager.h | 53 - .../nm-supplicant-settings-verify.c | 276 - .../nm-supplicant-settings-verify.h | 38 - src/supplicant-manager/nm-supplicant-types.h | 52 - src/supplicant-manager/tests/Makefile.am | 24 - src/supplicant-manager/tests/Makefile.in | 1256 ----- src/supplicant-manager/tests/certs/Makefile.am | 6 - src/supplicant-manager/tests/certs/Makefile.in | 605 --- .../tests/certs/test-ca-cert.pem | 27 - src/supplicant-manager/tests/certs/test-cert.p12 | Bin 4092 -> 0 bytes .../tests/test-supplicant-config.c | 614 --- src/supplicant/nm-supplicant-config.c | 1246 +++++ src/supplicant/nm-supplicant-config.h | 79 + src/supplicant/nm-supplicant-interface.c | 1681 ++++++ src/supplicant/nm-supplicant-interface.h | 122 + src/supplicant/nm-supplicant-manager.c | 413 ++ src/supplicant/nm-supplicant-manager.h | 45 + src/supplicant/nm-supplicant-settings-verify.c | 281 + src/supplicant/nm-supplicant-settings-verify.h | 38 + src/supplicant/nm-supplicant-types.h | 58 + src/supplicant/tests/certs/test-ca-cert.pem | 27 + src/supplicant/tests/certs/test-cert.p12 | Bin 0 -> 4092 bytes src/supplicant/tests/test-supplicant-config.c | 614 +++ src/systemd/nm-sd.h | 7 + src/systemd/sd-adapt/format-util.h | 3 + src/systemd/sd-adapt/formats-util.h | 3 - src/systemd/sd-adapt/glob-util.h | 3 + src/systemd/sd-adapt/khash.h | 3 + src/systemd/src/basic/alloc-util.h | 8 + src/systemd/src/basic/escape.c | 2 +- src/systemd/src/basic/extract-word.c | 6 +- src/systemd/src/basic/fd-util.c | 6 +- src/systemd/src/basic/fileio.c | 38 +- src/systemd/src/basic/fileio.h | 4 +- src/systemd/src/basic/fs-util.c | 255 +- src/systemd/src/basic/fs-util.h | 16 +- src/systemd/src/basic/hostname-util.c | 1 - src/systemd/src/basic/in-addr-util.c | 43 +- src/systemd/src/basic/in-addr-util.h | 7 +- src/systemd/src/basic/list.h | 2 + src/systemd/src/basic/log.h | 10 +- src/systemd/src/basic/parse-util.c | 16 + src/systemd/src/basic/parse-util.h | 2 + src/systemd/src/basic/path-util.c | 150 +- src/systemd/src/basic/path-util.h | 20 +- src/systemd/src/basic/prioq.c | 4 +- src/systemd/src/basic/socket-util.c | 21 +- src/systemd/src/basic/socket-util.h | 2 + src/systemd/src/basic/sparse-endian.h | 47 +- src/systemd/src/basic/string-util.c | 20 +- src/systemd/src/basic/string-util.h | 10 +- src/systemd/src/basic/strv.c | 9 +- src/systemd/src/basic/strv.h | 16 +- src/systemd/src/basic/time-util.c | 14 +- src/systemd/src/basic/time-util.h | 7 +- src/systemd/src/basic/util.c | 24 +- src/systemd/src/basic/util.h | 2 +- src/systemd/src/libsystemd-network/dhcp-internal.h | 9 +- src/systemd/src/libsystemd-network/dhcp-network.c | 24 +- src/systemd/src/libsystemd-network/dhcp-packet.c | 6 +- .../src/libsystemd-network/network-internal.c | 34 +- .../src/libsystemd-network/sd-dhcp-client.c | 53 +- src/systemd/src/libsystemd-network/sd-dhcp-lease.c | 23 +- .../src/libsystemd-network/sd-dhcp6-client.c | 4 +- .../src/libsystemd-network/sd-dhcp6-lease.c | 4 +- src/systemd/src/libsystemd-network/sd-ipv4acd.c | 4 +- src/systemd/src/libsystemd-network/sd-ipv4ll.c | 4 +- src/systemd/src/libsystemd-network/sd-lldp.c | 4 +- src/systemd/src/libsystemd/sd-event/sd-event.c | 3 +- src/systemd/src/libsystemd/sd-id128/id128-util.c | 15 +- src/systemd/src/libsystemd/sd-id128/id128-util.h | 6 + src/systemd/src/libsystemd/sd-id128/sd-id128.c | 172 + src/systemd/src/shared/dns-domain.c | 20 +- src/systemd/src/shared/dns-domain.h | 2 + src/systemd/src/systemd/sd-dhcp-client.h | 3 + src/systemd/src/systemd/sd-id128.h | 4 +- src/tests/Makefile.am | 187 - src/tests/Makefile.in | 1664 ------ src/tests/config/Makefile.am | 37 - src/tests/config/Makefile.in | 1156 ----- src/tests/config/nm-test-device.c | 43 +- src/tests/config/nm-test-device.h | 12 +- src/tests/config/test-config.c | 48 +- src/tests/test-dcb.c | 2 +- src/tests/test-general-with-expect.c | 16 +- src/tests/test-general.c | 96 +- src/tests/test-ip4-config.c | 4 +- src/tests/test-ip6-config.c | 8 +- src/tests/test-resolvconf-capture.c | 4 +- src/tests/test-route-manager.c | 8 +- src/tests/test-secret-agent.py | 17 +- src/tests/test-systemd.c | 6 +- src/tests/test-utils.c | 26 +- src/tests/test-wired-defname.c | 14 +- src/vpn-manager/nm-vpn-connection.c | 2728 ---------- src/vpn-manager/nm-vpn-connection.h | 82 - src/vpn-manager/nm-vpn-manager.c | 289 -- src/vpn-manager/nm-vpn-manager.h | 50 - src/vpn/nm-vpn-connection.c | 2778 ++++++++++ src/vpn/nm-vpn-connection.h | 83 + src/vpn/nm-vpn-manager.c | 295 ++ src/vpn/nm-vpn-manager.h | 45 + 593 files changed, 66819 insertions(+), 99819 deletions(-) delete mode 100644 src/Makefile.am delete mode 100644 src/Makefile.in delete mode 100644 src/NetworkManager.ver delete mode 100644 src/devices/Makefile.am delete mode 100644 src/devices/Makefile.in delete mode 100644 src/devices/adsl/Makefile.am delete mode 100644 src/devices/adsl/Makefile.in delete mode 100644 src/devices/adsl/exports.ver delete mode 100644 src/devices/adsl/nm-atm-manager.h delete mode 100644 src/devices/bluetooth/Makefile.am delete mode 100644 src/devices/bluetooth/Makefile.in delete mode 100644 src/devices/bluetooth/exports.ver delete mode 100644 src/devices/bluetooth/nm-bluez-manager.h delete mode 100644 src/devices/bluetooth/nm-bt-enum-types.c delete mode 100644 src/devices/bluetooth/nm-bt-enum-types.h create mode 100644 src/devices/nm-device-macsec.c create mode 100644 src/devices/nm-device-macsec.h delete mode 100644 src/devices/team/Makefile.am delete mode 100644 src/devices/team/Makefile.in delete mode 100644 src/devices/team/exports.ver delete mode 100644 src/devices/team/nm-team-factory.h delete mode 100644 src/devices/tests/Makefile.am delete mode 100644 src/devices/tests/Makefile.in delete mode 100644 src/devices/wifi/Makefile.am delete mode 100644 src/devices/wifi/Makefile.in delete mode 100644 src/devices/wifi/exports.ver delete mode 100644 src/devices/wifi/nm-wifi-ap-utils.c delete mode 100644 src/devices/wifi/nm-wifi-ap-utils.h create mode 100644 src/devices/wifi/nm-wifi-utils.c create mode 100644 src/devices/wifi/nm-wifi-utils.h delete mode 100644 src/devices/wifi/tests/Makefile.am delete mode 100644 src/devices/wifi/tests/Makefile.in create mode 100644 src/devices/wifi/tests/test-general.c delete mode 100644 src/devices/wifi/tests/test-wifi-ap-utils.c delete mode 100644 src/devices/wwan/Makefile.am delete mode 100644 src/devices/wwan/Makefile.in delete mode 100644 src/devices/wwan/exports.ver create mode 100644 src/devices/wwan/libnm-wwan.ver delete mode 100644 src/devices/wwan/nm-modem-enum-types.c delete mode 100644 src/devices/wwan/nm-modem-enum-types.h delete mode 100644 src/devices/wwan/nm-wwan-factory.h delete mode 100644 src/devices/wwan/wwan-exports.ver delete mode 100644 src/dhcp-manager/Makefile.am delete mode 100644 src/dhcp-manager/Makefile.in delete mode 100644 src/dhcp-manager/nm-dhcp-client-logging.h delete mode 100644 src/dhcp-manager/nm-dhcp-client.c delete mode 100644 src/dhcp-manager/nm-dhcp-client.h delete mode 100644 src/dhcp-manager/nm-dhcp-dhclient-utils.c delete mode 100644 src/dhcp-manager/nm-dhcp-dhclient-utils.h delete mode 100644 src/dhcp-manager/nm-dhcp-dhclient.c delete mode 100644 src/dhcp-manager/nm-dhcp-dhclient.h delete mode 100644 src/dhcp-manager/nm-dhcp-dhcpcd.c delete mode 100644 src/dhcp-manager/nm-dhcp-dhcpcd.h delete mode 100644 src/dhcp-manager/nm-dhcp-helper-api.h delete mode 100644 src/dhcp-manager/nm-dhcp-helper.c delete mode 100644 src/dhcp-manager/nm-dhcp-listener.c delete mode 100644 src/dhcp-manager/nm-dhcp-listener.h delete mode 100644 src/dhcp-manager/nm-dhcp-manager.c delete mode 100644 src/dhcp-manager/nm-dhcp-manager.h delete mode 100644 src/dhcp-manager/nm-dhcp-systemd.c delete mode 100644 src/dhcp-manager/nm-dhcp-systemd.h delete mode 100644 src/dhcp-manager/nm-dhcp-utils.c delete mode 100644 src/dhcp-manager/nm-dhcp-utils.h delete mode 100644 src/dhcp-manager/tests/Makefile.am delete mode 100644 src/dhcp-manager/tests/Makefile.in delete mode 100644 src/dhcp-manager/tests/leases/basic.leases delete mode 100644 src/dhcp-manager/tests/leases/malformed1.leases delete mode 100644 src/dhcp-manager/tests/leases/malformed2.leases delete mode 100644 src/dhcp-manager/tests/leases/malformed3.leases delete mode 100644 src/dhcp-manager/tests/test-dhclient-commented-duid.leases delete mode 100644 src/dhcp-manager/tests/test-dhclient-duid.leases delete mode 100644 src/dhcp-manager/tests/test-dhcp-dhclient.c delete mode 100644 src/dhcp-manager/tests/test-dhcp-utils.c create mode 100644 src/dhcp/nm-dhcp-client-logging.h create mode 100644 src/dhcp/nm-dhcp-client.c create mode 100644 src/dhcp/nm-dhcp-client.h create mode 100644 src/dhcp/nm-dhcp-dhclient-utils.c create mode 100644 src/dhcp/nm-dhcp-dhclient-utils.h create mode 100644 src/dhcp/nm-dhcp-dhclient.c create mode 100644 src/dhcp/nm-dhcp-dhcpcd.c create mode 100644 src/dhcp/nm-dhcp-helper-api.h create mode 100644 src/dhcp/nm-dhcp-helper.c create mode 100644 src/dhcp/nm-dhcp-listener.c create mode 100644 src/dhcp/nm-dhcp-listener.h create mode 100644 src/dhcp/nm-dhcp-manager.c create mode 100644 src/dhcp/nm-dhcp-manager.h create mode 100644 src/dhcp/nm-dhcp-systemd.c create mode 100644 src/dhcp/nm-dhcp-utils.c create mode 100644 src/dhcp/nm-dhcp-utils.h create mode 100644 src/dhcp/tests/leases/basic.leases create mode 100644 src/dhcp/tests/leases/malformed1.leases create mode 100644 src/dhcp/tests/leases/malformed2.leases create mode 100644 src/dhcp/tests/leases/malformed3.leases create mode 100644 src/dhcp/tests/test-dhclient-commented-duid.leases create mode 100644 src/dhcp/tests/test-dhclient-duid.leases create mode 100644 src/dhcp/tests/test-dhcp-dhclient.c create mode 100644 src/dhcp/tests/test-dhcp-utils.c delete mode 100644 src/dns-manager/nm-dns-dnsmasq.c delete mode 100644 src/dns-manager/nm-dns-dnsmasq.h delete mode 100644 src/dns-manager/nm-dns-manager.c delete mode 100644 src/dns-manager/nm-dns-manager.h delete mode 100644 src/dns-manager/nm-dns-plugin.c delete mode 100644 src/dns-manager/nm-dns-plugin.h delete mode 100644 src/dns-manager/nm-dns-unbound.c delete mode 100644 src/dns-manager/nm-dns-unbound.h create mode 100644 src/dns/nm-dns-dnsmasq.c create mode 100644 src/dns/nm-dns-dnsmasq.h create mode 100644 src/dns/nm-dns-manager.c create mode 100644 src/dns/nm-dns-manager.h create mode 100644 src/dns/nm-dns-plugin.c create mode 100644 src/dns/nm-dns-plugin.h create mode 100644 src/dns/nm-dns-systemd-resolved.c create mode 100644 src/dns/nm-dns-systemd-resolved.h create mode 100644 src/dns/nm-dns-unbound.c create mode 100644 src/dns/nm-dns-unbound.h delete mode 100644 src/dnsmasq-manager/nm-dnsmasq-manager.c delete mode 100644 src/dnsmasq-manager/nm-dnsmasq-manager.h delete mode 100644 src/dnsmasq-manager/nm-dnsmasq-utils.c delete mode 100644 src/dnsmasq-manager/nm-dnsmasq-utils.h delete mode 100644 src/dnsmasq-manager/tests/Makefile.am delete mode 100644 src/dnsmasq-manager/tests/Makefile.in delete mode 100644 src/dnsmasq-manager/tests/test-dnsmasq-utils.c create mode 100644 src/dnsmasq/nm-dnsmasq-manager.c create mode 100644 src/dnsmasq/nm-dnsmasq-manager.h create mode 100644 src/dnsmasq/nm-dnsmasq-utils.c create mode 100644 src/dnsmasq/nm-dnsmasq-utils.h create mode 100644 src/dnsmasq/tests/test-dnsmasq-utils.c create mode 100644 src/ndisc/nm-fake-ndisc.c create mode 100644 src/ndisc/nm-fake-ndisc.h create mode 100644 src/ndisc/nm-lndp-ndisc.c create mode 100644 src/ndisc/nm-lndp-ndisc.h create mode 100644 src/ndisc/nm-ndisc-private.h create mode 100644 src/ndisc/nm-ndisc.c create mode 100644 src/ndisc/nm-ndisc.h create mode 100644 src/ndisc/tests/test-ndisc-fake.c create mode 100644 src/ndisc/tests/test-ndisc-linux.c create mode 100644 src/nm-act-request.c create mode 100644 src/nm-act-request.h delete mode 100644 src/nm-activation-request.c delete mode 100644 src/nm-activation-request.h delete mode 100644 src/nm-enum-types.c delete mode 100644 src/nm-enum-types.h create mode 100644 src/nm-pacrunner-manager.c create mode 100644 src/nm-pacrunner-manager.h create mode 100644 src/nm-proxy-config.c create mode 100644 src/nm-proxy-config.h delete mode 100644 src/platform/Makefile.am delete mode 100644 src/platform/Makefile.in delete mode 100644 src/platform/tests/Makefile.am delete mode 100644 src/platform/tests/Makefile.in delete mode 100644 src/ppp-manager/Makefile.am delete mode 100644 src/ppp-manager/Makefile.in delete mode 100644 src/ppp-manager/nm-ppp-manager.c delete mode 100644 src/ppp-manager/nm-ppp-manager.h delete mode 100644 src/ppp-manager/nm-ppp-status.h delete mode 100644 src/ppp-manager/nm-pppd-plugin.c delete mode 100644 src/ppp-manager/nm-pppd-plugin.h create mode 100644 src/ppp/nm-ppp-manager-call.c create mode 100644 src/ppp/nm-ppp-manager-call.h create mode 100644 src/ppp/nm-ppp-manager.c create mode 100644 src/ppp/nm-ppp-manager.h create mode 100644 src/ppp/nm-ppp-plugin-api.h create mode 100644 src/ppp/nm-ppp-plugin.ver create mode 100644 src/ppp/nm-ppp-status.h create mode 100644 src/ppp/nm-pppd-plugin.c create mode 100644 src/ppp/nm-pppd-plugin.h delete mode 100644 src/rdisc/Makefile.am delete mode 100644 src/rdisc/Makefile.in delete mode 100644 src/rdisc/nm-fake-rdisc.c delete mode 100644 src/rdisc/nm-fake-rdisc.h delete mode 100644 src/rdisc/nm-lndp-rdisc.c delete mode 100644 src/rdisc/nm-lndp-rdisc.h delete mode 100644 src/rdisc/nm-rdisc-private.h delete mode 100644 src/rdisc/nm-rdisc.c delete mode 100644 src/rdisc/nm-rdisc.h delete mode 100644 src/rdisc/tests/Makefile.am delete mode 100644 src/rdisc/tests/Makefile.in delete mode 100644 src/rdisc/tests/test-rdisc-fake.c delete mode 100644 src/rdisc/tests/test-rdisc-linux.c delete mode 100644 src/settings/plugins/Makefile.am delete mode 100644 src/settings/plugins/Makefile.in delete mode 100644 src/settings/plugins/ibft/Makefile.am delete mode 100644 src/settings/plugins/ibft/Makefile.in delete mode 100644 src/settings/plugins/ibft/nm-ibft-connection.c delete mode 100644 src/settings/plugins/ibft/nm-ibft-connection.h create mode 100644 src/settings/plugins/ibft/nms-ibft-connection.c create mode 100644 src/settings/plugins/ibft/nms-ibft-connection.h create mode 100644 src/settings/plugins/ibft/nms-ibft-plugin.c create mode 100644 src/settings/plugins/ibft/nms-ibft-plugin.h create mode 100644 src/settings/plugins/ibft/nms-ibft-reader.c create mode 100644 src/settings/plugins/ibft/nms-ibft-reader.h delete mode 100644 src/settings/plugins/ibft/plugin.c delete mode 100644 src/settings/plugins/ibft/plugin.h delete mode 100644 src/settings/plugins/ibft/reader.c delete mode 100644 src/settings/plugins/ibft/reader.h delete mode 100644 src/settings/plugins/ibft/tests/Makefile.am delete mode 100644 src/settings/plugins/ibft/tests/Makefile.in delete mode 100644 src/settings/plugins/ifcfg-rh/Makefile.am delete mode 100644 src/settings/plugins/ifcfg-rh/Makefile.in delete mode 100644 src/settings/plugins/ifcfg-rh/common.h delete mode 100644 src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c delete mode 100644 src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.h create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c create mode 100644 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h delete mode 100644 src/settings/plugins/ifcfg-rh/plugin.c delete mode 100644 src/settings/plugins/ifcfg-rh/plugin.h delete mode 100644 src/settings/plugins/ifcfg-rh/reader.c delete mode 100644 src/settings/plugins/ifcfg-rh/reader.h delete mode 100644 src/settings/plugins/ifcfg-rh/tests/Makefile.am delete mode 100644 src/settings/plugins/ifcfg-rh/tests/Makefile.in delete mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am delete mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-auto-negotiate-on create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-unknown-ethtool-opt create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1 create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1.expected create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2 create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2.expected create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3 create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3.expected create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4 create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4.expected delete mode 100644 src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c delete mode 100644 src/settings/plugins/ifcfg-rh/utils.c delete mode 100644 src/settings/plugins/ifcfg-rh/utils.h delete mode 100644 src/settings/plugins/ifcfg-rh/writer.c delete mode 100644 src/settings/plugins/ifcfg-rh/writer.h delete mode 100644 src/settings/plugins/ifnet/Makefile.am delete mode 100644 src/settings/plugins/ifnet/Makefile.in delete mode 100644 src/settings/plugins/ifnet/connection_parser.c delete mode 100644 src/settings/plugins/ifnet/connection_parser.h delete mode 100644 src/settings/plugins/ifnet/net_parser.c delete mode 100644 src/settings/plugins/ifnet/net_parser.h delete mode 100644 src/settings/plugins/ifnet/net_utils.c delete mode 100644 src/settings/plugins/ifnet/net_utils.h delete mode 100644 src/settings/plugins/ifnet/nm-ifnet-connection.c delete mode 100644 src/settings/plugins/ifnet/nm-ifnet-connection.h create mode 100644 src/settings/plugins/ifnet/nms-ifnet-connection-parser.c create mode 100644 src/settings/plugins/ifnet/nms-ifnet-connection-parser.h create mode 100644 src/settings/plugins/ifnet/nms-ifnet-connection.c create mode 100644 src/settings/plugins/ifnet/nms-ifnet-connection.h create mode 100644 src/settings/plugins/ifnet/nms-ifnet-net-parser.c create mode 100644 src/settings/plugins/ifnet/nms-ifnet-net-parser.h create mode 100644 src/settings/plugins/ifnet/nms-ifnet-net-utils.c create mode 100644 src/settings/plugins/ifnet/nms-ifnet-net-utils.h create mode 100644 src/settings/plugins/ifnet/nms-ifnet-plugin.c create mode 100644 src/settings/plugins/ifnet/nms-ifnet-plugin.h create mode 100644 src/settings/plugins/ifnet/nms-ifnet-wpa-parser.c create mode 100644 src/settings/plugins/ifnet/nms-ifnet-wpa-parser.h delete mode 100644 src/settings/plugins/ifnet/plugin.c delete mode 100644 src/settings/plugins/ifnet/plugin.h delete mode 100644 src/settings/plugins/ifnet/tests/Makefile.am delete mode 100644 src/settings/plugins/ifnet/tests/Makefile.in delete mode 100644 src/settings/plugins/ifnet/wpa_parser.c delete mode 100644 src/settings/plugins/ifnet/wpa_parser.h delete mode 100644 src/settings/plugins/ifupdown/Makefile.am delete mode 100644 src/settings/plugins/ifupdown/Makefile.in delete mode 100644 src/settings/plugins/ifupdown/interface_parser.c delete mode 100644 src/settings/plugins/ifupdown/interface_parser.h delete mode 100644 src/settings/plugins/ifupdown/nm-ifupdown-connection.c delete mode 100644 src/settings/plugins/ifupdown/nm-ifupdown-connection.h create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-connection.c create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-connection.h create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-parser.c create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-parser.h create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-plugin.c create mode 100644 src/settings/plugins/ifupdown/nms-ifupdown-plugin.h delete mode 100644 src/settings/plugins/ifupdown/parser.c delete mode 100644 src/settings/plugins/ifupdown/parser.h delete mode 100644 src/settings/plugins/ifupdown/plugin.c delete mode 100644 src/settings/plugins/ifupdown/plugin.h delete mode 100644 src/settings/plugins/ifupdown/tests/Makefile.am delete mode 100644 src/settings/plugins/ifupdown/tests/Makefile.in delete mode 100644 src/settings/plugins/keyfile/Makefile.am delete mode 100644 src/settings/plugins/keyfile/Makefile.in delete mode 100644 src/settings/plugins/keyfile/nm-keyfile-connection.c delete mode 100644 src/settings/plugins/keyfile/nm-keyfile-connection.h create mode 100644 src/settings/plugins/keyfile/nms-keyfile-connection.c create mode 100644 src/settings/plugins/keyfile/nms-keyfile-connection.h create mode 100644 src/settings/plugins/keyfile/nms-keyfile-plugin.c create mode 100644 src/settings/plugins/keyfile/nms-keyfile-plugin.h create mode 100644 src/settings/plugins/keyfile/nms-keyfile-reader.c create mode 100644 src/settings/plugins/keyfile/nms-keyfile-reader.h create mode 100644 src/settings/plugins/keyfile/nms-keyfile-utils.c create mode 100644 src/settings/plugins/keyfile/nms-keyfile-utils.h create mode 100644 src/settings/plugins/keyfile/nms-keyfile-writer.c create mode 100644 src/settings/plugins/keyfile/nms-keyfile-writer.h delete mode 100644 src/settings/plugins/keyfile/plugin.c delete mode 100644 src/settings/plugins/keyfile/plugin.h delete mode 100644 src/settings/plugins/keyfile/reader.c delete mode 100644 src/settings/plugins/keyfile/reader.h delete mode 100644 src/settings/plugins/keyfile/tests/Makefile.am delete mode 100644 src/settings/plugins/keyfile/tests/Makefile.in delete mode 100644 src/settings/plugins/keyfile/tests/keyfiles/Makefile.am delete mode 100644 src/settings/plugins/keyfile/tests/keyfiles/Makefile.in create mode 100644 src/settings/plugins/keyfile/tests/keyfiles/Test_dcb_connection delete mode 100644 src/settings/plugins/keyfile/utils.c delete mode 100644 src/settings/plugins/keyfile/utils.h delete mode 100644 src/settings/plugins/keyfile/writer.c delete mode 100644 src/settings/plugins/keyfile/writer.h delete mode 100644 src/supplicant-manager/nm-supplicant-config.c delete mode 100644 src/supplicant-manager/nm-supplicant-config.h delete mode 100644 src/supplicant-manager/nm-supplicant-interface.c delete mode 100644 src/supplicant-manager/nm-supplicant-interface.h delete mode 100644 src/supplicant-manager/nm-supplicant-manager.c delete mode 100644 src/supplicant-manager/nm-supplicant-manager.h delete mode 100644 src/supplicant-manager/nm-supplicant-settings-verify.c delete mode 100644 src/supplicant-manager/nm-supplicant-settings-verify.h delete mode 100644 src/supplicant-manager/nm-supplicant-types.h delete mode 100644 src/supplicant-manager/tests/Makefile.am delete mode 100644 src/supplicant-manager/tests/Makefile.in delete mode 100644 src/supplicant-manager/tests/certs/Makefile.am delete mode 100644 src/supplicant-manager/tests/certs/Makefile.in delete mode 100644 src/supplicant-manager/tests/certs/test-ca-cert.pem delete mode 100644 src/supplicant-manager/tests/certs/test-cert.p12 delete mode 100644 src/supplicant-manager/tests/test-supplicant-config.c create mode 100644 src/supplicant/nm-supplicant-config.c create mode 100644 src/supplicant/nm-supplicant-config.h create mode 100644 src/supplicant/nm-supplicant-interface.c create mode 100644 src/supplicant/nm-supplicant-interface.h create mode 100644 src/supplicant/nm-supplicant-manager.c create mode 100644 src/supplicant/nm-supplicant-manager.h create mode 100644 src/supplicant/nm-supplicant-settings-verify.c create mode 100644 src/supplicant/nm-supplicant-settings-verify.h create mode 100644 src/supplicant/nm-supplicant-types.h create mode 100644 src/supplicant/tests/certs/test-ca-cert.pem create mode 100644 src/supplicant/tests/certs/test-cert.p12 create mode 100644 src/supplicant/tests/test-supplicant-config.c create mode 100644 src/systemd/sd-adapt/format-util.h delete mode 100644 src/systemd/sd-adapt/formats-util.h create mode 100644 src/systemd/sd-adapt/glob-util.h create mode 100644 src/systemd/sd-adapt/khash.h delete mode 100644 src/tests/Makefile.am delete mode 100644 src/tests/Makefile.in delete mode 100644 src/tests/config/Makefile.am delete mode 100644 src/tests/config/Makefile.in delete mode 100644 src/vpn-manager/nm-vpn-connection.c delete mode 100644 src/vpn-manager/nm-vpn-connection.h delete mode 100644 src/vpn-manager/nm-vpn-manager.c delete mode 100644 src/vpn-manager/nm-vpn-manager.h create mode 100644 src/vpn/nm-vpn-connection.c create mode 100644 src/vpn/nm-vpn-connection.h create mode 100644 src/vpn/nm-vpn-manager.c create mode 100644 src/vpn/nm-vpn-manager.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 8d29b191..00000000 --- a/src/Makefile.am +++ /dev/null @@ -1,663 +0,0 @@ -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -SUBDIRS = \ - . \ - dhcp-manager \ - ppp-manager \ - settings/plugins \ - devices/adsl - -if WITH_MODEM_MANAGER_1 -SUBDIRS += devices/wwan devices/bluetooth -endif - -if WITH_WIFI -SUBDIRS += devices/wifi -endif - -if WITH_TEAMDCTL -SUBDIRS += devices/team -endif - -if ENABLE_TESTS -SUBDIRS += \ - dhcp-manager/tests \ - dnsmasq-manager/tests \ - platform \ - devices \ - rdisc \ - supplicant-manager/tests \ - tests -endif - -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_builddir)/introspection \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - \ - $(foreach d,$(sort $(dir $(libNetworkManager_la_SOURCES))),-I$(top_srcdir)/src/$d) \ - \ - -DPREFIX=\"$(prefix)\" \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - \ - -DBINDIR=\"$(bindir)\" \ - -DDATADIR=\"$(datadir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ - -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DRUNSTATEDIR=\"$(runstatedir)\" \ - -DSBINDIR=\"$(sbindir)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DRUNDIR=\"$(rundir)\" \ - \ - -DNMCONFDIR=\"$(nmconfdir)\" \ - -DNMLOCALEDIR=\"$(datadir)/locale\" \ - -DNMPLUGINDIR=\"$(pkglibdir)\" \ - -DNMRUNDIR=\"$(nmrundir)\" \ - -DNMSTATEDIR=\"$(nmstatedir)\" \ - -DNMLIBDIR=\"$(nmlibdir)\" \ - \ - -DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \ - -DDHCPCD_PATH=\"$(DHCPCD_PATH)\" \ - -DPPPD_PLUGIN_DIR=\"$(PPPD_PLUGIN_DIR)\" \ - \ - $(GLIB_CFLAGS) \ - $(GUDEV_CFLAGS) \ - $(LIBNL_CFLAGS) \ - $(LIBNDP_CFLAGS) \ - $(LIBSOUP_CFLAGS) \ - $(SELINUX_CFLAGS) \ - $(LIBAUDIT_CFLAGS) \ - $(SYSTEMD_LOGIN_CFLAGS) \ - $(SYSTEMD_JOURNAL_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) \ - \ - -I$(top_srcdir)/src/systemd/src/systemd/ \ - -I$(top_srcdir)/src/systemd/ \ - \ - $(NULL) - -AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) - -sbin_PROGRAMS = \ - NetworkManager - -libexec_PROGRAMS = \ - nm-iface-helper - -noinst_LTLIBRARIES = \ - libNetworkManagerBase.la \ - libNetworkManager.la \ - libNetworkManagerTest.la \ - libnm-iface-helper.la \ - libsystemd-nm.la - -############################################################################### - -libsystemd_nm_la_SOURCES = \ - systemd/nm-sd.c \ - systemd/nm-sd.h \ - systemd/sd-adapt/nm-sd-adapt.c \ - systemd/sd-adapt/nm-sd-adapt.h \ - systemd/sd-adapt/build.h \ - systemd/sd-adapt/cgroup-util.h \ - systemd/sd-adapt/condition.h \ - systemd/sd-adapt/conf-parser.h \ - systemd/sd-adapt/def.h \ - systemd/sd-adapt/dirent-util.h \ - systemd/sd-adapt/formats-util.h \ - systemd/sd-adapt/gunicode.h \ - systemd/sd-adapt/libudev.h \ - systemd/sd-adapt/missing.h \ - systemd/sd-adapt/mkdir.h \ - systemd/sd-adapt/process-util.h \ - systemd/sd-adapt/sd-daemon.h \ - systemd/sd-adapt/stat-util.h \ - systemd/sd-adapt/udev-util.h \ - systemd/sd-adapt/udev.h \ - systemd/sd-adapt/user-util.h \ - systemd/sd-adapt/virt.h \ - systemd/src/basic/alloc-util.c \ - systemd/src/basic/alloc-util.h \ - systemd/src/basic/async.h \ - systemd/src/basic/escape.c \ - systemd/src/basic/escape.h \ - systemd/src/basic/ether-addr-util.c \ - systemd/src/basic/ether-addr-util.h \ - systemd/src/basic/extract-word.c \ - systemd/src/basic/extract-word.h \ - systemd/src/basic/fd-util.c \ - systemd/src/basic/fd-util.h \ - systemd/src/basic/fileio.c \ - systemd/src/basic/fileio.h \ - systemd/src/basic/fs-util.c \ - systemd/src/basic/fs-util.h \ - systemd/src/basic/hash-funcs.c \ - systemd/src/basic/hash-funcs.h \ - systemd/src/basic/hashmap.c \ - systemd/src/basic/hashmap.h \ - systemd/src/basic/hexdecoct.c \ - systemd/src/basic/hexdecoct.h \ - systemd/src/basic/hostname-util.c \ - systemd/src/basic/hostname-util.h \ - systemd/src/basic/in-addr-util.c \ - systemd/src/basic/in-addr-util.h \ - systemd/src/basic/io-util.c \ - systemd/src/basic/io-util.h \ - systemd/src/basic/list.h \ - systemd/src/basic/log.h \ - systemd/src/basic/macro.h \ - systemd/src/basic/mempool.c \ - systemd/src/basic/mempool.h \ - systemd/src/basic/parse-util.c \ - systemd/src/basic/parse-util.h \ - systemd/src/basic/path-util.c \ - systemd/src/basic/path-util.h \ - systemd/src/basic/prioq.c \ - systemd/src/basic/prioq.h \ - systemd/src/basic/random-util.c \ - systemd/src/basic/random-util.h \ - systemd/src/basic/refcnt.h \ - systemd/src/basic/set.h \ - systemd/src/basic/signal-util.h \ - systemd/src/basic/siphash24.c \ - systemd/src/basic/siphash24.h \ - systemd/src/basic/socket-util.c \ - systemd/src/basic/socket-util.h \ - systemd/src/basic/sparse-endian.h \ - systemd/src/basic/stdio-util.h \ - systemd/src/basic/string-table.c \ - systemd/src/basic/string-table.h \ - systemd/src/basic/string-util.c \ - systemd/src/basic/string-util.h \ - systemd/src/basic/strv.c \ - systemd/src/basic/strv.h \ - systemd/src/basic/time-util.c \ - systemd/src/basic/time-util.h \ - systemd/src/basic/umask-util.h \ - systemd/src/basic/unaligned.h \ - systemd/src/basic/utf8.c \ - systemd/src/basic/utf8.h \ - systemd/src/basic/util.c \ - systemd/src/basic/util.h \ - systemd/src/libsystemd-network/arp-util.c \ - systemd/src/libsystemd-network/arp-util.h \ - systemd/src/libsystemd-network/dhcp-identifier.c \ - systemd/src/libsystemd-network/dhcp-identifier.h \ - systemd/src/libsystemd-network/dhcp-internal.h \ - systemd/src/libsystemd-network/dhcp-lease-internal.h \ - systemd/src/libsystemd-network/dhcp-network.c \ - systemd/src/libsystemd-network/dhcp-option.c \ - systemd/src/libsystemd-network/dhcp-packet.c \ - systemd/src/libsystemd-network/dhcp-protocol.h \ - systemd/src/libsystemd-network/dhcp6-internal.h \ - systemd/src/libsystemd-network/dhcp6-lease-internal.h \ - systemd/src/libsystemd-network/dhcp6-network.c \ - systemd/src/libsystemd-network/dhcp6-option.c \ - systemd/src/libsystemd-network/dhcp6-protocol.h \ - systemd/src/libsystemd-network/lldp-internal.h \ - systemd/src/libsystemd-network/lldp-neighbor.c \ - systemd/src/libsystemd-network/lldp-neighbor.h \ - systemd/src/libsystemd-network/lldp-network.c \ - systemd/src/libsystemd-network/lldp-network.h \ - systemd/src/libsystemd-network/network-internal.c \ - systemd/src/libsystemd-network/network-internal.h \ - systemd/src/libsystemd-network/sd-dhcp-client.c \ - systemd/src/libsystemd-network/sd-dhcp-lease.c \ - systemd/src/libsystemd-network/sd-dhcp6-client.c \ - systemd/src/libsystemd-network/sd-dhcp6-lease.c \ - systemd/src/libsystemd-network/sd-ipv4acd.c \ - systemd/src/libsystemd-network/sd-ipv4ll.c \ - systemd/src/libsystemd-network/sd-lldp.c \ - systemd/src/libsystemd/sd-event/sd-event.c \ - systemd/src/libsystemd/sd-id128/id128-util.c \ - systemd/src/libsystemd/sd-id128/id128-util.h \ - systemd/src/libsystemd/sd-id128/sd-id128.c \ - systemd/src/shared/dns-domain.c \ - systemd/src/shared/dns-domain.h \ - systemd/src/systemd/_sd-common.h \ - systemd/src/systemd/sd-dhcp-client.h \ - systemd/src/systemd/sd-dhcp-lease.h \ - systemd/src/systemd/sd-dhcp6-client.h \ - systemd/src/systemd/sd-dhcp6-lease.h \ - systemd/src/systemd/sd-event.h \ - systemd/src/systemd/sd-id128.h \ - systemd/src/systemd/sd-ipv4acd.h \ - systemd/src/systemd/sd-ipv4ll.h \ - systemd/src/systemd/sd-lldp.h \ - systemd/src/systemd/sd-ndisc.h - -libsystemd_nm_la_CPPFLAGS = \ - -I$(top_srcdir)/shared/ \ - -I$(top_builddir)/shared/ \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/systemd/sd-adapt/ \ - -I$(top_srcdir)/src/systemd/src/systemd/ \ - -I$(top_srcdir)/src/systemd/src/basic/ \ - -I$(top_srcdir)/src/systemd/src/shared/ \ - -I$(top_srcdir)/src/systemd/src/libsystemd-network/ \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD \ - $(GLIB_CFLAGS) - -libsystemd_nm_la_LIBADD = \ - $(GLIB_LIBS) - -############################################################################### - -libNetworkManagerBase_la_SOURCES = \ - nm-core-utils.c \ - nm-core-utils.h \ - nm-logging.c \ - nm-logging.h - -libNetworkManagerBase_la_LIBADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(GLIB_LIBS) \ - $(SYSTEMD_JOURNAL_LIBS) \ - $(NULL) - -############################################################################### - -# These source files have a attribute((constructor)) to register their factories. -# This gets stripped out from the resulting binary if we add them to libNetworkManager.la. -# Instead, add them to the binary. An alternative would be to link with --as-needed. - -nm_device_sources = \ - devices/nm-device-bond.c \ - devices/nm-device-bridge.c \ - devices/nm-device-ethernet.c \ - devices/nm-device-infiniband.c \ - devices/nm-device-ip-tunnel.c \ - devices/nm-device-macvlan.c \ - devices/nm-device-tun.c \ - devices/nm-device-veth.c \ - devices/nm-device-vlan.c \ - devices/nm-device-vxlan.c \ - $(NULL) - -nm_device_headers = \ - devices/nm-device-bond.h \ - devices/nm-device-bridge.h \ - devices/nm-device-ethernet.h \ - devices/nm-device-infiniband.h \ - devices/nm-device-ip-tunnel.h \ - devices/nm-device-macvlan.h \ - devices/nm-device-tun.h \ - devices/nm-device-veth.h \ - devices/nm-device-vlan.h \ - devices/nm-device-vxlan.h \ - $(NULL) - -nm_dhcp_client_sources = \ - dhcp-manager/nm-dhcp-dhclient.c \ - dhcp-manager/nm-dhcp-dhcpcd.c \ - dhcp-manager/nm-dhcp-systemd.c \ - $(NULL) - -nm_dhcp_client_headers = \ - dhcp-manager/nm-dhcp-dhclient.h \ - dhcp-manager/nm-dhcp-dhcpcd.h \ - dhcp-manager/nm-dhcp-systemd.h \ - $(NULL) - -############################################################################### - -libNetworkManager_la_SOURCES = \ - \ - dhcp-manager/nm-dhcp-dhclient-utils.c \ - dhcp-manager/nm-dhcp-dhclient-utils.h \ - \ - nm-checkpoint-manager.c \ - nm-checkpoint-manager.h \ - nm-checkpoint.c \ - nm-checkpoint.h \ - \ - devices/nm-device.c \ - devices/nm-device.h \ - devices/nm-lldp-listener.c \ - devices/nm-lldp-listener.h \ - devices/nm-arping-manager.c \ - devices/nm-arping-manager.h \ - devices/nm-device-ethernet-utils.c \ - devices/nm-device-ethernet-utils.h \ - devices/nm-device-factory.c \ - devices/nm-device-factory.h \ - devices/nm-device-generic.c \ - devices/nm-device-generic.h \ - devices/nm-device-logging.h \ - devices/nm-device-private.h \ - \ - dhcp-manager/nm-dhcp-client.c \ - dhcp-manager/nm-dhcp-client.h \ - dhcp-manager/nm-dhcp-client-logging.h \ - dhcp-manager/nm-dhcp-helper-api.h \ - dhcp-manager/nm-dhcp-utils.c \ - dhcp-manager/nm-dhcp-utils.h \ - dhcp-manager/nm-dhcp-listener.c \ - dhcp-manager/nm-dhcp-listener.h \ - dhcp-manager/nm-dhcp-manager.c \ - dhcp-manager/nm-dhcp-manager.h \ - \ - dns-manager/nm-dns-dnsmasq.c \ - dns-manager/nm-dns-dnsmasq.h \ - dns-manager/nm-dns-unbound.c \ - dns-manager/nm-dns-unbound.h \ - dns-manager/nm-dns-manager.c \ - dns-manager/nm-dns-manager.h \ - dns-manager/nm-dns-plugin.c \ - dns-manager/nm-dns-plugin.h \ - \ - dnsmasq-manager/nm-dnsmasq-manager.c \ - dnsmasq-manager/nm-dnsmasq-manager.h \ - dnsmasq-manager/nm-dnsmasq-utils.c \ - dnsmasq-manager/nm-dnsmasq-utils.h \ - \ - platform/nmp-netns.c \ - platform/nmp-netns.h \ - platform/nmp-object.c \ - platform/nmp-object.h \ - platform/nm-platform-utils.c \ - platform/nm-platform-utils.h \ - platform/nm-platform.c \ - platform/nm-platform.h \ - platform/nm-linux-platform.c \ - platform/nm-linux-platform.h \ - platform/wifi/wifi-utils-nl80211.c \ - platform/wifi/wifi-utils-nl80211.h \ - platform/wifi/wifi-utils-private.h \ - platform/wifi/wifi-utils.c \ - platform/wifi/wifi-utils.h \ - \ - rdisc/nm-lndp-rdisc.c \ - rdisc/nm-lndp-rdisc.h \ - rdisc/nm-rdisc.c \ - rdisc/nm-rdisc.h \ - rdisc/nm-rdisc-private.h \ - \ - ppp-manager/nm-ppp-manager.c \ - ppp-manager/nm-ppp-manager.h \ - ppp-manager/nm-ppp-status.h \ - \ - settings/nm-agent-manager.c \ - settings/nm-agent-manager.h \ - settings/nm-inotify-helper.c \ - settings/nm-inotify-helper.h \ - settings/nm-secret-agent.c \ - settings/nm-secret-agent.h \ - settings/nm-settings-connection.c \ - settings/nm-settings-connection.h \ - settings/nm-settings-plugin.c \ - settings/nm-settings-plugin.h \ - settings/nm-settings.c \ - settings/nm-settings.h \ - \ - settings/plugins/keyfile/nm-keyfile-connection.c \ - settings/plugins/keyfile/nm-keyfile-connection.h \ - settings/plugins/keyfile/plugin.c \ - settings/plugins/keyfile/plugin.h \ - settings/plugins/keyfile/reader.c \ - settings/plugins/keyfile/reader.h \ - settings/plugins/keyfile/utils.c \ - settings/plugins/keyfile/utils.h \ - settings/plugins/keyfile/writer.c \ - settings/plugins/keyfile/writer.h \ - \ - supplicant-manager/nm-supplicant-config.c \ - supplicant-manager/nm-supplicant-config.h \ - supplicant-manager/nm-supplicant-interface.c \ - supplicant-manager/nm-supplicant-interface.h \ - supplicant-manager/nm-supplicant-manager.c \ - supplicant-manager/nm-supplicant-manager.h \ - supplicant-manager/nm-supplicant-settings-verify.c \ - supplicant-manager/nm-supplicant-settings-verify.h \ - supplicant-manager/nm-supplicant-types.h \ - \ - vpn-manager/nm-vpn-connection.c \ - vpn-manager/nm-vpn-connection.h \ - vpn-manager/nm-vpn-manager.c \ - vpn-manager/nm-vpn-manager.h \ - \ - nm-activation-request.c \ - nm-activation-request.h \ - nm-active-connection.c \ - nm-active-connection.h \ - nm-audit-manager.c \ - nm-audit-manager.h \ - nm-bus-manager.c \ - nm-bus-manager.h \ - nm-config.c \ - nm-config.h \ - nm-config-data.c \ - nm-config-data.h \ - nm-connectivity.c \ - nm-connectivity.h \ - nm-dcb.c \ - nm-dcb.h \ - nm-route-manager.c \ - nm-route-manager.h \ - nm-default-route-manager.c \ - nm-default-route-manager.h \ - nm-dhcp4-config.c \ - nm-dhcp4-config.h \ - nm-dhcp6-config.c \ - nm-dhcp6-config.h \ - nm-dispatcher.c \ - nm-dispatcher.h \ - nm-enum-types.c \ - nm-enum-types.h \ - nm-exported-object.c \ - nm-exported-object.h \ - nm-firewall-manager.c \ - nm-firewall-manager.h \ - nm-ip4-config.c \ - nm-ip4-config.h \ - nm-ip6-config.c \ - nm-ip6-config.h \ - nm-auth-manager.c \ - nm-auth-manager.h \ - nm-auth-subject.c \ - nm-auth-subject.h \ - nm-auth-utils.c \ - nm-auth-utils.h \ - nm-manager.c \ - nm-manager.h \ - nm-multi-index.c \ - nm-multi-index.h \ - nm-policy.c \ - nm-policy.h \ - nm-rfkill-manager.c \ - nm-rfkill-manager.h \ - nm-session-monitor.h \ - nm-session-monitor.c \ - nm-sleep-monitor.c \ - nm-sleep-monitor.h \ - nm-types.h \ - NetworkManagerUtils.c \ - NetworkManagerUtils.h \ - $(NULL) - -if WITH_WEXT -libNetworkManager_la_SOURCES += \ - platform/wifi/wifi-utils-wext.c \ - platform/wifi/wifi-utils-wext.h -endif - - -libNetworkManager_la_LIBADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(top_builddir)/introspection/libnmdbus.la \ - libNetworkManagerBase.la \ - libsystemd-nm.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) \ - $(LIBNL_LIBS) \ - $(SYSTEMD_LOGIN_LIBS) \ - $(LIBNDP_LIBS) \ - $(DL_LIBS) \ - $(LIBM) \ - $(SELINUX_LIBS) \ - $(LIBAUDIT_LIBS) - -if WITH_LIBSOUP -libNetworkManager_la_LIBADD += $(LIBSOUP_LIBS) -endif - -############################################################################### - -libNetworkManagerTest_la_SOURCES = \ - rdisc/nm-fake-rdisc.c \ - rdisc/nm-fake-rdisc.h \ - platform/nm-fake-platform.c \ - platform/nm-fake-platform.h - -libNetworkManagerTest_la_LIBADD = \ - libNetworkManager.la - -############################################################################### - -NetworkManager_SOURCES = \ - \ - $(nm_device_sources) \ - $(nm_device_headers) \ - \ - $(nm_dhcp_client_sources) \ - $(nm_dhcp_client_headers) \ - \ - main-utils.c \ - main-utils.h \ - main.c - -NetworkManager_LDADD = \ - libNetworkManager.la - -NetworkManager_LDFLAGS = \ - -rdynamic \ - -Wl,--version-script="$(srcdir)/NetworkManager.ver" - -############################################################################### - -libnm_iface_helper_la_SOURCES = \ - \ - dhcp-manager/nm-dhcp-client.c \ - dhcp-manager/nm-dhcp-client.h \ - dhcp-manager/nm-dhcp-client-logging.h \ - dhcp-manager/nm-dhcp-utils.c \ - dhcp-manager/nm-dhcp-utils.h \ - dhcp-manager/nm-dhcp-manager.c \ - dhcp-manager/nm-dhcp-manager.h \ - \ - platform/nmp-netns.c \ - platform/nmp-netns.h \ - platform/nmp-object.c \ - platform/nmp-object.h \ - platform/nm-platform-utils.c \ - platform/nm-platform-utils.h \ - platform/nm-platform.c \ - platform/nm-platform.h \ - platform/nm-linux-platform.c \ - platform/nm-linux-platform.h \ - platform/wifi/wifi-utils-nl80211.c \ - platform/wifi/wifi-utils-nl80211.h \ - platform/wifi/wifi-utils-private.h \ - platform/wifi/wifi-utils.c \ - platform/wifi/wifi-utils.h \ - \ - rdisc/nm-lndp-rdisc.c \ - rdisc/nm-lndp-rdisc.h \ - rdisc/nm-rdisc.c \ - rdisc/nm-rdisc.h \ - \ - nm-route-manager.c \ - nm-route-manager.h \ - \ - nm-exported-object.c \ - nm-exported-object.h \ - nm-ip4-config.c \ - nm-ip4-config.h \ - nm-ip6-config.c \ - nm-ip6-config.h \ - \ - nm-enum-types.c \ - nm-enum-types.h \ - nm-multi-index.c \ - nm-multi-index.h \ - NetworkManagerUtils.c \ - NetworkManagerUtils.h - -if WITH_WEXT -libnm_iface_helper_la_SOURCES += \ - platform/wifi/wifi-utils-wext.c \ - platform/wifi/wifi-utils-wext.h -endif - -libnm_iface_helper_la_LIBADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(top_builddir)/introspection/libnmdbus.la \ - libNetworkManagerBase.la \ - libsystemd-nm.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) \ - $(LIBNL_LIBS) \ - $(LIBNDP_LIBS) \ - $(DL_LIBS) \ - $(LIBM) - -nm_iface_helper_SOURCES = \ - dhcp-manager/nm-dhcp-systemd.h \ - dhcp-manager/nm-dhcp-systemd.c \ - nm-iface-helper.c \ - main-utils.c \ - main-utils.h - -nm_iface_helper_LDADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - libnm-iface-helper.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) \ - $(LIBNL_LIBS) \ - $(LIBNDP_LIBS) \ - $(LIBM) - -nm_iface_helper_LDFLAGS = \ - -rdynamic - -############################################################################### - -GLIB_GENERATED = nm-enum-types.h nm-enum-types.c -GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM --fhead '\#include \n' -GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM --fhead '\#include "nm-default.h"\n' -nm_enum_types_sources = $(filter-out \ - %/nm-device-private.h \ - %/nm-rdisc-private.h \ - %/wifi-utils-private.h \ - %/nm-dhcp-client-logging.h \ - %/nm-device-logging.h \ - , $(libNetworkManager_la_SOURCES)) - -BUILT_SOURCES = $(GLIB_GENERATED) - -############################################################################### - -dbusservicedir = $(DBUS_SYS_DIR) -dbusservice_DATA = org.freedesktop.NetworkManager.conf - -EXTRA_DIST = \ - $(dbusservice_DATA) \ - $(NetworkManager_DATA) \ - nm-test-utils-core.h \ - NetworkManager.ver - -rundir=$(runstatedir)/NetworkManager -statedir=$(localstatedir)/lib/NetworkManager -install-data-hook: - $(mkinstalldirs) -m 0755 $(DESTDIR)$(rundir) - $(mkinstalldirs) -m 0700 $(DESTDIR)$(statedir) - $(mkinstalldirs) -m 0755 $(DESTDIR)$(pkglibdir) - -CLEANFILES = \ - $(BUILT_SOURCES) diff --git a/src/Makefile.in b/src/Makefile.in deleted file mode 100644 index d7a37db5..00000000 --- a/src/Makefile.in +++ /dev/null @@ -1,2803 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@WITH_MODEM_MANAGER_1_TRUE@am__append_1 = devices/wwan devices/bluetooth -@WITH_WIFI_TRUE@am__append_2 = devices/wifi -@WITH_TEAMDCTL_TRUE@am__append_3 = devices/team -@ENABLE_TESTS_TRUE@am__append_4 = \ -@ENABLE_TESTS_TRUE@ dhcp-manager/tests \ -@ENABLE_TESTS_TRUE@ dnsmasq-manager/tests \ -@ENABLE_TESTS_TRUE@ platform \ -@ENABLE_TESTS_TRUE@ devices \ -@ENABLE_TESTS_TRUE@ rdisc \ -@ENABLE_TESTS_TRUE@ supplicant-manager/tests \ -@ENABLE_TESTS_TRUE@ tests - -sbin_PROGRAMS = NetworkManager$(EXEEXT) -libexec_PROGRAMS = nm-iface-helper$(EXEEXT) -@WITH_WEXT_TRUE@am__append_5 = \ -@WITH_WEXT_TRUE@ platform/wifi/wifi-utils-wext.c \ -@WITH_WEXT_TRUE@ platform/wifi/wifi-utils-wext.h - -@WITH_LIBSOUP_TRUE@am__append_6 = $(LIBSOUP_LIBS) -@WITH_WEXT_TRUE@am__append_7 = \ -@WITH_WEXT_TRUE@ platform/wifi/wifi-utils-wext.c \ -@WITH_WEXT_TRUE@ platform/wifi/wifi-utils-wext.h - -subdir = src -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LTLIBRARIES = $(noinst_LTLIBRARIES) -am__DEPENDENCIES_1 = -@WITH_LIBSOUP_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) -libNetworkManager_la_DEPENDENCIES = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(top_builddir)/introspection/libnmdbus.la \ - libNetworkManagerBase.la libsystemd-nm.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) -am__libNetworkManager_la_SOURCES_DIST = \ - dhcp-manager/nm-dhcp-dhclient-utils.c \ - dhcp-manager/nm-dhcp-dhclient-utils.h nm-checkpoint-manager.c \ - nm-checkpoint-manager.h nm-checkpoint.c nm-checkpoint.h \ - devices/nm-device.c devices/nm-device.h \ - devices/nm-lldp-listener.c devices/nm-lldp-listener.h \ - devices/nm-arping-manager.c devices/nm-arping-manager.h \ - devices/nm-device-ethernet-utils.c \ - devices/nm-device-ethernet-utils.h devices/nm-device-factory.c \ - devices/nm-device-factory.h devices/nm-device-generic.c \ - devices/nm-device-generic.h devices/nm-device-logging.h \ - devices/nm-device-private.h dhcp-manager/nm-dhcp-client.c \ - dhcp-manager/nm-dhcp-client.h \ - dhcp-manager/nm-dhcp-client-logging.h \ - dhcp-manager/nm-dhcp-helper-api.h dhcp-manager/nm-dhcp-utils.c \ - dhcp-manager/nm-dhcp-utils.h dhcp-manager/nm-dhcp-listener.c \ - dhcp-manager/nm-dhcp-listener.h dhcp-manager/nm-dhcp-manager.c \ - dhcp-manager/nm-dhcp-manager.h dns-manager/nm-dns-dnsmasq.c \ - dns-manager/nm-dns-dnsmasq.h dns-manager/nm-dns-unbound.c \ - dns-manager/nm-dns-unbound.h dns-manager/nm-dns-manager.c \ - dns-manager/nm-dns-manager.h dns-manager/nm-dns-plugin.c \ - dns-manager/nm-dns-plugin.h \ - dnsmasq-manager/nm-dnsmasq-manager.c \ - dnsmasq-manager/nm-dnsmasq-manager.h \ - dnsmasq-manager/nm-dnsmasq-utils.c \ - dnsmasq-manager/nm-dnsmasq-utils.h platform/nmp-netns.c \ - platform/nmp-netns.h platform/nmp-object.c \ - platform/nmp-object.h platform/nm-platform-utils.c \ - platform/nm-platform-utils.h platform/nm-platform.c \ - platform/nm-platform.h platform/nm-linux-platform.c \ - platform/nm-linux-platform.h \ - platform/wifi/wifi-utils-nl80211.c \ - platform/wifi/wifi-utils-nl80211.h \ - platform/wifi/wifi-utils-private.h platform/wifi/wifi-utils.c \ - platform/wifi/wifi-utils.h rdisc/nm-lndp-rdisc.c \ - rdisc/nm-lndp-rdisc.h rdisc/nm-rdisc.c rdisc/nm-rdisc.h \ - rdisc/nm-rdisc-private.h ppp-manager/nm-ppp-manager.c \ - ppp-manager/nm-ppp-manager.h ppp-manager/nm-ppp-status.h \ - settings/nm-agent-manager.c settings/nm-agent-manager.h \ - settings/nm-inotify-helper.c settings/nm-inotify-helper.h \ - settings/nm-secret-agent.c settings/nm-secret-agent.h \ - settings/nm-settings-connection.c \ - settings/nm-settings-connection.h \ - settings/nm-settings-plugin.c settings/nm-settings-plugin.h \ - settings/nm-settings.c settings/nm-settings.h \ - settings/plugins/keyfile/nm-keyfile-connection.c \ - settings/plugins/keyfile/nm-keyfile-connection.h \ - settings/plugins/keyfile/plugin.c \ - settings/plugins/keyfile/plugin.h \ - settings/plugins/keyfile/reader.c \ - settings/plugins/keyfile/reader.h \ - settings/plugins/keyfile/utils.c \ - settings/plugins/keyfile/utils.h \ - settings/plugins/keyfile/writer.c \ - settings/plugins/keyfile/writer.h \ - supplicant-manager/nm-supplicant-config.c \ - supplicant-manager/nm-supplicant-config.h \ - supplicant-manager/nm-supplicant-interface.c \ - supplicant-manager/nm-supplicant-interface.h \ - supplicant-manager/nm-supplicant-manager.c \ - supplicant-manager/nm-supplicant-manager.h \ - supplicant-manager/nm-supplicant-settings-verify.c \ - supplicant-manager/nm-supplicant-settings-verify.h \ - supplicant-manager/nm-supplicant-types.h \ - vpn-manager/nm-vpn-connection.c \ - vpn-manager/nm-vpn-connection.h vpn-manager/nm-vpn-manager.c \ - vpn-manager/nm-vpn-manager.h nm-activation-request.c \ - nm-activation-request.h nm-active-connection.c \ - nm-active-connection.h nm-audit-manager.c nm-audit-manager.h \ - nm-bus-manager.c nm-bus-manager.h nm-config.c nm-config.h \ - nm-config-data.c nm-config-data.h nm-connectivity.c \ - nm-connectivity.h nm-dcb.c nm-dcb.h nm-route-manager.c \ - nm-route-manager.h nm-default-route-manager.c \ - nm-default-route-manager.h nm-dhcp4-config.c nm-dhcp4-config.h \ - nm-dhcp6-config.c nm-dhcp6-config.h nm-dispatcher.c \ - nm-dispatcher.h nm-enum-types.c nm-enum-types.h \ - nm-exported-object.c nm-exported-object.h \ - nm-firewall-manager.c nm-firewall-manager.h nm-ip4-config.c \ - nm-ip4-config.h nm-ip6-config.c nm-ip6-config.h \ - nm-auth-manager.c nm-auth-manager.h nm-auth-subject.c \ - nm-auth-subject.h nm-auth-utils.c nm-auth-utils.h nm-manager.c \ - nm-manager.h nm-multi-index.c nm-multi-index.h nm-policy.c \ - nm-policy.h nm-rfkill-manager.c nm-rfkill-manager.h \ - nm-session-monitor.h nm-session-monitor.c nm-sleep-monitor.c \ - nm-sleep-monitor.h nm-types.h NetworkManagerUtils.c \ - NetworkManagerUtils.h platform/wifi/wifi-utils-wext.c \ - platform/wifi/wifi-utils-wext.h -@WITH_WEXT_TRUE@am__objects_1 = wifi-utils-wext.lo -am_libNetworkManager_la_OBJECTS = nm-dhcp-dhclient-utils.lo \ - nm-checkpoint-manager.lo nm-checkpoint.lo nm-device.lo \ - nm-lldp-listener.lo nm-arping-manager.lo \ - nm-device-ethernet-utils.lo nm-device-factory.lo \ - nm-device-generic.lo nm-dhcp-client.lo nm-dhcp-utils.lo \ - nm-dhcp-listener.lo nm-dhcp-manager.lo nm-dns-dnsmasq.lo \ - nm-dns-unbound.lo nm-dns-manager.lo nm-dns-plugin.lo \ - nm-dnsmasq-manager.lo nm-dnsmasq-utils.lo nmp-netns.lo \ - nmp-object.lo nm-platform-utils.lo nm-platform.lo \ - nm-linux-platform.lo wifi-utils-nl80211.lo wifi-utils.lo \ - nm-lndp-rdisc.lo nm-rdisc.lo nm-ppp-manager.lo \ - nm-agent-manager.lo nm-inotify-helper.lo nm-secret-agent.lo \ - nm-settings-connection.lo nm-settings-plugin.lo nm-settings.lo \ - nm-keyfile-connection.lo plugin.lo reader.lo utils.lo \ - writer.lo nm-supplicant-config.lo nm-supplicant-interface.lo \ - nm-supplicant-manager.lo nm-supplicant-settings-verify.lo \ - nm-vpn-connection.lo nm-vpn-manager.lo \ - nm-activation-request.lo nm-active-connection.lo \ - nm-audit-manager.lo nm-bus-manager.lo nm-config.lo \ - nm-config-data.lo nm-connectivity.lo nm-dcb.lo \ - nm-route-manager.lo nm-default-route-manager.lo \ - nm-dhcp4-config.lo nm-dhcp6-config.lo nm-dispatcher.lo \ - nm-enum-types.lo nm-exported-object.lo nm-firewall-manager.lo \ - nm-ip4-config.lo nm-ip6-config.lo nm-auth-manager.lo \ - nm-auth-subject.lo nm-auth-utils.lo nm-manager.lo \ - nm-multi-index.lo nm-policy.lo nm-rfkill-manager.lo \ - nm-session-monitor.lo nm-sleep-monitor.lo \ - NetworkManagerUtils.lo $(am__objects_1) -libNetworkManager_la_OBJECTS = $(am_libNetworkManager_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libNetworkManagerBase_la_DEPENDENCIES = \ - $(top_builddir)/libnm-core/libnm-core.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) -am_libNetworkManagerBase_la_OBJECTS = nm-core-utils.lo nm-logging.lo -libNetworkManagerBase_la_OBJECTS = \ - $(am_libNetworkManagerBase_la_OBJECTS) -libNetworkManagerTest_la_DEPENDENCIES = libNetworkManager.la -am_libNetworkManagerTest_la_OBJECTS = nm-fake-rdisc.lo \ - nm-fake-platform.lo -libNetworkManagerTest_la_OBJECTS = \ - $(am_libNetworkManagerTest_la_OBJECTS) -libnm_iface_helper_la_DEPENDENCIES = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(top_builddir)/introspection/libnmdbus.la \ - libNetworkManagerBase.la libsystemd-nm.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am__libnm_iface_helper_la_SOURCES_DIST = \ - dhcp-manager/nm-dhcp-client.c dhcp-manager/nm-dhcp-client.h \ - dhcp-manager/nm-dhcp-client-logging.h \ - dhcp-manager/nm-dhcp-utils.c dhcp-manager/nm-dhcp-utils.h \ - dhcp-manager/nm-dhcp-manager.c dhcp-manager/nm-dhcp-manager.h \ - platform/nmp-netns.c platform/nmp-netns.h \ - platform/nmp-object.c platform/nmp-object.h \ - platform/nm-platform-utils.c platform/nm-platform-utils.h \ - platform/nm-platform.c platform/nm-platform.h \ - platform/nm-linux-platform.c platform/nm-linux-platform.h \ - platform/wifi/wifi-utils-nl80211.c \ - platform/wifi/wifi-utils-nl80211.h \ - platform/wifi/wifi-utils-private.h platform/wifi/wifi-utils.c \ - platform/wifi/wifi-utils.h rdisc/nm-lndp-rdisc.c \ - rdisc/nm-lndp-rdisc.h rdisc/nm-rdisc.c rdisc/nm-rdisc.h \ - nm-route-manager.c nm-route-manager.h nm-exported-object.c \ - nm-exported-object.h nm-ip4-config.c nm-ip4-config.h \ - nm-ip6-config.c nm-ip6-config.h nm-enum-types.c \ - nm-enum-types.h nm-multi-index.c nm-multi-index.h \ - NetworkManagerUtils.c NetworkManagerUtils.h \ - platform/wifi/wifi-utils-wext.c \ - platform/wifi/wifi-utils-wext.h -am_libnm_iface_helper_la_OBJECTS = nm-dhcp-client.lo nm-dhcp-utils.lo \ - nm-dhcp-manager.lo nmp-netns.lo nmp-object.lo \ - nm-platform-utils.lo nm-platform.lo nm-linux-platform.lo \ - wifi-utils-nl80211.lo wifi-utils.lo nm-lndp-rdisc.lo \ - nm-rdisc.lo nm-route-manager.lo nm-exported-object.lo \ - nm-ip4-config.lo nm-ip6-config.lo nm-enum-types.lo \ - nm-multi-index.lo NetworkManagerUtils.lo $(am__objects_1) -libnm_iface_helper_la_OBJECTS = $(am_libnm_iface_helper_la_OBJECTS) -libsystemd_nm_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_libsystemd_nm_la_OBJECTS = libsystemd_nm_la-nm-sd.lo \ - libsystemd_nm_la-nm-sd-adapt.lo libsystemd_nm_la-alloc-util.lo \ - libsystemd_nm_la-escape.lo libsystemd_nm_la-ether-addr-util.lo \ - libsystemd_nm_la-extract-word.lo libsystemd_nm_la-fd-util.lo \ - libsystemd_nm_la-fileio.lo libsystemd_nm_la-fs-util.lo \ - libsystemd_nm_la-hash-funcs.lo libsystemd_nm_la-hashmap.lo \ - libsystemd_nm_la-hexdecoct.lo \ - libsystemd_nm_la-hostname-util.lo \ - libsystemd_nm_la-in-addr-util.lo libsystemd_nm_la-io-util.lo \ - libsystemd_nm_la-mempool.lo libsystemd_nm_la-parse-util.lo \ - libsystemd_nm_la-path-util.lo libsystemd_nm_la-prioq.lo \ - libsystemd_nm_la-random-util.lo libsystemd_nm_la-siphash24.lo \ - libsystemd_nm_la-socket-util.lo \ - libsystemd_nm_la-string-table.lo \ - libsystemd_nm_la-string-util.lo libsystemd_nm_la-strv.lo \ - libsystemd_nm_la-time-util.lo libsystemd_nm_la-utf8.lo \ - libsystemd_nm_la-util.lo libsystemd_nm_la-arp-util.lo \ - libsystemd_nm_la-dhcp-identifier.lo \ - libsystemd_nm_la-dhcp-network.lo \ - libsystemd_nm_la-dhcp-option.lo \ - libsystemd_nm_la-dhcp-packet.lo \ - libsystemd_nm_la-dhcp6-network.lo \ - libsystemd_nm_la-dhcp6-option.lo \ - libsystemd_nm_la-lldp-neighbor.lo \ - libsystemd_nm_la-lldp-network.lo \ - libsystemd_nm_la-network-internal.lo \ - libsystemd_nm_la-sd-dhcp-client.lo \ - libsystemd_nm_la-sd-dhcp-lease.lo \ - libsystemd_nm_la-sd-dhcp6-client.lo \ - libsystemd_nm_la-sd-dhcp6-lease.lo \ - libsystemd_nm_la-sd-ipv4acd.lo libsystemd_nm_la-sd-ipv4ll.lo \ - libsystemd_nm_la-sd-lldp.lo libsystemd_nm_la-sd-event.lo \ - libsystemd_nm_la-id128-util.lo libsystemd_nm_la-sd-id128.lo \ - libsystemd_nm_la-dns-domain.lo -libsystemd_nm_la_OBJECTS = $(am_libsystemd_nm_la_OBJECTS) -am__installdirs = "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(sbindir)" \ - "$(DESTDIR)$(dbusservicedir)" -PROGRAMS = $(libexec_PROGRAMS) $(sbin_PROGRAMS) -am__objects_2 = nm-device-bond.$(OBJEXT) nm-device-bridge.$(OBJEXT) \ - nm-device-ethernet.$(OBJEXT) nm-device-infiniband.$(OBJEXT) \ - nm-device-ip-tunnel.$(OBJEXT) nm-device-macvlan.$(OBJEXT) \ - nm-device-tun.$(OBJEXT) nm-device-veth.$(OBJEXT) \ - nm-device-vlan.$(OBJEXT) nm-device-vxlan.$(OBJEXT) -am__objects_3 = -am__objects_4 = nm-dhcp-dhclient.$(OBJEXT) nm-dhcp-dhcpcd.$(OBJEXT) \ - nm-dhcp-systemd.$(OBJEXT) -am_NetworkManager_OBJECTS = $(am__objects_2) $(am__objects_3) \ - $(am__objects_4) $(am__objects_3) main-utils.$(OBJEXT) \ - main.$(OBJEXT) -NetworkManager_OBJECTS = $(am_NetworkManager_OBJECTS) -NetworkManager_DEPENDENCIES = libNetworkManager.la -NetworkManager_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(NetworkManager_LDFLAGS) $(LDFLAGS) -o \ - $@ -am_nm_iface_helper_OBJECTS = nm-dhcp-systemd.$(OBJEXT) \ - nm-iface-helper.$(OBJEXT) main-utils.$(OBJEXT) -nm_iface_helper_OBJECTS = $(am_nm_iface_helper_OBJECTS) -nm_iface_helper_DEPENDENCIES = \ - $(top_builddir)/libnm-core/libnm-core.la libnm-iface-helper.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) -nm_iface_helper_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(nm_iface_helper_LDFLAGS) $(LDFLAGS) \ - -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libNetworkManager_la_SOURCES) \ - $(libNetworkManagerBase_la_SOURCES) \ - $(libNetworkManagerTest_la_SOURCES) \ - $(libnm_iface_helper_la_SOURCES) $(libsystemd_nm_la_SOURCES) \ - $(NetworkManager_SOURCES) $(nm_iface_helper_SOURCES) -DIST_SOURCES = $(am__libNetworkManager_la_SOURCES_DIST) \ - $(libNetworkManagerBase_la_SOURCES) \ - $(libNetworkManagerTest_la_SOURCES) \ - $(am__libnm_iface_helper_la_SOURCES_DIST) \ - $(libsystemd_nm_la_SOURCES) $(NetworkManager_SOURCES) \ - $(nm_iface_helper_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -DATA = $(dbusservice_DATA) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = . dhcp-manager ppp-manager settings/plugins \ - devices/adsl devices/wwan devices/bluetooth devices/wifi \ - devices/team dhcp-manager/tests dnsmasq-manager/tests platform \ - devices rdisc supplicant-manager/tests tests -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = . dhcp-manager ppp-manager settings/plugins devices/adsl \ - $(am__append_1) $(am__append_2) $(am__append_3) \ - $(am__append_4) -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_builddir)/introspection \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - \ - $(foreach d,$(sort $(dir $(libNetworkManager_la_SOURCES))),-I$(top_srcdir)/src/$d) \ - \ - -DPREFIX=\"$(prefix)\" \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - \ - -DBINDIR=\"$(bindir)\" \ - -DDATADIR=\"$(datadir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ - -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DRUNSTATEDIR=\"$(runstatedir)\" \ - -DSBINDIR=\"$(sbindir)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DRUNDIR=\"$(rundir)\" \ - \ - -DNMCONFDIR=\"$(nmconfdir)\" \ - -DNMLOCALEDIR=\"$(datadir)/locale\" \ - -DNMPLUGINDIR=\"$(pkglibdir)\" \ - -DNMRUNDIR=\"$(nmrundir)\" \ - -DNMSTATEDIR=\"$(nmstatedir)\" \ - -DNMLIBDIR=\"$(nmlibdir)\" \ - \ - -DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \ - -DDHCPCD_PATH=\"$(DHCPCD_PATH)\" \ - -DPPPD_PLUGIN_DIR=\"$(PPPD_PLUGIN_DIR)\" \ - \ - $(GLIB_CFLAGS) \ - $(GUDEV_CFLAGS) \ - $(LIBNL_CFLAGS) \ - $(LIBNDP_CFLAGS) \ - $(LIBSOUP_CFLAGS) \ - $(SELINUX_CFLAGS) \ - $(LIBAUDIT_CFLAGS) \ - $(SYSTEMD_LOGIN_CFLAGS) \ - $(SYSTEMD_JOURNAL_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) \ - \ - -I$(top_srcdir)/src/systemd/src/systemd/ \ - -I$(top_srcdir)/src/systemd/ \ - \ - $(NULL) - -AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) -noinst_LTLIBRARIES = \ - libNetworkManagerBase.la \ - libNetworkManager.la \ - libNetworkManagerTest.la \ - libnm-iface-helper.la \ - libsystemd-nm.la - - -############################################################################### -libsystemd_nm_la_SOURCES = \ - systemd/nm-sd.c \ - systemd/nm-sd.h \ - systemd/sd-adapt/nm-sd-adapt.c \ - systemd/sd-adapt/nm-sd-adapt.h \ - systemd/sd-adapt/build.h \ - systemd/sd-adapt/cgroup-util.h \ - systemd/sd-adapt/condition.h \ - systemd/sd-adapt/conf-parser.h \ - systemd/sd-adapt/def.h \ - systemd/sd-adapt/dirent-util.h \ - systemd/sd-adapt/formats-util.h \ - systemd/sd-adapt/gunicode.h \ - systemd/sd-adapt/libudev.h \ - systemd/sd-adapt/missing.h \ - systemd/sd-adapt/mkdir.h \ - systemd/sd-adapt/process-util.h \ - systemd/sd-adapt/sd-daemon.h \ - systemd/sd-adapt/stat-util.h \ - systemd/sd-adapt/udev-util.h \ - systemd/sd-adapt/udev.h \ - systemd/sd-adapt/user-util.h \ - systemd/sd-adapt/virt.h \ - systemd/src/basic/alloc-util.c \ - systemd/src/basic/alloc-util.h \ - systemd/src/basic/async.h \ - systemd/src/basic/escape.c \ - systemd/src/basic/escape.h \ - systemd/src/basic/ether-addr-util.c \ - systemd/src/basic/ether-addr-util.h \ - systemd/src/basic/extract-word.c \ - systemd/src/basic/extract-word.h \ - systemd/src/basic/fd-util.c \ - systemd/src/basic/fd-util.h \ - systemd/src/basic/fileio.c \ - systemd/src/basic/fileio.h \ - systemd/src/basic/fs-util.c \ - systemd/src/basic/fs-util.h \ - systemd/src/basic/hash-funcs.c \ - systemd/src/basic/hash-funcs.h \ - systemd/src/basic/hashmap.c \ - systemd/src/basic/hashmap.h \ - systemd/src/basic/hexdecoct.c \ - systemd/src/basic/hexdecoct.h \ - systemd/src/basic/hostname-util.c \ - systemd/src/basic/hostname-util.h \ - systemd/src/basic/in-addr-util.c \ - systemd/src/basic/in-addr-util.h \ - systemd/src/basic/io-util.c \ - systemd/src/basic/io-util.h \ - systemd/src/basic/list.h \ - systemd/src/basic/log.h \ - systemd/src/basic/macro.h \ - systemd/src/basic/mempool.c \ - systemd/src/basic/mempool.h \ - systemd/src/basic/parse-util.c \ - systemd/src/basic/parse-util.h \ - systemd/src/basic/path-util.c \ - systemd/src/basic/path-util.h \ - systemd/src/basic/prioq.c \ - systemd/src/basic/prioq.h \ - systemd/src/basic/random-util.c \ - systemd/src/basic/random-util.h \ - systemd/src/basic/refcnt.h \ - systemd/src/basic/set.h \ - systemd/src/basic/signal-util.h \ - systemd/src/basic/siphash24.c \ - systemd/src/basic/siphash24.h \ - systemd/src/basic/socket-util.c \ - systemd/src/basic/socket-util.h \ - systemd/src/basic/sparse-endian.h \ - systemd/src/basic/stdio-util.h \ - systemd/src/basic/string-table.c \ - systemd/src/basic/string-table.h \ - systemd/src/basic/string-util.c \ - systemd/src/basic/string-util.h \ - systemd/src/basic/strv.c \ - systemd/src/basic/strv.h \ - systemd/src/basic/time-util.c \ - systemd/src/basic/time-util.h \ - systemd/src/basic/umask-util.h \ - systemd/src/basic/unaligned.h \ - systemd/src/basic/utf8.c \ - systemd/src/basic/utf8.h \ - systemd/src/basic/util.c \ - systemd/src/basic/util.h \ - systemd/src/libsystemd-network/arp-util.c \ - systemd/src/libsystemd-network/arp-util.h \ - systemd/src/libsystemd-network/dhcp-identifier.c \ - systemd/src/libsystemd-network/dhcp-identifier.h \ - systemd/src/libsystemd-network/dhcp-internal.h \ - systemd/src/libsystemd-network/dhcp-lease-internal.h \ - systemd/src/libsystemd-network/dhcp-network.c \ - systemd/src/libsystemd-network/dhcp-option.c \ - systemd/src/libsystemd-network/dhcp-packet.c \ - systemd/src/libsystemd-network/dhcp-protocol.h \ - systemd/src/libsystemd-network/dhcp6-internal.h \ - systemd/src/libsystemd-network/dhcp6-lease-internal.h \ - systemd/src/libsystemd-network/dhcp6-network.c \ - systemd/src/libsystemd-network/dhcp6-option.c \ - systemd/src/libsystemd-network/dhcp6-protocol.h \ - systemd/src/libsystemd-network/lldp-internal.h \ - systemd/src/libsystemd-network/lldp-neighbor.c \ - systemd/src/libsystemd-network/lldp-neighbor.h \ - systemd/src/libsystemd-network/lldp-network.c \ - systemd/src/libsystemd-network/lldp-network.h \ - systemd/src/libsystemd-network/network-internal.c \ - systemd/src/libsystemd-network/network-internal.h \ - systemd/src/libsystemd-network/sd-dhcp-client.c \ - systemd/src/libsystemd-network/sd-dhcp-lease.c \ - systemd/src/libsystemd-network/sd-dhcp6-client.c \ - systemd/src/libsystemd-network/sd-dhcp6-lease.c \ - systemd/src/libsystemd-network/sd-ipv4acd.c \ - systemd/src/libsystemd-network/sd-ipv4ll.c \ - systemd/src/libsystemd-network/sd-lldp.c \ - systemd/src/libsystemd/sd-event/sd-event.c \ - systemd/src/libsystemd/sd-id128/id128-util.c \ - systemd/src/libsystemd/sd-id128/id128-util.h \ - systemd/src/libsystemd/sd-id128/sd-id128.c \ - systemd/src/shared/dns-domain.c \ - systemd/src/shared/dns-domain.h \ - systemd/src/systemd/_sd-common.h \ - systemd/src/systemd/sd-dhcp-client.h \ - systemd/src/systemd/sd-dhcp-lease.h \ - systemd/src/systemd/sd-dhcp6-client.h \ - systemd/src/systemd/sd-dhcp6-lease.h \ - systemd/src/systemd/sd-event.h \ - systemd/src/systemd/sd-id128.h \ - systemd/src/systemd/sd-ipv4acd.h \ - systemd/src/systemd/sd-ipv4ll.h \ - systemd/src/systemd/sd-lldp.h \ - systemd/src/systemd/sd-ndisc.h - -libsystemd_nm_la_CPPFLAGS = \ - -I$(top_srcdir)/shared/ \ - -I$(top_builddir)/shared/ \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/systemd/sd-adapt/ \ - -I$(top_srcdir)/src/systemd/src/systemd/ \ - -I$(top_srcdir)/src/systemd/src/basic/ \ - -I$(top_srcdir)/src/systemd/src/shared/ \ - -I$(top_srcdir)/src/systemd/src/libsystemd-network/ \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD \ - $(GLIB_CFLAGS) - -libsystemd_nm_la_LIBADD = \ - $(GLIB_LIBS) - - -############################################################################### -libNetworkManagerBase_la_SOURCES = \ - nm-core-utils.c \ - nm-core-utils.h \ - nm-logging.c \ - nm-logging.h - -libNetworkManagerBase_la_LIBADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(GLIB_LIBS) \ - $(SYSTEMD_JOURNAL_LIBS) \ - $(NULL) - - -############################################################################### - -# These source files have a attribute((constructor)) to register their factories. -# This gets stripped out from the resulting binary if we add them to libNetworkManager.la. -# Instead, add them to the binary. An alternative would be to link with --as-needed. -nm_device_sources = \ - devices/nm-device-bond.c \ - devices/nm-device-bridge.c \ - devices/nm-device-ethernet.c \ - devices/nm-device-infiniband.c \ - devices/nm-device-ip-tunnel.c \ - devices/nm-device-macvlan.c \ - devices/nm-device-tun.c \ - devices/nm-device-veth.c \ - devices/nm-device-vlan.c \ - devices/nm-device-vxlan.c \ - $(NULL) - -nm_device_headers = \ - devices/nm-device-bond.h \ - devices/nm-device-bridge.h \ - devices/nm-device-ethernet.h \ - devices/nm-device-infiniband.h \ - devices/nm-device-ip-tunnel.h \ - devices/nm-device-macvlan.h \ - devices/nm-device-tun.h \ - devices/nm-device-veth.h \ - devices/nm-device-vlan.h \ - devices/nm-device-vxlan.h \ - $(NULL) - -nm_dhcp_client_sources = \ - dhcp-manager/nm-dhcp-dhclient.c \ - dhcp-manager/nm-dhcp-dhcpcd.c \ - dhcp-manager/nm-dhcp-systemd.c \ - $(NULL) - -nm_dhcp_client_headers = \ - dhcp-manager/nm-dhcp-dhclient.h \ - dhcp-manager/nm-dhcp-dhcpcd.h \ - dhcp-manager/nm-dhcp-systemd.h \ - $(NULL) - - -############################################################################### -libNetworkManager_la_SOURCES = dhcp-manager/nm-dhcp-dhclient-utils.c \ - dhcp-manager/nm-dhcp-dhclient-utils.h nm-checkpoint-manager.c \ - nm-checkpoint-manager.h nm-checkpoint.c nm-checkpoint.h \ - devices/nm-device.c devices/nm-device.h \ - devices/nm-lldp-listener.c devices/nm-lldp-listener.h \ - devices/nm-arping-manager.c devices/nm-arping-manager.h \ - devices/nm-device-ethernet-utils.c \ - devices/nm-device-ethernet-utils.h devices/nm-device-factory.c \ - devices/nm-device-factory.h devices/nm-device-generic.c \ - devices/nm-device-generic.h devices/nm-device-logging.h \ - devices/nm-device-private.h dhcp-manager/nm-dhcp-client.c \ - dhcp-manager/nm-dhcp-client.h \ - dhcp-manager/nm-dhcp-client-logging.h \ - dhcp-manager/nm-dhcp-helper-api.h dhcp-manager/nm-dhcp-utils.c \ - dhcp-manager/nm-dhcp-utils.h dhcp-manager/nm-dhcp-listener.c \ - dhcp-manager/nm-dhcp-listener.h dhcp-manager/nm-dhcp-manager.c \ - dhcp-manager/nm-dhcp-manager.h dns-manager/nm-dns-dnsmasq.c \ - dns-manager/nm-dns-dnsmasq.h dns-manager/nm-dns-unbound.c \ - dns-manager/nm-dns-unbound.h dns-manager/nm-dns-manager.c \ - dns-manager/nm-dns-manager.h dns-manager/nm-dns-plugin.c \ - dns-manager/nm-dns-plugin.h \ - dnsmasq-manager/nm-dnsmasq-manager.c \ - dnsmasq-manager/nm-dnsmasq-manager.h \ - dnsmasq-manager/nm-dnsmasq-utils.c \ - dnsmasq-manager/nm-dnsmasq-utils.h platform/nmp-netns.c \ - platform/nmp-netns.h platform/nmp-object.c \ - platform/nmp-object.h platform/nm-platform-utils.c \ - platform/nm-platform-utils.h platform/nm-platform.c \ - platform/nm-platform.h platform/nm-linux-platform.c \ - platform/nm-linux-platform.h \ - platform/wifi/wifi-utils-nl80211.c \ - platform/wifi/wifi-utils-nl80211.h \ - platform/wifi/wifi-utils-private.h platform/wifi/wifi-utils.c \ - platform/wifi/wifi-utils.h rdisc/nm-lndp-rdisc.c \ - rdisc/nm-lndp-rdisc.h rdisc/nm-rdisc.c rdisc/nm-rdisc.h \ - rdisc/nm-rdisc-private.h ppp-manager/nm-ppp-manager.c \ - ppp-manager/nm-ppp-manager.h ppp-manager/nm-ppp-status.h \ - settings/nm-agent-manager.c settings/nm-agent-manager.h \ - settings/nm-inotify-helper.c settings/nm-inotify-helper.h \ - settings/nm-secret-agent.c settings/nm-secret-agent.h \ - settings/nm-settings-connection.c \ - settings/nm-settings-connection.h \ - settings/nm-settings-plugin.c settings/nm-settings-plugin.h \ - settings/nm-settings.c settings/nm-settings.h \ - settings/plugins/keyfile/nm-keyfile-connection.c \ - settings/plugins/keyfile/nm-keyfile-connection.h \ - settings/plugins/keyfile/plugin.c \ - settings/plugins/keyfile/plugin.h \ - settings/plugins/keyfile/reader.c \ - settings/plugins/keyfile/reader.h \ - settings/plugins/keyfile/utils.c \ - settings/plugins/keyfile/utils.h \ - settings/plugins/keyfile/writer.c \ - settings/plugins/keyfile/writer.h \ - supplicant-manager/nm-supplicant-config.c \ - supplicant-manager/nm-supplicant-config.h \ - supplicant-manager/nm-supplicant-interface.c \ - supplicant-manager/nm-supplicant-interface.h \ - supplicant-manager/nm-supplicant-manager.c \ - supplicant-manager/nm-supplicant-manager.h \ - supplicant-manager/nm-supplicant-settings-verify.c \ - supplicant-manager/nm-supplicant-settings-verify.h \ - supplicant-manager/nm-supplicant-types.h \ - vpn-manager/nm-vpn-connection.c \ - vpn-manager/nm-vpn-connection.h vpn-manager/nm-vpn-manager.c \ - vpn-manager/nm-vpn-manager.h nm-activation-request.c \ - nm-activation-request.h nm-active-connection.c \ - nm-active-connection.h nm-audit-manager.c nm-audit-manager.h \ - nm-bus-manager.c nm-bus-manager.h nm-config.c nm-config.h \ - nm-config-data.c nm-config-data.h nm-connectivity.c \ - nm-connectivity.h nm-dcb.c nm-dcb.h nm-route-manager.c \ - nm-route-manager.h nm-default-route-manager.c \ - nm-default-route-manager.h nm-dhcp4-config.c nm-dhcp4-config.h \ - nm-dhcp6-config.c nm-dhcp6-config.h nm-dispatcher.c \ - nm-dispatcher.h nm-enum-types.c nm-enum-types.h \ - nm-exported-object.c nm-exported-object.h \ - nm-firewall-manager.c nm-firewall-manager.h nm-ip4-config.c \ - nm-ip4-config.h nm-ip6-config.c nm-ip6-config.h \ - nm-auth-manager.c nm-auth-manager.h nm-auth-subject.c \ - nm-auth-subject.h nm-auth-utils.c nm-auth-utils.h nm-manager.c \ - nm-manager.h nm-multi-index.c nm-multi-index.h nm-policy.c \ - nm-policy.h nm-rfkill-manager.c nm-rfkill-manager.h \ - nm-session-monitor.h nm-session-monitor.c nm-sleep-monitor.c \ - nm-sleep-monitor.h nm-types.h NetworkManagerUtils.c \ - NetworkManagerUtils.h $(NULL) $(am__append_5) -libNetworkManager_la_LIBADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(top_builddir)/introspection/libnmdbus.la \ - libNetworkManagerBase.la libsystemd-nm.la $(GLIB_LIBS) \ - $(GUDEV_LIBS) $(LIBNL_LIBS) $(SYSTEMD_LOGIN_LIBS) \ - $(LIBNDP_LIBS) $(DL_LIBS) $(LIBM) $(SELINUX_LIBS) \ - $(LIBAUDIT_LIBS) $(am__append_6) - -############################################################################### -libNetworkManagerTest_la_SOURCES = \ - rdisc/nm-fake-rdisc.c \ - rdisc/nm-fake-rdisc.h \ - platform/nm-fake-platform.c \ - platform/nm-fake-platform.h - -libNetworkManagerTest_la_LIBADD = \ - libNetworkManager.la - - -############################################################################### -NetworkManager_SOURCES = \ - \ - $(nm_device_sources) \ - $(nm_device_headers) \ - \ - $(nm_dhcp_client_sources) \ - $(nm_dhcp_client_headers) \ - \ - main-utils.c \ - main-utils.h \ - main.c - -NetworkManager_LDADD = \ - libNetworkManager.la - -NetworkManager_LDFLAGS = \ - -rdynamic \ - -Wl,--version-script="$(srcdir)/NetworkManager.ver" - - -############################################################################### -libnm_iface_helper_la_SOURCES = dhcp-manager/nm-dhcp-client.c \ - dhcp-manager/nm-dhcp-client.h \ - dhcp-manager/nm-dhcp-client-logging.h \ - dhcp-manager/nm-dhcp-utils.c dhcp-manager/nm-dhcp-utils.h \ - dhcp-manager/nm-dhcp-manager.c dhcp-manager/nm-dhcp-manager.h \ - platform/nmp-netns.c platform/nmp-netns.h \ - platform/nmp-object.c platform/nmp-object.h \ - platform/nm-platform-utils.c platform/nm-platform-utils.h \ - platform/nm-platform.c platform/nm-platform.h \ - platform/nm-linux-platform.c platform/nm-linux-platform.h \ - platform/wifi/wifi-utils-nl80211.c \ - platform/wifi/wifi-utils-nl80211.h \ - platform/wifi/wifi-utils-private.h platform/wifi/wifi-utils.c \ - platform/wifi/wifi-utils.h rdisc/nm-lndp-rdisc.c \ - rdisc/nm-lndp-rdisc.h rdisc/nm-rdisc.c rdisc/nm-rdisc.h \ - nm-route-manager.c nm-route-manager.h nm-exported-object.c \ - nm-exported-object.h nm-ip4-config.c nm-ip4-config.h \ - nm-ip6-config.c nm-ip6-config.h nm-enum-types.c \ - nm-enum-types.h nm-multi-index.c nm-multi-index.h \ - NetworkManagerUtils.c NetworkManagerUtils.h $(am__append_7) -libnm_iface_helper_la_LIBADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - $(top_builddir)/introspection/libnmdbus.la \ - libNetworkManagerBase.la \ - libsystemd-nm.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) \ - $(LIBNL_LIBS) \ - $(LIBNDP_LIBS) \ - $(DL_LIBS) \ - $(LIBM) - -nm_iface_helper_SOURCES = \ - dhcp-manager/nm-dhcp-systemd.h \ - dhcp-manager/nm-dhcp-systemd.c \ - nm-iface-helper.c \ - main-utils.c \ - main-utils.h - -nm_iface_helper_LDADD = \ - $(top_builddir)/libnm-core/libnm-core.la \ - libnm-iface-helper.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) \ - $(LIBNL_LIBS) \ - $(LIBNDP_LIBS) \ - $(LIBM) - -nm_iface_helper_LDFLAGS = \ - -rdynamic - - -############################################################################### -GLIB_GENERATED = nm-enum-types.h nm-enum-types.c -GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM --fhead '\#include \n' -GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM --fhead '\#include "nm-default.h"\n' -nm_enum_types_sources = $(filter-out \ - %/nm-device-private.h \ - %/nm-rdisc-private.h \ - %/wifi-utils-private.h \ - %/nm-dhcp-client-logging.h \ - %/nm-device-logging.h \ - , $(libNetworkManager_la_SOURCES)) - -BUILT_SOURCES = $(GLIB_GENERATED) - -############################################################################### -dbusservicedir = $(DBUS_SYS_DIR) -dbusservice_DATA = org.freedesktop.NetworkManager.conf -EXTRA_DIST = \ - $(dbusservice_DATA) \ - $(NetworkManager_DATA) \ - nm-test-utils-core.h \ - NetworkManager.ver - -rundir = $(runstatedir)/NetworkManager -statedir = $(localstatedir)/lib/NetworkManager -CLEANFILES = \ - $(BUILT_SOURCES) - -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libNetworkManager.la: $(libNetworkManager_la_OBJECTS) $(libNetworkManager_la_DEPENDENCIES) $(EXTRA_libNetworkManager_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libNetworkManager_la_OBJECTS) $(libNetworkManager_la_LIBADD) $(LIBS) - -libNetworkManagerBase.la: $(libNetworkManagerBase_la_OBJECTS) $(libNetworkManagerBase_la_DEPENDENCIES) $(EXTRA_libNetworkManagerBase_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libNetworkManagerBase_la_OBJECTS) $(libNetworkManagerBase_la_LIBADD) $(LIBS) - -libNetworkManagerTest.la: $(libNetworkManagerTest_la_OBJECTS) $(libNetworkManagerTest_la_DEPENDENCIES) $(EXTRA_libNetworkManagerTest_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libNetworkManagerTest_la_OBJECTS) $(libNetworkManagerTest_la_LIBADD) $(LIBS) - -libnm-iface-helper.la: $(libnm_iface_helper_la_OBJECTS) $(libnm_iface_helper_la_DEPENDENCIES) $(EXTRA_libnm_iface_helper_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libnm_iface_helper_la_OBJECTS) $(libnm_iface_helper_la_LIBADD) $(LIBS) - -libsystemd-nm.la: $(libsystemd_nm_la_OBJECTS) $(libsystemd_nm_la_DEPENDENCIES) $(EXTRA_libsystemd_nm_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libsystemd_nm_la_OBJECTS) $(libsystemd_nm_la_LIBADD) $(LIBS) -install-libexecPROGRAMS: $(libexec_PROGRAMS) - @$(NORMAL_INSTALL) - @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ - fi; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p \ - || test -f $$p1 \ - ; then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' \ - -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-libexecPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' \ - `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(libexecdir)" && rm -f $$files - -clean-libexecPROGRAMS: - @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -install-sbinPROGRAMS: $(sbin_PROGRAMS) - @$(NORMAL_INSTALL) - @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \ - fi; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p \ - || test -f $$p1 \ - ; then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' \ - -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-sbinPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' \ - `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(sbindir)" && rm -f $$files - -clean-sbinPROGRAMS: - @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -NetworkManager$(EXEEXT): $(NetworkManager_OBJECTS) $(NetworkManager_DEPENDENCIES) $(EXTRA_NetworkManager_DEPENDENCIES) - @rm -f NetworkManager$(EXEEXT) - $(AM_V_CCLD)$(NetworkManager_LINK) $(NetworkManager_OBJECTS) $(NetworkManager_LDADD) $(LIBS) - -nm-iface-helper$(EXEEXT): $(nm_iface_helper_OBJECTS) $(nm_iface_helper_DEPENDENCIES) $(EXTRA_nm_iface_helper_DEPENDENCIES) - @rm -f nm-iface-helper$(EXEEXT) - $(AM_V_CCLD)$(nm_iface_helper_LINK) $(nm_iface_helper_OBJECTS) $(nm_iface_helper_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NetworkManagerUtils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-alloc-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-arp-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-dhcp-identifier.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-dhcp-network.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-dhcp-option.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-dhcp-packet.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-dhcp6-network.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-dhcp6-option.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-dns-domain.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-escape.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-ether-addr-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-extract-word.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-fd-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-fileio.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-fs-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-hash-funcs.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-hashmap.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-hexdecoct.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-hostname-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-id128-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-in-addr-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-io-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-lldp-neighbor.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-lldp-network.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-mempool.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-network-internal.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-nm-sd-adapt.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-nm-sd.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-parse-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-path-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-prioq.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-random-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-dhcp-client.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-dhcp-lease.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-dhcp6-client.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-dhcp6-lease.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-event.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-id128.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-ipv4acd.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-ipv4ll.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-sd-lldp.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-siphash24.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-socket-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-string-table.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-string-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-strv.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-time-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-utf8.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsystemd_nm_la-util.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main-utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-activation-request.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-active-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-agent-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-arping-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-audit-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-auth-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-auth-subject.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-auth-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bus-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-checkpoint-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-checkpoint.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-config-data.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-config.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-connectivity.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-core-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dcb.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-default-route-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-bond.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-bridge.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-ethernet-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-ethernet.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-factory.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-generic.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-infiniband.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-ip-tunnel.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-macvlan.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-tun.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-veth.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-vlan.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-vxlan.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-client.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-dhclient-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-dhclient.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-dhcpcd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-listener.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-systemd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp4-config.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp6-config.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dispatcher.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dns-dnsmasq.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dns-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dns-plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dns-unbound.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dnsmasq-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dnsmasq-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-enum-types.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-exported-object.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-fake-platform.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-fake-rdisc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-firewall-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-iface-helper.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-inotify-helper.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ip4-config.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ip6-config.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-keyfile-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-linux-platform.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-lldp-listener.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-lndp-rdisc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-logging.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-multi-index.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-platform-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-platform.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-policy.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ppp-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-rdisc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-rfkill-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-route-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-secret-agent.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-session-monitor.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-settings-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-settings-plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-settings.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-sleep-monitor.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-supplicant-config.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-supplicant-interface.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-supplicant-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-supplicant-settings-verify.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-vpn-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-vpn-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nmp-netns.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nmp-object.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wifi-utils-nl80211.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wifi-utils-wext.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wifi-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -nm-dhcp-dhclient-utils.lo: dhcp-manager/nm-dhcp-dhclient-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-dhclient-utils.lo -MD -MP -MF $(DEPDIR)/nm-dhcp-dhclient-utils.Tpo -c -o nm-dhcp-dhclient-utils.lo `test -f 'dhcp-manager/nm-dhcp-dhclient-utils.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-dhclient-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-dhclient-utils.Tpo $(DEPDIR)/nm-dhcp-dhclient-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-dhclient-utils.c' object='nm-dhcp-dhclient-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-dhclient-utils.lo `test -f 'dhcp-manager/nm-dhcp-dhclient-utils.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-dhclient-utils.c - -nm-device.lo: devices/nm-device.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device.lo -MD -MP -MF $(DEPDIR)/nm-device.Tpo -c -o nm-device.lo `test -f 'devices/nm-device.c' || echo '$(srcdir)/'`devices/nm-device.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device.Tpo $(DEPDIR)/nm-device.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device.c' object='nm-device.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device.lo `test -f 'devices/nm-device.c' || echo '$(srcdir)/'`devices/nm-device.c - -nm-lldp-listener.lo: devices/nm-lldp-listener.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-lldp-listener.lo -MD -MP -MF $(DEPDIR)/nm-lldp-listener.Tpo -c -o nm-lldp-listener.lo `test -f 'devices/nm-lldp-listener.c' || echo '$(srcdir)/'`devices/nm-lldp-listener.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-lldp-listener.Tpo $(DEPDIR)/nm-lldp-listener.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-lldp-listener.c' object='nm-lldp-listener.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-lldp-listener.lo `test -f 'devices/nm-lldp-listener.c' || echo '$(srcdir)/'`devices/nm-lldp-listener.c - -nm-arping-manager.lo: devices/nm-arping-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-arping-manager.lo -MD -MP -MF $(DEPDIR)/nm-arping-manager.Tpo -c -o nm-arping-manager.lo `test -f 'devices/nm-arping-manager.c' || echo '$(srcdir)/'`devices/nm-arping-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-arping-manager.Tpo $(DEPDIR)/nm-arping-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-arping-manager.c' object='nm-arping-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-arping-manager.lo `test -f 'devices/nm-arping-manager.c' || echo '$(srcdir)/'`devices/nm-arping-manager.c - -nm-device-ethernet-utils.lo: devices/nm-device-ethernet-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-ethernet-utils.lo -MD -MP -MF $(DEPDIR)/nm-device-ethernet-utils.Tpo -c -o nm-device-ethernet-utils.lo `test -f 'devices/nm-device-ethernet-utils.c' || echo '$(srcdir)/'`devices/nm-device-ethernet-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-ethernet-utils.Tpo $(DEPDIR)/nm-device-ethernet-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-ethernet-utils.c' object='nm-device-ethernet-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-ethernet-utils.lo `test -f 'devices/nm-device-ethernet-utils.c' || echo '$(srcdir)/'`devices/nm-device-ethernet-utils.c - -nm-device-factory.lo: devices/nm-device-factory.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-factory.lo -MD -MP -MF $(DEPDIR)/nm-device-factory.Tpo -c -o nm-device-factory.lo `test -f 'devices/nm-device-factory.c' || echo '$(srcdir)/'`devices/nm-device-factory.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-factory.Tpo $(DEPDIR)/nm-device-factory.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-factory.c' object='nm-device-factory.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-factory.lo `test -f 'devices/nm-device-factory.c' || echo '$(srcdir)/'`devices/nm-device-factory.c - -nm-device-generic.lo: devices/nm-device-generic.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-generic.lo -MD -MP -MF $(DEPDIR)/nm-device-generic.Tpo -c -o nm-device-generic.lo `test -f 'devices/nm-device-generic.c' || echo '$(srcdir)/'`devices/nm-device-generic.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-generic.Tpo $(DEPDIR)/nm-device-generic.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-generic.c' object='nm-device-generic.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-generic.lo `test -f 'devices/nm-device-generic.c' || echo '$(srcdir)/'`devices/nm-device-generic.c - -nm-dhcp-client.lo: dhcp-manager/nm-dhcp-client.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-client.lo -MD -MP -MF $(DEPDIR)/nm-dhcp-client.Tpo -c -o nm-dhcp-client.lo `test -f 'dhcp-manager/nm-dhcp-client.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-client.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-client.Tpo $(DEPDIR)/nm-dhcp-client.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-client.c' object='nm-dhcp-client.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-client.lo `test -f 'dhcp-manager/nm-dhcp-client.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-client.c - -nm-dhcp-utils.lo: dhcp-manager/nm-dhcp-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-utils.lo -MD -MP -MF $(DEPDIR)/nm-dhcp-utils.Tpo -c -o nm-dhcp-utils.lo `test -f 'dhcp-manager/nm-dhcp-utils.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-utils.Tpo $(DEPDIR)/nm-dhcp-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-utils.c' object='nm-dhcp-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-utils.lo `test -f 'dhcp-manager/nm-dhcp-utils.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-utils.c - -nm-dhcp-listener.lo: dhcp-manager/nm-dhcp-listener.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-listener.lo -MD -MP -MF $(DEPDIR)/nm-dhcp-listener.Tpo -c -o nm-dhcp-listener.lo `test -f 'dhcp-manager/nm-dhcp-listener.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-listener.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-listener.Tpo $(DEPDIR)/nm-dhcp-listener.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-listener.c' object='nm-dhcp-listener.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-listener.lo `test -f 'dhcp-manager/nm-dhcp-listener.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-listener.c - -nm-dhcp-manager.lo: dhcp-manager/nm-dhcp-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-manager.lo -MD -MP -MF $(DEPDIR)/nm-dhcp-manager.Tpo -c -o nm-dhcp-manager.lo `test -f 'dhcp-manager/nm-dhcp-manager.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-manager.Tpo $(DEPDIR)/nm-dhcp-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-manager.c' object='nm-dhcp-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-manager.lo `test -f 'dhcp-manager/nm-dhcp-manager.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-manager.c - -nm-dns-dnsmasq.lo: dns-manager/nm-dns-dnsmasq.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dns-dnsmasq.lo -MD -MP -MF $(DEPDIR)/nm-dns-dnsmasq.Tpo -c -o nm-dns-dnsmasq.lo `test -f 'dns-manager/nm-dns-dnsmasq.c' || echo '$(srcdir)/'`dns-manager/nm-dns-dnsmasq.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dns-dnsmasq.Tpo $(DEPDIR)/nm-dns-dnsmasq.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dns-manager/nm-dns-dnsmasq.c' object='nm-dns-dnsmasq.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dns-dnsmasq.lo `test -f 'dns-manager/nm-dns-dnsmasq.c' || echo '$(srcdir)/'`dns-manager/nm-dns-dnsmasq.c - -nm-dns-unbound.lo: dns-manager/nm-dns-unbound.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dns-unbound.lo -MD -MP -MF $(DEPDIR)/nm-dns-unbound.Tpo -c -o nm-dns-unbound.lo `test -f 'dns-manager/nm-dns-unbound.c' || echo '$(srcdir)/'`dns-manager/nm-dns-unbound.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dns-unbound.Tpo $(DEPDIR)/nm-dns-unbound.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dns-manager/nm-dns-unbound.c' object='nm-dns-unbound.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dns-unbound.lo `test -f 'dns-manager/nm-dns-unbound.c' || echo '$(srcdir)/'`dns-manager/nm-dns-unbound.c - -nm-dns-manager.lo: dns-manager/nm-dns-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dns-manager.lo -MD -MP -MF $(DEPDIR)/nm-dns-manager.Tpo -c -o nm-dns-manager.lo `test -f 'dns-manager/nm-dns-manager.c' || echo '$(srcdir)/'`dns-manager/nm-dns-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dns-manager.Tpo $(DEPDIR)/nm-dns-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dns-manager/nm-dns-manager.c' object='nm-dns-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dns-manager.lo `test -f 'dns-manager/nm-dns-manager.c' || echo '$(srcdir)/'`dns-manager/nm-dns-manager.c - -nm-dns-plugin.lo: dns-manager/nm-dns-plugin.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dns-plugin.lo -MD -MP -MF $(DEPDIR)/nm-dns-plugin.Tpo -c -o nm-dns-plugin.lo `test -f 'dns-manager/nm-dns-plugin.c' || echo '$(srcdir)/'`dns-manager/nm-dns-plugin.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dns-plugin.Tpo $(DEPDIR)/nm-dns-plugin.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dns-manager/nm-dns-plugin.c' object='nm-dns-plugin.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dns-plugin.lo `test -f 'dns-manager/nm-dns-plugin.c' || echo '$(srcdir)/'`dns-manager/nm-dns-plugin.c - -nm-dnsmasq-manager.lo: dnsmasq-manager/nm-dnsmasq-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dnsmasq-manager.lo -MD -MP -MF $(DEPDIR)/nm-dnsmasq-manager.Tpo -c -o nm-dnsmasq-manager.lo `test -f 'dnsmasq-manager/nm-dnsmasq-manager.c' || echo '$(srcdir)/'`dnsmasq-manager/nm-dnsmasq-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dnsmasq-manager.Tpo $(DEPDIR)/nm-dnsmasq-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dnsmasq-manager/nm-dnsmasq-manager.c' object='nm-dnsmasq-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dnsmasq-manager.lo `test -f 'dnsmasq-manager/nm-dnsmasq-manager.c' || echo '$(srcdir)/'`dnsmasq-manager/nm-dnsmasq-manager.c - -nm-dnsmasq-utils.lo: dnsmasq-manager/nm-dnsmasq-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dnsmasq-utils.lo -MD -MP -MF $(DEPDIR)/nm-dnsmasq-utils.Tpo -c -o nm-dnsmasq-utils.lo `test -f 'dnsmasq-manager/nm-dnsmasq-utils.c' || echo '$(srcdir)/'`dnsmasq-manager/nm-dnsmasq-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dnsmasq-utils.Tpo $(DEPDIR)/nm-dnsmasq-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dnsmasq-manager/nm-dnsmasq-utils.c' object='nm-dnsmasq-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dnsmasq-utils.lo `test -f 'dnsmasq-manager/nm-dnsmasq-utils.c' || echo '$(srcdir)/'`dnsmasq-manager/nm-dnsmasq-utils.c - -nmp-netns.lo: platform/nmp-netns.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nmp-netns.lo -MD -MP -MF $(DEPDIR)/nmp-netns.Tpo -c -o nmp-netns.lo `test -f 'platform/nmp-netns.c' || echo '$(srcdir)/'`platform/nmp-netns.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nmp-netns.Tpo $(DEPDIR)/nmp-netns.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/nmp-netns.c' object='nmp-netns.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nmp-netns.lo `test -f 'platform/nmp-netns.c' || echo '$(srcdir)/'`platform/nmp-netns.c - -nmp-object.lo: platform/nmp-object.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nmp-object.lo -MD -MP -MF $(DEPDIR)/nmp-object.Tpo -c -o nmp-object.lo `test -f 'platform/nmp-object.c' || echo '$(srcdir)/'`platform/nmp-object.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nmp-object.Tpo $(DEPDIR)/nmp-object.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/nmp-object.c' object='nmp-object.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nmp-object.lo `test -f 'platform/nmp-object.c' || echo '$(srcdir)/'`platform/nmp-object.c - -nm-platform-utils.lo: platform/nm-platform-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-platform-utils.lo -MD -MP -MF $(DEPDIR)/nm-platform-utils.Tpo -c -o nm-platform-utils.lo `test -f 'platform/nm-platform-utils.c' || echo '$(srcdir)/'`platform/nm-platform-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-platform-utils.Tpo $(DEPDIR)/nm-platform-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/nm-platform-utils.c' object='nm-platform-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-platform-utils.lo `test -f 'platform/nm-platform-utils.c' || echo '$(srcdir)/'`platform/nm-platform-utils.c - -nm-platform.lo: platform/nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-platform.lo -MD -MP -MF $(DEPDIR)/nm-platform.Tpo -c -o nm-platform.lo `test -f 'platform/nm-platform.c' || echo '$(srcdir)/'`platform/nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-platform.Tpo $(DEPDIR)/nm-platform.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/nm-platform.c' object='nm-platform.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-platform.lo `test -f 'platform/nm-platform.c' || echo '$(srcdir)/'`platform/nm-platform.c - -nm-linux-platform.lo: platform/nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-linux-platform.lo -MD -MP -MF $(DEPDIR)/nm-linux-platform.Tpo -c -o nm-linux-platform.lo `test -f 'platform/nm-linux-platform.c' || echo '$(srcdir)/'`platform/nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-linux-platform.Tpo $(DEPDIR)/nm-linux-platform.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/nm-linux-platform.c' object='nm-linux-platform.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-linux-platform.lo `test -f 'platform/nm-linux-platform.c' || echo '$(srcdir)/'`platform/nm-linux-platform.c - -wifi-utils-nl80211.lo: platform/wifi/wifi-utils-nl80211.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT wifi-utils-nl80211.lo -MD -MP -MF $(DEPDIR)/wifi-utils-nl80211.Tpo -c -o wifi-utils-nl80211.lo `test -f 'platform/wifi/wifi-utils-nl80211.c' || echo '$(srcdir)/'`platform/wifi/wifi-utils-nl80211.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/wifi-utils-nl80211.Tpo $(DEPDIR)/wifi-utils-nl80211.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/wifi/wifi-utils-nl80211.c' object='wifi-utils-nl80211.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wifi-utils-nl80211.lo `test -f 'platform/wifi/wifi-utils-nl80211.c' || echo '$(srcdir)/'`platform/wifi/wifi-utils-nl80211.c - -wifi-utils.lo: platform/wifi/wifi-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT wifi-utils.lo -MD -MP -MF $(DEPDIR)/wifi-utils.Tpo -c -o wifi-utils.lo `test -f 'platform/wifi/wifi-utils.c' || echo '$(srcdir)/'`platform/wifi/wifi-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/wifi-utils.Tpo $(DEPDIR)/wifi-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/wifi/wifi-utils.c' object='wifi-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wifi-utils.lo `test -f 'platform/wifi/wifi-utils.c' || echo '$(srcdir)/'`platform/wifi/wifi-utils.c - -nm-lndp-rdisc.lo: rdisc/nm-lndp-rdisc.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-lndp-rdisc.lo -MD -MP -MF $(DEPDIR)/nm-lndp-rdisc.Tpo -c -o nm-lndp-rdisc.lo `test -f 'rdisc/nm-lndp-rdisc.c' || echo '$(srcdir)/'`rdisc/nm-lndp-rdisc.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-lndp-rdisc.Tpo $(DEPDIR)/nm-lndp-rdisc.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rdisc/nm-lndp-rdisc.c' object='nm-lndp-rdisc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-lndp-rdisc.lo `test -f 'rdisc/nm-lndp-rdisc.c' || echo '$(srcdir)/'`rdisc/nm-lndp-rdisc.c - -nm-rdisc.lo: rdisc/nm-rdisc.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-rdisc.lo -MD -MP -MF $(DEPDIR)/nm-rdisc.Tpo -c -o nm-rdisc.lo `test -f 'rdisc/nm-rdisc.c' || echo '$(srcdir)/'`rdisc/nm-rdisc.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-rdisc.Tpo $(DEPDIR)/nm-rdisc.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rdisc/nm-rdisc.c' object='nm-rdisc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-rdisc.lo `test -f 'rdisc/nm-rdisc.c' || echo '$(srcdir)/'`rdisc/nm-rdisc.c - -nm-ppp-manager.lo: ppp-manager/nm-ppp-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-ppp-manager.lo -MD -MP -MF $(DEPDIR)/nm-ppp-manager.Tpo -c -o nm-ppp-manager.lo `test -f 'ppp-manager/nm-ppp-manager.c' || echo '$(srcdir)/'`ppp-manager/nm-ppp-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-ppp-manager.Tpo $(DEPDIR)/nm-ppp-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ppp-manager/nm-ppp-manager.c' object='nm-ppp-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-ppp-manager.lo `test -f 'ppp-manager/nm-ppp-manager.c' || echo '$(srcdir)/'`ppp-manager/nm-ppp-manager.c - -nm-agent-manager.lo: settings/nm-agent-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-agent-manager.lo -MD -MP -MF $(DEPDIR)/nm-agent-manager.Tpo -c -o nm-agent-manager.lo `test -f 'settings/nm-agent-manager.c' || echo '$(srcdir)/'`settings/nm-agent-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-agent-manager.Tpo $(DEPDIR)/nm-agent-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/nm-agent-manager.c' object='nm-agent-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-agent-manager.lo `test -f 'settings/nm-agent-manager.c' || echo '$(srcdir)/'`settings/nm-agent-manager.c - -nm-inotify-helper.lo: settings/nm-inotify-helper.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-inotify-helper.lo -MD -MP -MF $(DEPDIR)/nm-inotify-helper.Tpo -c -o nm-inotify-helper.lo `test -f 'settings/nm-inotify-helper.c' || echo '$(srcdir)/'`settings/nm-inotify-helper.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-inotify-helper.Tpo $(DEPDIR)/nm-inotify-helper.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/nm-inotify-helper.c' object='nm-inotify-helper.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-inotify-helper.lo `test -f 'settings/nm-inotify-helper.c' || echo '$(srcdir)/'`settings/nm-inotify-helper.c - -nm-secret-agent.lo: settings/nm-secret-agent.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-secret-agent.lo -MD -MP -MF $(DEPDIR)/nm-secret-agent.Tpo -c -o nm-secret-agent.lo `test -f 'settings/nm-secret-agent.c' || echo '$(srcdir)/'`settings/nm-secret-agent.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-secret-agent.Tpo $(DEPDIR)/nm-secret-agent.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/nm-secret-agent.c' object='nm-secret-agent.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-secret-agent.lo `test -f 'settings/nm-secret-agent.c' || echo '$(srcdir)/'`settings/nm-secret-agent.c - -nm-settings-connection.lo: settings/nm-settings-connection.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-settings-connection.lo -MD -MP -MF $(DEPDIR)/nm-settings-connection.Tpo -c -o nm-settings-connection.lo `test -f 'settings/nm-settings-connection.c' || echo '$(srcdir)/'`settings/nm-settings-connection.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-settings-connection.Tpo $(DEPDIR)/nm-settings-connection.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/nm-settings-connection.c' object='nm-settings-connection.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-settings-connection.lo `test -f 'settings/nm-settings-connection.c' || echo '$(srcdir)/'`settings/nm-settings-connection.c - -nm-settings-plugin.lo: settings/nm-settings-plugin.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-settings-plugin.lo -MD -MP -MF $(DEPDIR)/nm-settings-plugin.Tpo -c -o nm-settings-plugin.lo `test -f 'settings/nm-settings-plugin.c' || echo '$(srcdir)/'`settings/nm-settings-plugin.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-settings-plugin.Tpo $(DEPDIR)/nm-settings-plugin.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/nm-settings-plugin.c' object='nm-settings-plugin.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-settings-plugin.lo `test -f 'settings/nm-settings-plugin.c' || echo '$(srcdir)/'`settings/nm-settings-plugin.c - -nm-settings.lo: settings/nm-settings.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-settings.lo -MD -MP -MF $(DEPDIR)/nm-settings.Tpo -c -o nm-settings.lo `test -f 'settings/nm-settings.c' || echo '$(srcdir)/'`settings/nm-settings.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-settings.Tpo $(DEPDIR)/nm-settings.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/nm-settings.c' object='nm-settings.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-settings.lo `test -f 'settings/nm-settings.c' || echo '$(srcdir)/'`settings/nm-settings.c - -nm-keyfile-connection.lo: settings/plugins/keyfile/nm-keyfile-connection.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-keyfile-connection.lo -MD -MP -MF $(DEPDIR)/nm-keyfile-connection.Tpo -c -o nm-keyfile-connection.lo `test -f 'settings/plugins/keyfile/nm-keyfile-connection.c' || echo '$(srcdir)/'`settings/plugins/keyfile/nm-keyfile-connection.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-keyfile-connection.Tpo $(DEPDIR)/nm-keyfile-connection.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/plugins/keyfile/nm-keyfile-connection.c' object='nm-keyfile-connection.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-keyfile-connection.lo `test -f 'settings/plugins/keyfile/nm-keyfile-connection.c' || echo '$(srcdir)/'`settings/plugins/keyfile/nm-keyfile-connection.c - -plugin.lo: settings/plugins/keyfile/plugin.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT plugin.lo -MD -MP -MF $(DEPDIR)/plugin.Tpo -c -o plugin.lo `test -f 'settings/plugins/keyfile/plugin.c' || echo '$(srcdir)/'`settings/plugins/keyfile/plugin.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/plugin.Tpo $(DEPDIR)/plugin.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/plugins/keyfile/plugin.c' object='plugin.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o plugin.lo `test -f 'settings/plugins/keyfile/plugin.c' || echo '$(srcdir)/'`settings/plugins/keyfile/plugin.c - -reader.lo: settings/plugins/keyfile/reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.lo -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.lo `test -f 'settings/plugins/keyfile/reader.c' || echo '$(srcdir)/'`settings/plugins/keyfile/reader.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/plugins/keyfile/reader.c' object='reader.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.lo `test -f 'settings/plugins/keyfile/reader.c' || echo '$(srcdir)/'`settings/plugins/keyfile/reader.c - -utils.lo: settings/plugins/keyfile/utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.lo -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.lo `test -f 'settings/plugins/keyfile/utils.c' || echo '$(srcdir)/'`settings/plugins/keyfile/utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/plugins/keyfile/utils.c' object='utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.lo `test -f 'settings/plugins/keyfile/utils.c' || echo '$(srcdir)/'`settings/plugins/keyfile/utils.c - -writer.lo: settings/plugins/keyfile/writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.lo -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.lo `test -f 'settings/plugins/keyfile/writer.c' || echo '$(srcdir)/'`settings/plugins/keyfile/writer.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='settings/plugins/keyfile/writer.c' object='writer.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.lo `test -f 'settings/plugins/keyfile/writer.c' || echo '$(srcdir)/'`settings/plugins/keyfile/writer.c - -nm-supplicant-config.lo: supplicant-manager/nm-supplicant-config.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-supplicant-config.lo -MD -MP -MF $(DEPDIR)/nm-supplicant-config.Tpo -c -o nm-supplicant-config.lo `test -f 'supplicant-manager/nm-supplicant-config.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-config.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-supplicant-config.Tpo $(DEPDIR)/nm-supplicant-config.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='supplicant-manager/nm-supplicant-config.c' object='nm-supplicant-config.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-supplicant-config.lo `test -f 'supplicant-manager/nm-supplicant-config.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-config.c - -nm-supplicant-interface.lo: supplicant-manager/nm-supplicant-interface.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-supplicant-interface.lo -MD -MP -MF $(DEPDIR)/nm-supplicant-interface.Tpo -c -o nm-supplicant-interface.lo `test -f 'supplicant-manager/nm-supplicant-interface.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-interface.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-supplicant-interface.Tpo $(DEPDIR)/nm-supplicant-interface.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='supplicant-manager/nm-supplicant-interface.c' object='nm-supplicant-interface.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-supplicant-interface.lo `test -f 'supplicant-manager/nm-supplicant-interface.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-interface.c - -nm-supplicant-manager.lo: supplicant-manager/nm-supplicant-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-supplicant-manager.lo -MD -MP -MF $(DEPDIR)/nm-supplicant-manager.Tpo -c -o nm-supplicant-manager.lo `test -f 'supplicant-manager/nm-supplicant-manager.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-supplicant-manager.Tpo $(DEPDIR)/nm-supplicant-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='supplicant-manager/nm-supplicant-manager.c' object='nm-supplicant-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-supplicant-manager.lo `test -f 'supplicant-manager/nm-supplicant-manager.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-manager.c - -nm-supplicant-settings-verify.lo: supplicant-manager/nm-supplicant-settings-verify.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-supplicant-settings-verify.lo -MD -MP -MF $(DEPDIR)/nm-supplicant-settings-verify.Tpo -c -o nm-supplicant-settings-verify.lo `test -f 'supplicant-manager/nm-supplicant-settings-verify.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-settings-verify.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-supplicant-settings-verify.Tpo $(DEPDIR)/nm-supplicant-settings-verify.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='supplicant-manager/nm-supplicant-settings-verify.c' object='nm-supplicant-settings-verify.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-supplicant-settings-verify.lo `test -f 'supplicant-manager/nm-supplicant-settings-verify.c' || echo '$(srcdir)/'`supplicant-manager/nm-supplicant-settings-verify.c - -nm-vpn-connection.lo: vpn-manager/nm-vpn-connection.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-vpn-connection.lo -MD -MP -MF $(DEPDIR)/nm-vpn-connection.Tpo -c -o nm-vpn-connection.lo `test -f 'vpn-manager/nm-vpn-connection.c' || echo '$(srcdir)/'`vpn-manager/nm-vpn-connection.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-vpn-connection.Tpo $(DEPDIR)/nm-vpn-connection.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='vpn-manager/nm-vpn-connection.c' object='nm-vpn-connection.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-vpn-connection.lo `test -f 'vpn-manager/nm-vpn-connection.c' || echo '$(srcdir)/'`vpn-manager/nm-vpn-connection.c - -nm-vpn-manager.lo: vpn-manager/nm-vpn-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-vpn-manager.lo -MD -MP -MF $(DEPDIR)/nm-vpn-manager.Tpo -c -o nm-vpn-manager.lo `test -f 'vpn-manager/nm-vpn-manager.c' || echo '$(srcdir)/'`vpn-manager/nm-vpn-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-vpn-manager.Tpo $(DEPDIR)/nm-vpn-manager.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='vpn-manager/nm-vpn-manager.c' object='nm-vpn-manager.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-vpn-manager.lo `test -f 'vpn-manager/nm-vpn-manager.c' || echo '$(srcdir)/'`vpn-manager/nm-vpn-manager.c - -wifi-utils-wext.lo: platform/wifi/wifi-utils-wext.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT wifi-utils-wext.lo -MD -MP -MF $(DEPDIR)/wifi-utils-wext.Tpo -c -o wifi-utils-wext.lo `test -f 'platform/wifi/wifi-utils-wext.c' || echo '$(srcdir)/'`platform/wifi/wifi-utils-wext.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/wifi-utils-wext.Tpo $(DEPDIR)/wifi-utils-wext.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/wifi/wifi-utils-wext.c' object='wifi-utils-wext.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wifi-utils-wext.lo `test -f 'platform/wifi/wifi-utils-wext.c' || echo '$(srcdir)/'`platform/wifi/wifi-utils-wext.c - -nm-fake-rdisc.lo: rdisc/nm-fake-rdisc.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-fake-rdisc.lo -MD -MP -MF $(DEPDIR)/nm-fake-rdisc.Tpo -c -o nm-fake-rdisc.lo `test -f 'rdisc/nm-fake-rdisc.c' || echo '$(srcdir)/'`rdisc/nm-fake-rdisc.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-fake-rdisc.Tpo $(DEPDIR)/nm-fake-rdisc.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rdisc/nm-fake-rdisc.c' object='nm-fake-rdisc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-fake-rdisc.lo `test -f 'rdisc/nm-fake-rdisc.c' || echo '$(srcdir)/'`rdisc/nm-fake-rdisc.c - -nm-fake-platform.lo: platform/nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-fake-platform.lo -MD -MP -MF $(DEPDIR)/nm-fake-platform.Tpo -c -o nm-fake-platform.lo `test -f 'platform/nm-fake-platform.c' || echo '$(srcdir)/'`platform/nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-fake-platform.Tpo $(DEPDIR)/nm-fake-platform.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='platform/nm-fake-platform.c' object='nm-fake-platform.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-fake-platform.lo `test -f 'platform/nm-fake-platform.c' || echo '$(srcdir)/'`platform/nm-fake-platform.c - -libsystemd_nm_la-nm-sd.lo: systemd/nm-sd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-nm-sd.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-nm-sd.Tpo -c -o libsystemd_nm_la-nm-sd.lo `test -f 'systemd/nm-sd.c' || echo '$(srcdir)/'`systemd/nm-sd.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-nm-sd.Tpo $(DEPDIR)/libsystemd_nm_la-nm-sd.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/nm-sd.c' object='libsystemd_nm_la-nm-sd.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-nm-sd.lo `test -f 'systemd/nm-sd.c' || echo '$(srcdir)/'`systemd/nm-sd.c - -libsystemd_nm_la-nm-sd-adapt.lo: systemd/sd-adapt/nm-sd-adapt.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-nm-sd-adapt.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-nm-sd-adapt.Tpo -c -o libsystemd_nm_la-nm-sd-adapt.lo `test -f 'systemd/sd-adapt/nm-sd-adapt.c' || echo '$(srcdir)/'`systemd/sd-adapt/nm-sd-adapt.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-nm-sd-adapt.Tpo $(DEPDIR)/libsystemd_nm_la-nm-sd-adapt.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/sd-adapt/nm-sd-adapt.c' object='libsystemd_nm_la-nm-sd-adapt.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-nm-sd-adapt.lo `test -f 'systemd/sd-adapt/nm-sd-adapt.c' || echo '$(srcdir)/'`systemd/sd-adapt/nm-sd-adapt.c - -libsystemd_nm_la-alloc-util.lo: systemd/src/basic/alloc-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-alloc-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-alloc-util.Tpo -c -o libsystemd_nm_la-alloc-util.lo `test -f 'systemd/src/basic/alloc-util.c' || echo '$(srcdir)/'`systemd/src/basic/alloc-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-alloc-util.Tpo $(DEPDIR)/libsystemd_nm_la-alloc-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/alloc-util.c' object='libsystemd_nm_la-alloc-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-alloc-util.lo `test -f 'systemd/src/basic/alloc-util.c' || echo '$(srcdir)/'`systemd/src/basic/alloc-util.c - -libsystemd_nm_la-escape.lo: systemd/src/basic/escape.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-escape.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-escape.Tpo -c -o libsystemd_nm_la-escape.lo `test -f 'systemd/src/basic/escape.c' || echo '$(srcdir)/'`systemd/src/basic/escape.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-escape.Tpo $(DEPDIR)/libsystemd_nm_la-escape.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/escape.c' object='libsystemd_nm_la-escape.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-escape.lo `test -f 'systemd/src/basic/escape.c' || echo '$(srcdir)/'`systemd/src/basic/escape.c - -libsystemd_nm_la-ether-addr-util.lo: systemd/src/basic/ether-addr-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-ether-addr-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-ether-addr-util.Tpo -c -o libsystemd_nm_la-ether-addr-util.lo `test -f 'systemd/src/basic/ether-addr-util.c' || echo '$(srcdir)/'`systemd/src/basic/ether-addr-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-ether-addr-util.Tpo $(DEPDIR)/libsystemd_nm_la-ether-addr-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/ether-addr-util.c' object='libsystemd_nm_la-ether-addr-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-ether-addr-util.lo `test -f 'systemd/src/basic/ether-addr-util.c' || echo '$(srcdir)/'`systemd/src/basic/ether-addr-util.c - -libsystemd_nm_la-extract-word.lo: systemd/src/basic/extract-word.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-extract-word.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-extract-word.Tpo -c -o libsystemd_nm_la-extract-word.lo `test -f 'systemd/src/basic/extract-word.c' || echo '$(srcdir)/'`systemd/src/basic/extract-word.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-extract-word.Tpo $(DEPDIR)/libsystemd_nm_la-extract-word.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/extract-word.c' object='libsystemd_nm_la-extract-word.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-extract-word.lo `test -f 'systemd/src/basic/extract-word.c' || echo '$(srcdir)/'`systemd/src/basic/extract-word.c - -libsystemd_nm_la-fd-util.lo: systemd/src/basic/fd-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-fd-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-fd-util.Tpo -c -o libsystemd_nm_la-fd-util.lo `test -f 'systemd/src/basic/fd-util.c' || echo '$(srcdir)/'`systemd/src/basic/fd-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-fd-util.Tpo $(DEPDIR)/libsystemd_nm_la-fd-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/fd-util.c' object='libsystemd_nm_la-fd-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-fd-util.lo `test -f 'systemd/src/basic/fd-util.c' || echo '$(srcdir)/'`systemd/src/basic/fd-util.c - -libsystemd_nm_la-fileio.lo: systemd/src/basic/fileio.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-fileio.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-fileio.Tpo -c -o libsystemd_nm_la-fileio.lo `test -f 'systemd/src/basic/fileio.c' || echo '$(srcdir)/'`systemd/src/basic/fileio.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-fileio.Tpo $(DEPDIR)/libsystemd_nm_la-fileio.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/fileio.c' object='libsystemd_nm_la-fileio.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-fileio.lo `test -f 'systemd/src/basic/fileio.c' || echo '$(srcdir)/'`systemd/src/basic/fileio.c - -libsystemd_nm_la-fs-util.lo: systemd/src/basic/fs-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-fs-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-fs-util.Tpo -c -o libsystemd_nm_la-fs-util.lo `test -f 'systemd/src/basic/fs-util.c' || echo '$(srcdir)/'`systemd/src/basic/fs-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-fs-util.Tpo $(DEPDIR)/libsystemd_nm_la-fs-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/fs-util.c' object='libsystemd_nm_la-fs-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-fs-util.lo `test -f 'systemd/src/basic/fs-util.c' || echo '$(srcdir)/'`systemd/src/basic/fs-util.c - -libsystemd_nm_la-hash-funcs.lo: systemd/src/basic/hash-funcs.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-hash-funcs.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-hash-funcs.Tpo -c -o libsystemd_nm_la-hash-funcs.lo `test -f 'systemd/src/basic/hash-funcs.c' || echo '$(srcdir)/'`systemd/src/basic/hash-funcs.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-hash-funcs.Tpo $(DEPDIR)/libsystemd_nm_la-hash-funcs.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/hash-funcs.c' object='libsystemd_nm_la-hash-funcs.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-hash-funcs.lo `test -f 'systemd/src/basic/hash-funcs.c' || echo '$(srcdir)/'`systemd/src/basic/hash-funcs.c - -libsystemd_nm_la-hashmap.lo: systemd/src/basic/hashmap.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-hashmap.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-hashmap.Tpo -c -o libsystemd_nm_la-hashmap.lo `test -f 'systemd/src/basic/hashmap.c' || echo '$(srcdir)/'`systemd/src/basic/hashmap.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-hashmap.Tpo $(DEPDIR)/libsystemd_nm_la-hashmap.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/hashmap.c' object='libsystemd_nm_la-hashmap.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-hashmap.lo `test -f 'systemd/src/basic/hashmap.c' || echo '$(srcdir)/'`systemd/src/basic/hashmap.c - -libsystemd_nm_la-hexdecoct.lo: systemd/src/basic/hexdecoct.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-hexdecoct.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-hexdecoct.Tpo -c -o libsystemd_nm_la-hexdecoct.lo `test -f 'systemd/src/basic/hexdecoct.c' || echo '$(srcdir)/'`systemd/src/basic/hexdecoct.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-hexdecoct.Tpo $(DEPDIR)/libsystemd_nm_la-hexdecoct.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/hexdecoct.c' object='libsystemd_nm_la-hexdecoct.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-hexdecoct.lo `test -f 'systemd/src/basic/hexdecoct.c' || echo '$(srcdir)/'`systemd/src/basic/hexdecoct.c - -libsystemd_nm_la-hostname-util.lo: systemd/src/basic/hostname-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-hostname-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-hostname-util.Tpo -c -o libsystemd_nm_la-hostname-util.lo `test -f 'systemd/src/basic/hostname-util.c' || echo '$(srcdir)/'`systemd/src/basic/hostname-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-hostname-util.Tpo $(DEPDIR)/libsystemd_nm_la-hostname-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/hostname-util.c' object='libsystemd_nm_la-hostname-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-hostname-util.lo `test -f 'systemd/src/basic/hostname-util.c' || echo '$(srcdir)/'`systemd/src/basic/hostname-util.c - -libsystemd_nm_la-in-addr-util.lo: systemd/src/basic/in-addr-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-in-addr-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-in-addr-util.Tpo -c -o libsystemd_nm_la-in-addr-util.lo `test -f 'systemd/src/basic/in-addr-util.c' || echo '$(srcdir)/'`systemd/src/basic/in-addr-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-in-addr-util.Tpo $(DEPDIR)/libsystemd_nm_la-in-addr-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/in-addr-util.c' object='libsystemd_nm_la-in-addr-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-in-addr-util.lo `test -f 'systemd/src/basic/in-addr-util.c' || echo '$(srcdir)/'`systemd/src/basic/in-addr-util.c - -libsystemd_nm_la-io-util.lo: systemd/src/basic/io-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-io-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-io-util.Tpo -c -o libsystemd_nm_la-io-util.lo `test -f 'systemd/src/basic/io-util.c' || echo '$(srcdir)/'`systemd/src/basic/io-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-io-util.Tpo $(DEPDIR)/libsystemd_nm_la-io-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/io-util.c' object='libsystemd_nm_la-io-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-io-util.lo `test -f 'systemd/src/basic/io-util.c' || echo '$(srcdir)/'`systemd/src/basic/io-util.c - -libsystemd_nm_la-mempool.lo: systemd/src/basic/mempool.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-mempool.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-mempool.Tpo -c -o libsystemd_nm_la-mempool.lo `test -f 'systemd/src/basic/mempool.c' || echo '$(srcdir)/'`systemd/src/basic/mempool.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-mempool.Tpo $(DEPDIR)/libsystemd_nm_la-mempool.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/mempool.c' object='libsystemd_nm_la-mempool.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-mempool.lo `test -f 'systemd/src/basic/mempool.c' || echo '$(srcdir)/'`systemd/src/basic/mempool.c - -libsystemd_nm_la-parse-util.lo: systemd/src/basic/parse-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-parse-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-parse-util.Tpo -c -o libsystemd_nm_la-parse-util.lo `test -f 'systemd/src/basic/parse-util.c' || echo '$(srcdir)/'`systemd/src/basic/parse-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-parse-util.Tpo $(DEPDIR)/libsystemd_nm_la-parse-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/parse-util.c' object='libsystemd_nm_la-parse-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-parse-util.lo `test -f 'systemd/src/basic/parse-util.c' || echo '$(srcdir)/'`systemd/src/basic/parse-util.c - -libsystemd_nm_la-path-util.lo: systemd/src/basic/path-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-path-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-path-util.Tpo -c -o libsystemd_nm_la-path-util.lo `test -f 'systemd/src/basic/path-util.c' || echo '$(srcdir)/'`systemd/src/basic/path-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-path-util.Tpo $(DEPDIR)/libsystemd_nm_la-path-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/path-util.c' object='libsystemd_nm_la-path-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-path-util.lo `test -f 'systemd/src/basic/path-util.c' || echo '$(srcdir)/'`systemd/src/basic/path-util.c - -libsystemd_nm_la-prioq.lo: systemd/src/basic/prioq.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-prioq.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-prioq.Tpo -c -o libsystemd_nm_la-prioq.lo `test -f 'systemd/src/basic/prioq.c' || echo '$(srcdir)/'`systemd/src/basic/prioq.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-prioq.Tpo $(DEPDIR)/libsystemd_nm_la-prioq.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/prioq.c' object='libsystemd_nm_la-prioq.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-prioq.lo `test -f 'systemd/src/basic/prioq.c' || echo '$(srcdir)/'`systemd/src/basic/prioq.c - -libsystemd_nm_la-random-util.lo: systemd/src/basic/random-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-random-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-random-util.Tpo -c -o libsystemd_nm_la-random-util.lo `test -f 'systemd/src/basic/random-util.c' || echo '$(srcdir)/'`systemd/src/basic/random-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-random-util.Tpo $(DEPDIR)/libsystemd_nm_la-random-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/random-util.c' object='libsystemd_nm_la-random-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-random-util.lo `test -f 'systemd/src/basic/random-util.c' || echo '$(srcdir)/'`systemd/src/basic/random-util.c - -libsystemd_nm_la-siphash24.lo: systemd/src/basic/siphash24.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-siphash24.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-siphash24.Tpo -c -o libsystemd_nm_la-siphash24.lo `test -f 'systemd/src/basic/siphash24.c' || echo '$(srcdir)/'`systemd/src/basic/siphash24.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-siphash24.Tpo $(DEPDIR)/libsystemd_nm_la-siphash24.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/siphash24.c' object='libsystemd_nm_la-siphash24.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-siphash24.lo `test -f 'systemd/src/basic/siphash24.c' || echo '$(srcdir)/'`systemd/src/basic/siphash24.c - -libsystemd_nm_la-socket-util.lo: systemd/src/basic/socket-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-socket-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-socket-util.Tpo -c -o libsystemd_nm_la-socket-util.lo `test -f 'systemd/src/basic/socket-util.c' || echo '$(srcdir)/'`systemd/src/basic/socket-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-socket-util.Tpo $(DEPDIR)/libsystemd_nm_la-socket-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/socket-util.c' object='libsystemd_nm_la-socket-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-socket-util.lo `test -f 'systemd/src/basic/socket-util.c' || echo '$(srcdir)/'`systemd/src/basic/socket-util.c - -libsystemd_nm_la-string-table.lo: systemd/src/basic/string-table.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-string-table.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-string-table.Tpo -c -o libsystemd_nm_la-string-table.lo `test -f 'systemd/src/basic/string-table.c' || echo '$(srcdir)/'`systemd/src/basic/string-table.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-string-table.Tpo $(DEPDIR)/libsystemd_nm_la-string-table.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/string-table.c' object='libsystemd_nm_la-string-table.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-string-table.lo `test -f 'systemd/src/basic/string-table.c' || echo '$(srcdir)/'`systemd/src/basic/string-table.c - -libsystemd_nm_la-string-util.lo: systemd/src/basic/string-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-string-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-string-util.Tpo -c -o libsystemd_nm_la-string-util.lo `test -f 'systemd/src/basic/string-util.c' || echo '$(srcdir)/'`systemd/src/basic/string-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-string-util.Tpo $(DEPDIR)/libsystemd_nm_la-string-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/string-util.c' object='libsystemd_nm_la-string-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-string-util.lo `test -f 'systemd/src/basic/string-util.c' || echo '$(srcdir)/'`systemd/src/basic/string-util.c - -libsystemd_nm_la-strv.lo: systemd/src/basic/strv.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-strv.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-strv.Tpo -c -o libsystemd_nm_la-strv.lo `test -f 'systemd/src/basic/strv.c' || echo '$(srcdir)/'`systemd/src/basic/strv.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-strv.Tpo $(DEPDIR)/libsystemd_nm_la-strv.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/strv.c' object='libsystemd_nm_la-strv.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-strv.lo `test -f 'systemd/src/basic/strv.c' || echo '$(srcdir)/'`systemd/src/basic/strv.c - -libsystemd_nm_la-time-util.lo: systemd/src/basic/time-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-time-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-time-util.Tpo -c -o libsystemd_nm_la-time-util.lo `test -f 'systemd/src/basic/time-util.c' || echo '$(srcdir)/'`systemd/src/basic/time-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-time-util.Tpo $(DEPDIR)/libsystemd_nm_la-time-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/time-util.c' object='libsystemd_nm_la-time-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-time-util.lo `test -f 'systemd/src/basic/time-util.c' || echo '$(srcdir)/'`systemd/src/basic/time-util.c - -libsystemd_nm_la-utf8.lo: systemd/src/basic/utf8.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-utf8.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-utf8.Tpo -c -o libsystemd_nm_la-utf8.lo `test -f 'systemd/src/basic/utf8.c' || echo '$(srcdir)/'`systemd/src/basic/utf8.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-utf8.Tpo $(DEPDIR)/libsystemd_nm_la-utf8.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/utf8.c' object='libsystemd_nm_la-utf8.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-utf8.lo `test -f 'systemd/src/basic/utf8.c' || echo '$(srcdir)/'`systemd/src/basic/utf8.c - -libsystemd_nm_la-util.lo: systemd/src/basic/util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-util.Tpo -c -o libsystemd_nm_la-util.lo `test -f 'systemd/src/basic/util.c' || echo '$(srcdir)/'`systemd/src/basic/util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-util.Tpo $(DEPDIR)/libsystemd_nm_la-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/basic/util.c' object='libsystemd_nm_la-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-util.lo `test -f 'systemd/src/basic/util.c' || echo '$(srcdir)/'`systemd/src/basic/util.c - -libsystemd_nm_la-arp-util.lo: systemd/src/libsystemd-network/arp-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-arp-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-arp-util.Tpo -c -o libsystemd_nm_la-arp-util.lo `test -f 'systemd/src/libsystemd-network/arp-util.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/arp-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-arp-util.Tpo $(DEPDIR)/libsystemd_nm_la-arp-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/arp-util.c' object='libsystemd_nm_la-arp-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-arp-util.lo `test -f 'systemd/src/libsystemd-network/arp-util.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/arp-util.c - -libsystemd_nm_la-dhcp-identifier.lo: systemd/src/libsystemd-network/dhcp-identifier.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-dhcp-identifier.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-dhcp-identifier.Tpo -c -o libsystemd_nm_la-dhcp-identifier.lo `test -f 'systemd/src/libsystemd-network/dhcp-identifier.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-identifier.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-dhcp-identifier.Tpo $(DEPDIR)/libsystemd_nm_la-dhcp-identifier.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/dhcp-identifier.c' object='libsystemd_nm_la-dhcp-identifier.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-dhcp-identifier.lo `test -f 'systemd/src/libsystemd-network/dhcp-identifier.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-identifier.c - -libsystemd_nm_la-dhcp-network.lo: systemd/src/libsystemd-network/dhcp-network.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-dhcp-network.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-dhcp-network.Tpo -c -o libsystemd_nm_la-dhcp-network.lo `test -f 'systemd/src/libsystemd-network/dhcp-network.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-network.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-dhcp-network.Tpo $(DEPDIR)/libsystemd_nm_la-dhcp-network.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/dhcp-network.c' object='libsystemd_nm_la-dhcp-network.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-dhcp-network.lo `test -f 'systemd/src/libsystemd-network/dhcp-network.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-network.c - -libsystemd_nm_la-dhcp-option.lo: systemd/src/libsystemd-network/dhcp-option.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-dhcp-option.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-dhcp-option.Tpo -c -o libsystemd_nm_la-dhcp-option.lo `test -f 'systemd/src/libsystemd-network/dhcp-option.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-option.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-dhcp-option.Tpo $(DEPDIR)/libsystemd_nm_la-dhcp-option.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/dhcp-option.c' object='libsystemd_nm_la-dhcp-option.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-dhcp-option.lo `test -f 'systemd/src/libsystemd-network/dhcp-option.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-option.c - -libsystemd_nm_la-dhcp-packet.lo: systemd/src/libsystemd-network/dhcp-packet.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-dhcp-packet.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-dhcp-packet.Tpo -c -o libsystemd_nm_la-dhcp-packet.lo `test -f 'systemd/src/libsystemd-network/dhcp-packet.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-packet.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-dhcp-packet.Tpo $(DEPDIR)/libsystemd_nm_la-dhcp-packet.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/dhcp-packet.c' object='libsystemd_nm_la-dhcp-packet.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-dhcp-packet.lo `test -f 'systemd/src/libsystemd-network/dhcp-packet.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp-packet.c - -libsystemd_nm_la-dhcp6-network.lo: systemd/src/libsystemd-network/dhcp6-network.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-dhcp6-network.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-dhcp6-network.Tpo -c -o libsystemd_nm_la-dhcp6-network.lo `test -f 'systemd/src/libsystemd-network/dhcp6-network.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp6-network.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-dhcp6-network.Tpo $(DEPDIR)/libsystemd_nm_la-dhcp6-network.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/dhcp6-network.c' object='libsystemd_nm_la-dhcp6-network.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-dhcp6-network.lo `test -f 'systemd/src/libsystemd-network/dhcp6-network.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp6-network.c - -libsystemd_nm_la-dhcp6-option.lo: systemd/src/libsystemd-network/dhcp6-option.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-dhcp6-option.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-dhcp6-option.Tpo -c -o libsystemd_nm_la-dhcp6-option.lo `test -f 'systemd/src/libsystemd-network/dhcp6-option.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp6-option.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-dhcp6-option.Tpo $(DEPDIR)/libsystemd_nm_la-dhcp6-option.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/dhcp6-option.c' object='libsystemd_nm_la-dhcp6-option.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-dhcp6-option.lo `test -f 'systemd/src/libsystemd-network/dhcp6-option.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/dhcp6-option.c - -libsystemd_nm_la-lldp-neighbor.lo: systemd/src/libsystemd-network/lldp-neighbor.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-lldp-neighbor.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-lldp-neighbor.Tpo -c -o libsystemd_nm_la-lldp-neighbor.lo `test -f 'systemd/src/libsystemd-network/lldp-neighbor.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/lldp-neighbor.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-lldp-neighbor.Tpo $(DEPDIR)/libsystemd_nm_la-lldp-neighbor.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/lldp-neighbor.c' object='libsystemd_nm_la-lldp-neighbor.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-lldp-neighbor.lo `test -f 'systemd/src/libsystemd-network/lldp-neighbor.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/lldp-neighbor.c - -libsystemd_nm_la-lldp-network.lo: systemd/src/libsystemd-network/lldp-network.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-lldp-network.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-lldp-network.Tpo -c -o libsystemd_nm_la-lldp-network.lo `test -f 'systemd/src/libsystemd-network/lldp-network.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/lldp-network.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-lldp-network.Tpo $(DEPDIR)/libsystemd_nm_la-lldp-network.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/lldp-network.c' object='libsystemd_nm_la-lldp-network.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-lldp-network.lo `test -f 'systemd/src/libsystemd-network/lldp-network.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/lldp-network.c - -libsystemd_nm_la-network-internal.lo: systemd/src/libsystemd-network/network-internal.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-network-internal.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-network-internal.Tpo -c -o libsystemd_nm_la-network-internal.lo `test -f 'systemd/src/libsystemd-network/network-internal.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/network-internal.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-network-internal.Tpo $(DEPDIR)/libsystemd_nm_la-network-internal.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/network-internal.c' object='libsystemd_nm_la-network-internal.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-network-internal.lo `test -f 'systemd/src/libsystemd-network/network-internal.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/network-internal.c - -libsystemd_nm_la-sd-dhcp-client.lo: systemd/src/libsystemd-network/sd-dhcp-client.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-dhcp-client.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-dhcp-client.Tpo -c -o libsystemd_nm_la-sd-dhcp-client.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp-client.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp-client.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-dhcp-client.Tpo $(DEPDIR)/libsystemd_nm_la-sd-dhcp-client.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/sd-dhcp-client.c' object='libsystemd_nm_la-sd-dhcp-client.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-dhcp-client.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp-client.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp-client.c - -libsystemd_nm_la-sd-dhcp-lease.lo: systemd/src/libsystemd-network/sd-dhcp-lease.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-dhcp-lease.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-dhcp-lease.Tpo -c -o libsystemd_nm_la-sd-dhcp-lease.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp-lease.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp-lease.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-dhcp-lease.Tpo $(DEPDIR)/libsystemd_nm_la-sd-dhcp-lease.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/sd-dhcp-lease.c' object='libsystemd_nm_la-sd-dhcp-lease.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-dhcp-lease.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp-lease.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp-lease.c - -libsystemd_nm_la-sd-dhcp6-client.lo: systemd/src/libsystemd-network/sd-dhcp6-client.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-dhcp6-client.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-dhcp6-client.Tpo -c -o libsystemd_nm_la-sd-dhcp6-client.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp6-client.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp6-client.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-dhcp6-client.Tpo $(DEPDIR)/libsystemd_nm_la-sd-dhcp6-client.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/sd-dhcp6-client.c' object='libsystemd_nm_la-sd-dhcp6-client.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-dhcp6-client.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp6-client.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp6-client.c - -libsystemd_nm_la-sd-dhcp6-lease.lo: systemd/src/libsystemd-network/sd-dhcp6-lease.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-dhcp6-lease.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-dhcp6-lease.Tpo -c -o libsystemd_nm_la-sd-dhcp6-lease.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp6-lease.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp6-lease.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-dhcp6-lease.Tpo $(DEPDIR)/libsystemd_nm_la-sd-dhcp6-lease.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/sd-dhcp6-lease.c' object='libsystemd_nm_la-sd-dhcp6-lease.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-dhcp6-lease.lo `test -f 'systemd/src/libsystemd-network/sd-dhcp6-lease.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-dhcp6-lease.c - -libsystemd_nm_la-sd-ipv4acd.lo: systemd/src/libsystemd-network/sd-ipv4acd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-ipv4acd.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-ipv4acd.Tpo -c -o libsystemd_nm_la-sd-ipv4acd.lo `test -f 'systemd/src/libsystemd-network/sd-ipv4acd.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-ipv4acd.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-ipv4acd.Tpo $(DEPDIR)/libsystemd_nm_la-sd-ipv4acd.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/sd-ipv4acd.c' object='libsystemd_nm_la-sd-ipv4acd.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-ipv4acd.lo `test -f 'systemd/src/libsystemd-network/sd-ipv4acd.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-ipv4acd.c - -libsystemd_nm_la-sd-ipv4ll.lo: systemd/src/libsystemd-network/sd-ipv4ll.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-ipv4ll.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-ipv4ll.Tpo -c -o libsystemd_nm_la-sd-ipv4ll.lo `test -f 'systemd/src/libsystemd-network/sd-ipv4ll.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-ipv4ll.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-ipv4ll.Tpo $(DEPDIR)/libsystemd_nm_la-sd-ipv4ll.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/sd-ipv4ll.c' object='libsystemd_nm_la-sd-ipv4ll.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-ipv4ll.lo `test -f 'systemd/src/libsystemd-network/sd-ipv4ll.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-ipv4ll.c - -libsystemd_nm_la-sd-lldp.lo: systemd/src/libsystemd-network/sd-lldp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-lldp.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-lldp.Tpo -c -o libsystemd_nm_la-sd-lldp.lo `test -f 'systemd/src/libsystemd-network/sd-lldp.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-lldp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-lldp.Tpo $(DEPDIR)/libsystemd_nm_la-sd-lldp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd-network/sd-lldp.c' object='libsystemd_nm_la-sd-lldp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-lldp.lo `test -f 'systemd/src/libsystemd-network/sd-lldp.c' || echo '$(srcdir)/'`systemd/src/libsystemd-network/sd-lldp.c - -libsystemd_nm_la-sd-event.lo: systemd/src/libsystemd/sd-event/sd-event.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-event.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-event.Tpo -c -o libsystemd_nm_la-sd-event.lo `test -f 'systemd/src/libsystemd/sd-event/sd-event.c' || echo '$(srcdir)/'`systemd/src/libsystemd/sd-event/sd-event.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-event.Tpo $(DEPDIR)/libsystemd_nm_la-sd-event.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd/sd-event/sd-event.c' object='libsystemd_nm_la-sd-event.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-event.lo `test -f 'systemd/src/libsystemd/sd-event/sd-event.c' || echo '$(srcdir)/'`systemd/src/libsystemd/sd-event/sd-event.c - -libsystemd_nm_la-id128-util.lo: systemd/src/libsystemd/sd-id128/id128-util.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-id128-util.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-id128-util.Tpo -c -o libsystemd_nm_la-id128-util.lo `test -f 'systemd/src/libsystemd/sd-id128/id128-util.c' || echo '$(srcdir)/'`systemd/src/libsystemd/sd-id128/id128-util.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-id128-util.Tpo $(DEPDIR)/libsystemd_nm_la-id128-util.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd/sd-id128/id128-util.c' object='libsystemd_nm_la-id128-util.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-id128-util.lo `test -f 'systemd/src/libsystemd/sd-id128/id128-util.c' || echo '$(srcdir)/'`systemd/src/libsystemd/sd-id128/id128-util.c - -libsystemd_nm_la-sd-id128.lo: systemd/src/libsystemd/sd-id128/sd-id128.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-sd-id128.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-sd-id128.Tpo -c -o libsystemd_nm_la-sd-id128.lo `test -f 'systemd/src/libsystemd/sd-id128/sd-id128.c' || echo '$(srcdir)/'`systemd/src/libsystemd/sd-id128/sd-id128.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-sd-id128.Tpo $(DEPDIR)/libsystemd_nm_la-sd-id128.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/libsystemd/sd-id128/sd-id128.c' object='libsystemd_nm_la-sd-id128.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-sd-id128.lo `test -f 'systemd/src/libsystemd/sd-id128/sd-id128.c' || echo '$(srcdir)/'`systemd/src/libsystemd/sd-id128/sd-id128.c - -libsystemd_nm_la-dns-domain.lo: systemd/src/shared/dns-domain.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsystemd_nm_la-dns-domain.lo -MD -MP -MF $(DEPDIR)/libsystemd_nm_la-dns-domain.Tpo -c -o libsystemd_nm_la-dns-domain.lo `test -f 'systemd/src/shared/dns-domain.c' || echo '$(srcdir)/'`systemd/src/shared/dns-domain.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsystemd_nm_la-dns-domain.Tpo $(DEPDIR)/libsystemd_nm_la-dns-domain.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='systemd/src/shared/dns-domain.c' object='libsystemd_nm_la-dns-domain.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsystemd_nm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsystemd_nm_la-dns-domain.lo `test -f 'systemd/src/shared/dns-domain.c' || echo '$(srcdir)/'`systemd/src/shared/dns-domain.c - -nm-device-bond.o: devices/nm-device-bond.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-bond.o -MD -MP -MF $(DEPDIR)/nm-device-bond.Tpo -c -o nm-device-bond.o `test -f 'devices/nm-device-bond.c' || echo '$(srcdir)/'`devices/nm-device-bond.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-bond.Tpo $(DEPDIR)/nm-device-bond.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-bond.c' object='nm-device-bond.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-bond.o `test -f 'devices/nm-device-bond.c' || echo '$(srcdir)/'`devices/nm-device-bond.c - -nm-device-bond.obj: devices/nm-device-bond.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-bond.obj -MD -MP -MF $(DEPDIR)/nm-device-bond.Tpo -c -o nm-device-bond.obj `if test -f 'devices/nm-device-bond.c'; then $(CYGPATH_W) 'devices/nm-device-bond.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-bond.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-bond.Tpo $(DEPDIR)/nm-device-bond.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-bond.c' object='nm-device-bond.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-bond.obj `if test -f 'devices/nm-device-bond.c'; then $(CYGPATH_W) 'devices/nm-device-bond.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-bond.c'; fi` - -nm-device-bridge.o: devices/nm-device-bridge.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-bridge.o -MD -MP -MF $(DEPDIR)/nm-device-bridge.Tpo -c -o nm-device-bridge.o `test -f 'devices/nm-device-bridge.c' || echo '$(srcdir)/'`devices/nm-device-bridge.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-bridge.Tpo $(DEPDIR)/nm-device-bridge.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-bridge.c' object='nm-device-bridge.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-bridge.o `test -f 'devices/nm-device-bridge.c' || echo '$(srcdir)/'`devices/nm-device-bridge.c - -nm-device-bridge.obj: devices/nm-device-bridge.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-bridge.obj -MD -MP -MF $(DEPDIR)/nm-device-bridge.Tpo -c -o nm-device-bridge.obj `if test -f 'devices/nm-device-bridge.c'; then $(CYGPATH_W) 'devices/nm-device-bridge.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-bridge.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-bridge.Tpo $(DEPDIR)/nm-device-bridge.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-bridge.c' object='nm-device-bridge.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-bridge.obj `if test -f 'devices/nm-device-bridge.c'; then $(CYGPATH_W) 'devices/nm-device-bridge.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-bridge.c'; fi` - -nm-device-ethernet.o: devices/nm-device-ethernet.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-ethernet.o -MD -MP -MF $(DEPDIR)/nm-device-ethernet.Tpo -c -o nm-device-ethernet.o `test -f 'devices/nm-device-ethernet.c' || echo '$(srcdir)/'`devices/nm-device-ethernet.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-ethernet.Tpo $(DEPDIR)/nm-device-ethernet.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-ethernet.c' object='nm-device-ethernet.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-ethernet.o `test -f 'devices/nm-device-ethernet.c' || echo '$(srcdir)/'`devices/nm-device-ethernet.c - -nm-device-ethernet.obj: devices/nm-device-ethernet.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-ethernet.obj -MD -MP -MF $(DEPDIR)/nm-device-ethernet.Tpo -c -o nm-device-ethernet.obj `if test -f 'devices/nm-device-ethernet.c'; then $(CYGPATH_W) 'devices/nm-device-ethernet.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-ethernet.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-ethernet.Tpo $(DEPDIR)/nm-device-ethernet.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-ethernet.c' object='nm-device-ethernet.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-ethernet.obj `if test -f 'devices/nm-device-ethernet.c'; then $(CYGPATH_W) 'devices/nm-device-ethernet.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-ethernet.c'; fi` - -nm-device-infiniband.o: devices/nm-device-infiniband.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-infiniband.o -MD -MP -MF $(DEPDIR)/nm-device-infiniband.Tpo -c -o nm-device-infiniband.o `test -f 'devices/nm-device-infiniband.c' || echo '$(srcdir)/'`devices/nm-device-infiniband.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-infiniband.Tpo $(DEPDIR)/nm-device-infiniband.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-infiniband.c' object='nm-device-infiniband.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-infiniband.o `test -f 'devices/nm-device-infiniband.c' || echo '$(srcdir)/'`devices/nm-device-infiniband.c - -nm-device-infiniband.obj: devices/nm-device-infiniband.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-infiniband.obj -MD -MP -MF $(DEPDIR)/nm-device-infiniband.Tpo -c -o nm-device-infiniband.obj `if test -f 'devices/nm-device-infiniband.c'; then $(CYGPATH_W) 'devices/nm-device-infiniband.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-infiniband.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-infiniband.Tpo $(DEPDIR)/nm-device-infiniband.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-infiniband.c' object='nm-device-infiniband.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-infiniband.obj `if test -f 'devices/nm-device-infiniband.c'; then $(CYGPATH_W) 'devices/nm-device-infiniband.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-infiniband.c'; fi` - -nm-device-ip-tunnel.o: devices/nm-device-ip-tunnel.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-ip-tunnel.o -MD -MP -MF $(DEPDIR)/nm-device-ip-tunnel.Tpo -c -o nm-device-ip-tunnel.o `test -f 'devices/nm-device-ip-tunnel.c' || echo '$(srcdir)/'`devices/nm-device-ip-tunnel.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-ip-tunnel.Tpo $(DEPDIR)/nm-device-ip-tunnel.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-ip-tunnel.c' object='nm-device-ip-tunnel.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-ip-tunnel.o `test -f 'devices/nm-device-ip-tunnel.c' || echo '$(srcdir)/'`devices/nm-device-ip-tunnel.c - -nm-device-ip-tunnel.obj: devices/nm-device-ip-tunnel.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-ip-tunnel.obj -MD -MP -MF $(DEPDIR)/nm-device-ip-tunnel.Tpo -c -o nm-device-ip-tunnel.obj `if test -f 'devices/nm-device-ip-tunnel.c'; then $(CYGPATH_W) 'devices/nm-device-ip-tunnel.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-ip-tunnel.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-ip-tunnel.Tpo $(DEPDIR)/nm-device-ip-tunnel.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-ip-tunnel.c' object='nm-device-ip-tunnel.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-ip-tunnel.obj `if test -f 'devices/nm-device-ip-tunnel.c'; then $(CYGPATH_W) 'devices/nm-device-ip-tunnel.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-ip-tunnel.c'; fi` - -nm-device-macvlan.o: devices/nm-device-macvlan.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-macvlan.o -MD -MP -MF $(DEPDIR)/nm-device-macvlan.Tpo -c -o nm-device-macvlan.o `test -f 'devices/nm-device-macvlan.c' || echo '$(srcdir)/'`devices/nm-device-macvlan.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-macvlan.Tpo $(DEPDIR)/nm-device-macvlan.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-macvlan.c' object='nm-device-macvlan.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-macvlan.o `test -f 'devices/nm-device-macvlan.c' || echo '$(srcdir)/'`devices/nm-device-macvlan.c - -nm-device-macvlan.obj: devices/nm-device-macvlan.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-macvlan.obj -MD -MP -MF $(DEPDIR)/nm-device-macvlan.Tpo -c -o nm-device-macvlan.obj `if test -f 'devices/nm-device-macvlan.c'; then $(CYGPATH_W) 'devices/nm-device-macvlan.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-macvlan.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-macvlan.Tpo $(DEPDIR)/nm-device-macvlan.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-macvlan.c' object='nm-device-macvlan.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-macvlan.obj `if test -f 'devices/nm-device-macvlan.c'; then $(CYGPATH_W) 'devices/nm-device-macvlan.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-macvlan.c'; fi` - -nm-device-tun.o: devices/nm-device-tun.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-tun.o -MD -MP -MF $(DEPDIR)/nm-device-tun.Tpo -c -o nm-device-tun.o `test -f 'devices/nm-device-tun.c' || echo '$(srcdir)/'`devices/nm-device-tun.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-tun.Tpo $(DEPDIR)/nm-device-tun.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-tun.c' object='nm-device-tun.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-tun.o `test -f 'devices/nm-device-tun.c' || echo '$(srcdir)/'`devices/nm-device-tun.c - -nm-device-tun.obj: devices/nm-device-tun.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-tun.obj -MD -MP -MF $(DEPDIR)/nm-device-tun.Tpo -c -o nm-device-tun.obj `if test -f 'devices/nm-device-tun.c'; then $(CYGPATH_W) 'devices/nm-device-tun.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-tun.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-tun.Tpo $(DEPDIR)/nm-device-tun.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-tun.c' object='nm-device-tun.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-tun.obj `if test -f 'devices/nm-device-tun.c'; then $(CYGPATH_W) 'devices/nm-device-tun.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-tun.c'; fi` - -nm-device-veth.o: devices/nm-device-veth.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-veth.o -MD -MP -MF $(DEPDIR)/nm-device-veth.Tpo -c -o nm-device-veth.o `test -f 'devices/nm-device-veth.c' || echo '$(srcdir)/'`devices/nm-device-veth.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-veth.Tpo $(DEPDIR)/nm-device-veth.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-veth.c' object='nm-device-veth.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-veth.o `test -f 'devices/nm-device-veth.c' || echo '$(srcdir)/'`devices/nm-device-veth.c - -nm-device-veth.obj: devices/nm-device-veth.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-veth.obj -MD -MP -MF $(DEPDIR)/nm-device-veth.Tpo -c -o nm-device-veth.obj `if test -f 'devices/nm-device-veth.c'; then $(CYGPATH_W) 'devices/nm-device-veth.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-veth.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-veth.Tpo $(DEPDIR)/nm-device-veth.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-veth.c' object='nm-device-veth.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-veth.obj `if test -f 'devices/nm-device-veth.c'; then $(CYGPATH_W) 'devices/nm-device-veth.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-veth.c'; fi` - -nm-device-vlan.o: devices/nm-device-vlan.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-vlan.o -MD -MP -MF $(DEPDIR)/nm-device-vlan.Tpo -c -o nm-device-vlan.o `test -f 'devices/nm-device-vlan.c' || echo '$(srcdir)/'`devices/nm-device-vlan.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-vlan.Tpo $(DEPDIR)/nm-device-vlan.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-vlan.c' object='nm-device-vlan.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-vlan.o `test -f 'devices/nm-device-vlan.c' || echo '$(srcdir)/'`devices/nm-device-vlan.c - -nm-device-vlan.obj: devices/nm-device-vlan.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-vlan.obj -MD -MP -MF $(DEPDIR)/nm-device-vlan.Tpo -c -o nm-device-vlan.obj `if test -f 'devices/nm-device-vlan.c'; then $(CYGPATH_W) 'devices/nm-device-vlan.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-vlan.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-vlan.Tpo $(DEPDIR)/nm-device-vlan.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-vlan.c' object='nm-device-vlan.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-vlan.obj `if test -f 'devices/nm-device-vlan.c'; then $(CYGPATH_W) 'devices/nm-device-vlan.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-vlan.c'; fi` - -nm-device-vxlan.o: devices/nm-device-vxlan.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-vxlan.o -MD -MP -MF $(DEPDIR)/nm-device-vxlan.Tpo -c -o nm-device-vxlan.o `test -f 'devices/nm-device-vxlan.c' || echo '$(srcdir)/'`devices/nm-device-vxlan.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-vxlan.Tpo $(DEPDIR)/nm-device-vxlan.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-vxlan.c' object='nm-device-vxlan.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-vxlan.o `test -f 'devices/nm-device-vxlan.c' || echo '$(srcdir)/'`devices/nm-device-vxlan.c - -nm-device-vxlan.obj: devices/nm-device-vxlan.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-device-vxlan.obj -MD -MP -MF $(DEPDIR)/nm-device-vxlan.Tpo -c -o nm-device-vxlan.obj `if test -f 'devices/nm-device-vxlan.c'; then $(CYGPATH_W) 'devices/nm-device-vxlan.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-vxlan.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-device-vxlan.Tpo $(DEPDIR)/nm-device-vxlan.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='devices/nm-device-vxlan.c' object='nm-device-vxlan.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-device-vxlan.obj `if test -f 'devices/nm-device-vxlan.c'; then $(CYGPATH_W) 'devices/nm-device-vxlan.c'; else $(CYGPATH_W) '$(srcdir)/devices/nm-device-vxlan.c'; fi` - -nm-dhcp-dhclient.o: dhcp-manager/nm-dhcp-dhclient.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-dhclient.o -MD -MP -MF $(DEPDIR)/nm-dhcp-dhclient.Tpo -c -o nm-dhcp-dhclient.o `test -f 'dhcp-manager/nm-dhcp-dhclient.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-dhclient.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-dhclient.Tpo $(DEPDIR)/nm-dhcp-dhclient.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-dhclient.c' object='nm-dhcp-dhclient.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-dhclient.o `test -f 'dhcp-manager/nm-dhcp-dhclient.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-dhclient.c - -nm-dhcp-dhclient.obj: dhcp-manager/nm-dhcp-dhclient.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-dhclient.obj -MD -MP -MF $(DEPDIR)/nm-dhcp-dhclient.Tpo -c -o nm-dhcp-dhclient.obj `if test -f 'dhcp-manager/nm-dhcp-dhclient.c'; then $(CYGPATH_W) 'dhcp-manager/nm-dhcp-dhclient.c'; else $(CYGPATH_W) '$(srcdir)/dhcp-manager/nm-dhcp-dhclient.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-dhclient.Tpo $(DEPDIR)/nm-dhcp-dhclient.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-dhclient.c' object='nm-dhcp-dhclient.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-dhclient.obj `if test -f 'dhcp-manager/nm-dhcp-dhclient.c'; then $(CYGPATH_W) 'dhcp-manager/nm-dhcp-dhclient.c'; else $(CYGPATH_W) '$(srcdir)/dhcp-manager/nm-dhcp-dhclient.c'; fi` - -nm-dhcp-dhcpcd.o: dhcp-manager/nm-dhcp-dhcpcd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-dhcpcd.o -MD -MP -MF $(DEPDIR)/nm-dhcp-dhcpcd.Tpo -c -o nm-dhcp-dhcpcd.o `test -f 'dhcp-manager/nm-dhcp-dhcpcd.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-dhcpcd.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-dhcpcd.Tpo $(DEPDIR)/nm-dhcp-dhcpcd.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-dhcpcd.c' object='nm-dhcp-dhcpcd.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-dhcpcd.o `test -f 'dhcp-manager/nm-dhcp-dhcpcd.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-dhcpcd.c - -nm-dhcp-dhcpcd.obj: dhcp-manager/nm-dhcp-dhcpcd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-dhcpcd.obj -MD -MP -MF $(DEPDIR)/nm-dhcp-dhcpcd.Tpo -c -o nm-dhcp-dhcpcd.obj `if test -f 'dhcp-manager/nm-dhcp-dhcpcd.c'; then $(CYGPATH_W) 'dhcp-manager/nm-dhcp-dhcpcd.c'; else $(CYGPATH_W) '$(srcdir)/dhcp-manager/nm-dhcp-dhcpcd.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-dhcpcd.Tpo $(DEPDIR)/nm-dhcp-dhcpcd.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-dhcpcd.c' object='nm-dhcp-dhcpcd.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-dhcpcd.obj `if test -f 'dhcp-manager/nm-dhcp-dhcpcd.c'; then $(CYGPATH_W) 'dhcp-manager/nm-dhcp-dhcpcd.c'; else $(CYGPATH_W) '$(srcdir)/dhcp-manager/nm-dhcp-dhcpcd.c'; fi` - -nm-dhcp-systemd.o: dhcp-manager/nm-dhcp-systemd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-systemd.o -MD -MP -MF $(DEPDIR)/nm-dhcp-systemd.Tpo -c -o nm-dhcp-systemd.o `test -f 'dhcp-manager/nm-dhcp-systemd.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-systemd.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-systemd.Tpo $(DEPDIR)/nm-dhcp-systemd.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-systemd.c' object='nm-dhcp-systemd.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-systemd.o `test -f 'dhcp-manager/nm-dhcp-systemd.c' || echo '$(srcdir)/'`dhcp-manager/nm-dhcp-systemd.c - -nm-dhcp-systemd.obj: dhcp-manager/nm-dhcp-systemd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-systemd.obj -MD -MP -MF $(DEPDIR)/nm-dhcp-systemd.Tpo -c -o nm-dhcp-systemd.obj `if test -f 'dhcp-manager/nm-dhcp-systemd.c'; then $(CYGPATH_W) 'dhcp-manager/nm-dhcp-systemd.c'; else $(CYGPATH_W) '$(srcdir)/dhcp-manager/nm-dhcp-systemd.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-systemd.Tpo $(DEPDIR)/nm-dhcp-systemd.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhcp-manager/nm-dhcp-systemd.c' object='nm-dhcp-systemd.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-systemd.obj `if test -f 'dhcp-manager/nm-dhcp-systemd.c'; then $(CYGPATH_W) 'dhcp-manager/nm-dhcp-systemd.c'; else $(CYGPATH_W) '$(srcdir)/dhcp-manager/nm-dhcp-systemd.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-dbusserviceDATA: $(dbusservice_DATA) - @$(NORMAL_INSTALL) - @list='$(dbusservice_DATA)'; test -n "$(dbusservicedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(dbusservicedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(dbusservicedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dbusservicedir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(dbusservicedir)" || exit $$?; \ - done - -uninstall-dbusserviceDATA: - @$(NORMAL_UNINSTALL) - @list='$(dbusservice_DATA)'; test -n "$(dbusservicedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(dbusservicedir)'; $(am__uninstall_files_from_dir) - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-recursive -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(dbusservicedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-recursive - -clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ - clean-noinstLTLIBRARIES clean-sbinPROGRAMS mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-dbusserviceDATA - @$(NORMAL_INSTALL) - $(MAKE) $(AM_MAKEFLAGS) install-data-hook -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-libexecPROGRAMS install-sbinPROGRAMS - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-dbusserviceDATA uninstall-libexecPROGRAMS \ - uninstall-sbinPROGRAMS - -.MAKE: $(am__recursive_targets) all check install install-am \ - install-data-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libexecPROGRAMS \ - clean-libtool clean-noinstLTLIBRARIES clean-sbinPROGRAMS \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-data-hook \ - install-dbusserviceDATA install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-libexecPROGRAMS \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-sbinPROGRAMS install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-dbusserviceDATA \ - uninstall-libexecPROGRAMS uninstall-sbinPROGRAMS - -.PRECIOUS: Makefile - -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ -install-data-hook: - $(mkinstalldirs) -m 0755 $(DESTDIR)$(rundir) - $(mkinstalldirs) -m 0700 $(DESTDIR)$(statedir) - $(mkinstalldirs) -m 0755 $(DESTDIR)$(pkglibdir) - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/NetworkManager.ver b/src/NetworkManager.ver deleted file mode 100644 index d5358e5c..00000000 --- a/src/NetworkManager.ver +++ /dev/null @@ -1,20 +0,0 @@ -{ -global: - nm_*; - nmp_*; - _nm*; - NM*; - _NM*; - - /* The _IO_stdin_used symbol is used by the GNU libc to determine - which version of the I/O function should be used. Not - exporting it means that the "old" version is used, causing - crashes or other issues on some architectures. It should be - exported as an anonymous tag, but ld does not support mixing - anonymous version tags with other version tags. Fortunately - the GNU libc is able to cope with the symbol having the wrong - version tag. */ - _IO_stdin_used; -local: - *; -}; diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 7cfe03f1..55b660db 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -30,11 +30,11 @@ #include "nm-setting-ip6-config.h" #include "nm-core-internal.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-exported-object.h" #include "nm-auth-utils.h" -/******************************************************************************/ +/*****************************************************************************/ /** * nm_utils_get_shared_wifi_permission: @@ -65,7 +65,7 @@ nm_utils_get_shared_wifi_permission (NMConnection *connection) return NULL; } -/******************************************************************************/ +/*****************************************************************************/ static char * get_new_connection_name (const GSList *existing, @@ -774,7 +774,7 @@ nm_utils_match_connection (GSList *connections, return best_match; } -/******************************************************************************/ +/*****************************************************************************/ /** * nm_utils_g_value_set_object_path: @@ -830,4 +830,4 @@ nm_utils_g_value_set_object_path_array (GValue *value, g_value_take_boxed (value, paths); } -/******************************************************************************/ +/*****************************************************************************/ diff --git a/src/devices/Makefile.am b/src/devices/Makefile.am deleted file mode 100644 index 3c6155b9..00000000 --- a/src/devices/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = tests diff --git a/src/devices/Makefile.in b/src/devices/Makefile.in deleted file mode 100644 index b247b35b..00000000 --- a/src/devices/Makefile.in +++ /dev/null @@ -1,781 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/devices -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = tests -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/adsl/Makefile.am b/src/devices/adsl/Makefile.am deleted file mode 100644 index 9075021c..00000000 --- a/src/devices/adsl/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/platform \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-adsl"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GUDEV_CFLAGS) - -pkglib_LTLIBRARIES = libnm-device-plugin-adsl.la - -SYMBOL_VIS_FILE=$(srcdir)/exports.ver - -libnm_device_plugin_adsl_la_SOURCES = \ - nm-atm-manager.c \ - nm-atm-manager.h \ - nm-device-adsl.c \ - nm-device-adsl.h - -libnm_device_plugin_adsl_la_LDFLAGS = \ - -module -avoid-version \ - -Wl,--version-script=$(SYMBOL_VIS_FILE) - -libnm_device_plugin_adsl_la_LIBADD = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(GUDEV_LIBS) - -EXTRA_DIST = $(SYMBOL_VIS_FILE) - -if ENABLE_TESTS - -check-local: - $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-adsl.so $(SYMBOL_VIS_FILE) - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-adsl.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - diff --git a/src/devices/adsl/Makefile.in b/src/devices/adsl/Makefile.in deleted file mode 100644 index 37015ab1..00000000 --- a/src/devices/adsl/Makefile.in +++ /dev/null @@ -1,853 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/devices/adsl -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(pkglib_LTLIBRARIES) -am__DEPENDENCIES_1 = -libnm_device_plugin_adsl_la_DEPENDENCIES = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(am__DEPENDENCIES_1) -am_libnm_device_plugin_adsl_la_OBJECTS = nm-atm-manager.lo \ - nm-device-adsl.lo -libnm_device_plugin_adsl_la_OBJECTS = \ - $(am_libnm_device_plugin_adsl_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_device_plugin_adsl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(libnm_device_plugin_adsl_la_LDFLAGS) \ - $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libnm_device_plugin_adsl_la_SOURCES) -DIST_SOURCES = $(libnm_device_plugin_adsl_la_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/platform \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-adsl"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GUDEV_CFLAGS) - -pkglib_LTLIBRARIES = libnm-device-plugin-adsl.la -SYMBOL_VIS_FILE = $(srcdir)/exports.ver -libnm_device_plugin_adsl_la_SOURCES = \ - nm-atm-manager.c \ - nm-atm-manager.h \ - nm-device-adsl.c \ - nm-device-adsl.h - -libnm_device_plugin_adsl_la_LDFLAGS = \ - -module -avoid-version \ - -Wl,--version-script=$(SYMBOL_VIS_FILE) - -libnm_device_plugin_adsl_la_LIBADD = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(GUDEV_LIBS) - -EXTRA_DIST = $(SYMBOL_VIS_FILE) -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/adsl/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/adsl/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnm-device-plugin-adsl.la: $(libnm_device_plugin_adsl_la_OBJECTS) $(libnm_device_plugin_adsl_la_DEPENDENCIES) $(EXTRA_libnm_device_plugin_adsl_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_device_plugin_adsl_la_LINK) -rpath $(pkglibdir) $(libnm_device_plugin_adsl_la_OBJECTS) $(libnm_device_plugin_adsl_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-atm-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-adsl.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ - clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkglibLTLIBRARIES install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-adsl.so $(SYMBOL_VIS_FILE) -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-adsl.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/adsl/exports.ver b/src/devices/adsl/exports.ver deleted file mode 100644 index 24cd848c..00000000 --- a/src/devices/adsl/exports.ver +++ /dev/null @@ -1,6 +0,0 @@ -{ -global: - nm_device_factory_create; -local: - *; -}; diff --git a/src/devices/adsl/nm-atm-manager.c b/src/devices/adsl/nm-atm-manager.c index 40c782fd..b04e9fe7 100644 --- a/src/devices/adsl/nm-atm-manager.c +++ b/src/devices/adsl/nm-atm-manager.c @@ -24,27 +24,45 @@ #include #include -#include "nm-atm-manager.h" #include "nm-setting-adsl.h" #include "nm-device-adsl.h" -#include "nm-device-factory.h" -#include "nm-platform.h" +#include "devices/nm-device-factory.h" +#include "platform/nm-platform.h" + +/*****************************************************************************/ + +#define NM_TYPE_ATM_MANAGER (nm_atm_manager_get_type ()) +#define NM_ATM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ATM_MANAGER, NMAtmManager)) +#define NM_ATM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ATM_MANAGER, NMAtmManagerClass)) +#define NM_IS_ATM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ATM_MANAGER)) +#define NM_IS_ATM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_ATM_MANAGER)) +#define NM_ATM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ATM_MANAGER, NMAtmManagerClass)) typedef struct { GUdevClient *client; GSList *devices; } NMAtmManagerPrivate; -#define NM_ATM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ATM_MANAGER, NMAtmManagerPrivate)) +typedef struct { + NMDeviceFactory parent; + NMAtmManagerPrivate _priv; +} NMAtmManager; + +typedef struct { + NMDeviceFactoryClass parent; +} NMAtmManagerClass; static GType nm_atm_manager_get_type (void); -static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); +G_DEFINE_TYPE (NMAtmManager, nm_atm_manager, NM_TYPE_DEVICE_FACTORY); -G_DEFINE_TYPE_EXTENDED (NMAtmManager, nm_atm_manager, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) +#define NM_ATM_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMAtmManager, NM_IS_ATM_MANAGER) -/**************************************************************************/ +/*****************************************************************************/ + +NM_DEVICE_FACTORY_DECLARE_TYPES ( + NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_ADSL_SETTING_NAME) +); G_MODULE_EXPORT NMDeviceFactory * nm_device_factory_create (GError **error) @@ -52,7 +70,7 @@ nm_device_factory_create (GError **error) return (NMDeviceFactory *) g_object_new (NM_TYPE_ATM_MANAGER, NULL); } -/************************************************************************/ +/*****************************************************************************/ static gboolean dev_get_attrs (GUdevDevice *udev_device, @@ -119,7 +137,7 @@ adsl_add (NMAtmManager *self, GUdevDevice *udev_device) atm_index_path = g_strdup_printf ("/sys/class/atm/%s/atmindex", NM_ASSERT_VALID_PATH_COMPONENT (ifname)); atm_index = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, - atm_index_path, + NMP_SYSCTL_PATHID_ABSOLUTE (atm_index_path), 10, 0, G_MAXINT, -1); if (atm_index < 0) { @@ -219,11 +237,7 @@ handle_uevent (GUdevClient *client, adsl_remove (self, device); } -NM_DEVICE_FACTORY_DECLARE_TYPES ( - NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_ADSL_SETTING_NAME) -) - -/*********************************************************************/ +/*****************************************************************************/ static void nm_atm_manager_init (NMAtmManager *self) @@ -235,13 +249,6 @@ nm_atm_manager_init (NMAtmManager *self) g_signal_connect (priv->client, "uevent", G_CALLBACK (handle_uevent), self); } -static void -device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) -{ - factory_iface->get_supported_types = get_supported_types; - factory_iface->start = start; -} - static void dispose (GObject *object) { @@ -249,9 +256,10 @@ dispose (GObject *object) NMAtmManagerPrivate *priv = NM_ATM_MANAGER_GET_PRIVATE (self); GSList *iter; - if (priv->client) + if (priv->client) { g_signal_handlers_disconnect_by_func (priv->client, handle_uevent, self); - g_clear_object (&priv->client); + g_clear_object (&priv->client); + } for (iter = priv->devices; iter; iter = iter->next) g_object_weak_unref (G_OBJECT (iter->data), device_destroyed, self); @@ -264,9 +272,10 @@ static void nm_atm_manager_class_init (NMAtmManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMAtmManagerPrivate)); - - /* virtual methods */ object_class->dispose = dispose; + + factory_class->get_supported_types = get_supported_types; + factory_class->start = start; } diff --git a/src/devices/adsl/nm-atm-manager.h b/src/devices/adsl/nm-atm-manager.h deleted file mode 100644 index bcbc6c77..00000000 --- a/src/devices/adsl/nm-atm-manager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2014 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_ATM_MANAGER_H__ -#define __NETWORKMANAGER_ATM_MANAGER_H__ - -#define NM_TYPE_ATM_MANAGER (nm_atm_manager_get_type ()) -#define NM_ATM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ATM_MANAGER, NMAtmManager)) - -typedef struct { - GObject parent; -} NMAtmManager; - -typedef struct { - GObjectClass parent; -} NMAtmManagerClass; - -#endif /* __NETWORKMANAGER_ATM_MANAGER_H__ */ - diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index 77c6e119..53841a7f 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -20,44 +20,35 @@ #include "nm-default.h" +#include "nm-device-adsl.h" + #include #include #include - #include #include #include #include - #include #include -#include "nm-device-adsl.h" -#include "nm-device-private.h" -#include "nm-enum-types.h" -#include "nm-platform.h" - -#include "ppp-manager/nm-ppp-manager.h" +#include "devices/nm-device-private.h" +#include "platform/nm-platform.h" +#include "ppp/nm-ppp-manager-call.h" +#include "ppp/nm-ppp-status.h" #include "nm-setting-adsl.h" #include "nm-utils.h" -#include "nmdbus-device-adsl.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Adsl.h" -#include "nm-device-logging.h" +#include "devices/nm-device-logging.h" _LOG_DECLARE_SELF (NMDeviceAdsl); -G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE) - -#define NM_DEVICE_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ADSL, NMDeviceAdslPrivate)) +/*****************************************************************************/ -enum { - PROP_0, +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_ATM_INDEX, - - LAST_PROP -}; - -/**********************************************/ +); typedef struct { guint carrier_poll_id; @@ -74,7 +65,20 @@ typedef struct { guint nas_update_count; } NMDeviceAdslPrivate; -/**************************************************************/ +struct _NMDeviceAdsl { + NMDevice parent; + NMDeviceAdslPrivate _priv; +}; + +struct _NMDeviceAdslClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE) + +#define NM_DEVICE_ADSL_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceAdsl, NM_IS_DEVICE_ADSL) + +/*****************************************************************************/ static NMDeviceCapabilities get_generic_capabilities (NMDevice *dev) @@ -138,7 +142,7 @@ complete_connection (NMDevice *device, return TRUE; } -/**************************************************************/ +/*****************************************************************************/ static gboolean br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) @@ -230,12 +234,14 @@ error: static void link_changed_cb (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, NMPlatformLink *info, - NMPlatformSignalChangeType change_type, + int change_type_i, NMDeviceAdsl *self) { + const NMPlatformSignalChangeType change_type = change_type_i; + if (change_type == NM_PLATFORM_SIGNAL_REMOVED) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); NMDevice *device = NM_DEVICE (self); @@ -243,11 +249,11 @@ link_changed_cb (NMPlatform *platform, /* This only gets called for PPPoE connections and "nas" interfaces */ if (priv->nas_ifindex > 0 && ifindex == priv->nas_ifindex) { - /* NAS device went away for some reason; kill the connection */ - _LOGD (LOGD_ADSL, "br2684 interface disappeared"); - nm_device_state_changed (device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_BR2684_FAILED); + /* NAS device went away for some reason; kill the connection */ + _LOGD (LOGD_ADSL, "br2684 interface disappeared"); + nm_device_state_changed (device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_BR2684_FAILED); } } } @@ -471,12 +477,15 @@ act_stage3_ip4_config_start (NMDevice *device, _LOGD (LOGD_ADSL, "starting PPPoA"); } - priv->ppp_manager = nm_ppp_manager_new (ppp_iface); - if (nm_ppp_manager_start (priv->ppp_manager, req, nm_setting_adsl_get_username (s_adsl), 30, 0, &err)) { - g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED, + priv->ppp_manager = nm_ppp_manager_create (ppp_iface, &err); + if ( priv->ppp_manager + && nm_ppp_manager_start (priv->ppp_manager, req, + nm_setting_adsl_get_username (s_adsl), + 30, 0, &err)) { + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, G_CALLBACK (ppp_state_changed), self); - g_signal_connect (priv->ppp_manager, "ip4-config", + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, G_CALLBACK (ppp_ip4_config), self); ret = NM_ACT_STAGE_RETURN_POSTPONE; @@ -484,7 +493,7 @@ act_stage3_ip4_config_start (NMDevice *device, _LOGW (LOGD_ADSL, "PPP failed to start: %s", err->message); g_error_free (err); - nm_exported_object_clear_and_unexport (&priv->ppp_manager); + g_clear_object (&priv->ppp_manager); *reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; } @@ -500,7 +509,8 @@ adsl_cleanup (NMDeviceAdsl *self) if (priv->ppp_manager) { g_signal_handlers_disconnect_by_func (priv->ppp_manager, G_CALLBACK (ppp_state_changed), self); g_signal_handlers_disconnect_by_func (priv->ppp_manager, G_CALLBACK (ppp_ip4_config), self); - nm_exported_object_clear_and_unexport (&priv->ppp_manager); + nm_ppp_manager_stop_sync (priv->ppp_manager); + g_clear_object (&priv->ppp_manager); } g_signal_handlers_disconnect_by_func (NM_PLATFORM_GET, G_CALLBACK (link_changed_cb), self); @@ -526,7 +536,7 @@ deactivate (NMDevice *device) adsl_cleanup (NM_DEVICE_ADSL (device)); } -/**************************************************************/ +/*****************************************************************************/ static gboolean carrier_update_cb (gpointer user_data) @@ -537,7 +547,7 @@ carrier_update_cb (gpointer user_data) path = g_strdup_printf ("/sys/class/atm/%s/carrier", NM_ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self)))); - carrier = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, 1, -1); + carrier = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (path), 10, 0, 1, -1); g_free (path); if (carrier != -1) @@ -545,51 +555,7 @@ carrier_update_cb (gpointer user_data) return TRUE; } -/**************************************************************/ - -NMDevice * -nm_device_adsl_new (const char *udi, - const char *iface, - const char *driver, - int atm_index) -{ - g_return_val_if_fail (udi != NULL, NULL); - g_return_val_if_fail (atm_index >= 0, NULL); - - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ADSL, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, - NM_DEVICE_ADSL_ATM_INDEX, atm_index, - NM_DEVICE_TYPE_DESC, "ADSL", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ADSL, - NULL); -} - -static void -constructed (GObject *object) -{ - NMDeviceAdsl *self = NM_DEVICE_ADSL (object); - NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); - - G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructed (object); - - priv->carrier_poll_id = g_timeout_add_seconds (5, carrier_update_cb, self); - - _LOGD (LOGD_ADSL, "ATM device index %d", priv->atm_index); - - g_return_if_fail (priv->atm_index >= 0); -} - -static void -dispose (GObject *object) -{ - adsl_cleanup (NM_DEVICE_ADSL (object)); - - nm_clear_g_source (&NM_DEVICE_ADSL_GET_PRIVATE (object)->carrier_poll_id); - - G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object); -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, @@ -597,7 +563,7 @@ get_property (GObject *object, guint prop_id, { switch (prop_id) { case PROP_ATM_INDEX: - g_value_set_int (value, NM_DEVICE_ADSL_GET_PRIVATE (object)->atm_index); + g_value_set_int (value, NM_DEVICE_ADSL_GET_PRIVATE ((NMDeviceAdsl *) object)->atm_index); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -611,8 +577,8 @@ set_property (GObject *object, guint prop_id, { switch (prop_id) { case PROP_ATM_INDEX: - /* construct only */ - NM_DEVICE_ADSL_GET_PRIVATE (object)->atm_index = g_value_get_int (value); + /* construct-only */ + NM_DEVICE_ADSL_GET_PRIVATE ((NMDeviceAdsl *) object)->atm_index = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -620,19 +586,63 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + static void nm_device_adsl_init (NMDeviceAdsl *self) { } +static void +constructed (GObject *object) +{ + NMDeviceAdsl *self = NM_DEVICE_ADSL (object); + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); + + G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructed (object); + + priv->carrier_poll_id = g_timeout_add_seconds (5, carrier_update_cb, self); + + _LOGD (LOGD_ADSL, "ATM device index %d", priv->atm_index); + + g_return_if_fail (priv->atm_index >= 0); +} + +NMDevice * +nm_device_adsl_new (const char *udi, + const char *iface, + const char *driver, + int atm_index) +{ + g_return_val_if_fail (udi != NULL, NULL); + g_return_val_if_fail (atm_index >= 0, NULL); + + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ADSL, + NM_DEVICE_UDI, udi, + NM_DEVICE_IFACE, iface, + NM_DEVICE_DRIVER, driver, + NM_DEVICE_ADSL_ATM_INDEX, atm_index, + NM_DEVICE_TYPE_DESC, "ADSL", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ADSL, + NULL); +} + +static void +dispose (GObject *object) +{ + adsl_cleanup (NM_DEVICE_ADSL (object)); + + nm_clear_g_source (&NM_DEVICE_ADSL_GET_PRIVATE ((NMDeviceAdsl *) object)->carrier_poll_id); + + G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object); +} + static void nm_device_adsl_class_init (NMDeviceAdslClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceAdslPrivate)); - object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; @@ -647,13 +657,13 @@ nm_device_adsl_class_init (NMDeviceAdslClass *klass) parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; parent_class->deactivate = deactivate; - /* properties */ - g_object_class_install_property - (object_class, PROP_ATM_INDEX, - g_param_spec_int (NM_DEVICE_ADSL_ATM_INDEX, "", "", - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_ATM_INDEX] = + g_param_spec_int (NM_DEVICE_ADSL_ATM_INDEX, "", "", + -1, G_MAXINT, -1, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_ADSL_SKELETON, diff --git a/src/devices/adsl/nm-device-adsl.h b/src/devices/adsl/nm-device-adsl.h index cfde2b35..351c8e7a 100644 --- a/src/devices/adsl/nm-device-adsl.h +++ b/src/devices/adsl/nm-device-adsl.h @@ -22,8 +22,7 @@ #ifndef __NETWORKMANAGER_DEVICE_ADSL_H__ #define __NETWORKMANAGER_DEVICE_ADSL_H__ -// Parent class -#include "nm-device.h" +#include "devices/nm-device.h" #define NM_TYPE_DEVICE_ADSL (nm_device_adsl_get_type ()) #define NM_DEVICE_ADSL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_ADSL, NMDeviceAdsl)) @@ -34,13 +33,8 @@ #define NM_DEVICE_ADSL_ATM_INDEX "atm-index" -typedef struct { - NMDevice parent; -} NMDeviceAdsl; - -typedef struct { - NMDeviceClass parent; -} NMDeviceAdslClass; +typedef struct _NMDeviceAdsl NMDeviceAdsl; +typedef struct _NMDeviceAdslClass NMDeviceAdslClass; GType nm_device_adsl_get_type (void); diff --git a/src/devices/bluetooth/Makefile.am b/src/devices/bluetooth/Makefile.am deleted file mode 100644 index 8454702e..00000000 --- a/src/devices/bluetooth/Makefile.am +++ /dev/null @@ -1,82 +0,0 @@ -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/settings \ - -I${top_srcdir}/src/platform \ - -I${top_srcdir}/src/devices/wwan \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-bluetooth"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(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 - -BUILT_SOURCES = $(GLIB_GENERATED) - -pkglib_LTLIBRARIES = libnm-device-plugin-bluetooth.la - -SYMBOL_VIS_FILE=$(srcdir)/exports.ver - -libnm_device_plugin_bluetooth_la_SOURCES = \ - nm-bluez-manager.c \ - nm-bluez-manager.h \ - nm-bluez-common.h \ - nm-bluez-device.c \ - nm-bluez-device.h \ - nm-bluez4-adapter.c \ - nm-bluez4-adapter.h \ - nm-bluez4-manager.c \ - nm-bluez4-manager.h \ - nm-bluez5-manager.c \ - nm-bluez5-manager.h \ - nm-bt-error.h \ - nm-bt-error.c \ - \ - nm-device-bt.c \ - nm-device-bt.h \ - \ - $(BUILT_SOURCES) - -libnm_device_plugin_bluetooth_la_LDFLAGS = \ - -module -avoid-version \ - -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 \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) - -if WITH_BLUEZ5_DUN -AM_CPPFLAGS += $(BLUEZ5_CFLAGS) - -libnm_device_plugin_bluetooth_la_SOURCES += \ - nm-bluez5-dun.c \ - nm-bluez5-dun.h - -libnm_device_plugin_bluetooth_la_LIBADD += $(BLUEZ5_LIBS) -endif - -CLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = $(SYMBOL_VIS_FILE) - -if ENABLE_TESTS - -check-local: - $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-bluetooth.so $(SYMBOL_VIS_FILE) - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-bluetooth.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - diff --git a/src/devices/bluetooth/Makefile.in b/src/devices/bluetooth/Makefile.in deleted file mode 100644 index ce12d2d4..00000000 --- a/src/devices/bluetooth/Makefile.in +++ /dev/null @@ -1,887 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@WITH_BLUEZ5_DUN_TRUE@am__append_1 = $(BLUEZ5_CFLAGS) -@WITH_BLUEZ5_DUN_TRUE@am__append_2 = \ -@WITH_BLUEZ5_DUN_TRUE@ nm-bluez5-dun.c \ -@WITH_BLUEZ5_DUN_TRUE@ nm-bluez5-dun.h - -@WITH_BLUEZ5_DUN_TRUE@am__append_3 = $(BLUEZ5_LIBS) -subdir = src/devices/bluetooth -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(pkglib_LTLIBRARIES) -am__DEPENDENCIES_1 = -@WITH_BLUEZ5_DUN_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) -libnm_device_plugin_bluetooth_la_DEPENDENCIES = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(top_builddir)/src/devices/wwan/libnm-wwan.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_2) -am__libnm_device_plugin_bluetooth_la_SOURCES_DIST = \ - nm-bluez-manager.c nm-bluez-manager.h nm-bluez-common.h \ - nm-bluez-device.c nm-bluez-device.h nm-bluez4-adapter.c \ - nm-bluez4-adapter.h nm-bluez4-manager.c nm-bluez4-manager.h \ - nm-bluez5-manager.c nm-bluez5-manager.h nm-bt-error.h \ - nm-bt-error.c nm-device-bt.c nm-device-bt.h nm-bt-enum-types.h \ - nm-bt-enum-types.c nm-bluez5-dun.c nm-bluez5-dun.h -am__objects_1 = nm-bt-enum-types.lo -am__objects_2 = $(am__objects_1) -@WITH_BLUEZ5_DUN_TRUE@am__objects_3 = nm-bluez5-dun.lo -am_libnm_device_plugin_bluetooth_la_OBJECTS = nm-bluez-manager.lo \ - nm-bluez-device.lo nm-bluez4-adapter.lo nm-bluez4-manager.lo \ - nm-bluez5-manager.lo nm-bt-error.lo nm-device-bt.lo \ - $(am__objects_2) $(am__objects_3) -libnm_device_plugin_bluetooth_la_OBJECTS = \ - $(am_libnm_device_plugin_bluetooth_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_device_plugin_bluetooth_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_device_plugin_bluetooth_la_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libnm_device_plugin_bluetooth_la_SOURCES) -DIST_SOURCES = $(am__libnm_device_plugin_bluetooth_la_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = -I${top_srcdir}/src -I${top_builddir}/src \ - -I${top_srcdir}/src/devices -I${top_srcdir}/src/settings \ - -I${top_srcdir}/src/platform -I${top_srcdir}/src/devices/wwan \ - -I${top_builddir}/introspection -I${top_srcdir}/shared \ - -I$(top_builddir)/shared -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-bluetooth"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) $(am__append_1) -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 -BUILT_SOURCES = $(GLIB_GENERATED) -pkglib_LTLIBRARIES = libnm-device-plugin-bluetooth.la -SYMBOL_VIS_FILE = $(srcdir)/exports.ver -libnm_device_plugin_bluetooth_la_SOURCES = nm-bluez-manager.c \ - nm-bluez-manager.h nm-bluez-common.h nm-bluez-device.c \ - nm-bluez-device.h nm-bluez4-adapter.c nm-bluez4-adapter.h \ - nm-bluez4-manager.c nm-bluez4-manager.h nm-bluez5-manager.c \ - nm-bluez5-manager.h nm-bt-error.h nm-bt-error.c nm-device-bt.c \ - nm-device-bt.h $(BUILT_SOURCES) $(am__append_2) -libnm_device_plugin_bluetooth_la_LDFLAGS = \ - -module -avoid-version \ - -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 $(GLIB_LIBS) \ - $(GUDEV_LIBS) $(am__append_3) -CLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = $(SYMBOL_VIS_FILE) -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/bluetooth/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/bluetooth/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnm-device-plugin-bluetooth.la: $(libnm_device_plugin_bluetooth_la_OBJECTS) $(libnm_device_plugin_bluetooth_la_DEPENDENCIES) $(EXTRA_libnm_device_plugin_bluetooth_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_device_plugin_bluetooth_la_LINK) -rpath $(pkglibdir) $(libnm_device_plugin_bluetooth_la_OBJECTS) $(libnm_device_plugin_bluetooth_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bluez-device.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bluez-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bluez4-adapter.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bluez4-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bluez5-dun.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bluez5-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bt-enum-types.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-bt-error.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-bt.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-am - -clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: all check check-am install install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ - clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkglibLTLIBRARIES install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-bluetooth.so $(SYMBOL_VIS_FILE) -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-bluetooth.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/bluetooth/exports.ver b/src/devices/bluetooth/exports.ver deleted file mode 100644 index 24cd848c..00000000 --- a/src/devices/bluetooth/exports.ver +++ /dev/null @@ -1,6 +0,0 @@ -{ -global: - nm_device_factory_create; -local: - *; -}; diff --git a/src/devices/bluetooth/nm-bluez-common.h b/src/devices/bluetooth/nm-bluez-common.h index 67810b94..6e97c3f5 100644 --- a/src/devices/bluetooth/nm-bluez-common.h +++ b/src/devices/bluetooth/nm-bluez-common.h @@ -39,5 +39,6 @@ #define BLUEZ4_SERIAL_INTERFACE "org.bluez.Serial" #define BLUEZ4_NETWORK_INTERFACE "org.bluez.Network" -#endif /* NM_BLUEZ_COMMON_H */ +#define NM_BLUEZ_MANAGER_BDADDR_ADDED "bdaddr-added" +#endif /* NM_BLUEZ_COMMON_H */ diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index 3463da6b..92b2c918 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -21,24 +21,46 @@ #include "nm-default.h" +#include "nm-bluez-device.h" + #include #include "nm-core-internal.h" - #include "nm-bt-error.h" #include "nm-bluez-common.h" -#include "nm-bluez-device.h" -#include "nm-settings.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings.h" +#include "settings/nm-settings-connection.h" #include "NetworkManagerUtils.h" #if WITH_BLUEZ5_DUN #include "nm-bluez5-dun.h" #endif -G_DEFINE_TYPE (NMBluezDevice, nm_bluez_device, G_TYPE_OBJECT) +/*****************************************************************************/ + +#define VARIANT_IS_OF_TYPE_BOOLEAN(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_BOOLEAN) )) +#define VARIANT_IS_OF_TYPE_STRING(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_STRING) )) +#define VARIANT_IS_OF_TYPE_OBJECT_PATH(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_OBJECT_PATH) )) +#define VARIANT_IS_OF_TYPE_STRING_ARRAY(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_STRING_ARRAY) )) + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE (NMBluezDevice, + PROP_PATH, + PROP_ADDRESS, + PROP_NAME, + PROP_CAPABILITIES, + PROP_USABLE, + PROP_CONNECTED, +); + +enum { + INITIALIZED, + REMOVED, + LAST_SIGNAL +}; -#define NM_BLUEZ_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_BLUEZ_DEVICE, NMBluezDevicePrivate)) +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { char *path; @@ -75,39 +97,26 @@ typedef struct { gboolean pan_connection_no_autocreate; } NMBluezDevicePrivate; - -enum { - PROP_0, - PROP_PATH, - PROP_ADDRESS, - PROP_NAME, - PROP_CAPABILITIES, - PROP_USABLE, - PROP_CONNECTED, - - LAST_PROP +struct _NMBluezDevice { + GObject parent; + NMBluezDevicePrivate _priv; }; -/* Signals */ -enum { - INITIALIZED, - REMOVED, - LAST_SIGNAL +struct _NMBluezDeviceClass { + GObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_TYPE (NMBluezDevice, nm_bluez_device, G_TYPE_OBJECT) + +#define NM_BLUEZ_DEVICE_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMBluezDevice, NM_IS_BLUEZ_DEVICE) + +/*****************************************************************************/ static void cp_connection_added (NMSettings *settings, NMConnection *connection, NMBluezDevice *self); static gboolean connection_compatible (NMBluezDevice *self, NMConnection *connection); - -#define VARIANT_IS_OF_TYPE_BOOLEAN(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_BOOLEAN) )) -#define VARIANT_IS_OF_TYPE_STRING(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_STRING) )) -#define VARIANT_IS_OF_TYPE_OBJECT_PATH(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_OBJECT_PATH) )) -#define VARIANT_IS_OF_TYPE_STRING_ARRAY(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_STRING_ARRAY) )) - -/***********************************************************/ +/*****************************************************************************/ const char * nm_bluez_device_get_path (NMBluezDevice *self) @@ -292,7 +301,7 @@ check_emit_usable (NMBluezDevice *self) END: if (new_usable != priv->usable) { priv->usable = new_usable; - g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_USABLE); + _notify (self, PROP_USABLE); } return G_SOURCE_REMOVE; @@ -307,7 +316,7 @@ check_emit_usable_schedule (NMBluezDevice *self) priv->check_emit_usable_id = g_idle_add ((GSourceFunc) check_emit_usable, self); } -/********************************************************************/ +/*****************************************************************************/ static gboolean connection_compatible (NMBluezDevice *self, NMConnection *connection) @@ -417,14 +426,14 @@ load_connections (NMBluezDevice *self) check_emit_usable (self); } -/***********************************************************/ +/*****************************************************************************/ static void bluez_disconnect_cb (GDBusConnection *dbus_connection, GAsyncResult *res, gpointer user_data) { - NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (user_data); + NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE ((NMBluezDevice *) user_data); GError *error = NULL; GVariant *variant; @@ -628,13 +637,13 @@ nm_bluez_device_connect_finish (NMBluezDevice *self, device = (const char *) g_simple_async_result_get_op_res_gpointer (simple); if (device && priv->bluez_version == 5) { priv->connected = TRUE; - g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_CONNECTED); + _notify (self, PROP_CONNECTED); } return device; } -/***********************************************************/ +/*****************************************************************************/ static void set_adapter_address (NMBluezDevice *self, const char *address) @@ -695,7 +704,7 @@ _set_property_capabilities (NMBluezDevice *self, const char **uuids) ((uint_val & NM_BT_CAPABILITY_DUN) && (uint_val &NM_BT_CAPABILITY_NAP)) ? " | " : "", uint_val & NM_BT_CAPABILITY_DUN ? "DUN" : ""); priv->capabilities = uint_val; - g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_CAPABILITIES); + _notify (self, PROP_CAPABILITIES); } } @@ -727,7 +736,7 @@ _set_property_address (NMBluezDevice *self, const char *addr) } priv->address = g_strdup (addr); - g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_ADDRESS); + _notify (self, PROP_ADDRESS); } static void @@ -749,7 +758,7 @@ _take_variant_property_name (NMBluezDevice *self, GVariant *v) if (g_strcmp0 (priv->name, str)) { g_free (priv->name); priv->name = g_strdup (str); - g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_NAME); + _notify (self, PROP_NAME); } } if (v) @@ -779,7 +788,7 @@ _take_variant_property_connected (NMBluezDevice *self, GVariant *v) if (priv->connected != connected) { priv->connected = connected; - g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_CONNECTED); + _notify (self, PROP_CONNECTED); } } if (v) @@ -1027,7 +1036,62 @@ on_bus_acquired (GObject *object, GAsyncResult *res, NMBluezDevice *self) g_object_unref (self); } -/********************************************************************/ +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE ((NMBluezDevice *) object); + + switch (prop_id) { + case PROP_PATH: + g_value_set_string (value, priv->path); + break; + case PROP_ADDRESS: + g_value_set_string (value, priv->address); + break; + case PROP_NAME: + g_value_set_string (value, priv->name); + break; + case PROP_CAPABILITIES: + g_value_set_uint (value, priv->capabilities); + break; + case PROP_USABLE: + g_value_set_boolean (value, priv->usable); + break; + case PROP_CONNECTED: + g_value_set_boolean (value, priv->connected); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE ((NMBluezDevice *) object); + + switch (prop_id) { + case PROP_PATH: + /* construct-only */ + priv->path = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_bluez_device_init (NMBluezDevice *self) +{ +} NMBluezDevice * nm_bluez_device_new (const char *path, @@ -1089,11 +1153,6 @@ nm_bluez_device_new (const char *path, return self; } -static void -nm_bluez_device_init (NMBluezDevice *self) -{ -} - static void dispose (GObject *object) { @@ -1146,7 +1205,7 @@ dispose (GObject *object) static void finalize (GObject *object) { - NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (object); + NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE ((NMBluezDevice *) object); nm_log_dbg (LOGD_BT, "bluez[%s]: finalize NMBluezDevice", priv->path); @@ -1163,122 +1222,65 @@ finalize (GObject *object) G_OBJECT_CLASS (nm_bluez_device_parent_class)->finalize (object); } -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PATH: - g_value_set_string (value, priv->path); - break; - case PROP_ADDRESS: - g_value_set_string (value, priv->address); - break; - case PROP_NAME: - g_value_set_string (value, priv->name); - break; - case PROP_CAPABILITIES: - g_value_set_uint (value, priv->capabilities); - break; - case PROP_USABLE: - g_value_set_boolean (value, priv->usable); - break; - case PROP_CONNECTED: - g_value_set_boolean (value, priv->connected); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PATH: - /* construct only */ - priv->path = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void nm_bluez_device_class_init (NMBluezDeviceClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); - g_type_class_add_private (config_class, sizeof (NMBluezDevicePrivate)); - - /* virtual methods */ object_class->get_property = get_property; object_class->set_property = set_property; object_class->dispose = dispose; object_class->finalize = finalize; - /* Properties */ - g_object_class_install_property - (object_class, PROP_PATH, - g_param_spec_string (NM_BLUEZ_DEVICE_PATH, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_ADDRESS, - g_param_spec_string (NM_BLUEZ_DEVICE_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_NAME, - g_param_spec_string (NM_BLUEZ_DEVICE_NAME, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_CAPABILITIES, - g_param_spec_uint (NM_BLUEZ_DEVICE_CAPABILITIES, "", "", - 0, G_MAXUINT, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_USABLE, - g_param_spec_boolean (NM_BLUEZ_DEVICE_USABLE, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_CONNECTED, - g_param_spec_boolean (NM_BLUEZ_DEVICE_CONNECTED, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - /* Signals */ + obj_properties[PROP_PATH] = + g_param_spec_string (NM_BLUEZ_DEVICE_PATH, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_ADDRESS] = + g_param_spec_string (NM_BLUEZ_DEVICE_ADDRESS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_NAME] = + g_param_spec_string (NM_BLUEZ_DEVICE_NAME, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_CAPABILITIES] = + g_param_spec_uint (NM_BLUEZ_DEVICE_CAPABILITIES, "", "", + 0, G_MAXUINT, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_USABLE] = + g_param_spec_boolean (NM_BLUEZ_DEVICE_USABLE, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_CONNECTED] = + g_param_spec_boolean (NM_BLUEZ_DEVICE_CONNECTED, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + signals[INITIALIZED] = g_signal_new ("initialized", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMBluezDeviceClass, initialized), + 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); signals[REMOVED] = g_signal_new (NM_BLUEZ_DEVICE_REMOVED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMBluezDeviceClass, removed), + 0, NULL, NULL, NULL, G_TYPE_NONE, 0); } diff --git a/src/devices/bluetooth/nm-bluez-device.h b/src/devices/bluetooth/nm-bluez-device.h index 66a349e0..e56d5d24 100644 --- a/src/devices/bluetooth/nm-bluez-device.h +++ b/src/devices/bluetooth/nm-bluez-device.h @@ -41,18 +41,8 @@ /* Signals */ #define NM_BLUEZ_DEVICE_REMOVED "removed" -typedef struct { - GObject parent; -} NMBluezDevice; - -typedef struct { - GObjectClass parent; - - /* virtual functions */ - void (*initialized) (NMBluezDevice *self, gboolean success); - - void (*removed) (NMBluezDevice *self); -} NMBluezDeviceClass; +typedef struct _NMBluezDevice NMBluezDevice; +typedef struct _NMBluezDeviceClass NMBluezDeviceClass; GType nm_bluez_device_get_type (void); diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index 0d2e302c..58fa9b01 100644 --- a/src/devices/bluetooth/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -20,34 +20,31 @@ #include "nm-default.h" -#include "nm-bluez-manager.h" - #include #include #include #include -#include "nm-device-factory.h" +#include "devices/nm-device-factory.h" #include "nm-setting-bluetooth.h" -#include "nm-settings.h" +#include "settings/nm-settings.h" #include "nm-bluez4-manager.h" #include "nm-bluez5-manager.h" #include "nm-bluez-device.h" #include "nm-bluez-common.h" #include "nm-device-bt.h" #include "nm-core-internal.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-dbus-compat.h" -#define _NMLOG_DOMAIN LOGD_BT -#define _NMLOG_PREFIX_NAME "bluez" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END +/*****************************************************************************/ + +#define NM_TYPE_BLUEZ_MANAGER (nm_bluez_manager_get_type ()) +#define NM_BLUEZ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BLUEZ_MANAGER, NMBluezManager)) +#define NM_BLUEZ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_BLUEZ_MANAGER, NMBluezManagerClass)) +#define NM_IS_BLUEZ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_BLUEZ_MANAGER)) +#define NM_IS_BLUEZ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_BLUEZ_MANAGER)) +#define NM_BLUEZ_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_BLUEZ_MANAGER, NMBluezManagerClass)) typedef struct { int bluez_version; @@ -62,18 +59,27 @@ typedef struct { GCancellable *async_cancellable; } NMBluezManagerPrivate; -#define NM_BLUEZ_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_BLUEZ_MANAGER, NMBluezManagerPrivate)) +typedef struct { + NMDeviceFactory parent; + NMBluezManagerPrivate _priv; +} NMBluezManager; + +typedef struct { + NMDeviceFactoryClass parent; +} NMBluezManagerClass; static GType nm_bluez_manager_get_type (void); -static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); +G_DEFINE_TYPE (NMBluezManager, nm_bluez_manager, NM_TYPE_DEVICE_FACTORY); -G_DEFINE_TYPE_EXTENDED (NMBluezManager, nm_bluez_manager, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) +#define NM_BLUEZ_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMBluezManager, NM_IS_BLUEZ_MANAGER) -static void check_bluez_and_try_setup (NMBluezManager *self); +/*****************************************************************************/ -/**************************************************************************/ +NM_DEVICE_FACTORY_DECLARE_TYPES ( + NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BNEP) + NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BLUETOOTH_SETTING_NAME) +) G_MODULE_EXPORT NMDeviceFactory * nm_device_factory_create (GError **error) @@ -81,7 +87,16 @@ nm_device_factory_create (GError **error) return (NMDeviceFactory *) g_object_new (NM_TYPE_BLUEZ_MANAGER, NULL); } -/************************************************************************/ +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_BT +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "bluez", __VA_ARGS__) + +/*****************************************************************************/ + +static void check_bluez_and_try_setup (NMBluezManager *self); + +/*****************************************************************************/ struct AsyncData { NMBluezManager *self; @@ -382,12 +397,27 @@ start (NMDeviceFactory *factory) check_bluez_and_try_setup (NM_BLUEZ_MANAGER (factory)); } -NM_DEVICE_FACTORY_DECLARE_TYPES ( - NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BNEP) - NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BLUETOOTH_SETTING_NAME) -) +static NMDevice * +create_device (NMDeviceFactory *factory, + const char *iface, + const NMPlatformLink *plink, + NMConnection *connection, + gboolean *out_ignore) +{ + g_warn_if_fail (plink->type == NM_LINK_TYPE_BNEP); + *out_ignore = TRUE; + return NULL; +} -/*********************************************************************/ +/*****************************************************************************/ + +static void +nm_bluez_manager_init (NMBluezManager *self) +{ + NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); + + priv->settings = g_object_ref (NM_SETTINGS_GET); +} static void dispose (GObject *object) @@ -413,42 +443,15 @@ dispose (GObject *object) g_clear_object (&priv->settings); } -static void -nm_bluez_manager_init (NMBluezManager *self) -{ - NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); - - priv->settings = g_object_ref (NM_SETTINGS_GET); -} - -static NMDevice * -create_device (NMDeviceFactory *factory, - const char *iface, - const NMPlatformLink *plink, - NMConnection *connection, - gboolean *out_ignore) -{ - g_warn_if_fail (plink->type == NM_LINK_TYPE_BNEP); - *out_ignore = TRUE; - return NULL; -} - -static void -device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) -{ - factory_iface->get_supported_types = get_supported_types; - factory_iface->create_device = create_device; - factory_iface->start = start; -} - static void nm_bluez_manager_class_init (NMBluezManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMBluezManagerPrivate)); - - /* virtual methods */ object_class->dispose = dispose; -} + factory_class->get_supported_types = get_supported_types; + factory_class->create_device = create_device; + factory_class->start = start; +} diff --git a/src/devices/bluetooth/nm-bluez-manager.h b/src/devices/bluetooth/nm-bluez-manager.h deleted file mode 100644 index d23b33a7..00000000 --- a/src/devices/bluetooth/nm-bluez-manager.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2014 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_BLUEZ_MANAGER_H__ -#define __NETWORKMANAGER_BLUEZ_MANAGER_H__ - -#define NM_TYPE_BLUEZ_MANAGER (nm_bluez_manager_get_type ()) -#define NM_BLUEZ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BLUEZ_MANAGER, NMBluezManager)) - -#define NM_BLUEZ_MANAGER_BDADDR_ADDED "bdaddr-added" - -typedef struct { - GObject parent; -} NMBluezManager; - -typedef struct { - GObjectClass parent; -} NMBluezManagerClass; - -#endif /* __NETWORKMANAGER_BLUEZ_MANAGER_H__ */ - diff --git a/src/devices/bluetooth/nm-bluez4-adapter.c b/src/devices/bluetooth/nm-bluez4-adapter.c index 2ef071a8..c0c1be30 100644 --- a/src/devices/bluetooth/nm-bluez4-adapter.c +++ b/src/devices/bluetooth/nm-bluez4-adapter.c @@ -28,11 +28,23 @@ #include "nm-bluez-device.h" #include "nm-bluez-common.h" #include "nm-core-internal.h" -#include "nm-settings.h" +#include "settings/nm-settings.h" -G_DEFINE_TYPE (NMBluez4Adapter, nm_bluez4_adapter, G_TYPE_OBJECT) +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PATH, + PROP_ADDRESS, +); + +enum { + INITIALIZED, + DEVICE_ADDED, + DEVICE_REMOVED, + LAST_SIGNAL, +}; -#define NM_BLUEZ4_ADAPTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_BLUEZ4_ADAPTER, NMBluez4AdapterPrivate)) +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { char *path; @@ -46,26 +58,25 @@ typedef struct { NMSettings *settings; } NMBluez4AdapterPrivate; - -enum { - PROP_0, - PROP_PATH, - PROP_ADDRESS, - - LAST_PROP +struct _NMBluez4Adapter { + GObject parent; + NMBluez4AdapterPrivate _priv; }; -/* Signals */ -enum { - INITIALIZED, - DEVICE_ADDED, - DEVICE_REMOVED, - LAST_SIGNAL +struct _NMBluez4AdapterClass { + GObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; + +G_DEFINE_TYPE (NMBluez4Adapter, nm_bluez4_adapter, G_TYPE_OBJECT) + +#define NM_BLUEZ4_ADAPTER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMBluez4Adapter, NM_IS_BLUEZ4_ADAPTER) + +/*****************************************************************************/ static void device_do_remove (NMBluez4Adapter *self, NMBluezDevice *device); +/*****************************************************************************/ + const char * nm_bluez4_adapter_get_path (NMBluez4Adapter *self) { @@ -233,7 +244,62 @@ query_properties (NMBluez4Adapter *self) get_properties_cb, self); } -/***********************************************************/ +/*****************************************************************************/ + +static gboolean +_find_all (gpointer key, gpointer value, gpointer user_data) +{ + return TRUE; +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE ((NMBluez4Adapter *) object); + + switch (prop_id) { + case PROP_PATH: + g_value_set_string (value, priv->path); + break; + case PROP_ADDRESS: + g_value_set_string (value, priv->address); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE ((NMBluez4Adapter *) object); + + switch (prop_id) { + case PROP_PATH: + /* construct-only */ + priv->path = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_bluez4_adapter_init (NMBluez4Adapter *self) +{ + NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (self); + + priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, NULL); +} NMBluez4Adapter * nm_bluez4_adapter_new (const char *path, NMSettings *settings) @@ -266,21 +332,6 @@ nm_bluez4_adapter_new (const char *path, NMSettings *settings) return self; } -static void -nm_bluez4_adapter_init (NMBluez4Adapter *self) -{ - NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (self); - - priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, NULL); -} - -static gboolean -_find_all (gpointer key, gpointer value, gpointer user_data) -{ - return TRUE; -} - static void dispose (GObject *object) { @@ -297,7 +348,7 @@ dispose (GObject *object) static void finalize (GObject *object) { - NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (object); + NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE ((NMBluez4Adapter *) object); g_hash_table_destroy (priv->devices); g_free (priv->address); @@ -309,75 +360,34 @@ finalize (GObject *object) g_object_unref (priv->settings); } -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PATH: - g_value_set_string (value, priv->path); - break; - case PROP_ADDRESS: - g_value_set_string (value, priv->address); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PATH: - /* construct only */ - priv->path = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void nm_bluez4_adapter_class_init (NMBluez4AdapterClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); - g_type_class_add_private (config_class, sizeof (NMBluez4AdapterPrivate)); - - /* virtual methods */ object_class->get_property = get_property; object_class->set_property = set_property; object_class->dispose = dispose; object_class->finalize = finalize; - /* Properties */ - g_object_class_install_property - (object_class, PROP_PATH, - g_param_spec_string (NM_BLUEZ4_ADAPTER_PATH, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_ADDRESS, - g_param_spec_string (NM_BLUEZ4_ADAPTER_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - /* Signals */ + obj_properties[PROP_PATH] = + g_param_spec_string (NM_BLUEZ4_ADAPTER_PATH, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_ADDRESS] = + g_param_spec_string (NM_BLUEZ4_ADAPTER_ADDRESS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + signals[INITIALIZED] = g_signal_new ("initialized", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMBluez4AdapterClass, initialized), + 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); @@ -385,7 +395,7 @@ nm_bluez4_adapter_class_init (NMBluez4AdapterClass *config_class) signals[DEVICE_ADDED] = g_signal_new ("device-added", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMBluez4AdapterClass, device_added), + 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); @@ -393,7 +403,7 @@ nm_bluez4_adapter_class_init (NMBluez4AdapterClass *config_class) signals[DEVICE_REMOVED] = g_signal_new ("device-removed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMBluez4AdapterClass, device_removed), + 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); diff --git a/src/devices/bluetooth/nm-bluez4-adapter.h b/src/devices/bluetooth/nm-bluez4-adapter.h index ee61112f..e240ec2c 100644 --- a/src/devices/bluetooth/nm-bluez4-adapter.h +++ b/src/devices/bluetooth/nm-bluez4-adapter.h @@ -33,20 +33,8 @@ #define NM_BLUEZ4_ADAPTER_PATH "path" #define NM_BLUEZ4_ADAPTER_ADDRESS "address" -typedef struct { - GObject parent; -} NMBluez4Adapter; - -typedef struct { - GObjectClass parent; - - /* virtual functions */ - void (*initialized) (NMBluez4Adapter *self, gboolean success); - - void (*device_added) (NMBluez4Adapter *self, NMBluezDevice *device); - - void (*device_removed) (NMBluez4Adapter *self, NMBluezDevice *device); -} NMBluez4AdapterClass; +typedef struct _NMBluez4Adapter NMBluez4Adapter; +typedef struct _NMBluez4AdapterClass NMBluez4AdapterClass; GType nm_bluez4_adapter_get_type (void); @@ -62,4 +50,3 @@ gboolean nm_bluez4_adapter_get_initialized (NMBluez4Adapter *self); GSList *nm_bluez4_adapter_get_devices (NMBluez4Adapter *self); #endif /* __NETWORKMANAGER_BLUEZ4_ADAPTER_H__ */ - diff --git a/src/devices/bluetooth/nm-bluez4-manager.c b/src/devices/bluetooth/nm-bluez4-manager.c index 36bc30e5..a9079a2f 100644 --- a/src/devices/bluetooth/nm-bluez4-manager.c +++ b/src/devices/bluetooth/nm-bluez4-manager.c @@ -28,10 +28,18 @@ #include #include "nm-bluez4-adapter.h" -#include "nm-bluez-manager.h" #include "nm-bluez-common.h" #include "nm-core-internal.h" -#include "nm-settings.h" +#include "settings/nm-settings.h" + +/*****************************************************************************/ + +enum { + BDADDR_ADDED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { gulong name_owner_changed_id; @@ -43,19 +51,22 @@ typedef struct { NMBluez4Adapter *adapter; } NMBluez4ManagerPrivate; -#define NM_BLUEZ4_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_BLUEZ4_MANAGER, NMBluez4ManagerPrivate)) +struct _NMBluez4Manager { + GObject parent; + NMBluez4ManagerPrivate _priv; +}; + +struct _NMBluez4ManagerClass { + GObjectClass parent; +}; G_DEFINE_TYPE (NMBluez4Manager, nm_bluez4_manager, G_TYPE_OBJECT) -enum { - BDADDR_ADDED, - LAST_SIGNAL -}; +#define NM_BLUEZ4_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMBluez4Manager, NM_IS_BLUEZ4_MANAGER) -static guint signals[LAST_SIGNAL] = { 0 }; +/*****************************************************************************/ static void - emit_bdaddr_added (NMBluez4Manager *self, NMBluezDevice *device) { g_signal_emit (self, signals[BDADDR_ADDED], 0, @@ -222,19 +233,7 @@ name_owner_changed_cb (GObject *object, } } -/****************************************************************/ - -NMBluez4Manager * -nm_bluez4_manager_new (NMSettings *settings) -{ - NMBluez4Manager *instance; - - g_return_val_if_fail (NM_IS_SETTINGS (settings), NULL); - - instance = g_object_new (NM_TYPE_BLUEZ4_MANAGER, NULL); - NM_BLUEZ4_MANAGER_GET_PRIVATE (instance)->settings = g_object_ref (settings); - return instance; -} +/*****************************************************************************/ static void nm_bluez4_manager_init (NMBluez4Manager *self) @@ -258,6 +257,18 @@ nm_bluez4_manager_init (NMBluez4Manager *self) query_default_adapter (self); } +NMBluez4Manager * +nm_bluez4_manager_new (NMSettings *settings) +{ + NMBluez4Manager *instance; + + g_return_val_if_fail (NM_IS_SETTINGS (settings), NULL); + + instance = g_object_new (NM_TYPE_BLUEZ4_MANAGER, NULL); + NM_BLUEZ4_MANAGER_GET_PRIVATE (instance)->settings = g_object_ref (settings); + return instance; +} + static void dispose (GObject *object) { @@ -277,19 +288,14 @@ nm_bluez4_manager_class_init (NMBluez4ManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMBluez4ManagerPrivate)); - - /* virtual methods */ object_class->dispose = dispose; - /* Signals */ signals[BDADDR_ADDED] = - g_signal_new (NM_BLUEZ_MANAGER_BDADDR_ADDED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMBluez4ManagerClass, bdaddr_added), - NULL, NULL, NULL, - G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); + g_signal_new (NM_BLUEZ_MANAGER_BDADDR_ADDED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); } diff --git a/src/devices/bluetooth/nm-bluez4-manager.h b/src/devices/bluetooth/nm-bluez4-manager.h index 8afe6924..f46379ff 100644 --- a/src/devices/bluetooth/nm-bluez4-manager.h +++ b/src/devices/bluetooth/nm-bluez4-manager.h @@ -28,20 +28,8 @@ #define NM_IS_BLUEZ4_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_BLUEZ4_MANAGER)) #define NM_BLUEZ4_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_BLUEZ4_MANAGER, NMBluez4ManagerClass)) -typedef struct { - GObject parent; -} NMBluez4Manager; - -typedef struct { - GObjectClass parent; - - /* Signals */ - void (*bdaddr_added) (NMBluez4Manager *manager, - const char *bdaddr, - const char *name, - const char *object_path, - guint uuids); -} NMBluez4ManagerClass; +typedef struct _NMBluez4Manager NMBluez4Manager; +typedef struct _NMBluez4ManagerClass NMBluez4ManagerClass; GType nm_bluez4_manager_get_type (void); @@ -50,4 +38,3 @@ NMBluez4Manager *nm_bluez4_manager_new (NMSettings *settings); void nm_bluez4_manager_query_devices (NMBluez4Manager *manager); #endif /* __NETWORKMANAGER_BLUEZ4_MANAGER_H__ */ - diff --git a/src/devices/bluetooth/nm-bluez5-manager.c b/src/devices/bluetooth/nm-bluez5-manager.c index a014d0c1..88759301 100644 --- a/src/devices/bluetooth/nm-bluez5-manager.c +++ b/src/devices/bluetooth/nm-bluez5-manager.c @@ -30,10 +30,18 @@ #include "nm-core-internal.h" -#include "nm-bluez-manager.h" #include "nm-bluez-device.h" #include "nm-bluez-common.h" -#include "nm-settings.h" +#include "settings/nm-settings.h" + +/*****************************************************************************/ + +enum { + BDADDR_ADDED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { NMSettings *settings; @@ -43,20 +51,26 @@ typedef struct { GHashTable *devices; } NMBluez5ManagerPrivate; -#define NM_BLUEZ5_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_BLUEZ5_MANAGER, NMBluez5ManagerPrivate)) +struct _NMBluez5Manager { + GObject parent; + NMBluez5ManagerPrivate _priv; +}; + +struct _NMBluez5ManagerClass { + GObjectClass parent; +}; G_DEFINE_TYPE (NMBluez5Manager, nm_bluez5_manager, G_TYPE_OBJECT) -enum { - BDADDR_ADDED, - LAST_SIGNAL -}; +#define NM_BLUEZ5_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMBluez5Manager, NM_IS_BLUEZ5_MANAGER) -static guint signals[LAST_SIGNAL] = { 0 }; +/*****************************************************************************/ static void device_initialized (NMBluezDevice *device, gboolean success, NMBluez5Manager *self); static void device_usable (NMBluezDevice *device, GParamSpec *pspec, NMBluez5Manager *self); +/*****************************************************************************/ + static void emit_bdaddr_added (NMBluez5Manager *self, NMBluezDevice *device) { @@ -308,7 +322,18 @@ bluez_cleanup (NMBluez5Manager *self, gboolean do_signal) g_hash_table_remove_all (priv->devices); } -/****************************************************************/ +/*****************************************************************************/ + +static void +nm_bluez5_manager_init (NMBluez5Manager *self) +{ + NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (self); + + bluez_connect (self); + + priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, g_object_unref); +} NMBluez5Manager * nm_bluez5_manager_new (NMSettings *settings) @@ -322,17 +347,6 @@ nm_bluez5_manager_new (NMSettings *settings) return instance; } -static void -nm_bluez5_manager_init (NMBluez5Manager *self) -{ - NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (self); - - bluez_connect (self); - - priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, g_object_unref); -} - static void dispose (GObject *object) { @@ -346,7 +360,7 @@ dispose (GObject *object) static void finalize (GObject *object) { - NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (object); + NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE ((NMBluez5Manager *) object); g_hash_table_destroy (priv->devices); @@ -360,19 +374,14 @@ nm_bluez5_manager_class_init (NMBluez5ManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMBluez5ManagerPrivate)); - - /* virtual methods */ object_class->dispose = dispose; object_class->finalize = finalize; - /* Signals */ signals[BDADDR_ADDED] = - g_signal_new (NM_BLUEZ_MANAGER_BDADDR_ADDED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMBluez5ManagerClass, bdaddr_added), - NULL, NULL, NULL, - G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); + g_signal_new (NM_BLUEZ_MANAGER_BDADDR_ADDED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); } diff --git a/src/devices/bluetooth/nm-bluez5-manager.h b/src/devices/bluetooth/nm-bluez5-manager.h index 0e309d33..43694435 100644 --- a/src/devices/bluetooth/nm-bluez5-manager.h +++ b/src/devices/bluetooth/nm-bluez5-manager.h @@ -29,20 +29,8 @@ #define NM_IS_BLUEZ5_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_BLUEZ5_MANAGER)) #define NM_BLUEZ5_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_BLUEZ5_MANAGER, NMBluez5ManagerClass)) -typedef struct { - GObject parent; -} NMBluez5Manager; - -typedef struct { - GObjectClass parent; - - /* Signals */ - void (*bdaddr_added) (NMBluez5Manager *manager, - const char *bdaddr, - const char *name, - const char *object_path, - guint uuids); -} NMBluez5ManagerClass; +typedef struct _NMBluez5Manager NMBluez5Manager; +typedef struct _NMBluez5ManagerClass NMBluez5ManagerClass; GType nm_bluez5_manager_get_type (void); @@ -51,4 +39,3 @@ NMBluez5Manager *nm_bluez5_manager_new (NMSettings *settings); void nm_bluez5_manager_query_devices (NMBluez5Manager *manager); #endif /* __NETWORKMANAGER_BLUEZ5_MANAGER_H__ */ - diff --git a/src/devices/bluetooth/nm-bt-enum-types.c b/src/devices/bluetooth/nm-bt-enum-types.c deleted file mode 100644 index 207055e1..00000000 --- a/src/devices/bluetooth/nm-bt-enum-types.c +++ /dev/null @@ -1,35 +0,0 @@ - - - -/* Generated by glib-mkenums. Do not edit */ - -#include "config.h" - -#include "nm-bt-enum-types.h" - -#include "nm-bt-error.h" - -GType -nm_bt_error_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_BT_ERROR_CONNECTION_NOT_BT, "NM_BT_ERROR_CONNECTION_NOT_BT", "ConnectionNotBt" }, - { NM_BT_ERROR_CONNECTION_INVALID, "NM_BT_ERROR_CONNECTION_INVALID", "ConnectionInvalid" }, - { NM_BT_ERROR_CONNECTION_INCOMPATIBLE, "NM_BT_ERROR_CONNECTION_INCOMPATIBLE", "ConnectionIncompatible" }, - { NM_BT_ERROR_DUN_CONNECT_FAILED, "NM_BT_ERROR_DUN_CONNECT_FAILED", "DunConnectFailed" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMBtError"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} - - - diff --git a/src/devices/bluetooth/nm-bt-enum-types.h b/src/devices/bluetooth/nm-bt-enum-types.h deleted file mode 100644 index af887929..00000000 --- a/src/devices/bluetooth/nm-bt-enum-types.h +++ /dev/null @@ -1,19 +0,0 @@ - - - -/* Generated by glib-mkenums. Do not edit */ - -#ifndef __NM_BT_ENUM_TYPES_H__ -#define __NM_BT_ENUM_TYPES_H__ - -#include - -G_BEGIN_DECLS -GType nm_bt_error_get_type (void) G_GNUC_CONST; -#define NM_TYPE_BT_ERROR (nm_bt_error_get_type ()) -G_END_DECLS - -#endif /* __NM_BT_ENUM_TYPES_H__ */ - - - diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 67ae15bc..31b9bbf9 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -27,8 +27,8 @@ #include "nm-bluez-common.h" #include "nm-bluez-device.h" -#include "nm-device-private.h" -#include "ppp-manager/nm-ppp-manager.h" +#include "devices/nm-device-private.h" +#include "ppp/nm-ppp-manager.h" #include "nm-setting-connection.h" #include "nm-setting-bluetooth.h" #include "nm-setting-cdma.h" @@ -36,26 +36,33 @@ #include "nm-setting-serial.h" #include "nm-setting-ppp.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 "nm-platform.h" +#include "platform/nm-platform.h" -#include "nmdbus-device-bt.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Bluetooth.h" + +#include "devices/nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceBt); #define MM_DBUS_SERVICE "org.freedesktop.ModemManager1" #define MM_DBUS_PATH "/org/freedesktop/ModemManager1" #define MM_DBUS_INTERFACE "org.freedesktop.ModemManager1" -#include "nm-device-logging.h" -_LOG_DECLARE_SELF(NMDeviceBt); +/*****************************************************************************/ -G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_BT_NAME, + PROP_BT_CAPABILITIES, + PROP_BT_DEVICE, +); -#define NM_DEVICE_BT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BT, NMDeviceBtPrivate)) +enum { + PPP_STATS, + LAST_SIGNAL, +}; -static gboolean modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *reason); +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { GDBusProxy *mm_proxy; @@ -77,22 +84,24 @@ typedef struct { guint32 bt_type; /* BT type of the current connection */ } NMDeviceBtPrivate; -enum { - PROP_0, - PROP_BT_NAME, - PROP_BT_CAPABILITIES, - PROP_BT_DEVICE, +struct _NMDeviceBt { + NMDevice parent; + NMDeviceBtPrivate _priv; +}; - LAST_PROP +struct _NMDeviceBtClass { + NMDeviceClass parent; }; -enum { - PPP_STATS, +G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE) - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; +#define NM_DEVICE_BT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceBt, NM_IS_DEVICE_BT) + +/*****************************************************************************/ +static gboolean modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *reason); + +/*****************************************************************************/ guint32 nm_device_bt_get_capabilities (NMDeviceBt *self) { @@ -133,10 +142,12 @@ can_auto_connect (NMDevice *device, NMConnection *connection, char **specific_object) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); guint32 bt_type; - if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, connection, specific_object)) + nm_assert (!specific_object || !*specific_object); + + if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, connection, NULL)) return FALSE; /* Can't auto-activate a DUN connection without ModemManager */ @@ -150,7 +161,7 @@ can_auto_connect (NMDevice *device, static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMSettingConnection *s_con; NMSettingBluetooth *s_bt; const char *bdaddr; @@ -188,7 +199,7 @@ check_connection_available (NMDevice *device, NMDeviceCheckConAvailableFlags flags, const char *specific_object) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); guint32 bt_type; bt_type = get_connection_bt_type (connection); @@ -209,7 +220,7 @@ complete_connection (NMDevice *device, const GSList *existing_connections, GError **error) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMSettingBluetooth *s_bt; const char *setting_bdaddr; const char *ctype; @@ -351,9 +362,9 @@ complete_connection (NMDevice *device, static void ppp_stats (NMModem *modem, - guint32 in_bytes, - guint32 out_bytes, - gpointer user_data) + guint32 in_bytes, + guint32 out_bytes, + gpointer user_data) { g_signal_emit (NM_DEVICE_BT (user_data), signals[PPP_STATS], 0, in_bytes, out_bytes); } @@ -418,7 +429,7 @@ static void modem_auth_result (NMModem *modem, GError *error, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; if (error) { @@ -486,7 +497,7 @@ device_state_changed (NMDevice *device, NMDeviceState old_state, NMDeviceStateReason reason) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); if (priv->modem) nm_modem_device_state_changed (priv->modem, new_state, old_state, reason); @@ -569,10 +580,12 @@ modem_cleanup (NMDeviceBt *self) static void modem_state_cb (NMModem *modem, - NMModemState new_state, - NMModemState old_state, + int new_state_i, + int old_state_i, gpointer user_data) { + NMModemState new_state = new_state_i; + NMModemState old_state = old_state_i; NMDevice *device = NM_DEVICE (user_data); NMDeviceState dev_state = nm_device_get_state (device); @@ -826,7 +839,7 @@ static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceBt *self = NM_DEVICE_BT (device); - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self); NMConnection *connection; connection = nm_device_get_applied_connection (device); @@ -861,11 +874,11 @@ act_stage3_ip4_config_start (NMDevice *device, NMIP4Config **out_config, NMDeviceStateReason *reason) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMActStageReturn ret; if (priv->bt_type == NM_BT_CAPABILITY_DUN) { - ret = nm_modem_stage3_ip4_config_start (NM_DEVICE_BT_GET_PRIVATE (device)->modem, + ret = nm_modem_stage3_ip4_config_start (priv->modem, device, NM_DEVICE_CLASS (nm_device_bt_parent_class), reason); @@ -880,11 +893,11 @@ act_stage3_ip6_config_start (NMDevice *device, NMIP6Config **out_config, NMDeviceStateReason *reason) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); NMActStageReturn ret; if (priv->bt_type == NM_BT_CAPABILITY_DUN) { - ret = nm_modem_stage3_ip6_config_start (NM_DEVICE_BT_GET_PRIVATE (device)->modem, + ret = nm_modem_stage3_ip6_config_start (priv->modem, nm_device_get_act_request (device), reason); } else @@ -896,7 +909,7 @@ act_stage3_ip6_config_start (NMDevice *device, static void deactivate (NMDevice *device) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); priv->have_iface = FALSE; priv->connected = FALSE; @@ -985,32 +998,56 @@ mm_name_owner_changed (GObject *object, /*****************************************************************************/ -NMDevice * -nm_device_bt_new (NMBluezDevice *bt_device, - const char *udi, - const char *bdaddr, - const char *name, - guint32 capabilities) +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { - g_return_val_if_fail (udi != NULL, NULL); - g_return_val_if_fail (bdaddr != NULL, NULL); - g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (capabilities != NM_BT_CAPABILITY_NONE, NULL); - g_return_val_if_fail (NM_IS_BLUEZ_DEVICE (bt_device), NULL); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) object); - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BT, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, bdaddr, - NM_DEVICE_DRIVER, "bluez", - NM_DEVICE_PERM_HW_ADDRESS, bdaddr, - NM_DEVICE_BT_DEVICE, bt_device, - NM_DEVICE_BT_NAME, name, - NM_DEVICE_BT_CAPABILITIES, capabilities, - NM_DEVICE_TYPE_DESC, "Bluetooth", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BT, - NULL); + switch (prop_id) { + case PROP_BT_NAME: + g_value_set_string (value, priv->name); + break; + case PROP_BT_CAPABILITIES: + g_value_set_uint (value, priv->capabilities); + break; + case PROP_BT_DEVICE: + g_value_set_object (value, priv->bt_device); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) object); + + switch (prop_id) { + case PROP_BT_NAME: + /* Construct only */ + priv->name = g_value_dup_string (value); + break; + case PROP_BT_CAPABILITIES: + /* Construct only */ + priv->capabilities = g_value_get_uint (value); + break; + case PROP_BT_DEVICE: + /* Construct only */ + priv->bt_device = g_value_dup_object (value); + g_signal_connect (priv->bt_device, "removed", G_CALLBACK (bluez_device_removed), object); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + static void nm_device_bt_init (NMDeviceBt *self) { @@ -1041,7 +1078,7 @@ nm_device_bt_init (NMDeviceBt *self) static void constructed (GObject *object) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) object); const char *my_hwaddr; G_OBJECT_CLASS (nm_device_bt_parent_class)->constructed (object); @@ -1056,58 +1093,36 @@ constructed (GObject *object) object); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_BT_NAME: - /* Construct only */ - priv->name = g_value_dup_string (value); - break; - case PROP_BT_CAPABILITIES: - /* Construct only */ - priv->capabilities = g_value_get_uint (value); - break; - case PROP_BT_DEVICE: - /* Construct only */ - priv->bt_device = g_value_dup_object (value); - g_signal_connect (priv->bt_device, "removed", G_CALLBACK (bluez_device_removed), object); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +NMDevice * +nm_device_bt_new (NMBluezDevice *bt_device, + const char *udi, + const char *bdaddr, + const char *name, + guint32 capabilities) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); + g_return_val_if_fail (udi != NULL, NULL); + g_return_val_if_fail (bdaddr != NULL, NULL); + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (capabilities != NM_BT_CAPABILITY_NONE, NULL); + g_return_val_if_fail (NM_IS_BLUEZ_DEVICE (bt_device), NULL); - switch (prop_id) { - case PROP_BT_NAME: - g_value_set_string (value, priv->name); - break; - case PROP_BT_CAPABILITIES: - g_value_set_uint (value, priv->capabilities); - break; - case PROP_BT_DEVICE: - g_value_set_object (value, priv->bt_device); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BT, + NM_DEVICE_UDI, udi, + NM_DEVICE_IFACE, bdaddr, + NM_DEVICE_DRIVER, "bluez", + NM_DEVICE_PERM_HW_ADDRESS, bdaddr, + NM_DEVICE_BT_DEVICE, bt_device, + NM_DEVICE_BT_NAME, name, + NM_DEVICE_BT_CAPABILITIES, capabilities, + NM_DEVICE_TYPE_DESC, "Bluetooth", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BT, + NULL); } static void dispose (GObject *object) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) object); nm_clear_g_source (&priv->timeout_id); @@ -1127,7 +1142,7 @@ dispose (GObject *object) static void finalize (GObject *object) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) object); g_free (priv->rfcomm_iface); g_free (priv->name); @@ -1142,8 +1157,6 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceBtPrivate)); - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; @@ -1164,37 +1177,33 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) device_class->state_changed = device_state_changed; - /* Properties */ - g_object_class_install_property - (object_class, PROP_BT_NAME, - g_param_spec_string (NM_DEVICE_BT_NAME, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_BT_CAPABILITIES, - g_param_spec_uint (NM_DEVICE_BT_CAPABILITIES, "", "", - NM_BT_CAPABILITY_NONE, G_MAXUINT, NM_BT_CAPABILITY_NONE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_BT_DEVICE, - g_param_spec_object (NM_DEVICE_BT_DEVICE, "", "", - NM_TYPE_BLUEZ_DEVICE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /* Signals */ + obj_properties[PROP_BT_NAME] = + g_param_spec_string (NM_DEVICE_BT_NAME, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_BT_CAPABILITIES] = + g_param_spec_uint (NM_DEVICE_BT_CAPABILITIES, "", "", + NM_BT_CAPABILITY_NONE, G_MAXUINT, NM_BT_CAPABILITY_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_BT_DEVICE] = + g_param_spec_object (NM_DEVICE_BT_DEVICE, "", "", + NM_TYPE_BLUEZ_DEVICE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + signals[PPP_STATS] = - g_signal_new ("ppp-stats", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDeviceBtClass, ppp_stats), - NULL, NULL, NULL, - G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); + g_signal_new ("ppp-stats", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_BLUETOOTH_SKELETON, diff --git a/src/devices/bluetooth/nm-device-bt.h b/src/devices/bluetooth/nm-device-bt.h index c97cca01..43bd4257 100644 --- a/src/devices/bluetooth/nm-device-bt.h +++ b/src/devices/bluetooth/nm-device-bt.h @@ -21,31 +21,24 @@ #ifndef __NETWORKMANAGER_DEVICE_BT_H__ #define __NETWORKMANAGER_DEVICE_BT_H__ -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-bluez-device.h" -#include "nm-modem.h" -#define NM_TYPE_DEVICE_BT (nm_device_bt_get_type ()) -#define NM_DEVICE_BT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_BT, NMDeviceBt)) -#define NM_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_BT, NMDeviceBtClass)) -#define NM_IS_DEVICE_BT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_BT)) -#define NM_IS_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BT)) -#define NM_DEVICE_BT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BT, NMDeviceBtClass)) +#include "devices/wwan/nm-modem.h" + +#define NM_TYPE_DEVICE_BT (nm_device_bt_get_type ()) +#define NM_DEVICE_BT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_BT, NMDeviceBt)) +#define NM_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_BT, NMDeviceBtClass)) +#define NM_IS_DEVICE_BT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_BT)) +#define NM_IS_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BT)) +#define NM_DEVICE_BT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BT, NMDeviceBtClass)) #define NM_DEVICE_BT_NAME "name" #define NM_DEVICE_BT_CAPABILITIES "bt-capabilities" #define NM_DEVICE_BT_DEVICE "bt-device" -typedef struct { - NMDevice parent; -} NMDeviceBt; - -typedef struct { - NMDeviceClass parent; - - /* Signals */ - void (*ppp_stats) (NMDeviceBt *device, guint32 in_bytes, guint32 out_bytes); -} NMDeviceBtClass; +typedef struct _NMDeviceBt NMDeviceBt; +typedef struct _NMDeviceBtClass NMDeviceBtClass; GType nm_device_bt_get_type (void); diff --git a/src/devices/nm-arping-manager.c b/src/devices/nm-arping-manager.c index dfb20b4b..7b765844 100644 --- a/src/devices/nm-arping-manager.c +++ b/src/devices/nm-arping-manager.c @@ -16,15 +16,18 @@ #include "nm-default.h" +#include "nm-arping-manager.h" + #include #include #include -#include "nm-arping-manager.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" +/*****************************************************************************/ + typedef enum { STATE_INIT, STATE_PROBING, @@ -32,15 +35,6 @@ typedef enum { STATE_ANNOUNCING, } State; -typedef struct { - int ifindex; - State state; - GHashTable *addresses; - guint completed; - guint timer; - guint round2_id; -} NMArpingManagerPrivate; - typedef struct { in_addr_t address; GPid pid; @@ -49,15 +43,38 @@ typedef struct { NMArpingManager *manager; } AddressInfo; +/*****************************************************************************/ + enum { PROBE_TERMINATED, LAST_SIGNAL, }; + static guint signals[LAST_SIGNAL] = { 0 }; +typedef struct { + int ifindex; + State state; + GHashTable *addresses; + guint completed; + guint timer; + guint round2_id; +} NMArpingManagerPrivate; + +struct _NMArpingManager { + GObject parent; + NMArpingManagerPrivate _priv; +}; + +struct _NMArpingManagerClass { + GObjectClass parent; +}; + G_DEFINE_TYPE (NMArpingManager, nm_arping_manager, G_TYPE_OBJECT) -#define NM_ARPING_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ARPING_MANAGER, NMArpingManagerPrivate)) +#define NM_ARPING_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMArpingManager, NM_IS_ARPING_MANAGER) + +/*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_IP4 #define _NMLOG_PREFIX_NAME "arping" @@ -74,6 +91,8 @@ G_DEFINE_TYPE (NMArpingManager, nm_arping_manager, G_TYPE_OBJECT) _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ } G_STMT_END +/*****************************************************************************/ + /** * nm_arping_manager_add_address: * @self: a #NMArpingManager @@ -174,7 +193,7 @@ arping_timeout_cb (gpointer user_data) * Start probing IP addresses for duplicates; when the probe terminates a * PROBE_TERMINATED signal is emitted. * - * Returns: %TRUE on success, %FALSE on failure + * Returns: %TRUE if at least one probe could be started, %FALSE otherwise */ gboolean nm_arping_manager_start_probe (NMArpingManager *self, guint timeout, GError **error) @@ -184,6 +203,7 @@ nm_arping_manager_start_probe (NMArpingManager *self, guint timeout, GError **er GHashTableIter iter; AddressInfo *info; gs_free char *timeout_str = NULL; + gboolean success = FALSE; g_return_val_if_fail (NM_IS_ARPING_MANAGER (self), FALSE); g_return_val_if_fail (!error || !*error, FALSE); @@ -217,24 +237,29 @@ nm_arping_manager_start_probe (NMArpingManager *self, guint timeout, GError **er while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &info)) { gs_free char *tmp_str = NULL; - gboolean success; argv[9] = nm_utils_inet4_ntop (info->address, NULL); _LOGD ("run %s", (tmp_str = g_strjoinv (" ", (char **) argv))); - success = g_spawn_async (NULL, (char **) argv, NULL, - G_SPAWN_STDOUT_TO_DEV_NULL | - G_SPAWN_STDERR_TO_DEV_NULL | - G_SPAWN_DO_NOT_REAP_CHILD, - NULL, NULL, &info->pid, NULL); - - info->watch = g_child_watch_add (info->pid, arping_watch_cb, info); + if (g_spawn_async (NULL, (char **) argv, NULL, + G_SPAWN_STDOUT_TO_DEV_NULL | + G_SPAWN_STDERR_TO_DEV_NULL | + G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, &info->pid, NULL)) { + info->watch = g_child_watch_add (info->pid, arping_watch_cb, info); + success = TRUE; + } } - priv->timer = g_timeout_add (timeout, arping_timeout_cb, self); - priv->state = STATE_PROBING; + if (success) { + priv->timer = g_timeout_add (timeout, arping_timeout_cb, self); + priv->state = STATE_PROBING; + } else { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + "could not spawn arping process"); + } - return TRUE; + return success; } /** @@ -350,7 +375,7 @@ send_announcements (NMArpingManager *self, const char *mode_arg) static gboolean arp_announce_round2 (gpointer self) { - NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self); + NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE ((NMArpingManager *) self); priv->round2_id = 0; send_announcements (self, "-U"); @@ -395,18 +420,7 @@ destroy_address_info (gpointer data) g_slice_free (AddressInfo, info); } -static void -dispose (GObject *object) -{ - NMArpingManager *self = NM_ARPING_MANAGER (object); - NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self); - - nm_clear_g_source (&priv->timer); - nm_clear_g_source (&priv->round2_id); - g_clear_pointer (&priv->addresses, g_hash_table_destroy); - - G_OBJECT_CLASS (nm_arping_manager_parent_class)->dispose (object); -} +/*****************************************************************************/ static void nm_arping_manager_init (NMArpingManager *self) @@ -427,23 +441,33 @@ nm_arping_manager_new (int ifindex) self = g_object_new (NM_TYPE_ARPING_MANAGER, NULL); priv = NM_ARPING_MANAGER_GET_PRIVATE (self); priv->ifindex = ifindex; - return self; } +static void +dispose (GObject *object) +{ + NMArpingManager *self = NM_ARPING_MANAGER (object); + NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self); + + nm_clear_g_source (&priv->timer); + nm_clear_g_source (&priv->round2_id); + g_clear_pointer (&priv->addresses, g_hash_table_destroy); + + G_OBJECT_CLASS (nm_arping_manager_parent_class)->dispose (object); +} + static void nm_arping_manager_class_init (NMArpingManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMArpingManagerPrivate)); - object_class->dispose = dispose; signals[PROBE_TERMINATED] = - g_signal_new (NM_ARPING_MANAGER_PROBE_TERMINATED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, NULL, - G_TYPE_NONE, 0); + g_signal_new (NM_ARPING_MANAGER_PROBE_TERMINATED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); } diff --git a/src/devices/nm-arping-manager.h b/src/devices/nm-arping-manager.h index 78965a0d..c8a86af0 100644 --- a/src/devices/nm-arping-manager.h +++ b/src/devices/nm-arping-manager.h @@ -28,13 +28,7 @@ #define NM_ARPING_MANAGER_PROBE_TERMINATED "probe-terminated" -struct _NMArpingManager { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMArpingManagerClass; +typedef struct _NMArpingManagerClass NMArpingManagerClass; GType nm_arping_manager_get_type (void); diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 75b2e315..5dba19d9 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -20,32 +20,36 @@ #include "nm-default.h" +#include "nm-device-bond.h" + #include #include -#include "nm-device-bond.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" -#include "nm-platform.h" -#include "nm-enum-types.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-core-internal.h" #include "nm-ip4-config.h" -#include "nmdbus-device-bond.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Bond.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceBond); -G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) +/*****************************************************************************/ + +struct _NMDeviceBond { + NMDevice parent; +}; -#define NM_DEVICE_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BOND, NMDeviceBondPrivate)) +struct _NMDeviceBondClass { + NMDeviceClass parent; +}; -typedef struct { - int dummy; -} NMDeviceBondPrivate; +G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) -/******************************************************************/ +/*****************************************************************************/ static NMDeviceCapabilities get_generic_capabilities (NMDevice *dev) @@ -115,7 +119,7 @@ complete_connection (NMDevice *device, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static gboolean set_bond_attr (NMDevice *device, NMBondMode mode, const char *attr, const char *value) @@ -372,30 +376,13 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) /* Interface must be down to set bond options */ nm_device_take_down (dev, TRUE); ret = apply_bonding_config (dev); + if (ret) + ret = nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE); nm_device_bring_up (dev, TRUE, &no_firmware); return ret; } -static void -ip4_config_pre_commit (NMDevice *self, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - - connection = nm_device_get_applied_connection (self); - g_assert (connection); - s_wired = nm_connection_get_setting_wired (connection); - - if (s_wired) { - /* MTU override */ - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); - } -} - static gboolean enslave_slave (NMDevice *device, NMDevice *slave, @@ -432,8 +419,14 @@ release_slave (NMDevice *device, { NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean success, no_firmware = FALSE; + gs_free char *address = NULL; if (configure) { + /* When the last slave is released the bond MAC will be set to a random + * value by kernel; remember the current one and restore it afterwards. + */ + address = g_strdup (nm_device_get_hw_address (device)); + success = nm_platform_link_release (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); @@ -446,6 +439,10 @@ release_slave (NMDevice *device, nm_device_get_ip_iface (slave)); } + nm_platform_process_events (NM_PLATFORM_GET); + if (nm_device_update_hw_address (device)) + nm_device_hw_addr_set (device, address, "restore", FALSE); + /* Kernel bonding code "closes" the slave when releasing it, (which clears * IFF_UP), so we must bring it back up here to ensure carrier changes and * other state is noticed by the now-released slave. @@ -482,7 +479,7 @@ create_and_realize (NMDevice *device, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static void nm_device_bond_init (NMDeviceBond * self) @@ -492,11 +489,8 @@ nm_device_bond_init (NMDeviceBond * self) static void nm_device_bond_class_init (NMDeviceBondClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceBondPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BOND_SETTING_NAME, NM_LINK_TYPE_BOND) parent_class->get_generic_capabilities = get_generic_capabilities; @@ -510,7 +504,7 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) parent_class->create_and_realize = create_and_realize; parent_class->act_stage1_prepare = act_stage1_prepare; - parent_class->ip4_config_pre_commit = ip4_config_pre_commit; + parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; parent_class->enslave_slave = enslave_slave; parent_class->release_slave = release_slave; @@ -519,10 +513,10 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_BOND_FACTORY (nm_bond_factory_get_type ()) -#define NM_BOND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BOND_FACTORY, NMBondFactory)) +#define NM_TYPE_BOND_DEVICE_FACTORY (nm_bond_device_factory_get_type ()) +#define NM_BOND_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BOND_DEVICE_FACTORY, NMBondDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -544,6 +538,5 @@ create_device (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (BOND, Bond, bond, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BOND) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BOND_SETTING_NAME), - factory_iface->create_device = create_device; - ) - + factory_class->create_device = create_device; +); diff --git a/src/devices/nm-device-bond.h b/src/devices/nm-device-bond.h index 02b6c8e5..b4e9b0e8 100644 --- a/src/devices/nm-device-bond.h +++ b/src/devices/nm-device-bond.h @@ -30,8 +30,8 @@ #define NM_IS_DEVICE_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BOND)) #define NM_DEVICE_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BOND, NMDeviceBondClass)) -typedef NMDevice NMDeviceBond; -typedef NMDeviceClass NMDeviceBondClass; +typedef struct _NMDeviceBond NMDeviceBond; +typedef struct _NMDeviceBondClass NMDeviceBondClass; GType nm_device_bond_get_type (void); diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index c35d2863..613d59cd 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -20,30 +20,34 @@ #include "nm-default.h" +#include "nm-device-bridge.h" + #include -#include "nm-device-bridge.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" -#include "nm-enum-types.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-core-internal.h" -#include "nmdbus-device-bridge.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Bridge.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceBridge); -G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgePrivate)) +struct _NMDeviceBridge { + NMDevice parent; +}; -typedef struct { - int dummy; -} NMDeviceBridgePrivate; +struct _NMDeviceBridgeClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) -/******************************************************************/ +/*****************************************************************************/ static NMDeviceCapabilities get_generic_capabilities (NMDevice *dev) @@ -121,7 +125,7 @@ complete_connection (NMDevice *device, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ typedef struct { const char *name; @@ -312,6 +316,9 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) if (ret != NM_ACT_STAGE_RETURN_SUCCESS) return ret; + if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE)) + return NM_ACT_STAGE_RETURN_FAILURE; + commit_master_options (device, nm_connection_get_setting_bridge (connection)); return NM_ACT_STAGE_RETURN_SUCCESS; @@ -411,7 +418,7 @@ create_and_realize (NMDevice *device, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static void nm_device_bridge_init (NMDeviceBridge * self) @@ -421,11 +428,8 @@ nm_device_bridge_init (NMDeviceBridge * self) static void nm_device_bridge_class_init (NMDeviceBridgeClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceBridgePrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BRIDGE_SETTING_NAME, NM_LINK_TYPE_BRIDGE) parent_class->get_generic_capabilities = get_generic_capabilities; @@ -441,16 +445,17 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) parent_class->act_stage1_prepare = act_stage1_prepare; parent_class->enslave_slave = enslave_slave; parent_class->release_slave = release_slave; + parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_BRIDGE_SKELETON, NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_BRIDGE_FACTORY (nm_bridge_factory_get_type ()) -#define NM_BRIDGE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BRIDGE_FACTORY, NMBridgeFactory)) +#define NM_TYPE_BRIDGE_DEVICE_FACTORY (nm_bridge_device_factory_get_type ()) +#define NM_BRIDGE_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BRIDGE_DEVICE_FACTORY, NMBridgeDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -472,6 +477,5 @@ create_device (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (BRIDGE, Bridge, bridge, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BRIDGE) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BRIDGE_SETTING_NAME), - factory_iface->create_device = create_device; - ) - + factory_class->create_device = create_device; +); diff --git a/src/devices/nm-device-bridge.h b/src/devices/nm-device-bridge.h index 05da9ed7..f0fa1f4b 100644 --- a/src/devices/nm-device-bridge.h +++ b/src/devices/nm-device-bridge.h @@ -30,8 +30,8 @@ #define NM_IS_DEVICE_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BRIDGE)) #define NM_DEVICE_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgeClass)) -typedef NMDevice NMDeviceBridge; -typedef NMDeviceClass NMDeviceBridgeClass; +typedef struct _NMDeviceBridge NMDeviceBridge; +typedef struct _NMDeviceBridgeClass NMDeviceBridgeClass; GType nm_device_bridge_get_type (void); diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 51515c09..f9d753a5 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -32,25 +32,27 @@ #include #include "nm-device-private.h" -#include "nm-activation-request.h" +#include "nm-act-request.h" +#include "nm-ip4-config.h" #include "NetworkManagerUtils.h" -#include "nm-supplicant-manager.h" -#include "nm-supplicant-interface.h" -#include "nm-supplicant-config.h" -#include "ppp-manager/nm-ppp-manager.h" -#include "nm-enum-types.h" -#include "nm-platform.h" -#include "nm-platform-utils.h" +#include "supplicant/nm-supplicant-manager.h" +#include "supplicant/nm-supplicant-interface.h" +#include "supplicant/nm-supplicant-config.h" +#include "ppp/nm-ppp-manager.h" +#include "ppp/nm-ppp-manager-call.h" +#include "ppp/nm-ppp-status.h" +#include "platform/nm-platform.h" +#include "platform/nm-platform-utils.h" #include "nm-dcb.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings-connection.h" #include "nm-config.h" #include "nm-device-ethernet-utils.h" -#include "nm-settings.h" +#include "settings/nm-settings.h" #include "nm-device-factory.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" -#include "nmdbus-device-ethernet.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Wired.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceEthernet); @@ -73,7 +75,6 @@ typedef struct Supplicant { gulong iface_state_id; /* Timeouts and idles */ - guint iface_con_error_cb_id; guint con_timeout_id; } Supplicant; @@ -106,6 +107,8 @@ typedef struct _NMDeviceEthernetPrivate { char * s390_nettype; GHashTable * s390_options; + NMActRequestGetSecretsCallId wired_secrets_id; + /* PPPoE */ NMPPPManager *ppp_manager; NMIP4Config *pending_ip4_config; @@ -131,6 +134,10 @@ G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) /*****************************************************************************/ +static void wired_secrets_cancel (NMDeviceEthernet *self); + +/*****************************************************************************/ + static char * get_link_basename (const char *parent_path, const char *name, GError **error) { @@ -169,11 +176,8 @@ _update_s390_subchannels (NMDeviceEthernet *self) ifindex = nm_device_get_ifindex ((NMDevice *) self); dev = (GUdevDevice *) nm_g_object_ref (nm_platform_link_get_udev_device (NM_PLATFORM_GET, ifindex)); - if (!dev) { - /* we only call _update_s390_subchannels() when platform claims the device to be initialized. - * Thus, we expect to successfully lookup a GUdevDevice. */ - g_return_if_reached (); - } + if (!dev) + return; /* Try for the "ccwgroup" parent */ parent = g_udev_device_get_parent_with_subsystem (dev, "ccwgroup", NULL); @@ -209,7 +213,7 @@ _update_s390_subchannels (NMDeviceEthernet *self) gs_free char *path = NULL, *value = NULL; path = g_strdup_printf ("%s/%s", parent_path, item); - value = nm_platform_sysctl_get (NM_PLATFORM_GET, path); + value = nm_platform_sysctl_get (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (path)); if ( !strcmp (item, "portname") && !g_strcmp0 (value, "no portname required")) { @@ -254,18 +258,6 @@ _update_s390_subchannels (NMDeviceEthernet *self) _notify (self, PROP_S390_SUBCHANNELS); } -static void -constructed (GObject *object) -{ - const NMPlatformLink *pllink; - - G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructed (object); - - pllink = nm_platform_link_get (NM_PLATFORM_GET, nm_device_get_ifindex ((NMDevice *) object)); - if (pllink && pllink->initialized) - _update_s390_subchannels ((NMDeviceEthernet *) object); -} - static void clear_secrets_tries (NMDevice *device) { @@ -286,6 +278,9 @@ device_state_changed (NMDevice *device, NMDeviceState old_state, NMDeviceStateReason reason) { + if (new_state > NM_DEVICE_STATE_ACTIVATED) + wired_secrets_cancel (NM_DEVICE_ETHERNET (device)); + if ( new_state == NM_DEVICE_STATE_ACTIVATED || new_state == NM_DEVICE_STATE_FAILED || new_state == NM_DEVICE_STATE_DISCONNECTED) @@ -307,14 +302,18 @@ static NMDeviceCapabilities get_generic_capabilities (NMDevice *device) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); - - if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (device))) - return NM_DEVICE_CAP_CARRIER_DETECT; - else { - _LOGI (LOGD_PLATFORM, "driver '%s' does not support carrier detection.", - nm_device_get_driver (device)); - return NM_DEVICE_CAP_NONE; + int ifindex = nm_device_get_ifindex (device); + + if (ifindex > 0) { + if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, ifindex)) + return NM_DEVICE_CAP_CARRIER_DETECT; + else { + _LOGI (LOGD_PLATFORM, "driver '%s' does not support carrier detection.", + nm_device_get_driver (device)); + } } + + return NM_DEVICE_CAP_NONE; } static guint32 @@ -430,7 +429,6 @@ supplicant_interface_clear_handlers (NMDeviceEthernet *self) nm_clear_g_source (&priv->supplicant_timeout_id); nm_clear_g_source (&priv->supplicant.con_timeout_id); - nm_clear_g_source (&priv->supplicant.iface_con_error_cb_id); nm_clear_g_signal_handler (priv->supplicant.iface, &priv->supplicant.iface_error_id); } @@ -456,22 +454,66 @@ wired_secrets_cb (NMActRequest *req, GError *error, gpointer user_data) { - NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data); - NMDevice *dev = NM_DEVICE (self); + NMDeviceEthernet *self = user_data; + NMDevice *device = user_data; + NMDeviceEthernetPrivate *priv; + + g_return_if_fail (NM_IS_DEVICE_ETHERNET (self)); + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - if (req != nm_device_get_act_request (dev)) + g_return_if_fail (priv->wired_secrets_id == call_id); + + priv->wired_secrets_id = NULL; + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH); + g_return_if_fail (req == nm_device_get_act_request (device)); + g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH); g_return_if_fail (nm_act_request_get_settings_connection (req) == connection); if (error) { _LOGW (LOGD_ETHER, "%s", error->message); - nm_device_state_changed (dev, + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); } else - nm_device_activate_schedule_stage1_device_prepare (dev); + nm_device_activate_schedule_stage1_device_prepare (device); +} + +static void +wired_secrets_cancel (NMDeviceEthernet *self) +{ + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); + + if (priv->wired_secrets_id) + nm_act_request_cancel_secrets (NULL, priv->wired_secrets_id); + nm_assert (!priv->wired_secrets_id); +} + +static void +wired_secrets_get_secrets (NMDeviceEthernet *self, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags) +{ + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); + NMActRequest *req; + + wired_secrets_cancel (self); + + req = nm_device_get_act_request (NM_DEVICE (self)); + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + priv->wired_secrets_id = nm_act_request_get_secrets (req, + TRUE, + setting_name, + flags, + NULL, + wired_secrets_cb, + self); + g_return_if_fail (priv->wired_secrets_id); } static gboolean @@ -514,12 +556,7 @@ link_timeout_cb (gpointer user_data) supplicant_interface_release (self); nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT); - nm_act_request_get_secrets (req, - setting_name, - NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW, - NULL, - wired_secrets_cb, - self); + wired_secrets_get_secrets (self, setting_name, NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW); return FALSE; @@ -640,19 +677,6 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, } } -static gboolean -supplicant_iface_connection_error_cb_handler (gpointer user_data) -{ - NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data); - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - - supplicant_interface_release (self); - nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED); - - priv->supplicant.iface_con_error_cb_id = 0; - return FALSE; -} - static void supplicant_iface_connection_error_cb (NMSupplicantInterface *iface, const char *name, @@ -660,18 +684,15 @@ supplicant_iface_connection_error_cb (NMSupplicantInterface *iface, gpointer user_data) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data); - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - guint id; _LOGW (LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) association request to the supplicant failed: %s - %s", name, message); - if (priv->supplicant.iface_con_error_cb_id) - g_source_remove (priv->supplicant.iface_con_error_cb_id); - - id = g_idle_add (supplicant_iface_connection_error_cb_handler, self); - priv->supplicant.iface_con_error_cb_id = id; + supplicant_interface_release (self); + nm_device_queue_state (NM_DEVICE (self), + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED); } static NMActStageReturn @@ -695,12 +716,9 @@ handle_auth_or_fail (NMDeviceEthernet *self, setting_name = nm_connection_need_secrets (applied_connection, NULL); if (setting_name) { - NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; - - if (new_secrets) - flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; - nm_act_request_get_secrets (req, setting_name, flags, NULL, wired_secrets_cb, self); - + wired_secrets_get_secrets (self, setting_name, + NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION + | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); g_object_set_data (G_OBJECT (applied_connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); } else _LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); @@ -758,7 +776,7 @@ supplicant_interface_init (NMDeviceEthernet *self) priv->supplicant.iface = nm_supplicant_manager_create_interface (priv->supplicant.mgr, nm_device_get_iface (NM_DEVICE (self)), - FALSE); + NM_SUPPLICANT_DRIVER_WIRED); if (!priv->supplicant.iface) { _LOGE (LOGD_DEVICE | LOGD_ETHER, @@ -774,7 +792,7 @@ supplicant_interface_init (NMDeviceEthernet *self) /* Hook up error signal handler to capture association errors */ priv->supplicant.iface_error_id = g_signal_connect (priv->supplicant.iface, - "connection-error", + NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR, G_CALLBACK (supplicant_iface_connection_error_cb), self); @@ -784,6 +802,84 @@ supplicant_interface_init (NMDeviceEthernet *self) return TRUE; } +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (link_duplex_to_string, NMPlatformLinkDuplexType, + NM_UTILS_LOOKUP_DEFAULT_WARN (NULL), + NM_UTILS_LOOKUP_STR_ITEM (NM_PLATFORM_LINK_DUPLEX_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM (NM_PLATFORM_LINK_DUPLEX_FULL, "full"), + NM_UTILS_LOOKUP_STR_ITEM (NM_PLATFORM_LINK_DUPLEX_HALF, "half"), +); + +static NMPlatformLinkDuplexType +link_duplex_to_platform (const char *duplex) +{ + if (!duplex) + return NM_PLATFORM_LINK_DUPLEX_UNKNOWN; + if (nm_streq (duplex, "full")) + return NM_PLATFORM_LINK_DUPLEX_FULL; + if (nm_streq (duplex, "half")) + return NM_PLATFORM_LINK_DUPLEX_HALF; + g_return_val_if_reached (NM_PLATFORM_LINK_DUPLEX_UNKNOWN); +} + +static void +link_negotiation_set (NMDevice *device) +{ + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); + NMSettingWired *s_wired; + gboolean autoneg = TRUE; + gboolean link_autoneg; + NMPlatformLinkDuplexType duplex = NM_PLATFORM_LINK_DUPLEX_UNKNOWN; + NMPlatformLinkDuplexType link_duplex; + guint32 speed = 0; + guint32 link_speed; + + s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED); + if (s_wired) { + autoneg = nm_setting_wired_get_auto_negotiate (s_wired); + if (!autoneg) { + speed = nm_setting_wired_get_speed (s_wired); + duplex = link_duplex_to_platform (nm_setting_wired_get_duplex (s_wired)); + if (!speed && !duplex) { + _LOGD (LOGD_DEVICE, "set-link: ignore link negotiation"); + return; + } + } + } + + if (!nm_platform_ethtool_get_link_settings (NM_PLATFORM_GET, nm_device_get_ifindex (device), + &link_autoneg, &link_speed, &link_duplex)) { + _LOGW (LOGD_DEVICE, "set-link: unable to retrieve link negotiation"); + return; + } + + /* If link negotiation setting are already in place do nothing and return with success */ + if ( (!!autoneg == !!link_autoneg) + && (!speed || (speed == link_speed)) + && (!duplex || (duplex == link_duplex))) { + _LOGD (LOGD_DEVICE, "set-link: link negotiation is already configured"); + return; + } + + if (autoneg) + _LOGD (LOGD_DEVICE, "set-link: configure autonegotiation"); + else { + _LOGD (LOGD_DEVICE, "set-link: configure static negotiation (%u Mbit%s - %s duplex%s)", + speed ?: link_speed, + speed ? "" : "*", + duplex ? link_duplex_to_string (duplex) : link_duplex_to_string (link_duplex), + duplex ? "" : "*"); + } + + if (!nm_platform_ethtool_set_link_settings (NM_PLATFORM_GET, + nm_device_get_ifindex (device), + autoneg, + speed, + duplex)) { + _LOGW (LOGD_DEVICE, "set-link: failure to set link negotiation"); + return; + } +} + static gboolean pppoe_reconnect_delay (gpointer user_data) { @@ -801,40 +897,41 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; + NMActStageReturn ret; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason); - if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE)) - ret = NM_ACT_STAGE_RETURN_FAILURE; - } + if (ret != NM_ACT_STAGE_RETURN_SUCCESS) + return ret; - if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - /* If we're re-activating a PPPoE connection a short while after - * a previous PPPoE connection was torn down, wait a bit to allow the - * remote side to handle the disconnection. Otherwise the peer may - * get confused and fail to negotiate the new connection. (rh #1023503) - */ - if (priv->last_pppoe_time) { - gint32 delay = nm_utils_get_monotonic_timestamp_s () - priv->last_pppoe_time; - - if ( delay < PPPOE_RECONNECT_DELAY - && nm_device_get_applied_setting (dev, NM_TYPE_SETTING_PPPOE)) { - _LOGI (LOGD_DEVICE, "delaying PPPoE reconnect for %d seconds to ensure peer is ready...", - delay); - g_assert (!priv->pppoe_wait_id); - priv->pppoe_wait_id = g_timeout_add_seconds (delay, - pppoe_reconnect_delay, - self); - ret = NM_ACT_STAGE_RETURN_POSTPONE; - } else - priv->last_pppoe_time = 0; + link_negotiation_set (dev); + + if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE)) + return NM_ACT_STAGE_RETURN_FAILURE; + + /* If we're re-activating a PPPoE connection a short while after + * a previous PPPoE connection was torn down, wait a bit to allow the + * remote side to handle the disconnection. Otherwise the peer may + * get confused and fail to negotiate the new connection. (rh #1023503) + */ + if (priv->last_pppoe_time) { + gint32 delay = nm_utils_get_monotonic_timestamp_s () - priv->last_pppoe_time; + + if ( delay < PPPOE_RECONNECT_DELAY + && nm_device_get_applied_setting (dev, NM_TYPE_SETTING_PPPOE)) { + _LOGI (LOGD_DEVICE, "delaying PPPoE reconnect for %d seconds to ensure peer is ready...", + delay); + g_assert (!priv->pppoe_wait_id); + priv->pppoe_wait_id = g_timeout_add_seconds (delay, + pppoe_reconnect_delay, + self); + return NM_ACT_STAGE_RETURN_POSTPONE; } + priv->last_pppoe_time = 0; } - return ret; + return NM_ACT_STAGE_RETURN_SUCCESS; } static NMActStageReturn @@ -934,12 +1031,16 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE); g_assert (s_pppoe); - priv->ppp_manager = nm_ppp_manager_new (nm_device_get_iface (NM_DEVICE (self))); - if (nm_ppp_manager_start (priv->ppp_manager, req, nm_setting_pppoe_get_username (s_pppoe), 30, 0, &err)) { - g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED, + priv->ppp_manager = nm_ppp_manager_create (nm_device_get_iface (NM_DEVICE (self)), + &err); + if ( priv->ppp_manager + && nm_ppp_manager_start (priv->ppp_manager, req, + nm_setting_pppoe_get_username (s_pppoe), + 30, 0, &err)) { + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, G_CALLBACK (ppp_state_changed), self); - g_signal_connect (priv->ppp_manager, "ip4-config", + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, G_CALLBACK (ppp_ip4_config), self); ret = NM_ACT_STAGE_RETURN_POSTPONE; @@ -947,7 +1048,7 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas _LOGW (LOGD_DEVICE, "PPPoE failed to start: %s", err->message); g_error_free (err); - nm_exported_object_clear_and_unexport (&priv->ppp_manager); + g_clear_object (&priv->ppp_manager); *reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; } @@ -955,7 +1056,7 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas return ret; } -/****************************************************************/ +/*****************************************************************************/ static void dcb_state (NMDevice *device, gboolean timeout); @@ -1123,7 +1224,7 @@ dcb_carrier_changed (NMDevice *device, GParamSpec *pspec, gpointer unused) } } -/****************************************************************/ +/*****************************************************************************/ static gboolean wake_on_lan_enable (NMDevice *device) @@ -1161,10 +1262,10 @@ wake_on_lan_enable (NMDevice *device) } wol = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; found: - return nm_platform_ethtool_set_wake_on_lan (NM_PLATFORM_GET, nm_device_get_iface (device), wol, password); + return nm_platform_ethtool_set_wake_on_lan (NM_PLATFORM_GET, nm_device_get_ifindex (device), wol, password); } -/****************************************************************/ +/*****************************************************************************/ static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) @@ -1272,26 +1373,14 @@ act_stage3_ip4_config_start (NMDevice *device, return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage3_ip4_config_start (device, out_config, reason); } -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) +static guint32 +get_configured_mtu (NMDevice *device, gboolean *out_is_user_config) { - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - /* MTU only set for plain ethernet */ if (NM_DEVICE_ETHERNET_GET_PRIVATE ((NMDeviceEthernet *) device)->ppp_manager) - return; - - connection = nm_device_get_applied_connection (device); - g_assert (connection); - s_wired = nm_connection_get_setting_wired (connection); - g_assert (s_wired); + return 0; - /* MTU override */ - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); + return nm_device_get_configured_mtu_for_wired (device, out_is_user_config); } static void @@ -1312,7 +1401,10 @@ deactivate (NMDevice *device) priv->pending_ip4_config = NULL; } - nm_exported_object_clear_and_unexport (&priv->ppp_manager); + if (priv->ppp_manager) { + nm_ppp_manager_stop_sync (priv->ppp_manager); + g_clear_object (&priv->ppp_manager); + } supplicant_interface_release (self); @@ -1524,7 +1616,7 @@ get_link_speed (NMDevice *device) NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); guint32 speed; - if (!nm_platform_ethtool_get_link_speed (NM_PLATFORM_GET, nm_device_get_iface (device), &speed)) + if (!nm_platform_ethtool_get_link_settings (NM_PLATFORM_GET, nm_device_get_ifindex (device), NULL, &speed, NULL)) return; if (priv->speed == speed) return; @@ -1545,10 +1637,11 @@ carrier_changed (NMDevice *device, gboolean carrier) } static void -link_changed (NMDevice *device, NMPlatformLink *info) +link_changed (NMDevice *device, + const NMPlatformLink *pllink) { - NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->link_changed (device, info); - if (info->initialized) + NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->link_changed (device, pllink); + if (pllink->initialized) _update_s390_subchannels ((NMDeviceEthernet *) device); } @@ -1567,6 +1660,8 @@ dispose (GObject *object) NMDeviceEthernet *self = NM_DEVICE_ETHERNET (object); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); + wired_secrets_cancel (self); + supplicant_interface_release (self); nm_clear_g_source (&priv->pppoe_wait_id); @@ -1617,7 +1712,7 @@ get_property (GObject *object, guint prop_id, static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) + const GValue *value, GParamSpec *pspec) { switch (prop_id) { default: @@ -1636,8 +1731,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRED_SETTING_NAME, NM_LINK_TYPE_ETHERNET) - /* virtual methods */ - object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; @@ -1651,7 +1744,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) parent_class->act_stage1_prepare = act_stage1_prepare; parent_class->act_stage2_config = act_stage2_config; parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; - parent_class->ip4_config_pre_commit = ip4_config_pre_commit; + parent_class->get_configured_mtu = get_configured_mtu; parent_class->deactivate = deactivate; parent_class->spec_match_list = spec_match_list; parent_class->update_connection = update_connection; @@ -1680,10 +1773,10 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_ETHERNET_FACTORY (nm_ethernet_factory_get_type ()) -#define NM_ETHERNET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ETHERNET_FACTORY, NMEthernetFactory)) +#define NM_TYPE_ETHERNET_DEVICE_FACTORY (nm_ethernet_device_factory_get_type ()) +#define NM_ETHERNET_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ETHERNET_DEVICE_FACTORY, NMEthernetDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -1703,6 +1796,5 @@ create_device (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (ETHERNET, Ethernet, ethernet, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_ETHERNET) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_PPPOE_SETTING_NAME), - factory_iface->create_device = create_device; - ) - + factory_class->create_device = create_device; +); diff --git a/src/devices/nm-device-ethernet.h b/src/devices/nm-device-ethernet.h index 3ce6f0ca..a50a7d85 100644 --- a/src/devices/nm-device-ethernet.h +++ b/src/devices/nm-device-ethernet.h @@ -42,7 +42,7 @@ typedef struct { } NMDeviceEthernet; typedef struct { - NMDeviceClass parent_class; + NMDeviceClass parent; } NMDeviceEthernetClass; GType nm_device_ethernet_get_type (void); diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c index a72c0bbb..0ce2cb48 100644 --- a/src/devices/nm-device-factory.c +++ b/src/devices/nm-device-factory.c @@ -19,33 +19,43 @@ */ #include "nm-default.h" + +#include "nm-device-factory.h" + #include #include #include #include #include -#include "nm-device-factory.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-utils.h" -const NMLinkType _nm_device_factory_no_default_links[] = { NM_LINK_TYPE_NONE }; -const char *_nm_device_factory_no_default_settings[] = { NULL }; +#define PLUGIN_PREFIX "libnm-device-plugin-" +#define PLUGIN_PATH_TAG "NMManager-plugin-path" -G_DEFINE_INTERFACE (NMDeviceFactory, nm_device_factory, G_TYPE_OBJECT) +/*****************************************************************************/ enum { DEVICE_ADDED, COMPONENT_ADDED, LAST_SIGNAL }; + static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_ABSTRACT_TYPE (NMDeviceFactory, nm_device_factory, G_TYPE_OBJECT) + +/*****************************************************************************/ + gboolean nm_device_factory_emit_component_added (NMDeviceFactory *factory, GObject *component) { gboolean consumed = FALSE; + g_return_val_if_fail (NM_IS_DEVICE_FACTORY (factory), FALSE); + g_return_val_if_fail (G_IS_OBJECT (component), FALSE); + g_signal_emit (factory, signals[COMPONENT_ADDED], 0, component, &consumed); return consumed; } @@ -53,21 +63,13 @@ nm_device_factory_emit_component_added (NMDeviceFactory *factory, GObject *compo void nm_device_factory_get_supported_types (NMDeviceFactory *factory, const NMLinkType **out_link_types, - const char ***out_setting_types) + const char *const**out_setting_types) { - const NMLinkType *link_types_fallback; - const char **setting_types_fallback; - - g_return_if_fail (factory != NULL); - - if (!out_link_types) - out_link_types = &link_types_fallback; - if (!out_setting_types) - out_setting_types = &setting_types_fallback; + g_return_if_fail (NM_IS_DEVICE_FACTORY (factory)); - NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_supported_types (factory, - out_link_types, - out_setting_types); + NM_DEVICE_FACTORY_GET_CLASS (factory)->get_supported_types (factory, + out_link_types, + out_setting_types); } void @@ -75,8 +77,8 @@ nm_device_factory_start (NMDeviceFactory *factory) { g_return_if_fail (factory != NULL); - if (NM_DEVICE_FACTORY_GET_INTERFACE (factory)->start) - NM_DEVICE_FACTORY_GET_INTERFACE (factory)->start (factory); + if (NM_DEVICE_FACTORY_GET_CLASS (factory)->start) + NM_DEVICE_FACTORY_GET_CLASS (factory)->start (factory); } NMDevice * @@ -87,9 +89,9 @@ nm_device_factory_create_device (NMDeviceFactory *factory, gboolean *out_ignore, GError **error) { - NMDeviceFactoryInterface *interface; + NMDeviceFactoryClass *klass; const NMLinkType *link_types = NULL; - const char **setting_types = NULL; + const char *const*setting_types = NULL; int i; NMDevice *device; gboolean ignore = FALSE; @@ -133,15 +135,15 @@ nm_device_factory_create_device (NMDeviceFactory *factory, } } - interface = NM_DEVICE_FACTORY_GET_INTERFACE (factory); - if (!interface->create_device) { + klass = NM_DEVICE_FACTORY_GET_CLASS (factory); + if (!klass->create_device) { g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Device factory %s cannot manage new devices", G_OBJECT_TYPE_NAME (factory)); return NULL; } - device = interface->create_device (factory, iface, plink, connection, &ignore); + device = klass->create_device (factory, iface, plink, connection, &ignore); NM_SET_OUT (out_ignore, ignore); if (!device) { if (ignore) { @@ -167,8 +169,8 @@ nm_device_factory_get_connection_parent (NMDeviceFactory *factory, if (!nm_connection_is_virtual (connection)) return NULL; - if (NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_connection_parent) - return NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_connection_parent (factory, connection); + if (NM_DEVICE_FACTORY_GET_CLASS (factory)->get_connection_parent) + return NM_DEVICE_FACTORY_GET_CLASS (factory)->get_connection_parent (factory, connection); return NULL; } @@ -178,14 +180,14 @@ nm_device_factory_get_connection_iface (NMDeviceFactory *factory, const char *parent_iface, GError **error) { - NMDeviceFactoryInterface *klass; + NMDeviceFactoryClass *klass; char *ifname; g_return_val_if_fail (factory != NULL, NULL); g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (!error || !*error, NULL); - klass = NM_DEVICE_FACTORY_GET_INTERFACE (factory); + klass = NM_DEVICE_FACTORY_GET_CLASS (factory); ifname = g_strdup (nm_connection_get_interface_name (connection)); if (!ifname && klass->get_connection_iface) @@ -200,12 +202,10 @@ nm_device_factory_get_connection_iface (NMDeviceFactory *factory, return NULL; } - if (!nm_utils_iface_valid_name (ifname)) { - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "failed to determine interface name: name \"%s\" is invalid", - ifname); + if (!nm_utils_is_valid_iface_name (ifname, error)) { + g_prefix_error (error, + "failed to determine interface name: name \"%s\" is invalid", + ifname); g_free (ifname); return NULL; } @@ -213,51 +213,48 @@ nm_device_factory_get_connection_iface (NMDeviceFactory *factory, return ifname; } -/*******************************************************************/ +/*****************************************************************************/ static void -nm_device_factory_default_init (NMDeviceFactoryInterface *factory_iface) +nm_device_factory_init (NMDeviceFactory *self) { - /* Signals */ +} + +static void +nm_device_factory_class_init (NMDeviceFactoryClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + signals[DEVICE_ADDED] = g_signal_new (NM_DEVICE_FACTORY_DEVICE_ADDED, - NM_TYPE_DEVICE_FACTORY, + G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDeviceFactoryInterface, device_added), + G_STRUCT_OFFSET (NMDeviceFactoryClass, device_added), NULL, NULL, NULL, G_TYPE_NONE, 1, NM_TYPE_DEVICE); signals[COMPONENT_ADDED] = g_signal_new (NM_DEVICE_FACTORY_COMPONENT_ADDED, - NM_TYPE_DEVICE_FACTORY, + G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMDeviceFactoryInterface, component_added), + G_STRUCT_OFFSET (NMDeviceFactoryClass, component_added), g_signal_accumulator_true_handled, NULL, NULL, G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT); } -/*******************************************************************/ +/*****************************************************************************/ -static GSList *internal_types = NULL; static GHashTable *factories_by_link = NULL; static GHashTable *factories_by_setting = NULL; -void -_nm_device_factory_internal_register_type (GType factory_type) -{ - g_return_if_fail (g_slist_find (internal_types, GUINT_TO_POINTER (factory_type)) == NULL); - internal_types = g_slist_prepend (internal_types, GUINT_TO_POINTER (factory_type)); -} - static void __attribute__((destructor)) _cleanup (void) { - g_clear_pointer (&internal_types, g_slist_free); g_clear_pointer (&factories_by_link, g_hash_table_unref); g_clear_pointer (&factories_by_setting, g_hash_table_unref); } static NMDeviceFactory * find_factory (const NMLinkType *needle_link_types, - const char **needle_setting_types) + const char *const*needle_setting_types) { NMDeviceFactory *found; guint i; @@ -296,7 +293,7 @@ nm_device_factory_manager_find_factory_for_link_type (NMLinkType link_type) NMDeviceFactory * nm_device_factory_manager_find_factory_for_connection (NMConnection *connection) { - const char *stypes[2] = { nm_connection_get_connection_type (connection), NULL }; + const char *const stypes[2] = { nm_connection_get_connection_type (connection), NULL }; g_assert (stypes[0]); return find_factory (NULL, stypes); @@ -332,98 +329,6 @@ nm_device_factory_manager_for_each_factory (NMDeviceFactoryManagerFactoryFunc ca g_slist_free (list); } -#define PLUGIN_PREFIX "libnm-device-plugin-" -#define PLUGIN_PATH_TAG "NMManager-plugin-path" - -struct read_device_factory_paths_data { - char *path; - struct stat st; -}; - -static gint -read_device_factory_paths_sort_fcn (gconstpointer a, gconstpointer b) -{ - const struct read_device_factory_paths_data *da = a; - const struct read_device_factory_paths_data *db = b; - time_t ta, tb; - - ta = MAX (da->st.st_mtime, da->st.st_ctime); - tb = MAX (db->st.st_mtime, db->st.st_ctime); - - if (ta < tb) - return 1; - if (ta > tb) - return -1; - return 0; -} - -static char** -read_device_factory_paths (void) -{ - GDir *dir; - GError *error = NULL; - const char *item; - GArray *paths; - char **result; - guint i; - - dir = g_dir_open (NMPLUGINDIR, 0, &error); - if (!dir) { - nm_log_warn (LOGD_PLATFORM, "device plugin: failed to open directory %s: %s", - NMPLUGINDIR, - error->message); - g_clear_error (&error); - return NULL; - } - - paths = g_array_new (FALSE, FALSE, sizeof (struct read_device_factory_paths_data)); - - while ((item = g_dir_read_name (dir))) { - int errsv; - struct read_device_factory_paths_data data; - - if (!g_str_has_prefix (item, PLUGIN_PREFIX)) - continue; - if (g_str_has_suffix (item, ".la")) - continue; - - data.path = g_build_filename (NMPLUGINDIR, item, NULL); - - if (stat (data.path, &data.st) != 0) { - errsv = errno; - nm_log_warn (LOGD_PLATFORM, "device plugin: skip invalid file %s (error during stat: %s)", data.path, strerror (errsv)); - goto NEXT; - } - if (!S_ISREG (data.st.st_mode)) - goto NEXT; - if (data.st.st_uid != 0) { - nm_log_warn (LOGD_PLATFORM, "device plugin: skip invalid file %s (file must be owned by root)", data.path); - goto NEXT; - } - if (data.st.st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) { - nm_log_warn (LOGD_PLATFORM, "device plugin: skip invalid file %s (invalid file permissions)", data.path); - goto NEXT; - } - - g_array_append_val (paths, data); - continue; -NEXT: - g_free (data.path); - } - g_dir_close (dir); - - /* sort filenames by modification time. */ - g_array_sort (paths, read_device_factory_paths_sort_fcn); - - result = g_new (char *, paths->len + 1); - for (i = 0; i < paths->len; i++) - result[i] = g_array_index (paths, struct read_device_factory_paths_data, i).path; - result[i] = NULL; - - g_array_free (paths, TRUE); - return result; -} - static gboolean _add_factory (NMDeviceFactory *factory, gboolean check_duplicates, @@ -433,7 +338,7 @@ _add_factory (NMDeviceFactory *factory, { NMDeviceFactory *found = NULL; const NMLinkType *link_types = NULL; - const char **setting_types = NULL; + const char *const*setting_types = NULL; int i; g_return_val_if_fail (factories_by_link, FALSE); @@ -463,12 +368,22 @@ _add_factory (NMDeviceFactory *factory, return TRUE; } +static void +_load_internal_factory (GType factory_gtype, + NMDeviceFactoryManagerFactoryFunc callback, + gpointer user_data) +{ + NMDeviceFactory *factory; + + factory = (NMDeviceFactory *) g_object_new (factory_gtype, NULL); + _add_factory (factory, FALSE, "internal", callback, user_data); +} + void nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc callback, gpointer user_data) { NMDeviceFactory *factory; - const GSList *iter; GError *error = NULL; char **path, **paths; @@ -478,16 +393,26 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call factories_by_link = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); factories_by_setting = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); - /* Register internal factories first */ - for (iter = internal_types; iter; iter = iter->next) { - GType ftype = (GType) GPOINTER_TO_SIZE (iter->data); - - factory = (NMDeviceFactory *) g_object_new (ftype, NULL); - g_assert (factory); - _add_factory (factory, FALSE, "internal", callback, user_data); - } - - paths = read_device_factory_paths (); +#define _ADD_INTERNAL(get_type_fcn) \ + G_STMT_START { \ + GType get_type_fcn (void); \ + _load_internal_factory (get_type_fcn (), \ + callback, user_data); \ + } G_STMT_END + + _ADD_INTERNAL (nm_bond_device_factory_get_type); + _ADD_INTERNAL (nm_bridge_device_factory_get_type); + _ADD_INTERNAL (nm_ethernet_device_factory_get_type); + _ADD_INTERNAL (nm_infiniband_device_factory_get_type); + _ADD_INTERNAL (nm_ip_tunnel_device_factory_get_type); + _ADD_INTERNAL (nm_macsec_device_factory_get_type); + _ADD_INTERNAL (nm_macvlan_device_factory_get_type); + _ADD_INTERNAL (nm_tun_device_factory_get_type); + _ADD_INTERNAL (nm_veth_device_factory_get_type); + _ADD_INTERNAL (nm_vlan_device_factory_get_type); + _ADD_INTERNAL (nm_vxlan_device_factory_get_type); + + paths = nm_utils_read_plugin_paths (NMPLUGINDIR, PLUGIN_PREFIX); if (!paths) return; diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h index 4a62468c..ff105da7 100644 --- a/src/devices/nm-device-factory.h +++ b/src/devices/nm-device-factory.h @@ -30,37 +30,22 @@ * not meant to enable third-party plugins. */ -typedef struct _NMDeviceFactory NMDeviceFactory; +#define NM_TYPE_DEVICE_FACTORY (nm_device_factory_get_type ()) +#define NM_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactory)) +#define NM_DEVICE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_FACTORY, NMDeviceFactoryClass)) +#define NM_IS_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_FACTORY)) +#define NM_IS_DEVICE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_FACTORY)) +#define NM_DEVICE_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactoryClass)) -/** - * nm_device_factory_create: - * @error: an error if creation of the factory failed, or %NULL - * - * Creates a #GObject that implements the #NMDeviceFactory interface. This - * function must not emit any signals or perform any actions that would cause - * devices or components to be created immediately. Instead these should be - * deferred to the "start" interface method. - * - * Returns: the #GObject implementing #NMDeviceFactory or %NULL - */ -NMDeviceFactory *nm_device_factory_create (GError **error); - -/* Should match nm_device_factory_create() */ -typedef NMDeviceFactory * (*NMDeviceFactoryCreateFunc) (GError **error); - -/********************************************************************/ - -#define NM_TYPE_DEVICE_FACTORY (nm_device_factory_get_type ()) -#define NM_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactory)) -#define NM_IS_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_FACTORY)) -#define NM_DEVICE_FACTORY_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactoryInterface)) - -/* signals */ #define NM_DEVICE_FACTORY_COMPONENT_ADDED "component-added" #define NM_DEVICE_FACTORY_DEVICE_ADDED "device-added" typedef struct { - GTypeInterface g_iface; + GObject parent; +} NMDeviceFactory; + +typedef struct { + GObjectClass parent; /** * get_supported_types: @@ -75,7 +60,7 @@ typedef struct { */ void (*get_supported_types) (NMDeviceFactory *factory, const NMLinkType **out_link_types, - const char ***out_setting_types); + const char *const**out_setting_types); /** * start: @@ -164,13 +149,34 @@ typedef struct { * Returns: %TRUE if the component was claimed by a device, %FALSE if not */ gboolean (*component_added) (NMDeviceFactory *factory, GObject *component); -} NMDeviceFactoryInterface; + +} NMDeviceFactoryClass; GType nm_device_factory_get_type (void); +/*****************************************************************************/ + +/** + * nm_device_factory_create: + * @error: an error if creation of the factory failed, or %NULL + * + * Creates a #GObject that implements the #NMDeviceFactory interface. This + * function must not emit any signals or perform any actions that would cause + * devices or components to be created immediately. Instead these should be + * deferred to the "start" interface method. + * + * Returns: the #GObject implementing #NMDeviceFactory or %NULL + */ +NMDeviceFactory *nm_device_factory_create (GError **error); + +/* Should match nm_device_factory_create() */ +typedef NMDeviceFactory * (*NMDeviceFactoryCreateFunc) (GError **error); + +/*****************************************************************************/ + void nm_device_factory_get_supported_types (NMDeviceFactory *factory, const NMLinkType **out_link_types, - const char ***out_setting_types); + const char *const**out_setting_types); const char *nm_device_factory_get_connection_parent (NMDeviceFactory *factory, NMConnection *connection); @@ -180,7 +186,7 @@ char * nm_device_factory_get_connection_iface (NMDeviceFactory *factory, const char *parent_iface, GError **error); -void nm_device_factory_start (NMDeviceFactory *factory); +void nm_device_factory_start (NMDeviceFactory *factory); NMDevice * nm_device_factory_create_device (NMDeviceFactory *factory, const char *iface, @@ -194,25 +200,27 @@ gboolean nm_device_factory_emit_component_added (NMDeviceFactory *factory, GObject *component); #define NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(...) \ - { static const NMLinkType _df_links[] = { __VA_ARGS__, NM_LINK_TYPE_NONE }; *out_link_types = _df_links; } + { static NMLinkType const _link_types_declared[] = { __VA_ARGS__, NM_LINK_TYPE_NONE }; _link_types = _link_types_declared; } #define NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(...) \ - { static const char *_df_settings[] = { __VA_ARGS__, NULL }; *out_setting_types = _df_settings; } - -extern const NMLinkType _nm_device_factory_no_default_links[]; -extern const char *_nm_device_factory_no_default_settings[]; + { static const char *const _setting_types_declared[] = { __VA_ARGS__, NULL }; _setting_types = _setting_types_declared; } #define NM_DEVICE_FACTORY_DECLARE_TYPES(...) \ static void \ get_supported_types (NMDeviceFactory *factory, \ const NMLinkType **out_link_types, \ - const char ***out_setting_types) \ + const char *const**out_setting_types) \ { \ - *out_link_types = _nm_device_factory_no_default_links; \ - *out_setting_types = _nm_device_factory_no_default_settings; \ - \ + static NMLinkType const _link_types_null[1] = { NM_LINK_TYPE_NONE }; \ + static const char *const _setting_types_null[1] = { NULL }; \ + \ + const NMLinkType *_link_types = _link_types_null; \ + const char *const*_setting_types = _setting_types_null; \ + \ { __VA_ARGS__; } \ - } \ - \ + \ + NM_SET_OUT (out_link_types, _link_types); \ + NM_SET_OUT (out_setting_types, _setting_types); \ + } /************************************************************************** * INTERNAL DEVICE FACTORY FUNCTIONS - devices provided by plugins should @@ -220,48 +228,33 @@ extern const char *_nm_device_factory_no_default_settings[]; **************************************************************************/ #define NM_DEVICE_FACTORY_DEFINE_INTERNAL(upper, mixed, lower, st_code, dfi_code) \ - typedef GObject NM##mixed##Factory; \ - typedef GObjectClass NM##mixed##FactoryClass; \ + typedef struct { \ + NMDeviceFactory parent; \ + } NM##mixed##DeviceFactory; \ + typedef struct { \ + NMDeviceFactoryClass parent; \ + } NM##mixed##DeviceFactoryClass; \ \ - static GType nm_##lower##_factory_get_type (void); \ - static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); \ + GType nm_##lower##_device_factory_get_type (void); \ \ - G_DEFINE_TYPE_EXTENDED (NM##mixed##Factory, nm_##lower##_factory, G_TYPE_OBJECT, 0, \ - G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init) \ - _nm_device_factory_internal_register_type (g_define_type_id);) \ - \ - /* Use a module constructor to register the factory's GType at load \ - * time, which then calls _nm_device_factory_internal_register_type() \ - * to register the factory's GType with the Manager. \ - */ \ - static void __attribute__((constructor)) \ - register_device_factory_internal_##lower (void) \ - { \ - nm_g_type_init (); \ - g_type_ensure (NM_TYPE_##upper##_FACTORY); \ - } \ + G_DEFINE_TYPE (NM##mixed##DeviceFactory, nm_##lower##_device_factory, NM_TYPE_DEVICE_FACTORY) \ \ NM_DEVICE_FACTORY_DECLARE_TYPES(st_code) \ \ static void \ - device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) \ + nm_##lower##_device_factory_init (NM##mixed##DeviceFactory *self) \ { \ - factory_iface->get_supported_types = get_supported_types; \ - dfi_code \ } \ \ static void \ - nm_##lower##_factory_init (NM##mixed##Factory *self) \ - { \ - } \ - \ - static void \ - nm_##lower##_factory_class_init (NM##mixed##FactoryClass *lower##_class) \ + nm_##lower##_device_factory_class_init (NM##mixed##DeviceFactoryClass *klass) \ { \ + NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS (klass); \ + \ + factory_class->get_supported_types = get_supported_types; \ + dfi_code \ } -void _nm_device_factory_internal_register_type (GType factory_type); - /************************************************************************** * PRIVATE FACTORY FUNCTIONS - for factory consumers (eg, NMManager). **************************************************************************/ diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index d90840d2..2f51c69d 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -21,32 +21,44 @@ #include "nm-default.h" #include "nm-device-generic.h" + #include "nm-device-private.h" -#include "nm-enum-types.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-core-internal.h" -#include "nmdbus-device-generic.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Generic.h" -G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_GENERIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_TYPE_DESCRIPTION, +); typedef struct { char *type_description; } NMDeviceGenericPrivate; -enum { - PROP_0, - PROP_TYPE_DESCRIPTION, +struct _NMDeviceGeneric { + NMDevice parent; + NMDeviceGenericPrivate _priv; +}; - LAST_PROP +struct _NMDeviceGenericClass { + NMDeviceClass parent; }; +G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE) + +#define NM_DEVICE_GENERIC_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceGeneric, NM_IS_DEVICE_GENERIC) + +/*****************************************************************************/ + static NMDeviceCapabilities get_generic_capabilities (NMDevice *dev) { - if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (dev))) + int ifindex = nm_device_get_ifindex (dev); + + if (ifindex > 0 && nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, ifindex)) return NM_DEVICE_CAP_CARRIER_DETECT; else return NM_DEVICE_CAP_NONE; @@ -55,8 +67,8 @@ get_generic_capabilities (NMDevice *dev) static const char * get_type_description (NMDevice *device) { - if (NM_DEVICE_GENERIC_GET_PRIVATE (device)->type_description) - return NM_DEVICE_GENERIC_GET_PRIVATE (device)->type_description; + if (NM_DEVICE_GENERIC_GET_PRIVATE ((NMDeviceGeneric *) device)->type_description) + return NM_DEVICE_GENERIC_GET_PRIVATE ((NMDeviceGeneric *) device)->type_description; return NM_DEVICE_CLASS (nm_device_generic_parent_class)->get_type_description (device); } @@ -108,20 +120,44 @@ update_connection (NMDevice *device, NMConnection *connection) NULL); } -/**************************************************************/ +/*****************************************************************************/ -NMDevice * -nm_device_generic_new (const NMPlatformLink *plink) +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { - g_return_val_if_fail (plink != NULL, NULL); + NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); + NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GENERIC, - NM_DEVICE_IFACE, plink->name, - NM_DEVICE_TYPE_DESC, "Generic", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, - NULL); + switch (prop_id) { + case PROP_TYPE_DESCRIPTION: + g_value_set_string (value, priv->type_description); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); + NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_TYPE_DESCRIPTION: + priv->type_description = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + static void nm_device_generic_init (NMDeviceGeneric *self) { @@ -143,49 +179,28 @@ constructor (GType type, return object; } -static void -dispose (GObject *object) +NMDevice * +nm_device_generic_new (const NMPlatformLink *plink, gboolean nm_plugin_missing) { - NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); - NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); - - g_clear_pointer (&priv->type_description, g_free); + g_return_val_if_fail (plink != NULL, NULL); - G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object); + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GENERIC, + NM_DEVICE_IFACE, plink->name, + NM_DEVICE_TYPE_DESC, "Generic", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, + NM_DEVICE_NM_PLUGIN_MISSING, nm_plugin_missing, + NULL); } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +dispose (GObject *object) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); - switch (prop_id) { - case PROP_TYPE_DESCRIPTION: - g_value_set_string (value, priv->type_description); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); - NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); + g_clear_pointer (&priv->type_description, g_free); - switch (prop_id) { - case PROP_TYPE_DESCRIPTION: - priv->type_description = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object); } static void @@ -194,8 +209,6 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDeviceGenericPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_GENERIC_SETTING_NAME, NM_LINK_TYPE_ANY) object_class->constructor = constructor; @@ -209,13 +222,13 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) parent_class->check_connection_compatible = check_connection_compatible; parent_class->update_connection = update_connection; - /* properties */ - g_object_class_install_property - (object_class, PROP_TYPE_DESCRIPTION, - g_param_spec_string (NM_DEVICE_GENERIC_TYPE_DESCRIPTION, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_TYPE_DESCRIPTION] = + g_param_spec_string (NM_DEVICE_GENERIC_TYPE_DESCRIPTION, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_GENERIC_SKELETON, diff --git a/src/devices/nm-device-generic.h b/src/devices/nm-device-generic.h index 9a5ff091..42442180 100644 --- a/src/devices/nm-device-generic.h +++ b/src/devices/nm-device-generic.h @@ -32,17 +32,12 @@ #define NM_DEVICE_GENERIC_TYPE_DESCRIPTION "type-description" -typedef struct { - NMDevice parent; -} NMDeviceGeneric; - -typedef struct { - NMDeviceClass parent; - -} NMDeviceGenericClass; +typedef struct _NMDeviceGeneric NMDeviceGeneric; +typedef struct _NMDeviceGenericClass NMDeviceGenericClass; GType nm_device_generic_get_type (void); -NMDevice *nm_device_generic_new (const NMPlatformLink *plink); +NMDevice *nm_device_generic_new (const NMPlatformLink *plink, + gboolean nm_plugin_missing); #endif /* __NETWORKMANAGER_DEVICE_GENERIC_H__ */ diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index e2a67de4..60f1aefa 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -20,46 +20,55 @@ #include "nm-default.h" +#include "nm-device-infiniband.h" + #include -#include "nm-device-infiniband.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" -#include "nm-enum-types.h" -#include "nm-activation-request.h" +#include "nm-act-request.h" #include "nm-ip4-config.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-core-internal.h" -#include "nmdbus-device-infiniband.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Infiniband.h" -G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) +#define NM_DEVICE_INFINIBAND_IS_PARTITION "is-partition" -#define NM_DEVICE_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandPrivate)) +/*****************************************************************************/ -#define NM_DEVICE_INFINIBAND_IS_PARTITION "is-partition" +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_IS_PARTITION, +); typedef struct { gboolean is_partition; - int parent_ifindex, p_key; + int parent_ifindex; + int p_key; } NMDeviceInfinibandPrivate; -enum { - PROP_0, - PROP_IS_PARTITION, +struct _NMDeviceInfiniband { + NMDevice parent; + NMDeviceInfinibandPrivate _priv; +}; - LAST_PROP +struct _NMDeviceInfinibandClass { + NMDeviceClass parent; }; -/*************************************************************/ +G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) + +#define NM_DEVICE_INFINIBAND_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceInfiniband, NM_IS_DEVICE_INFINIBAND) + +/*****************************************************************************/ static NMDeviceCapabilities -get_generic_capabilities (NMDevice *dev) +get_generic_capabilities (NMDevice *device) { guint32 caps = NM_DEVICE_CAP_CARRIER_DETECT; - if (NM_DEVICE_INFINIBAND_GET_PRIVATE (dev)->is_partition) + if (NM_DEVICE_INFINIBAND_GET_PRIVATE ((NMDeviceInfiniband *) device)->is_partition) caps |= NM_DEVICE_CAP_IS_SOFTWARE; return caps; @@ -68,10 +77,11 @@ get_generic_capabilities (NMDevice *dev) static NMActStageReturn act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { + nm_auto_close int dirfd = -1; NMActStageReturn ret; NMSettingInfiniband *s_infiniband; + char ifname_verified[IFNAMSIZ]; const char *transport_mode; - char *mode_path; gboolean ok, no_firmware = FALSE; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); @@ -85,11 +95,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband); - mode_path = g_strdup_printf ("/sys/class/net/%s/mode", - NM_ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (dev))); - if (!g_file_test (mode_path, G_FILE_TEST_EXISTS)) { - g_free (mode_path); - + dirfd = nm_platform_sysctl_open_netdir (NM_PLATFORM_GET, nm_device_get_ifindex (dev), ifname_verified); + if (dirfd < 0) { if (!strcmp (transport_mode, "datagram")) return NM_ACT_STAGE_RETURN_SUCCESS; else { @@ -100,8 +107,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) /* With some drivers the interface must be down to set transport mode */ nm_device_take_down (dev, TRUE); - ok = nm_platform_sysctl_set (NM_PLATFORM_GET, mode_path, transport_mode); - g_free (mode_path); + ok = nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_verified, "mode"), transport_mode); nm_device_bring_up (dev, TRUE, &no_firmware); if (!ok) { @@ -112,22 +118,30 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_SUCCESS; } -static void -ip4_config_pre_commit (NMDevice *self, NMIP4Config *config) +static guint32 +get_configured_mtu (NMDevice *device, gboolean *out_is_user_config) { - NMConnection *connection; - NMSettingInfiniband *s_infiniband; + NMSettingInfiniband *setting; + gint64 mtu_default; guint32 mtu; - connection = nm_device_get_applied_connection (self); - g_assert (connection); - s_infiniband = nm_connection_get_setting_infiniband (connection); - g_assert (s_infiniband); + nm_assert (NM_IS_DEVICE (device)); + nm_assert (out_is_user_config); + + setting = NM_SETTING_INFINIBAND (nm_device_get_applied_setting (device, NM_TYPE_SETTING_INFINIBAND)); + if (!setting) + g_return_val_if_reached (0); - /* MTU override */ - mtu = nm_setting_infiniband_get_mtu (s_infiniband); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); + mtu = nm_setting_infiniband_get_mtu (setting); + if (mtu == 0) { + mtu_default = nm_device_get_configured_mtu_from_connection_default (device, "infiniband.mtu"); + if (mtu_default >= 0) { + *out_is_user_config = TRUE; + return (guint32) mtu_default; + } + } + *out_is_user_config = (mtu != 0); + return mtu ?: NM_DEVICE_DEFAULT_MTU_INFINIBAND; } static gboolean @@ -241,7 +255,7 @@ create_and_realize (NMDevice *device, const NMPlatformLink **out_plink, GError **error) { - NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device); + NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE ((NMDeviceInfiniband *) device); NMSettingInfiniband *s_infiniband; NMPlatformError plerr; @@ -294,11 +308,13 @@ create_and_realize (NMDevice *device, static gboolean unrealize (NMDevice *device, GError **error) { - NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device); + NMDeviceInfinibandPrivate *priv; NMPlatformError plerr; g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), FALSE); + priv = NM_DEVICE_INFINIBAND_GET_PRIVATE ((NMDeviceInfiniband *) device); + if (priv->p_key < 0) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, "Only InfiniBand partitions can be removed"); @@ -317,12 +333,7 @@ unrealize (NMDevice *device, GError **error) return TRUE; } -/*************************************************************/ - -static void -nm_device_infiniband_init (NMDeviceInfiniband * self) -{ -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, @@ -330,7 +341,7 @@ get_property (GObject *object, guint prop_id, { switch (prop_id) { case PROP_IS_PARTITION: - g_value_set_boolean (value, NM_DEVICE_INFINIBAND_GET_PRIVATE (object)->is_partition); + g_value_set_boolean (value, NM_DEVICE_INFINIBAND_GET_PRIVATE ((NMDeviceInfiniband *) object)->is_partition); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -340,11 +351,11 @@ get_property (GObject *object, guint prop_id, static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) + const GValue *value, GParamSpec *pspec) { switch (prop_id) { case PROP_IS_PARTITION: - NM_DEVICE_INFINIBAND_GET_PRIVATE (object)->is_partition = g_value_get_boolean (value); + NM_DEVICE_INFINIBAND_GET_PRIVATE ((NMDeviceInfiniband *) object)->is_partition = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -352,17 +363,21 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + +static void +nm_device_infiniband_init (NMDeviceInfiniband * self) +{ +} + static void nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceInfinibandPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_INFINIBAND_SETTING_NAME, NM_LINK_TYPE_INFINIBAND) - /* virtual methods */ object_class->get_property = get_property; object_class->set_property = set_property; @@ -374,25 +389,25 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) parent_class->update_connection = update_connection; parent_class->act_stage1_prepare = act_stage1_prepare; - parent_class->ip4_config_pre_commit = ip4_config_pre_commit; + parent_class->get_configured_mtu = get_configured_mtu; - /* properties */ - g_object_class_install_property - (object_class, PROP_IS_PARTITION, - g_param_spec_boolean (NM_DEVICE_INFINIBAND_IS_PARTITION, "", "", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_IS_PARTITION] = + g_param_spec_boolean (NM_DEVICE_INFINIBAND_IS_PARTITION, "", "", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_INFINIBAND_SKELETON, NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_INFINIBAND_FACTORY (nm_infiniband_factory_get_type ()) -#define NM_INFINIBAND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_INFINIBAND_FACTORY, NMInfinibandFactory)) +#define NM_TYPE_INFINIBAND_DEVICE_FACTORY (nm_infiniband_device_factory_get_type ()) +#define NM_INFINIBAND_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_INFINIBAND_DEVICE_FACTORY, NMInfinibandDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -461,8 +476,7 @@ get_connection_iface (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (INFINIBAND, Infiniband, infiniband, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_INFINIBAND) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_INFINIBAND_SETTING_NAME), - factory_iface->create_device = create_device; - factory_iface->get_connection_parent = get_connection_parent; - factory_iface->get_connection_iface = get_connection_iface; - ) - + factory_class->create_device = create_device; + factory_class->get_connection_parent = get_connection_parent; + factory_class->get_connection_iface = get_connection_iface; +); diff --git a/src/devices/nm-device-infiniband.h b/src/devices/nm-device-infiniband.h index a74d07a5..719c9cc9 100644 --- a/src/devices/nm-device-infiniband.h +++ b/src/devices/nm-device-infiniband.h @@ -23,15 +23,15 @@ #include "nm-device.h" -#define NM_TYPE_DEVICE_INFINIBAND (nm_device_infiniband_get_type ()) -#define NM_DEVICE_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfiniband)) -#define NM_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass)) -#define NM_IS_DEVICE_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_INFINIBAND)) -#define NM_IS_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_INFINIBAND)) -#define NM_DEVICE_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass)) +#define NM_TYPE_DEVICE_INFINIBAND (nm_device_infiniband_get_type ()) +#define NM_DEVICE_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfiniband)) +#define NM_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass)) +#define NM_IS_DEVICE_INFINIBAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_INFINIBAND)) +#define NM_IS_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_INFINIBAND)) +#define NM_DEVICE_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass)) -typedef NMDevice NMDeviceInfiniband; -typedef NMDeviceClass NMDeviceInfinibandClass; +typedef struct _NMDeviceInfiniband NMDeviceInfiniband; +typedef struct _NMDeviceInfinibandClass NMDeviceInfinibandClass; GType nm_device_infiniband_get_type (void); diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 72a13893..58544377 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -30,26 +30,35 @@ #include "nm-device-private.h" #include "nm-manager.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-core-internal.h" -#include "nm-settings.h" -#include "nm-activation-request.h" +#include "settings/nm-settings.h" +#include "nm-act-request.h" #include "nm-ip4-config.h" -#include "nmdbus-device-ip-tunnel.h" +#include "introspection/org.freedesktop.NetworkManager.Device.IPTunnel.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceIPTunnel); -G_DEFINE_TYPE (NMDeviceIPTunnel, nm_device_ip_tunnel, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_IP_TUNNEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_IP_TUNNEL, NMDeviceIPTunnelPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIPTunnel, + PROP_MODE, + PROP_LOCAL, + PROP_REMOTE, + PROP_TTL, + PROP_TOS, + PROP_PATH_MTU_DISCOVERY, + PROP_INPUT_KEY, + PROP_OUTPUT_KEY, + PROP_ENCAPSULATION_LIMIT, + PROP_FLOW_LABEL, +); typedef struct { NMIPTunnelMode mode; - NMDevice *parent; - int parent_ifindex; char *local; char *remote; guint8 ttl; @@ -62,24 +71,20 @@ typedef struct { guint32 flow_label; } NMDeviceIPTunnelPrivate; -enum { - PROP_0, - PROP_MODE, - PROP_PARENT, - PROP_LOCAL, - PROP_REMOTE, - PROP_TTL, - PROP_TOS, - PROP_PATH_MTU_DISCOVERY, - PROP_INPUT_KEY, - PROP_OUTPUT_KEY, - PROP_ENCAPSULATION_LIMIT, - PROP_FLOW_LABEL, +struct _NMDeviceIPTunnel { + NMDevice parent; + NMDeviceIPTunnelPrivate _priv; +}; - LAST_PROP +struct _NMDeviceIPTunnelClass { + NMDeviceClass parent; }; -/**************************************************************/ +G_DEFINE_TYPE (NMDeviceIPTunnel, nm_device_ip_tunnel, NM_TYPE_DEVICE) + +#define NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceIPTunnel, NM_IS_DEVICE_IP_TUNNEL) + +/*****************************************************************************/ static gboolean address_equal_pp (int family, const char *a, const char *b) @@ -118,9 +123,7 @@ update_properties_from_ifindex (NMDevice *device, int ifindex) { NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self); - GObject *object = G_OBJECT (device); - NMDevice *parent; - int parent_ifindex; + int parent_ifindex = 0; in_addr_t local4, remote4; struct in6_addr local6, remote6; guint8 ttl = 0, tos = 0, encap_limit = 0; @@ -130,26 +133,22 @@ update_properties_from_ifindex (NMDevice *device, int ifindex) if (ifindex <= 0) { clear: - if (priv->parent || priv->parent_ifindex) { - g_clear_object (&priv->parent); - priv->parent_ifindex = 0; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_PARENT); - } + nm_device_parent_set_ifindex (device, 0); if (priv->local) { g_clear_pointer (&priv->local, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_LOCAL); + _notify (self, PROP_LOCAL); } if (priv->remote) { g_clear_pointer (&priv->remote, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_REMOTE); + _notify (self, PROP_REMOTE); } if (priv->input_key) { g_clear_pointer (&priv->input_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_INPUT_KEY); + _notify (self, PROP_INPUT_KEY); } if (priv->output_key) { g_clear_pointer (&priv->output_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_OUTPUT_KEY); + _notify (self, PROP_OUTPUT_KEY); } goto out; @@ -176,13 +175,13 @@ clear: if (g_strcmp0 (priv->input_key, key)) { g_free (priv->input_key); priv->input_key = key; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_INPUT_KEY); + _notify (self, PROP_INPUT_KEY); } else g_free (key); } else { if (priv->input_key) { g_clear_pointer (&priv->input_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_INPUT_KEY); + _notify (self, PROP_INPUT_KEY); } } @@ -191,13 +190,13 @@ clear: if (g_strcmp0 (priv->output_key, key)) { g_free (priv->output_key); priv->output_key = key; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_OUTPUT_KEY); + _notify (self, PROP_OUTPUT_KEY); } else g_free (key); } else { if (priv->output_key) { g_clear_pointer (&priv->output_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_OUTPUT_KEY); + _notify (self, PROP_OUTPUT_KEY); } } } else if (priv->mode == NM_IP_TUNNEL_MODE_SIT) { @@ -250,42 +249,35 @@ clear: } else g_return_if_reached (); - if (priv->parent_ifindex != parent_ifindex) { - g_clear_object (&priv->parent); - priv->parent_ifindex = parent_ifindex; - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex); - if (parent) - priv->parent = g_object_ref (parent); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_PARENT); - } + nm_device_parent_set_ifindex (device, parent_ifindex); if (priv->addr_family == AF_INET) { if (!address_equal_pn (AF_INET, priv->local, &local4)) { g_clear_pointer (&priv->local, g_free); if (local4) priv->local = g_strdup (nm_utils_inet4_ntop (local4, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_LOCAL); + _notify (self, PROP_LOCAL); } if (!address_equal_pn (AF_INET, priv->remote, &remote4)) { g_clear_pointer (&priv->remote, g_free); if (remote4) priv->remote = g_strdup (nm_utils_inet4_ntop (remote4, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_REMOTE); + _notify (self, PROP_REMOTE); } } else { if (!address_equal_pn (AF_INET6, priv->local, &local6)) { g_clear_pointer (&priv->local, g_free); if (memcmp (&local6, &in6addr_any, sizeof (in6addr_any))) priv->local = g_strdup (nm_utils_inet6_ntop (&local6, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_LOCAL); + _notify (self, PROP_LOCAL); } if (!address_equal_pn (AF_INET6, priv->remote, &remote6)) { g_clear_pointer (&priv->remote, g_free); if (memcmp (&remote6, &in6addr_any, sizeof (in6addr_any))) priv->remote = g_strdup (nm_utils_inet6_ntop (&remote6, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_REMOTE); + _notify (self, PROP_REMOTE); } } @@ -293,27 +285,27 @@ out: if (priv->ttl != ttl) { priv->ttl = ttl; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_TTL); + _notify (self, PROP_TTL); } if (priv->tos != tos) { priv->tos = tos; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_TOS); + _notify (self, PROP_TOS); } if (priv->path_mtu_discovery != pmtud) { priv->path_mtu_discovery = pmtud; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_PATH_MTU_DISCOVERY); + _notify (self, PROP_PATH_MTU_DISCOVERY); } if (priv->encap_limit != encap_limit) { priv->encap_limit = encap_limit; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT); + _notify (self, PROP_ENCAPSULATION_LIMIT); } if (priv->flow_label != flow_label) { priv->flow_label = flow_label; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_FLOW_LABEL); + _notify (self, PROP_FLOW_LABEL); } } @@ -324,9 +316,10 @@ update_properties (NMDevice *device) } static void -link_changed (NMDevice *device, NMPlatformLink *info) +link_changed (NMDevice *device, + const NMPlatformLink *pllink) { - NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->link_changed (device, info); + NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->link_changed (device, pllink); update_properties (device); } @@ -375,8 +368,7 @@ update_connection (NMDevice *device, NMConnection *connection) if (nm_setting_ip_tunnel_get_mode (s_ip_tunnel) != priv->mode) g_object_set (G_OBJECT (s_ip_tunnel), NM_SETTING_IP_TUNNEL_MODE, priv->mode, NULL); - if (priv->parent_ifindex > 0) - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex); + parent = nm_device_parent_get_device (device); /* Update parent in the connection; default to parent's interface name */ if (parent) { @@ -505,7 +497,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) /* Check parent interface; could be an interface name or a UUID */ parent = nm_setting_ip_tunnel_get_parent (s_ip_tunnel); if (parent) { - if (!match_parent (priv->parent, parent)) + if (!match_parent (nm_device_parent_get_device (device), parent)) return FALSE; } @@ -550,12 +542,13 @@ platform_link_to_tunnel_mode (const NMPlatformLink *link) return NM_IP_TUNNEL_MODE_GRE; case NM_LINK_TYPE_IP6TNL: lnk = nm_platform_link_get_lnk_ip6tnl (NM_PLATFORM_GET, link->ifindex, NULL); - if (lnk->proto == IPPROTO_IPIP) - return NM_IP_TUNNEL_MODE_IPIP6; - else if (lnk->proto == IPPROTO_IPV6) - return NM_IP_TUNNEL_MODE_IP6IP6; - else - return NM_IP_TUNNEL_MODE_UNKNOWN; + if (lnk) { + if (lnk->proto == IPPROTO_IPIP) + return NM_IP_TUNNEL_MODE_IPIP6; + if (lnk->proto == IPPROTO_IPV6) + return NM_IP_TUNNEL_MODE_IP6IP6; + } + return NM_IP_TUNNEL_MODE_UNKNOWN; case NM_LINK_TYPE_IPIP: return NM_IP_TUNNEL_MODE_IPIP; case NM_LINK_TYPE_SIT: @@ -578,31 +571,18 @@ tunnel_mode_to_link_type (NMIPTunnelMode tunnel_mode) return NM_LINK_TYPE_IPIP; case NM_IP_TUNNEL_MODE_SIT: return NM_LINK_TYPE_SIT; - default: - g_return_val_if_reached (NM_LINK_TYPE_UNKNOWN); + case NM_IP_TUNNEL_MODE_VTI: + case NM_IP_TUNNEL_MODE_IP6GRE: + case NM_IP_TUNNEL_MODE_VTI6: + case NM_IP_TUNNEL_MODE_ISATAP: + return NM_LINK_TYPE_UNKNOWN; + case NM_IP_TUNNEL_MODE_UNKNOWN: + break; } + g_return_val_if_reached (NM_LINK_TYPE_UNKNOWN); } -/**************************************************************/ - -static void -nm_device_ip_tunnel_init (NMDeviceIPTunnel *self) -{ -} - -static void -constructed (GObject *object) -{ - NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (object); - - if ( priv->mode == NM_IP_TUNNEL_MODE_IPIP6 - || priv->mode == NM_IP_TUNNEL_MODE_IP6IP6) - priv->addr_family = AF_INET6; - else - priv->addr_family = AF_INET; - - G_OBJECT_CLASS (nm_device_ip_tunnel_parent_class)->constructed (object); -} +/*****************************************************************************/ static gboolean create_and_realize (NMDevice *device, @@ -764,30 +744,30 @@ create_and_realize (NMDevice *device, return TRUE; } -static void -realize_start_notify (NMDevice *device, const NMPlatformLink *plink) +static guint32 +get_configured_mtu (NMDevice *self, gboolean *out_is_user_config) { - NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->realize_start_notify (device, plink); - - update_properties (device); -} - -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingIPTunnel *s_ip_tunnel; + NMSettingIPTunnel *setting; + gint64 mtu_default; guint32 mtu; - connection = nm_device_get_applied_connection (device); - g_assert (connection); - s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection); - g_assert (s_ip_tunnel); + nm_assert (NM_IS_DEVICE (self)); + nm_assert (out_is_user_config); - /* MTU override */ - mtu = nm_setting_ip_tunnel_get_mtu (s_ip_tunnel); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); + setting = NM_SETTING_IP_TUNNEL (nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP_TUNNEL)); + if (!setting) + g_return_val_if_reached (0); + + mtu = nm_setting_ip_tunnel_get_mtu (setting); + if (mtu == 0) { + mtu_default = nm_device_get_configured_mtu_from_connection_default (self, "ip-tunnel.mtu"); + if (mtu_default >= 0) { + *out_is_user_config = TRUE; + return (guint32) mtu_default; + } + } + *out_is_user_config = (mtu != 0); + return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED; } static NMDeviceCapabilities @@ -804,21 +784,18 @@ unrealize_notify (NMDevice *device) update_properties_from_ifindex (device, 0); } +/*****************************************************************************/ + static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (object); - NMDevice *parent; + NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object); switch (prop_id) { case PROP_MODE: g_value_set_uint (value, priv->mode); break; - case PROP_PARENT: - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex); - nm_utils_g_value_set_object_path (value, parent); - break; case PROP_LOCAL: g_value_set_string (value, priv->local); break; @@ -854,9 +831,9 @@ get_property (GObject *object, guint prop_id, static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) + const GValue *value, GParamSpec *pspec) { - NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (object); + NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object); switch (prop_id) { case PROP_MODE: @@ -867,14 +844,33 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + +static void +nm_device_ip_tunnel_init (NMDeviceIPTunnel *self) +{ +} + +static void +constructed (GObject *object) +{ + NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object); + + if ( priv->mode == NM_IP_TUNNEL_MODE_IPIP6 + || priv->mode == NM_IP_TUNNEL_MODE_IP6IP6) + priv->addr_family = AF_INET6; + else + priv->addr_family = AF_INET; + + G_OBJECT_CLASS (nm_device_ip_tunnel_parent_class)->constructed (object); +} + static void nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDeviceIPTunnelPrivate)); - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; @@ -885,8 +881,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; - device_class->ip4_config_pre_commit = ip4_config_pre_commit; - device_class->realize_start_notify = realize_start_notify; + device_class->get_configured_mtu = get_configured_mtu; device_class->unrealize_notify = unrealize_notify; NM_DEVICE_CLASS_DECLARE_TYPES (klass, @@ -896,94 +891,78 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) NM_LINK_TYPE_IPIP, NM_LINK_TYPE_SIT); - /* properties */ - g_object_class_install_property - (object_class, PROP_MODE, - g_param_spec_uint (NM_DEVICE_IP_TUNNEL_MODE, "", "", - 0, G_MAXUINT, 0, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /* properties */ - g_object_class_install_property - (object_class, PROP_PARENT, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_PARENT, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_LOCAL, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_LOCAL, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_REMOTE, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_REMOTE, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TTL, - g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TTL, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TOS, - g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TOS, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_PATH_MTU_DISCOVERY, - g_param_spec_boolean (NM_DEVICE_IP_TUNNEL_PATH_MTU_DISCOVERY, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_INPUT_KEY, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_INPUT_KEY, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_OUTPUT_KEY, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_OUTPUT_KEY, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_ENCAPSULATION_LIMIT, - g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_FLOW_LABEL, - g_param_spec_uint (NM_DEVICE_IP_TUNNEL_FLOW_LABEL, "", "", - 0, (1 << 20) - 1, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_MODE] = + g_param_spec_uint (NM_DEVICE_IP_TUNNEL_MODE, "", "", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_LOCAL] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_LOCAL, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_REMOTE] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_REMOTE, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TTL] = + g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TTL, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TOS] = + g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TOS, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_PATH_MTU_DISCOVERY] = + g_param_spec_boolean (NM_DEVICE_IP_TUNNEL_PATH_MTU_DISCOVERY, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_INPUT_KEY] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_INPUT_KEY, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_OUTPUT_KEY] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_OUTPUT_KEY, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_ENCAPSULATION_LIMIT] = + g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_FLOW_LABEL] = + g_param_spec_uint (NM_DEVICE_IP_TUNNEL_FLOW_LABEL, "", "", + 0, (1 << 20) - 1, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_IPTUNNEL_SKELETON, NULL); } -/*************************************************************/ -#define NM_TYPE_IP_TUNNEL_FACTORY (nm_ip_tunnel_factory_get_type ()) -#define NM_IP_TUNNEL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP_TUNNEL_FACTORY, NMIPTunnelFactory)) +/*****************************************************************************/ + +#define NM_TYPE_IP_TUNNEL_DEVICE_FACTORY (nm_ip_tunnel_device_factory_get_type ()) +#define NM_IP_TUNNEL_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP_TUNNEL_DEVICE_FACTORY, NMIPTunnelDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -1005,7 +984,7 @@ create_device (NMDeviceFactory *factory, mode = platform_link_to_tunnel_mode (plink); } - if (mode == NM_IP_TUNNEL_MODE_UNKNOWN) + if (mode == NM_IP_TUNNEL_MODE_UNKNOWN || link_type == NM_LINK_TYPE_UNKNOWN) return NULL; return (NMDevice *) g_object_new (NM_TYPE_DEVICE_IP_TUNNEL, @@ -1054,7 +1033,7 @@ get_connection_iface (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (IP_TUNNEL, IPTunnel, ip_tunnel, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_GRE, NM_LINK_TYPE_SIT, NM_LINK_TYPE_IPIP) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_IP_TUNNEL_SETTING_NAME), - factory_iface->create_device = create_device; - factory_iface->get_connection_parent = get_connection_parent; - factory_iface->get_connection_iface = get_connection_iface; -) + factory_class->create_device = create_device; + factory_class->get_connection_parent = get_connection_parent; + factory_class->get_connection_iface = get_connection_iface; +); diff --git a/src/devices/nm-device-ip-tunnel.h b/src/devices/nm-device-ip-tunnel.h index 94cc7375..4bff6e33 100644 --- a/src/devices/nm-device-ip-tunnel.h +++ b/src/devices/nm-device-ip-tunnel.h @@ -32,7 +32,6 @@ #define NM_DEVICE_IP_TUNNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_IP_TUNNEL, NMDeviceIPTunnelClass)) #define NM_DEVICE_IP_TUNNEL_MODE "mode" -#define NM_DEVICE_IP_TUNNEL_PARENT "parent" #define NM_DEVICE_IP_TUNNEL_LOCAL "local" #define NM_DEVICE_IP_TUNNEL_REMOTE "remote" #define NM_DEVICE_IP_TUNNEL_TTL "ttl" @@ -43,13 +42,11 @@ #define NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT "encapsulation-limit" #define NM_DEVICE_IP_TUNNEL_FLOW_LABEL "flow-label" -typedef struct { - NMDevice parent; -} NMDeviceIPTunnel; +/* defined in the parent class, but exposed on D-Bus by the subclass. */ +#define NM_DEVICE_IP_TUNNEL_PARENT NM_DEVICE_PARENT -typedef struct { - NMDeviceClass parent; -} NMDeviceIPTunnelClass; +typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel; +typedef struct _NMDeviceIPTunnelClass NMDeviceIPTunnelClass; GType nm_device_ip_tunnel_get_type (void); diff --git a/src/devices/nm-device-logging.h b/src/devices/nm-device-logging.h index fac92eac..b7ec58fd 100644 --- a/src/devices/nm-device-logging.h +++ b/src/devices/nm-device-logging.h @@ -24,7 +24,7 @@ #include "nm-device.h" #define _LOG_DECLARE_SELF(t) \ -inline static NMDevice * \ +_nm_unused inline static NMDevice * \ _nm_device_log_self_to_device (t *self) \ { \ return (NMDevice *) self; \ diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c new file mode 100644 index 00000000..c511a0e7 --- /dev/null +++ b/src/devices/nm-device-macsec.c @@ -0,0 +1,1009 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2017 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-device-macsec.h" + +#include "nm-act-request.h" +#include "nm-device-private.h" +#include "platform/nm-platform.h" +#include "nm-device-factory.h" +#include "nm-manager.h" +#include "nm-setting-macsec.h" +#include "nm-core-internal.h" +#include "supplicant/nm-supplicant-manager.h" +#include "supplicant/nm-supplicant-interface.h" +#include "supplicant/nm-supplicant-config.h" + +#include "introspection/org.freedesktop.NetworkManager.Device.Macsec.h" + +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceMacsec); + +/*****************************************************************************/ + +typedef struct Supplicant { + NMSupplicantManager *mgr; + NMSupplicantInterface *iface; + + /* signal handler ids */ + gulong iface_error_id; + gulong iface_state_id; + + /* Timeouts and idles */ + guint con_timeout_id; +} Supplicant; + +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceMacsec, + PROP_SCI, + PROP_CIPHER_SUITE, + PROP_ICV_LENGTH, + PROP_WINDOW, + PROP_ENCODING_SA, + PROP_ENCRYPT, + PROP_PROTECT, + PROP_INCLUDE_SCI, + PROP_ES, + PROP_SCB, + PROP_REPLAY_PROTECT, + PROP_VALIDATION, +); + +typedef struct { + NMPlatformLnkMacsec props; + gulong parent_state_id; + Supplicant supplicant; + guint supplicant_timeout_id; + NMActRequestGetSecretsCallId macsec_secrets_id; +} NMDeviceMacsecPrivate; + +struct _NMDeviceMacsec { + NMDevice parent; + NMDeviceMacsecPrivate _priv; +}; + +struct _NMDeviceMacsecClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceMacsec, nm_device_macsec, NM_TYPE_DEVICE) + +#define NM_DEVICE_MACSEC_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceMacsec, NM_IS_DEVICE_MACSEC) + +/******************************************************************/ + +#define MACSEC_SECRETS_TRIES "macsec-secrets-tries" + +static void macsec_secrets_cancel (NMDeviceMacsec *self); + +/******************************************************************/ + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (validation_mode_to_string, guint8, + NM_UTILS_LOOKUP_DEFAULT_WARN (""), + NM_UTILS_LOOKUP_STR_ITEM (0, "disable"), + NM_UTILS_LOOKUP_STR_ITEM (1, "check"), + NM_UTILS_LOOKUP_STR_ITEM (2, "strict"), +); + +static void +parent_state_changed (NMDevice *parent, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason, + gpointer user_data) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (user_data); + + /* We'll react to our own carrier state notifications. Ignore the parent's. */ + if (reason == NM_DEVICE_STATE_REASON_CARRIER) + return; + + nm_device_set_unmanaged_by_flags (NM_DEVICE (self), NM_UNMANAGED_PARENT, !nm_device_get_managed (parent, FALSE), reason); +} + +static void +parent_changed_notify (NMDevice *device, + int old_ifindex, + NMDevice *old_parent, + int new_ifindex, + NMDevice *new_parent) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (device); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + + NM_DEVICE_CLASS (nm_device_macsec_parent_class)->parent_changed_notify (device, + old_ifindex, + old_parent, + new_ifindex, + new_parent); + + /* note that @self doesn't have to clear @parent_state_id on dispose, + * because NMDevice's dispose() will unset the parent, which in turn calls + * parent_changed_notify(). */ + nm_clear_g_signal_handler (old_parent, &priv->parent_state_id); + + if (new_parent) { + priv->parent_state_id = g_signal_connect (new_parent, + NM_DEVICE_STATE_CHANGED, + G_CALLBACK (parent_state_changed), + device); + + /* Set parent-dependent unmanaged flag */ + nm_device_set_unmanaged_by_flags (device, + NM_UNMANAGED_PARENT, + !nm_device_get_managed (new_parent, FALSE), + NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED); + } + + /* Recheck availability now that the parent has changed */ + if (new_ifindex > 0) { + nm_device_queue_recheck_available (device, + NM_DEVICE_STATE_REASON_PARENT_CHANGED, + NM_DEVICE_STATE_REASON_PARENT_CHANGED); + } +} + +static void +update_properties (NMDevice *device) +{ + NMDeviceMacsec *self; + NMDeviceMacsecPrivate *priv; + const NMPlatformLink *plink = NULL; + const NMPlatformLnkMacsec *props = NULL; + int ifindex; + + g_return_if_fail (NM_IS_DEVICE_MACSEC (device)); + self = NM_DEVICE_MACSEC (device); + priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + + ifindex = nm_device_get_ifindex (device); + g_return_if_fail (ifindex > 0); + props = nm_platform_link_get_lnk_macsec (NM_PLATFORM_GET, ifindex, &plink); + + if (!props) { + _LOGW (LOGD_PLATFORM, "could not get macsec properties"); + return; + } + + g_object_freeze_notify ((GObject *) device); + + if (priv->props.parent_ifindex != props->parent_ifindex) + nm_device_parent_set_ifindex (device, props->parent_ifindex); + +#define CHECK_PROPERTY_CHANGED(field, prop) \ + if (props->field != priv->props.field) \ + _notify (self, prop) + + CHECK_PROPERTY_CHANGED (sci, PROP_SCI); + CHECK_PROPERTY_CHANGED (cipher_suite, PROP_CIPHER_SUITE); + CHECK_PROPERTY_CHANGED (window, PROP_WINDOW); + CHECK_PROPERTY_CHANGED (icv_length, PROP_ICV_LENGTH); + CHECK_PROPERTY_CHANGED (encoding_sa, PROP_ENCODING_SA); + CHECK_PROPERTY_CHANGED (validation, PROP_VALIDATION); + CHECK_PROPERTY_CHANGED (encrypt, PROP_ENCRYPT); + CHECK_PROPERTY_CHANGED (protect, PROP_PROTECT); + CHECK_PROPERTY_CHANGED (include_sci, PROP_INCLUDE_SCI); + CHECK_PROPERTY_CHANGED (es, PROP_ES); + CHECK_PROPERTY_CHANGED (scb, PROP_SCB); + CHECK_PROPERTY_CHANGED (replay_protect, PROP_REPLAY_PROTECT); + + priv->props = *props; + g_object_thaw_notify ((GObject *) device); +} + +static NMSupplicantConfig * +build_supplicant_config (NMDeviceMacsec *self, GError **error) +{ + NMSupplicantConfig *config = NULL; + NMSettingMacsec *s_macsec; + NMSetting8021x *s_8021x; + NMConnection *connection; + const char *con_uuid; + guint32 mtu; + + connection = nm_device_get_applied_connection (NM_DEVICE (self)); + g_assert (connection); + con_uuid = nm_connection_get_uuid (connection); + mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, + nm_device_get_ifindex (NM_DEVICE (self))); + + config = nm_supplicant_config_new (); + + s_macsec = (NMSettingMacsec *) + nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_MACSEC); + + if (!nm_supplicant_config_add_setting_macsec (config, s_macsec, error)) { + g_prefix_error (error, "macsec-setting: "); + g_object_unref (config); + return NULL; + } + + if (nm_setting_macsec_get_mode (s_macsec) == NM_SETTING_MACSEC_MODE_EAP) { + s_8021x = nm_connection_get_setting_802_1x (connection); + if (!nm_supplicant_config_add_setting_8021x (config, s_8021x, con_uuid, mtu, TRUE, error)) { + g_prefix_error (error, "802-1x-setting: "); + g_clear_object (&config); + } + } + + return config; +} + +static void +supplicant_interface_clear_handlers (NMDeviceMacsec *self) +{ + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + + nm_clear_g_source (&priv->supplicant_timeout_id); + nm_clear_g_source (&priv->supplicant.con_timeout_id); + nm_clear_g_signal_handler (priv->supplicant.iface, &priv->supplicant.iface_error_id); +} + +static void +supplicant_interface_release (NMDeviceMacsec *self) +{ + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + + supplicant_interface_clear_handlers (self); + + nm_clear_g_signal_handler (priv->supplicant.iface, &priv->supplicant.iface_state_id); + + if (priv->supplicant.iface) { + nm_supplicant_interface_disconnect (priv->supplicant.iface); + g_clear_object (&priv->supplicant.iface); + } +} + +static void +supplicant_iface_connection_error_cb (NMSupplicantInterface *iface, + const char *name, + const char *message, + gpointer user_data) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (user_data); + + _LOGW (LOGD_DEVICE, + "Activation: association request to the supplicant failed: %s - %s", + name, message); + + supplicant_interface_release (self); + nm_device_queue_state (NM_DEVICE (self), + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED); +} + +static void +macsec_secrets_cb (NMActRequest *req, + NMActRequestGetSecretsCallId call_id, + NMSettingsConnection *connection, + GError *error, + gpointer user_data) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (user_data); + NMDevice *device = NM_DEVICE (self); + NMDeviceMacsecPrivate *priv; + + g_return_if_fail (NM_IS_DEVICE_MACSEC (self)); + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + + g_return_if_fail (priv->macsec_secrets_id == call_id); + + priv->macsec_secrets_id = NULL; + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + g_return_if_fail (req == nm_device_get_act_request (device)); + g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH); + g_return_if_fail (nm_act_request_get_settings_connection (req) == connection); + + if (error) { + _LOGW (LOGD_ETHER, "%s", error->message); + nm_device_state_changed (device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_NO_SECRETS); + } else + nm_device_activate_schedule_stage1_device_prepare (device); +} + +static void +macsec_secrets_cancel (NMDeviceMacsec *self) +{ + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + + if (priv->macsec_secrets_id) + nm_act_request_cancel_secrets (NULL, priv->macsec_secrets_id); + nm_assert (!priv->macsec_secrets_id); +} + +static void +macsec_secrets_get_secrets (NMDeviceMacsec *self, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags) +{ + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + NMActRequest *req; + + macsec_secrets_cancel (self); + + req = nm_device_get_act_request (NM_DEVICE (self)); + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + priv->macsec_secrets_id = nm_act_request_get_secrets (req, + TRUE, + setting_name, + flags, + NULL, + macsec_secrets_cb, + self); + g_return_if_fail (priv->macsec_secrets_id); +} + +static gboolean +link_timeout_cb (gpointer user_data) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (user_data); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + NMDevice *dev = NM_DEVICE (self); + NMActRequest *req; + NMConnection *applied_connection; + const char *setting_name; + + priv->supplicant_timeout_id = 0; + + req = nm_device_get_act_request (dev); + + if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED) { + nm_device_state_changed (dev, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT); + return FALSE; + } + + /* Disconnect event during initial authentication and credentials + * ARE checked - we are likely to have wrong key. Ask the user for + * another one. + */ + if (nm_device_get_state (dev) != NM_DEVICE_STATE_CONFIG) + goto time_out; + + nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (req)); + + applied_connection = nm_act_request_get_applied_connection (req); + setting_name = nm_connection_need_secrets (applied_connection, NULL); + if (!setting_name) + goto time_out; + + _LOGI (LOGD_DEVICE | LOGD_ETHER, + "Activation: disconnected during authentication, asking for new key."); + supplicant_interface_release (self); + + nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT); + macsec_secrets_get_secrets (self, setting_name, NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW); + + return FALSE; + +time_out: + _LOGW (LOGD_DEVICE | LOGD_ETHER, "link timed out."); + nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT); + + return FALSE; +} + +static void +supplicant_iface_state_cb (NMSupplicantInterface *iface, + guint32 new_state, + guint32 old_state, + int disconnect_reason, + gpointer user_data) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (user_data); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + NMDevice *device = NM_DEVICE (self); + NMSupplicantConfig *config; + gboolean success = FALSE; + NMDeviceState devstate; + GError *error = NULL; + + if (new_state == old_state) + return; + + _LOGI (LOGD_DEVICE, "supplicant interface state: %s -> %s", + nm_supplicant_interface_state_to_string (old_state), + nm_supplicant_interface_state_to_string (new_state)); + + devstate = nm_device_get_state (device); + + switch (new_state) { + case NM_SUPPLICANT_INTERFACE_STATE_READY: + config = build_supplicant_config (self, &error); + if (config) { + success = nm_supplicant_interface_set_config (priv->supplicant.iface, config, &error); + g_object_unref (config); + + if (!success) { + _LOGE (LOGD_DEVICE, + "Activation: couldn't send security configuration to the supplicant: %s", + error->message); + g_clear_error (&error); + } + } else { + _LOGE (LOGD_DEVICE, + "Activation: couldn't build security configuration: %s", + error->message); + g_clear_error (&error); + } + + if (!success) { + nm_device_state_changed (device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED); + } + break; + case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED: + supplicant_interface_clear_handlers (self); + nm_device_bring_up (device, TRUE, NULL); + + /* If this is the initial association during device activation, + * schedule the next activation stage. + */ + if (devstate == NM_DEVICE_STATE_CONFIG) { + _LOGI (LOGD_DEVICE, + "Activation: Stage 2 of 5 (Device Configure) successful."); + nm_device_activate_schedule_stage3_ip_config_start (device); + } + break; + case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED: + if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) { + /* Start the link timeout so we allow some time for reauthentication */ + if (!priv->supplicant_timeout_id) + priv->supplicant_timeout_id = g_timeout_add_seconds (15, link_timeout_cb, device); + } + break; + case NM_SUPPLICANT_INTERFACE_STATE_DOWN: + supplicant_interface_release (self); + + if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) { + nm_device_state_changed (device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); + } + break; + default: + ; + } +} + +static NMActStageReturn +handle_auth_or_fail (NMDeviceMacsec *self, + NMActRequest *req, + gboolean new_secrets) +{ + const char *setting_name; + guint32 tries; + NMConnection *applied_connection; + + applied_connection = nm_act_request_get_applied_connection (req); + + tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), MACSEC_SECRETS_TRIES)); + if (tries > 3) + return NM_ACT_STAGE_RETURN_FAILURE; + + nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); + + nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (req)); + + setting_name = nm_connection_need_secrets (applied_connection, NULL); + if (setting_name) { + macsec_secrets_get_secrets (self, setting_name, + NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION + | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); + g_object_set_data (G_OBJECT (applied_connection), MACSEC_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); + } else + _LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); + + return NM_ACT_STAGE_RETURN_POSTPONE; +} + +static gboolean +supplicant_connection_timeout_cb (gpointer user_data) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (user_data); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + NMDevice *device = NM_DEVICE (self); + NMActRequest *req; + NMSettingsConnection *connection; + guint64 timestamp = 0; + gboolean new_secrets = TRUE; + + priv->supplicant.con_timeout_id = 0; + + /* Authentication failed; either driver problems, the encryption key is + * wrong, the passwords or certificates were wrong or the Ethernet switch's + * port is not configured for 802.1x. */ + _LOGW (LOGD_DEVICE, + "Activation: (macsec) association took too long."); + + supplicant_interface_release (self); + req = nm_device_get_act_request (device); + g_assert (req); + + connection = nm_act_request_get_settings_connection (req); + g_assert (connection); + + /* Ask for new secrets only if we've never activated this connection + * before. If we've connected before, don't bother the user with dialogs, + * just retry or fail, and if we never connect the user can fix the + * password somewhere else. */ + if (nm_settings_connection_get_timestamp (connection, ×tamp)) + new_secrets = !timestamp; + + if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE) + _LOGW (LOGD_DEVICE, "Activation: (macsec) asking for new secrets"); + else + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); + + return FALSE; +} + +static gboolean +supplicant_interface_init (NMDeviceMacsec *self) +{ + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + NMDevice *parent; + + parent = nm_device_parent_get_device (NM_DEVICE (self)); + g_return_val_if_fail (parent, FALSE); + + supplicant_interface_release (self); + + priv->supplicant.iface = nm_supplicant_manager_create_interface (priv->supplicant.mgr, + nm_device_get_iface (parent), + NM_SUPPLICANT_DRIVER_MACSEC); + + if (!priv->supplicant.iface) { + _LOGE (LOGD_DEVICE, + "Couldn't initialize supplicant interface"); + return FALSE; + } + + /* Listen for its state signals */ + priv->supplicant.iface_state_id = g_signal_connect (priv->supplicant.iface, + NM_SUPPLICANT_INTERFACE_STATE, + G_CALLBACK (supplicant_iface_state_cb), + self); + + /* Hook up error signal handler to capture association errors */ + priv->supplicant.iface_error_id = g_signal_connect (priv->supplicant.iface, + NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR, + G_CALLBACK (supplicant_iface_connection_error_cb), + self); + + /* Set up a timeout on the connection attempt to fail it after 25 seconds */ + priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self); + + return TRUE; +} + +static NMActStageReturn +act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (device); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + NMConnection *connection; + NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; + const char *setting_name; + + connection = nm_device_get_applied_connection (NM_DEVICE (self)); + g_assert (connection); + + if (!priv->supplicant.mgr) + priv->supplicant.mgr = g_object_ref (nm_supplicant_manager_get ()); + + /* If we need secrets, get them */ + setting_name = nm_connection_need_secrets (connection, NULL); + if (setting_name) { + NMActRequest *req = nm_device_get_act_request (NM_DEVICE (self)); + + _LOGI (LOGD_DEVICE, + "Activation: connection '%s' has security, but secrets are required.", + nm_connection_get_id (connection)); + + ret = handle_auth_or_fail (self, req, FALSE); + if (ret != NM_ACT_STAGE_RETURN_POSTPONE) + *reason = NM_DEVICE_STATE_REASON_NO_SECRETS; + } else { + _LOGI (LOGD_DEVICE | LOGD_ETHER, + "Activation: connection '%s' requires no security. No secrets needed.", + nm_connection_get_id (connection)); + + if (supplicant_interface_init (self)) + ret = NM_ACT_STAGE_RETURN_POSTPONE; + else + *reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; + } + + return ret; +} + +static void +deactivate (NMDevice *device) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (device); + + supplicant_interface_release (self); +} + +static gboolean +check_connection_compatible (NMDevice *device, NMConnection *connection) +{ + NMSettingMacsec *s_macsec; + + if (!NM_DEVICE_CLASS (nm_device_macsec_parent_class)->check_connection_compatible (device, connection)) + return FALSE; + + s_macsec = nm_connection_get_setting_macsec (connection); + if (!s_macsec) + return FALSE; + + return TRUE; +} + +/******************************************************************/ + +static NMDeviceCapabilities +get_generic_capabilities (NMDevice *dev) +{ + /* We assume MACsec interfaces always support carrier detect */ + return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE; +} + +/******************************************************************/ + +static gboolean +is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) +{ + if (!nm_device_parent_get_device (device)) + return FALSE; + return NM_DEVICE_CLASS (nm_device_macsec_parent_class)->is_available (device, flags); +} + +static gboolean +create_and_realize (NMDevice *device, + NMConnection *connection, + NMDevice *parent, + const NMPlatformLink **out_plink, + GError **error) +{ + const char *iface = nm_device_get_iface (device); + NMPlatformError plerr; + NMSettingMacsec *s_macsec; + NMPlatformLnkMacsec lnk = { }; + int parent_ifindex; + const char *hw_addr; + union { + struct { + guint8 mac[6]; + guint16 port; + } s; + guint64 u; + } sci; + + s_macsec = nm_connection_get_setting_macsec (connection); + g_assert (s_macsec); + + if (!parent) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + "MACsec devices can not be created without a parent interface"); + return FALSE; + } + + lnk.encrypt = nm_setting_macsec_get_encrypt (s_macsec); + + hw_addr = nm_device_get_hw_address (parent); + if (!hw_addr) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + "can't read parent MAC"); + return FALSE; + } + + nm_utils_hwaddr_aton (hw_addr, sci.s.mac, ETH_ALEN); + sci.s.port = htons (nm_setting_macsec_get_port (s_macsec)); + lnk.sci = be64toh (sci.u); + lnk.validation = nm_setting_macsec_get_validation (s_macsec); + + parent_ifindex = nm_device_get_ifindex (parent); + g_warn_if_fail (parent_ifindex > 0); + + plerr = nm_platform_link_macsec_add (NM_PLATFORM_GET, iface, parent_ifindex, &lnk, out_plink); + if (plerr != NM_PLATFORM_ERROR_SUCCESS) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, + "Failed to create macsec interface '%s' for '%s': %s", + iface, + nm_connection_get_id (connection), + nm_platform_error_to_string (plerr)); + return FALSE; + } + + nm_device_parent_set_ifindex (device, parent_ifindex); + + return TRUE; +} + +static void +link_changed (NMDevice *device, + const NMPlatformLink *pllink) +{ + NM_DEVICE_CLASS (nm_device_macsec_parent_class)->link_changed (device, pllink); + update_properties (device); +} + +static void +clear_secrets_tries (NMDevice *device) +{ + NMActRequest *req; + NMConnection *connection; + + req = nm_device_get_act_request (device); + if (req) { + connection = nm_act_request_get_applied_connection (req); + /* Clear macsec secrets tries on success, failure, or when deactivating */ + g_object_set_data (G_OBJECT (connection), MACSEC_SECRETS_TRIES, NULL); + } +} + +static void +device_state_changed (NMDevice *device, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason) +{ + if (new_state > NM_DEVICE_STATE_ACTIVATED) + macsec_secrets_cancel (NM_DEVICE_MACSEC (device)); + + if ( new_state == NM_DEVICE_STATE_ACTIVATED + || new_state == NM_DEVICE_STATE_FAILED + || new_state == NM_DEVICE_STATE_DISCONNECTED) + clear_secrets_tries (device); +} + +/******************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (object); + NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_SCI: + g_value_set_uint64 (value, priv->props.sci); + break; + case PROP_CIPHER_SUITE: + g_value_set_uint64 (value, priv->props.cipher_suite); + break; + case PROP_ICV_LENGTH: + g_value_set_uchar (value, priv->props.icv_length); + break; + case PROP_WINDOW: + g_value_set_uint (value, priv->props.window); + break; + case PROP_ENCODING_SA: + g_value_set_uchar (value, priv->props.encoding_sa); + break; + case PROP_ENCRYPT: + g_value_set_boolean (value, priv->props.encrypt); + break; + case PROP_PROTECT: + g_value_set_boolean (value, priv->props.protect); + break; + case PROP_INCLUDE_SCI: + g_value_set_boolean (value, priv->props.include_sci); + break; + case PROP_ES: + g_value_set_boolean (value, priv->props.es); + break; + case PROP_SCB: + g_value_set_boolean (value, priv->props.scb); + break; + case PROP_REPLAY_PROTECT: + g_value_set_boolean (value, priv->props.replay_protect); + break; + case PROP_VALIDATION: + g_value_set_string (value, + validation_mode_to_string (priv->props.validation)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_device_macsec_init (NMDeviceMacsec * self) +{ +} + +static void +dispose (GObject *object) +{ + NMDeviceMacsec *self = NM_DEVICE_MACSEC (object); + + macsec_secrets_cancel (self); + supplicant_interface_release (self); + + G_OBJECT_CLASS (nm_device_macsec_parent_class)->dispose (object); +} + +static void +nm_device_macsec_class_init (NMDeviceMacsecClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); + + NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACSEC) + + object_class->get_property = get_property; + object_class->dispose = dispose; + + parent_class->act_stage2_config = act_stage2_config; + parent_class->check_connection_compatible = check_connection_compatible; + parent_class->create_and_realize = create_and_realize; + parent_class->deactivate = deactivate; + parent_class->get_generic_capabilities = get_generic_capabilities; + parent_class->link_changed = link_changed; + parent_class->is_available = is_available; + parent_class->parent_changed_notify = parent_changed_notify; + parent_class->state_changed = device_state_changed; + parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; + + parent_class->connection_type = NM_SETTING_MACSEC_SETTING_NAME; + + obj_properties[PROP_SCI] = + g_param_spec_uint64 (NM_DEVICE_MACSEC_SCI, "", "", + 0, G_MAXUINT64, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_CIPHER_SUITE] = + g_param_spec_uint64 (NM_DEVICE_MACSEC_CIPHER_SUITE, "", "", + 0, G_MAXUINT64, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_ICV_LENGTH] = + g_param_spec_uchar (NM_DEVICE_MACSEC_ICV_LENGTH, "", "", + 0, G_MAXUINT8, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_WINDOW] = + g_param_spec_uint (NM_DEVICE_MACSEC_WINDOW, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_ENCODING_SA] = + g_param_spec_uchar (NM_DEVICE_MACSEC_ENCODING_SA, "", "", + 0, 3, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_VALIDATION] = + g_param_spec_string (NM_DEVICE_MACSEC_VALIDATION, "", "", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_ENCRYPT] = + g_param_spec_boolean (NM_DEVICE_MACSEC_ENCRYPT, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_PROTECT] = + g_param_spec_boolean (NM_DEVICE_MACSEC_PROTECT, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_INCLUDE_SCI] = + g_param_spec_boolean (NM_DEVICE_MACSEC_INCLUDE_SCI, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_ES] = + g_param_spec_boolean (NM_DEVICE_MACSEC_ES, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_SCB] = + g_param_spec_boolean (NM_DEVICE_MACSEC_SCB, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_REPLAY_PROTECT] = + g_param_spec_boolean (NM_DEVICE_MACSEC_REPLAY_PROTECT, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), + NMDBUS_TYPE_DEVICE_MACSEC_SKELETON, + NULL); +} + +/*************************************************************/ + +#define NM_TYPE_MACSEC_DEVICE_FACTORY (nm_macsec_device_factory_get_type ()) +#define NM_MACSEC_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MACSEC_DEVICE_FACTORY, NMMacsecDeviceFactory)) + +static NMDevice * +create_device (NMDeviceFactory *factory, + const char *iface, + const NMPlatformLink *plink, + NMConnection *connection, + gboolean *out_ignore) +{ + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACSEC, + NM_DEVICE_IFACE, iface, + NM_DEVICE_TYPE_DESC, "Macsec", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_MACSEC, + NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_MACSEC, + NULL); +} + +static const char * +get_connection_parent (NMDeviceFactory *factory, NMConnection *connection) +{ + NMSettingMacsec *s_macsec; + NMSettingWired *s_wired; + const char *parent = NULL; + + g_return_val_if_fail (nm_connection_is_type (connection, NM_SETTING_MACSEC_SETTING_NAME), NULL); + + s_macsec = nm_connection_get_setting_macsec (connection); + g_assert (s_macsec); + + parent = nm_setting_macsec_get_parent (s_macsec); + if (parent) + return parent; + + /* Try the hardware address from the MACsec connection's hardware setting */ + s_wired = nm_connection_get_setting_wired (connection); + if (s_wired) + return nm_setting_wired_get_mac_address (s_wired); + + return NULL; +} + +static char * +get_connection_iface (NMDeviceFactory *factory, + NMConnection *connection, + const char *parent_iface) +{ + NMSettingMacsec *s_macsec; + const char *ifname; + + g_return_val_if_fail (nm_connection_is_type (connection, NM_SETTING_MACSEC_SETTING_NAME), NULL); + + s_macsec = nm_connection_get_setting_macsec (connection); + g_assert (s_macsec); + + if (!parent_iface) + return NULL; + + ifname = nm_connection_get_interface_name (connection); + return g_strdup (ifname); +} + +NM_DEVICE_FACTORY_DEFINE_INTERNAL (MACSEC, Macsec, macsec, + NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_MACSEC) + NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_MACSEC_SETTING_NAME), + factory_class->create_device = create_device; + factory_class->get_connection_parent = get_connection_parent; + factory_class->get_connection_iface = get_connection_iface; +) diff --git a/src/devices/nm-device-macsec.h b/src/devices/nm-device-macsec.h new file mode 100644 index 00000000..17b33bf5 --- /dev/null +++ b/src/devices/nm-device-macsec.h @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2017 Red Hat, Inc. + */ + +#ifndef __NM_DEVICE_MACSEC_H__ +#define __NM_DEVICE_MACSEC_H__ + +#include "nm-device.h" + +#define NM_TYPE_DEVICE_MACSEC (nm_device_macsec_get_type ()) +#define NM_DEVICE_MACSEC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_MACSEC, NMDeviceMacsec)) +#define NM_DEVICE_MACSEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_MACSEC, NMDeviceMacsecClass)) +#define NM_IS_DEVICE_MACSEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_MACSEC)) +#define NM_IS_DEVICE_MACSEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_MACSEC)) +#define NM_DEVICE_MACSEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MACSEC, NMDeviceMacsecClass)) + +#define NM_DEVICE_MACSEC_SCI "sci" +#define NM_DEVICE_MACSEC_CIPHER_SUITE "cipher-suite" +#define NM_DEVICE_MACSEC_ICV_LENGTH "icv-length" +#define NM_DEVICE_MACSEC_WINDOW "window" +#define NM_DEVICE_MACSEC_ENCODING_SA "encoding-sa" +#define NM_DEVICE_MACSEC_VALIDATION "validation" +#define NM_DEVICE_MACSEC_ENCRYPT "encrypt" +#define NM_DEVICE_MACSEC_PROTECT "protect" +#define NM_DEVICE_MACSEC_INCLUDE_SCI "include-sci" +#define NM_DEVICE_MACSEC_ES "es" +#define NM_DEVICE_MACSEC_SCB "scb" +#define NM_DEVICE_MACSEC_REPLAY_PROTECT "replay-protect" + +/* defined in the parent class, but exposed on D-Bus by the subclass. */ +#define NM_DEVICE_MACSEC_PARENT NM_DEVICE_PARENT + +typedef struct _NMDeviceMacsec NMDeviceMacsec; +typedef struct _NMDeviceMacsecClass NMDeviceMacsecClass; + +GType nm_device_macsec_get_type (void); + +#endif /* __NM_DEVICE_MACSEC_H__ */ diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index c53abb68..94206716 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -25,10 +25,10 @@ #include #include "nm-device-private.h" -#include "nm-settings.h" -#include "nm-activation-request.h" +#include "settings/nm-settings.h" +#include "nm-act-request.h" #include "nm-manager.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-macvlan.h" #include "nm-setting-wired.h" @@ -36,32 +36,39 @@ #include "nm-ip4-config.h" #include "nm-utils.h" -#include "nmdbus-device-macvlan.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Macvlan.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceMacvlan); -G_DEFINE_TYPE (NMDeviceMacvlan, nm_device_macvlan, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_MACVLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlanPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceMacvlan, + PROP_MODE, + PROP_NO_PROMISC, + PROP_TAP, +); typedef struct { - int parent_ifindex; gulong parent_state_id; - NMDevice *parent; NMPlatformLnkMacvlan props; } NMDeviceMacvlanPrivate; -enum { - PROP_0, - PROP_PARENT, - PROP_MODE, - PROP_NO_PROMISC, - PROP_TAP, +struct _NMDeviceMacvlan { + NMDevice parent; + NMDeviceMacvlanPrivate _priv; +}; - LAST_PROP +struct _NMDeviceMacvlanClass { + NMDeviceClass parent; }; +G_DEFINE_TYPE (NMDeviceMacvlan, nm_device_macvlan, NM_TYPE_DEVICE) + +#define NM_DEVICE_MACVLAN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceMacvlan, NM_IS_DEVICE_MACVLAN) + +/*****************************************************************************/ + static int modes[][2] = { { NM_SETTING_MACVLAN_MODE_VEPA, MACVLAN_MODE_VEPA }, { NM_SETTING_MACVLAN_MODE_BRIDGE, MACVLAN_MODE_BRIDGE }, @@ -112,7 +119,7 @@ platform_mode_to_string (guint mode) } } -/**************************************************************/ +/*****************************************************************************/ static void parent_state_changed (NMDevice *parent, @@ -131,48 +138,51 @@ parent_state_changed (NMDevice *parent, } static void -nm_device_macvlan_set_parent (NMDeviceMacvlan *self, NMDevice *parent) - { +parent_changed_notify (NMDevice *device, + int old_ifindex, + NMDevice *old_parent, + int new_ifindex, + NMDevice *new_parent) +{ + NMDeviceMacvlan *self = NM_DEVICE_MACVLAN (device); NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self); - NMDevice *device = NM_DEVICE (self); - if (parent == priv->parent) - return; - - nm_clear_g_signal_handler (priv->parent, &priv->parent_state_id); + NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->parent_changed_notify (device, old_ifindex, old_parent, new_ifindex, new_parent); - g_clear_object (&priv->parent); + /* note that @self doesn't have to clear @parent_state_id on dispose, + * because NMDevice's dispose() will unset the parent, which in turn calls + * parent_changed_notify(). */ + nm_clear_g_signal_handler (old_parent, &priv->parent_state_id); - if (parent) { - priv->parent = g_object_ref (parent); - priv->parent_state_id = g_signal_connect (priv->parent, - "state-changed", + if (new_parent) { + priv->parent_state_id = g_signal_connect (new_parent, + NM_DEVICE_STATE_CHANGED, G_CALLBACK (parent_state_changed), device); /* Set parent-dependent unmanaged flag */ nm_device_set_unmanaged_by_flags (device, NM_UNMANAGED_PARENT, - !nm_device_get_managed (parent, FALSE), + !nm_device_get_managed (new_parent, FALSE), NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED); } - /* Recheck availability now that the parent has changed */ - nm_device_queue_recheck_available (self, - NM_DEVICE_STATE_REASON_PARENT_CHANGED, - NM_DEVICE_STATE_REASON_PARENT_CHANGED); - g_object_notify (G_OBJECT (device), NM_DEVICE_MACVLAN_PARENT); + if (new_ifindex > 0) { + /* Recheck availability now that the parent has changed */ + nm_device_queue_recheck_available (device, + NM_DEVICE_STATE_REASON_PARENT_CHANGED, + NM_DEVICE_STATE_REASON_PARENT_CHANGED); + } } static void update_properties (NMDevice *device) { NMDeviceMacvlan *self = NM_DEVICE_MACVLAN (device); - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); + NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self); GObject *object = G_OBJECT (device); const NMPlatformLnkMacvlan *props; const NMPlatformLink *plink; - NMDevice *parent = NULL; if (priv->props.tap) props = nm_platform_link_get_lnk_macvtap (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink); @@ -186,25 +196,22 @@ update_properties (NMDevice *device) g_object_freeze_notify (object); - if (priv->parent_ifindex != plink->parent) { - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent); - nm_device_macvlan_set_parent (self, parent); - } + nm_device_parent_set_ifindex (device, plink->parent); if (priv->props.mode != props->mode) - g_object_notify (object, NM_DEVICE_MACVLAN_MODE); + _notify (self, PROP_MODE); if (priv->props.no_promisc != props->no_promisc) - g_object_notify (object, NM_DEVICE_MACVLAN_NO_PROMISC); + _notify (self, PROP_NO_PROMISC); - priv->parent_ifindex = plink->parent; priv->props = *props; g_object_thaw_notify (object); } static void -link_changed (NMDevice *device, NMPlatformLink *info) +link_changed (NMDevice *device, + const NMPlatformLink *pllink) { - NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, info); + NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, pllink); update_properties (device); } @@ -222,17 +229,17 @@ create_and_realize (NMDevice *device, int parent_ifindex; s_macvlan = nm_connection_get_setting_macvlan (connection); - g_assert (s_macvlan); + g_return_val_if_fail (s_macvlan, FALSE); + + parent_ifindex = parent ? nm_device_get_ifindex (parent) : 0; - if (!parent) { + if (parent_ifindex <= 0) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, "MACVLAN devices can not be created without a parent interface"); + g_return_val_if_fail (!parent, FALSE); return FALSE; } - parent_ifindex = nm_device_get_ifindex (parent); - g_warn_if_fail (parent_ifindex > 0); - lnk.mode = setting_mode_to_platform (nm_setting_macvlan_get_mode (s_macvlan)); if (!lnk.mode) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, @@ -258,7 +265,7 @@ create_and_realize (NMDevice *device, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static NMDeviceCapabilities get_generic_capabilities (NMDevice *dev) @@ -267,64 +274,28 @@ get_generic_capabilities (NMDevice *dev) return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE; } -static gboolean -bring_up (NMDevice *dev, gboolean *no_firmware) -{ - gboolean success = FALSE; - guint i = 20; - - while (i-- > 0 && !success) { - success = NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->bring_up (dev, no_firmware); - g_usleep (50); - } - - return success; -} - -/******************************************************************/ +/*****************************************************************************/ static gboolean is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { - if (!NM_DEVICE_MACVLAN_GET_PRIVATE (device)->parent) + if (!nm_device_parent_get_device (device)) return FALSE; - return NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->is_available (device, flags); } -static void -notify_new_device_added (NMDevice *device, NMDevice *new_device) -{ - NMDeviceMacvlan *self = NM_DEVICE_MACVLAN (device); - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self); - - if (priv->parent) - return; - - if (!nm_device_is_real (device)) - return; - - update_properties (device); - - if ( priv->parent_ifindex <= 0 - || nm_device_get_ifindex (new_device) != priv->parent_ifindex) - return; - - priv->parent_ifindex = nm_device_get_ifindex (new_device); - nm_device_macvlan_set_parent (self, new_device); -} - -/**************************************************************/ +/*****************************************************************************/ static gboolean match_parent (NMDeviceMacvlan *self, const char *parent) { - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self); + NMDevice *parent_device; g_return_val_if_fail (parent != NULL, FALSE); - if (!priv->parent) + parent_device = nm_device_parent_get_device (NM_DEVICE (self)); + if (!parent_device) return FALSE; if (nm_utils_is_uuid (parent)) { @@ -335,7 +306,7 @@ match_parent (NMDeviceMacvlan *self, const char *parent) * device has that connection activated. */ - parent_req = nm_device_get_act_request (priv->parent); + parent_req = nm_device_get_act_request (parent_device); if (!parent_req) return FALSE; @@ -347,7 +318,7 @@ match_parent (NMDeviceMacvlan *self, const char *parent) return FALSE; } else { /* interface name */ - if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0) + if (g_strcmp0 (parent, nm_device_get_ip_iface (parent_device)) != 0) return FALSE; } @@ -357,8 +328,8 @@ match_parent (NMDeviceMacvlan *self, const char *parent) static gboolean match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr) { - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); NMSettingWired *s_wired; + NMDevice *parent_device; const char *setting_mac; const char *parent_mac; @@ -370,17 +341,18 @@ match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hw if (!setting_mac) return !fail_if_no_hwaddr; - if (!priv->parent) + parent_device = nm_device_parent_get_device (device); + if (!parent_device) return !fail_if_no_hwaddr; - parent_mac = nm_device_get_permanent_hw_address (priv->parent); + parent_mac = nm_device_get_permanent_hw_address (parent_device); return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1); } static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); + NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) device); NMSettingMacvlan *s_macvlan; const char *parent = NULL; @@ -459,8 +431,9 @@ complete_connection (NMDevice *device, static void update_connection (NMDevice *device, NMConnection *connection) { - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); + NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) device); NMSettingMacvlan *s_macvlan = nm_connection_get_setting_macvlan (connection); + NMDevice *parent_device; const char *setting_parent, *new_parent; int new_mode; @@ -481,15 +454,16 @@ update_connection (NMDevice *device, NMConnection *connection) g_object_set (s_macvlan, NM_SETTING_MACVLAN_TAP, !!priv->props.tap, NULL); /* Update parent in the connection; default to parent's interface name */ - if (priv->parent) { - new_parent = nm_device_get_iface (priv->parent); + parent_device = nm_device_parent_get_device (device); + if (parent_device) { + new_parent = nm_device_get_iface (parent_device); setting_parent = nm_setting_macvlan_get_parent (s_macvlan); if (setting_parent && nm_utils_is_uuid (setting_parent)) { NMConnection *parent_connection; /* Don't change a parent specified by UUID if it's still valid */ parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent); - if (parent_connection && nm_device_check_connection_compatible (priv->parent, parent_connection)) + if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection)) new_parent = NULL; } if (new_parent) @@ -515,54 +489,15 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_SUCCESS; } -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - - connection = nm_device_get_applied_connection (device); - g_assert (connection); - - s_wired = nm_connection_get_setting_wired (connection); - if (s_wired) { - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); - } -} - -static void -realize_start_notify (NMDevice *device, const NMPlatformLink *plink) -{ - NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->realize_start_notify (device, plink); - - update_properties (device); -} - -/******************************************************************/ - -static void -nm_device_macvlan_init (NMDeviceMacvlan *self) -{ -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (object); - NMDevice *parent; + NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) object); switch (prop_id) { - case PROP_PARENT: - if (priv->parent_ifindex > 0) - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex); - else - parent = NULL; - nm_utils_g_value_set_object_path (value, parent); - break; case PROP_MODE: g_value_set_string (value, platform_mode_to_string (priv->props.mode)); break; @@ -580,9 +515,9 @@ get_property (GObject *object, guint prop_id, static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) + const GValue *value, GParamSpec *pspec) { - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (object); + NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) object); switch (prop_id) { case PROP_TAP: @@ -593,12 +528,11 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + static void -dispose (GObject *object) +nm_device_macvlan_init (NMDeviceMacvlan *self) { - nm_device_macvlan_set_parent (NM_DEVICE_MACVLAN (object), NULL); - - G_OBJECT_CLASS (nm_device_macvlan_parent_class)->dispose (object); } static void @@ -607,67 +541,53 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDeviceMacvlanPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP) - object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; device_class->act_stage1_prepare = act_stage1_prepare; - device_class->bring_up = bring_up; device_class->check_connection_compatible = check_connection_compatible; device_class->complete_connection = complete_connection; device_class->connection_type = NM_SETTING_MACVLAN_SETTING_NAME; device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; - device_class->ip4_config_pre_commit = ip4_config_pre_commit; + device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; device_class->is_available = is_available; device_class->link_changed = link_changed; - device_class->notify_new_device_added = notify_new_device_added; - device_class->realize_start_notify = realize_start_notify; + device_class->parent_changed_notify = parent_changed_notify; device_class->update_connection = update_connection; - /* properties */ - g_object_class_install_property - (object_class, PROP_PARENT, - 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, - g_param_spec_string (NM_DEVICE_MACVLAN_MODE, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_NO_PROMISC, - g_param_spec_boolean (NM_DEVICE_MACVLAN_NO_PROMISC, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TAP, - g_param_spec_boolean (NM_DEVICE_MACVLAN_TAP, "", "", - FALSE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_MODE] = + g_param_spec_string (NM_DEVICE_MACVLAN_MODE, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_NO_PROMISC] = + g_param_spec_boolean (NM_DEVICE_MACVLAN_NO_PROMISC, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TAP] = + g_param_spec_boolean (NM_DEVICE_MACVLAN_TAP, "", "", + FALSE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_MACVLAN_SKELETON, NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_MACVLAN_FACTORY (nm_macvlan_factory_get_type ()) -#define NM_MACVLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MACVLAN_FACTORY, NMMacvlanFactory)) +#define NM_TYPE_MACVLAN_DEVICE_FACTORY (nm_macvlan_device_factory_get_type ()) +#define NM_MACVLAN_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MACVLAN_DEVICE_FACTORY, NMMacvlanDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -747,8 +667,7 @@ get_connection_iface (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (MACVLAN, Macvlan, macvlan, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_MACVLAN_SETTING_NAME), - factory_iface->create_device = create_device; - factory_iface->get_connection_parent = get_connection_parent; - factory_iface->get_connection_iface = get_connection_iface; - ) - + factory_class->create_device = create_device; + factory_class->get_connection_parent = get_connection_parent; + factory_class->get_connection_iface = get_connection_iface; +); diff --git a/src/devices/nm-device-macvlan.h b/src/devices/nm-device-macvlan.h index 5756f696..e6d3a333 100644 --- a/src/devices/nm-device-macvlan.h +++ b/src/devices/nm-device-macvlan.h @@ -30,13 +30,15 @@ #define NM_IS_DEVICE_MACVLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_MACVLAN)) #define NM_DEVICE_MACVLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlanClass)) -#define NM_DEVICE_MACVLAN_PARENT "parent" #define NM_DEVICE_MACVLAN_MODE "mode" #define NM_DEVICE_MACVLAN_NO_PROMISC "no-promisc" #define NM_DEVICE_MACVLAN_TAP "tap" -typedef NMDevice NMDeviceMacvlan; -typedef NMDeviceClass NMDeviceMacvlanClass; +/* defined in the parent class, but exposed on D-Bus by the subclass. */ +#define NM_DEVICE_MACVLAN_PARENT NM_DEVICE_PARENT + +typedef struct _NMDeviceMacvlan NMDeviceMacvlan; +typedef struct _NMDeviceMacvlanClass NMDeviceMacvlanClass; GType nm_device_macvlan_get_type (void); diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index c85cb969..c6d2a931 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -27,12 +27,15 @@ /* This file should only be used by subclasses of NMDevice */ enum NMActStageReturn { - NM_ACT_STAGE_RETURN_FAILURE = 0, + NM_ACT_STAGE_RETURN_FAILURE = 0, /* Hard failure of activation */ NM_ACT_STAGE_RETURN_SUCCESS, /* Activation stage done */ NM_ACT_STAGE_RETURN_POSTPONE, /* Long-running operation in progress */ - NM_ACT_STAGE_RETURN_WAIT, /* Not ready to start stage; wait */ - NM_ACT_STAGE_RETURN_STOP, /* Activation not wanted */ - NM_ACT_STAGE_RETURN_FINISH /* Activation stage done; nothing to do */ + NM_ACT_STAGE_RETURN_IP_WAIT, /* IP config stage is waiting (state IP_WAIT) */ + NM_ACT_STAGE_RETURN_IP_DONE, /* IP config stage is done (state IP_DONE), + For the ip-config stage, this is similar to + NM_ACT_STAGE_RETURN_SUCCESS, except that no + IP config should be commited. */ + NM_ACT_STAGE_RETURN_IP_FAIL, /* IP config stage failed (state IP_FAIL), activation may proceed */ }; #define NM_DEVICE_CAP_NONSTANDARD_CARRIER 0x80000000 @@ -42,7 +45,7 @@ enum NMActStageReturn { NMSettings *nm_device_get_settings (NMDevice *self); -void nm_device_set_ip_iface (NMDevice *self, const char *iface); +gboolean nm_device_set_ip_iface (NMDevice *self, const char *iface); void nm_device_activate_schedule_stage3_ip_config_start (NMDevice *device); @@ -54,7 +57,10 @@ gboolean nm_device_bring_up (NMDevice *self, gboolean wait, gboolean *no_firmwar void nm_device_take_down (NMDevice *self, gboolean block); -gboolean nm_device_hw_addr_set (NMDevice *device, const char *addr, const char *detail); +gboolean nm_device_hw_addr_set (NMDevice *device, + const char *addr, + const char *detail, + gboolean set_permanent); gboolean nm_device_hw_addr_set_cloned (NMDevice *device, NMConnection *connection, gboolean is_wifi); gboolean nm_device_hw_addr_reset (NMDevice *device, const char *detail); @@ -112,6 +118,19 @@ void nm_device_ip_method_failed (NMDevice *self, int family, NMDeviceStateReason gboolean nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value); +/*****************************************************************************/ + +#define NM_DEVICE_DEFAULT_MTU_WIRED ((guint32) 1500) +#define NM_DEVICE_DEFAULT_MTU_WIRELESS ((guint32) 1500) +#define NM_DEVICE_DEFAULT_MTU_INFINIBAND ((guint32) 0) + +gint64 nm_device_get_configured_mtu_from_connection_default (NMDevice *self, + const char *property_name); + +guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config); + +/*****************************************************************************/ + #define NM_DEVICE_CLASS_DECLARE_TYPES(klass, conn_type, ...) \ NM_DEVICE_CLASS (klass)->connection_type = conn_type; \ { \ diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index f818cd7c..a937ae2d 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -20,47 +20,58 @@ #include "nm-default.h" +#include "nm-device-tun.h" + #include #include #include -#include "nm-activation-request.h" -#include "nm-device-tun.h" +#include "nm-act-request.h" #include "nm-device-private.h" #include "nm-ip4-config.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-tun.h" #include "nm-core-internal.h" -#include "nmdbus-device-tun.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Tun.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceTun); -G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_TUN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_TUN, NMDeviceTunPrivate)) - -typedef struct { - NMPlatformTunProperties props; - const char *mode; -} NMDeviceTunPrivate; - -enum { - PROP_0, +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceTun, PROP_OWNER, PROP_GROUP, PROP_MODE, PROP_NO_PI, PROP_VNET_HDR, PROP_MULTI_QUEUE, +); + +typedef struct { + NMPlatformTunProperties props; + const char *mode; +} NMDeviceTunPrivate; + +struct _NMDeviceTun { + NMDevice parent; + NMDeviceTunPrivate _priv; +}; - LAST_PROP +struct _NMDeviceTunClass { + NMDeviceClass parent; }; +G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) + +#define NM_DEVICE_TUN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceTun, NM_IS_DEVICE_TUN) + +/*****************************************************************************/ + static void -reload_tun_properties (NMDeviceTun *self) +update_properties (NMDeviceTun *self) { NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); GObject *object = G_OBJECT (self); @@ -89,15 +100,15 @@ reload_tun_properties (NMDeviceTun *self) g_object_freeze_notify (object); if (priv->props.owner != props.owner) - g_object_notify (object, NM_DEVICE_TUN_OWNER); + _notify (self, PROP_OWNER); if (priv->props.group != props.group) - g_object_notify (object, NM_DEVICE_TUN_GROUP); + _notify (self, PROP_GROUP); if (priv->props.no_pi != props.no_pi) - g_object_notify (object, NM_DEVICE_TUN_NO_PI); + _notify (self, PROP_NO_PI); if (priv->props.vnet_hdr != props.vnet_hdr) - g_object_notify (object, NM_DEVICE_TUN_VNET_HDR); + _notify (self, PROP_VNET_HDR); if (priv->props.multi_queue != props.multi_queue) - g_object_notify (object, NM_DEVICE_TUN_MULTI_QUEUE); + _notify (self, PROP_MULTI_QUEUE); memcpy (&priv->props, &props, sizeof (NMPlatformTunProperties)); @@ -111,11 +122,11 @@ get_generic_capabilities (NMDevice *dev) } static void -link_changed (NMDevice *device, NMPlatformLink *info) +link_changed (NMDevice *device, + const NMPlatformLink *pllink) { - NM_DEVICE_CLASS (nm_device_tun_parent_class)->link_changed (device, info); - - reload_tun_properties (NM_DEVICE_TUN (device)); + NM_DEVICE_CLASS (nm_device_tun_parent_class)->link_changed (device, pllink); + update_properties (NM_DEVICE_TUN (device)); } static gboolean @@ -240,13 +251,6 @@ create_and_realize (NMDevice *device, return TRUE; } -static void -realize_start_notify (NMDevice *device, const NMPlatformLink *plink) -{ - NM_DEVICE_CLASS (nm_device_tun_parent_class)->realize_start_notify (device, plink); - reload_tun_properties (device); -} - static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { @@ -309,48 +313,22 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_SUCCESS; } -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - - connection = nm_device_get_applied_connection (device); - g_assert (connection); - - s_wired = nm_connection_get_setting_wired (connection); - if (s_wired) { - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); - } -} - static void unrealize_notify (NMDevice *device) { NMDeviceTun *self = NM_DEVICE_TUN (device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); - GParamSpec **properties; - guint n_properties, i; + guint i; NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize_notify (device); memset (&priv->props, 0, sizeof (NMPlatformTunProperties)); - properties = g_object_class_list_properties (G_OBJECT_GET_CLASS (self), &n_properties); - for (i = 0; i < n_properties; i++) - g_object_notify_by_pspec (G_OBJECT (self), properties[i]); - g_free (properties); + for (i = 1; i < _PROPERTY_ENUMS_LAST; i++) + g_object_notify_by_pspec ((GObject *) self, obj_properties[i]); } -/**************************************************************/ - -static void -nm_device_tun_init (NMDeviceTun *self) -{ -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, @@ -411,68 +389,67 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + +static void +nm_device_tun_init (NMDeviceTun *self) +{ +} + static void nm_device_tun_class_init (NMDeviceTunClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDeviceTunPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_TUN, NM_LINK_TYPE_TAP) object_class->get_property = get_property; object_class->set_property = set_property; device_class->connection_type = NM_SETTING_TUN_SETTING_NAME; - device_class->link_changed = link_changed; device_class->complete_connection = complete_connection; device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; - device_class->realize_start_notify = realize_start_notify; device_class->unrealize_notify = unrealize_notify; device_class->update_connection = update_connection; device_class->act_stage1_prepare = act_stage1_prepare; - device_class->ip4_config_pre_commit = ip4_config_pre_commit; - - /* properties */ - g_object_class_install_property - (object_class, PROP_OWNER, - g_param_spec_int64 (NM_DEVICE_TUN_OWNER, "", "", - -1, G_MAXUINT32, -1, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_GROUP, - g_param_spec_int64 (NM_DEVICE_TUN_GROUP, "", "", - -1, G_MAXUINT32, -1, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_MODE, - g_param_spec_string (NM_DEVICE_TUN_MODE, "", "", - "tun", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_NO_PI, - g_param_spec_boolean (NM_DEVICE_TUN_NO_PI, "", "", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_VNET_HDR, - g_param_spec_boolean (NM_DEVICE_TUN_VNET_HDR, "", "", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_MULTI_QUEUE, - g_param_spec_boolean (NM_DEVICE_TUN_MULTI_QUEUE, "", "", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; + + obj_properties[PROP_OWNER] = + g_param_spec_int64 (NM_DEVICE_TUN_OWNER, "", "", + -1, G_MAXUINT32, -1, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_GROUP] = + g_param_spec_int64 (NM_DEVICE_TUN_GROUP, "", "", + -1, G_MAXUINT32, -1, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_MODE] = + g_param_spec_string (NM_DEVICE_TUN_MODE, "", "", + "tun", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_NO_PI] = + g_param_spec_boolean (NM_DEVICE_TUN_NO_PI, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_VNET_HDR] = + g_param_spec_boolean (NM_DEVICE_TUN_VNET_HDR, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_MULTI_QUEUE] = + g_param_spec_boolean (NM_DEVICE_TUN_MULTI_QUEUE, "", "", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_TUN_SKELETON, @@ -480,10 +457,10 @@ nm_device_tun_class_init (NMDeviceTunClass *klass) } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_TUN_FACTORY (nm_tun_factory_get_type ()) -#define NM_TUN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_TUN_FACTORY, NMTunFactory)) +#define NM_TYPE_TUN_DEVICE_FACTORY (nm_tun_device_factory_get_type ()) +#define NM_TUN_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_TUN_DEVICE_FACTORY, NMTunDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -529,6 +506,5 @@ create_device (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (TUN, Tun, tun, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_TUN, NM_LINK_TYPE_TAP) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_TUN_SETTING_NAME), - factory_iface->create_device = create_device; - ) - + factory_class->create_device = create_device; +); diff --git a/src/devices/nm-device-tun.h b/src/devices/nm-device-tun.h index d62b0c37..b0d309bb 100644 --- a/src/devices/nm-device-tun.h +++ b/src/devices/nm-device-tun.h @@ -37,8 +37,8 @@ #define NM_DEVICE_TUN_VNET_HDR "vnet-hdr" #define NM_DEVICE_TUN_MULTI_QUEUE "multi-queue" -typedef NMDevice NMDeviceTun; -typedef NMDeviceClass NMDeviceTunClass; +typedef struct _NMDeviceTun NMDeviceTun; +typedef struct _NMDeviceTunClass NMDeviceTunClass; GType nm_device_tun_get_type (void); diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index c16df6d8..a5a87a2d 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -23,17 +23,14 @@ #include #include #include -#include -#include -#include #include "nm-device-veth.h" #include "nm-device-private.h" #include "nm-manager.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" -#include "nmdbus-device-veth.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Veth.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceVeth); @@ -41,8 +38,6 @@ _LOG_DECLARE_SELF(NMDeviceVeth); /*****************************************************************************/ typedef struct { - NMDevice *peer; - gboolean ever_had_peer; } NMDeviceVethPrivate; struct _NMDeviceVeth { @@ -51,7 +46,7 @@ struct _NMDeviceVeth { }; struct _NMDeviceVethClass { - NMDeviceEthernetClass parent_class; + NMDeviceEthernetClass parent; }; NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVeth, @@ -67,42 +62,23 @@ G_DEFINE_TYPE (NMDeviceVeth, nm_device_veth, NM_TYPE_DEVICE_ETHERNET) /*****************************************************************************/ static void -set_peer (NMDeviceVeth *self, NMDevice *peer) -{ - NMDeviceVethPrivate *priv = NM_DEVICE_VETH_GET_PRIVATE (self); - - if (!priv->peer) { - priv->ever_had_peer = TRUE; - priv->peer = peer; - g_object_add_weak_pointer (G_OBJECT (peer), (gpointer *) &priv->peer); - - _notify (self, PROP_PEER); - } -} - -static NMDevice * -get_peer (NMDeviceVeth *self) +update_properties (NMDevice *device) { - NMDeviceVethPrivate *priv = NM_DEVICE_VETH_GET_PRIVATE (self); - NMDevice *device = NM_DEVICE (self), *peer = NULL; - int peer_ifindex; + NMDevice *peer; + int ifindex, peer_ifindex; - if (priv->ever_had_peer) - return priv->peer; + ifindex = nm_device_get_ifindex (device); - if (!nm_platform_link_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &peer_ifindex)) { - _LOGW (LOGD_PLATFORM, "could not read veth properties"); - return NULL; - } + if (!nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex, &peer_ifindex)) + peer_ifindex = 0; - if (peer_ifindex > 0) - peer = nm_manager_get_device_by_ifindex (nm_manager_get (), peer_ifindex); - if (peer && NM_IS_DEVICE_VETH (peer)) { - set_peer (self, peer); - set_peer (NM_DEVICE_VETH (peer), device); - } + nm_device_parent_set_ifindex (device, peer_ifindex); - return priv->peer; + peer = nm_device_parent_get_device (device); + if ( peer + && NM_IS_DEVICE_VETH (peer) + && nm_device_parent_get_ifindex (peer) <= 0) + update_properties (peer); } static gboolean @@ -115,7 +91,15 @@ can_unmanaged_external_down (NMDevice *self) return FALSE; } -/**************************************************************/ +static void +link_changed (NMDevice *device, + const NMPlatformLink *pllink) +{ + NM_DEVICE_CLASS (nm_device_veth_parent_class)->link_changed (device, pllink); + update_properties (device); +} + +/*****************************************************************************/ static void nm_device_veth_init (NMDeviceVeth *self) @@ -123,17 +107,10 @@ nm_device_veth_init (NMDeviceVeth *self) } static void -dispose (GObject *object) +notify (GObject *object, GParamSpec *pspec) { - NMDeviceVeth *self = NM_DEVICE_VETH (object); - NMDeviceVethPrivate *priv = NM_DEVICE_VETH_GET_PRIVATE (self); - - if (priv->peer) { - g_object_remove_weak_pointer (G_OBJECT (priv->peer), (gpointer *) &priv->peer); - priv->peer = NULL; - } - - G_OBJECT_CLASS (nm_device_veth_parent_class)->dispose (object); + if (nm_streq (pspec->name, NM_DEVICE_PARENT)) + _notify (NM_DEVICE_VETH (object), PROP_PEER); } static void @@ -145,7 +122,9 @@ get_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_PEER: - peer = get_peer (self); + peer = nm_device_parent_get_device (NM_DEVICE (self)); + if (peer && !NM_IS_DEVICE_VETH (peer)) + peer = NULL; nm_utils_g_value_set_object_path (value, peer); break; default: @@ -163,9 +142,10 @@ nm_device_veth_class_init (NMDeviceVethClass *klass) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VETH) object_class->get_property = get_property; - object_class->dispose = dispose; + object_class->notify = notify; device_class->can_unmanaged_external_down = can_unmanaged_external_down; + device_class->link_changed = link_changed; obj_properties[PROP_PEER] = g_param_spec_string (NM_DEVICE_VETH_PEER, "", "", @@ -180,10 +160,10 @@ nm_device_veth_class_init (NMDeviceVethClass *klass) NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_VETH_FACTORY (nm_veth_factory_get_type ()) -#define NM_VETH_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VETH_FACTORY, NMVethFactory)) +#define NM_TYPE_VETH_DEVICE_FACTORY (nm_veth_device_factory_get_type ()) +#define NM_VETH_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VETH_DEVICE_FACTORY, NMVethDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -202,6 +182,5 @@ create_device (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (VETH, Veth, veth, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_VETH), - factory_iface->create_device = create_device; - ) - + factory_class->create_device = create_device; +); diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 461bae66..3979c95d 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -28,41 +28,46 @@ #include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" -#include "nm-enum-types.h" -#include "nm-settings.h" -#include "nm-activation-request.h" +#include "settings/nm-settings.h" +#include "nm-act-request.h" #include "nm-ip4-config.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-manager.h" #include "nm-core-internal.h" -#include "nmp-object.h" +#include "platform/nmp-object.h" -#include "nmdbus-device-vlan.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Vlan.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceVlan); -G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVlan, + PROP_VLAN_ID, +); typedef struct { - NMDevice *parent; gulong parent_state_id; gulong parent_hwaddr_id; guint vlan_id; } NMDeviceVlanPrivate; -enum { - PROP_0, - PROP_PARENT, - PROP_VLAN_ID, +struct _NMDeviceVlan { + NMDevice parent; + NMDeviceVlanPrivate _priv; +}; - LAST_PROP +struct _NMDeviceVlanClass { + NMDeviceClass parent; }; -/******************************************************************/ +G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) + +#define NM_DEVICE_VLAN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceVlan, NM_IS_DEVICE_VLAN) + +/*****************************************************************************/ static void parent_state_changed (NMDevice *parent, @@ -91,18 +96,18 @@ parent_hwaddr_maybe_changed (NMDevice *parent, NMSettingIPConfig *s_ip6; /* Never touch assumed devices */ - if (nm_device_uses_assumed_connection (self)) + if (nm_device_uses_assumed_connection ((NMDevice *) self)) return; - connection = nm_device_get_applied_connection (self); + connection = nm_device_get_applied_connection ((NMDevice *) self); if (!connection) return; /* Update the VLAN MAC only if configuration does not specify one */ - if (nm_device_hw_addr_is_explict (self)) + if (nm_device_hw_addr_is_explict ((NMDevice *) self)) return; - old_mac = nm_device_get_hw_address (self); + old_mac = nm_device_get_hw_address ((NMDevice *) self); new_mac = nm_device_get_hw_address (parent); if (nm_streq0 (old_mac, new_mac)) return; @@ -110,7 +115,7 @@ parent_hwaddr_maybe_changed (NMDevice *parent, _LOGD (LOGD_VLAN, "parent hardware address changed to %s%s%s", NM_PRINT_FMT_QUOTE_STRING (new_mac)); if (new_mac) { - nm_device_hw_addr_set (self, new_mac, "vlan-parent"); + nm_device_hw_addr_set ((NMDevice *) self, new_mac, "vlan-parent", TRUE); /* When changing the hw address the interface is taken down, * removing the IPv6 configuration; reapply it. */ @@ -121,41 +126,46 @@ parent_hwaddr_maybe_changed (NMDevice *parent, } static void -nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent) +parent_changed_notify (NMDevice *device, + int old_ifindex, + NMDevice *old_parent, + int new_ifindex, + NMDevice *new_parent) { + NMDeviceVlan *self = NM_DEVICE_VLAN (device); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); - NMDevice *device = NM_DEVICE (self); - if (parent == priv->parent) - return; + NM_DEVICE_CLASS (nm_device_vlan_parent_class)->parent_changed_notify (device, old_ifindex, old_parent, new_ifindex, new_parent); - nm_clear_g_signal_handler (priv->parent, &priv->parent_state_id); - nm_clear_g_signal_handler (priv->parent, &priv->parent_hwaddr_id); - g_clear_object (&priv->parent); + /* note that @self doesn't have to clear @parent_state_id on dispose, + * because NMDevice's dispose() will unset the parent, which in turn calls + * parent_changed_notify(). */ + nm_clear_g_signal_handler (old_parent, &priv->parent_state_id); + nm_clear_g_signal_handler (old_parent, &priv->parent_hwaddr_id); - if (parent) { - priv->parent = g_object_ref (parent); - priv->parent_state_id = g_signal_connect (priv->parent, + if (new_parent) { + priv->parent_state_id = g_signal_connect (new_parent, NM_DEVICE_STATE_CHANGED, G_CALLBACK (parent_state_changed), device); - priv->parent_hwaddr_id = g_signal_connect (priv->parent, "notify::" NM_DEVICE_HW_ADDRESS, + priv->parent_hwaddr_id = g_signal_connect (new_parent, "notify::" NM_DEVICE_HW_ADDRESS, G_CALLBACK (parent_hwaddr_maybe_changed), device); - parent_hwaddr_maybe_changed (parent, NULL, self); + parent_hwaddr_maybe_changed (new_parent, NULL, self); /* Set parent-dependent unmanaged flag */ nm_device_set_unmanaged_by_flags (device, NM_UNMANAGED_PARENT, - !nm_device_get_managed (parent, FALSE), + !nm_device_get_managed (new_parent, FALSE), NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED); } /* Recheck availability now that the parent has changed */ - nm_device_queue_recheck_available (self, - NM_DEVICE_STATE_REASON_PARENT_CHANGED, - NM_DEVICE_STATE_REASON_PARENT_CHANGED); - g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_PARENT); + if (new_ifindex > 0) { + nm_device_queue_recheck_available (device, + NM_DEVICE_STATE_REASON_PARENT_CHANGED, + NM_DEVICE_STATE_REASON_PARENT_CHANGED); + } } static void @@ -164,41 +174,41 @@ update_properties (NMDevice *device) NMDeviceVlanPrivate *priv; const NMPlatformLink *plink = NULL; const NMPlatformLnkVlan *plnk = NULL; - NMDevice *parent = NULL; int ifindex; + int parent_ifindex = 0; guint vlan_id; g_return_if_fail (NM_IS_DEVICE_VLAN (device)); - priv = NM_DEVICE_VLAN_GET_PRIVATE (device); + priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) device); ifindex = nm_device_get_ifindex (device); if (ifindex > 0) plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, ifindex, &plink); + if ( plnk - && plink->parent - && plink->parent != NM_PLATFORM_LINK_OTHER_NETNS) - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent); + && plink->parent > 0) + parent_ifindex = plink->parent; g_object_freeze_notify ((GObject *) device); - nm_device_vlan_set_parent ((NMDeviceVlan *) device, parent); + nm_device_parent_set_ifindex (device, parent_ifindex); vlan_id = plnk ? plnk->id : 0; if (vlan_id != priv->vlan_id) { priv->vlan_id = vlan_id; - g_object_notify ((GObject *) device, NM_DEVICE_VLAN_ID); + _notify ((NMDeviceVlan *) device, PROP_VLAN_ID); } g_object_thaw_notify ((GObject *) device); } static void -realize_start_notify (NMDevice *device, const NMPlatformLink *plink) +link_changed (NMDevice *device, + const NMPlatformLink *pllink) { - NM_DEVICE_CLASS (nm_device_vlan_parent_class)->realize_start_notify (device, plink); - + NM_DEVICE_CLASS (nm_device_vlan_parent_class)->link_changed (device, pllink); update_properties (device); } @@ -209,7 +219,7 @@ create_and_realize (NMDevice *device, const NMPlatformLink **out_plink, GError **error) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) device); const char *iface = nm_device_get_iface (device); NMSettingVlan *s_vlan; int parent_ifindex; @@ -253,11 +263,10 @@ create_and_realize (NMDevice *device, return FALSE; } - g_warn_if_fail (priv->parent == NULL); - nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent); + nm_device_parent_set_ifindex (device, parent_ifindex); if (vlan_id != priv->vlan_id) { priv->vlan_id = vlan_id; - g_object_notify ((GObject *) device, NM_DEVICE_VLAN_ID); + _notify ((NMDeviceVlan *) device, PROP_VLAN_ID); } return TRUE; @@ -266,82 +275,47 @@ create_and_realize (NMDevice *device, static void unrealize_notify (NMDevice *device) { + NMDeviceVlan *self = NM_DEVICE_VLAN (device); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); + NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize_notify (device); - NM_DEVICE_VLAN_GET_PRIVATE (device)->vlan_id = 0; - g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_ID); - nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), NULL); + if (priv->vlan_id != 0) { + priv->vlan_id = 0; + _notify (self, PROP_VLAN_ID); + } } -/******************************************************************/ +/*****************************************************************************/ static NMDeviceCapabilities -get_generic_capabilities (NMDevice *dev) +get_generic_capabilities (NMDevice *device) { /* We assume VLAN interfaces always support carrier detect */ return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE; } -static gboolean -bring_up (NMDevice *dev, gboolean *no_firmware) -{ - gboolean success = FALSE; - guint i = 20; - - while (i-- > 0 && !success) { - success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->bring_up (dev, no_firmware); - g_usleep (50); - } - - return success; -} - -/******************************************************************/ +/*****************************************************************************/ static gboolean is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { - if (!NM_DEVICE_VLAN_GET_PRIVATE (device)->parent) + if (!nm_device_parent_get_device (device)) return FALSE; - return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->is_available (device, flags); } -static void -notify_new_device_added (NMDevice *device, NMDevice *new_device) -{ - NMDeviceVlan *self = NM_DEVICE_VLAN (device); - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); - const NMPlatformLink *plink; - const NMPlatformLnkVlan *plnk; - - if (priv->parent) - return; - - if (!nm_device_is_real (device)) - return; - - plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink); - if (!plnk) - return; - - if ( plink->parent <= 0 - || nm_device_get_ifindex (new_device) != plink->parent) - return; - - nm_device_vlan_set_parent (self, new_device); -} - -/******************************************************************/ +/*****************************************************************************/ static gboolean match_parent (NMDeviceVlan *self, const char *parent) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); + NMDevice *parent_device; g_return_val_if_fail (parent != NULL, FALSE); - if (!priv->parent) + parent_device = nm_device_parent_get_device (NM_DEVICE (self)); + if (!parent_device) return FALSE; if (nm_utils_is_uuid (parent)) { @@ -352,7 +326,7 @@ match_parent (NMDeviceVlan *self, const char *parent) * device has that connection activated. */ - parent_req = nm_device_get_act_request (priv->parent); + parent_req = nm_device_get_act_request (parent_device); if (!parent_req) return FALSE; @@ -364,7 +338,7 @@ match_parent (NMDeviceVlan *self, const char *parent) return FALSE; } else { /* interface name */ - if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0) + if (g_strcmp0 (parent, nm_device_get_ip_iface (parent_device)) != 0) return FALSE; } @@ -374,8 +348,8 @@ match_parent (NMDeviceVlan *self, const char *parent) static gboolean match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr) { - NMDeviceVlanPrivate *priv; NMSettingWired *s_wired; + NMDevice *parent_device; const char *setting_mac; const char *parent_mac; @@ -387,18 +361,18 @@ match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hw if (!setting_mac) return !fail_if_no_hwaddr; - priv = NM_DEVICE_VLAN_GET_PRIVATE (device); - if (!priv->parent) + parent_device = nm_device_parent_get_device (device); + if (!parent_device) return !fail_if_no_hwaddr; - parent_mac = nm_device_get_permanent_hw_address (priv->parent); + parent_mac = nm_device_get_permanent_hw_address (parent_device); return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1); } static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) device); NMSettingVlan *s_vlan; const char *parent = NULL; @@ -482,12 +456,13 @@ complete_connection (NMDevice *device, static void update_connection (NMDevice *device, NMConnection *connection) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) device); NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection); int ifindex = nm_device_get_ifindex (device); const char *setting_parent, *new_parent; const NMPlatformLink *plink; const NMPObject *polnk; + NMDevice *parent_device; guint vlan_id; guint vlan_flags; @@ -506,18 +481,19 @@ update_connection (NMDevice *device, NMConnection *connection) g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL); /* Update parent in the connection; default to parent's interface name */ - if ( priv->parent + parent_device = nm_device_parent_get_device (device); + if ( parent_device && polnk && plink->parent > 0 - && nm_device_get_ifindex (priv->parent) == plink->parent) { - new_parent = nm_device_get_iface (priv->parent); + && nm_device_get_ifindex (parent_device) == plink->parent) { + new_parent = nm_device_get_iface (parent_device); setting_parent = nm_setting_vlan_get_parent (s_vlan); if (setting_parent && nm_utils_is_uuid (setting_parent)) { NMConnection *parent_connection; /* Don't change a parent specified by UUID if it's still valid */ parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent); - if (parent_connection && nm_device_check_connection_compatible (priv->parent, parent_connection)) + if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection)) new_parent = NULL; } if (new_parent) @@ -546,26 +522,27 @@ update_connection (NMDevice *device, NMConnection *connection) } static NMActStageReturn -act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) +act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (dev); + NMDevice *parent_device; NMSettingVlan *s_vlan; NMActStageReturn ret; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); - ret = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (dev, reason); + ret = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (device, reason); if (ret != NM_ACT_STAGE_RETURN_SUCCESS) return ret; - if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE)) + if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE)) return NM_ACT_STAGE_RETURN_FAILURE; /* Change MAC address to parent's one if needed */ - if (priv->parent) - parent_hwaddr_maybe_changed (priv->parent, NULL, dev); + parent_device = nm_device_parent_get_device (device); + if (parent_device) + parent_hwaddr_maybe_changed (parent_device, NULL, device); - s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_VLAN); + s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN); if (s_vlan) { gs_free NMVlanQosMapping *ingress_map = NULL; gs_free NMVlanQosMapping *egress_map = NULL; @@ -581,7 +558,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) &n_egress_map); nm_platform_link_vlan_change (NM_PLATFORM_GET, - nm_device_get_ifindex (dev), + nm_device_get_ifindex (device), NM_VLAN_FLAGS_ALL, nm_setting_vlan_get_flags (s_vlan), TRUE, @@ -595,41 +572,15 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) return ret; } -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - - connection = nm_device_get_applied_connection (device); - g_assert (connection); - - s_wired = nm_connection_get_setting_wired (connection); - if (s_wired) { - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); - } -} - -/******************************************************************/ - -static void -nm_device_vlan_init (NMDeviceVlan * self) -{ -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) object); switch (prop_id) { - case PROP_PARENT: - nm_utils_g_value_set_object_path (value, priv->parent); - break; case PROP_VLAN_ID: g_value_set_uint (value, priv->vlan_id); break; @@ -639,19 +590,11 @@ get_property (GObject *object, guint prop_id, } } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); -} +/*****************************************************************************/ static void -dispose (GObject *object) +nm_device_vlan_init (NMDeviceVlan * self) { - nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), NULL); - - G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object); } static void @@ -662,50 +605,39 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_VLAN_SETTING_NAME, NM_LINK_TYPE_VLAN) - g_type_class_add_private (object_class, sizeof (NMDeviceVlanPrivate)); - - /* virtual methods */ object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->dispose = dispose; parent_class->create_and_realize = create_and_realize; - parent_class->realize_start_notify = realize_start_notify; + parent_class->link_changed = link_changed; parent_class->unrealize_notify = unrealize_notify; parent_class->get_generic_capabilities = get_generic_capabilities; - parent_class->bring_up = bring_up; parent_class->act_stage1_prepare = act_stage1_prepare; - parent_class->ip4_config_pre_commit = ip4_config_pre_commit; + parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; parent_class->is_available = is_available; - parent_class->notify_new_device_added = notify_new_device_added; + parent_class->parent_changed_notify = parent_changed_notify; parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_available = check_connection_available; parent_class->complete_connection = complete_connection; parent_class->update_connection = update_connection; - /* properties */ - g_object_class_install_property - (object_class, PROP_PARENT, - 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, "", "", - 0, 4095, 0, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_VLAN_ID] = + g_param_spec_uint (NM_DEVICE_VLAN_ID, "", "", + 0, 4095, 0, + G_PARAM_READABLE + | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_VLAN_SKELETON, NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_VLAN_FACTORY (nm_vlan_factory_get_type ()) -#define NM_VLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VLAN_FACTORY, NMVlanFactory)) +#define NM_TYPE_VLAN_DEVICE_FACTORY (nm_vlan_device_factory_get_type ()) +#define NM_VLAN_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VLAN_DEVICE_FACTORY, NMVlanDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -777,8 +709,7 @@ get_connection_iface (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (VLAN, Vlan, vlan, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_VLAN) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_VLAN_SETTING_NAME), - factory_iface->create_device = create_device; - factory_iface->get_connection_parent = get_connection_parent; - factory_iface->get_connection_iface = get_connection_iface; - ) - + factory_class->create_device = create_device; + factory_class->get_connection_parent = get_connection_parent; + factory_class->get_connection_iface = get_connection_iface; +); diff --git a/src/devices/nm-device-vlan.h b/src/devices/nm-device-vlan.h index 71ca8030..0d788940 100644 --- a/src/devices/nm-device-vlan.h +++ b/src/devices/nm-device-vlan.h @@ -37,11 +37,13 @@ typedef enum { } NMVlanError; /* D-Bus exported properties */ -#define NM_DEVICE_VLAN_PARENT "parent" #define NM_DEVICE_VLAN_ID "vlan-id" -typedef NMDevice NMDeviceVlan; -typedef NMDeviceClass NMDeviceVlanClass; +/* defined in the parent class, but exposed on D-Bus by the subclass. */ +#define NM_DEVICE_VLAN_PARENT NM_DEVICE_PARENT + +typedef struct _NMDeviceVlan NMDeviceVlan; +typedef struct _NMDeviceVlanClass NMDeviceVlanClass; GType nm_device_vlan_get_type (void); diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 2453543d..b4508133 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -26,32 +26,23 @@ #include "nm-device-private.h" #include "nm-manager.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-utils.h" #include "nm-device-factory.h" #include "nm-setting-vxlan.h" #include "nm-setting-wired.h" -#include "nm-settings.h" -#include "nm-activation-request.h" +#include "settings/nm-settings.h" +#include "nm-act-request.h" #include "nm-ip4-config.h" -#include "nmdbus-device-vxlan.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Vxlan.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceVxlan); -G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) - -#define NM_DEVICE_VXLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VXLAN, NMDeviceVxlanPrivate)) - -typedef struct { - NMDevice *parent; - NMPlatformLnkVxlan props; -} NMDeviceVxlanPrivate; +/*****************************************************************************/ -enum { - PROP_0, - PROP_PARENT, +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVxlan, PROP_ID, PROP_LOCAL, PROP_GROUP, @@ -67,20 +58,34 @@ enum { PROP_RSC, PROP_L2MISS, PROP_L3MISS, +); - LAST_PROP +typedef struct { + NMPlatformLnkVxlan props; +} NMDeviceVxlanPrivate; + +struct _NMDeviceVxlan { + NMDevice parent; + NMDeviceVxlanPrivate _priv; }; -/**************************************************************/ +struct _NMDeviceVxlanClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) + +#define NM_DEVICE_VXLAN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceVxlan, NM_IS_DEVICE_VXLAN) + +/*****************************************************************************/ static void update_properties (NMDevice *device) { NMDeviceVxlan *self = NM_DEVICE_VXLAN (device); - NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (device); + NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self); GObject *object = G_OBJECT (device); const NMPlatformLnkVxlan *props; - NMDevice *parent; props = nm_platform_link_get_lnk_vxlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), NULL); if (!props) { @@ -90,47 +95,42 @@ update_properties (NMDevice *device) g_object_freeze_notify (object); - if (priv->props.parent_ifindex != props->parent_ifindex) { - g_clear_object (&priv->parent); - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), props->parent_ifindex); - if (parent) - priv->parent = g_object_ref (parent); - g_object_notify (object, NM_DEVICE_VXLAN_PARENT); - } + if (priv->props.parent_ifindex != props->parent_ifindex) + nm_device_parent_set_ifindex (device, props->parent_ifindex); if (priv->props.id != props->id) - g_object_notify (object, NM_DEVICE_VXLAN_ID); + _notify (self, PROP_ID); if (priv->props.local != props->local) - g_object_notify (object, NM_DEVICE_VXLAN_LOCAL); + _notify (self, PROP_LOCAL); if (memcmp (&priv->props.local6, &props->local6, sizeof (props->local6)) != 0) - g_object_notify (object, NM_DEVICE_VXLAN_LOCAL); + _notify (self, PROP_LOCAL); if (priv->props.group != props->group) - g_object_notify (object, NM_DEVICE_VXLAN_GROUP); + _notify (self, PROP_GROUP); if (memcmp (&priv->props.group6, &props->group6, sizeof (props->group6)) != 0) - g_object_notify (object, NM_DEVICE_VXLAN_GROUP); + _notify (self, PROP_GROUP); if (priv->props.tos != props->tos) - g_object_notify (object, NM_DEVICE_VXLAN_TOS); + _notify (self, PROP_TOS); if (priv->props.ttl != props->ttl) - g_object_notify (object, NM_DEVICE_VXLAN_TTL); + _notify (self, PROP_TTL); if (priv->props.learning != props->learning) - g_object_notify (object, NM_DEVICE_VXLAN_LEARNING); + _notify (self, PROP_LEARNING); if (priv->props.ageing != props->ageing) - g_object_notify (object, NM_DEVICE_VXLAN_AGEING); + _notify (self, PROP_AGEING); if (priv->props.limit != props->limit) - g_object_notify (object, NM_DEVICE_VXLAN_LIMIT); + _notify (self, PROP_LIMIT); if (priv->props.src_port_min != props->src_port_min) - g_object_notify (object, NM_DEVICE_VXLAN_SRC_PORT_MIN); + _notify (self, PROP_SRC_PORT_MIN); if (priv->props.src_port_max != props->src_port_max) - g_object_notify (object, NM_DEVICE_VXLAN_SRC_PORT_MAX); + _notify (self, PROP_SRC_PORT_MAX); if (priv->props.dst_port != props->dst_port) - g_object_notify (object, NM_DEVICE_VXLAN_DST_PORT); + _notify (self, PROP_DST_PORT); if (priv->props.proxy != props->proxy) - g_object_notify (object, NM_DEVICE_VXLAN_PROXY); + _notify (self, PROP_PROXY); if (priv->props.rsc != props->rsc) - g_object_notify (object, NM_DEVICE_VXLAN_RSC); + _notify (self, PROP_RSC); if (priv->props.l2miss != props->l2miss) - g_object_notify (object, NM_DEVICE_VXLAN_L2MISS); + _notify (self, PROP_L2MISS); if (priv->props.l3miss != props->l3miss) - g_object_notify (object, NM_DEVICE_VXLAN_L3MISS); + _notify (self, PROP_L3MISS); priv->props = *props; @@ -144,19 +144,10 @@ get_generic_capabilities (NMDevice *dev) } static void -link_changed (NMDevice *device, NMPlatformLink *info) -{ - NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->link_changed (device, info); - update_properties (device); -} - -static void -realize_start_notify (NMDevice *device, const NMPlatformLink *plink) +link_changed (NMDevice *device, + const NMPlatformLink *pllink) { - g_assert (plink->type == NM_LINK_TYPE_VXLAN); - - NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->realize_start_notify (device, plink); - + NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->link_changed (device, pllink); update_properties (device); } @@ -165,17 +156,14 @@ unrealize_notify (NMDevice *device) { NMDeviceVxlan *self = NM_DEVICE_VXLAN (device); NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self); - GParamSpec **properties; - guint n_properties, i; + guint i; NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->unrealize_notify (device); memset (&priv->props, 0, sizeof (NMPlatformLnkVxlan)); - properties = g_object_class_list_properties (G_OBJECT_GET_CLASS (self), &n_properties); - for (i = 0; i < n_properties; i++) - g_object_notify_by_pspec (G_OBJECT (self), properties[i]); - g_free (properties); + for (i = 1; i < _PROPERTY_ENUMS_LAST; i++) + g_object_notify_by_pspec (G_OBJECT (self), obj_properties[i]); } static gboolean @@ -245,11 +233,12 @@ create_and_realize (NMDevice *device, static gboolean match_parent (NMDeviceVxlan *self, const char *parent) { - NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self); + NMDevice *parent_device; g_return_val_if_fail (parent != NULL, FALSE); - if (!priv->parent) + parent_device = nm_device_parent_get_device (NM_DEVICE (self)); + if (!parent_device) return FALSE; if (nm_utils_is_uuid (parent)) { @@ -259,7 +248,7 @@ match_parent (NMDeviceVxlan *self, const char *parent) /* If the parent is a UUID, the connection matches if our parent * device has that connection activated. */ - parent_req = nm_device_get_act_request (priv->parent); + parent_req = nm_device_get_act_request (parent_device); if (!parent_req) return FALSE; @@ -271,7 +260,7 @@ match_parent (NMDeviceVxlan *self, const char *parent) return FALSE; } else { /* interface name */ - if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0) + if (g_strcmp0 (parent, nm_device_get_ip_iface (parent_device)) != 0) return FALSE; } @@ -300,7 +289,7 @@ address_matches (const char *str, in_addr_t addr4, struct in6_addr *addr6) static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { - NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (device); + NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) device); NMSettingVxlan *s_vxlan; const char *parent; @@ -394,10 +383,11 @@ complete_connection (NMDevice *device, static void update_connection (NMDevice *device, NMConnection *connection) { - NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (device); + NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) device); NMSettingVxlan *s_vxlan = nm_connection_get_setting_vxlan (connection); - NMDevice *parent = NULL; - const char *setting_parent, *new_parent; + NMDevice *parent_device; + const char *setting_parent; + const char *new_parent = NULL; if (!s_vxlan) { s_vxlan = (NMSettingVxlan *) nm_setting_vxlan_new (); @@ -407,12 +397,11 @@ update_connection (NMDevice *device, NMConnection *connection) if (priv->props.id != nm_setting_vxlan_get_id (s_vxlan)) g_object_set (G_OBJECT (s_vxlan), NM_SETTING_VXLAN_ID, priv->props.id, NULL); - if (priv->props.parent_ifindex != NM_PLATFORM_LINK_OTHER_NETNS) - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex); + parent_device = nm_device_parent_get_device (device); /* Update parent in the connection; default to parent's interface name */ - if (parent) { - new_parent = nm_device_get_iface (parent); + if (parent_device) { + new_parent = nm_device_get_iface (parent_device); setting_parent = nm_setting_vxlan_get_parent (s_vxlan); if (setting_parent && nm_utils_is_uuid (setting_parent)) { NMConnection *parent_connection; @@ -420,13 +409,11 @@ update_connection (NMDevice *device, NMConnection *connection) /* Don't change a parent specified by UUID if it's still valid */ parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent); - if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection)) + if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection)) new_parent = NULL; } - if (new_parent) - g_object_set (s_vxlan, NM_SETTING_VXLAN_PARENT, new_parent, NULL); - } else - g_object_set (s_vxlan, NM_SETTING_VXLAN_PARENT, NULL, NULL); + } + g_object_set (s_vxlan, NM_SETTING_VXLAN_PARENT, new_parent, NULL); if (!address_matches (nm_setting_vxlan_get_remote (s_vxlan), priv->props.group, &priv->props.group6)) { if (priv->props.group) { @@ -525,43 +512,15 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_SUCCESS; } -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - - connection = nm_device_get_applied_connection (device); - g_assert (connection); - - s_wired = nm_connection_get_setting_wired (connection); - if (s_wired) { - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); - } -} - -/**************************************************************/ - -static void -nm_device_vxlan_init (NMDeviceVxlan *self) -{ -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (object); - NMDevice *parent; + NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) object); switch (prop_id) { - case PROP_PARENT: - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex); - nm_utils_g_value_set_object_path (value, parent); - break; case PROP_ID: g_value_set_uint (value, priv->props.id); break; @@ -619,13 +578,11 @@ get_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + static void -dispose (GObject *object) +nm_device_vxlan_init (NMDeviceVxlan *self) { - NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (object); - - g_clear_object (&priv->parent); - G_OBJECT_CLASS (nm_device_vxlan_parent_class)->dispose (object); } static void @@ -634,15 +591,11 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDeviceVxlanPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VXLAN) object_class->get_property = get_property; - object_class->dispose = dispose; device_class->link_changed = link_changed; - device_class->realize_start_notify = realize_start_notify; device_class->unrealize_notify = unrealize_notify; device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME; device_class->create_and_realize = create_and_realize; @@ -651,130 +604,109 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) device_class->get_generic_capabilities = get_generic_capabilities; device_class->update_connection = update_connection; device_class->act_stage1_prepare = act_stage1_prepare; - device_class->ip4_config_pre_commit = ip4_config_pre_commit; - - /* properties */ - g_object_class_install_property - (object_class, PROP_PARENT, - 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, - g_param_spec_uint (NM_DEVICE_VXLAN_ID, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_LOCAL, - g_param_spec_string (NM_DEVICE_VXLAN_LOCAL, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_GROUP, - g_param_spec_string (NM_DEVICE_VXLAN_GROUP, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TOS, - g_param_spec_uchar (NM_DEVICE_VXLAN_TOS, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TTL, - g_param_spec_uchar (NM_DEVICE_VXLAN_TTL, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_LEARNING, - g_param_spec_boolean (NM_DEVICE_VXLAN_LEARNING, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_AGEING, - g_param_spec_uint (NM_DEVICE_VXLAN_AGEING, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_LIMIT, - g_param_spec_uint (NM_DEVICE_VXLAN_LIMIT, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_SRC_PORT_MIN, - g_param_spec_uint (NM_DEVICE_VXLAN_SRC_PORT_MIN, "", "", - 0, 65535, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_SRC_PORT_MAX, - g_param_spec_uint (NM_DEVICE_VXLAN_SRC_PORT_MAX, "", "", - 0, 65535, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_DST_PORT, - g_param_spec_uint (NM_DEVICE_VXLAN_DST_PORT, "", "", - 0, 65535, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_PROXY, - g_param_spec_boolean (NM_DEVICE_VXLAN_PROXY, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_RSC, - g_param_spec_boolean (NM_DEVICE_VXLAN_RSC, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_L2MISS, - g_param_spec_boolean (NM_DEVICE_VXLAN_L2MISS, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_L3MISS, - g_param_spec_boolean (NM_DEVICE_VXLAN_L3MISS, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; + + obj_properties[PROP_ID] = + g_param_spec_uint (NM_DEVICE_VXLAN_ID, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_LOCAL] = + g_param_spec_string (NM_DEVICE_VXLAN_LOCAL, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_GROUP] = + g_param_spec_string (NM_DEVICE_VXLAN_GROUP, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TOS] = + g_param_spec_uchar (NM_DEVICE_VXLAN_TOS, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TTL] = + g_param_spec_uchar (NM_DEVICE_VXLAN_TTL, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_LEARNING] = + g_param_spec_boolean (NM_DEVICE_VXLAN_LEARNING, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_AGEING] = + g_param_spec_uint (NM_DEVICE_VXLAN_AGEING, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_LIMIT] = + g_param_spec_uint (NM_DEVICE_VXLAN_LIMIT, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_SRC_PORT_MIN] = + g_param_spec_uint (NM_DEVICE_VXLAN_SRC_PORT_MIN, "", "", + 0, 65535, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_SRC_PORT_MAX] = + g_param_spec_uint (NM_DEVICE_VXLAN_SRC_PORT_MAX, "", "", + 0, 65535, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_DST_PORT] = + g_param_spec_uint (NM_DEVICE_VXLAN_DST_PORT, "", "", + 0, 65535, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_PROXY] = + g_param_spec_boolean (NM_DEVICE_VXLAN_PROXY, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_RSC] = + g_param_spec_boolean (NM_DEVICE_VXLAN_RSC, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_L2MISS] = + g_param_spec_boolean (NM_DEVICE_VXLAN_L2MISS, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_L3MISS] = + g_param_spec_boolean (NM_DEVICE_VXLAN_L3MISS, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_VXLAN_SKELETON, NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_VXLAN_FACTORY (nm_vxlan_factory_get_type ()) -#define NM_VXLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VXLAN_FACTORY, NMVxlanFactory)) +#define NM_TYPE_VXLAN_DEVICE_FACTORY (nm_vxlan_device_factory_get_type ()) +#define NM_VXLAN_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VXLAN_DEVICE_FACTORY, NMVxlanDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -827,8 +759,7 @@ get_connection_iface (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (VXLAN, Vxlan, vxlan, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_VXLAN) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_VXLAN_SETTING_NAME), - factory_iface->create_device = create_device; - factory_iface->get_connection_parent = get_connection_parent; - factory_iface->get_connection_iface = get_connection_iface; - ) - + factory_class->create_device = create_device; + factory_class->get_connection_parent = get_connection_parent; + factory_class->get_connection_iface = get_connection_iface; +); diff --git a/src/devices/nm-device-vxlan.h b/src/devices/nm-device-vxlan.h index 71204d3b..6f0102dc 100644 --- a/src/devices/nm-device-vxlan.h +++ b/src/devices/nm-device-vxlan.h @@ -30,7 +30,6 @@ #define NM_IS_DEVICE_VXLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_VXLAN)) #define NM_DEVICE_VXLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_VXLAN, NMDeviceVxlanClass)) -#define NM_DEVICE_VXLAN_PARENT "parent" #define NM_DEVICE_VXLAN_ID "id" #define NM_DEVICE_VXLAN_GROUP "group" #define NM_DEVICE_VXLAN_LOCAL "local" @@ -47,8 +46,11 @@ #define NM_DEVICE_VXLAN_L2MISS "l2miss" #define NM_DEVICE_VXLAN_L3MISS "l3miss" -typedef NMDevice NMDeviceVxlan; -typedef NMDeviceClass NMDeviceVxlanClass; +/* defined in the parent class, but exposed on D-Bus by the subclass. */ +#define NM_DEVICE_VXLAN_PARENT NM_DEVICE_PARENT + +typedef struct _NMDeviceVxlan NMDeviceVxlan; +typedef struct _NMDeviceVxlanClass NMDeviceVxlanClass; GType nm_device_vxlan_get_type (void); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index ac840ab9..bc532ff9 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -39,38 +39,39 @@ #include "nm-device-private.h" #include "NetworkManagerUtils.h" #include "nm-manager.h" -#include "nm-platform.h" -#include "nm-rdisc.h" -#include "nm-lndp-rdisc.h" -#include "nm-dhcp-manager.h" -#include "nm-activation-request.h" +#include "platform/nm-platform.h" +#include "ndisc/nm-ndisc.h" +#include "ndisc/nm-lndp-ndisc.h" +#include "dhcp/nm-dhcp-manager.h" +#include "nm-act-request.h" +#include "nm-proxy-config.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" -#include "nm-dnsmasq-manager.h" +#include "nm-pacrunner-manager.h" +#include "dnsmasq/nm-dnsmasq-manager.h" #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" #include "nm-rfkill-manager.h" #include "nm-firewall-manager.h" -#include "nm-enum-types.h" -#include "nm-settings-connection.h" -#include "nm-settings.h" +#include "settings/nm-settings-connection.h" +#include "settings/nm-settings.h" #include "nm-auth-utils.h" #include "nm-dispatcher.h" #include "nm-config.h" -#include "nm-dns-manager.h" +#include "dns/nm-dns-manager.h" #include "nm-core-internal.h" #include "nm-default-route-manager.h" #include "nm-route-manager.h" +#include "systemd/nm-sd.h" #include "nm-lldp-listener.h" -#include "sd-ipv4ll.h" #include "nm-audit-manager.h" #include "nm-arping-manager.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF (NMDevice); -#include "nmdbus-device.h" -#include "nmdbus-device-statistics.h" +#include "introspection/org.freedesktop.NetworkManager.Device.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Statistics.h" G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_EXPORTED_OBJECT) @@ -82,6 +83,8 @@ enum { AUTH_REQUEST, IP4_CONFIG_CHANGED, IP6_CONFIG_CHANGED, + IP6_PREFIX_DELEGATED, + IP6_SUBNET_NEEDED, REMOVED, RECHECK_AUTO_ACTIVATE, RECHECK_ASSUME, @@ -120,6 +123,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDevice, PROP_PHYSICAL_PORT_ID, PROP_IS_MASTER, PROP_MASTER, + PROP_PARENT, PROP_HW_ADDRESS, PROP_PERM_HW_ADDRESS, PROP_HAS_PENDING_ACTION, @@ -134,7 +138,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDevice, #define DEFAULT_AUTOCONNECT TRUE -/***********************************************************/ +/*****************************************************************************/ #define PENDING_ACTION_DHCP4 "dhcp4" #define PENDING_ACTION_DHCP6 "dhcp6" @@ -222,10 +226,14 @@ typedef struct _NMDevicePrivate { GSList *pending_actions; GSList *dad6_failed_addrs; + NMDevice *parent_device; + char * udi; char * iface; /* may change, could be renamed by user */ int ifindex; + int parent_ifindex; + union { const guint8 hw_addr_len; /* read-only */ guint8 hw_addr_len_; @@ -253,6 +261,9 @@ typedef struct _NMDevicePrivate { bool firmware_missing:1; bool nm_plugin_missing:1; bool hw_addr_perm_fake:1; /* whether the permanent HW address could not be read and is a fake */ + + NMUtilsStableType current_stable_id_type:3; + GHashTable * available_connections; char * hw_addr; char * hw_addr_perm; @@ -295,15 +306,30 @@ typedef struct _NMDevicePrivate { bool ignore_carrier; gulong ignore_carrier_id; guint32 mtu; - bool up; /* IFF_UP */ + guint32 ip6_mtu; + guint32 mtu_initial; + guint32 ip6_mtu_initial; + + bool mtu_initialized:1; + + bool up:1; /* IFF_UP */ /* Generic DHCP stuff */ guint32 dhcp_timeout; char * dhcp_anycast_address; + char * current_stable_id; + + /* Proxy Configuration */ + NMProxyConfig *proxy_config; + NMPacrunnerManager *pacrunner_manager; + /* IP4 configuration info */ NMIP4Config * ip4_config; /* Combined config from VPN, settings, and device */ - IpState ip4_state; + union { + const IpState ip4_state; + IpState ip4_state_; + }; NMIP4Config * con_ip4_config; /* config from the setting */ NMIP4Config * dev_ip4_config; /* Config from DHCP, PPP, LLv4, etc */ NMIP4Config * ext_ip4_config; /* Stuff added outside NM */ @@ -352,20 +378,22 @@ typedef struct _NMDevicePrivate { /* IP6 configuration info */ NMIP6Config * ip6_config; - IpState ip6_state; + union { + const IpState ip6_state; + IpState ip6_state_; + }; NMIP6Config * con_ip6_config; /* config from the setting */ NMIP6Config * wwan_ip6_config; NMIP6Config * ext_ip6_config; /* Stuff added outside NM */ NMIP6Config * ext_ip6_config_captured; /* Configuration captured from platform. */ GSList * vpn6_configs; /* VPNs which use this device */ bool nm_ipv6ll; /* TRUE if NM handles the device's IPv6LL address */ - guint32 ip6_mtu; NMIP6Config * dad6_ip6_config; - NMRDisc * rdisc; - gulong rdisc_changed_id; - gulong rdisc_timeout_id; - NMSettingIP6ConfigPrivacy rdisc_use_tempaddr; + NMNDisc * ndisc; + gulong ndisc_changed_id; + gulong ndisc_timeout_id; + NMSettingIP6ConfigPrivacy ndisc_use_tempaddr; /* IP6 config from autoconf */ NMIP6Config * ac_ip6_config; @@ -376,8 +404,9 @@ typedef struct _NMDevicePrivate { struct { NMDhcpClient * client; - NMRDiscDHCPLevel mode; + NMNDiscDHCPLevel mode; gulong state_sigid; + gulong prefix_sigid; NMDhcp6Config * config; /* IP6 config from DHCP */ NMIP6Config * ip6_config; @@ -385,8 +414,11 @@ typedef struct _NMDevicePrivate { char * event_id; guint restart_id; guint num_tries_left; + guint needed_prefixes; } dhcp6; + gboolean needs_ip6_subnet; + /* allow autoconnect feature */ bool autoconnect; @@ -417,6 +449,8 @@ typedef struct _NMDevicePrivate { } NMDevicePrivate; +static void nm_device_set_proxy_config (NMDevice *self, GHashTable *options); + static gboolean nm_device_set_ip4_config (NMDevice *self, NMIP4Config *config, guint32 default_route_metric, @@ -462,11 +496,11 @@ static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection, N static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason); static void nm_device_start_ip_check (NMDevice *self); static void realize_start_setup (NMDevice *self, const NMPlatformLink *plink); -static void nm_device_set_mtu (NMDevice *self, guint32 mtu); +static void _commit_mtu (NMDevice *self, const NMIP4Config *config); static void dhcp_schedule_restart (NMDevice *self, int family, const char *reason); static void _cancel_activation (NMDevice *self); -/***********************************************************/ +/*****************************************************************************/ #define QUEUED_PREFIX "queued state change to " @@ -570,7 +604,7 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_reason_to_string, NMDeviceStateReason, #define reason_to_string(reason) \ NM_UTILS_LOOKUP_STR (_reason_to_string, reason) -/***********************************************************/ +/*****************************************************************************/ NMSettings * nm_device_get_settings (NMDevice *self) @@ -604,18 +638,23 @@ init_ip6_config_dns_priority (NMDevice *self, NMIP6Config *config) nm_ip6_config_set_dns_priority (config, priority ?: NM_DNS_PRIORITY_DEFAULT_NORMAL); } -/***********************************************************/ +/*****************************************************************************/ gboolean nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value) { - return nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value); + return nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)), value); } static guint32 -nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback) +nm_device_ipv6_sysctl_get_uint32 (NMDevice *self, const char *property, guint32 fallback) { - return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback); + return nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, + NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)), + 10, + 0, + G_MAXUINT32, + fallback); } gboolean @@ -635,31 +674,111 @@ _add_capabilities (NMDevice *self, NMDeviceCapabilities capabilities) } } -/***********************************************************/ +/*****************************************************************************/ static const char * -_get_stable_id (NMConnection *connection, NMUtilsStableType *out_stable_type) +_get_stable_id (NMDevice *self, + NMConnection *connection, + NMUtilsStableType *out_stable_type) { - NMSettingConnection *s_con; - const char *stable_id; + NMDevicePrivate *priv; + nm_assert (NM_IS_DEVICE (self)); nm_assert (NM_IS_CONNECTION (connection)); nm_assert (out_stable_type); - s_con = nm_connection_get_setting_connection (connection); - g_return_val_if_fail (s_con, NULL); + priv = NM_DEVICE_GET_PRIVATE (self); + + /* we cache the generated stable ID for the time of an activation. + * + * The reason is, that we don't want the stable-id to change as long + * as the device is active. + * + * Especially with ${RANDOM} stable-id we want to generate *one* configuration + * for each activation. */ + if (G_UNLIKELY (!priv->current_stable_id)) { + gs_free char *default_id = NULL; + gs_free char *generated = NULL; + NMUtilsStableType stable_type; + NMSettingConnection *s_con; + const char *stable_id; + const char *uuid; + + s_con = nm_connection_get_setting_connection (connection); + + stable_id = nm_setting_connection_get_stable_id (s_con); + + if (!stable_id) { + default_id = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, + "connection.stable-id", + self); + stable_id = default_id; + } + + uuid = nm_connection_get_uuid (connection); - stable_id = nm_setting_connection_get_stable_id (s_con); - if (!stable_id) { - *out_stable_type = NM_UTILS_STABLE_TYPE_UUID; - return nm_connection_get_uuid (connection); + stable_type = nm_utils_stable_id_parse (stable_id, + uuid, + NULL, + &generated); + + /* current_stable_id_type is a bitfield! */ + priv->current_stable_id_type = stable_type; + nm_assert (stable_type <= (NMUtilsStableType) 0x3); + nm_assert (stable_type + (NMUtilsStableType) 1 > (NMUtilsStableType) 0); + nm_assert (priv->current_stable_id_type == stable_type); + + if (stable_type == NM_UTILS_STABLE_TYPE_UUID) + priv->current_stable_id = g_strdup (uuid); + else if (stable_type == NM_UTILS_STABLE_TYPE_STABLE_ID) + priv->current_stable_id = g_strdup (stable_id); + else if (stable_type == NM_UTILS_STABLE_TYPE_GENERATED) + priv->current_stable_id = nm_str_realloc (nm_utils_stable_id_generated_complete (generated)); + else { + nm_assert (stable_type == NM_UTILS_STABLE_TYPE_RANDOM); + priv->current_stable_id = nm_str_realloc (nm_utils_stable_id_random ()); + } + _LOGT (LOGD_DEVICE, + "stable-id: type=%d, \"%s\"" + "%s%s%s", + (int) priv->current_stable_id_type, + priv->current_stable_id, + NM_PRINT_FMT_QUOTED (stable_type == NM_UTILS_STABLE_TYPE_GENERATED, " from \"", generated, "\"", "")); } - *out_stable_type = NM_UTILS_STABLE_TYPE_STABLE_ID; - return stable_id; + *out_stable_type = priv->current_stable_id_type; + return priv->current_stable_id; } -/***********************************************************/ +/*****************************************************************************/ + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_ip_state_to_string, IpState, + NM_UTILS_LOOKUP_DEFAULT_WARN ("unknown"), + NM_UTILS_LOOKUP_STR_ITEM (IP_NONE, "none"), + NM_UTILS_LOOKUP_STR_ITEM (IP_WAIT, "wait"), + NM_UTILS_LOOKUP_STR_ITEM (IP_CONF, "conf"), + NM_UTILS_LOOKUP_STR_ITEM (IP_DONE, "done"), + NM_UTILS_LOOKUP_STR_ITEM (IP_FAIL, "fail"), +); + +static void +_set_ip_state (NMDevice *self, int addr_family, IpState new_state) +{ + IpState *p; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + nm_assert (NM_IN_SET (addr_family, AF_INET, AF_INET6)); + + p = addr_family == AF_INET ? &priv->ip4_state_ : &priv->ip6_state_; + + if (*p != new_state) { + _LOGT (LOGD_DEVICE, "ip%c-state: set to %d (%s)", addr_family == AF_INET ? '4' : '6', + (int) new_state, _ip_state_to_string (new_state)); + *p = new_state; + } +} + +/*****************************************************************************/ const char * nm_device_get_udi (NMDevice *self) @@ -738,43 +857,224 @@ nm_device_get_ip_ifindex (NMDevice *self) return priv->ip_iface ? priv->ip_ifindex : priv->ifindex; } -void +/** + * nm_device_set_ip_iface: + * @self: the #NMDevice + * @iface: the new IP interface name + * + * Updates the IP interface name and possibly the ifindex. + * + * Returns: %TRUE if the anything (name or ifindex) changed, %FALSE if nothing + * changed. + */ +gboolean nm_device_set_ip_iface (NMDevice *self, const char *iface) { NMDevicePrivate *priv; - char *old_ip_iface; + int ifindex; - g_return_if_fail (NM_IS_DEVICE (self)); + g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); priv = NM_DEVICE_GET_PRIVATE (self); - if (!g_strcmp0 (iface, priv->ip_iface)) - return; - - old_ip_iface = priv->ip_iface; - priv->ip_ifindex = 0; - - priv->ip_iface = g_strdup (iface); - if (priv->ip_iface) { - priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface); - if (priv->ip_ifindex > 0) { - if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) - nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE); + if (nm_streq0 (iface, priv->ip_iface)) { + if (!iface) + return FALSE; + ifindex = nm_platform_if_nametoindex (NM_PLATFORM_GET, iface); + if ( ifindex <= 0 + || priv->ip_ifindex == ifindex) + return FALSE; - if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex)) - nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL); + priv->ip_ifindex = ifindex; + _LOGD (LOGD_DEVICE, "ip-ifname: update ifindex for ifname '%s': %d", iface, priv->ip_ifindex); + } else { + g_free (priv->ip_iface); + priv->ip_iface = g_strdup (iface); + + if (iface) { + /* The @iface name is not in sync with the platform cache. + * So, there is no point asking the platform cache to resolve + * the ifindex. Instead, we can only hope that the interface + * with this name still exists and we resolve the ifindex + * anew. + */ + priv->ip_ifindex = nm_platform_if_nametoindex (NM_PLATFORM_GET, iface); + if (priv->ip_ifindex > 0) + _LOGD (LOGD_DEVICE, "ip-ifname: set ifname '%s', ifindex %d", iface, priv->ip_ifindex); + else + _LOGW (LOGD_DEVICE, "ip-ifname: set ifname '%s', unknown ifindex", iface); } else { - /* Device IP interface must always be a kernel network interface */ - _LOGW (LOGD_PLATFORM, "failed to look up interface index"); + priv->ip_ifindex = 0; + _LOGD (LOGD_DEVICE, "ip-ifname: clear ifname"); } } + if (priv->ip_ifindex > 0) { + if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) + nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE); + + if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex)) + nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL); + } + /* We don't care about any saved values from the old iface */ g_hash_table_remove_all (priv->ip6_saved_properties); - /* Emit change notification */ - if (g_strcmp0 (old_ip_iface, priv->ip_iface)) - _notify (self, PROP_IP_IFACE); - g_free (old_ip_iface); + _notify (self, PROP_IP_IFACE); + return TRUE; +} + +static gboolean +_ip_iface_update (NMDevice *self, const char *ip_iface) +{ + NMDevicePrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + + priv = NM_DEVICE_GET_PRIVATE (self); + + g_return_val_if_fail (priv->ip_iface, FALSE); + g_return_val_if_fail (priv->ip_ifindex > 0, FALSE); + g_return_val_if_fail (ip_iface, FALSE); + + if (!ip_iface[0]) + return FALSE; + + if (nm_streq (priv->ip_iface, ip_iface)) + return FALSE; + + _LOGI (LOGD_DEVICE, "ip-ifname: interface index %d renamed ip_iface (%d) from '%s' to '%s'", + priv->ifindex, priv->ip_ifindex, + priv->ip_iface, ip_iface); + g_free (priv->ip_iface); + priv->ip_iface = g_strdup (ip_iface); + _notify (self, PROP_IP_IFACE); + return TRUE; +} + +/*****************************************************************************/ + +int +nm_device_parent_get_ifindex (NMDevice *self) +{ + NMDevicePrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE (self), 0); + + priv = NM_DEVICE_GET_PRIVATE (self); + return priv->parent_ifindex; +} + +NMDevice * +nm_device_parent_get_device (NMDevice *self) +{ + NMDevicePrivate *priv; + + g_return_val_if_fail (NM_IS_DEVICE (self), NULL); + + priv = NM_DEVICE_GET_PRIVATE (self); + return priv->parent_device; +} + +static void +parent_changed_notify (NMDevice *self, + int old_ifindex, + NMDevice *old_parent, + int new_ifindex, + NMDevice *new_parent) +{ + /* empty handler to allow subclasses to always chain up the virtual function. */ +} + +static gboolean +_parent_set_ifindex (NMDevice *self, + int parent_ifindex, + gboolean force_check) +{ + NMDevicePrivate *priv; + NMDevice *parent_device; + gboolean changed = FALSE; + int old_ifindex; + NMDevice *old_device; + + g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + + priv = NM_DEVICE_GET_PRIVATE (self); + + if (parent_ifindex <= 0) + parent_ifindex = 0; + + old_ifindex = priv->parent_ifindex; + old_device = priv->parent_device; + + if (priv->parent_ifindex == parent_ifindex) { + if (parent_ifindex > 0) { + if ( !force_check + && priv->parent_device + && nm_device_get_ifindex (priv->parent_device) == parent_ifindex) + return FALSE; + } else { + if (!priv->parent_device) + return FALSE; + } + } else { + priv->parent_ifindex = parent_ifindex; + changed = TRUE; + } + + if (parent_ifindex > 0) { + parent_device = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex); + if (parent_device == self) + parent_device = NULL; + } else + parent_device = NULL; + + if (parent_device != priv->parent_device) { + priv->parent_device = parent_device; + changed = TRUE; + } + + if (changed) { + if (priv->parent_ifindex <= 0) + _LOGD (LOGD_DEVICE, "parent: clear"); + else if (!priv->parent_device) + _LOGD (LOGD_DEVICE, "parent: ifindex %d, no device", priv->parent_ifindex); + else { + _LOGD (LOGD_DEVICE, "parent: ifindex %d, device %p, %s", priv->parent_ifindex, + priv->parent_device, nm_device_get_iface (priv->parent_device)); + } + + NM_DEVICE_GET_CLASS (self)->parent_changed_notify (self, old_ifindex, old_device, priv->parent_ifindex, priv->parent_device); + + _notify (self, PROP_PARENT); + } + return changed; +} + +void +nm_device_parent_set_ifindex (NMDevice *self, + int parent_ifindex) +{ + _parent_set_ifindex (self, parent_ifindex, FALSE); +} + +gboolean +nm_device_parent_notify_changed (NMDevice *self, + NMDevice *change_candidate, + gboolean device_removed) +{ + NMDevicePrivate *priv; + + nm_assert (NM_IS_DEVICE (self)); + nm_assert (NM_IS_DEVICE (change_candidate)); + + priv = NM_DEVICE_GET_PRIVATE (self); + + if (priv->parent_ifindex > 0) { + if ( priv->parent_device == change_candidate + || priv->parent_ifindex == nm_device_get_ifindex (change_candidate)) + return _parent_set_ifindex (self, priv->parent_ifindex, device_removed); + } + return FALSE; } /*****************************************************************************/ @@ -1030,6 +1330,8 @@ nm_device_get_priority (NMDevice *self) case NM_DEVICE_TYPE_ETHERNET: case NM_DEVICE_TYPE_VETH: return 100; + case NM_DEVICE_TYPE_MACSEC: + return 125; case NM_DEVICE_TYPE_INFINIBAND: return 150; case NM_DEVICE_TYPE_ADSL: @@ -1293,7 +1595,7 @@ nm_device_get_physical_port_id (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->physical_port_id; } -/***********************************************************/ +/*****************************************************************************/ static gboolean nm_device_uses_generated_assumed_connection (NMDevice *self) @@ -1337,38 +1639,6 @@ find_slave_info (NMDevice *self, NMDevice *slave) return NULL; } -static void -apply_mtu_from_config (NMDevice *self) -{ - const char *method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; - NMSettingIPConfig *s_ip4; - NMSettingWired *s_wired; - guint32 mtu; - - /* Devices having an IPv4 configuration will set MTU during the commit - * stage, so it is an error to call this function if the IPv4 method is not - * 'disabled'. - */ - s_ip4 = (NMSettingIPConfig *) - nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG); - if (s_ip4) - method = nm_setting_ip_config_get_method (s_ip4); - g_return_if_fail (nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)); - - s_wired = (NMSettingWired *) - nm_device_get_applied_setting (self, NM_TYPE_SETTING_WIRED); - - if (s_wired) { - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) { - _LOGD (LOGD_DEVICE | LOGD_IP, - "setting MTU of device without IP4 config to %u", - mtu); - nm_device_set_mtu (self, mtu); - } - } -} - /** * nm_device_master_enslave_slave: * @self: the master device @@ -1429,7 +1699,7 @@ nm_device_master_enslave_slave (NMDevice *self, NMDevice *slave, NMConnection *c /* Since slave devices don't have their own IP configuration, * set the MTU here. */ - apply_mtu_from_config (slave); + _commit_mtu (slave, NM_DEVICE_GET_PRIVATE (slave)->ip4_config); return success; } @@ -1585,7 +1855,7 @@ nm_device_update_dynamic_ip_setup (NMDevice *self) return; } } - if (priv->rdisc) { + if (priv->ndisc) { /* FIXME: todo */ } if (priv->dnsmasq_manager) { @@ -1770,6 +2040,75 @@ device_recheck_slave_status (NMDevice *self, const NMPlatformLink *plink) } } +static void +ndisc_set_router_config (NMNDisc *ndisc, NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + gint32 now; + GArray *addresses, *dns_servers, *dns_domains; + guint len, i; + + if (nm_ndisc_get_node_type (ndisc) != NM_NDISC_NODE_TYPE_ROUTER) + return; + + now = nm_utils_get_monotonic_timestamp_s (); + + len = nm_ip6_config_get_num_addresses (priv->ip6_config); + addresses = g_array_sized_new (FALSE, TRUE, sizeof (NMNDiscAddress), len); + for (i = 0; i < len; i++) { + const NMPlatformIP6Address *addr = nm_ip6_config_get_address (priv->ip6_config, i); + NMNDiscAddress *ndisc_addr; + + if (IN6_IS_ADDR_LINKLOCAL (&addr->address)) + continue; + + if ( addr->n_ifa_flags & IFA_F_TENTATIVE + || addr->n_ifa_flags & IFA_F_DADFAILED) + continue; + + if (addr->plen != 64) + continue; + + g_array_set_size (addresses, addresses->len+1); + ndisc_addr = &g_array_index (addresses, NMNDiscAddress, addresses->len-1); + ndisc_addr->address = addr->address; + ndisc_addr->timestamp = addr->timestamp; + ndisc_addr->lifetime = addr->lifetime; + ndisc_addr->preferred = addr->preferred; + } + + len = nm_ip6_config_get_num_nameservers (priv->ip6_config); + dns_servers = g_array_sized_new (FALSE, TRUE, sizeof (NMNDiscDNSServer), len); + g_array_set_size (dns_servers, len); + for (i = 0; i < len; i++) { + const struct in6_addr *nameserver = nm_ip6_config_get_nameserver (priv->ip6_config, i); + NMNDiscDNSServer *ndisc_nameserver; + + ndisc_nameserver = &g_array_index (dns_servers, NMNDiscDNSServer, i); + ndisc_nameserver->address = *nameserver; + ndisc_nameserver->timestamp = now; + ndisc_nameserver->lifetime = NM_NDISC_ROUTER_LIFETIME; + } + + len = nm_ip6_config_get_num_searches (priv->ip6_config); + dns_domains = g_array_sized_new (FALSE, TRUE, sizeof (NMNDiscDNSDomain), len); + g_array_set_size (dns_domains, len); + for (i = 0; i < len; i++) { + const char *search = nm_ip6_config_get_search (priv->ip6_config, i); + NMNDiscDNSDomain *ndisc_search; + + ndisc_search = &g_array_index (dns_domains, NMNDiscDNSDomain, i); + ndisc_search->domain = (char *) search; + ndisc_search->timestamp = now; + ndisc_search->lifetime = NM_NDISC_ROUTER_LIFETIME; + } + + nm_ndisc_set_config (ndisc, addresses, dns_servers, dns_domains); + g_array_unref (addresses); + g_array_unref (dns_servers); + g_array_unref (dns_domains); +} + static gboolean device_link_changed (NMDevice *self) { @@ -1808,7 +2147,6 @@ device_link_changed (NMDevice *self) _notify (self, PROP_DRIVER); } - /* Update MTU if it has changed. */ if (priv->mtu != info.mtu) { priv->mtu = info.mtu; _notify (self, PROP_MTU); @@ -1855,15 +2193,17 @@ device_link_changed (NMDevice *self) nm_device_emit_recheck_auto_activate (self); } - if (priv->rdisc && info.inet6_token.id) { - if (nm_rdisc_set_iid (priv->rdisc, info.inet6_token)) { + if (priv->ndisc && info.inet6_token.id) { + if (nm_ndisc_set_iid (priv->ndisc, info.inet6_token)) _LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface); - nm_rdisc_start (priv->rdisc); - } } - if (klass->link_changed) - klass->link_changed (self, &info); + /* Update carrier from link event if applicable. */ + if ( nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT) + && !nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) + nm_device_set_carrier (self, pllink->connected); + + klass->link_changed (self, &info); /* Update DHCP, etc, if needed */ if (ip_ifname_changed) @@ -1953,28 +2293,21 @@ device_ip_link_changed (NMDevice *self) _stats_update_counters_from_pllink (self, pllink); - if (pllink->name[0] && g_strcmp0 (priv->ip_iface, pllink->name)) { - _LOGI (LOGD_DEVICE, "interface index %d renamed ip_iface (%d) from '%s' to '%s'", - priv->ifindex, nm_device_get_ip_ifindex (self), - priv->ip_iface, pllink->name); - g_free (priv->ip_iface); - priv->ip_iface = g_strdup (pllink->name); - - _notify (self, PROP_IP_IFACE); + if (_ip_iface_update (self, pllink->name)) nm_device_update_dynamic_ip_setup (self); - } return G_SOURCE_REMOVE; } static void link_changed_cb (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, NMPlatformLink *info, - NMPlatformSignalChangeType change_type, + int change_type_i, NMDevice *self) { + const NMPlatformSignalChangeType change_type = change_type_i; NMDevicePrivate *priv; if (change_type != NM_PLATFORM_SIGNAL_CHANGED) @@ -1996,12 +2329,9 @@ link_changed_cb (NMPlatform *platform, } static void -link_changed (NMDevice *self, NMPlatformLink *info) +link_changed (NMDevice *self, const NMPlatformLink *pllink) { - /* Update carrier from link event if applicable. */ - if ( nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT) - && !nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) - nm_device_set_carrier (self, info->connected); + /* stub implementation of virtual function to allow subclasses to chain up. */ } static gboolean @@ -2161,8 +2491,10 @@ update_device_from_platform_link (NMDevice *self, const NMPlatformLink *plink) _notify (self, PROP_IFACE); } - priv->ifindex = plink->ifindex; - _notify (self, PROP_IFINDEX); + if (priv->ifindex != plink->ifindex) { + priv->ifindex = plink->ifindex; + _notify (self, PROP_IFINDEX); + } priv->up = NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP); if (plink->driver && g_strcmp0 (plink->driver, priv->driver) != 0) { @@ -2196,11 +2528,12 @@ check_carrier (NMDevice *self) } static void -realize_start_notify (NMDevice *self, const NMPlatformLink *plink) +realize_start_notify (NMDevice *self, + const NMPlatformLink *pllink) { - /* Stub implementation for realize_start_notify(). It does nothing, - * but allows derived classes to uniformly invoke the parent - * implementation. */ + /* the default implementation of realize_start_notify() just calls + * link_changed() -- which by default does nothing. */ + NM_DEVICE_GET_CLASS (self)->link_changed (self, pllink); } /** @@ -2223,6 +2556,7 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) NMDeviceCapabilities capabilities = 0; NMConfig *config; guint real_rate; + guint32 mtu; g_return_if_fail (NM_IS_DEVICE (self)); @@ -2243,6 +2577,15 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) /* Balanced by a thaw in nm_device_realize_finish() */ g_object_freeze_notify (G_OBJECT (self)); + priv->mtu_initialized = FALSE; + priv->mtu_initial = 0; + priv->ip6_mtu_initial = 0; + priv->ip6_mtu = 0; + if (priv->mtu) { + priv->mtu = 0; + _notify (self, PROP_MTU); + } + if (plink) { g_return_if_fail (link_type_compatible (self, plink->type, NULL, NULL)); update_device_from_platform_link (self, plink); @@ -2258,8 +2601,11 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) if (nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex)) capabilities |= NM_DEVICE_CAP_IS_SOFTWARE; - priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex); - _notify (self, PROP_MTU); + mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex); + if (priv->mtu != mtu) { + priv->mtu = mtu; + _notify (self, PROP_MTU); + } nm_platform_link_get_driver_info (NM_PLATFORM_GET, priv->ifindex, @@ -2460,15 +2806,21 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) NM_DEVICE_GET_CLASS (self)->unrealize_notify (self); + _parent_set_ifindex (self, 0, FALSE); + if (priv->ifindex > 0) { priv->ifindex = 0; _notify (self, PROP_IFINDEX); } priv->ip_ifindex = 0; - if (priv->ip_iface) { - g_clear_pointer (&priv->ip_iface, g_free); + if (nm_clear_g_free (&priv->ip_iface)) _notify (self, PROP_IP_IFACE); + + if (priv->mtu != 0) { + priv->mtu = 0; + _notify (self, PROP_MTU); } + if (priv->driver_version) { g_clear_pointer (&priv->driver_version, g_free); _notify (self, PROP_DRIVER_VERSION); @@ -2535,27 +2887,6 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) return TRUE; } -/** - * nm_device_notify_new_device_added(): - * @self: the #NMDevice - * @device: the newly added device - * - * Called by the manager to notify the device that a new device has - * been found and added. - */ -void -nm_device_notify_new_device_added (NMDevice *self, NMDevice *device) -{ - NMDeviceClass *klass; - - g_return_if_fail (NM_IS_DEVICE (self)); - g_return_if_fail (NM_IS_DEVICE (device)); - - klass = NM_DEVICE_GET_CLASS (self); - if (klass->notify_new_device_added) - klass->notify_new_device_added (self, device); -} - /** * nm_device_notify_component_added(): * @self: the #NMDevice @@ -2896,8 +3227,8 @@ nm_device_slave_notify_enslave (NMDevice *self, gboolean success) } if (activating) { - priv->ip4_state = IP_DONE; - priv->ip6_state = IP_DONE; + _set_ip_state (self, AF_INET, IP_DONE); + _set_ip_state (self, AF_INET6, IP_DONE); if (success) nm_device_queue_state (self, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE); else @@ -3161,6 +3492,8 @@ can_auto_connect (NMDevice *self, { NMSettingConnection *s_con; + nm_assert (!specific_object || !*specific_object); + s_con = nm_connection_get_setting_connection (connection); if (!nm_setting_connection_get_autoconnect (s_con)) return FALSE; @@ -3585,9 +3918,9 @@ recheck_available (gpointer user_data) if (new_state > NM_DEVICE_STATE_UNKNOWN) { _LOGD (LOGD_DEVICE, "is %savailable, %s %s", - now_available ? "" : "not ", - new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to", - state_to_string (new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state)); + now_available ? "" : "not ", + new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to", + state_to_string (new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state)); priv->recheck_available.available_reason = NM_DEVICE_STATE_REASON_NONE; priv->recheck_available.unavailable_reason = NM_DEVICE_STATE_REASON_NONE; @@ -3877,7 +4210,8 @@ activate_stage1_device_prepare (NMDevice *self) NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMActiveConnection *active = NM_ACTIVE_CONNECTION (priv->act_request); - priv->ip4_state = priv->ip6_state = IP_NONE; + _set_ip_state (self, AF_INET, IP_NONE); + _set_ip_state (self, AF_INET6, IP_NONE); /* Notify the new ActiveConnection along with the state change */ _notify (self, PROP_ACTIVE_CONNECTION); @@ -3977,7 +4311,7 @@ activate_stage2_device_config (NMDevice *self) nm_device_queue_recheck_assume (info->slave); } - if (lldp_rx_enabled (self)) { + if (lldp_rx_enabled (self) && priv->ifindex > 0) { gs_free_error GError *error = NULL; gconstpointer addr; size_t addr_length; @@ -4057,39 +4391,81 @@ nm_device_activate_schedule_stage2_device_config (NMDevice *self) } /* - * check_ip_failed + * check_ip_state * - * Progress the device to appropriate state if both IPv4 and IPv6 failed + * Transition the device from IP_CONFIG to the next state according to the + * outcome of IPv4 and IPv6 configuration. @may_fail indicates that we are + * called just after the initial configuration and thus IPv4/IPv6 are allowed to + * fail if the ipvx.may-fail properties say so, because the IP methods couldn't + * even be started. */ static void -check_ip_failed (NMDevice *self, gboolean may_fail) +check_ip_state (NMDevice *self, gboolean may_fail) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + gboolean ip4_disabled = FALSE, ip6_ignore = FALSE; + NMSettingIPConfig *s_ip4, *s_ip6; NMDeviceState state; - if ( priv->ip4_state != IP_FAIL - || priv->ip6_state != IP_FAIL) + if (nm_device_get_state (self) != NM_DEVICE_STATE_IP_CONFIG) return; - if (nm_device_uses_assumed_connection (self)) { - /* We have assumed configuration, but couldn't - * redo it. No problem, move to check state. */ - priv->ip4_state = priv->ip6_state = IP_DONE; - state = NM_DEVICE_STATE_IP_CHECK; - } else if ( may_fail - && get_ip_config_may_fail (self, AF_INET) - && get_ip_config_may_fail (self, AF_INET6)) { - /* Couldn't start either IPv6 and IPv4 autoconfiguration, - * but both are allowed to fail. */ - state = NM_DEVICE_STATE_SECONDARIES; - } else { - /* Autoconfiguration attempted without success. */ - state = NM_DEVICE_STATE_FAILED; + s_ip4 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG); + if (s_ip4 && nm_streq0 (nm_setting_ip_config_get_method (s_ip4), + NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) + ip4_disabled = TRUE; + + s_ip6 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG); + if (s_ip6 && nm_streq0 (nm_setting_ip_config_get_method (s_ip6), + NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) + ip6_ignore = TRUE; + + if ( priv->ip4_state == IP_DONE + && priv->ip6_state == IP_DONE) { + /* Both method completed (or disabled), proceed with activation */ + nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE); + return; } - nm_device_state_changed (self, - state, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + if ( (priv->ip4_state == IP_FAIL || (ip4_disabled && priv->ip4_state == IP_DONE)) + && (priv->ip6_state == IP_FAIL || (ip6_ignore && priv->ip6_state == IP_DONE))) { + /* Either both methods failed, or only one failed and the other is + * disabled */ + if (nm_device_uses_assumed_connection (self)) { + /* We have assumed configuration, but couldn't redo it. No problem, + * move to check state. */ + _set_ip_state (self, AF_INET, IP_DONE); + _set_ip_state (self, AF_INET6, IP_DONE); + state = NM_DEVICE_STATE_IP_CHECK; + } else if ( may_fail + && get_ip_config_may_fail (self, AF_INET) + && get_ip_config_may_fail (self, AF_INET6)) { + /* Couldn't start either IPv6 and IPv4 autoconfiguration, + * but both are allowed to fail. */ + state = NM_DEVICE_STATE_SECONDARIES; + } else { + /* Autoconfiguration attempted without success. */ + state = NM_DEVICE_STATE_FAILED; + } + + nm_device_state_changed (self, + state, + NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + return; + } + + /* If a method is still pending but required, wait */ + if (priv->ip4_state != IP_DONE && !get_ip_config_may_fail (self, AF_INET)) + return; + if (priv->ip6_state != IP_DONE && !get_ip_config_may_fail (self, AF_INET6)) + return; + + /* If at least a method has completed, proceed with activation */ + if ( (priv->ip4_state == IP_DONE && !ip4_disabled) + || (priv->ip6_state == IP_DONE && !ip6_ignore)) { + nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE); + return; + } } void @@ -4099,42 +4475,18 @@ nm_device_ip_method_failed (NMDevice *self, int family, NMDeviceStateReason reas g_return_if_fail (NM_IS_DEVICE (self)); g_return_if_fail (family == AF_INET || family == AF_INET6); + priv = NM_DEVICE_GET_PRIVATE (self); - if (family == AF_INET) - priv->ip4_state = IP_FAIL; - else - priv->ip6_state = IP_FAIL; + _set_ip_state (self, family, IP_FAIL); if (get_ip_config_may_fail (self, family)) - check_ip_failed (self, FALSE); + check_ip_state (self, FALSE); else nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); } -/* - * check_ip_done - * - * Progress the device to ip connectivity check state if IPv4 or IPv6 succeeded - */ -static void -check_ip_done (NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - - if (nm_device_get_state (self) != NM_DEVICE_STATE_IP_CONFIG) - return; - - if (priv->ip4_state != IP_DONE && !get_ip_config_may_fail (self, AF_INET)) - return; - - if (priv->ip6_state != IP_DONE && !get_ip_config_may_fail (self, AF_INET6)) - return; - - nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE); -} - -/*********************************************/ +/*****************************************************************************/ /* IPv4 DAD stuff */ static guint @@ -4318,7 +4670,7 @@ ipv4_dad_start (NMDevice *self, NMIP4Config **configs, ArpingCallback cb) } } -/*********************************************/ +/*****************************************************************************/ /* IPv4LL stuff */ static void @@ -4509,7 +4861,7 @@ fail: return NM_ACT_STAGE_RETURN_FAILURE; } -/*********************************************/ +/*****************************************************************************/ static gboolean _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlatformIPRoute *out_route) @@ -4555,7 +4907,7 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat return success; } -/*********************************************/ +/*****************************************************************************/ static void ensure_con_ip4_config (NMDevice *self) @@ -4609,7 +4961,7 @@ ensure_con_ip6_config (NMDevice *self) } } -/*********************************************/ +/*****************************************************************************/ /* DHCPv4 stuff */ static void @@ -4813,7 +5165,6 @@ END_ADD_DEFAULT_ROUTE: priv->default_route.v4_has = _device_get_default_route_from_platform (self, AF_INET, (NMPlatformIPRoute *) &priv->default_route.v4); } - /* Allow setting MTU etc */ if (commit) { if (NM_DEVICE_GET_CLASS (self)->ip4_config_pre_commit) NM_DEVICE_GET_CLASS (self)->ip4_config_pre_commit (self, composite); @@ -4959,6 +5310,8 @@ dhcp4_state_changed (NMDhcpClient *client, break; } + nm_device_set_proxy_config (self, options); + nm_dhcp4_config_set_options (priv->dhcp4.config, options); _notify (self, PROP_DHCP4_CONFIG); priv->dhcp4.num_tries_left = DHCP_NUM_TRIES_MAX; @@ -5105,7 +5458,7 @@ nm_device_dhcp4_renew (NMDevice *self, gboolean release) return (ret != NM_ACT_STAGE_RETURN_FAILURE); } -/*********************************************/ +/*****************************************************************************/ static GHashTable *shared_ips = NULL; @@ -5175,7 +5528,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection, NMDeviceStateReaso return config; } -/*********************************************/ +/*****************************************************************************/ static gboolean connection_ip4_method_requires_carrier (NMConnection *connection, @@ -5201,6 +5554,7 @@ connection_ip6_method_requires_carrier (NMConnection *connection, static const char *ip6_carrier_methods[] = { NM_SETTING_IP6_CONFIG_METHOD_AUTO, NM_SETTING_IP6_CONFIG_METHOD_DHCP, + NM_SETTING_IP6_CONFIG_METHOD_SHARED, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL, NULL }; @@ -5296,7 +5650,7 @@ act_stage3_ip4_config_start (NMDevice *self, && !priv->carrier) { _LOGI (LOGD_IP4 | LOGD_DEVICE, "IPv4 config waiting until carrier is on"); - return NM_ACT_STAGE_RETURN_WAIT; + return NM_ACT_STAGE_RETURN_IP_WAIT; } if (priv->is_master && ip4_requires_slaves (connection)) { @@ -5310,7 +5664,7 @@ act_stage3_ip4_config_start (NMDevice *self, if (ready_slaves == FALSE) { _LOGI (LOGD_DEVICE | LOGD_IP4, "IPv4 config waiting until slaves are ready"); - return NM_ACT_STAGE_RETURN_WAIT; + return NM_ACT_STAGE_RETURN_IP_WAIT; } } @@ -5335,23 +5689,25 @@ act_stage3_ip4_config_start (NMDevice *self, ipv4_dad_start (self, configs, ipv4_manual_method_apply); ret = NM_ACT_STAGE_RETURN_POSTPONE; } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) { - *out_config = shared4_new_config (self, connection, reason); - if (*out_config) { - priv->dnsmasq_manager = nm_dnsmasq_manager_new (nm_device_get_ip_iface (self)); - ret = NM_ACT_STAGE_RETURN_SUCCESS; + if (out_config) { + *out_config = shared4_new_config (self, connection, reason); + if (*out_config) { + priv->dnsmasq_manager = nm_dnsmasq_manager_new (nm_device_get_ip_iface (self)); + ret = NM_ACT_STAGE_RETURN_SUCCESS; + } else + ret = NM_ACT_STAGE_RETURN_FAILURE; } else - ret = NM_ACT_STAGE_RETURN_FAILURE; + g_return_val_if_reached (NM_ACT_STAGE_RETURN_FAILURE); } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) { - apply_mtu_from_config (self); - /* Nothing else to do... */ - ret = NM_ACT_STAGE_RETURN_STOP; + _commit_mtu (self, priv->ip4_config); + ret = NM_ACT_STAGE_RETURN_SUCCESS; } else _LOGW (LOGD_IP4, "unhandled IPv4 config method '%s'; will fail", method); return ret; } -/*********************************************/ +/*****************************************************************************/ /* DHCPv6 stuff */ static void @@ -5359,13 +5715,14 @@ dhcp6_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - priv->dhcp6.mode = NM_RDISC_DHCP_LEVEL_NONE; + priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_NONE; g_clear_object (&priv->dhcp6.ip6_config); g_clear_pointer (&priv->dhcp6.event_id, g_free); nm_clear_g_source (&priv->dhcp6.restart_id); if (priv->dhcp6.client) { nm_clear_g_signal_handler (priv->dhcp6.client, &priv->dhcp6.state_sigid); + nm_clear_g_signal_handler (priv->dhcp6.client, &priv->dhcp6.prefix_sigid); if ( cleanup_type == CLEANUP_TYPE_DECONFIGURE || cleanup_type == CLEANUP_TYPE_REMOVED) @@ -5433,8 +5790,8 @@ ip6_config_merge_and_apply (NMDevice *self, /* If no config was passed in, create a new one */ composite = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); nm_ip6_config_set_privacy (composite, - priv->rdisc ? - priv->rdisc_use_tempaddr : + priv->ndisc ? + priv->ndisc_use_tempaddr : NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); init_ip6_config_dns_priority (self, composite); @@ -5576,9 +5933,6 @@ END_ADD_DEFAULT_ROUTE: nm_device_get_ip_ifindex (self), iid); } - - if (NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit) - NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit (self, composite); } routes_full_sync = commit @@ -5685,7 +6039,7 @@ dhcp6_fail (NMDevice *self, gboolean timeout) dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE); - if (priv->dhcp6.mode == NM_RDISC_DHCP_LEVEL_MANAGED) { + if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED) { /* Don't fail if there are static addresses configured on * the device, instead retry after some time. */ @@ -5731,7 +6085,7 @@ dhcp6_timeout (NMDevice *self, NMDhcpClient *client) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - if (priv->dhcp6.mode == NM_RDISC_DHCP_LEVEL_MANAGED) + if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED) dhcp6_fail (self, TRUE); else { /* not a hard failure; just live with the RA info */ @@ -5808,7 +6162,7 @@ dhcp6_state_changed (NMDhcpClient *client, * may exit right after getting a response from the server. That's * normal. In that case we just ignore the exit. */ - if (priv->dhcp6.mode == NM_RDISC_DHCP_LEVEL_OTHERCONF) + if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) break; /* Otherwise, fall through */ case NM_DHCP_STATE_FAIL: @@ -5819,6 +6173,19 @@ dhcp6_state_changed (NMDhcpClient *client, } } +static void +dhcp6_prefix_delegated (NMDhcpClient *client, + NMPlatformIP6Address *prefix, + gpointer user_data) +{ + NMDevice *self = NM_DEVICE (user_data); + + /* Just re-emit. The device just contributes the prefix to the + * pool in NMPolicy, which decides about subnet allocation + * on the shared devices. */ + g_signal_emit (self, signals[IP6_PREFIX_DELEGATED], 0, prefix); +} + static gboolean dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection) { @@ -5855,8 +6222,9 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection) nm_setting_ip_config_get_dhcp_hostname (s_ip6), priv->dhcp_timeout, priv->dhcp_anycast_address, - (priv->dhcp6.mode == NM_RDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE, - nm_setting_ip6_config_get_ip6_privacy (NM_SETTING_IP6_CONFIG (s_ip6))); + (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE, + nm_setting_ip6_config_get_ip6_privacy (NM_SETTING_IP6_CONFIG (s_ip6)), + priv->dhcp6.needed_prefixes); if (tmp) g_byte_array_free (tmp, TRUE); @@ -5865,6 +6233,10 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection) NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, G_CALLBACK (dhcp6_state_changed), self); + priv->dhcp6.prefix_sigid = g_signal_connect (priv->dhcp6.client, + NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED, + G_CALLBACK (dhcp6_prefix_delegated), + self); } return !!priv->dhcp6.client; @@ -5902,7 +6274,7 @@ dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason) } /* success; already have the LL address; kick off DHCP */ - g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS || ret == NM_ACT_STAGE_RETURN_FINISH); + g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); } if (!dhcp6_start_with_link_ready (self, connection)) { @@ -5929,7 +6301,96 @@ nm_device_dhcp6_renew (NMDevice *self, gboolean release) return dhcp6_start (self, FALSE, NULL); } -/******************************************/ +/*****************************************************************************/ + +/* + * Called on the requesting interface when a subnet can't be obtained + * from known prefixes for a newly active shared connection. + */ +void +nm_device_request_ip6_prefixes (NMDevice *self, int needed_prefixes) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + priv->dhcp6.needed_prefixes = needed_prefixes; + + if (priv->dhcp6.client) { + _LOGD (LOGD_IP6, "ipv6-pd: asking DHCPv6 for %d prefixes", needed_prefixes); + nm_device_dhcp6_renew (self, FALSE); + } else { + _LOGI (LOGD_IP6, "ipv6-pd: device doesn't use DHCPv6, can't request prefixes"); + } +} + +gboolean +nm_device_needs_ip6_subnet (NMDevice *self) +{ + return NM_DEVICE_GET_PRIVATE (self)->needs_ip6_subnet; +} + +/* + * Called on the ipv6.method=shared interface when a new subnet is allocated + * or the prefix from which it is allocated is renewed. + */ +void +nm_device_use_ip6_subnet (NMDevice *self, const NMPlatformIP6Address *subnet) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMPlatformIP6Address address = *subnet; + + if (!priv->ac_ip6_config) + priv->ac_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); + + /* Assign a ::1 address in the subnet for us. */ + address.address.s6_addr32[3] |= htonl (1); + nm_ip6_config_add_address (priv->ac_ip6_config, &address); + + _LOGD (LOGD_IP6, "ipv6-pd: using %s address (preferred for %u seconds)", + nm_utils_inet6_ntop (&address.address, NULL), + subnet->preferred); + + /* This also updates the ndisc if there are actual changes. */ + if (!ip6_config_merge_and_apply (self, TRUE, NULL)) + _LOGW (LOGD_IP6, "ipv6-pd: failed applying IP6 config for connection sharing"); +} + +/* + * Called whenever the policy picks a default IPv6 device. + * The ipv6.method=shared devices just reuse its DNS configuration. + */ +void +nm_device_copy_ip6_dns_config (NMDevice *self, NMDevice *from_device) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMIP6Config *from_config = NULL; + int i; + + if (priv->ac_ip6_config) { + nm_ip6_config_reset_nameservers (priv->ac_ip6_config); + nm_ip6_config_reset_searches (priv->ac_ip6_config); + } else + priv->ac_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); + + if (from_device) + from_config = nm_device_get_ip6_config (from_device); + if (!from_config) + return; + + for (i = 0; i < nm_ip6_config_get_num_nameservers (from_config); i++) { + nm_ip6_config_add_nameserver (priv->ac_ip6_config, + nm_ip6_config_get_nameserver (from_config, i)); + } + + for (i = 0; i < nm_ip6_config_get_num_searches (from_config); i++) { + nm_ip6_config_add_search (priv->ac_ip6_config, + nm_ip6_config_get_search (from_config, i)); + } + + if (!ip6_config_merge_and_apply (self, TRUE, NULL)) + _LOGW (LOGD_IP6, "ipv6-pd: failed applying DNS config for connection sharing"); +} + +/*****************************************************************************/ static void linklocal6_cleanup (NMDevice *self) @@ -5975,7 +6436,8 @@ linklocal6_complete (NMDevice *self) _LOGD (LOGD_DEVICE, "linklocal6: waiting for link-local addresses successful, continue with method %s", method); - if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0) { + if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 + || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) { if (!addrconf6_start_with_link_ready (self)) { /* Time out IPv6 instead of failing the entire activation */ nm_device_activate_schedule_ip6_config_timeout (self); @@ -6030,7 +6492,7 @@ check_and_add_ipv6ll_addr (NMDevice *self) NMUtilsStableType stable_type; const char *stable_id; - stable_id = _get_stable_id (connection, &stable_type); + stable_id = _get_stable_id (self, connection, &stable_type); if ( !stable_id || !nm_utils_ipv6_addr_set_stable_privacy (stable_type, &lladdr, @@ -6089,7 +6551,7 @@ linklocal6_start (NMDevice *self) if ( priv->ip6_config && nm_ip6_config_get_address_first_nontentative (priv->ip6_config, TRUE)) - return NM_ACT_STAGE_RETURN_FINISH; + return NM_ACT_STAGE_RETURN_SUCCESS; connection = nm_device_get_applied_connection (self); g_assert (connection); @@ -6109,64 +6571,198 @@ linklocal6_start (NMDevice *self) return NM_ACT_STAGE_RETURN_POSTPONE; } -/******************************************/ +/*****************************************************************************/ + +gint64 +nm_device_get_configured_mtu_from_connection_default (NMDevice *self, + const char *property_name) +{ + gs_free char *str = NULL; -static void nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu); + str = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, property_name, self); + return _nm_utils_ascii_str_to_int64 (str, 10, 0, G_MAXUINT32, -1); +} -static void -nm_device_set_mtu (NMDevice *self, guint32 mtu) +guint32 +nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - int ifindex = nm_device_get_ip_ifindex (self); + NMConnection *connection; + NMSettingWired *setting; + gint64 mtu_default; + guint32 mtu; + + nm_assert (NM_IS_DEVICE (self)); + nm_assert (out_is_user_config); + + connection = nm_device_get_applied_connection (self); + if (!connection) + g_return_val_if_reached (0); + + setting = nm_connection_get_setting_wired (connection); - if (mtu) - priv->mtu = mtu; + if (setting) { + mtu = nm_setting_wired_get_mtu (setting); + if (mtu) { + *out_is_user_config = TRUE; + return mtu; + } + } - /* Ensure the IPv6 MTU is still alright. */ - if (priv->ip6_mtu) - nm_device_ipv6_set_mtu (self, priv->ip6_mtu); + mtu_default = nm_device_get_configured_mtu_from_connection_default (self, "ethernet.mtu"); + if (mtu_default >= 0) { + *out_is_user_config = TRUE; + return (guint32) mtu_default; + } - if (priv->mtu && priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex)) - nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu); + *out_is_user_config = FALSE; + return NM_DEVICE_DEFAULT_MTU_WIRED; } +/*****************************************************************************/ + static void -nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu) +_commit_mtu (NMDevice *self, const NMIP4Config *config) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - guint32 plat_mtu = nm_device_ipv6_sysctl_get_int32 (self, "mtu", priv->mtu); - char val[16]; + guint32 ip6_mtu, ip6_mtu_orig; + guint32 mtu_desired, mtu_desired_orig; + guint32 mtu_plat; + struct { + gboolean initialized; + guint32 value; + } ip6_mtu_sysctl; + int ifindex; + char sbuf[64], sbuf1[64], sbuf2[64]; + + ifindex = nm_device_get_ip_ifindex (self); + if (ifindex <= 0) + return; + + if (nm_device_uses_assumed_connection (self)) { + /* for assumed connections we don't tamper with the MTU. This is + * a bug and supposed to be fixed by the unmanaged/assumed rework. */ + return; + } + + { + gboolean mtu_is_user_config = FALSE; + guint32 mtu = 0; + + /* preferably, get the MTU from explict user-configuration. + * Only if that fails, look at the current @config (which contains + * MTUs from DHCP/PPP) or maybe fallback to a device-specific MTU. */ + + if (NM_DEVICE_GET_CLASS (self)->get_configured_mtu) + mtu = NM_DEVICE_GET_CLASS (self)->get_configured_mtu (self, &mtu_is_user_config); + + if (mtu_is_user_config) + mtu_desired = mtu; + else { + if (config) + mtu_desired = nm_ip4_config_get_mtu (config); + else + mtu_desired = 0; + if (!mtu_desired && !priv->mtu_initialized) { + /* there is no MTU specified, and this is the first commit of the MTU. + * Reset a per-device MTU default, as returned from get_configured_mtu(). + * + * The device might choose not to return a default MTU via get_configured_mtu() + * to suppress this behavior. */ + mtu_desired = mtu; + } + } + } - priv->ip6_mtu = mtu ?: plat_mtu; + if (mtu_desired && mtu_desired < 1280) { + NMSettingIPConfig *s_ip6; - if (priv->ip6_mtu && priv->mtu && priv->mtu < priv->ip6_mtu) { - _LOGI (LOGD_DEVICE | LOGD_IP6, "Lowering IPv6 MTU (%d) to match device MTU (%d)", - priv->ip6_mtu, priv->mtu); - priv->ip6_mtu = priv->mtu; + s_ip6 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG); + if (s_ip6 && nm_streq0 (nm_setting_ip_config_get_method (s_ip6), + NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + /* the interface has IPv6 enabled. The MTU with IPv6 cannot be smaller + * then 1280. + * + * For slave-devices (that don't have @s_ip6 we) don't do this fixup because + * it's anyway an unsolved problem when the slave configures a conflicting + * MTU. */ + mtu_desired = 1280; + } } - if (priv->ip6_mtu && priv->ip6_mtu < 1280) { - _LOGI (LOGD_DEVICE | LOGD_IP6, "IPv6 MTU (%d) smaller than 1280, adjusting", - priv->ip6_mtu); - priv->ip6_mtu = 1280; + ip6_mtu = priv->ip6_mtu; + if (!ip6_mtu && !priv->mtu_initialized) { + /* initially, if the IPv6 MTU is not specified, grow it as large as the + * link MTU @mtu_desired. Only exception is, if @mtu_desired is so small + * to disable IPv6. */ + if (mtu_desired >= 1280) + ip6_mtu = mtu_desired; } - if (priv->ip6_mtu && priv->mtu && priv->mtu < priv->ip6_mtu) { - _LOGI (LOGD_DEVICE | LOGD_IP6, "Raising device MTU (%d) to match IPv6 MTU (%d)", - priv->mtu, priv->ip6_mtu); - nm_device_set_mtu (self, priv->ip6_mtu); + priv->mtu_initialized = TRUE; + + if (!ip6_mtu && !mtu_desired) + return; + + mtu_desired_orig = mtu_desired; + ip6_mtu_orig = ip6_mtu; + + mtu_plat = nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex); + + if (ip6_mtu) { + ip6_mtu = NM_MAX (1280, ip6_mtu); + + if (!mtu_desired) + mtu_desired = mtu_plat; + + if (mtu_desired) { + mtu_desired = NM_MAX (1280, mtu_desired); + + if (mtu_desired < ip6_mtu) + ip6_mtu = mtu_desired; + } } - if (priv->ip6_mtu != plat_mtu) { - g_snprintf (val, sizeof (val), "%d", mtu); - nm_device_ipv6_sysctl_set (self, "mtu", val); + _LOGT (LOGD_DEVICE, "mtu: device-mtu: %u%s, ipv6-mtu: %u%s, ifindex: %d", + (guint) mtu_desired, + mtu_desired == mtu_desired_orig ? "" : nm_sprintf_buf (sbuf1, " (was %u)", (guint) mtu_desired_orig), + (guint) ip6_mtu, + ip6_mtu == ip6_mtu_orig ? "" : nm_sprintf_buf (sbuf2, " (was %u)", (guint) ip6_mtu_orig), + ifindex); + + ip6_mtu_sysctl.initialized = FALSE; +#define _IP6_MTU_SYS() \ + ({ \ + if (!ip6_mtu_sysctl.initialized) { \ + ip6_mtu_sysctl.value = nm_device_ipv6_sysctl_get_uint32 (self, "mtu", 0); \ + ip6_mtu_sysctl.initialized = TRUE; \ + } \ + ip6_mtu_sysctl.value; \ + }) + if ( (mtu_desired && mtu_desired != mtu_plat) + || (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) { + + if (!priv->mtu_initial && !priv->ip6_mtu_initial) { + /* before touching any of the MTU paramters, record the + * original setting to restore on deactivation. */ + priv->mtu_initial = mtu_plat; + priv->ip6_mtu_initial = _IP6_MTU_SYS (); + } + + if (mtu_desired && mtu_desired != mtu_plat) + nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, mtu_desired); + + if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) { + nm_device_ipv6_sysctl_set (self, "mtu", + nm_sprintf_buf (sbuf, "%u", (unsigned) ip6_mtu)); + } } +#undef _IP6_MTU_SYS } static void -rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_int, NMDevice *self) +ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, NMDevice *self) { - NMRDiscConfigMap changed = changed_int; + NMNDiscConfigMap changed = changed_int; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); int i; int system_support; @@ -6182,8 +6778,8 @@ rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_in if (system_support) ifa_flags = IFA_F_NOPREFIXROUTE; - if ( priv->rdisc_use_tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR - || priv->rdisc_use_tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR) + if ( priv->ndisc_use_tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR + || priv->ndisc_use_tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR) { /* without system_support, this flag will be ignored. Still set it, doesn't seem to do any harm. */ ifa_flags |= IFA_F_MANAGETEMPADDR; @@ -6194,25 +6790,25 @@ rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_in if (!priv->ac_ip6_config) priv->ac_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); - if (changed & NM_RDISC_CONFIG_GATEWAYS) { - /* Use the first gateway as ordered in router discovery cache. */ + if (changed & NM_NDISC_CONFIG_GATEWAYS) { + /* Use the first gateway as ordered in neighbor discovery cache. */ if (rdata->gateways_n) nm_ip6_config_set_gateway (priv->ac_ip6_config, &rdata->gateways[0].address); else nm_ip6_config_set_gateway (priv->ac_ip6_config, NULL); } - if (changed & NM_RDISC_CONFIG_ADDRESSES) { - /* Rebuild address list from router discovery cache. */ + if (changed & NM_NDISC_CONFIG_ADDRESSES) { + /* Rebuild address list from neighbor discovery cache. */ nm_ip6_config_reset_addresses (priv->ac_ip6_config); - /* rdisc->addresses contains at most max_addresses entries. + /* ndisc->addresses contains at most max_addresses entries. * This is different from what the kernel does, which * also counts static and temporary addresses when checking * max_addresses. **/ for (i = 0; i < rdata->addresses_n; i++) { - const NMRDiscAddress *discovered_address = &rdata->addresses[i]; + const NMNDiscAddress *discovered_address = &rdata->addresses[i]; NMPlatformIP6Address address; memset (&address, 0, sizeof (address)); @@ -6223,24 +6819,24 @@ rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_in address.preferred = discovered_address->preferred; if (address.preferred > address.lifetime) address.preferred = address.lifetime; - address.addr_source = NM_IP_CONFIG_SOURCE_RDISC; + address.addr_source = NM_IP_CONFIG_SOURCE_NDISC; address.n_ifa_flags = ifa_flags; nm_ip6_config_add_address (priv->ac_ip6_config, &address); } } - if (changed & NM_RDISC_CONFIG_ROUTES) { - /* Rebuild route list from router discovery cache. */ + if (changed & NM_NDISC_CONFIG_ROUTES) { + /* Rebuild route list from neighbor discovery cache. */ nm_ip6_config_reset_routes (priv->ac_ip6_config); for (i = 0; i < rdata->routes_n; i++) { - const NMRDiscRoute *discovered_route = &rdata->routes[i]; + const NMNDiscRoute *discovered_route = &rdata->routes[i]; const NMPlatformIP6Route route = { .network = discovered_route->network, .plen = discovered_route->plen, .gateway = discovered_route->gateway, - .rt_source = NM_IP_CONFIG_SOURCE_RDISC, + .rt_source = NM_IP_CONFIG_SOURCE_NDISC, .metric = nm_device_get_ip6_route_metric (self), }; @@ -6248,34 +6844,34 @@ rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_in } } - if (changed & NM_RDISC_CONFIG_DNS_SERVERS) { - /* Rebuild DNS server list from router discovery cache. */ + if (changed & NM_NDISC_CONFIG_DNS_SERVERS) { + /* Rebuild DNS server list from neighbor discovery cache. */ nm_ip6_config_reset_nameservers (priv->ac_ip6_config); for (i = 0; i < rdata->dns_servers_n; i++) nm_ip6_config_add_nameserver (priv->ac_ip6_config, &rdata->dns_servers[i].address); } - if (changed & NM_RDISC_CONFIG_DNS_DOMAINS) { - /* Rebuild domain list from router discovery cache. */ - nm_ip6_config_reset_domains (priv->ac_ip6_config); + if (changed & NM_NDISC_CONFIG_DNS_DOMAINS) { + /* Rebuild domain list from neighbor discovery cache. */ + nm_ip6_config_reset_searches (priv->ac_ip6_config); for (i = 0; i < rdata->dns_domains_n; i++) - nm_ip6_config_add_domain (priv->ac_ip6_config, rdata->dns_domains[i].domain); + nm_ip6_config_add_search (priv->ac_ip6_config, rdata->dns_domains[i].domain); } - if (changed & NM_RDISC_CONFIG_DHCP_LEVEL) { + if (changed & NM_NDISC_CONFIG_DHCP_LEVEL) { dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, TRUE); priv->dhcp6.mode = rdata->dhcp_level; - if (priv->dhcp6.mode != NM_RDISC_DHCP_LEVEL_NONE) { + if (priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE) { NMDeviceStateReason reason; _LOGD (LOGD_DEVICE | LOGD_DHCP6, "Activation: Stage 3 of 5 (IP Configure Start) starting DHCPv6" " as requested by IPv6 router..."); if (!dhcp6_start (self, FALSE, &reason)) { - if (priv->dhcp6.mode == NM_RDISC_DHCP_LEVEL_MANAGED) { + if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED) { nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); return; } @@ -6283,17 +6879,21 @@ rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_in } } - if (changed & NM_RDISC_CONFIG_HOP_LIMIT) + if (changed & NM_NDISC_CONFIG_HOP_LIMIT) nm_platform_sysctl_set_ip6_hop_limit_safe (NM_PLATFORM_GET, nm_device_get_ip_iface (self), rdata->hop_limit); - if (changed & NM_RDISC_CONFIG_MTU) - priv->ip6_mtu = rdata->mtu; + if (changed & NM_NDISC_CONFIG_MTU) { + if (priv->ip6_mtu != rdata->mtu) { + _LOGD (LOGD_DEVICE, "mtu: set IPv6 MTU to %u", (guint) rdata->mtu); + priv->ip6_mtu = rdata->mtu; + } + } nm_device_activate_schedule_ip6_config_result (self); } static void -rdisc_ra_timeout (NMRDisc *rdisc, NMDevice *self) +ndisc_ra_timeout (NMNDisc *ndisc, NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); @@ -6323,13 +6923,13 @@ addrconf6_start_with_link_ready (NMDevice *self) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMUtilsIPv6IfaceId iid; - g_assert (priv->rdisc); + g_assert (priv->ndisc); if (nm_device_get_ip_iface_identifier (self, &iid, FALSE)) { _LOGD (LOGD_IP6, "addrconf6: using the device EUI-64 identifier"); - nm_rdisc_set_iid (priv->rdisc, iid); + nm_ndisc_set_iid (priv->ndisc, iid); } else { - /* Don't abort the addrconf at this point -- if rdisc needs the iid + /* Don't abort the addrconf at this point -- if ndisc needs the iid * it will notice this itself. */ _LOGI (LOGD_IP6, "addrconf6: no interface identifier; IPv6 adddress creation may fail"); } @@ -6338,24 +6938,55 @@ addrconf6_start_with_link_ready (NMDevice *self) if (!ip6_config_merge_and_apply (self, TRUE, NULL)) _LOGW (LOGD_IP6, "failed to apply manual IPv6 configuration"); - nm_device_ipv6_sysctl_set (self, "accept_ra", "1"); - nm_device_ipv6_sysctl_set (self, "accept_ra_defrtr", "0"); - nm_device_ipv6_sysctl_set (self, "accept_ra_pinfo", "0"); - nm_device_ipv6_sysctl_set (self, "accept_ra_rtr_pref", "0"); + /* XXX: These sysctls would probably be better set by the lndp ndisc itself. */ + switch (nm_ndisc_get_node_type (priv->ndisc)) { + case NM_NDISC_NODE_TYPE_HOST: + /* Accepting prefixes from discovered routers. */ + nm_device_ipv6_sysctl_set (self, "accept_ra", "1"); + nm_device_ipv6_sysctl_set (self, "accept_ra_defrtr", "0"); + nm_device_ipv6_sysctl_set (self, "accept_ra_pinfo", "0"); + nm_device_ipv6_sysctl_set (self, "accept_ra_rtr_pref", "0"); + break; + case NM_NDISC_NODE_TYPE_ROUTER: + /* We're the router. */ + nm_device_ipv6_sysctl_set (self, "forwarding", "1"); + nm_device_activate_schedule_ip6_config_result (self); + priv->needs_ip6_subnet = TRUE; + g_signal_emit (self, signals[IP6_SUBNET_NEEDED], 0); + break; + default: + g_assert_not_reached (); + } - priv->rdisc_changed_id = g_signal_connect (priv->rdisc, - NM_RDISC_CONFIG_CHANGED, - G_CALLBACK (rdisc_config_changed), + priv->ndisc_changed_id = g_signal_connect (priv->ndisc, + NM_NDISC_CONFIG_RECEIVED, + G_CALLBACK (ndisc_config_changed), self); - priv->rdisc_timeout_id = g_signal_connect (priv->rdisc, - NM_RDISC_RA_TIMEOUT, - G_CALLBACK (rdisc_ra_timeout), + priv->ndisc_timeout_id = g_signal_connect (priv->ndisc, + NM_NDISC_RA_TIMEOUT, + G_CALLBACK (ndisc_ra_timeout), self); - nm_rdisc_start (priv->rdisc); + ndisc_set_router_config (priv->ndisc, self); + nm_ndisc_start (priv->ndisc); return TRUE; } +static NMNDiscNodeType +ndisc_node_type (NMDevice *self) +{ + NMConnection *connection; + + connection = nm_device_get_applied_connection (self); + g_assert (connection); + + if (strcmp (nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG), + NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) + return NM_NDISC_NODE_TYPE_ROUTER; + else + return NM_NDISC_NODE_TYPE_HOST; +} + static gboolean addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) { @@ -6379,23 +7010,24 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) s_ip6 = NM_SETTING_IP6_CONFIG (nm_connection_get_setting_ip6_config (connection)); g_assert (s_ip6); - stable_id = _get_stable_id (connection, &stable_type); + stable_id = _get_stable_id (self, connection, &stable_type); if (stable_id) { - priv->rdisc = nm_lndp_rdisc_new (NM_PLATFORM_GET, + priv->ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), nm_device_get_ip_iface (self), stable_type, stable_id, nm_setting_ip6_config_get_addr_gen_mode (s_ip6), + ndisc_node_type (self), &error); } - if (!priv->rdisc) { - _LOGE (LOGD_IP6, "addrconf6: failed to start router discovery: %s", error->message); + if (!priv->ndisc) { + _LOGE (LOGD_IP6, "addrconf6: failed to start neighbor discovery: %s", error->message); g_error_free (error); return FALSE; } - priv->rdisc_use_tempaddr = use_tempaddr; + priv->ndisc_use_tempaddr = use_tempaddr; if ( NM_IN_SET (use_tempaddr, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR) && !nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET)) { @@ -6413,8 +7045,8 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) return TRUE; } - /* success; already have the LL address; kick off router discovery */ - g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS || ret == NM_ACT_STAGE_RETURN_FINISH); + /* success; already have the LL address; kick off neighbor discovery */ + g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); return addrconf6_start_with_link_ready (self); } @@ -6423,22 +7055,23 @@ addrconf6_cleanup (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - nm_clear_g_signal_handler (priv->rdisc, &priv->rdisc_changed_id); - nm_clear_g_signal_handler (priv->rdisc, &priv->rdisc_timeout_id); + nm_clear_g_signal_handler (priv->ndisc, &priv->ndisc_changed_id); + nm_clear_g_signal_handler (priv->ndisc, &priv->ndisc_timeout_id); nm_device_remove_pending_action (self, PENDING_ACTION_AUTOCONF6, FALSE); g_clear_object (&priv->ac_ip6_config); - g_clear_object (&priv->rdisc); + g_clear_object (&priv->ndisc); } -/******************************************/ +/*****************************************************************************/ static const char *ip6_properties_to_save[] = { "accept_ra", "accept_ra_defrtr", "accept_ra_pinfo", "accept_ra_rtr_pref", + "forwarding", "disable_ipv6", "hop_limit", "use_tempaddr", @@ -6455,7 +7088,7 @@ save_ip6_properties (NMDevice *self) g_hash_table_remove_all (priv->ip6_saved_properties); for (i = 0; i < G_N_ELEMENTS (ip6_properties_to_save); i++) { - value = nm_platform_sysctl_get (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i])); + value = nm_platform_sysctl_get (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i]))); if (value) { g_hash_table_insert (priv->ip6_saved_properties, (char *) ip6_properties_to_save[i], @@ -6516,7 +7149,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable) if (enable) { /* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */ value = nm_platform_sysctl_get (NM_PLATFORM_GET, - nm_utils_ip6_property_path (nm_device_get_ip_iface (self), "disable_ipv6")); + NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), "disable_ipv6"))); if (g_strcmp0 (value, "0") == 0) nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1"); g_free (value); @@ -6528,7 +7161,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable) } } -/************************************************************************/ +/*****************************************************************************/ static NMSettingIP6ConfigPrivacy _ip6_privacy_clamp (NMSettingIP6ConfigPrivacy use_tempaddr) @@ -6582,11 +7215,11 @@ _ip6_privacy_get (NMDevice *self) * Instead of reading static config files in /etc, just read the current sysctl value. * This works as NM only writes to "/proc/sys/net/ipv6/conf/IFNAME/use_tempaddr", but leaves * the "default" entry untouched. */ - ip6_privacy = nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, "/proc/sys/net/ipv6/conf/default/use_tempaddr", NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); + ip6_privacy = nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/default/use_tempaddr"), NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN); return _ip6_privacy_clamp (ip6_privacy); } -/****************************************************************/ +/*****************************************************************************/ static gboolean ip6_requires_slaves (NMConnection *connection) @@ -6596,12 +7229,10 @@ ip6_requires_slaves (NMConnection *connection) method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG); /* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves) - * to complete addressing. SLAAC and DHCP obviously need a peer to - * provide a prefix, while Link-Local must perform DAD on the local link. + * to complete addressing. SLAAC and DHCP need a peer to provide a prefix. */ return strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 - || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0 - || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0; + || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0; } static NMActStageReturn @@ -6614,7 +7245,7 @@ act_stage3_ip6_config_start (NMDevice *self, NMConnection *connection; const char *method; NMSettingIP6ConfigPrivacy ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; - const char *ip6_privacy_str = "0\n"; + const char *ip6_privacy_str = "0"; GSList *slaves; gboolean ready_slaves; @@ -6628,7 +7259,7 @@ act_stage3_ip6_config_start (NMDevice *self, && !priv->carrier) { _LOGI (LOGD_IP6 | LOGD_DEVICE, "IPv6 config waiting until carrier is on"); - return NM_ACT_STAGE_RETURN_WAIT; + return NM_ACT_STAGE_RETURN_IP_WAIT; } if (priv->is_master && ip6_requires_slaves (connection)) { @@ -6642,11 +7273,11 @@ act_stage3_ip6_config_start (NMDevice *self, if (ready_slaves == FALSE) { _LOGI (LOGD_DEVICE | LOGD_IP6, "IPv6 config waiting until slaves are ready"); - return NM_ACT_STAGE_RETURN_WAIT; + return NM_ACT_STAGE_RETURN_IP_WAIT; } } - priv->dhcp6.mode = NM_RDISC_DHCP_LEVEL_NONE; + priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_NONE; priv->dhcp6.num_tries_left = DHCP_NUM_TRIES_MAX; method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG); @@ -6664,15 +7295,14 @@ act_stage3_ip6_config_start (NMDevice *self, nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1"); restore_ip6_properties (self); } - return NM_ACT_STAGE_RETURN_STOP; + return NM_ACT_STAGE_RETURN_IP_DONE; } /* Ensure the MTU makes sense. If it was below 1280 the kernel would not * expose any ipv6 sysctls or allow presence of any addresses on the interface, * including LL, which * would make it impossible to autoconfigure MTU to a * correct value. */ - if (!nm_device_uses_assumed_connection (self)) - nm_device_ipv6_set_mtu (self, priv->ip6_mtu); + _commit_mtu (self, priv->ip4_config); /* Any method past this point requires an IPv6LL address. Use NM-controlled * IPv6LL if this is not an assumed connection, since assumed connections @@ -6686,45 +7316,43 @@ act_stage3_ip6_config_start (NMDevice *self, ip6_privacy = _ip6_privacy_get (self); - if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0) { + if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 + || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) { if (!addrconf6_start (self, ip6_privacy)) { /* IPv6 might be disabled; allow IPv4 to proceed */ - ret = NM_ACT_STAGE_RETURN_STOP; + ret = NM_ACT_STAGE_RETURN_IP_FAIL; } else ret = NM_ACT_STAGE_RETURN_POSTPONE; } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0) { ret = linklocal6_start (self); } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) { - priv->dhcp6.mode = NM_RDISC_DHCP_LEVEL_MANAGED; + priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_MANAGED; if (!dhcp6_start (self, TRUE, reason)) { /* IPv6 might be disabled; allow IPv4 to proceed */ - ret = NM_ACT_STAGE_RETURN_STOP; + ret = NM_ACT_STAGE_RETURN_IP_FAIL; } else ret = NM_ACT_STAGE_RETURN_POSTPONE; } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0) { - /* New blank config */ - *out_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); - g_assert (*out_config); - ret = NM_ACT_STAGE_RETURN_SUCCESS; } else _LOGW (LOGD_IP6, "unhandled IPv6 config method '%s'; will fail", method); - /* Other methods (shared) aren't implemented yet */ - - switch (ip6_privacy) { - case NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN: - case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: - ip6_privacy_str = "0"; - break; - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: - ip6_privacy_str = "1"; - break; - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: - ip6_privacy_str = "2"; - break; + if ( ret != NM_ACT_STAGE_RETURN_FAILURE + && !nm_device_uses_assumed_connection (self)) { + switch (ip6_privacy) { + case NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN: + case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: + ip6_privacy_str = "0"; + break; + case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: + ip6_privacy_str = "1"; + break; + case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: + ip6_privacy_str = "2"; + break; + } + nm_device_ipv6_sysctl_set (self, "use_tempaddr", ip6_privacy_str); } - nm_device_ipv6_sysctl_set (self, "use_tempaddr", ip6_privacy_str); return ret; } @@ -6745,21 +7373,25 @@ nm_device_activate_stage3_ip4_start (NMDevice *self) g_assert (priv->ip4_state == IP_WAIT); - priv->ip4_state = IP_CONF; + _set_ip_state (self, AF_INET, IP_CONF); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &ip4_config, &reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - g_assert (ip4_config); + if (!ip4_config) + ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); nm_device_activate_schedule_ip4_config_result (self, ip4_config); g_object_unref (ip4_config); + } else if (ret == NM_ACT_STAGE_RETURN_IP_DONE) { + _set_ip_state (self, AF_INET, IP_DONE); + check_ip_state (self, FALSE); } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); return FALSE; - } else if (ret == NM_ACT_STAGE_RETURN_STOP) { - /* Early finish */ - priv->ip4_state = IP_FAIL; - } else if (ret == NM_ACT_STAGE_RETURN_WAIT) { + } else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) { + /* Activation not wanted */ + _set_ip_state (self, AF_INET, IP_FAIL); + } else if (ret == NM_ACT_STAGE_RETURN_IP_WAIT) { /* Wait for something to try IP config again */ - priv->ip4_state = IP_WAIT; + _set_ip_state (self, AF_INET, IP_WAIT); } else g_assert (ret == NM_ACT_STAGE_RETURN_POSTPONE); @@ -6782,29 +7414,29 @@ nm_device_activate_stage3_ip6_start (NMDevice *self) g_assert (priv->ip6_state == IP_WAIT); - priv->ip6_state = IP_CONF; + _set_ip_state (self, AF_INET6, IP_CONF); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &ip6_config, &reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - g_assert (ip6_config); + if (!ip6_config) + ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); /* Here we get a static IPv6 config, like for Shared where it's * autogenerated or from modems where it comes from ModemManager. */ g_warn_if_fail (priv->ac_ip6_config == NULL); priv->ac_ip6_config = ip6_config; nm_device_activate_schedule_ip6_config_result (self); + } else if (ret == NM_ACT_STAGE_RETURN_IP_DONE) { + _set_ip_state (self, AF_INET6, IP_DONE); + check_ip_state (self, FALSE); } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); return FALSE; - } else if (ret == NM_ACT_STAGE_RETURN_STOP) { + } else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) { /* Activation not wanted */ - priv->ip6_state = IP_FAIL; - } else if (ret == NM_ACT_STAGE_RETURN_FINISH) { - /* Early finish, nothing more to do */ - priv->ip6_state = IP_DONE; - check_ip_done (self); - } else if (ret == NM_ACT_STAGE_RETURN_WAIT) { + _set_ip_state (self, AF_INET6, IP_FAIL); + } else if (ret == NM_ACT_STAGE_RETURN_IP_WAIT) { /* Wait for something to try IP config again */ - priv->ip6_state = IP_WAIT; + _set_ip_state (self, AF_INET6, IP_WAIT); } else g_assert (ret == NM_ACT_STAGE_RETURN_POSTPONE); @@ -6824,7 +7456,8 @@ activate_stage3_ip_config_start (NMDevice *self) NMActiveConnection *master; NMDevice *master_device; - priv->ip4_state = priv->ip6_state = IP_WAIT; + _set_ip_state (self, AF_INET, IP_WAIT); + _set_ip_state (self, AF_INET6, IP_WAIT); nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); @@ -6862,7 +7495,10 @@ activate_stage3_ip_config_start (NMDevice *self) && !nm_device_activate_stage3_ip6_start (self)) return; - check_ip_failed (self, TRUE); + /* Proxy */ + nm_device_set_proxy_config (self, NULL); + + check_ip_state (self, TRUE); } static gboolean @@ -6909,12 +7545,16 @@ fw_change_zone_cb_ip_check (NMFirewallManager *firewall_manager, gpointer user_data) { NMDevice *self = user_data; + NMDevicePrivate *priv; if (!fw_change_zone_handle (self, call_id, error)) return; /* FIXME: fail the device on error? */ - nm_device_start_ip_check (self); + + priv = NM_DEVICE_GET_PRIVATE (self); + if (priv->ip4_state == IP_DONE || priv->ip6_state == IP_DONE) + nm_device_start_ip_check (self); } /* @@ -6981,7 +7621,6 @@ act_stage4_ip4_config_timeout (NMDevice *self, NMDeviceStateReason *reason) static void activate_stage4_ip4_config_timeout (NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; @@ -6994,9 +7633,9 @@ activate_stage4_ip4_config_timeout (NMDevice *self) } g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); - priv->ip4_state = IP_FAIL; + _set_ip_state (self, AF_INET, IP_FAIL); - check_ip_failed (self, FALSE); + check_ip_state (self, FALSE); } /* @@ -7038,7 +7677,6 @@ act_stage4_ip6_config_timeout (NMDevice *self, NMDeviceStateReason *reason) static void activate_stage4_ip6_config_timeout (NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; @@ -7051,9 +7689,9 @@ activate_stage4_ip6_config_timeout (NMDevice *self) } g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS); - priv->ip6_state = IP_FAIL; + _set_ip_state (self, AF_INET6, IP_FAIL); - check_ip_failed (self, FALSE); + check_ip_state (self, FALSE); } /* @@ -7084,16 +7722,16 @@ share_init (void) char **iter; int errsv; - if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_forward", "1")) { + if (!nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_forward"), "1")) { errsv = errno; - nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s", + nm_log_err (LOGD_SHARING, "share: error enabling IPv4 forwarding: (%d) %s", errsv, strerror (errsv)); return FALSE; } - if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_dynaddr", "1")) { + if (!nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_dynaddr"), "1")) { errsv = errno; - nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s", + nm_log_err (LOGD_SHARING, "share: error enabling dynamic addresses: (%d) %s", errsv, strerror (errsv)); } @@ -7265,7 +7903,7 @@ activate_stage5_ip4_config_commit (NMDevice *self) if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) { if (!start_sharing (self, priv->ip4_config)) { _LOGW (LOGD_SHARING, "Activation: Stage 5 of 5 (IPv4 Commit) start sharing failed."); - nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED); + nm_device_ip_method_failed (self, AF_INET, NM_DEVICE_STATE_REASON_SHARED_START_FAILED); return; } } @@ -7291,8 +7929,8 @@ activate_stage5_ip4_config_commit (NMDevice *self) nm_device_remove_pending_action (self, PENDING_ACTION_DHCP4, FALSE); /* Enter the IP_CHECK state if this is the first method to complete */ - priv->ip4_state = IP_DONE; - check_ip_done (self); + _set_ip_state (self, AF_INET, IP_DONE); + check_ip_state (self, FALSE); } void @@ -7387,9 +8025,11 @@ activate_stage5_ip6_config_commit (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMActRequest *req; + const char *method; NMConnection *connection; NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; int ip_ifindex; + int errsv; req = nm_device_get_act_request (self); g_assert (req); @@ -7405,7 +8045,7 @@ activate_stage5_ip6_config_commit (NMDevice *self) } if (ip6_config_merge_and_apply (self, TRUE, &reason)) { - if ( priv->dhcp6.mode != NM_RDISC_DHCP_LEVEL_NONE + if ( priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE && priv->ip6_state == IP_CONF) { if (priv->dhcp6.ip6_config) { /* If IPv6 wasn't the first IP to complete, and DHCP was used, @@ -7426,6 +8066,17 @@ activate_stage5_ip6_config_commit (NMDevice *self) nm_device_remove_pending_action (self, PENDING_ACTION_DHCP6, FALSE); nm_device_remove_pending_action (self, PENDING_ACTION_AUTOCONF6, FALSE); + /* Start IPv6 forwarding if we need it */ + method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG); + + if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) { + if (!nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/all/forwarding"), "1")) { + errsv = errno; + _LOGE (LOGD_SHARING, "share: error enabling IPv6 forwarding: (%d) %s", errsv, strerror (errsv)); + nm_device_ip_method_failed (self, AF_INET6, NM_DEVICE_STATE_REASON_SHARED_START_FAILED); + } + } + /* Check if we have to wait for DAD */ if (priv->ip6_state == IP_CONF && !priv->dad6_ip6_config) { priv->dad6_ip6_config = dad6_get_pending_addresses (self); @@ -7433,8 +8084,8 @@ activate_stage5_ip6_config_commit (NMDevice *self) _LOGD (LOGD_DEVICE | LOGD_IP6, "IPv6 DAD: waiting termination"); } else { /* No tentative addresses, proceed right away */ - priv->ip6_state = IP_DONE; - check_ip_done (self); + _set_ip_state (self, AF_INET6, IP_DONE); + check_ip_state (self, FALSE); } } } else { @@ -7454,7 +8105,7 @@ nm_device_activate_schedule_ip6_config_result (NMDevice *self) * clearly now have configuration. */ if (priv->ip6_state == IP_FAIL) - priv->ip6_state = IP_CONF; + _set_ip_state (self, AF_INET6, IP_CONF); activation_source_schedule (self, activate_stage5_ip6_config_commit, AF_INET6); } @@ -7623,7 +8274,7 @@ _cleanup_ip4_pre (NMDevice *self, CleanupType cleanup_type) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - priv->ip4_state = IP_NONE; + _set_ip_state (self, AF_INET, IP_NONE); if (nm_clear_g_source (&priv->queued_ip4_config_id)) _LOGD (LOGD_DEVICE, "clearing queued IP4 config change"); @@ -7640,7 +8291,7 @@ _cleanup_ip6_pre (NMDevice *self, CleanupType cleanup_type) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - priv->ip6_state = IP_NONE; + _set_ip_state (self, AF_INET6, IP_NONE); if (nm_clear_g_source (&priv->queued_ip6_config_id)) _LOGD (LOGD_DEVICE, "clearing queued IP6 config change"); @@ -7746,7 +8397,7 @@ nm_device_reactivate_ip4_config (NMDevice *self, if (!nm_streq0 (method_old, method_new)) { _cleanup_ip4_pre (self, CLEANUP_TYPE_DECONFIGURE); - priv->ip4_state = IP_WAIT; + _set_ip_state (self, AF_INET, IP_WAIT); if (!nm_device_activate_stage3_ip4_start (self)) _LOGW (LOGD_IP4, "Failed to apply IPv4 configuration"); } else { @@ -7784,7 +8435,7 @@ nm_device_reactivate_ip6_config (NMDevice *self, if (!nm_streq0 (method_old, method_new)) { _cleanup_ip6_pre (self, CLEANUP_TYPE_DECONFIGURE); - priv->ip6_state = IP_WAIT; + _set_ip_state (self, AF_INET6, IP_WAIT); if (!nm_device_activate_stage3_ip6_start (self)) _LOGW (LOGD_IP6, "Failed to apply IPv6 configuration"); } else { @@ -7854,6 +8505,7 @@ reapply_connection (NMDevice *self, error, NM_SETTING_CONNECTION_ID, NM_SETTING_CONNECTION_UUID, + NM_SETTING_CONNECTION_STABLE_ID, NM_SETTING_CONNECTION_AUTOCONNECT, NM_SETTING_CONNECTION_ZONE, NM_SETTING_CONNECTION_METERED)) @@ -7880,9 +8532,37 @@ reapply_connection (NMDevice *self, diffs ? "" : " (unmodified)"); if (diffs) { + NMConnection *connection_clean = connection; + gs_free NMConnection *connection_clean_free = NULL; + + { + NMSettingConnection *s_con_a, *s_con_n; + + /* we allow re-applying a connection with differing ID, UUID, STABLE_ID and AUTOCONNECT. + * This is for convenience but these values are not actually changable. So, check + * if they changed, and if the did revert to the original values. */ + s_con_a = nm_connection_get_setting_connection (applied); + s_con_n = nm_connection_get_setting_connection (connection); + + if ( !nm_streq (nm_setting_connection_get_id (s_con_a), nm_setting_connection_get_id (s_con_n)) + || !nm_streq (nm_setting_connection_get_uuid (s_con_a), nm_setting_connection_get_uuid (s_con_n)) + || nm_setting_connection_get_autoconnect (s_con_a) != nm_setting_connection_get_autoconnect (s_con_n) + || !nm_streq0 (nm_setting_connection_get_stable_id (s_con_a), nm_setting_connection_get_stable_id (s_con_n))) { + connection_clean_free = nm_simple_connection_new_clone (connection); + connection_clean = connection_clean_free; + s_con_n = nm_connection_get_setting_connection (connection); + g_object_set (s_con_n, + NM_SETTING_CONNECTION_ID, nm_setting_connection_get_id (s_con_a), + NM_SETTING_CONNECTION_UUID, nm_setting_connection_get_uuid (s_con_a), + NM_SETTING_CONNECTION_AUTOCONNECT, nm_setting_connection_get_autoconnect (s_con_a), + NM_SETTING_CONNECTION_STABLE_ID, nm_setting_connection_get_stable_id (s_con_a), + NULL); + } + } + con_old = applied_clone = nm_simple_connection_new_clone (applied); con_new = applied; - nm_connection_replace_settings_from_connection (applied, connection); + nm_connection_replace_settings_from_connection (applied, connection_clean); nm_connection_clear_secrets (applied); } else con_old = con_new = applied; @@ -8402,8 +9082,50 @@ nm_device_is_activating (NMDevice *self) return priv->act_handle4.id ? TRUE : FALSE; } -/* IP Configuration stuff */ +NMProxyConfig * +nm_device_get_proxy_config (NMDevice *self) +{ + g_return_val_if_fail (NM_IS_DEVICE (self), NULL); + + return NM_DEVICE_GET_PRIVATE (self)->proxy_config; +} + +static void +nm_device_set_proxy_config (NMDevice *self, GHashTable *options) +{ + NMDevicePrivate *priv; + NMConnection *connection; + NMSettingProxy *s_proxy = NULL; + char *pac = NULL; + + g_return_if_fail (NM_IS_DEVICE (self)); + + priv = NM_DEVICE_GET_PRIVATE (self); + + g_clear_object (&priv->proxy_config); + priv->proxy_config = nm_proxy_config_new (); + + if (options) { + pac = g_hash_table_lookup (options, "wpad"); + if (pac) { + nm_proxy_config_set_method (priv->proxy_config, NM_PROXY_CONFIG_METHOD_AUTO); + nm_proxy_config_set_pac_url (priv->proxy_config, pac); + _LOGD (LOGD_PROXY, "proxy: PAC url \"%s\"", pac); + } else { + nm_proxy_config_set_method (priv->proxy_config, NM_PROXY_CONFIG_METHOD_NONE); + _LOGD (LOGD_PROXY, "proxy: PAC url not obtained from DHCP server"); + } + } + + connection = nm_device_get_applied_connection (self); + if (connection) + s_proxy = nm_connection_get_setting_proxy (connection); + + if (s_proxy) + nm_proxy_config_merge_setting (priv->proxy_config, s_proxy); +} +/* IP Configuration stuff */ NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *self) { @@ -8456,8 +9178,7 @@ nm_device_set_ip4_config (NMDevice *self, if (commit && new_config) { gboolean assumed = nm_device_uses_assumed_connection (self); - nm_device_set_mtu (self, nm_ip4_config_get_mtu (new_config)); - + _commit_mtu (self, new_config); /* For assumed devices we must not touch the kernel-routes, such as the device-route. * FIXME: this is wrong in case where "assumed" means "take-over-seamlessly". In this * case, we should manage the device route, for example on new DHCP lease. */ @@ -8625,7 +9346,7 @@ nm_device_set_ip6_config (NMDevice *self, /* Always commit to nm-platform to update lifetimes */ if (commit && new_config) { - nm_device_ipv6_set_mtu (self, priv->ip6_mtu); + _commit_mtu (self, priv->ip4_config); success = nm_ip6_config_commit (new_config, ip_ifindex, routes_full_sync); @@ -8683,6 +9404,9 @@ nm_device_set_ip6_config (NMDevice *self, } nm_device_queue_recheck_assume (self); + + if (priv->ndisc) + ndisc_set_router_config (priv->ndisc, self); } if (reason) @@ -8737,7 +9461,7 @@ nm_device_get_ip6_config (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->ip6_config; } -/****************************************************************/ +/*****************************************************************************/ static void dispatcher_cleanup (NMDevice *self) @@ -8767,7 +9491,7 @@ dispatcher_complete_proceed_state (guint call_id, gpointer user_data) priv->dispatcher.post_state_reason = NM_DEVICE_STATE_REASON_NONE; } -/****************************************************************/ +/*****************************************************************************/ static void ip_check_pre_up (NMDevice *self) @@ -8953,10 +9677,10 @@ nm_device_start_ip_check (NMDevice *self) * first IP method completes. Any subsequently completing IP method doesn't * get checked. */ - g_assert (!priv->gw_ping.watch); - g_assert (!priv->gw_ping.timeout); - g_assert (!priv->gw_ping.pid); - g_assert (priv->ip4_state == IP_DONE || priv->ip6_state == IP_DONE); + g_return_if_fail (!priv->gw_ping.watch); + g_return_if_fail (!priv->gw_ping.timeout); + g_return_if_fail (!priv->gw_ping.pid); + g_return_if_fail (priv->ip4_state == IP_DONE || priv->ip6_state == IP_DONE); connection = nm_device_get_applied_connection (self); g_assert (connection); @@ -8995,7 +9719,7 @@ nm_device_start_ip_check (NMDevice *self) ip_check_pre_up (self); } -/****************************************************************/ +/*****************************************************************************/ static gboolean carrier_wait_timeout (gpointer user_data) @@ -9013,19 +9737,11 @@ carrier_wait_timeout (gpointer user_data) static gboolean nm_device_is_up (NMDevice *self) { - g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); - - if (NM_DEVICE_GET_CLASS (self)->is_up) - return NM_DEVICE_GET_CLASS (self)->is_up (self); - - return TRUE; -} + int ifindex; -static gboolean -is_up (NMDevice *self) -{ - int ifindex = nm_device_get_ip_ifindex (self); + g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + ifindex = nm_device_get_ip_ifindex (self); return ifindex > 0 ? nm_platform_link_is_up (NM_PLATFORM_GET, ifindex) : TRUE; } @@ -9035,13 +9751,23 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); gboolean device_is_up = FALSE; NMDeviceCapabilities capabilities; + int ifindex; g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); - _LOGD (LOGD_PLATFORM, "bringing up device"); + NM_SET_OUT (no_firmware, FALSE); + + if (!nm_device_get_enabled (self)) { + _LOGD (LOGD_PLATFORM, "bringing up device ignored due to disabled"); + return FALSE; + } - if (NM_DEVICE_GET_CLASS (self)->bring_up) { - if (!NM_DEVICE_GET_CLASS (self)->bring_up (self, no_firmware)) + ifindex = nm_device_get_ip_ifindex (self); + _LOGD (LOGD_PLATFORM, "bringing up device %d", ifindex); + if (ifindex <= 0) { + /* assume success. */ + } else { + if (!nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, no_firmware)) return FALSE; } @@ -9051,7 +9777,6 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) device_is_up = nm_device_is_up (self); if (block && !device_is_up) { - int ifindex = nm_device_get_ip_ifindex (self); gint64 wait_until = nm_utils_get_monotonic_timestamp_us () + 10000 /* microseconds */; do { @@ -9106,40 +9831,26 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) return TRUE; } -static gboolean -bring_up (NMDevice *self, gboolean *no_firmware) -{ - int ifindex = nm_device_get_ip_ifindex (self); - gboolean result; - - if (ifindex <= 0) { - if (no_firmware) - *no_firmware = FALSE; - return TRUE; - } - - result = nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, no_firmware); - - return result; -} - void nm_device_take_down (NMDevice *self, gboolean block) { + int ifindex; gboolean device_is_up; g_return_if_fail (NM_IS_DEVICE (self)); - _LOGD (LOGD_PLATFORM, "taking down device"); - - if (NM_DEVICE_GET_CLASS (self)->take_down) { - if (!NM_DEVICE_GET_CLASS (self)->take_down (self)) - return; + ifindex = nm_device_get_ip_ifindex (self); + _LOGD (LOGD_PLATFORM, "taking down device %d", ifindex); + if (ifindex <= 0) { + /* devices without ifindex are always up. */ + return; } + if (!nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)) + return; + device_is_up = nm_device_is_up (self); if (block && device_is_up) { - int ifindex = nm_device_get_ip_ifindex (self); gint64 wait_until = nm_utils_get_monotonic_timestamp_us () + 10000 /* microseconds */; do { @@ -9158,19 +9869,6 @@ nm_device_take_down (NMDevice *self, gboolean block) } } -static gboolean -take_down (NMDevice *self) -{ - int ifindex = nm_device_get_ip_ifindex (self); - - if (ifindex > 0) - return nm_platform_link_set_down (NM_PLATFORM_GET, ifindex); - - /* devices without ifindex are always up. */ - _LOGD (LOGD_PLATFORM, "cannot take down device without ifindex"); - return FALSE; -} - void nm_device_set_firmware_missing (NMDevice *self, gboolean new_missing) { @@ -9191,26 +9889,6 @@ nm_device_get_firmware_missing (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->firmware_missing; } -void -nm_device_set_nm_plugin_missing (NMDevice *self, gboolean new_missing) -{ - NMDevicePrivate *priv; - - g_return_if_fail (NM_IS_DEVICE (self)); - - priv = NM_DEVICE_GET_PRIVATE (self); - if (priv->nm_plugin_missing != new_missing) { - priv->nm_plugin_missing = new_missing; - _notify (self, PROP_NM_PLUGIN_MISSING); - } -} - -gboolean -nm_device_get_nm_plugin_missing (NMDevice *self) -{ - return NM_DEVICE_GET_PRIVATE (self)->nm_plugin_missing; -} - static NMIP4Config * find_ip4_lease_config (NMDevice *self, NMConnection *connection, @@ -9563,8 +10241,8 @@ queued_ip6_config_change (gpointer user_data) if (IN6_IS_ADDR_LINKLOCAL (&addr->address)) need_ipv6ll = TRUE; - else if (priv->rdisc) - nm_rdisc_dad_failed (priv->rdisc, &addr->address); + else if (priv->ndisc) + nm_ndisc_dad_failed (priv->ndisc, &addr->address); } /* If no IPv6 link-local address exists but other addresses do then we @@ -9590,8 +10268,8 @@ queued_ip6_config_change (gpointer user_data) priv->dad6_ip6_config)) { _LOGD (LOGD_DEVICE | LOGD_IP6, "IPv6 DAD terminated"); g_clear_object (&priv->dad6_ip6_config); - priv->ip6_state = IP_DONE; - check_ip_done (self); + _set_ip_state (self, AF_INET6, IP_DONE); + check_ip_state (self, FALSE); } } @@ -9602,12 +10280,14 @@ queued_ip6_config_change (gpointer user_data) static void device_ipx_changed (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, gpointer platform_object, - NMPlatformSignalChangeType change_type, + int change_type_i, NMDevice *self) { + const NMPObjectType obj_type = obj_type_i; + const NMPlatformSignalChangeType change_type = change_type_i; NMDevicePrivate *priv; NMPlatformIP6Address *addr; @@ -10645,7 +11325,7 @@ nm_device_has_pending_action (NMDevice *self) return !!priv->pending_actions; } -/***********************************************************/ +/*****************************************************************************/ static void _cancel_activation (NMDevice *self) @@ -10717,6 +11397,7 @@ _cleanup_generic_post (NMDevice *self, CleanupType cleanup_type) */ nm_device_set_ip4_config (self, NULL, 0, TRUE, TRUE, NULL); nm_device_set_ip6_config (self, NULL, TRUE, TRUE, NULL); + g_clear_object (&priv->proxy_config); g_clear_object (&priv->con_ip4_config); g_clear_object (&priv->dev_ip4_config); g_clear_object (&priv->ext_ip4_config); @@ -10735,6 +11416,8 @@ _cleanup_generic_post (NMDevice *self, CleanupType cleanup_type) g_slist_free_full (priv->vpn6_configs, g_object_unref); priv->vpn6_configs = NULL; + priv->needs_ip6_subnet = FALSE; + clear_act_request (self); /* Clear legacy IPv4 address property */ @@ -10827,6 +11510,27 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean NM_DEVICE_GET_CLASS (self)->deactivate_reset_hw_addr (self); } + priv->mtu_initialized = FALSE; + if (priv->mtu_initial || priv->ip6_mtu_initial) { + ifindex = nm_device_get_ip_ifindex (self); + + if ( ifindex > 0 + && cleanup_type == CLEANUP_TYPE_DECONFIGURE) { + _LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d", + (guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex); + if (priv->mtu_initial) + nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu_initial); + if (priv->ip6_mtu_initial) { + char sbuf[64]; + + nm_device_ipv6_sysctl_set (self, "mtu", + nm_sprintf_buf (sbuf, "%u", (unsigned) priv->ip6_mtu_initial)); + } + } + priv->mtu_initial = 0; + priv->ip6_mtu_initial = 0; + } + _cleanup_generic_post (self, cleanup_type); } @@ -10886,7 +11590,7 @@ nm_device_spawn_iface_helper (NMDevice *self) g_ptr_array_add (argv, g_strdup ("--uuid")); g_ptr_array_add (argv, g_strdup (nm_connection_get_uuid (connection))); - stable_id = _get_stable_id (connection, &stable_type); + stable_id = _get_stable_id (self, connection, &stable_type); if (stable_id && stable_type != NM_UTILS_STABLE_TYPE_UUID) { g_ptr_array_add (argv, g_strdup ("--stable-id")); g_ptr_array_add (argv, g_strdup_printf ("%d %s", (int) stable_type, stable_id)); @@ -10903,6 +11607,12 @@ nm_device_spawn_iface_helper (NMDevice *self) g_ptr_array_add (argv, logging_backend); } + g_ptr_array_add (argv, g_strdup ("--log-level")); + g_ptr_array_add (argv, g_strdup (nm_logging_level_to_string ())); + + g_ptr_array_add (argv, g_strdup ("--log-domains")); + g_ptr_array_add (argv, g_strdup (nm_logging_domains_to_string ())); + dhcp4_address = find_dhcp4_address (self); method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG); @@ -10966,7 +11676,7 @@ nm_device_spawn_iface_helper (NMDevice *self) g_ptr_array_add (argv, g_strdup ("--slaac-required")); g_ptr_array_add (argv, g_strdup ("--slaac-tempaddr")); - g_ptr_array_add (argv, g_strdup_printf ("%d", priv->rdisc_use_tempaddr)); + g_ptr_array_add (argv, g_strdup_printf ("%d", priv->ndisc_use_tempaddr)); if (nm_device_get_ip_iface_identifier (self, &iid, FALSE)) { g_ptr_array_add (argv, g_strdup ("--iid")); @@ -11007,7 +11717,7 @@ nm_device_spawn_iface_helper (NMDevice *self) g_ptr_array_unref (argv); } -/***********************************************************/ +/*****************************************************************************/ static gboolean ip_config_valid (NMDeviceState state) @@ -11036,6 +11746,7 @@ ip6_managed_setup (NMDevice *self) nm_device_ipv6_sysctl_set (self, "accept_ra_pinfo", "0"); nm_device_ipv6_sysctl_set (self, "accept_ra_rtr_pref", "0"); nm_device_ipv6_sysctl_set (self, "use_tempaddr", "0"); + nm_device_ipv6_sysctl_set (self, "forwarding", "0"); } static void @@ -11174,6 +11885,11 @@ _set_state_full (NMDevice *self, if (state >= NM_DEVICE_STATE_DISCONNECTED && old_state < NM_DEVICE_STATE_DISCONNECTED) nm_device_recheck_available_connections (self); + if (state <= NM_DEVICE_STATE_DISCONNECTED || state > NM_DEVICE_STATE_DEACTIVATING) { + if (nm_clear_g_free (&priv->current_stable_id)) + _LOGT (LOGD_DEVICE, "stable-id: clear"); + } + /* Handle the new state here; but anything that could trigger * another state change should be done below. */ @@ -11307,6 +12023,9 @@ _set_state_full (NMDevice *self, deactivate_dispatcher_complete (0, self); } } + + /* Remove config from PacRunner */ + nm_pacrunner_manager_remove (priv->pacrunner_manager, nm_device_get_ip_iface (self)); break; case NM_DEVICE_STATE_DISCONNECTED: if ( priv->queued_act_request @@ -11330,6 +12049,14 @@ _set_state_full (NMDevice *self, nm_act_request_get_settings_connection (req), nm_act_request_get_applied_connection (req), self, NULL, NULL, NULL); + + if (priv->proxy_config) { + nm_pacrunner_manager_send (priv->pacrunner_manager, + nm_device_get_ip_iface (self), + priv->proxy_config, + priv->ip4_config, + priv->ip6_config); + } break; case NM_DEVICE_STATE_FAILED: /* Usually upon failure the activation chain is interrupted in @@ -11548,7 +12275,7 @@ nm_device_get_state (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->state; } -/***********************************************************/ +/*****************************************************************************/ /* NMConfigDevice interface related stuff */ const char * @@ -11715,6 +12442,28 @@ nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze) * (until we unrealize the device). */ priv->hw_addr_perm_fake = TRUE; + /* We also persist our choice of the fake address to the device state + * file to use the same address on restart of NetworkManager. + * First, try to reload the address from the state file. */ + { + gs_free NMConfigDeviceStateData *dev_state = NULL; + + dev_state = nm_config_device_state_load (nm_config_get (), ifindex); + if ( dev_state + && dev_state->perm_hw_addr_fake + && nm_utils_hwaddr_aton (dev_state->perm_hw_addr_fake, buf, priv->hw_addr_len) + && !nm_utils_hwaddr_matches (buf, priv->hw_addr_len, priv->hw_addr, -1)) { + _LOGD (LOGD_PLATFORM | LOGD_ETHER, "hw-addr: %s (use from statefile: %s, current: %s)", + success_read + ? "read HW addr length of permanent MAC address differs" + : "unable to read permanent MAC address", + dev_state->perm_hw_addr_fake, + priv->hw_addr); + priv->hw_addr_perm = nm_utils_hwaddr_ntoa (buf, priv->hw_addr_len); + goto notify_and_out; + } + } + _LOGD (LOGD_PLATFORM | LOGD_ETHER, "hw-addr: %s (use current: %s)", success_read ? "read HW addr length of permanent MAC address differs" @@ -11748,8 +12497,8 @@ _get_cloned_mac_address_setting (NMDevice *self, NMConnection *connection, gbool a = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, is_wifi ? "wifi.cloned-mac-address" : "ethernet.cloned-mac-address", self); - /* default is permanent. */ - addr = NM_CLONED_MAC_PERMANENT; + + addr = NM_CLONED_MAC_PRESERVE; if (!a) { if (is_wifi) { @@ -11937,7 +12686,10 @@ handle_fail: } gboolean -nm_device_hw_addr_set (NMDevice *self, const char *addr, const char *detail) +nm_device_hw_addr_set (NMDevice *self, + const char *addr, + const char *detail, + gboolean set_permanent) { NMDevicePrivate *priv; @@ -11948,10 +12700,13 @@ nm_device_hw_addr_set (NMDevice *self, const char *addr, const char *detail) if (!addr) g_return_val_if_reached (FALSE); - /* this is called by NMDeviceVlan to take the MAC address from the parent - * and by NMDeviceWifi to set a random MAC address during scanning. - * In this case, it's like setting it to PERMANENT. */ - priv->hw_addr_type = HW_ADDR_TYPE_PERMANENT; + if (set_permanent) { + /* The type is set to PERMANENT by NMDeviceVlan when taking the MAC + * address from the parent and by NMDeviceWifi when setting a random MAC + * address during scanning. + */ + priv->hw_addr_type = HW_ADDR_TYPE_PERMANENT; + } return _hw_addr_set (self, addr, "set", detail); } @@ -12009,7 +12764,7 @@ nm_device_hw_addr_set_cloned (NMDevice *self, NMConnection *connection, gboolean return TRUE; } - stable_id = _get_stable_id (connection, &stable_type); + stable_id = _get_stable_id (self, connection, &stable_type); if (stable_id) { hw_addr_generated = nm_utils_hw_addr_gen_stable_eth (stable_type, stable_id, nm_device_get_ip_iface (self), @@ -12153,7 +12908,7 @@ spec_match_list (NMDevice *self, const GSList *specs) return matched; } -/***********************************************************/ +/*****************************************************************************/ static const char * _activation_func_to_string (ActivationHandleFunc func) @@ -12173,7 +12928,7 @@ _activation_func_to_string (ActivationHandleFunc func) g_return_val_if_reached ("unknown"); } -/***********************************************************/ +/*****************************************************************************/ static void nm_device_init (NMDevice *self) @@ -12196,6 +12951,8 @@ nm_device_init (NMDevice *self) priv->available_connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL); priv->ip6_saved_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); + priv->pacrunner_manager = g_object_ref (nm_pacrunner_manager_get ()); + priv->default_route.v4_is_assumed = TRUE; priv->default_route.v6_is_assumed = TRUE; @@ -12297,6 +13054,8 @@ dispose (GObject *object) _LOGD (LOGD_DEVICE, "disposing"); + _parent_set_ifindex (self, 0, FALSE); + platform = NM_PLATFORM_GET; g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (device_ipx_changed), self); g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (link_changed_cb), self); @@ -12310,6 +13069,8 @@ dispose (GObject *object) dispatcher_cleanup (self); + g_clear_object (&priv->pacrunner_manager); + _cleanup_generic_pre (self, CLEANUP_TYPE_KEEP); g_warn_if_fail (priv->slaves == NULL); @@ -12331,6 +13092,11 @@ dispose (GObject *object) link_disconnect_action_cancel (self); + if (priv->ifindex > 0) { + priv->ifindex = 0; + _notify (self, PROP_IFINDEX); + } + if (priv->settings) { g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_added, self); g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_updated, self); @@ -12387,6 +13153,7 @@ finalize (GObject *object) g_free (priv->type_desc); g_free (priv->type_description); g_free (priv->dhcp_anycast_address); + g_free (priv->current_stable_id); g_hash_table_unref (priv->ip6_saved_properties); g_hash_table_unref (priv->available_connections); @@ -12414,7 +13181,7 @@ set_property (GObject *object, guint prop_id, } break; case PROP_IFACE: - /* construct only */ + /* construct-only */ g_return_if_fail (!priv->iface); priv->iface = g_value_dup_string (value); break; @@ -12432,9 +13199,6 @@ set_property (GObject *object, guint prop_id, g_free (priv->firmware_version); priv->firmware_version = g_value_dup_string (value); break; - case PROP_MTU: - priv->mtu = g_value_get_uint (value); - break; case PROP_IP4_ADDRESS: priv->ip4_address = g_value_get_uint (value); break; @@ -12458,10 +13222,11 @@ set_property (GObject *object, guint prop_id, nm_device_set_autoconnect (self, g_value_get_boolean (value)); break; case PROP_FIRMWARE_MISSING: - /* construct only */ + /* construct-only */ priv->firmware_missing = g_value_get_boolean (value); break; case PROP_NM_PLUGIN_MISSING: + /* construct-only */ priv->nm_plugin_missing = g_value_get_boolean (value); break; case PROP_DEVICE_TYPE: @@ -12469,7 +13234,7 @@ set_property (GObject *object, guint prop_id, priv->type = g_value_get_uint (value); break; case PROP_LINK_TYPE: - /* construct only */ + /* construct-only */ g_return_if_fail (priv->link_type == NM_LINK_TYPE_NONE); priv->link_type = g_value_get_uint (value); break; @@ -12484,7 +13249,7 @@ set_property (GObject *object, guint prop_id, priv->is_master = g_value_get_boolean (value); break; case PROP_PERM_HW_ADDRESS: - /* construct only */ + /* construct-only */ priv->hw_addr_perm = g_value_dup_string (value); break; case PROP_REFRESH_RATE_MS: @@ -12608,6 +13373,9 @@ get_property (GObject *object, guint prop_id, case PROP_MASTER: g_value_set_object (value, nm_device_get_master (self)); break; + case PROP_PARENT: + nm_utils_g_value_set_object_path (value, priv->parent_device); + break; case PROP_HW_ADDRESS: g_value_set_string (value, priv->hw_addr); break; @@ -12680,9 +13448,8 @@ nm_device_class_init (NMDeviceClass *klass) g_type_class_add_private (object_class, sizeof (NMDevicePrivate)); - exported_object_class->export_path = NM_DBUS_PATH "/Devices/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/Devices"); - /* Virtual methods */ object_class->dispose = dispose; object_class->finalize = finalize; object_class->set_property = set_property; @@ -12709,15 +13476,12 @@ nm_device_class_init (NMDeviceClass *klass) klass->can_unmanaged_external_down = can_unmanaged_external_down; klass->realize_start_notify = realize_start_notify; klass->unrealize_notify = unrealize_notify; - klass->is_up = is_up; - klass->bring_up = bring_up; - klass->take_down = take_down; klass->carrier_changed = carrier_changed; klass->get_ip_iface_identifier = get_ip_iface_identifier; klass->unmanaged_on_quit = unmanaged_on_quit; klass->deactivate_reset_hw_addr = deactivate_reset_hw_addr; + klass->parent_changed_notify = parent_changed_notify; - /* Properties */ obj_properties[PROP_UDI] = g_param_spec_string (NM_DEVICE_UDI, "", "", NULL, @@ -12871,6 +13635,11 @@ nm_device_class_init (NMDeviceClass *klass) NM_TYPE_DEVICE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_PARENT] = + g_param_spec_string (NM_DEVICE_PARENT, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); obj_properties[PROP_HW_ADDRESS] = g_param_spec_string (NM_DEVICE_HW_ADDRESS, "", "", NULL, @@ -12935,7 +13704,6 @@ nm_device_class_init (NMDeviceClass *klass) g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - /* Signals */ signals[STATE_CHANGED] = g_signal_new (NM_DEVICE_STATE_CHANGED, G_OBJECT_CLASS_TYPE (object_class), @@ -12946,7 +13714,7 @@ nm_device_class_init (NMDeviceClass *klass) G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); signals[AUTOCONNECT_ALLOWED] = - g_signal_new ("autoconnect-allowed", + g_signal_new (NM_DEVICE_AUTOCONNECT_ALLOWED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, 0, @@ -12975,6 +13743,20 @@ nm_device_class_init (NMDeviceClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_OBJECT); + signals[IP6_PREFIX_DELEGATED] = + g_signal_new (NM_DEVICE_IP6_PREFIX_DELEGATED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_POINTER); + + signals[IP6_SUBNET_NEEDED] = + g_signal_new (NM_DEVICE_IP6_SUBNET_NEEDED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); + signals[REMOVED] = g_signal_new (NM_DEVICE_REMOVED, G_OBJECT_CLASS_TYPE (object_class), diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index f90444cd..52a74d26 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -66,6 +66,9 @@ #define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors" #define NM_DEVICE_REAL "real" +/* "parent" is exposed on D-Bus by subclasses like NMDeviceIPTunnel */ +#define NM_DEVICE_PARENT "parent" + /* the "slaves" property is internal in the parent class, but exposed * by the derived classes NMDeviceBond, NMDeviceBridge and NMDeviceTeam. * It is thus important that the property name matches. */ @@ -82,11 +85,14 @@ #define NM_DEVICE_AUTH_REQUEST "auth-request" #define NM_DEVICE_IP4_CONFIG_CHANGED "ip4-config-changed" #define NM_DEVICE_IP6_CONFIG_CHANGED "ip6-config-changed" +#define NM_DEVICE_IP6_PREFIX_DELEGATED "ip6-prefix-delegated" +#define NM_DEVICE_IP6_SUBNET_NEEDED "ip6-subnet-needed" #define NM_DEVICE_REMOVED "removed" #define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate" #define NM_DEVICE_RECHECK_ASSUME "recheck-assume" #define NM_DEVICE_STATE_CHANGED "state-changed" #define NM_DEVICE_LINK_INITIALIZED "link-initialized" +#define NM_DEVICE_AUTOCONNECT_ALLOWED "autoconnect-allowed" #define NM_DEVICE_STATISTICS_REFRESH_RATE_MS "refresh-rate-ms" #define NM_DEVICE_STATISTICS_TX_BYTES "tx-bytes" @@ -150,7 +156,8 @@ typedef struct { NMDeviceState old_state, NMDeviceStateReason reason); - void (* link_changed) (NMDevice *self, NMPlatformLink *info); + void (* link_changed) (NMDevice *self, + const NMPlatformLink *pllink); /** * create_and_realize(): @@ -178,12 +185,15 @@ typedef struct { /** * realize_start_notify(): * @self: the #NMDevice - * @plink: the #NMPlatformLink if backed by a kernel netdevice + * @pllink: the #NMPlatformLink if backed by a kernel netdevice * * Hook for derived classes to be notfied during realize_start_setup() * and perform additional setup. + * + * The default implemention of NMDevice calls link_changed(). */ - void (*realize_start_notify) (NMDevice *self, const NMPlatformLink *plink); + void (*realize_start_notify) (NMDevice *self, + const NMPlatformLink *pllink); /** * unrealize(): @@ -204,9 +214,6 @@ typedef struct { /* Hardware state (IFF_UP) */ gboolean (*can_unmanaged_external_down) (NMDevice *self); - gboolean (*is_up) (NMDevice *self); - gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware); - gboolean (*take_down) (NMDevice *self); /* Carrier state (IFF_LOWER_UP) */ void (*carrier_changed) (NMDevice *, gboolean carrier); @@ -225,6 +232,8 @@ typedef struct { NMConnection *connection, char **specific_object); + guint32 (*get_configured_mtu) (NMDevice *self, gboolean *out_is_user_config); + /* Checks whether the connection is compatible with the device using * only the devices type and characteristics. Does not use any live * network information like WiFi scan lists etc. @@ -268,9 +277,7 @@ typedef struct { NMActStageReturn (* act_stage4_ip6_config_timeout) (NMDevice *self, NMDeviceStateReason *reason); - /* Called right before IP config is set; use for setting MTU etc */ void (* ip4_config_pre_commit) (NMDevice *self, NMIP4Config *config); - void (* ip6_config_pre_commit) (NMDevice *self, NMIP6Config *config); /* Async deactivating (in the DEACTIVATING phase) */ void (* deactivate_async) (NMDevice *self, @@ -310,7 +317,11 @@ typedef struct { gboolean (* have_any_ready_slaves) (NMDevice *self, const GSList *slaves); - void (* notify_new_device_added) (NMDevice *self, NMDevice *new_device); + void (* parent_changed_notify) (NMDevice *self, + int old_ifindex, + NMDevice *old_parent, + int new_ifindex, + NMDevice *new_parent); /** * component_added: @@ -370,9 +381,10 @@ const char * nm_device_get_permanent_hw_address_full (NMDevice *self, gboolean *out_is_fake); const char * nm_device_get_initial_hw_address (NMDevice *dev); +NMProxyConfig * nm_device_get_proxy_config (NMDevice *dev); + NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *dev); NMDhcp6Config * nm_device_get_dhcp6_config (NMDevice *dev); - NMIP4Config * nm_device_get_ip4_config (NMDevice *dev); void nm_device_replace_vpn4_config (NMDevice *dev, NMIP4Config *old, @@ -385,6 +397,14 @@ void nm_device_replace_vpn6_config (NMDevice *dev, void nm_device_capture_initial_config (NMDevice *dev); +int nm_device_parent_get_ifindex (NMDevice *dev); +NMDevice *nm_device_parent_get_device (NMDevice *dev); +void nm_device_parent_set_ifindex (NMDevice *self, + int parent_ifindex); +gboolean nm_device_parent_notify_changed (NMDevice *self, + NMDevice *change_candidate, + gboolean device_removed); + /* Master */ gboolean nm_device_is_master (NMDevice *dev); @@ -440,6 +460,16 @@ void nm_device_set_enabled (NMDevice *device, gboolean enabled); RfKillType nm_device_get_rfkill_type (NMDevice *device); +/* IPv6 prefix delegation */ + +void nm_device_request_ip6_prefixes (NMDevice *self, int needed_prefixes); + +gboolean nm_device_needs_ip6_subnet (NMDevice *self); + +void nm_device_use_ip6_subnet (NMDevice *self, const NMPlatformIP6Address *subnet); + +void nm_device_copy_ip6_dns_config (NMDevice *self, NMDevice *from_device); + /** * NMUnmanagedFlags: * @NM_UNMANAGED_NONE: placeholder value @@ -544,9 +574,6 @@ void nm_device_queue_state (NMDevice *self, NMDeviceStateReason reason); gboolean nm_device_get_firmware_missing (NMDevice *self); -gboolean nm_device_get_nm_plugin_missing (NMDevice *self); -void nm_device_set_nm_plugin_missing (NMDevice *self, - gboolean missing); void nm_device_steal_connection (NMDevice *device, NMSettingsConnection *connection); @@ -567,7 +594,6 @@ gboolean nm_device_check_connection_available (NMDevice *device, NMDeviceCheckConAvailableFlags flags, const char *specific_object); -void nm_device_notify_new_device_added (NMDevice *self, NMDevice *new_device); gboolean nm_device_notify_component_added (NMDevice *device, GObject *component); gboolean nm_device_owns_iface (NMDevice *device, const char *iface); diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c index f4663405..ceec6063 100644 --- a/src/devices/nm-lldp-listener.c +++ b/src/devices/nm-lldp-listener.c @@ -25,10 +25,10 @@ #include #include -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-utils.h" -#include "sd-lldp.h" +#include "systemd/nm-sd.h" #define MAX_NEIGHBORS 4096 #define MIN_UPDATE_INTERVAL_NS (2 * NM_UTILS_NS_PER_SECOND) @@ -66,6 +66,12 @@ typedef struct { }; } LldpAttrData; +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE (NMLldpListener, + PROP_NEIGHBORS, +); + typedef struct { char *iface; int ifindex; @@ -79,13 +85,20 @@ typedef struct { GVariant *variant; } NMLldpListenerPrivate; -NM_GOBJECT_PROPERTIES_DEFINE (NMLldpListener, - PROP_NEIGHBORS, -); +struct _NMLldpListener { + GObject parent; + NMLldpListenerPrivate _priv; +}; + +struct _NMLldpListenerClass { + GObjectClass parent; +}; G_DEFINE_TYPE (NMLldpListener, nm_lldp_listener, G_TYPE_OBJECT) -#define NM_LLDP_LISTENER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_LLDP_LISTENER, NMLldpListenerPrivate)) +#define NM_LLDP_LISTENER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMLldpListener, NM_IS_LLDP_LISTENER) + +/*****************************************************************************/ typedef struct { guint8 chassis_id_type; @@ -903,8 +916,6 @@ nm_lldp_listener_class_init (NMLldpListenerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMLldpListenerPrivate)); - object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; diff --git a/src/devices/nm-lldp-listener.h b/src/devices/nm-lldp-listener.h index 870ca8a5..1afa8456 100644 --- a/src/devices/nm-lldp-listener.h +++ b/src/devices/nm-lldp-listener.h @@ -30,13 +30,7 @@ #define NM_LLDP_LISTENER_NEIGHBORS "neighbors" -struct _NMLldpListener { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMLldpListenerClass; +typedef struct _NMLldpListenerClass NMLldpListenerClass; GType nm_lldp_listener_get_type (void); NMLldpListener *nm_lldp_listener_new (void); diff --git a/src/devices/team/Makefile.am b/src/devices/team/Makefile.am deleted file mode 100644 index db756b4c..00000000 --- a/src/devices/team/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/platform \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-team"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -if WITH_TEAMDCTL -AM_CPPFLAGS += ${LIBTEAMDCTL_CFLAGS} -endif - -pkglib_LTLIBRARIES = libnm-device-plugin-team.la - -SYMBOL_VIS_FILE=$(srcdir)/exports.ver - -libnm_device_plugin_team_la_SOURCES = \ - nm-device-team.c \ - nm-device-team.h \ - nm-team-factory.c \ - nm-team-factory.h - -libnm_device_plugin_team_la_LDFLAGS = \ - -module -avoid-version \ - -Wl,--version-script=$(SYMBOL_VIS_FILE) - -libnm_device_plugin_team_la_LIBADD = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) - -if WITH_TEAMDCTL -libnm_device_plugin_team_la_LIBADD += $(LIBTEAMDCTL_LIBS) -endif - -EXTRA_DIST = $(SYMBOL_VIS_FILE) - -if ENABLE_TESTS - -check-local: - $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-team.so $(SYMBOL_VIS_FILE) - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-team.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - diff --git a/src/devices/team/Makefile.in b/src/devices/team/Makefile.in deleted file mode 100644 index f227a77a..00000000 --- a/src/devices/team/Makefile.in +++ /dev/null @@ -1,850 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@WITH_TEAMDCTL_TRUE@am__append_1 = ${LIBTEAMDCTL_CFLAGS} -@WITH_TEAMDCTL_TRUE@am__append_2 = $(LIBTEAMDCTL_LIBS) -subdir = src/devices/team -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(pkglib_LTLIBRARIES) -am__DEPENDENCIES_1 = -@WITH_TEAMDCTL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) -libnm_device_plugin_team_la_DEPENDENCIES = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_2) -am_libnm_device_plugin_team_la_OBJECTS = nm-device-team.lo \ - nm-team-factory.lo -libnm_device_plugin_team_la_OBJECTS = \ - $(am_libnm_device_plugin_team_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_device_plugin_team_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(libnm_device_plugin_team_la_LDFLAGS) \ - $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libnm_device_plugin_team_la_SOURCES) -DIST_SOURCES = $(libnm_device_plugin_team_la_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = -I${top_srcdir}/src -I${top_builddir}/src \ - -I${top_srcdir}/src/devices -I${top_srcdir}/src/platform \ - -I${top_builddir}/introspection -I${top_srcdir}/shared \ - -I$(top_builddir)/shared -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-team"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) $(am__append_1) -pkglib_LTLIBRARIES = libnm-device-plugin-team.la -SYMBOL_VIS_FILE = $(srcdir)/exports.ver -libnm_device_plugin_team_la_SOURCES = \ - nm-device-team.c \ - nm-device-team.h \ - nm-team-factory.c \ - nm-team-factory.h - -libnm_device_plugin_team_la_LDFLAGS = \ - -module -avoid-version \ - -Wl,--version-script=$(SYMBOL_VIS_FILE) - -libnm_device_plugin_team_la_LIBADD = \ - $(top_builddir)/introspection/libnmdbus.la $(GLIB_LIBS) \ - $(GUDEV_LIBS) $(am__append_2) -EXTRA_DIST = $(SYMBOL_VIS_FILE) -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/team/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/team/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnm-device-plugin-team.la: $(libnm_device_plugin_team_la_OBJECTS) $(libnm_device_plugin_team_la_DEPENDENCIES) $(EXTRA_libnm_device_plugin_team_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_device_plugin_team_la_LINK) -rpath $(pkglibdir) $(libnm_device_plugin_team_la_OBJECTS) $(libnm_device_plugin_team_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-team.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-team-factory.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ - clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkglibLTLIBRARIES install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-team.so $(SYMBOL_VIS_FILE) -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-team.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/team/exports.ver b/src/devices/team/exports.ver deleted file mode 100644 index 24cd848c..00000000 --- a/src/devices/team/exports.ver +++ /dev/null @@ -1,6 +0,0 @@ -{ -global: - nm_device_factory_create; -local: - *; -}; diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 09eefe70..28d91ab3 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -20,6 +20,8 @@ #include "nm-default.h" +#include "nm-device-team.h" + #include #include #include @@ -27,23 +29,19 @@ #include #include -#include "nm-device-team.h" #include "NetworkManagerUtils.h" -#include "nm-device-private.h" -#include "nm-platform.h" -#include "nm-enum-types.h" +#include "devices/nm-device-private.h" +#include "platform/nm-platform.h" #include "nm-core-internal.h" #include "nm-ip4-config.h" #include "nm-dbus-compat.h" -#include "nmdbus-device-team.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Team.h" -#include "nm-device-logging.h" +#include "devices/nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceTeam); -G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) - -#define NM_DEVICE_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_TEAM, NMDeviceTeamPrivate)) +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceTeam, PROP_CONFIG, @@ -59,9 +57,24 @@ typedef struct { char *config; } NMDeviceTeamPrivate; +struct _NMDeviceTeam { + NMDevice parent; + NMDeviceTeamPrivate _priv; +}; + +struct _NMDeviceTeamClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) + +#define NM_DEVICE_TEAM_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceTeam, NM_IS_DEVICE_TEAM) + +/*****************************************************************************/ + static gboolean teamd_start (NMDevice *device, NMSettingTeam *s_team); -/******************************************************************/ +/*****************************************************************************/ static NMDeviceCapabilities get_generic_capabilities (NMDevice *device) @@ -153,18 +166,28 @@ ensure_teamd_connection (NMDevice *device) return !!priv->tdc; } +static const char * +_get_config (NMDeviceTeam *self) +{ + return nm_str_not_empty (NM_DEVICE_TEAM_GET_PRIVATE (self)->config); +} + static gboolean teamd_read_config (NMDevice *device) { NMDeviceTeam *self = NM_DEVICE_TEAM (device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); - char *config = NULL; + const char *config = NULL; int err; if (priv->tdc) { - err = teamdctl_config_actual_get_raw_direct (priv->tdc, &config); + err = teamdctl_config_actual_get_raw_direct (priv->tdc, (char **) &config); if (err) return FALSE; + if (!config) { + /* set "" to distinguish an empty result from no config at all. */ + config = ""; + } } if (!nm_streq0 (config, priv->config)) { @@ -179,7 +202,7 @@ teamd_read_config (NMDevice *device) static gboolean teamd_read_timeout_cb (gpointer user_data) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (user_data); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE ((NMDeviceTeam *) user_data); teamd_read_config ((NMDevice *) user_data); priv->teamd_read_timeout = 0; @@ -211,10 +234,10 @@ update_connection (NMDevice *device, NMConnection *connection) priv->tdc = NULL; } - g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_CONFIG, priv->config, NULL); + g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_CONFIG, _get_config (self), NULL); } -/******************************************************************/ +/*****************************************************************************/ static gboolean master_update_slave_connection (NMDevice *self, @@ -281,12 +304,12 @@ master_update_slave_connection (NMDevice *self, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static void teamd_cleanup (NMDevice *device, gboolean free_tdc) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE ((NMDeviceTeam *) device); nm_clear_g_source (&priv->teamd_process_watch); nm_clear_g_source (&priv->teamd_timeout); @@ -309,7 +332,7 @@ teamd_timeout_cb (gpointer user_data) { NMDeviceTeam *self = NM_DEVICE_TEAM (user_data); NMDevice *device = NM_DEVICE (self); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); g_return_val_if_fail (priv->teamd_timeout, FALSE); priv->teamd_timeout = 0; @@ -441,7 +464,7 @@ teamd_process_watch_cb (GPid pid, gint status, gpointer user_data) g_return_if_fail (priv->teamd_process_watch); - _LOGD (LOGD_TEAM, "teamd died with status %d", status); + _LOGD (LOGD_TEAM, "teamd %lld died with status %d", (long long) pid, status); priv->teamd_pid = 0; priv->teamd_process_watch = 0; @@ -451,12 +474,19 @@ teamd_process_watch_cb (GPid pid, gint status, gpointer user_data) if (priv->teamd_timeout && (state >= NM_DEVICE_STATE_PREPARE) && (state <= NM_DEVICE_STATE_ACTIVATED)) { - _LOGW (LOGD_TEAM, "teamd process quit unexpectedly; failing activation"); + _LOGW (LOGD_TEAM, "teamd process %lld quit unexpectedly; failing activation", (long long) pid); teamd_cleanup (device, TRUE); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); } } +static void +teamd_child_setup (gpointer user_data) +{ + nm_utils_setpgid (NULL); + signal (SIGPIPE, SIG_IGN); +} + static gboolean teamd_kill (NMDeviceTeam *self, const char *teamd_binary, GError **error) { @@ -479,7 +509,7 @@ teamd_kill (NMDeviceTeam *self, const char *teamd_binary, GError **error) g_ptr_array_add (argv, NULL); _LOGD (LOGD_TEAM, "running: %s", (tmp_str = g_strjoinv (" ", (gchar **) argv->pdata))); - return g_spawn_sync ("/", (char **) argv->pdata, NULL, 0, NULL, NULL, NULL, NULL, NULL, error); + return g_spawn_sync ("/", (char **) argv->pdata, NULL, 0, teamd_child_setup, NULL, NULL, NULL, NULL, error); } static gboolean @@ -530,7 +560,7 @@ teamd_start (NMDevice *device, NMSettingTeam *s_team) _LOGD (LOGD_TEAM, "running: %s", (tmp_str = g_strjoinv (" ", (gchar **) argv->pdata))); if (!g_spawn_async ("/", (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD, - nm_utils_setpgid, NULL, &priv->teamd_pid, &error)) { + teamd_child_setup, NULL, &priv->teamd_pid, &error)) { _LOGW (LOGD_TEAM, "Activation: (team) failed to start teamd: %s", error->message); teamd_cleanup (device, TRUE); return FALSE; @@ -597,25 +627,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) NM_ACT_STAGE_RETURN_POSTPONE : NM_ACT_STAGE_RETURN_FAILURE; } -static void -ip4_config_pre_commit (NMDevice *self, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - - connection = nm_device_get_applied_connection (self); - g_assert (connection); - s_wired = nm_connection_get_setting_wired (connection); - - if (s_wired) { - /* MTU override */ - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); - } -} - static void deactivate (NMDevice *device) { @@ -637,7 +648,7 @@ enslave_slave (NMDevice *device, gboolean configure) { NMDeviceTeam *self = NM_DEVICE_TEAM (device); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); gboolean success = TRUE, no_firmware = FALSE; const char *slave_iface = nm_device_get_ip_iface (slave); NMSettingTeamPort *s_team_port; @@ -696,7 +707,7 @@ release_slave (NMDevice *device, gboolean configure) { NMDeviceTeam *self = NM_DEVICE_TEAM (device); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); gboolean success, no_firmware = FALSE; if (configure) { @@ -748,31 +759,17 @@ create_and_realize (NMDevice *device, return TRUE; } -/******************************************************************/ - -NMDevice * -nm_device_team_new (const char *iface) -{ - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_TEAM, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, "team", - NM_DEVICE_TYPE_DESC, "Team", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_TEAM, - NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_TEAM, - NM_DEVICE_IS_MASTER, TRUE, - NULL); -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMDeviceTeam *self = NM_DEVICE_TEAM (object); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); switch (prop_id) { case PROP_CONFIG: - g_value_set_string (value, priv->config); + g_value_set_string (value, _get_config (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -780,6 +777,8 @@ get_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + static void nm_device_team_init (NMDeviceTeam * self) { @@ -789,7 +788,7 @@ static void constructed (GObject *object) { NMDevice *device = NM_DEVICE (object); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE ((NMDeviceTeam *) device); char *tmp_str = NULL; G_OBJECT_CLASS (nm_device_team_parent_class)->constructed (object); @@ -806,11 +805,24 @@ constructed (GObject *object) g_free (tmp_str); } +NMDevice * +nm_device_team_new (const char *iface) +{ + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_TEAM, + NM_DEVICE_IFACE, iface, + NM_DEVICE_DRIVER, "team", + NM_DEVICE_TYPE_DESC, "Team", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_TEAM, + NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_TEAM, + NM_DEVICE_IS_MASTER, TRUE, + NULL); +} + static void dispose (GObject *object) { NMDevice *device = NM_DEVICE (object); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE ((NMDeviceTeam *) device); if (priv->teamd_dbus_watch) { g_bus_unwatch_name (priv->teamd_dbus_watch); @@ -829,8 +841,6 @@ nm_device_team_class_init (NMDeviceTeamClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceTeamPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_TEAM_SETTING_NAME, NM_LINK_TYPE_TEAM) object_class->constructed = constructed; @@ -847,7 +857,7 @@ nm_device_team_class_init (NMDeviceTeamClass *klass) parent_class->master_update_slave_connection = master_update_slave_connection; parent_class->act_stage1_prepare = act_stage1_prepare; - parent_class->ip4_config_pre_commit = ip4_config_pre_commit; + parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; parent_class->deactivate = deactivate; parent_class->enslave_slave = enslave_slave; parent_class->release_slave = release_slave; diff --git a/src/devices/team/nm-device-team.h b/src/devices/team/nm-device-team.h index 43e8aab4..bbb1417f 100644 --- a/src/devices/team/nm-device-team.h +++ b/src/devices/team/nm-device-team.h @@ -21,7 +21,7 @@ #ifndef __NETWORKMANAGER_DEVICE_TEAM_H__ #define __NETWORKMANAGER_DEVICE_TEAM_H__ -#include "nm-device.h" +#include "devices/nm-device.h" #define NM_TYPE_DEVICE_TEAM (nm_device_team_get_type ()) #define NM_DEVICE_TEAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeam)) @@ -33,8 +33,8 @@ /* Properties */ #define NM_DEVICE_TEAM_CONFIG "config" -typedef NMDevice NMDeviceTeam; -typedef NMDeviceClass NMDeviceTeamClass; +typedef struct _NMDeviceTeam NMDeviceTeam; +typedef struct _NMDeviceTeamClass NMDeviceTeamClass; GType nm_device_team_get_type (void); diff --git a/src/devices/team/nm-team-factory.c b/src/devices/team/nm-team-factory.c index 971efe87..d062429f 100644 --- a/src/devices/team/nm-team-factory.c +++ b/src/devices/team/nm-team-factory.c @@ -23,28 +23,48 @@ #include #include -#include "nm-device-factory.h" -#include "nm-team-factory.h" +#include "nm-manager.h" +#include "devices/nm-device-factory.h" #include "nm-device-team.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-core-internal.h" +/*****************************************************************************/ + +#define NM_TYPE_TEAM_FACTORY (nm_team_factory_get_type ()) +#define NM_TEAM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_TEAM_FACTORY, NMTeamFactory)) +#define NM_TEAM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_TEAM_FACTORY, NMTeamFactoryClass)) +#define NM_IS_TEAM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_TEAM_FACTORY)) +#define NM_IS_TEAM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_TEAM_FACTORY)) +#define NM_TEAM_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_TEAM_FACTORY, NMTeamFactoryClass)) + +typedef struct { + NMDeviceFactory parent; +} NMTeamFactory; + +typedef struct { + NMDeviceFactoryClass parent; +} NMTeamFactoryClass; + static GType nm_team_factory_get_type (void); -static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); +G_DEFINE_TYPE (NMTeamFactory, nm_team_factory, NM_TYPE_DEVICE_FACTORY) -G_DEFINE_TYPE_EXTENDED (NMTeamFactory, nm_team_factory, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) +/*****************************************************************************/ -/************************************************************************/ +NM_DEVICE_FACTORY_DECLARE_TYPES ( + NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_TEAM) + NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_TEAM_SETTING_NAME) +) G_MODULE_EXPORT NMDeviceFactory * nm_device_factory_create (GError **error) { + nm_manager_set_capability (nm_manager_get (), NM_CAPABILITY_TEAM); return (NMDeviceFactory *) g_object_new (NM_TYPE_TEAM_FACTORY, NULL); } -/************************************************************************/ +/*****************************************************************************/ static NMDevice * create_device (NMDeviceFactory *factory, @@ -56,26 +76,18 @@ create_device (NMDeviceFactory *factory, return nm_device_team_new (iface); } -NM_DEVICE_FACTORY_DECLARE_TYPES ( - NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_TEAM) - NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_TEAM_SETTING_NAME) -) - -/************************************************************************/ +/*****************************************************************************/ static void nm_team_factory_init (NMTeamFactory *self) { } -static void -device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) -{ - factory_iface->create_device = create_device; - factory_iface->get_supported_types = get_supported_types; -} - static void nm_team_factory_class_init (NMTeamFactoryClass *klass) { + NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS (klass); + + factory_class->create_device = create_device; + factory_class->get_supported_types = get_supported_types; } diff --git a/src/devices/team/nm-team-factory.h b/src/devices/team/nm-team-factory.h deleted file mode 100644 index 4155870c..00000000 --- a/src/devices/team/nm-team-factory.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2014 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_TEAM_FACTORY_H__ -#define __NETWORKMANAGER_TEAM_FACTORY_H__ - -#define NM_TYPE_TEAM_FACTORY (nm_team_factory_get_type ()) -#define NM_TEAM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_TEAM_FACTORY, NMTeamFactory)) - -typedef struct { - GObject parent; -} NMTeamFactory; - -typedef struct { - GObjectClass parent; -} NMTeamFactoryClass; - -#endif /* __NETWORKMANAGER_TEAM_FACTORY_H__ */ diff --git a/src/devices/tests/Makefile.am b/src/devices/tests/Makefile.am deleted file mode 100644 index cd1ef6ed..00000000 --- a/src/devices/tests/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/devices \ - -I$(top_srcdir)/src/systemd/ \ - -I$(top_srcdir)/src/systemd/src/systemd/ \ - -I$(top_srcdir)/src/systemd/src/libsystemd-network/ \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -AM_LDFLAGS = $(GLIB_LIBS) $(CODE_COVERAGE_LDFLAGS) -DEVICES_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -@GNOME_CODE_COVERAGE_RULES@ - -noinst_PROGRAMS = \ - test-lldp \ - test-arping - -test_lldp_SOURCES = \ - test-lldp.c \ - ../nm-lldp-listener.c \ - $(top_srcdir)/src/platform/tests/test-common.c - -test_lldp_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_linux_platform_setup - -test_lldp_LDADD = $(DEVICES_LDADD) - -test_arping_SOURCES = \ - test-arping.c \ - ../nm-arping-manager.c \ - $(top_srcdir)/src/platform/tests/test-common.c - -test_arping_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_linux_platform_setup - -test_arping_LDADD = $(DEVICES_LDADD) - -@VALGRIND_RULES@ -TESTS = \ - test-lldp \ - test-arping diff --git a/src/devices/tests/Makefile.in b/src/devices/tests/Makefile.in deleted file mode 100644 index 866fe0e1..00000000 --- a/src/devices/tests/Makefile.in +++ /dev/null @@ -1,1273 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-lldp$(EXEEXT) test-arping$(EXEEXT) -TESTS = test-lldp$(EXEEXT) test-arping$(EXEEXT) -subdir = src/devices/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_arping_OBJECTS = test_arping-test-arping.$(OBJEXT) \ - test_arping-nm-arping-manager.$(OBJEXT) \ - test_arping-test-common.$(OBJEXT) -test_arping_OBJECTS = $(am_test_arping_OBJECTS) -test_arping_DEPENDENCIES = $(DEVICES_LDADD) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -am_test_lldp_OBJECTS = test_lldp-test-lldp.$(OBJEXT) \ - test_lldp-nm-lldp-listener.$(OBJEXT) \ - test_lldp-test-common.$(OBJEXT) -test_lldp_OBJECTS = $(am_test_lldp_OBJECTS) -test_lldp_DEPENDENCIES = $(DEVICES_LDADD) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_arping_SOURCES) $(test_lldp_SOURCES) -DIST_SOURCES = $(test_arping_SOURCES) $(test_lldp_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/devices \ - -I$(top_srcdir)/src/systemd/ \ - -I$(top_srcdir)/src/systemd/src/systemd/ \ - -I$(top_srcdir)/src/systemd/src/libsystemd-network/ \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -AM_LDFLAGS = $(GLIB_LIBS) $(CODE_COVERAGE_LDFLAGS) -DEVICES_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -test_lldp_SOURCES = \ - test-lldp.c \ - ../nm-lldp-listener.c \ - $(top_srcdir)/src/platform/tests/test-common.c - -test_lldp_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_linux_platform_setup - -test_lldp_LDADD = $(DEVICES_LDADD) -test_arping_SOURCES = \ - test-arping.c \ - ../nm-arping-manager.c \ - $(top_srcdir)/src/platform/tests/test-common.c - -test_arping_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_linux_platform_setup - -test_arping_LDADD = $(DEVICES_LDADD) -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-arping$(EXEEXT): $(test_arping_OBJECTS) $(test_arping_DEPENDENCIES) $(EXTRA_test_arping_DEPENDENCIES) - @rm -f test-arping$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_arping_OBJECTS) $(test_arping_LDADD) $(LIBS) - -test-lldp$(EXEEXT): $(test_lldp_OBJECTS) $(test_lldp_DEPENDENCIES) $(EXTRA_test_lldp_DEPENDENCIES) - @rm -f test-lldp$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_lldp_OBJECTS) $(test_lldp_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_arping-nm-arping-manager.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_arping-test-arping.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_arping-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_lldp-nm-lldp-listener.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_lldp-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_lldp-test-lldp.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -test_arping-test-arping.o: test-arping.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_arping-test-arping.o -MD -MP -MF $(DEPDIR)/test_arping-test-arping.Tpo -c -o test_arping-test-arping.o `test -f 'test-arping.c' || echo '$(srcdir)/'`test-arping.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_arping-test-arping.Tpo $(DEPDIR)/test_arping-test-arping.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-arping.c' object='test_arping-test-arping.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_arping-test-arping.o `test -f 'test-arping.c' || echo '$(srcdir)/'`test-arping.c - -test_arping-test-arping.obj: test-arping.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_arping-test-arping.obj -MD -MP -MF $(DEPDIR)/test_arping-test-arping.Tpo -c -o test_arping-test-arping.obj `if test -f 'test-arping.c'; then $(CYGPATH_W) 'test-arping.c'; else $(CYGPATH_W) '$(srcdir)/test-arping.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_arping-test-arping.Tpo $(DEPDIR)/test_arping-test-arping.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-arping.c' object='test_arping-test-arping.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_arping-test-arping.obj `if test -f 'test-arping.c'; then $(CYGPATH_W) 'test-arping.c'; else $(CYGPATH_W) '$(srcdir)/test-arping.c'; fi` - -test_arping-nm-arping-manager.o: ../nm-arping-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_arping-nm-arping-manager.o -MD -MP -MF $(DEPDIR)/test_arping-nm-arping-manager.Tpo -c -o test_arping-nm-arping-manager.o `test -f '../nm-arping-manager.c' || echo '$(srcdir)/'`../nm-arping-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_arping-nm-arping-manager.Tpo $(DEPDIR)/test_arping-nm-arping-manager.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-arping-manager.c' object='test_arping-nm-arping-manager.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_arping-nm-arping-manager.o `test -f '../nm-arping-manager.c' || echo '$(srcdir)/'`../nm-arping-manager.c - -test_arping-nm-arping-manager.obj: ../nm-arping-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_arping-nm-arping-manager.obj -MD -MP -MF $(DEPDIR)/test_arping-nm-arping-manager.Tpo -c -o test_arping-nm-arping-manager.obj `if test -f '../nm-arping-manager.c'; then $(CYGPATH_W) '../nm-arping-manager.c'; else $(CYGPATH_W) '$(srcdir)/../nm-arping-manager.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_arping-nm-arping-manager.Tpo $(DEPDIR)/test_arping-nm-arping-manager.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-arping-manager.c' object='test_arping-nm-arping-manager.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_arping-nm-arping-manager.obj `if test -f '../nm-arping-manager.c'; then $(CYGPATH_W) '../nm-arping-manager.c'; else $(CYGPATH_W) '$(srcdir)/../nm-arping-manager.c'; fi` - -test_arping-test-common.o: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_arping-test-common.o -MD -MP -MF $(DEPDIR)/test_arping-test-common.Tpo -c -o test_arping-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_arping-test-common.Tpo $(DEPDIR)/test_arping-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_arping-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_arping-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c - -test_arping-test-common.obj: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_arping-test-common.obj -MD -MP -MF $(DEPDIR)/test_arping-test-common.Tpo -c -o test_arping-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_arping-test-common.Tpo $(DEPDIR)/test_arping-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_arping-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_arping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_arping-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` - -test_lldp-test-lldp.o: test-lldp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_lldp-test-lldp.o -MD -MP -MF $(DEPDIR)/test_lldp-test-lldp.Tpo -c -o test_lldp-test-lldp.o `test -f 'test-lldp.c' || echo '$(srcdir)/'`test-lldp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lldp-test-lldp.Tpo $(DEPDIR)/test_lldp-test-lldp.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-lldp.c' object='test_lldp-test-lldp.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_lldp-test-lldp.o `test -f 'test-lldp.c' || echo '$(srcdir)/'`test-lldp.c - -test_lldp-test-lldp.obj: test-lldp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_lldp-test-lldp.obj -MD -MP -MF $(DEPDIR)/test_lldp-test-lldp.Tpo -c -o test_lldp-test-lldp.obj `if test -f 'test-lldp.c'; then $(CYGPATH_W) 'test-lldp.c'; else $(CYGPATH_W) '$(srcdir)/test-lldp.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lldp-test-lldp.Tpo $(DEPDIR)/test_lldp-test-lldp.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-lldp.c' object='test_lldp-test-lldp.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_lldp-test-lldp.obj `if test -f 'test-lldp.c'; then $(CYGPATH_W) 'test-lldp.c'; else $(CYGPATH_W) '$(srcdir)/test-lldp.c'; fi` - -test_lldp-nm-lldp-listener.o: ../nm-lldp-listener.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_lldp-nm-lldp-listener.o -MD -MP -MF $(DEPDIR)/test_lldp-nm-lldp-listener.Tpo -c -o test_lldp-nm-lldp-listener.o `test -f '../nm-lldp-listener.c' || echo '$(srcdir)/'`../nm-lldp-listener.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lldp-nm-lldp-listener.Tpo $(DEPDIR)/test_lldp-nm-lldp-listener.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-lldp-listener.c' object='test_lldp-nm-lldp-listener.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_lldp-nm-lldp-listener.o `test -f '../nm-lldp-listener.c' || echo '$(srcdir)/'`../nm-lldp-listener.c - -test_lldp-nm-lldp-listener.obj: ../nm-lldp-listener.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_lldp-nm-lldp-listener.obj -MD -MP -MF $(DEPDIR)/test_lldp-nm-lldp-listener.Tpo -c -o test_lldp-nm-lldp-listener.obj `if test -f '../nm-lldp-listener.c'; then $(CYGPATH_W) '../nm-lldp-listener.c'; else $(CYGPATH_W) '$(srcdir)/../nm-lldp-listener.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lldp-nm-lldp-listener.Tpo $(DEPDIR)/test_lldp-nm-lldp-listener.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-lldp-listener.c' object='test_lldp-nm-lldp-listener.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_lldp-nm-lldp-listener.obj `if test -f '../nm-lldp-listener.c'; then $(CYGPATH_W) '../nm-lldp-listener.c'; else $(CYGPATH_W) '$(srcdir)/../nm-lldp-listener.c'; fi` - -test_lldp-test-common.o: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_lldp-test-common.o -MD -MP -MF $(DEPDIR)/test_lldp-test-common.Tpo -c -o test_lldp-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lldp-test-common.Tpo $(DEPDIR)/test_lldp-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_lldp-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_lldp-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c - -test_lldp-test-common.obj: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_lldp-test-common.obj -MD -MP -MF $(DEPDIR)/test_lldp-test-common.Tpo -c -o test_lldp-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_lldp-test-common.Tpo $(DEPDIR)/test_lldp-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_lldp-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_lldp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_lldp-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-lldp.log: test-lldp$(EXEEXT) - @p='test-lldp$(EXEEXT)'; \ - b='test-lldp'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-arping.log: test-arping$(EXEEXT) - @p='test-arping$(EXEEXT)'; \ - b='test-arping'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/tests/test-arping.c b/src/devices/tests/test-arping.c index 244d0715..59223f11 100644 --- a/src/devices/tests/test-arping.c +++ b/src/devices/tests/test-arping.c @@ -20,8 +20,8 @@ #include "nm-default.h" -#include "nm-arping-manager.h" -#include "test-common.h" +#include "devices/nm-arping-manager.h" +#include "platform/tests/test-common.h" #define IFACE_VETH0 "nm-test-veth0" #define IFACE_VETH1 "nm-test-veth1" @@ -125,6 +125,8 @@ fixture_teardown (test_fixture *fixture, gconstpointer user_data) nm_platform_link_delete (NM_PLATFORM_GET, fixture->ifindex1); } +NMTstpSetupFunc const _nmtstp_setup_platform_func = nm_linux_platform_setup; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c index f6b6af90..4d25f9a6 100644 --- a/src/devices/tests/test-lldp.c +++ b/src/devices/tests/test-lldp.c @@ -26,12 +26,10 @@ #include #include -#include "nm-lldp-listener.h" -#include "nm-sd.h" +#include "devices/nm-lldp-listener.h" +#include "systemd/nm-sd.h" -#include "sd-lldp.h" - -#include "test-common.h" +#include "platform/tests/test-common.h" #include "nm-test-utils-core.h" @@ -434,6 +432,8 @@ _test_recv_fixture_teardown (TestRecvFixture *fixture, gconstpointer user_data) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = nm_linux_platform_setup; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/devices/wifi/Makefile.am b/src/devices/wifi/Makefile.am deleted file mode 100644 index add0a007..00000000 --- a/src/devices/wifi/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -if ENABLE_TESTS -SUBDIRS=. tests -endif - -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/settings \ - -I${top_srcdir}/src/platform \ - -I${top_srcdir}/src/supplicant-manager \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -pkglib_LTLIBRARIES = libnm-device-plugin-wifi.la - -libnm_device_plugin_wifi_la_SOURCES = \ - nm-wifi-factory.c \ - nm-device-wifi.c \ - nm-device-wifi.h \ - nm-wifi-ap.c \ - nm-wifi-ap.h \ - nm-wifi-ap-utils.c \ - nm-wifi-ap-utils.h \ - nm-device-olpc-mesh.c \ - nm-device-olpc-mesh.h - -SYMBOL_VIS_FILE=$(srcdir)/exports.ver - -libnm_device_plugin_wifi_la_LDFLAGS = \ - -module -avoid-version \ - -Wl,--version-script=$(SYMBOL_VIS_FILE) - -libnm_device_plugin_wifi_la_LIBADD = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) - -EXTRA_DIST = $(SYMBOL_VIS_FILE) - -if ENABLE_TESTS - -check-local: - $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-wifi.so $(SYMBOL_VIS_FILE) - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-wifi.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - diff --git a/src/devices/wifi/Makefile.in b/src/devices/wifi/Makefile.in deleted file mode 100644 index 42246d5c..00000000 --- a/src/devices/wifi/Makefile.in +++ /dev/null @@ -1,982 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/devices/wifi -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(pkglib_LTLIBRARIES) -am__DEPENDENCIES_1 = -libnm_device_plugin_wifi_la_DEPENDENCIES = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am_libnm_device_plugin_wifi_la_OBJECTS = nm-wifi-factory.lo \ - nm-device-wifi.lo nm-wifi-ap.lo nm-wifi-ap-utils.lo \ - nm-device-olpc-mesh.lo -libnm_device_plugin_wifi_la_OBJECTS = \ - $(am_libnm_device_plugin_wifi_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_device_plugin_wifi_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(libnm_device_plugin_wifi_la_LDFLAGS) \ - $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libnm_device_plugin_wifi_la_SOURCES) -DIST_SOURCES = $(libnm_device_plugin_wifi_la_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = . tests -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@ENABLE_TESTS_TRUE@SUBDIRS = . tests -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/settings \ - -I${top_srcdir}/src/platform \ - -I${top_srcdir}/src/supplicant-manager \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_builddir}/libnm-core \ - -I${top_srcdir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -pkglib_LTLIBRARIES = libnm-device-plugin-wifi.la -libnm_device_plugin_wifi_la_SOURCES = \ - nm-wifi-factory.c \ - nm-device-wifi.c \ - nm-device-wifi.h \ - nm-wifi-ap.c \ - nm-wifi-ap.h \ - nm-wifi-ap-utils.c \ - nm-wifi-ap-utils.h \ - nm-device-olpc-mesh.c \ - nm-device-olpc-mesh.h - -SYMBOL_VIS_FILE = $(srcdir)/exports.ver -libnm_device_plugin_wifi_la_LDFLAGS = \ - -module -avoid-version \ - -Wl,--version-script=$(SYMBOL_VIS_FILE) - -libnm_device_plugin_wifi_la_LIBADD = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) - -EXTRA_DIST = $(SYMBOL_VIS_FILE) -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/wifi/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/wifi/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnm-device-plugin-wifi.la: $(libnm_device_plugin_wifi_la_OBJECTS) $(libnm_device_plugin_wifi_la_DEPENDENCIES) $(EXTRA_libnm_device_plugin_wifi_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_device_plugin_wifi_la_LINK) -rpath $(pkglibdir) $(libnm_device_plugin_wifi_la_OBJECTS) $(libnm_device_plugin_wifi_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-olpc-mesh.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-wifi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-wifi-ap-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-wifi-ap.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-wifi-factory.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: check-recursive -all-am: Makefile $(LTLIBRARIES) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: $(am__recursive_targets) check-am install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am check-local clean clean-generic clean-libtool \ - clean-pkglibLTLIBRARIES cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-pkglibLTLIBRARIES \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am \ - uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-wifi.so $(SYMBOL_VIS_FILE) -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-wifi.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/wifi/exports.ver b/src/devices/wifi/exports.ver deleted file mode 100644 index 24cd848c..00000000 --- a/src/devices/wifi/exports.ver +++ /dev/null @@ -1,6 +0,0 @@ -{ -global: - nm_device_factory_create; -local: - *; -}; diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 6fbc63a1..e0258523 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -26,6 +26,8 @@ #include "nm-default.h" +#include "nm-device-olpc-mesh.h" + #include #include #include @@ -35,46 +37,52 @@ #include #include -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-device-wifi.h" -#include "nm-device-olpc-mesh.h" -#include "nm-device-private.h" +#include "devices/nm-device-private.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" -#include "nm-activation-request.h" +#include "nm-act-request.h" #include "nm-setting-connection.h" #include "nm-setting-olpc-mesh.h" #include "nm-manager.h" -#include "nm-enum-types.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" /* This is a bug; but we can't really change API now... */ #include "nm-vpn-dbus-interface.h" -#include "nmdbus-device-olpc-mesh.h" +#include "introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.h" -#include "nm-device-logging.h" +#include "devices/nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceOlpcMesh); -G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) - -#define NM_DEVICE_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshPrivate)) +/*****************************************************************************/ -enum { - PROP_0, +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceOlpcMesh, PROP_COMPANION, PROP_ACTIVE_CHANNEL, +); - LAST_PROP -}; - -struct _NMDeviceOlpcMeshPrivate { +typedef struct { NMDevice *companion; NMManager *manager; gboolean stage1_waiting; +} NMDeviceOlpcMeshPrivate; + +struct _NMDeviceOlpcMesh { + NMDevice parent; + NMDeviceOlpcMeshPrivate _priv; }; -/*******************************************************************/ +struct _NMDeviceOlpcMeshClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) + +#define NM_DEVICE_OLPC_MESH_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceOlpcMesh, NM_IS_DEVICE_OLPC_MESH) + +/*****************************************************************************/ static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) @@ -103,6 +111,8 @@ can_auto_connect (NMDevice *device, NMConnection *connection, char **specific_object) { + nm_assert (!specific_object || !*specific_object); + return FALSE; } @@ -150,13 +160,13 @@ complete_connection (NMDevice *device, return TRUE; } -/****************************************************************************/ +/*****************************************************************************/ static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); NMActStageReturn ret; gboolean scanning; @@ -178,7 +188,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) /* wait with continuing configuration untill the companion device is done scanning */ - g_object_get (priv->companion, "scanning", &scanning, NULL); + g_object_get (priv->companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL); if (scanning) { priv->stage1_waiting = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; @@ -194,7 +204,7 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel) if (nm_platform_mesh_get_channel (NM_PLATFORM_GET, ifindex) != channel) { if (nm_platform_mesh_set_channel (NM_PLATFORM_GET, ifindex, channel)) - g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL); + _notify (self, PROP_ACTIVE_CHANNEL); } } @@ -243,7 +253,7 @@ is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) return TRUE; } -/*******************************************************************/ +/*****************************************************************************/ static void companion_cleanup (NMDeviceOlpcMesh *self) @@ -254,7 +264,7 @@ companion_cleanup (NMDeviceOlpcMesh *self) g_signal_handlers_disconnect_by_data (priv->companion, self); g_clear_object (&priv->companion); } - g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_COMPANION); + _notify (self, PROP_COMPANION); } static void @@ -267,7 +277,7 @@ companion_notify_cb (NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_d if (!priv->stage1_waiting) return; - g_object_get (companion, "scanning", &scanning, NULL); + g_object_get (companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL); if (!scanning) { priv->stage1_waiting = FALSE; @@ -343,16 +353,16 @@ check_companion (NMDeviceOlpcMesh *self, NMDevice *other) g_signal_connect (G_OBJECT (other), NM_DEVICE_STATE_CHANGED, G_CALLBACK (companion_state_changed_cb), self); - g_signal_connect (G_OBJECT (other), "notify::scanning", + g_signal_connect (G_OBJECT (other), "notify::" NM_DEVICE_WIFI_SCANNING, G_CALLBACK (companion_notify_cb), self); - g_signal_connect (G_OBJECT (other), "scanning-allowed", + g_signal_connect (G_OBJECT (other), NM_DEVICE_WIFI_SCANNING_ALLOWED, G_CALLBACK (companion_scan_allowed_cb), self); - g_signal_connect (G_OBJECT (other), "autoconnect-allowed", + g_signal_connect (G_OBJECT (other), NM_DEVICE_AUTOCONNECT_ALLOWED, G_CALLBACK (companion_autoconnect_allowed_cb), self); - g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_COMPANION); + _notify (self, PROP_COMPANION); return TRUE; } @@ -413,19 +423,30 @@ state_changed (NMDevice *device, find_companion (NM_DEVICE_OLPC_MESH (device)); } -/*******************************************************************/ +/*****************************************************************************/ -NMDevice * -nm_device_olpc_mesh_new (const char *iface) +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_OLPC_MESH, - NM_DEVICE_IFACE, iface, - NM_DEVICE_TYPE_DESC, "802.11 OLPC Mesh", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_OLPC_MESH, - NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_OLPC_MESH, - NULL); + NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object); + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); + + switch (prop_id) { + case PROP_COMPANION: + nm_utils_g_value_set_object_path (value, priv->companion); + break; + case PROP_ACTIVE_CHANNEL: + g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device)))); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } +/*****************************************************************************/ + static void nm_device_olpc_mesh_init (NMDeviceOlpcMesh * self) { @@ -448,35 +469,15 @@ constructed (GObject *object) nm_device_set_dhcp_timeout (NM_DEVICE (self), 20); } -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object); - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); - - switch (prop_id) { - case PROP_COMPANION: - nm_utils_g_value_set_object_path (value, priv->companion); - break; - case PROP_ACTIVE_CHANNEL: - g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device)))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +NMDevice * +nm_device_olpc_mesh_new (const char *iface) { - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_OLPC_MESH, + NM_DEVICE_IFACE, iface, + NM_DEVICE_TYPE_DESC, "802.11 OLPC Mesh", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_OLPC_MESH, + NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_OLPC_MESH, + NULL); } static void @@ -502,39 +503,33 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceOlpcMeshPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_OLPC_MESH_SETTING_NAME, NM_LINK_TYPE_OLPC_MESH) object_class->constructed = constructed; object_class->get_property = get_property; - object_class->set_property = set_property; object_class->dispose = dispose; parent_class->check_connection_compatible = check_connection_compatible; parent_class->can_auto_connect = can_auto_connect; parent_class->complete_connection = complete_connection; - parent_class->is_available = is_available; parent_class->act_stage1_prepare = act_stage1_prepare; parent_class->act_stage2_config = act_stage2_config; - parent_class->state_changed = state_changed; - /* Properties */ - g_object_class_install_property - (object_class, PROP_COMPANION, - 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, - g_param_spec_uint (NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_COMPANION] = + g_param_spec_string (NM_DEVICE_OLPC_MESH_COMPANION, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_ACTIVE_CHANNEL] = + g_param_spec_uint (NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_OLPC_MESH_SKELETON, diff --git a/src/devices/wifi/nm-device-olpc-mesh.h b/src/devices/wifi/nm-device-olpc-mesh.h index 135226d5..bf0e4da9 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.h +++ b/src/devices/wifi/nm-device-olpc-mesh.h @@ -28,7 +28,7 @@ #ifndef __NETWORKMANAGER_DEVICE_OLPC_MESH_H__ #define __NETWORKMANAGER_DEVICE_OLPC_MESH_H__ -#include "nm-device.h" +#include "devices/nm-device.h" #define NM_TYPE_DEVICE_OLPC_MESH (nm_device_olpc_mesh_get_type ()) #define NM_DEVICE_OLPC_MESH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMesh)) @@ -41,25 +41,8 @@ #define NM_DEVICE_OLPC_MESH_BITRATE "bitrate" #define NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL "active-channel" -#ifndef NM_DEVICE_OLPC_MESH_DEFINED -#define NM_DEVICE_OLPC_MESH_DEFINED typedef struct _NMDeviceOlpcMesh NMDeviceOlpcMesh; -#endif - typedef struct _NMDeviceOlpcMeshClass NMDeviceOlpcMeshClass; -typedef struct _NMDeviceOlpcMeshPrivate NMDeviceOlpcMeshPrivate; - -struct _NMDeviceOlpcMesh -{ - NMDevice parent; -}; - -struct _NMDeviceOlpcMeshClass -{ - NMDeviceClass parent; - -}; - GType nm_device_olpc_mesh_get_type (void); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index c58b3fa8..ed5d2c62 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -29,14 +29,14 @@ #include #include "nm-common-macros.h" -#include "nm-device.h" -#include "nm-device-private.h" +#include "devices/nm-device.h" +#include "devices/nm-device-private.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" -#include "nm-activation-request.h" -#include "nm-supplicant-manager.h" -#include "nm-supplicant-interface.h" -#include "nm-supplicant-config.h" +#include "nm-act-request.h" +#include "supplicant/nm-supplicant-manager.h" +#include "supplicant/nm-supplicant-interface.h" +#include "supplicant/nm-supplicant-config.h" #include "nm-setting-connection.h" #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" @@ -44,17 +44,16 @@ #include "nm-setting-ip4-config.h" #include "nm-ip4-config.h" #include "nm-setting-ip6-config.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-auth-utils.h" -#include "nm-settings-connection.h" -#include "nm-settings.h" -#include "nm-enum-types.h" +#include "settings/nm-settings-connection.h" +#include "settings/nm-settings.h" #include "nm-core-internal.h" #include "nm-config.h" -#include "nmdbus-device-wifi.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Wireless.h" -#include "nm-device-logging.h" +#include "devices/nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceWifi); /* All of these are in seconds */ @@ -91,7 +90,7 @@ typedef struct { gint8 invalid_strength_counter; GHashTable * aps; - NMAccessPoint * current_ap; + NMWifiAP * current_ap; guint32 rate; bool enabled:1; /* rfkilled or not */ bool requested_scan:1; @@ -109,6 +108,8 @@ typedef struct { NM80211Mode mode; + NMActRequestGetSecretsCallId wifi_secrets_id; + guint periodic_source_id; guint link_timeout_id; guint32 failed_iface_count; @@ -185,7 +186,7 @@ static void request_wireless_scan (NMDeviceWifi *self, GVariant *scan_options); static void ap_add_remove (NMDeviceWifi *self, guint signum, - NMAccessPoint *ap, + NMWifiAP *ap, gboolean recheck_available_connections); static void remove_supplicant_interface_error_handler (NMDeviceWifi *self); @@ -231,7 +232,7 @@ supplicant_interface_acquire (NMDeviceWifi *self) priv->sup_iface = nm_supplicant_manager_create_interface (priv->sup_mgr, nm_device_get_iface (NM_DEVICE (self)), - TRUE); + NM_SUPPLICANT_DRIVER_WIRELESS); if (!priv->sup_iface) { _LOGE (LOGD_WIFI, "Couldn't initialize supplicant interface"); return FALSE; @@ -321,7 +322,7 @@ supplicant_interface_release (NMDeviceWifi *self) } } -static NMAccessPoint * +static NMWifiAP * get_ap_by_path (NMDeviceWifi *self, const char *path) { g_return_val_if_fail (path != NULL, NULL); @@ -329,24 +330,24 @@ get_ap_by_path (NMDeviceWifi *self, const char *path) } -static NMAccessPoint * +static NMWifiAP * get_ap_by_supplicant_path (NMDeviceWifi *self, const char *path) { GHashTableIter iter; - NMAccessPoint *ap; + NMWifiAP *ap; g_return_val_if_fail (path != NULL, NULL); g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps); while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) { - if (g_strcmp0 (path, nm_ap_get_supplicant_path (ap)) == 0) + if (g_strcmp0 (path, nm_wifi_ap_get_supplicant_path (ap)) == 0) return ap; } return NULL; } static void -update_seen_bssids_cache (NMDeviceWifi *self, NMAccessPoint *ap) +update_seen_bssids_cache (NMDeviceWifi *self, NMWifiAP *ap) { g_return_if_fail (NM_IS_DEVICE_WIFI (self)); @@ -354,21 +355,21 @@ update_seen_bssids_cache (NMDeviceWifi *self, NMAccessPoint *ap) return; /* Don't cache the BSSID for Ad-Hoc APs */ - if (nm_ap_get_mode (ap) != NM_802_11_MODE_INFRA) + if (nm_wifi_ap_get_mode (ap) != NM_802_11_MODE_INFRA) return; if ( nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED && nm_device_has_unmodified_applied_connection (NM_DEVICE (self), NM_SETTING_COMPARE_FLAG_NONE)) { nm_settings_connection_add_seen_bssid (nm_device_get_settings_connection (NM_DEVICE (self)), - nm_ap_get_address (ap)); + nm_wifi_ap_get_address (ap)); } } static void -set_current_ap (NMDeviceWifi *self, NMAccessPoint *new_ap, gboolean recheck_available_connections) +set_current_ap (NMDeviceWifi *self, NMWifiAP *new_ap, gboolean recheck_available_connections) { NMDeviceWifiPrivate *priv; - NMAccessPoint *old_ap; + NMWifiAP *old_ap; g_return_if_fail (NM_IS_DEVICE_WIFI (self)); @@ -387,10 +388,10 @@ set_current_ap (NMDeviceWifi *self, NMAccessPoint *new_ap, gboolean recheck_avai priv->current_ap = NULL; if (old_ap) { - NM80211Mode mode = nm_ap_get_mode (old_ap); + NM80211Mode mode = nm_wifi_ap_get_mode (old_ap); /* Remove any AP from the internal list if it was created by NM or isn't known to the supplicant */ - if (mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_AP || nm_ap_get_fake (old_ap)) + if (mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_AP || nm_wifi_ap_get_fake (old_ap)) ap_add_remove (self, ACCESS_POINT_REMOVED, old_ap, recheck_available_connections); g_object_unref (old_ap); } @@ -433,7 +434,7 @@ periodic_update (NMDeviceWifi *self) /* Smooth out the strength to work around crappy drivers */ percent = nm_platform_wifi_get_quality (NM_PLATFORM_GET, ifindex); if (percent >= 0 || ++priv->invalid_strength_counter > 3) { - nm_ap_set_strength (priv->current_ap, (gint8) percent); + nm_wifi_ap_set_strength (priv->current_ap, (gint8) percent); priv->invalid_strength_counter = 0; } } @@ -452,19 +453,10 @@ periodic_update_cb (gpointer user_data) return TRUE; } -static gboolean -bring_up (NMDevice *device, gboolean *no_firmware) -{ - if (!NM_DEVICE_WIFI_GET_PRIVATE ((NMDeviceWifi *) device)->enabled) - return FALSE; - - return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->bring_up (device, no_firmware); -} - static void ap_add_remove (NMDeviceWifi *self, guint signum, - NMAccessPoint *ap, + NMWifiAP *ap, gboolean recheck_available_connections) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); @@ -497,7 +489,7 @@ remove_all_aps (NMDeviceWifi *self) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); GHashTableIter iter; - NMAccessPoint *ap; + NMWifiAP *ap; if (!g_hash_table_size (priv->aps)) return; @@ -548,10 +540,8 @@ deactivate (NMDevice *device) } /* Ensure we trigger a scan after deactivating a Hotspot */ - if (old_mode == NM_802_11_MODE_AP) { - nm_clear_g_source (&priv->pending_scan_id); + if (old_mode == NM_802_11_MODE_AP) request_wireless_scan (self, NULL); - } } static void @@ -661,24 +651,24 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) return TRUE; } -static NMAccessPoint * +static NMWifiAP * find_first_compatible_ap (NMDeviceWifi *self, NMConnection *connection, gboolean allow_unstable_order) { GHashTableIter iter; - NMAccessPoint *ap; - NMAccessPoint *cand_ap = NULL; + NMWifiAP *ap; + NMWifiAP *cand_ap = NULL; g_return_val_if_fail (connection != NULL, NULL); g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps); while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) { - if (!nm_ap_check_compatible (ap, connection)) + if (!nm_wifi_ap_check_compatible (ap, connection)) continue; if (allow_unstable_order) return ap; - if (!cand_ap || (nm_ap_get_id (cand_ap) < nm_ap_get_id (ap))) + if (!cand_ap || (nm_wifi_ap_get_id (cand_ap) < nm_wifi_ap_get_id (ap))) cand_ap = ap; } return cand_ap; @@ -700,10 +690,10 @@ check_connection_available (NMDevice *device, * also be available in general (without @specific_object). */ if (specific_object) { - NMAccessPoint *ap; + NMWifiAP *ap; ap = get_ap_by_path (NM_DEVICE_WIFI (device), specific_object); - return ap ? nm_ap_check_compatible (ap, connection) : FALSE; + return ap ? nm_wifi_ap_check_compatible (ap, connection) : FALSE; } /* Ad-Hoc and AP connections are always available because they may be @@ -773,7 +763,7 @@ complete_connection (NMDevice *device, NMSettingWireless *s_wifi; const char *setting_mac; char *str_ssid = NULL; - NMAccessPoint *ap = NULL; + NMWifiAP *ap = NULL; const GByteArray *ssid = NULL; GByteArray *tmp_ssid = NULL; GBytes *setting_ssid = NULL; @@ -833,7 +823,7 @@ complete_connection (NMDevice *device, } if (ap) - ssid = nm_ap_get_ssid (ap); + ssid = nm_wifi_ap_get_ssid (ap); if (ssid == NULL) { /* The AP must be hidden. Connecting to a WiFi AP requires the SSID * as part of the initial handshake, so check the connection details @@ -866,10 +856,10 @@ complete_connection (NMDevice *device, /* If the SSID is a well-known SSID, lock the connection to the AP's * specific BSSID so NM doesn't autoconnect to some random wifi net. */ - if (!nm_ap_complete_connection (ap, - connection, - is_manf_default_ssid (ssid), - error)) { + if (!nm_wifi_ap_complete_connection (ap, + connection, + is_manf_default_ssid (ssid), + error)) { if (tmp_ssid) g_byte_array_unref (tmp_ssid); return FALSE; @@ -967,11 +957,13 @@ can_auto_connect (NMDevice *device, { NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMSettingWireless *s_wifi; - NMAccessPoint *ap; + NMWifiAP *ap; const char *method, *mode; guint64 timestamp = 0; - if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, specific_object)) + nm_assert (!specific_object || !*specific_object); + + if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, NULL)) return FALSE; s_wifi = nm_connection_get_setting_wireless (connection); @@ -998,73 +990,99 @@ can_auto_connect (NMDevice *device, ap = find_first_compatible_ap (self, connection, FALSE); if (ap) { /* All good; connection is usable */ - *specific_object = (char *) nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)); + NM_SET_OUT (specific_object, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)))); return TRUE; } return FALSE; } -static gint -ap_id_compare (NMAccessPoint *a, NMAccessPoint *b) +static int +ap_id_compare (gconstpointer p_a, gconstpointer p_b, gpointer user_data) { - guint32 a_id = nm_ap_get_id (a); - guint32 b_id = nm_ap_get_id (b); + guint64 a_id = nm_wifi_ap_get_id (*((NMWifiAP **) p_a)); + guint64 b_id = nm_wifi_ap_get_id (*((NMWifiAP **) p_b)); return a_id < b_id ? -1 : (a_id == b_id ? 0 : 1); } -static GSList * -get_sorted_ap_list (NMDeviceWifi *self) +static NMWifiAP ** +ap_list_get_sorted (NMDeviceWifi *self, gboolean include_without_ssid) { - GSList *sorted = NULL; + NMDeviceWifiPrivate *priv; + NMWifiAP **list; GHashTableIter iter; - NMAccessPoint *ap; + NMWifiAP *ap; + gsize i, n; - g_hash_table_iter_init (&iter, NM_DEVICE_WIFI_GET_PRIVATE (self)->aps); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) - sorted = g_slist_prepend (sorted, ap); - return g_slist_sort (sorted, (GCompareFunc) ap_id_compare); + priv = NM_DEVICE_WIFI_GET_PRIVATE (self); + + n = g_hash_table_size (priv->aps); + list = g_new (NMWifiAP *, n + 1); + + i = 0; + if (n > 0) { + g_hash_table_iter_init (&iter, priv->aps); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &ap)) { + nm_assert (i < n); + if ( include_without_ssid + || nm_wifi_ap_get_ssid (ap)) + list[i++] = ap; + } + nm_assert (i <= n); + nm_assert (!include_without_ssid || i == n); + + g_qsort_with_data (list, + i, + sizeof (gpointer), + ap_id_compare, + NULL); + } + list[i] = NULL; + return list; } -static void -impl_device_wifi_get_access_points (NMDeviceWifi *self, - GDBusMethodInvocation *context) +static const char ** +ap_list_get_sorted_paths (NMDeviceWifi *self, gboolean include_without_ssid) { - GSList *sorted, *iter; - GPtrArray *paths; + gpointer *list; + gsize i, j; - paths = g_ptr_array_new (); - sorted = get_sorted_ap_list (self); - for (iter = sorted; iter; iter = iter->next) { - NMAccessPoint *ap = NM_AP (iter->data); + list = (gpointer *) ap_list_get_sorted (self, include_without_ssid); + for (i = 0, j = 0; list[i]; i++) { + NMWifiAP *ap = list[i]; + const char *path; - if (nm_ap_get_ssid (ap)) - g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)))); + /* update @list inplace to hold instead the export-path. */ + path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)); + nm_assert (path); + list[j++] = (gpointer) path; } - g_ptr_array_add (paths, NULL); - g_slist_free (sorted); + return (const char **) list; +} + +static void +impl_device_wifi_get_access_points (NMDeviceWifi *self, + GDBusMethodInvocation *context) +{ + gs_free const char **list = NULL; + GVariant *v; - g_dbus_method_invocation_return_value (context, g_variant_new ("(^ao)", (char **) paths->pdata)); - g_ptr_array_unref (paths); + list = ap_list_get_sorted_paths (self, FALSE); + v = g_variant_new_objv (list, -1); + g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1)); } static void impl_device_wifi_get_all_access_points (NMDeviceWifi *self, GDBusMethodInvocation *context) { - GSList *sorted, *iter; - GPtrArray *paths; - - paths = g_ptr_array_new (); - sorted = get_sorted_ap_list (self); - for (iter = sorted; iter; iter = iter->next) - 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); + gs_free const char **list = NULL; + GVariant *v; - g_dbus_method_invocation_return_value (context, g_variant_new ("(^ao)", (char **) paths->pdata)); - g_ptr_array_unref (paths); + list = ap_list_get_sorted_paths (self, TRUE); + v = g_variant_new_objv (list, -1); + g_dbus_method_invocation_return_value (context, g_variant_new_tuple (&v, 1)); } static void @@ -1118,7 +1136,7 @@ _hw_addr_set_scanning (NMDeviceWifi *self, gboolean do_reset) generate_mac_address_mask); } - nm_device_hw_addr_set (device, priv->hw_addr_scan, "scanning"); + nm_device_hw_addr_set (device, priv->hw_addr_scan, "scanning", TRUE); } static void @@ -1147,7 +1165,6 @@ request_scan_cb (NMDevice *device, priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - nm_clear_g_source (&priv->pending_scan_id); request_wireless_scan (self, new_scan_options); g_dbus_method_invocation_return_value (context, NULL); } @@ -1389,6 +1406,8 @@ request_wireless_scan (NMDeviceWifi *self, GVariant *scan_options) gboolean backoff = FALSE; GPtrArray *ssids = NULL; + nm_clear_g_source (&priv->pending_scan_id); + if (priv->requested_scan) { /* There's already a scan in progress */ return; @@ -1443,7 +1462,6 @@ request_wireless_scan (NMDeviceWifi *self, GVariant *scan_options) } else _LOGD (LOGD_WIFI_SCAN, "scan requested but not allowed at this time"); - priv->pending_scan_id = 0; schedule_scan (self, backoff); } @@ -1455,7 +1473,7 @@ request_wireless_scan_periodic (gpointer user_data) priv->pending_scan_id = 0; request_wireless_scan (self, NULL); - return FALSE; + return G_SOURCE_REMOVE; } /* @@ -1531,17 +1549,17 @@ ap_list_dump (gpointer user_data) { NMDeviceWifi *self = NM_DEVICE_WIFI (user_data); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - GSList *sorted, *iter; + gs_free NMWifiAP **list = NULL; + gsize i; priv->ap_dump_id = 0; _LOGD (LOGD_WIFI_SCAN, "APs: [now:%u last:%u next:%u]", nm_utils_get_monotonic_timestamp_s (), priv->last_scan, priv->scheduled_scan_time); - sorted = get_sorted_ap_list (self); - for (iter = sorted; iter; iter = iter->next) - nm_ap_dump (NM_AP (iter->data), "dump ", nm_device_get_iface (NM_DEVICE (self))); - g_slist_free (sorted); + list = ap_list_get_sorted (self, TRUE); + for (i = 0; list[i]; i++) + nm_wifi_ap_dump (list[i], "dump ", nm_device_get_iface (NM_DEVICE (self))); return G_SOURCE_REMOVE; } @@ -1558,15 +1576,15 @@ schedule_ap_list_dump (NMDeviceWifi *self) static void try_fill_ssid_for_hidden_ap (NMDeviceWifi *self, - NMAccessPoint *ap) + NMWifiAP *ap) { const char *bssid; NMSettingsConnection *const*connections; guint i; - g_return_if_fail (nm_ap_get_ssid (ap) == NULL); + g_return_if_fail (nm_wifi_ap_get_ssid (ap) == NULL); - bssid = nm_ap_get_address (ap); + bssid = nm_wifi_ap_get_address (ap); g_return_if_fail (bssid); /* Look for this AP's BSSID in the seen-bssids list of a connection, @@ -1581,9 +1599,9 @@ try_fill_ssid_for_hidden_ap (NMDeviceWifi *self, if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) { GBytes *ssid = nm_setting_wireless_get_ssid (s_wifi); - nm_ap_set_ssid (ap, - g_bytes_get_data (ssid, NULL), - g_bytes_get_size (ssid)); + nm_wifi_ap_set_ssid (ap, + g_bytes_get_data (ssid, NULL), + g_bytes_get_size (ssid)); break; } } @@ -1598,8 +1616,8 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface, { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceState state; - NMAccessPoint *ap; - NMAccessPoint *found_ap = NULL; + NMWifiAP *ap; + NMWifiAP *found_ap = NULL; const GByteArray *ssid; g_return_if_fail (self != NULL); @@ -1613,36 +1631,36 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface, if (NM_DEVICE_WIFI_GET_PRIVATE (self)->mode == NM_802_11_MODE_AP) return; - ap = nm_ap_new_from_properties (object_path, properties); + ap = nm_wifi_ap_new_from_properties (object_path, properties); if (!ap) { _LOGD (LOGD_WIFI_SCAN, "invalid AP properties received for %s", object_path); return; } /* Let the manager try to fill in the SSID from seen-bssids lists */ - ssid = nm_ap_get_ssid (ap); + ssid = nm_wifi_ap_get_ssid (ap); if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) { /* Try to fill the SSID from the AP database */ try_fill_ssid_for_hidden_ap (self, ap); - ssid = nm_ap_get_ssid (ap); + ssid = nm_wifi_ap_get_ssid (ap); if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) { /* Yay, matched it, no longer treat as hidden */ _LOGD (LOGD_WIFI_SCAN, "matched hidden AP %s => '%s'", - nm_ap_get_address (ap), nm_utils_escape_ssid (ssid->data, ssid->len)); + nm_wifi_ap_get_address (ap), nm_utils_escape_ssid (ssid->data, ssid->len)); } else { /* Didn't have an entry for this AP in the database */ _LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP %s", - nm_ap_get_address (ap)); + nm_wifi_ap_get_address (ap)); } } found_ap = get_ap_by_supplicant_path (self, object_path); if (found_ap) { - nm_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self))); - nm_ap_update_from_properties (found_ap, object_path, properties); + nm_wifi_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self))); + nm_wifi_ap_update_from_properties (found_ap, object_path, properties); } else { - nm_ap_dump (ap, "added ", nm_device_get_iface (NM_DEVICE (self))); + nm_wifi_ap_dump (ap, "added ", nm_device_get_iface (NM_DEVICE (self))); ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE); } @@ -1664,7 +1682,7 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface, NMDeviceWifi *self) { NMDeviceState state; - NMAccessPoint *ap; + NMWifiAP *ap; g_return_if_fail (self != NULL); g_return_if_fail (object_path != NULL); @@ -1677,8 +1695,8 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface, ap = get_ap_by_supplicant_path (self, object_path); if (ap) { - nm_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self))); - nm_ap_update_from_properties (ap, object_path, properties); + nm_wifi_ap_dump (ap, "updated ", nm_device_get_iface (NM_DEVICE (self))); + nm_wifi_ap_update_from_properties (ap, object_path, properties); schedule_ap_list_dump (self); } } @@ -1689,7 +1707,7 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface, NMDeviceWifi *self) { NMDeviceWifiPrivate *priv; - NMAccessPoint *ap; + NMWifiAP *ap; g_return_if_fail (self != NULL); g_return_if_fail (object_path != NULL); @@ -1703,9 +1721,9 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface, * when the current AP is changed or cleared. Set 'fake' to * indicate that this AP is now unknown to the supplicant. */ - nm_ap_set_fake (ap, TRUE); + nm_wifi_ap_set_fake (ap, TRUE); } else { - nm_ap_dump (ap, "removed ", nm_device_get_iface (NM_DEVICE (self))); + nm_wifi_ap_dump (ap, "removed ", nm_device_get_iface (NM_DEVICE (self))); ap_add_remove (self, ACCESS_POINT_REMOVED, ap, TRUE); schedule_ap_list_dump (self); } @@ -1748,12 +1766,23 @@ wifi_secrets_cb (NMActRequest *req, GError *error, gpointer user_data) { - NMDevice *device = NM_DEVICE (user_data); - NMDeviceWifi *self = NM_DEVICE_WIFI (device); + NMDevice *device = user_data; + NMDeviceWifi *self = user_data; + NMDeviceWifiPrivate *priv; + + g_return_if_fail (NM_IS_DEVICE_WIFI (self)); + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + priv = NM_DEVICE_WIFI_GET_PRIVATE (self); + + g_return_if_fail (priv->wifi_secrets_id == call_id); + + priv->wifi_secrets_id = NULL; - if (req != nm_device_get_act_request (device)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; + g_return_if_fail (req == nm_device_get_act_request (device)); g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH); g_return_if_fail (nm_act_request_get_settings_connection (req) == connection); @@ -1766,6 +1795,39 @@ wifi_secrets_cb (NMActRequest *req, nm_device_activate_schedule_stage1_device_prepare (device); } +static void +wifi_secrets_cancel (NMDeviceWifi *self) +{ + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); + + if (priv->wifi_secrets_id) + nm_act_request_cancel_secrets (NULL, priv->wifi_secrets_id); + nm_assert (!priv->wifi_secrets_id); +} + +static void +wifi_secrets_get_secrets (NMDeviceWifi *self, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags) +{ + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); + NMActRequest *req; + + wifi_secrets_cancel (self); + + req = nm_device_get_act_request (NM_DEVICE (self)); + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + priv->wifi_secrets_id = nm_act_request_get_secrets (req, + TRUE, + setting_name, + flags, + NULL, + wifi_secrets_cb, + self); + g_return_if_fail (priv->wifi_secrets_id); +} + /* * link_timeout_cb * @@ -1856,6 +1918,7 @@ need_new_8021x_secrets (NMDeviceWifi *self, static gboolean need_new_wpa_psk (NMDeviceWifi *self, guint32 old_state, + gint disconnect_reason, const char **setting_name) { NMSettingWirelessSecurity *s_wsec; @@ -1876,6 +1939,15 @@ need_new_wpa_psk (NMDeviceWifi *self, key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); if (g_strcmp0 (key_mgmt, "wpa-psk") == 0) { + /* -4 (locally-generated WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY) usually + * means the driver missed beacons from the AP. This usually happens + * due to driver bugs or faulty power-save management. It doesn't + * indicate that the PSK is wrong. + */ + #define LOCAL_WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY -4 + if (disconnect_reason == LOCAL_WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY) + return FALSE; + *setting_name = NM_SETTING_WIRELESS_SECURITY_SETTING_NAME; return TRUE; } @@ -1901,7 +1973,7 @@ handle_8021x_or_psk_auth_fail (NMDeviceWifi *self, g_return_val_if_fail (req != NULL, FALSE); if ( need_new_8021x_secrets (self, old_state, &setting_name) - || need_new_wpa_psk (self, old_state, &setting_name)) { + || need_new_wpa_psk (self, old_state, disconnect_reason, &setting_name)) { nm_act_request_clear_secrets (req); @@ -1910,13 +1982,10 @@ handle_8021x_or_psk_auth_fail (NMDeviceWifi *self, cleanup_association_attempt (self, TRUE); nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT); - nm_act_request_get_secrets (req, - setting_name, - NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION - | NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW, - NULL, - wifi_secrets_cb, - self); + wifi_secrets_get_secrets (self, + setting_name, + NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION + | NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW); handled = TRUE; } @@ -2054,7 +2123,6 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, break; case NM_SUPPLICANT_INTERFACE_STATE_INACTIVE: _requested_scan_set (self, FALSE); - nm_clear_g_source (&priv->pending_scan_id); request_wireless_scan (self, NULL); break; default: @@ -2129,7 +2197,7 @@ supplicant_iface_notify_current_bss (NMSupplicantInterface *iface, { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); const char *current_bss; - NMAccessPoint *new_ap = NULL; + NMWifiAP *new_ap = NULL; current_bss = nm_supplicant_interface_get_current_bss (iface); if (current_bss) @@ -2145,17 +2213,17 @@ supplicant_iface_notify_current_bss (NMSupplicantInterface *iface, * supplicant's current BSS yet. It'll get replaced when we receive * the current BSS's scan result. */ - if (new_ap == NULL && nm_ap_get_fake (priv->current_ap)) + if (new_ap == NULL && nm_wifi_ap_get_fake (priv->current_ap)) return; if (new_ap) { - new_bssid = nm_ap_get_address (new_ap); - new_ssid = nm_ap_get_ssid (new_ap); + new_bssid = nm_wifi_ap_get_address (new_ap); + new_ssid = nm_wifi_ap_get_ssid (new_ap); } if (priv->current_ap) { - old_bssid = nm_ap_get_address (priv->current_ap); - old_ssid = nm_ap_get_ssid (priv->current_ap); + old_bssid = nm_wifi_ap_get_address (priv->current_ap); + old_ssid = nm_wifi_ap_get_ssid (priv->current_ap); } _LOGD (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)", @@ -2182,7 +2250,7 @@ handle_auth_or_fail (NMDeviceWifi *self, if (!req) { req = nm_device_get_act_request (NM_DEVICE (self)); - g_assert (req); + g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE); } applied_connection = nm_act_request_get_applied_connection (req); @@ -2196,12 +2264,9 @@ handle_auth_or_fail (NMDeviceWifi *self, nm_act_request_clear_secrets (req); setting_name = nm_connection_need_secrets (applied_connection, NULL); if (setting_name) { - NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; - - if (new_secrets) - flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; - nm_act_request_get_secrets (req, setting_name, flags, NULL, wifi_secrets_cb, self); - + wifi_secrets_get_secrets (self, setting_name, + NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION + | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); g_object_set_data (G_OBJECT (applied_connection), WIRELESS_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); ret = NM_ACT_STAGE_RETURN_POSTPONE; } else @@ -2357,7 +2422,7 @@ error: return NULL; } -/****************************************************************************/ +/*****************************************************************************/ static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) @@ -2365,7 +2430,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMActStageReturn ret; - NMAccessPoint *ap = NULL; + NMWifiAP *ap = NULL; NMActRequest *req; NMConnection *connection; NMSettingWireless *s_wireless; @@ -2437,11 +2502,11 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) * until the real one is found in the scan list (Ad-Hoc or Hidden), or until * the device is deactivated (Hotspot). */ - ap = nm_ap_new_fake_from_connection (connection); + ap = nm_wifi_ap_new_fake_from_connection (connection); g_return_val_if_fail (ap != NULL, NM_ACT_STAGE_RETURN_FAILURE); - if (nm_ap_is_hotspot (ap)) - nm_ap_set_address (ap, nm_device_get_hw_address (device)); + if (nm_wifi_ap_is_hotspot (ap)) + nm_wifi_ap_set_address (ap, nm_device_get_hw_address (device)); g_object_freeze_notify (G_OBJECT (self)); ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE); @@ -2459,7 +2524,7 @@ done: static void ensure_hotspot_frequency (NMDeviceWifi *self, NMSettingWireless *s_wifi, - NMAccessPoint *ap) + NMWifiAP *ap) { const char *band = nm_setting_wireless_get_band (s_wifi); const guint32 a_freqs[] = { 5180, 5200, 5220, 5745, 5765, 5785, 5805, 0 }; @@ -2468,7 +2533,7 @@ ensure_hotspot_frequency (NMDeviceWifi *self, g_assert (ap); - if (nm_ap_get_freq (ap)) + if (nm_wifi_ap_get_freq (ap)) return; if (g_strcmp0 (band, "a") == 0) @@ -2479,7 +2544,7 @@ ensure_hotspot_frequency (NMDeviceWifi *self, if (!freq) freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462; - nm_ap_set_freq (ap, freq); + nm_wifi_ap_set_freq (ap, freq); } static void @@ -2522,7 +2587,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMSupplicantConfig *config = NULL; NMActRequest *req; - NMAccessPoint *ap; + NMWifiAP *ap; NMConnection *connection; const char *setting_name; NMSettingWireless *s_wireless; @@ -2577,14 +2642,14 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) * didn't specify one and we didn't find an AP that matched the connection, * just pick a frequency the device supports. */ - if ((nm_ap_get_mode (ap) == NM_802_11_MODE_ADHOC) || nm_ap_is_hotspot (ap)) + if ((nm_wifi_ap_get_mode (ap) == NM_802_11_MODE_ADHOC) || nm_wifi_ap_is_hotspot (ap)) ensure_hotspot_frequency (self, s_wireless, ap); - if (nm_ap_get_mode (ap) == NM_802_11_MODE_INFRA) + if (nm_wifi_ap_get_mode (ap) == NM_802_11_MODE_INFRA) set_powersave (device); /* Build up the supplicant configuration */ - config = build_supplicant_config (self, connection, nm_ap_get_freq (ap), &error); + config = build_supplicant_config (self, connection, nm_wifi_ap_get_freq (ap), &error); if (config == NULL) { _LOGE (LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) couldn't build wireless configuration: %s", @@ -2676,22 +2741,30 @@ act_stage3_ip6_config_start (NMDevice *device, return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason); } -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) +static guint32 +get_configured_mtu (NMDevice *device, gboolean *out_is_user_config) { - NMConnection *connection; - NMSettingWireless *s_wifi; + NMSettingWireless *setting; + gint64 mtu_default; guint32 mtu; - connection = nm_device_get_applied_connection (device); - g_assert (connection); - s_wifi = nm_connection_get_setting_wireless (connection); - g_assert (s_wifi); + nm_assert (NM_IS_DEVICE (device)); + nm_assert (out_is_user_config); + + setting = NM_SETTING_WIRELESS (nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS)); + if (!setting) + g_return_val_if_reached (0); - /* MTU override */ - mtu = nm_setting_wireless_get_mtu (s_wifi); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); + mtu = nm_setting_wireless_get_mtu (setting); + if (mtu == 0) { + mtu_default = nm_device_get_configured_mtu_from_connection_default (device, "wifi.mtu"); + if (mtu_default >= 0) { + *out_is_user_config = TRUE; + return (guint32) mtu_default; + } + } + *out_is_user_config = (mtu != 0); + return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRELESS; } static gboolean @@ -2830,26 +2903,26 @@ activation_success_handler (NMDevice *device) */ g_warn_if_fail (priv->current_ap); if (priv->current_ap) { - if (nm_ap_get_fake (priv->current_ap)) { + if (nm_wifi_ap_get_fake (priv->current_ap)) { /* If the activation AP hasn't been seen by the supplicant in a scan * yet, it will be "fake". This usually happens for Ad-Hoc and * AP-mode connections. Fill in the details from the device itself * until the supplicant sends the scan result. */ - if (!nm_ap_get_address (priv->current_ap)) { + if (!nm_wifi_ap_get_address (priv->current_ap)) { guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; gs_free char *bssid_str = NULL; if ( nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid) && nm_ethernet_address_is_valid (bssid, ETH_ALEN)) { bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN); - nm_ap_set_address (priv->current_ap, bssid_str); + nm_wifi_ap_set_address (priv->current_ap, bssid_str); } } - if (!nm_ap_get_freq (priv->current_ap)) - nm_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex)); - if (!nm_ap_get_max_bitrate (priv->current_ap)) - nm_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex)); + if (!nm_wifi_ap_get_freq (priv->current_ap)) + nm_wifi_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex)); + if (!nm_wifi_ap_get_max_bitrate (priv->current_ap)) + nm_wifi_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex)); } nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), @@ -2889,6 +2962,9 @@ device_state_changed (NMDevice *device, NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); gboolean clear_aps = FALSE; + if (new_state > NM_DEVICE_STATE_ACTIVATED) + wifi_secrets_cancel (self); + if (new_state <= NM_DEVICE_STATE_UNAVAILABLE) { /* Clean up the supplicant interface because in these states the * device cannot be used. @@ -2935,7 +3011,6 @@ device_state_changed (NMDevice *device, case NM_DEVICE_STATE_DISCONNECTED: /* Kick off a scan to get latest results */ priv->scan_interval = SCAN_INTERVAL_MIN; - nm_clear_g_source (&priv->pending_scan_id); request_wireless_scan (self, NULL); break; default: @@ -2946,6 +3021,12 @@ device_state_changed (NMDevice *device, remove_all_aps (self); } +static gboolean +get_enabled (NMDevice *device) +{ + return NM_DEVICE_WIFI_GET_PRIVATE ((NMDeviceWifi *) device)->enabled; +} + static void set_enabled (NMDevice *device, gboolean enabled) { @@ -3002,7 +3083,7 @@ set_enabled (NMDevice *device, gboolean enabled) } } -/********************************************************************/ +/*****************************************************************************/ NMDevice * nm_device_wifi_new (const char *iface, NMDeviceWifiCapabilities capabilities) @@ -3034,6 +3115,8 @@ dispose (GObject *object) nm_clear_g_source (&priv->periodic_source_id); + wifi_secrets_cancel (self); + cleanup_association_attempt (self, TRUE); supplicant_interface_release (self); cleanup_supplicant_failures (self); @@ -3064,11 +3147,10 @@ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceWifi *device = NM_DEVICE_WIFI (object); - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); - GHashTableIter iter; - const char *dbus_path; - GPtrArray *array; + NMDeviceWifi *self = NM_DEVICE_WIFI (object); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); + gsize i; + char **list; switch (prop_id) { case PROP_MODE: @@ -3081,12 +3163,10 @@ 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) + 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_ptr_array_add (array, NULL); - g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE)); + list = (char **) ap_list_get_sorted_paths (self, TRUE); + for (i = 0; list[i]; i++) + list[i] = g_strdup (list[i]); + g_value_take_boxed (value, list); break; case PROP_ACTIVE_ACCESS_POINT: nm_utils_g_value_set_object_path (value, priv->current_ap); @@ -3133,17 +3213,17 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) object_class->dispose = dispose; object_class->finalize = finalize; - parent_class->bring_up = bring_up; parent_class->can_auto_connect = can_auto_connect; parent_class->is_available = is_available; parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_available = check_connection_available; parent_class->complete_connection = complete_connection; + parent_class->get_enabled = get_enabled; parent_class->set_enabled = set_enabled; parent_class->act_stage1_prepare = act_stage1_prepare; parent_class->act_stage2_config = act_stage2_config; - parent_class->ip4_config_pre_commit = ip4_config_pre_commit; + parent_class->get_configured_mtu = get_configured_mtu; parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; parent_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start; parent_class->act_stage4_ip4_config_timeout = act_stage4_ip4_config_timeout; @@ -3156,7 +3236,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) klass->scanning_allowed = scanning_allowed; - /* Properties */ obj_properties[PROP_MODE] = g_param_spec_uint (NM_DEVICE_WIFI_MODE, "", "", NM_802_11_MODE_UNKNOWN, @@ -3198,27 +3277,26 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - /* Signals */ signals[ACCESS_POINT_ADDED] = - g_signal_new ("access-point-added", + g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_ADDED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, - NM_TYPE_AP); + NM_TYPE_WIFI_AP); signals[ACCESS_POINT_REMOVED] = - g_signal_new ("access-point-removed", + g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_REMOVED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, - NM_TYPE_AP); + NM_TYPE_WIFI_AP); signals[SCANNING_ALLOWED] = - g_signal_new ("scanning-allowed", + g_signal_new (NM_DEVICE_WIFI_SCANNING_ALLOWED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (NMDeviceWifiClass, scanning_allowed), diff --git a/src/devices/wifi/nm-device-wifi.h b/src/devices/wifi/nm-device-wifi.h index ba9d60e2..024fe0ef 100644 --- a/src/devices/wifi/nm-device-wifi.h +++ b/src/devices/wifi/nm-device-wifi.h @@ -22,7 +22,7 @@ #ifndef __NETWORKMANAGER_DEVICE_WIFI_H__ #define __NETWORKMANAGER_DEVICE_WIFI_H__ -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-wifi-ap.h" #define NM_TYPE_DEVICE_WIFI (nm_device_wifi_get_type ()) @@ -39,6 +39,13 @@ #define NM_DEVICE_WIFI_CAPABILITIES "wireless-capabilities" #define NM_DEVICE_WIFI_SCANNING "scanning" +/* signals */ +#define NM_DEVICE_WIFI_ACCESS_POINT_ADDED "access-point-added" +#define NM_DEVICE_WIFI_ACCESS_POINT_REMOVED "access-point-removed" + +/* internal signals */ +#define NM_DEVICE_WIFI_SCANNING_ALLOWED "scanning-allowed" + typedef struct _NMDeviceWifi NMDeviceWifi; typedef struct _NMDeviceWifiClass NMDeviceWifiClass; diff --git a/src/devices/wifi/nm-wifi-ap-utils.c b/src/devices/wifi/nm-wifi-ap-utils.c deleted file mode 100644 index bcf439da..00000000 --- a/src/devices/wifi/nm-wifi-ap-utils.c +++ /dev/null @@ -1,785 +0,0 @@ -/*-*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-wifi-ap-utils.h" -#include "nm-utils.h" - -static gboolean -verify_no_wep (NMSettingWirelessSecurity *s_wsec, const char *tag, GError **error) -{ - if ( nm_setting_wireless_security_get_wep_key (s_wsec, 0) - || nm_setting_wireless_security_get_wep_key (s_wsec, 1) - || nm_setting_wireless_security_get_wep_key (s_wsec, 2) - || nm_setting_wireless_security_get_wep_key (s_wsec, 3) - || nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec) - || nm_setting_wireless_security_get_wep_key_type (s_wsec)) { - /* Dynamic WEP cannot have any WEP keys set */ - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("%s is incompatible with static WEP keys"), tag); - g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); - return FALSE; - } - - return TRUE; -} - -static gboolean -verify_leap (NMSettingWirelessSecurity *s_wsec, - NMSetting8021x *s_8021x, - gboolean adhoc, - GError **error) -{ - const char *key_mgmt, *auth_alg, *leap_username; - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); - - /* One (or both) of two things indicates we want LEAP: - * 1) auth_alg == 'leap' - * 2) valid leap_username - * - * LEAP always requires a LEAP username. - */ - - if (auth_alg) { - if (!strcmp (auth_alg, "leap")) { - /* LEAP authentication requires at least a LEAP username */ - if (!leap_username) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("LEAP authentication requires a LEAP username")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); - return FALSE; - } - } else if (leap_username) { - /* Leap username requires 'leap' auth */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("LEAP username requires 'leap' authentication")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); - return FALSE; - } - } - - if (leap_username) { - if (key_mgmt && strcmp (key_mgmt, "ieee8021x")) { - /* LEAP requires ieee8021x key management */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("LEAP authentication requires IEEE 802.1x key management")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); - return FALSE; - } - } - - /* At this point if auth_alg is set it must be 'leap', and if key_mgmt - * is set it must be 'ieee8021x'. - */ - if (leap_username) { - if (auth_alg) - g_assert (strcmp (auth_alg, "leap") == 0); - if (key_mgmt) - g_assert (strcmp (key_mgmt, "ieee8021x") == 0); - - if (adhoc) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("LEAP authentication is incompatible with Ad-Hoc mode")); - g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); - return FALSE; - } - - if (!verify_no_wep (s_wsec, "LEAP", error)) - return FALSE; - - if (s_8021x) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("LEAP authentication is incompatible with 802.1x setting")); - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - } - - return TRUE; -} - -static gboolean -verify_no_wpa (NMSettingWirelessSecurity *s_wsec, - const char *tag, - GError **error) -{ - const char *key_mgmt; - int n, i; - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - if (key_mgmt && !strncmp (key_mgmt, "wpa", 3)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("a connection using '%s' authentication cannot use WPA key management"), - tag); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); - return FALSE; - } - - if (nm_setting_wireless_security_get_num_protos (s_wsec)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("a connection using '%s' authentication cannot specify WPA protocols"), - tag); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_PROTO); - return FALSE; - } - - n = nm_setting_wireless_security_get_num_pairwise (s_wsec); - for (i = 0; i < n; i++) { - const char *pw; - - pw = nm_setting_wireless_security_get_pairwise (s_wsec, i); - if (!strcmp (pw, "tkip") || !strcmp (pw, "ccmp")) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("a connection using '%s' authentication cannot specify WPA ciphers"), - tag); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_PAIRWISE); - return FALSE; - } - } - - n = nm_setting_wireless_security_get_num_groups (s_wsec); - for (i = 0; i < n; i++) { - const char *gr; - - gr = nm_setting_wireless_security_get_group (s_wsec, i); - if (strcmp (gr, "wep40") && strcmp (gr, "wep104")) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("a connection using '%s' authentication cannot specify WPA ciphers"), - tag); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_GROUP); - return FALSE; - } - } - - if (nm_setting_wireless_security_get_psk (s_wsec)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("a connection using '%s' authentication cannot specify a WPA password"), - tag); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_PSK); - return FALSE; - } - - return TRUE; -} - -static gboolean -verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec, - NMSetting8021x *s_8021x, - gboolean adhoc, - GError **error) -{ - const char *key_mgmt, *auth_alg, *leap_username; - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); - - g_return_val_if_fail (leap_username == NULL, TRUE); - - if (key_mgmt) { - if (!strcmp (key_mgmt, "ieee8021x")) { - if (!s_8021x) { - /* 802.1x key management requires an 802.1x setting */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_SETTING, - _("Dynamic WEP requires an 802.1x setting")); - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - - if (auth_alg && strcmp (auth_alg, "open")) { - /* 802.1x key management must use "open" authentication */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Dynamic WEP requires 'open' authentication")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); - return FALSE; - } - - /* Dynamic WEP incompatible with anything static WEP related */ - if (!verify_no_wep (s_wsec, "Dynamic WEP", error)) - return FALSE; - } else if (!strcmp (key_mgmt, "none")) { - if (s_8021x) { - /* 802.1x setting requires 802.1x key management */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Dynamic WEP requires 'ieee8021x' key management")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); - return FALSE; - } - } - } else if (s_8021x) { - /* 802.1x setting incompatible with anything but 'open' auth */ - if (auth_alg && strcmp (auth_alg, "open")) { - /* 802.1x key management must use "open" authentication */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Dynamic WEP requires 'open' authentication")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); - return FALSE; - } - - /* Dynamic WEP incompatible with anything static WEP related */ - if (!verify_no_wep (s_wsec, "Dynamic WEP", error)) - return FALSE; - } - - return TRUE; -} - -static gboolean -verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, - NMSetting8021x *s_8021x, - gboolean adhoc, - guint32 wpa_flags, - guint32 rsn_flags, - GError **error) -{ - const char *key_mgmt, *auth_alg, *tmp; - int n; - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - - if (key_mgmt) { - if (!strcmp (key_mgmt, "wpa-psk") || !strcmp (key_mgmt, "wpa-none")) { - if (s_8021x) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("WPA-PSK authentication is incompatible with 802.1x")); - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - - if (auth_alg && strcmp (auth_alg, "open")) { - /* WPA must use "open" authentication */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA-PSK requires 'open' authentication")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); - return FALSE; - } - } - - if (!strcmp (key_mgmt, "wpa-none")) { - if (!adhoc) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA Ad-Hoc authentication requires an Ad-Hoc mode AP")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, - NM_SETTING_WIRELESS_MODE); - return FALSE; - } - - /* Ad-Hoc WPA requires 'wpa' proto, 'none' pairwise, and 'tkip' group */ - n = nm_setting_wireless_security_get_num_protos (s_wsec); - tmp = (n > 0) ? nm_setting_wireless_security_get_proto (s_wsec, 0) : NULL; - if (n > 1 || !tmp || strcmp (tmp, "wpa")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA Ad-Hoc authentication requires 'wpa' protocol")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_PROTO); - return FALSE; - } - - n = nm_setting_wireless_security_get_num_pairwise (s_wsec); - tmp = (n > 0) ? nm_setting_wireless_security_get_pairwise (s_wsec, 0) : NULL; - if (n > 1 || g_strcmp0 (tmp, "none")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA Ad-Hoc authentication requires 'none' pairwise cipher")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_PAIRWISE); - return FALSE; - } - - n = nm_setting_wireless_security_get_num_groups (s_wsec); - tmp = (n > 0) ? nm_setting_wireless_security_get_group (s_wsec, 0) : NULL; - if (n > 1 || !tmp || strcmp (tmp, "tkip")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA Ad-Hoc requires 'tkip' group cipher")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_GROUP); - return FALSE; - } - } - - if (!strcmp (key_mgmt, "wpa-psk")) { - /* Make sure the AP's capabilities support WPA-PSK */ - if ( !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) - && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Access point does not support PSK but setting requires it")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); - return FALSE; - } - } - } - - return TRUE; -} - -static gboolean -verify_wpa_eap (NMSettingWirelessSecurity *s_wsec, - NMSetting8021x *s_8021x, - guint32 wpa_flags, - guint32 rsn_flags, - GError **error) -{ - const char *key_mgmt, *auth_alg; - gboolean is_wpa_eap = FALSE; - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - - if (key_mgmt) { - if (!strcmp (key_mgmt, "wpa-eap")) { - if (!s_8021x) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_SETTING, - _("WPA-EAP authentication requires an 802.1x setting")); - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - - if (auth_alg && strcmp (auth_alg, "open")) { - /* WPA must use "open" authentication */ - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA-EAP requires 'open' authentication")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); - return FALSE; - } - - is_wpa_eap = TRUE; - } else if (s_8021x) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("802.1x setting requires 'wpa-eap' key management")); - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - } - - if (is_wpa_eap || s_8021x) { - /* Make sure the AP's capabilities support WPA-EAP */ - if ( !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) - && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("Access point does not support 802.1x but setting requires it")); - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - } - - return TRUE; -} - -static gboolean -verify_adhoc (NMSettingWirelessSecurity *s_wsec, - NMSetting8021x *s_8021x, - gboolean adhoc, - GError **error) -{ - const char *key_mgmt = NULL, *leap_username = NULL, *auth_alg = NULL; - - if (s_wsec) { - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); - } - - if (adhoc) { - if (key_mgmt && strcmp (key_mgmt, "wpa-none") && strcmp (key_mgmt, "none")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Access point mode is Ad-Hoc but setting requires Infrastructure security")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); - return FALSE; - } - - if (s_8021x) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("Ad-Hoc mode is incompatible with 802.1x security")); - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - - if (leap_username) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Ad-Hoc mode is incompatible with LEAP security")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); - return FALSE; - } - - if (auth_alg && strcmp (auth_alg, "open")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Ad-Hoc mode requires 'open' authentication")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); - return FALSE; - } - } else { - if (key_mgmt && !strcmp (key_mgmt, "wpa-none")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Access point mode is Infrastructure but setting requires Ad-Hoc security")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); - return FALSE; - } - } - - return TRUE; -} - -gboolean -nm_ap_utils_complete_connection (const GByteArray *ap_ssid, - const char *bssid, - NM80211Mode ap_mode, - guint32 ap_flags, - guint32 ap_wpa_flags, - guint32 ap_rsn_flags, - NMConnection *connection, - gboolean lock_bssid, - GError **error) -{ - NMSettingWireless *s_wifi; - NMSettingWirelessSecurity *s_wsec; - NMSetting8021x *s_8021x; - GBytes *ssid, *ap_ssid_bytes; - const char *mode, *key_mgmt, *auth_alg, *leap_username; - gboolean adhoc = FALSE; - - s_wifi = nm_connection_get_setting_wireless (connection); - g_assert (s_wifi); - s_wsec = nm_connection_get_setting_wireless_security (connection); - s_8021x = nm_connection_get_setting_802_1x (connection); - - /* Fill in missing SSID */ - ap_ssid_bytes = ap_ssid ? g_bytes_new (ap_ssid->data, ap_ssid->len) : NULL; - ssid = nm_setting_wireless_get_ssid (s_wifi); - if (!ssid) - g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid_bytes, NULL); - else if (!ap_ssid_bytes || !g_bytes_equal (ssid, ap_ssid_bytes)) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("connection does not match access point")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - g_bytes_unref (ap_ssid_bytes); - return FALSE; - } - g_bytes_unref (ap_ssid_bytes); - - if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi)) - g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL); - - /* And mode */ - mode = nm_setting_wireless_get_mode (s_wifi); - if (mode) { - gboolean valid = FALSE; - - /* Make sure the supplied mode matches the AP's */ - if ( !strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) - || !strcmp (mode, NM_SETTING_WIRELESS_MODE_AP)) { - if (ap_mode == NM_802_11_MODE_INFRA) - valid = TRUE; - } else if (!strcmp (mode, NM_SETTING_WIRELESS_MODE_ADHOC)) { - if (ap_mode == NM_802_11_MODE_ADHOC) - valid = TRUE; - adhoc = TRUE; - } - - if (valid == FALSE) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("connection does not match access point")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE); - return FALSE; - } - } else { - mode = NM_SETTING_WIRELESS_MODE_INFRA; - if (ap_mode == NM_802_11_MODE_ADHOC) { - mode = NM_SETTING_WIRELESS_MODE_ADHOC; - adhoc = TRUE; - } - g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, mode, NULL); - } - - /* Security */ - - /* Open */ - if ( !(ap_flags & NM_802_11_AP_FLAGS_PRIVACY) - && (ap_wpa_flags == NM_802_11_AP_SEC_NONE) - && (ap_rsn_flags == NM_802_11_AP_SEC_NONE)) { - /* Make sure the connection doesn't specify security */ - if (s_wsec || s_8021x) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("Access point is unencrypted but setting specifies security")); - if (s_wsec) - g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); - else - g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); - return FALSE; - } - return TRUE; - } - - /* Everything else requires security */ - if (!s_wsec) { - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wsec)); - } - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); - - /* Ad-Hoc checks */ - if (!verify_adhoc (s_wsec, s_8021x, adhoc, error)) - return FALSE; - - /* Static WEP, Dynamic WEP, or LEAP */ - if ( (ap_flags & NM_802_11_AP_FLAGS_PRIVACY) - && (ap_wpa_flags == NM_802_11_AP_SEC_NONE) - && (ap_rsn_flags == NM_802_11_AP_SEC_NONE)) { - const char *tag = "WEP"; - gboolean is_dynamic_wep = FALSE; - - if (!verify_leap (s_wsec, s_8021x, adhoc, error)) - return FALSE; - - if (leap_username) { - tag = "LEAP"; - } else { - /* Static or Dynamic WEP */ - if (!verify_dynamic_wep (s_wsec, s_8021x, adhoc, error)) - return FALSE; - - if (s_8021x || (key_mgmt && !strcmp (key_mgmt, "ieee8021x"))) { - is_dynamic_wep = TRUE; - tag = "Dynamic WEP"; - } - } - - /* Nothing WPA-related can be set */ - if (!verify_no_wpa (s_wsec, tag, error)) - return FALSE; - - if (leap_username) { - /* LEAP */ - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", - NULL); - } else if (is_dynamic_wep) { - /* Dynamic WEP */ - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", - NULL); - - if (s_8021x) { - /* Dynamic WEP requires a valid 802.1x setting since we can't - * autocomplete 802.1x. - */ - if (!nm_setting_verify (NM_SETTING (s_8021x), NULL, error)) - return FALSE; - } - } else { - /* Static WEP */ - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", - NULL); - } - - return TRUE; - } - - /* WPA/RSN */ - g_assert (ap_wpa_flags || ap_rsn_flags); - - /* Ensure key management is valid for WPA */ - if ((key_mgmt && !strcmp (key_mgmt, "ieee8021x")) || leap_username) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA authentication is incompatible with non-EAP (original) LEAP or Dynamic WEP")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); - return FALSE; - } - - /* 'shared' auth incompatible with any type of WPA */ - if (auth_alg && strcmp (auth_alg, "open")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("WPA authentication is incompatible with Shared Key authentication")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); - return FALSE; - } - - if (!verify_no_wep (s_wsec, "WPA", error)) - return FALSE; - - if (!verify_wpa_psk (s_wsec, s_8021x, adhoc, ap_wpa_flags, ap_rsn_flags, error)) - return FALSE; - - if (!adhoc && !verify_wpa_eap (s_wsec, s_8021x, ap_wpa_flags, ap_rsn_flags, error)) - return FALSE; - - if (adhoc) { - g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL); - /* Ad-Hoc does not support RSN/WPA2 */ - nm_setting_wireless_security_add_proto (s_wsec, "wpa"); - nm_setting_wireless_security_add_pairwise (s_wsec, "none"); - nm_setting_wireless_security_add_group (s_wsec, "tkip"); - } else if (s_8021x) { - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", - NULL); - /* Leave proto/pairwise/group as client set them; if they are unset the - * supplicant will figure out the best combination at connect time. - */ - - /* 802.1x also requires the client to completely fill in the 8021x - * setting. Since there's so much configuration required for it, there's - * no way it can be automatically completed. - */ - } else if ( (key_mgmt && !strcmp (key_mgmt, "wpa-psk")) - || (ap_wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) - || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) { - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", - NULL); - /* Leave proto/pairwise/group as client set them; if they are unset the - * supplicant will figure out the best combination at connect time. - */ - } else { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_FAILED, - _("Failed to determine AP security information")); - return FALSE; - } - - return TRUE; -} - -guint32 -nm_ap_utils_level_to_quality (gint val) -{ - if (val < 0) { - /* Assume dBm already; rough conversion: best = -40, worst = -100 */ - val = abs (CLAMP (val, -100, -40) + 40); /* normalize to 0 */ - val = 100 - (int) ((100.0 * (double) val) / 60.0); - } else if (val > 110 && val < 256) { - /* assume old-style WEXT 8-bit unsigned signal level */ - val -= 256; /* subtract 256 to convert to dBm */ - val = abs (CLAMP (val, -100, -40) + 40); /* normalize to 0 */ - val = 100 - (int) ((100.0 * (double) val) / 60.0); - } else { - /* Assume signal is a "quality" percentage */ - val = CLAMP (val, 0, 100); - } - g_assert (val >= 0); - - return (guint32) val; -} - diff --git a/src/devices/wifi/nm-wifi-ap-utils.h b/src/devices/wifi/nm-wifi-ap-utils.h deleted file mode 100644 index 31c12cd7..00000000 --- a/src/devices/wifi/nm-wifi-ap-utils.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2011 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_WIFI_AP_UTILS_H__ -#define __NETWORKMANAGER_WIFI_AP_UTILS_H__ - - -#include -#include -#include -#include -#include - -gboolean nm_ap_utils_complete_connection (const GByteArray *ssid, - const char *bssid, - NM80211Mode mode, - guint32 flags, - guint32 wpa_flags, - guint32 rsn_flags, - NMConnection *connection, - gboolean lock_bssid, - GError **error); - -guint32 nm_ap_utils_level_to_quality (gint val); - -#endif /* NM_WIFI_AP_UTILS_H */ - diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index 2232f826..9d8ba42c 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -25,20 +25,34 @@ #include #include "nm-wifi-ap.h" -#include "nm-wifi-ap-utils.h" +#include "nm-wifi-utils.h" #include "NetworkManagerUtils.h" #include "nm-utils.h" #include "nm-core-internal.h" #include "nm-setting-wireless.h" -#include "nmdbus-access-point.h" +#include "introspection/org.freedesktop.NetworkManager.AccessPoint.h" -/* - * Encapsulates Access Point information - */ -typedef struct -{ +#define PROTO_WPA "wpa" +#define PROTO_RSN "rsn" + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE (NMWifiAP, + PROP_FLAGS, + PROP_WPA_FLAGS, + PROP_RSN_FLAGS, + PROP_SSID, + PROP_FREQUENCY, + PROP_HW_ADDRESS, + PROP_MODE, + PROP_MAX_BITRATE, + PROP_STRENGTH, + PROP_LAST_SEEN, +); + +typedef struct { char *supplicant_path; /* D-Bus object path of this AP from wpa_supplicant */ /* Scanned or cached values */ @@ -57,69 +71,66 @@ typedef struct bool fake; /* Whether or not the AP is from a scan */ bool hotspot; /* Whether the AP is a local device's hotspot network */ gint32 last_seen; /* Timestamp when the AP was seen lastly (obtained via nm_utils_get_monotonic_timestamp_s()) */ -} NMAccessPointPrivate; +} NMWifiAPPrivate; -struct _NMAccessPoint { +struct _NMWifiAP { NMExportedObject parent; - NMAccessPointPrivate _priv; + NMWifiAPPrivate _priv; }; -struct _NMAccessPointClass{ +struct _NMWifiAPClass{ NMExportedObjectClass parent; }; -#define NM_AP_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMAccessPoint, NM_IS_AP) - -G_DEFINE_TYPE (NMAccessPoint, nm_ap, NM_TYPE_EXPORTED_OBJECT) +G_DEFINE_TYPE (NMWifiAP, nm_wifi_ap, NM_TYPE_EXPORTED_OBJECT) -NM_GOBJECT_PROPERTIES_DEFINE (NMAccessPoint, - PROP_FLAGS, - PROP_WPA_FLAGS, - PROP_RSN_FLAGS, - PROP_SSID, - PROP_FREQUENCY, - PROP_HW_ADDRESS, - PROP_MODE, - PROP_MAX_BITRATE, - PROP_STRENGTH, - PROP_LAST_SEEN, -); +#define NM_WIFI_AP_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMWifiAP, NM_IS_WIFI_AP) -/*****************************************************************/ +/*****************************************************************************/ const char * -nm_ap_get_supplicant_path (NMAccessPoint *ap) +nm_wifi_ap_get_supplicant_path (NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), NULL); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL); - return NM_AP_GET_PRIVATE (ap)->supplicant_path; + return NM_WIFI_AP_GET_PRIVATE (ap)->supplicant_path; } -guint32 -nm_ap_get_id (NMAccessPoint *ap) +guint64 +nm_wifi_ap_get_id (NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), 0); - g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0); + const char *path; + guint64 i; + + g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0); - return atoi (strrchr (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)), '/') + 1); + path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap)); + g_return_val_if_fail (path, 0); + + nm_assert (g_str_has_prefix (path, NM_DBUS_PATH_ACCESS_POINT"/")); + + i = _nm_utils_ascii_str_to_int64 (&path[NM_STRLEN (NM_DBUS_PATH_ACCESS_POINT"/")], 10, 1, G_MAXINT64, 0); + + nm_assert (i); + return i; } -const GByteArray * nm_ap_get_ssid (const NMAccessPoint *ap) +const GByteArray * nm_wifi_ap_get_ssid (const NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), NULL); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL); - return NM_AP_GET_PRIVATE (ap)->ssid; + return NM_WIFI_AP_GET_PRIVATE (ap)->ssid; } void -nm_ap_set_ssid (NMAccessPoint *ap, const guint8 *ssid, gsize len) +nm_wifi_ap_set_ssid (NMWifiAP *ap, const guint8 *ssid, gsize len) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); g_return_if_fail (ssid == NULL || len > 0); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); /* same SSID */ if ((ssid && priv->ssid) && (len == priv->ssid->len)) { @@ -141,13 +152,13 @@ nm_ap_set_ssid (NMAccessPoint *ap, const guint8 *ssid, gsize len) } static void -nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags) +nm_wifi_ap_set_flags (NMWifiAP *ap, NM80211ApFlags flags) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->flags != flags) { priv->flags = flags; @@ -156,13 +167,13 @@ nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags) } static void -nm_ap_set_wpa_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags) +nm_wifi_ap_set_wpa_flags (NMWifiAP *ap, NM80211ApSecurityFlags flags) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->wpa_flags != flags) { priv->wpa_flags = flags; _notify (ap, PROP_WPA_FLAGS); @@ -170,13 +181,13 @@ nm_ap_set_wpa_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags) } static void -nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags) +nm_wifi_ap_set_rsn_flags (NMWifiAP *ap, NM80211ApSecurityFlags flags) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->rsn_flags != flags) { priv->rsn_flags = flags; _notify (ap, PROP_RSN_FLAGS); @@ -184,23 +195,23 @@ nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags) } const char * -nm_ap_get_address (const NMAccessPoint *ap) +nm_wifi_ap_get_address (const NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), NULL); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), NULL); - return NM_AP_GET_PRIVATE (ap)->address; + return NM_WIFI_AP_GET_PRIVATE (ap)->address; } void -nm_ap_set_address (NMAccessPoint *ap, const char *addr) +nm_wifi_ap_set_address (NMWifiAP *ap, const char *addr) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); g_return_if_fail (addr != NULL); g_return_if_fail (nm_utils_hwaddr_valid (addr, ETH_ALEN)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (!priv->address || !nm_utils_hwaddr_matches (addr, -1, priv->address, -1)) { g_free (priv->address); @@ -210,23 +221,23 @@ nm_ap_set_address (NMAccessPoint *ap, const char *addr) } NM80211Mode -nm_ap_get_mode (NMAccessPoint *ap) +nm_wifi_ap_get_mode (NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), NM_802_11_MODE_UNKNOWN); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), NM_802_11_MODE_UNKNOWN); - return NM_AP_GET_PRIVATE (ap)->mode; + return NM_WIFI_AP_GET_PRIVATE (ap)->mode; } static void -nm_ap_set_mode (NMAccessPoint *ap, const NM80211Mode mode) +nm_wifi_ap_set_mode (NMWifiAP *ap, const NM80211Mode mode) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); g_return_if_fail ( mode == NM_802_11_MODE_ADHOC || mode == NM_802_11_MODE_INFRA); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->mode != mode) { priv->mode = mode; @@ -235,29 +246,29 @@ nm_ap_set_mode (NMAccessPoint *ap, const NM80211Mode mode) } gboolean -nm_ap_is_hotspot (NMAccessPoint *ap) +nm_wifi_ap_is_hotspot (NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), FALSE); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), FALSE); - return NM_AP_GET_PRIVATE (ap)->hotspot; + return NM_WIFI_AP_GET_PRIVATE (ap)->hotspot; } gint8 -nm_ap_get_strength (NMAccessPoint *ap) +nm_wifi_ap_get_strength (NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), 0); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0); - return NM_AP_GET_PRIVATE (ap)->strength; + return NM_WIFI_AP_GET_PRIVATE (ap)->strength; } void -nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength) +nm_wifi_ap_set_strength (NMWifiAP *ap, const gint8 strength) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->strength != strength) { priv->strength = strength; @@ -266,22 +277,22 @@ nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength) } guint32 -nm_ap_get_freq (NMAccessPoint *ap) +nm_wifi_ap_get_freq (NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), 0); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0); - return NM_AP_GET_PRIVATE (ap)->freq; + return NM_WIFI_AP_GET_PRIVATE (ap)->freq; } void -nm_ap_set_freq (NMAccessPoint *ap, - const guint32 freq) +nm_wifi_ap_set_freq (NMWifiAP *ap, + const guint32 freq) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->freq != freq) { priv->freq = freq; @@ -290,22 +301,22 @@ nm_ap_set_freq (NMAccessPoint *ap, } guint32 -nm_ap_get_max_bitrate (NMAccessPoint *ap) +nm_wifi_ap_get_max_bitrate (NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), 0); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), 0); g_return_val_if_fail (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (ap)), 0); - return NM_AP_GET_PRIVATE (ap)->max_bitrate; + return NM_WIFI_AP_GET_PRIVATE (ap)->max_bitrate; } void -nm_ap_set_max_bitrate (NMAccessPoint *ap, guint32 bitrate) +nm_wifi_ap_set_max_bitrate (NMWifiAP *ap, guint32 bitrate) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->max_bitrate != bitrate) { priv->max_bitrate = bitrate; @@ -314,29 +325,29 @@ nm_ap_set_max_bitrate (NMAccessPoint *ap, guint32 bitrate) } gboolean -nm_ap_get_fake (const NMAccessPoint *ap) +nm_wifi_ap_get_fake (const NMWifiAP *ap) { - g_return_val_if_fail (NM_IS_AP (ap), FALSE); + g_return_val_if_fail (NM_IS_WIFI_AP (ap), FALSE); - return NM_AP_GET_PRIVATE (ap)->fake; + return NM_WIFI_AP_GET_PRIVATE (ap)->fake; } void -nm_ap_set_fake (NMAccessPoint *ap, gboolean fake) +nm_wifi_ap_set_fake (NMWifiAP *ap, gboolean fake) { - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - NM_AP_GET_PRIVATE (ap)->fake = fake; + NM_WIFI_AP_GET_PRIVATE (ap)->fake = fake; } static void -nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen) +nm_wifi_ap_set_last_seen (NMWifiAP *ap, gint32 last_seen) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; - g_return_if_fail (NM_IS_AP (ap)); + g_return_if_fail (NM_IS_WIFI_AP (ap)); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); if (priv->last_seen != last_seen) { priv->last_seen = last_seen; @@ -344,7 +355,7 @@ nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen) } } -/*****************************************************************/ +/*****************************************************************************/ static NM80211ApSecurityFlags security_from_vardict (GVariant *security) @@ -387,11 +398,11 @@ security_from_vardict (GVariant *security) } void -nm_ap_update_from_properties (NMAccessPoint *ap, - const char *supplicant_path, - GVariant *properties) +nm_wifi_ap_update_from_properties (NMWifiAP *ap, + const char *supplicant_path, + GVariant *properties) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; char *addr; const guint8 *bytes; GVariant *v; @@ -403,25 +414,25 @@ nm_ap_update_from_properties (NMAccessPoint *ap, g_return_if_fail (ap != NULL); g_return_if_fail (properties != NULL); - priv = NM_AP_GET_PRIVATE (ap); + priv = NM_WIFI_AP_GET_PRIVATE (ap); g_object_freeze_notify (G_OBJECT (ap)); if (g_variant_lookup (properties, "Privacy", "b", &b) && b) - nm_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY); + nm_wifi_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY); if (g_variant_lookup (properties, "Mode", "&s", &s)) { if (!g_strcmp0 (s, "infrastructure")) - nm_ap_set_mode (ap, NM_802_11_MODE_INFRA); + nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA); else if (!g_strcmp0 (s, "ad-hoc")) - nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC); + nm_wifi_ap_set_mode (ap, NM_802_11_MODE_ADHOC); } if (g_variant_lookup (properties, "Signal", "n", &i16)) - nm_ap_set_strength (ap, nm_ap_utils_level_to_quality (i16)); + nm_wifi_ap_set_strength (ap, nm_wifi_utils_level_to_quality (i16)); if (g_variant_lookup (properties, "Frequency", "q", &u16)) - nm_ap_set_freq (ap, u16); + nm_wifi_ap_set_freq (ap, u16); v = g_variant_lookup_value (properties, "SSID", G_VARIANT_TYPE_BYTESTRING); if (v) { @@ -432,7 +443,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap, if ( bytes && len && !(((len == 8) || (len == 9)) && !memcmp (bytes, "", 8)) && !nm_utils_is_empty_ssid (bytes, len)) - nm_ap_set_ssid (ap, bytes, len); + nm_wifi_ap_set_ssid (ap, bytes, len); g_variant_unref (v); } @@ -442,13 +453,13 @@ nm_ap_update_from_properties (NMAccessPoint *ap, bytes = g_variant_get_fixed_array (v, &len, 1); if (len == ETH_ALEN) { addr = nm_utils_hwaddr_ntoa (bytes, len); - nm_ap_set_address (ap, addr); + nm_wifi_ap_set_address (ap, addr); g_free (addr); } g_variant_unref (v); } - v = g_variant_lookup_value (properties, "Rates", G_VARIANT_TYPE ("au")); + v = g_variant_lookup_value (properties, "Rates", G_VARIANT_TYPE ("au")); if (v) { const guint32 *rates = g_variant_get_fixed_array (v, &len, sizeof (guint32)); guint32 maxrate = 0; @@ -458,7 +469,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap, for (i = 0; i < len; i++) { if (rates[i] > maxrate) { maxrate = rates[i]; - nm_ap_set_max_bitrate (ap, rates[i] / 1000); + nm_wifi_ap_set_max_bitrate (ap, rates[i] / 1000); } } g_variant_unref (v); @@ -466,54 +477,25 @@ nm_ap_update_from_properties (NMAccessPoint *ap, v = g_variant_lookup_value (properties, "WPA", G_VARIANT_TYPE_VARDICT); if (v) { - nm_ap_set_wpa_flags (ap, priv->wpa_flags | security_from_vardict (v)); + nm_wifi_ap_set_wpa_flags (ap, priv->wpa_flags | security_from_vardict (v)); g_variant_unref (v); } v = g_variant_lookup_value (properties, "RSN", G_VARIANT_TYPE_VARDICT); if (v) { - nm_ap_set_rsn_flags (ap, priv->rsn_flags | security_from_vardict (v)); + nm_wifi_ap_set_rsn_flags (ap, priv->rsn_flags | security_from_vardict (v)); g_variant_unref (v); } if (!priv->supplicant_path) priv->supplicant_path = g_strdup (supplicant_path); - nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ()); + nm_wifi_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ()); priv->fake = FALSE; g_object_thaw_notify (G_OBJECT (ap)); } -NMAccessPoint * -nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties) -{ - const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - NMAccessPoint *ap; - const char *addr; - - g_return_val_if_fail (supplicant_path != NULL, NULL); - g_return_val_if_fail (properties != NULL, NULL); - - ap = (NMAccessPoint *) g_object_new (NM_TYPE_AP, NULL); - nm_ap_update_from_properties (ap, supplicant_path, properties); - - /* ignore APs with invalid or missing BSSIDs */ - addr = nm_ap_get_address (ap); - if ( !addr - || nm_utils_hwaddr_matches (addr, -1, bad_bssid1, ETH_ALEN) - || nm_utils_hwaddr_matches (addr, -1, bad_bssid2, ETH_ALEN)) { - g_object_unref (ap); - return NULL; - } - - return ap; -} - -#define PROTO_WPA "wpa" -#define PROTO_RSN "rsn" - static gboolean has_proto (NMSettingWirelessSecurity *sec, const char *proto) { @@ -531,9 +513,9 @@ has_proto (NMSettingWirelessSecurity *sec, const char *proto) } static void -add_pair_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec) +add_pair_ciphers (NMWifiAP *ap, NMSettingWirelessSecurity *sec) { - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap); + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (ap); guint32 num = nm_setting_wireless_security_get_num_pairwise (sec); NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE; guint32 i; @@ -553,15 +535,15 @@ add_pair_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec) } if (has_proto (sec, PROTO_WPA)) - nm_ap_set_wpa_flags (ap, priv->wpa_flags | flags); + nm_wifi_ap_set_wpa_flags (ap, priv->wpa_flags | flags); if (has_proto (sec, PROTO_RSN)) - nm_ap_set_rsn_flags (ap, priv->rsn_flags | flags); + nm_wifi_ap_set_rsn_flags (ap, priv->rsn_flags | flags); } static void -add_group_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec) +add_group_ciphers (NMWifiAP *ap, NMSettingWirelessSecurity *sec) { - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap); + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (ap); guint32 num = nm_setting_wireless_security_get_num_groups (sec); NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE; guint32 i; @@ -585,143 +567,15 @@ add_group_ciphers (NMAccessPoint *ap, NMSettingWirelessSecurity *sec) } if (has_proto (sec, PROTO_WPA)) - nm_ap_set_wpa_flags (ap, priv->wpa_flags | flags); + nm_wifi_ap_set_wpa_flags (ap, priv->wpa_flags | flags); if (has_proto (sec, PROTO_RSN)) - nm_ap_set_rsn_flags (ap, priv->rsn_flags | flags); -} - -NMAccessPoint * -nm_ap_new_fake_from_connection (NMConnection *connection) -{ - NMAccessPoint *ap; - NMAccessPointPrivate *priv; - NMSettingWireless *s_wireless; - NMSettingWirelessSecurity *s_wireless_sec; - GBytes *ssid; - const char *mode, *band, *key_mgmt; - guint32 channel; - NM80211ApSecurityFlags flags; - gboolean psk = FALSE, eap = FALSE; - - g_return_val_if_fail (connection != NULL, NULL); - - s_wireless = nm_connection_get_setting_wireless (connection); - g_return_val_if_fail (s_wireless != NULL, NULL); - - ssid = nm_setting_wireless_get_ssid (s_wireless); - g_return_val_if_fail (ssid != NULL, NULL); - g_return_val_if_fail (g_bytes_get_size (ssid) > 0, NULL); - - ap = (NMAccessPoint *) g_object_new (NM_TYPE_AP, NULL); - priv = NM_AP_GET_PRIVATE (ap); - priv->fake = TRUE; - nm_ap_set_ssid (ap, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); - - // FIXME: bssid too? - - mode = nm_setting_wireless_get_mode (s_wireless); - if (mode) { - if (!strcmp (mode, "infrastructure")) - nm_ap_set_mode (ap, NM_802_11_MODE_INFRA); - else if (!strcmp (mode, "adhoc")) - nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC); - else if (!strcmp (mode, "ap")) { - nm_ap_set_mode (ap, NM_802_11_MODE_INFRA); - NM_AP_GET_PRIVATE (ap)->hotspot = TRUE; - } else - goto error; - } else { - nm_ap_set_mode (ap, NM_802_11_MODE_INFRA); - } - - band = nm_setting_wireless_get_band (s_wireless); - channel = nm_setting_wireless_get_channel (s_wireless); - - if (band && channel) { - guint32 freq = nm_utils_wifi_channel_to_freq (channel, band); - - if (freq == 0) - goto error; - - nm_ap_set_freq (ap, freq); - } - - s_wireless_sec = nm_connection_get_setting_wireless_security (connection); - /* Assume presence of a security setting means the AP is encrypted */ - if (!s_wireless_sec) - goto done; - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec); - - /* Everything below here uses encryption */ - nm_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY); - - /* Static & Dynamic WEP */ - if (!strcmp (key_mgmt, "none") || !strcmp (key_mgmt, "ieee8021x")) - goto done; - - psk = !strcmp (key_mgmt, "wpa-psk"); - eap = !strcmp (key_mgmt, "wpa-eap"); - if (psk || eap) { - if (has_proto (s_wireless_sec, PROTO_WPA)) { - flags = priv->wpa_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK); - nm_ap_set_wpa_flags (ap, flags); - } - if (has_proto (s_wireless_sec, PROTO_RSN)) { - flags = priv->rsn_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK); - nm_ap_set_rsn_flags (ap, flags); - } - - add_pair_ciphers (ap, s_wireless_sec); - add_group_ciphers (ap, s_wireless_sec); - } else if (!strcmp (key_mgmt, "wpa-none")) { - guint32 i; - - /* Ad-Hoc has special requirements: proto=WPA, pairwise=(none), and - * group=TKIP/CCMP (but not both). - */ - - flags = priv->wpa_flags | NM_802_11_AP_SEC_KEY_MGMT_PSK; - - /* Clear ciphers; pairwise must be unset anyway, and group gets set below */ - flags &= ~( NM_802_11_AP_SEC_PAIR_WEP40 - | NM_802_11_AP_SEC_PAIR_WEP104 - | NM_802_11_AP_SEC_PAIR_TKIP - | NM_802_11_AP_SEC_PAIR_CCMP - | NM_802_11_AP_SEC_GROUP_WEP40 - | NM_802_11_AP_SEC_GROUP_WEP104 - | NM_802_11_AP_SEC_GROUP_TKIP - | NM_802_11_AP_SEC_GROUP_CCMP); - - for (i = 0; i < nm_setting_wireless_security_get_num_groups (s_wireless_sec); i++) { - if (!strcmp (nm_setting_wireless_security_get_group (s_wireless_sec, i), "ccmp")) { - flags |= NM_802_11_AP_SEC_GROUP_CCMP; - break; - } - } - - /* Default to TKIP since not all WPA-capable cards can do CCMP */ - if (!(flags & NM_802_11_AP_SEC_GROUP_CCMP)) - flags |= NM_802_11_AP_SEC_GROUP_TKIP; - - nm_ap_set_wpa_flags (ap, flags); - - /* Don't use Ad-Hoc RSN yet */ - nm_ap_set_rsn_flags (ap, NM_802_11_AP_SEC_NONE); - } - -done: - return ap; - -error: - g_object_unref (ap); - return NULL; + nm_wifi_ap_set_rsn_flags (ap, priv->rsn_flags | flags); } static char -mode_to_char (NMAccessPoint *self) +mode_to_char (NMWifiAP *self) { - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (self); + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (self); if (priv->mode == NM_802_11_MODE_ADHOC) return '*'; @@ -733,17 +587,17 @@ mode_to_char (NMAccessPoint *self) } void -nm_ap_dump (NMAccessPoint *self, - const char *prefix, - const char *ifname) +nm_wifi_ap_dump (NMWifiAP *self, + const char *prefix, + const char *ifname) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; const char *supplicant_id = "-"; guint32 chan; - g_return_if_fail (NM_IS_AP (self)); + g_return_if_fail (NM_IS_WIFI_AP (self)); - priv = NM_AP_GET_PRIVATE (self); + priv = NM_WIFI_AP_GET_PRIVATE (self); chan = nm_utils_wifi_freq_to_channel (priv->freq); if (priv->supplicant_path) supplicant_id = strrchr (priv->supplicant_path, '/'); @@ -775,10 +629,10 @@ freq_to_band (guint32 freq) } gboolean -nm_ap_check_compatible (NMAccessPoint *self, - NMConnection *connection) +nm_wifi_ap_check_compatible (NMWifiAP *self, + NMConnection *connection) { - NMAccessPointPrivate *priv; + NMWifiAPPrivate *priv; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wireless_sec; GBytes *ssid; @@ -787,15 +641,15 @@ nm_ap_check_compatible (NMAccessPoint *self, const char *bssid; guint32 channel; - g_return_val_if_fail (NM_IS_AP (self), FALSE); + g_return_val_if_fail (NM_IS_WIFI_AP (self), FALSE); g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); - priv = NM_AP_GET_PRIVATE (self); + priv = NM_WIFI_AP_GET_PRIVATE (self); s_wireless = nm_connection_get_setting_wireless (connection); if (s_wireless == NULL) return FALSE; - + ssid = nm_setting_wireless_get_ssid (s_wireless); if ( (ssid && !priv->ssid) || (priv->ssid && !ssid)) @@ -851,65 +705,33 @@ nm_ap_check_compatible (NMAccessPoint *self, } gboolean -nm_ap_complete_connection (NMAccessPoint *self, - NMConnection *connection, - gboolean lock_bssid, - GError **error) +nm_wifi_ap_complete_connection (NMWifiAP *self, + NMConnection *connection, + gboolean lock_bssid, + GError **error) { - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (self); + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (self); g_return_val_if_fail (connection != NULL, FALSE); - return nm_ap_utils_complete_connection (priv->ssid, - priv->address, - priv->mode, - priv->flags, - priv->wpa_flags, - priv->rsn_flags, - connection, - lock_bssid, - error); -} - -/*****************************************************************/ - -static void -nm_ap_init (NMAccessPoint *ap) -{ - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap); - - priv->mode = NM_802_11_MODE_INFRA; - priv->flags = NM_802_11_AP_FLAGS_NONE; - priv->wpa_flags = NM_802_11_AP_SEC_NONE; - priv->rsn_flags = NM_802_11_AP_SEC_NONE; - priv->last_seen = -1; -} - -static void -finalize (GObject *object) -{ - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE ((NMAccessPoint *) object); - - g_free (priv->supplicant_path); - if (priv->ssid) - g_byte_array_free (priv->ssid, TRUE); - g_free (priv->address); - - G_OBJECT_CLASS (nm_ap_parent_class)->finalize (object); + return nm_wifi_utils_complete_connection (priv->ssid, + priv->address, + priv->mode, + priv->flags, + priv->wpa_flags, + priv->rsn_flags, + connection, + lock_bssid, + error); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE ((NMAccessPoint *) object); + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE ((NMWifiAP *) object); GVariant *ssid; switch (prop_id) { @@ -957,85 +779,265 @@ get_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + static void -nm_ap_class_init (NMAccessPointClass *ap_class) +nm_wifi_ap_init (NMWifiAP *ap) +{ + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE (ap); + + priv->mode = NM_802_11_MODE_INFRA; + priv->flags = NM_802_11_AP_FLAGS_NONE; + priv->wpa_flags = NM_802_11_AP_SEC_NONE; + priv->rsn_flags = NM_802_11_AP_SEC_NONE; + priv->last_seen = -1; +} + +NMWifiAP * +nm_wifi_ap_new_from_properties (const char *supplicant_path, GVariant *properties) +{ + const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + NMWifiAP *ap; + const char *addr; + + g_return_val_if_fail (supplicant_path != NULL, NULL); + g_return_val_if_fail (properties != NULL, NULL); + + ap = (NMWifiAP *) g_object_new (NM_TYPE_WIFI_AP, NULL); + nm_wifi_ap_update_from_properties (ap, supplicant_path, properties); + + /* ignore APs with invalid or missing BSSIDs */ + addr = nm_wifi_ap_get_address (ap); + if ( !addr + || nm_utils_hwaddr_matches (addr, -1, bad_bssid1, ETH_ALEN) + || nm_utils_hwaddr_matches (addr, -1, bad_bssid2, ETH_ALEN)) { + g_object_unref (ap); + return NULL; + } + + return ap; +} + +NMWifiAP * +nm_wifi_ap_new_fake_from_connection (NMConnection *connection) { + NMWifiAP *ap; + NMWifiAPPrivate *priv; + NMSettingWireless *s_wireless; + NMSettingWirelessSecurity *s_wireless_sec; + GBytes *ssid; + const char *mode, *band, *key_mgmt; + guint32 channel; + NM80211ApSecurityFlags flags; + gboolean psk = FALSE, eap = FALSE; + + g_return_val_if_fail (connection != NULL, NULL); + + s_wireless = nm_connection_get_setting_wireless (connection); + g_return_val_if_fail (s_wireless != NULL, NULL); + + ssid = nm_setting_wireless_get_ssid (s_wireless); + g_return_val_if_fail (ssid != NULL, NULL); + g_return_val_if_fail (g_bytes_get_size (ssid) > 0, NULL); + + ap = (NMWifiAP *) g_object_new (NM_TYPE_WIFI_AP, NULL); + priv = NM_WIFI_AP_GET_PRIVATE (ap); + priv->fake = TRUE; + nm_wifi_ap_set_ssid (ap, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); + + // FIXME: bssid too? + + mode = nm_setting_wireless_get_mode (s_wireless); + if (mode) { + if (!strcmp (mode, "infrastructure")) + nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA); + else if (!strcmp (mode, "adhoc")) + nm_wifi_ap_set_mode (ap, NM_802_11_MODE_ADHOC); + else if (!strcmp (mode, "ap")) { + nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA); + NM_WIFI_AP_GET_PRIVATE (ap)->hotspot = TRUE; + } else + goto error; + } else { + nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA); + } + + band = nm_setting_wireless_get_band (s_wireless); + channel = nm_setting_wireless_get_channel (s_wireless); + + if (band && channel) { + guint32 freq = nm_utils_wifi_channel_to_freq (channel, band); + + if (freq == 0) + goto error; + + nm_wifi_ap_set_freq (ap, freq); + } + + s_wireless_sec = nm_connection_get_setting_wireless_security (connection); + /* Assume presence of a security setting means the AP is encrypted */ + if (!s_wireless_sec) + goto done; + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec); + + /* Everything below here uses encryption */ + nm_wifi_ap_set_flags (ap, priv->flags | NM_802_11_AP_FLAGS_PRIVACY); + + /* Static & Dynamic WEP */ + if (!strcmp (key_mgmt, "none") || !strcmp (key_mgmt, "ieee8021x")) + goto done; + + psk = !strcmp (key_mgmt, "wpa-psk"); + eap = !strcmp (key_mgmt, "wpa-eap"); + if (psk || eap) { + if (has_proto (s_wireless_sec, PROTO_WPA)) { + flags = priv->wpa_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK); + nm_wifi_ap_set_wpa_flags (ap, flags); + } + if (has_proto (s_wireless_sec, PROTO_RSN)) { + flags = priv->rsn_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK); + nm_wifi_ap_set_rsn_flags (ap, flags); + } + + add_pair_ciphers (ap, s_wireless_sec); + add_group_ciphers (ap, s_wireless_sec); + } else if (!strcmp (key_mgmt, "wpa-none")) { + guint32 i; + + /* Ad-Hoc has special requirements: proto=WPA, pairwise=(none), and + * group=TKIP/CCMP (but not both). + */ + + flags = priv->wpa_flags | NM_802_11_AP_SEC_KEY_MGMT_PSK; + + /* Clear ciphers; pairwise must be unset anyway, and group gets set below */ + flags &= ~( NM_802_11_AP_SEC_PAIR_WEP40 + | NM_802_11_AP_SEC_PAIR_WEP104 + | NM_802_11_AP_SEC_PAIR_TKIP + | NM_802_11_AP_SEC_PAIR_CCMP + | NM_802_11_AP_SEC_GROUP_WEP40 + | NM_802_11_AP_SEC_GROUP_WEP104 + | NM_802_11_AP_SEC_GROUP_TKIP + | NM_802_11_AP_SEC_GROUP_CCMP); + + for (i = 0; i < nm_setting_wireless_security_get_num_groups (s_wireless_sec); i++) { + if (!strcmp (nm_setting_wireless_security_get_group (s_wireless_sec, i), "ccmp")) { + flags |= NM_802_11_AP_SEC_GROUP_CCMP; + break; + } + } + + /* Default to TKIP since not all WPA-capable cards can do CCMP */ + if (!(flags & NM_802_11_AP_SEC_GROUP_CCMP)) + flags |= NM_802_11_AP_SEC_GROUP_TKIP; + + nm_wifi_ap_set_wpa_flags (ap, flags); + + /* Don't use Ad-Hoc RSN yet */ + nm_wifi_ap_set_rsn_flags (ap, NM_802_11_AP_SEC_NONE); + } + +done: + return ap; + +error: + g_object_unref (ap); + return NULL; +} + +static void +finalize (GObject *object) +{ + NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE ((NMWifiAP *) object); + + g_free (priv->supplicant_path); + if (priv->ssid) + g_byte_array_free (priv->ssid, TRUE); + g_free (priv->address); + + G_OBJECT_CLASS (nm_wifi_ap_parent_class)->finalize (object); +} + +static void +nm_wifi_ap_class_init (NMWifiAPClass *ap_class) +{ +#define ALL_SEC_FLAGS \ + ( NM_802_11_AP_SEC_NONE \ + | NM_802_11_AP_SEC_PAIR_WEP40 \ + | NM_802_11_AP_SEC_PAIR_WEP104 \ + | NM_802_11_AP_SEC_PAIR_TKIP \ + | NM_802_11_AP_SEC_PAIR_CCMP \ + | NM_802_11_AP_SEC_GROUP_WEP40 \ + | NM_802_11_AP_SEC_GROUP_WEP104 \ + | NM_802_11_AP_SEC_GROUP_TKIP \ + | NM_802_11_AP_SEC_GROUP_CCMP \ + | NM_802_11_AP_SEC_KEY_MGMT_PSK \ + | NM_802_11_AP_SEC_KEY_MGMT_802_1X ) + GObjectClass *object_class = G_OBJECT_CLASS (ap_class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (ap_class); - const NM80211ApSecurityFlags all_sec_flags = NM_802_11_AP_SEC_NONE - | NM_802_11_AP_SEC_PAIR_WEP40 - | NM_802_11_AP_SEC_PAIR_WEP104 - | NM_802_11_AP_SEC_PAIR_TKIP - | NM_802_11_AP_SEC_PAIR_CCMP - | NM_802_11_AP_SEC_GROUP_WEP40 - | NM_802_11_AP_SEC_GROUP_WEP104 - | NM_802_11_AP_SEC_GROUP_TKIP - | NM_802_11_AP_SEC_GROUP_CCMP - | NM_802_11_AP_SEC_KEY_MGMT_PSK - | NM_802_11_AP_SEC_KEY_MGMT_802_1X; - - exported_object_class->export_path = NM_DBUS_PATH_ACCESS_POINT "/%u"; - - /* virtual methods */ - object_class->set_property = set_property; + + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH_ACCESS_POINT); + object_class->get_property = get_property; object_class->finalize = finalize; - /* properties */ obj_properties[PROP_FLAGS] = - g_param_spec_uint (NM_AP_FLAGS, "", "", + g_param_spec_uint (NM_WIFI_AP_FLAGS, "", "", NM_802_11_AP_FLAGS_NONE, NM_802_11_AP_FLAGS_PRIVACY, NM_802_11_AP_FLAGS_NONE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_WPA_FLAGS] = - g_param_spec_uint (NM_AP_WPA_FLAGS, "", "", + g_param_spec_uint (NM_WIFI_AP_WPA_FLAGS, "", "", NM_802_11_AP_SEC_NONE, - all_sec_flags, + ALL_SEC_FLAGS, NM_802_11_AP_SEC_NONE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_RSN_FLAGS] = - g_param_spec_uint (NM_AP_RSN_FLAGS, "", "", + g_param_spec_uint (NM_WIFI_AP_RSN_FLAGS, "", "", NM_802_11_AP_SEC_NONE, - all_sec_flags, + ALL_SEC_FLAGS, NM_802_11_AP_SEC_NONE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_SSID] = - g_param_spec_variant (NM_AP_SSID, "", "", + g_param_spec_variant (NM_WIFI_AP_SSID, "", "", G_VARIANT_TYPE ("ay"), NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_FREQUENCY] = - g_param_spec_uint (NM_AP_FREQUENCY, "", "", + g_param_spec_uint (NM_WIFI_AP_FREQUENCY, "", "", 0, 10000, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_AP_HW_ADDRESS, "", "", + g_param_spec_string (NM_WIFI_AP_HW_ADDRESS, "", "", NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_MODE] = - g_param_spec_uint (NM_AP_MODE, "", "", + g_param_spec_uint (NM_WIFI_AP_MODE, "", "", NM_802_11_MODE_ADHOC, NM_802_11_MODE_INFRA, NM_802_11_MODE_INFRA, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_MAX_BITRATE] = - g_param_spec_uint (NM_AP_MAX_BITRATE, "", "", + g_param_spec_uint (NM_WIFI_AP_MAX_BITRATE, "", "", 0, G_MAXUINT16, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_STRENGTH] = - g_param_spec_uchar (NM_AP_STRENGTH, "", "", + g_param_spec_uchar (NM_WIFI_AP_STRENGTH, "", "", 0, G_MAXINT8, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_LAST_SEEN] = - g_param_spec_int (NM_AP_LAST_SEEN, "", "", + g_param_spec_int (NM_WIFI_AP_LAST_SEEN, "", "", -1, G_MAXINT, -1, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h index 035d1b5e..5a2a2e58 100644 --- a/src/devices/wifi/nm-wifi-ap.h +++ b/src/devices/wifi/nm-wifi-ap.h @@ -19,78 +19,78 @@ * Copyright (C) 2006 - 2008 Novell, Inc. */ -#ifndef __NETWORKMANAGER_ACCESS_POINT_H__ -#define __NETWORKMANAGER_ACCESS_POINT_H__ +#ifndef __NM_WIFI_AP_H__ +#define __NM_WIFI_AP_H__ #include "nm-exported-object.h" #include "nm-dbus-interface.h" #include "nm-connection.h" -#define NM_TYPE_AP (nm_ap_get_type ()) -#define NM_AP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AP, NMAccessPoint)) -#define NM_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_AP, NMAccessPointClass)) -#define NM_IS_AP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_AP)) -#define NM_IS_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AP)) -#define NM_AP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AP, NMAccessPointClass)) +#define NM_TYPE_WIFI_AP (nm_wifi_ap_get_type ()) +#define NM_WIFI_AP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_AP, NMWifiAP)) +#define NM_WIFI_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIFI_AP, NMWifiAPClass)) +#define NM_IS_WIFI_AP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIFI_AP)) +#define NM_IS_WIFI_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIFI_AP)) +#define NM_WIFI_AP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIFI_AP, NMWifiAPClass)) -#define NM_AP_FLAGS "flags" -#define NM_AP_WPA_FLAGS "wpa-flags" -#define NM_AP_RSN_FLAGS "rsn-flags" -#define NM_AP_SSID "ssid" -#define NM_AP_FREQUENCY "frequency" -#define NM_AP_HW_ADDRESS "hw-address" -#define NM_AP_MODE "mode" -#define NM_AP_MAX_BITRATE "max-bitrate" -#define NM_AP_STRENGTH "strength" -#define NM_AP_LAST_SEEN "last-seen" +#define NM_WIFI_AP_FLAGS "flags" +#define NM_WIFI_AP_WPA_FLAGS "wpa-flags" +#define NM_WIFI_AP_RSN_FLAGS "rsn-flags" +#define NM_WIFI_AP_SSID "ssid" +#define NM_WIFI_AP_FREQUENCY "frequency" +#define NM_WIFI_AP_HW_ADDRESS "hw-address" +#define NM_WIFI_AP_MODE "mode" +#define NM_WIFI_AP_MAX_BITRATE "max-bitrate" +#define NM_WIFI_AP_STRENGTH "strength" +#define NM_WIFI_AP_LAST_SEEN "last-seen" -typedef struct _NMAccessPoint NMAccessPoint; -typedef struct _NMAccessPointClass NMAccessPointClass; +typedef struct _NMWifiAP NMWifiAP; +typedef struct _NMWifiAPClass NMWifiAPClass; -GType nm_ap_get_type (void); +GType nm_wifi_ap_get_type (void); -NMAccessPoint * nm_ap_new_from_properties (const char *supplicant_path, +NMWifiAP * nm_wifi_ap_new_from_properties (const char *supplicant_path, GVariant *properties); -NMAccessPoint * nm_ap_new_fake_from_connection (NMConnection *connection); +NMWifiAP * nm_wifi_ap_new_fake_from_connection (NMConnection *connection); -void nm_ap_update_from_properties (NMAccessPoint *ap, - const char *supplicant_path, - GVariant *properties); +void nm_wifi_ap_update_from_properties (NMWifiAP *ap, + const char *supplicant_path, + GVariant *properties); -gboolean nm_ap_check_compatible (NMAccessPoint *self, - NMConnection *connection); +gboolean nm_wifi_ap_check_compatible (NMWifiAP *self, + NMConnection *connection); -gboolean nm_ap_complete_connection (NMAccessPoint *self, - NMConnection *connection, - gboolean lock_bssid, - GError **error); +gboolean nm_wifi_ap_complete_connection (NMWifiAP *self, + NMConnection *connection, + gboolean lock_bssid, + GError **error); -const char * nm_ap_get_supplicant_path (NMAccessPoint *ap); -guint32 nm_ap_get_id (NMAccessPoint *ap); -const GByteArray *nm_ap_get_ssid (const NMAccessPoint *ap); -void nm_ap_set_ssid (NMAccessPoint *ap, - const guint8 *ssid, - gsize len); -const char * nm_ap_get_address (const NMAccessPoint *ap); -void nm_ap_set_address (NMAccessPoint *ap, - const char *addr); -NM80211Mode nm_ap_get_mode (NMAccessPoint *ap); -gboolean nm_ap_is_hotspot (NMAccessPoint *ap); -gint8 nm_ap_get_strength (NMAccessPoint *ap); -void nm_ap_set_strength (NMAccessPoint *ap, - gint8 strength); -guint32 nm_ap_get_freq (NMAccessPoint *ap); -void nm_ap_set_freq (NMAccessPoint *ap, - guint32 freq); -guint32 nm_ap_get_max_bitrate (NMAccessPoint *ap); -void nm_ap_set_max_bitrate (NMAccessPoint *ap, - guint32 bitrate); -gboolean nm_ap_get_fake (const NMAccessPoint *ap); -void nm_ap_set_fake (NMAccessPoint *ap, - gboolean fake); +const char * nm_wifi_ap_get_supplicant_path (NMWifiAP *ap); +guint64 nm_wifi_ap_get_id (NMWifiAP *ap); +const GByteArray *nm_wifi_ap_get_ssid (const NMWifiAP *ap); +void nm_wifi_ap_set_ssid (NMWifiAP *ap, + const guint8 *ssid, + gsize len); +const char * nm_wifi_ap_get_address (const NMWifiAP *ap); +void nm_wifi_ap_set_address (NMWifiAP *ap, + const char *addr); +NM80211Mode nm_wifi_ap_get_mode (NMWifiAP *ap); +gboolean nm_wifi_ap_is_hotspot (NMWifiAP *ap); +gint8 nm_wifi_ap_get_strength (NMWifiAP *ap); +void nm_wifi_ap_set_strength (NMWifiAP *ap, + gint8 strength); +guint32 nm_wifi_ap_get_freq (NMWifiAP *ap); +void nm_wifi_ap_set_freq (NMWifiAP *ap, + guint32 freq); +guint32 nm_wifi_ap_get_max_bitrate (NMWifiAP *ap); +void nm_wifi_ap_set_max_bitrate (NMWifiAP *ap, + guint32 bitrate); +gboolean nm_wifi_ap_get_fake (const NMWifiAP *ap); +void nm_wifi_ap_set_fake (NMWifiAP *ap, + gboolean fake); -void nm_ap_dump (NMAccessPoint *self, - const char *prefix, - const char *ifname); +void nm_wifi_ap_dump (NMWifiAP *self, + const char *prefix, + const char *ifname); -#endif /* __NETWORKMANAGER_ACCESS_POINT_H__ */ +#endif /* __NM_WIFI_AP_H__ */ diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c index cf8cf03b..a1752634 100644 --- a/src/devices/wifi/nm-wifi-factory.c +++ b/src/devices/wifi/nm-wifi-factory.c @@ -22,33 +22,41 @@ #include -#include "nm-device-factory.h" +#include "devices/nm-device-factory.h" #include "nm-setting-wireless.h" #include "nm-setting-olpc-mesh.h" #include "nm-device-wifi.h" #include "nm-device-olpc-mesh.h" -#include "nm-settings-connection.h" -#include "nm-platform.h" +#include "settings/nm-settings-connection.h" +#include "platform/nm-platform.h" -#define NM_TYPE_WIFI_FACTORY (nm_wifi_factory_get_type ()) -#define NM_WIFI_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_FACTORY, NMWifiFactory)) +/*****************************************************************************/ + +#define NM_TYPE_WIFI_FACTORY (nm_wifi_factory_get_type ()) +#define NM_WIFI_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_FACTORY, NMWifiFactory)) +#define NM_WIFI_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIFI_FACTORY, NMWifiFactoryClass)) +#define NM_IS_WIFI_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIFI_FACTORY)) +#define NM_IS_WIFI_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIFI_FACTORY)) +#define NM_WIFI_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIFI_FACTORY, NMWifiFactoryClass)) typedef struct { - GObject parent; + NMDeviceFactory parent; } NMWifiFactory; typedef struct { - GObjectClass parent; + NMDeviceFactoryClass parent; } NMWifiFactoryClass; static GType nm_wifi_factory_get_type (void); -static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); +G_DEFINE_TYPE (NMWifiFactory, nm_wifi_factory, NM_TYPE_DEVICE_FACTORY) -G_DEFINE_TYPE_EXTENDED (NMWifiFactory, nm_wifi_factory, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) +/*****************************************************************************/ -/**************************************************************************/ +NM_DEVICE_FACTORY_DECLARE_TYPES ( + NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_WIFI, NM_LINK_TYPE_OLPC_MESH) + NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_OLPC_MESH_SETTING_NAME) +) G_MODULE_EXPORT NMDeviceFactory * nm_device_factory_create (GError **error) @@ -56,7 +64,7 @@ nm_device_factory_create (GError **error) return (NMDeviceFactory *) g_object_new (NM_TYPE_WIFI_FACTORY, NULL); } -/**************************************************************************/ +/*****************************************************************************/ static NMDevice * create_device (NMDeviceFactory *factory, @@ -96,17 +104,7 @@ create_device (NMDeviceFactory *factory, return nm_device_olpc_mesh_new (iface); } -NM_DEVICE_FACTORY_DECLARE_TYPES ( - NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_WIFI, NM_LINK_TYPE_OLPC_MESH) - NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_OLPC_MESH_SETTING_NAME) -) - -static void -device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) -{ - factory_iface->create_device = create_device; - factory_iface->get_supported_types = get_supported_types; -} +/*****************************************************************************/ static void nm_wifi_factory_init (NMWifiFactory *self) @@ -114,7 +112,10 @@ nm_wifi_factory_init (NMWifiFactory *self) } static void -nm_wifi_factory_class_init (NMWifiFactoryClass *wf_class) +nm_wifi_factory_class_init (NMWifiFactoryClass *klass) { -} + NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS (klass); + factory_class->create_device = create_device; + factory_class->get_supported_types = get_supported_types; +} diff --git a/src/devices/wifi/nm-wifi-utils.c b/src/devices/wifi/nm-wifi-utils.c new file mode 100644 index 00000000..06da92ce --- /dev/null +++ b/src/devices/wifi/nm-wifi-utils.c @@ -0,0 +1,786 @@ +/*-*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-wifi-utils.h" + +#include +#include + +#include "nm-utils.h" + +static gboolean +verify_no_wep (NMSettingWirelessSecurity *s_wsec, const char *tag, GError **error) +{ + if ( nm_setting_wireless_security_get_wep_key (s_wsec, 0) + || nm_setting_wireless_security_get_wep_key (s_wsec, 1) + || nm_setting_wireless_security_get_wep_key (s_wsec, 2) + || nm_setting_wireless_security_get_wep_key (s_wsec, 3) + || nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec) + || nm_setting_wireless_security_get_wep_key_type (s_wsec)) { + /* Dynamic WEP cannot have any WEP keys set */ + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("%s is incompatible with static WEP keys"), tag); + g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + return FALSE; + } + + return TRUE; +} + +static gboolean +verify_leap (NMSettingWirelessSecurity *s_wsec, + NMSetting8021x *s_8021x, + gboolean adhoc, + GError **error) +{ + const char *key_mgmt, *auth_alg, *leap_username; + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); + + /* One (or both) of two things indicates we want LEAP: + * 1) auth_alg == 'leap' + * 2) valid leap_username + * + * LEAP always requires a LEAP username. + */ + + if (auth_alg) { + if (!strcmp (auth_alg, "leap")) { + /* LEAP authentication requires at least a LEAP username */ + if (!leap_username) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("LEAP authentication requires a LEAP username")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); + return FALSE; + } + } else if (leap_username) { + /* Leap username requires 'leap' auth */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("LEAP username requires 'leap' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); + return FALSE; + } + } + + if (leap_username) { + if (key_mgmt && strcmp (key_mgmt, "ieee8021x")) { + /* LEAP requires ieee8021x key management */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("LEAP authentication requires IEEE 802.1x key management")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + return FALSE; + } + } + + /* At this point if auth_alg is set it must be 'leap', and if key_mgmt + * is set it must be 'ieee8021x'. + */ + if (leap_username) { + if (auth_alg) + g_assert (strcmp (auth_alg, "leap") == 0); + if (key_mgmt) + g_assert (strcmp (key_mgmt, "ieee8021x") == 0); + + if (adhoc) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("LEAP authentication is incompatible with Ad-Hoc mode")); + g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + return FALSE; + } + + if (!verify_no_wep (s_wsec, "LEAP", error)) + return FALSE; + + if (s_8021x) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("LEAP authentication is incompatible with 802.1x setting")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + } + + return TRUE; +} + +static gboolean +verify_no_wpa (NMSettingWirelessSecurity *s_wsec, + const char *tag, + GError **error) +{ + const char *key_mgmt; + int n, i; + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + if (key_mgmt && !strncmp (key_mgmt, "wpa", 3)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot use WPA key management"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + return FALSE; + } + + if (nm_setting_wireless_security_get_num_protos (s_wsec)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specify WPA protocols"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PROTO); + return FALSE; + } + + n = nm_setting_wireless_security_get_num_pairwise (s_wsec); + for (i = 0; i < n; i++) { + const char *pw; + + pw = nm_setting_wireless_security_get_pairwise (s_wsec, i); + if (!strcmp (pw, "tkip") || !strcmp (pw, "ccmp")) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specify WPA ciphers"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PAIRWISE); + return FALSE; + } + } + + n = nm_setting_wireless_security_get_num_groups (s_wsec); + for (i = 0; i < n; i++) { + const char *gr; + + gr = nm_setting_wireless_security_get_group (s_wsec, i); + if (strcmp (gr, "wep40") && strcmp (gr, "wep104")) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specify WPA ciphers"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_GROUP); + return FALSE; + } + } + + if (nm_setting_wireless_security_get_psk (s_wsec)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specify a WPA password"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PSK); + return FALSE; + } + + return TRUE; +} + +static gboolean +verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec, + NMSetting8021x *s_8021x, + gboolean adhoc, + GError **error) +{ + const char *key_mgmt, *auth_alg, *leap_username; + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); + + g_return_val_if_fail (leap_username == NULL, TRUE); + + if (key_mgmt) { + if (!strcmp (key_mgmt, "ieee8021x")) { + if (!s_8021x) { + /* 802.1x key management requires an 802.1x setting */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("Dynamic WEP requires an 802.1x setting")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + + if (auth_alg && strcmp (auth_alg, "open")) { + /* 802.1x key management must use "open" authentication */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Dynamic WEP requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); + return FALSE; + } + + /* Dynamic WEP incompatible with anything static WEP related */ + if (!verify_no_wep (s_wsec, "Dynamic WEP", error)) + return FALSE; + } else if (!strcmp (key_mgmt, "none")) { + if (s_8021x) { + /* 802.1x setting requires 802.1x key management */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Dynamic WEP requires 'ieee8021x' key management")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + return FALSE; + } + } + } else if (s_8021x) { + /* 802.1x setting incompatible with anything but 'open' auth */ + if (auth_alg && strcmp (auth_alg, "open")) { + /* 802.1x key management must use "open" authentication */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Dynamic WEP requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); + return FALSE; + } + + /* Dynamic WEP incompatible with anything static WEP related */ + if (!verify_no_wep (s_wsec, "Dynamic WEP", error)) + return FALSE; + } + + return TRUE; +} + +static gboolean +verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, + NMSetting8021x *s_8021x, + gboolean adhoc, + guint32 wpa_flags, + guint32 rsn_flags, + GError **error) +{ + const char *key_mgmt, *auth_alg, *tmp; + int n; + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + + if (key_mgmt) { + if (!strcmp (key_mgmt, "wpa-psk") || !strcmp (key_mgmt, "wpa-none")) { + if (s_8021x) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("WPA-PSK authentication is incompatible with 802.1x")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + + if (auth_alg && strcmp (auth_alg, "open")) { + /* WPA must use "open" authentication */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA-PSK requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); + return FALSE; + } + } + + if (!strcmp (key_mgmt, "wpa-none")) { + if (!adhoc) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc authentication requires an Ad-Hoc mode AP")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, + NM_SETTING_WIRELESS_MODE); + return FALSE; + } + + /* Ad-Hoc WPA requires 'wpa' proto, 'none' pairwise, and 'tkip' group */ + n = nm_setting_wireless_security_get_num_protos (s_wsec); + tmp = (n > 0) ? nm_setting_wireless_security_get_proto (s_wsec, 0) : NULL; + if (n > 1 || !tmp || strcmp (tmp, "wpa")) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc authentication requires 'wpa' protocol")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PROTO); + return FALSE; + } + + n = nm_setting_wireless_security_get_num_pairwise (s_wsec); + tmp = (n > 0) ? nm_setting_wireless_security_get_pairwise (s_wsec, 0) : NULL; + if (n > 1 || g_strcmp0 (tmp, "none")) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc authentication requires 'none' pairwise cipher")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PAIRWISE); + return FALSE; + } + + n = nm_setting_wireless_security_get_num_groups (s_wsec); + tmp = (n > 0) ? nm_setting_wireless_security_get_group (s_wsec, 0) : NULL; + if (n > 1 || !tmp || strcmp (tmp, "tkip")) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc requires 'tkip' group cipher")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_GROUP); + return FALSE; + } + } + + if (!strcmp (key_mgmt, "wpa-psk")) { + /* Make sure the AP's capabilities support WPA-PSK */ + if ( !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) + && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Access point does not support PSK but setting requires it")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + return FALSE; + } + } + } + + return TRUE; +} + +static gboolean +verify_wpa_eap (NMSettingWirelessSecurity *s_wsec, + NMSetting8021x *s_8021x, + guint32 wpa_flags, + guint32 rsn_flags, + GError **error) +{ + const char *key_mgmt, *auth_alg; + gboolean is_wpa_eap = FALSE; + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + + if (key_mgmt) { + if (!strcmp (key_mgmt, "wpa-eap")) { + if (!s_8021x) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("WPA-EAP authentication requires an 802.1x setting")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + + if (auth_alg && strcmp (auth_alg, "open")) { + /* WPA must use "open" authentication */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA-EAP requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); + return FALSE; + } + + is_wpa_eap = TRUE; + } else if (s_8021x) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("802.1x setting requires 'wpa-eap' key management")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + } + + if (is_wpa_eap || s_8021x) { + /* Make sure the AP's capabilities support WPA-EAP */ + if ( !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) + && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("Access point does not support 802.1x but setting requires it")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + } + + return TRUE; +} + +static gboolean +verify_adhoc (NMSettingWirelessSecurity *s_wsec, + NMSetting8021x *s_8021x, + gboolean adhoc, + GError **error) +{ + const char *key_mgmt = NULL, *leap_username = NULL, *auth_alg = NULL; + + if (s_wsec) { + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); + } + + if (adhoc) { + if (key_mgmt && strcmp (key_mgmt, "wpa-none") && strcmp (key_mgmt, "none")) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Access point mode is Ad-Hoc but setting requires Infrastructure security")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + return FALSE; + } + + if (s_8021x) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("Ad-Hoc mode is incompatible with 802.1x security")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + + if (leap_username) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Ad-Hoc mode is incompatible with LEAP security")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); + return FALSE; + } + + if (auth_alg && strcmp (auth_alg, "open")) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Ad-Hoc mode requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); + return FALSE; + } + } else { + if (key_mgmt && !strcmp (key_mgmt, "wpa-none")) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Access point mode is Infrastructure but setting requires Ad-Hoc security")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + return FALSE; + } + } + + return TRUE; +} + +gboolean +nm_wifi_utils_complete_connection (const GByteArray *ap_ssid, + const char *bssid, + NM80211Mode ap_mode, + guint32 ap_flags, + guint32 ap_wpa_flags, + guint32 ap_rsn_flags, + NMConnection *connection, + gboolean lock_bssid, + GError **error) +{ + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; + GBytes *ssid, *ap_ssid_bytes; + const char *mode, *key_mgmt, *auth_alg, *leap_username; + gboolean adhoc = FALSE; + + s_wifi = nm_connection_get_setting_wireless (connection); + g_assert (s_wifi); + s_wsec = nm_connection_get_setting_wireless_security (connection); + s_8021x = nm_connection_get_setting_802_1x (connection); + + /* Fill in missing SSID */ + ap_ssid_bytes = ap_ssid ? g_bytes_new (ap_ssid->data, ap_ssid->len) : NULL; + ssid = nm_setting_wireless_get_ssid (s_wifi); + if (!ssid) + g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid_bytes, NULL); + else if (!ap_ssid_bytes || !g_bytes_equal (ssid, ap_ssid_bytes)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match access point")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); + g_bytes_unref (ap_ssid_bytes); + return FALSE; + } + g_bytes_unref (ap_ssid_bytes); + + if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi)) + g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL); + + /* And mode */ + mode = nm_setting_wireless_get_mode (s_wifi); + if (mode) { + gboolean valid = FALSE; + + /* Make sure the supplied mode matches the AP's */ + if ( !strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) + || !strcmp (mode, NM_SETTING_WIRELESS_MODE_AP)) { + if (ap_mode == NM_802_11_MODE_INFRA) + valid = TRUE; + } else if (!strcmp (mode, NM_SETTING_WIRELESS_MODE_ADHOC)) { + if (ap_mode == NM_802_11_MODE_ADHOC) + valid = TRUE; + adhoc = TRUE; + } + + if (valid == FALSE) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match access point")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE); + return FALSE; + } + } else { + mode = NM_SETTING_WIRELESS_MODE_INFRA; + if (ap_mode == NM_802_11_MODE_ADHOC) { + mode = NM_SETTING_WIRELESS_MODE_ADHOC; + adhoc = TRUE; + } + g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, mode, NULL); + } + + /* Security */ + + /* Open */ + if ( !(ap_flags & NM_802_11_AP_FLAGS_PRIVACY) + && (ap_wpa_flags == NM_802_11_AP_SEC_NONE) + && (ap_rsn_flags == NM_802_11_AP_SEC_NONE)) { + /* Make sure the connection doesn't specify security */ + if (s_wsec || s_8021x) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("Access point is unencrypted but setting specifies security")); + if (s_wsec) + g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + else + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); + return FALSE; + } + return TRUE; + } + + /* Everything else requires security */ + if (!s_wsec) { + s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wsec)); + } + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + leap_username = nm_setting_wireless_security_get_leap_username (s_wsec); + + /* Ad-Hoc checks */ + if (!verify_adhoc (s_wsec, s_8021x, adhoc, error)) + return FALSE; + + /* Static WEP, Dynamic WEP, or LEAP */ + if ( (ap_flags & NM_802_11_AP_FLAGS_PRIVACY) + && (ap_wpa_flags == NM_802_11_AP_SEC_NONE) + && (ap_rsn_flags == NM_802_11_AP_SEC_NONE)) { + const char *tag = "WEP"; + gboolean is_dynamic_wep = FALSE; + + if (!verify_leap (s_wsec, s_8021x, adhoc, error)) + return FALSE; + + if (leap_username) { + tag = "LEAP"; + } else { + /* Static or Dynamic WEP */ + if (!verify_dynamic_wep (s_wsec, s_8021x, adhoc, error)) + return FALSE; + + if (s_8021x || (key_mgmt && !strcmp (key_mgmt, "ieee8021x"))) { + is_dynamic_wep = TRUE; + tag = "Dynamic WEP"; + } + } + + /* Nothing WPA-related can be set */ + if (!verify_no_wpa (s_wsec, tag, error)) + return FALSE; + + if (leap_username) { + /* LEAP */ + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", + NULL); + } else if (is_dynamic_wep) { + /* Dynamic WEP */ + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", + NULL); + + if (s_8021x) { + /* Dynamic WEP requires a valid 802.1x setting since we can't + * autocomplete 802.1x. + */ + if (!nm_setting_verify (NM_SETTING (s_8021x), NULL, error)) + return FALSE; + } + } else { + /* Static WEP */ + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", + NULL); + } + + return TRUE; + } + + /* WPA/RSN */ + g_assert (ap_wpa_flags || ap_rsn_flags); + + /* Ensure key management is valid for WPA */ + if ((key_mgmt && !strcmp (key_mgmt, "ieee8021x")) || leap_username) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA authentication is incompatible with non-EAP (original) LEAP or Dynamic WEP")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + return FALSE; + } + + /* 'shared' auth incompatible with any type of WPA */ + if (auth_alg && strcmp (auth_alg, "open")) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA authentication is incompatible with Shared Key authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); + return FALSE; + } + + if (!verify_no_wep (s_wsec, "WPA", error)) + return FALSE; + + if (!verify_wpa_psk (s_wsec, s_8021x, adhoc, ap_wpa_flags, ap_rsn_flags, error)) + return FALSE; + + if (!adhoc && !verify_wpa_eap (s_wsec, s_8021x, ap_wpa_flags, ap_rsn_flags, error)) + return FALSE; + + if (adhoc) { + g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL); + /* Ad-Hoc does not support RSN/WPA2 */ + nm_setting_wireless_security_add_proto (s_wsec, "wpa"); + nm_setting_wireless_security_add_pairwise (s_wsec, "none"); + nm_setting_wireless_security_add_group (s_wsec, "tkip"); + } else if (s_8021x) { + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", + NULL); + /* Leave proto/pairwise/group as client set them; if they are unset the + * supplicant will figure out the best combination at connect time. + */ + + /* 802.1x also requires the client to completely fill in the 8021x + * setting. Since there's so much configuration required for it, there's + * no way it can be automatically completed. + */ + } else if ( (key_mgmt && !strcmp (key_mgmt, "wpa-psk")) + || (ap_wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) + || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) { + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", + NULL); + /* Leave proto/pairwise/group as client set them; if they are unset the + * supplicant will figure out the best combination at connect time. + */ + } else { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + _("Failed to determine AP security information")); + return FALSE; + } + + return TRUE; +} + +guint32 +nm_wifi_utils_level_to_quality (gint val) +{ + if (val < 0) { + /* Assume dBm already; rough conversion: best = -40, worst = -100 */ + val = abs (CLAMP (val, -100, -40) + 40); /* normalize to 0 */ + val = 100 - (int) ((100.0 * (double) val) / 60.0); + } else if (val > 110 && val < 256) { + /* assume old-style WEXT 8-bit unsigned signal level */ + val -= 256; /* subtract 256 to convert to dBm */ + val = abs (CLAMP (val, -100, -40) + 40); /* normalize to 0 */ + val = 100 - (int) ((100.0 * (double) val) / 60.0); + } else { + /* Assume signal is a "quality" percentage */ + val = CLAMP (val, 0, 100); + } + g_assert (val >= 0); + + return (guint32) val; +} + diff --git a/src/devices/wifi/nm-wifi-utils.h b/src/devices/wifi/nm-wifi-utils.h new file mode 100644 index 00000000..39c7fa17 --- /dev/null +++ b/src/devices/wifi/nm-wifi-utils.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 Red Hat, Inc. + */ + +#ifndef __NM_WIFI_UTILS_H__ +#define __NM_WIFI_UTILS_H__ + +#include +#include +#include +#include +#include + +gboolean nm_wifi_utils_complete_connection (const GByteArray *ssid, + const char *bssid, + NM80211Mode mode, + guint32 flags, + guint32 wpa_flags, + guint32 rsn_flags, + NMConnection *connection, + gboolean lock_bssid, + GError **error); + +guint32 nm_wifi_utils_level_to_quality (gint val); + +#endif /* __NM_WIFI_UTILS_H__ */ diff --git a/src/devices/wifi/tests/Makefile.am b/src/devices/wifi/tests/Makefile.am deleted file mode 100644 index d05ccf7e..00000000 --- a/src/devices/wifi/tests/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_builddir)/introspection \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I${top_srcdir}/src/platform \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/devices/wifi \ - -I$(top_builddir)/src \ - -DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -noinst_PROGRAMS = test-wifi-ap-utils - -test_wifi_ap_utils_SOURCES = \ - test-wifi-ap-utils.c \ - $(srcdir)/../nm-wifi-ap.c \ - $(srcdir)/../nm-wifi-ap.h \ - $(srcdir)/../nm-wifi-ap-utils.c \ - $(srcdir)/../nm-wifi-ap-utils.h - -test_wifi_ap_utils_LDADD = $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-wifi-ap-utils - diff --git a/src/devices/wifi/tests/Makefile.in b/src/devices/wifi/tests/Makefile.in deleted file mode 100644 index 676ae990..00000000 --- a/src/devices/wifi/tests/Makefile.in +++ /dev/null @@ -1,1175 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-wifi-ap-utils$(EXEEXT) -TESTS = test-wifi-ap-utils$(EXEEXT) -subdir = src/devices/wifi/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_wifi_ap_utils_OBJECTS = test-wifi-ap-utils.$(OBJEXT) \ - nm-wifi-ap.$(OBJEXT) nm-wifi-ap-utils.$(OBJEXT) -test_wifi_ap_utils_OBJECTS = $(am_test_wifi_ap_utils_OBJECTS) -test_wifi_ap_utils_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_wifi_ap_utils_SOURCES) -DIST_SOURCES = $(test_wifi_ap_utils_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I$(top_builddir)/introspection \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I${top_srcdir}/src/platform \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/devices/wifi \ - -I$(top_builddir)/src \ - -DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -test_wifi_ap_utils_SOURCES = \ - test-wifi-ap-utils.c \ - $(srcdir)/../nm-wifi-ap.c \ - $(srcdir)/../nm-wifi-ap.h \ - $(srcdir)/../nm-wifi-ap-utils.c \ - $(srcdir)/../nm-wifi-ap-utils.h - -test_wifi_ap_utils_LDADD = $(top_builddir)/src/libNetworkManager.la -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/wifi/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/wifi/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-wifi-ap-utils$(EXEEXT): $(test_wifi_ap_utils_OBJECTS) $(test_wifi_ap_utils_DEPENDENCIES) $(EXTRA_test_wifi_ap_utils_DEPENDENCIES) - @rm -f test-wifi-ap-utils$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_wifi_ap_utils_OBJECTS) $(test_wifi_ap_utils_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-wifi-ap-utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-wifi-ap.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wifi-ap-utils.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -nm-wifi-ap.o: $(srcdir)/../nm-wifi-ap.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-wifi-ap.o -MD -MP -MF $(DEPDIR)/nm-wifi-ap.Tpo -c -o nm-wifi-ap.o `test -f '$(srcdir)/../nm-wifi-ap.c' || echo '$(srcdir)/'`$(srcdir)/../nm-wifi-ap.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-wifi-ap.Tpo $(DEPDIR)/nm-wifi-ap.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../nm-wifi-ap.c' object='nm-wifi-ap.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-wifi-ap.o `test -f '$(srcdir)/../nm-wifi-ap.c' || echo '$(srcdir)/'`$(srcdir)/../nm-wifi-ap.c - -nm-wifi-ap.obj: $(srcdir)/../nm-wifi-ap.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-wifi-ap.obj -MD -MP -MF $(DEPDIR)/nm-wifi-ap.Tpo -c -o nm-wifi-ap.obj `if test -f '$(srcdir)/../nm-wifi-ap.c'; then $(CYGPATH_W) '$(srcdir)/../nm-wifi-ap.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../nm-wifi-ap.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-wifi-ap.Tpo $(DEPDIR)/nm-wifi-ap.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../nm-wifi-ap.c' object='nm-wifi-ap.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-wifi-ap.obj `if test -f '$(srcdir)/../nm-wifi-ap.c'; then $(CYGPATH_W) '$(srcdir)/../nm-wifi-ap.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../nm-wifi-ap.c'; fi` - -nm-wifi-ap-utils.o: $(srcdir)/../nm-wifi-ap-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-wifi-ap-utils.o -MD -MP -MF $(DEPDIR)/nm-wifi-ap-utils.Tpo -c -o nm-wifi-ap-utils.o `test -f '$(srcdir)/../nm-wifi-ap-utils.c' || echo '$(srcdir)/'`$(srcdir)/../nm-wifi-ap-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-wifi-ap-utils.Tpo $(DEPDIR)/nm-wifi-ap-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../nm-wifi-ap-utils.c' object='nm-wifi-ap-utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-wifi-ap-utils.o `test -f '$(srcdir)/../nm-wifi-ap-utils.c' || echo '$(srcdir)/'`$(srcdir)/../nm-wifi-ap-utils.c - -nm-wifi-ap-utils.obj: $(srcdir)/../nm-wifi-ap-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-wifi-ap-utils.obj -MD -MP -MF $(DEPDIR)/nm-wifi-ap-utils.Tpo -c -o nm-wifi-ap-utils.obj `if test -f '$(srcdir)/../nm-wifi-ap-utils.c'; then $(CYGPATH_W) '$(srcdir)/../nm-wifi-ap-utils.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../nm-wifi-ap-utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-wifi-ap-utils.Tpo $(DEPDIR)/nm-wifi-ap-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../nm-wifi-ap-utils.c' object='nm-wifi-ap-utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-wifi-ap-utils.obj `if test -f '$(srcdir)/../nm-wifi-ap-utils.c'; then $(CYGPATH_W) '$(srcdir)/../nm-wifi-ap-utils.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../nm-wifi-ap-utils.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-wifi-ap-utils.log: test-wifi-ap-utils$(EXEEXT) - @p='test-wifi-ap-utils$(EXEEXT)'; \ - b='test-wifi-ap-utils'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/wifi/tests/test-general.c b/src/devices/wifi/tests/test-general.c new file mode 100644 index 00000000..3e61c5f0 --- /dev/null +++ b/src/devices/wifi/tests/test-general.c @@ -0,0 +1,1502 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include + +#include "devices/wifi/nm-wifi-utils.h" + +#include "nm-core-internal.h" + +#include "nm-test-utils-core.h" + +#define DEBUG 1 + +/*****************************************************************************/ + +#define COMPARE(src, expected, success, error, edomain, ecode) \ +{ \ + if (expected) { \ + if (!success) { \ + g_assert (error != NULL); \ + g_warning ("Failed to complete connection: %s", error->message); \ + } \ + g_assert (success == TRUE); \ + g_assert (error == NULL); \ +\ + success = nm_connection_compare (src, expected, NM_SETTING_COMPARE_FLAG_EXACT); \ + if (success == FALSE && DEBUG) { \ + g_message ("\n- COMPLETED ---------------------------------\n"); \ + nm_connection_dump (src); \ + g_message ("+ EXPECTED ++++++++++++++++++++++++++++++++++++\n"); \ + nm_connection_dump (expected); \ + g_message ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); \ + } \ + g_assert (success == TRUE); \ + } else { \ + if (success) { \ + g_message ("\n- COMPLETED ---------------------------------\n"); \ + nm_connection_dump (src); \ + } \ + g_assert (success == FALSE); \ + g_assert_error (error, edomain, ecode); \ + } \ + \ + g_clear_error (&error); \ +} + +static gboolean +complete_connection (const char *ssid, + const char *bssid, + NM80211Mode mode, + guint32 flags, + guint32 wpa_flags, + guint32 rsn_flags, + gboolean lock_bssid, + NMConnection *src, + GError **error) +{ + GByteArray *tmp; + gboolean success; + NMSettingWireless *s_wifi; + + /* Add a wifi setting if one doesn't exist */ + s_wifi = nm_connection_get_setting_wireless (src); + if (!s_wifi) { + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (src, NM_SETTING (s_wifi)); + } + + tmp = g_byte_array_sized_new (strlen (ssid)); + g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid)); + + success = nm_wifi_utils_complete_connection (tmp, + bssid, + mode, + flags, + wpa_flags, + rsn_flags, + src, + lock_bssid, + error); + g_byte_array_free (tmp, TRUE); + return success; +} + +typedef struct { + const char *key; + const char *str; + guint32 uint; +} KeyData; + +static void +set_items (NMSetting *setting, const KeyData *items) +{ + const KeyData *item; + GParamSpec *pspec; + GBytes *tmp; + + for (item = items; item && item->key; item++) { + g_assert (item->key); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), item->key); + g_assert (pspec); + + if (pspec->value_type == G_TYPE_STRING) { + g_assert (item->uint == 0); + if (item->str) + g_object_set (G_OBJECT (setting), item->key, item->str, NULL); + } else if (pspec->value_type == G_TYPE_UINT) { + g_assert (item->str == NULL); + g_object_set (G_OBJECT (setting), item->key, item->uint, NULL); + } else if (pspec->value_type == G_TYPE_INT) { + gint foo = (gint) item->uint; + + g_assert (item->str == NULL); + g_object_set (G_OBJECT (setting), item->key, foo, NULL); + } else if (pspec->value_type == G_TYPE_BOOLEAN) { + gboolean foo = !! (item->uint); + + g_assert (item->str == NULL); + g_object_set (G_OBJECT (setting), item->key, foo, NULL); + } else if (pspec->value_type == G_TYPE_BYTES) { + g_assert (item->str); + tmp = g_bytes_new (item->str, strlen (item->str)); + g_object_set (G_OBJECT (setting), item->key, tmp, NULL); + g_bytes_unref (tmp); + } else { + /* Special types, check based on property name */ + if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PROTO)) + nm_setting_wireless_security_add_proto (NM_SETTING_WIRELESS_SECURITY (setting), item->str); + else if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PAIRWISE)) + nm_setting_wireless_security_add_pairwise (NM_SETTING_WIRELESS_SECURITY (setting), item->str); + else if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_GROUP)) + nm_setting_wireless_security_add_group (NM_SETTING_WIRELESS_SECURITY (setting), item->str); + else if (!strcmp (item->key, NM_SETTING_802_1X_EAP)) + nm_setting_802_1x_add_eap_method (NM_SETTING_802_1X (setting), item->str); + } + } +} + +static NMSettingWireless * +fill_wifi_empty (NMConnection *connection) +{ + NMSettingWireless *s_wifi; + + s_wifi = nm_connection_get_setting_wireless (connection); + if (!s_wifi) { + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + } + return s_wifi; +} + +static NMSettingWireless * +fill_wifi (NMConnection *connection, const KeyData items[]) +{ + NMSettingWireless *s_wifi; + + s_wifi = nm_connection_get_setting_wireless (connection); + if (!s_wifi) { + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + } + + set_items (NM_SETTING (s_wifi), items); + return s_wifi; +} + +static NMSettingWirelessSecurity * +fill_wsec (NMConnection *connection, const KeyData items[]) +{ + NMSettingWirelessSecurity *s_wsec; + + s_wsec = nm_connection_get_setting_wireless_security (connection); + if (!s_wsec) { + s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wsec)); + } + + set_items (NM_SETTING (s_wsec), items); + return s_wsec; +} + +static NMSetting8021x * +fill_8021x (NMConnection *connection, const KeyData items[]) +{ + NMSetting8021x *s_8021x; + + s_8021x = nm_connection_get_setting_802_1x (connection); + if (!s_8021x) { + s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + } + + set_items (NM_SETTING (s_8021x), items); + return s_8021x; +} + +static NMConnection * +create_basic (const char *ssid, + const char *bssid, + NM80211Mode mode) +{ + NMConnection *connection; + NMSettingWireless *s_wifi = NULL; + GBytes *tmp; + + connection = nm_simple_connection_new (); + + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + /* SSID */ + tmp = g_bytes_new (ssid, strlen (ssid)); + g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, tmp, NULL); + g_bytes_unref (tmp); + + /* BSSID */ + if (bssid) + g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL); + + if (mode == NM_802_11_MODE_INFRA) + g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); + else if (mode == NM_802_11_MODE_ADHOC) + g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, "adhoc", NULL); + else + g_assert_not_reached (); + + return connection; +} + +/*****************************************************************************/ + +static void +test_lock_bssid (void) +{ + NMConnection *src, *expected; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; + gboolean success; + GError *error = NULL; + + src = nm_simple_connection_new (); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + TRUE, + src, &error); + expected = create_basic (ssid, bssid, NM_802_11_MODE_INFRA); + COMPARE (src, expected, success, error, 0, 0); + + g_object_unref (src); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_open_ap_empty_connection (void) +{ + NMConnection *src, *expected; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; + gboolean success; + GError *error = NULL; + + /* Test that an empty source connection is correctly filled with the + * SSID and Infra modes of the given AP details. + */ + + src = nm_simple_connection_new (); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); + COMPARE (src, expected, success, error, 0, 0); + + g_object_unref (src); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_open_ap_leap_connection_1 (gconstpointer add_wifi) +{ + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "Bill Smith", 0 }, { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that a basic connection filled with a LEAP username is + * rejected when completion is attempted with an open AP. LEAP requires + * the AP to have the Privacy bit set. + */ + + src = nm_simple_connection_new (); + if (add_wifi) + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + + success = complete_connection ("blahblah", bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + /* We expect failure */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_open_ap_leap_connection_2 (void) +{ + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that a basic connection specifying IEEE8021x security (ie, Dynamic + * WEP or LEAP) is rejected when completion is attempted with an open AP. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + + success = complete_connection ("blahblah", bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + /* We expect failure */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_open_ap_wep_connection (gconstpointer add_wifi) +{ + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "11111111111111111111111111", 0 }, + { NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, NULL, 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that a static WEP connection is rejected when completion is + * attempted with an open AP. + */ + + src = nm_simple_connection_new (); + if (add_wifi) + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + success = complete_connection ("blahblah", bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + /* We expect failure */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_ap_wpa_psk_connection_base (const char *key_mgmt, + const char *auth_alg, + guint32 flags, + guint32 wpa_flags, + guint32 rsn_flags, + gboolean add_wifi, + guint error_code, + NMConnection *expected) +{ + NMConnection *src; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const KeyData exp_wifi[] = { + { NM_SETTING_WIRELESS_SSID, ssid, 0 }, + { NM_SETTING_WIRELESS_MODE, "infrastructure", 0 }, + { NULL } }; + const KeyData both_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0 }, + { NM_SETTING_WIRELESS_SECURITY_PSK, "asdfasdfasdfasdfasdfafs", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + src = nm_simple_connection_new (); + if (add_wifi) + fill_wifi_empty (src); + fill_wsec (src, both_wsec); + success = complete_connection (ssid, bssid, NM_802_11_MODE_INFRA, + flags, wpa_flags, rsn_flags, + FALSE, src, &error); + if (expected) { + fill_wifi (expected, exp_wifi); + fill_wsec (expected, both_wsec); + } + COMPARE (src, expected, success, error, NM_CONNECTION_ERROR, error_code); + + g_object_unref (src); +} + +static void +test_open_ap_wpa_psk_connection_1 (void) +{ + /* Test that a WPA-PSK connection filling only the PSK itself and *not* + * filling the wifi setting is rejected when completion is attempted with + * an open AP. + */ + test_ap_wpa_psk_connection_base (NULL, NULL, + NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); +} + +static void +test_open_ap_wpa_psk_connection_2 (void) +{ + /* Test that a WPA-PSK connection filling only the PSK itself and also + * filling the wifi setting is rejected when completion is attempted with + * an open AP. + */ + test_ap_wpa_psk_connection_base (NULL, NULL, + NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + TRUE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); +} + +static void +test_open_ap_wpa_psk_connection_3 (void) +{ + /* Test that a WPA-PSK connection filling the PSK and setting the auth alg + * to 'open' is rejected when completion is attempted with an open AP. + */ + test_ap_wpa_psk_connection_base (NULL, "open", + NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); +} + +static void +test_open_ap_wpa_psk_connection_4 (void) +{ + /* Test that a WPA-PSK connection filling the PSK and setting the auth alg + * to 'shared' is rejected when completion is attempted with an open AP. + * Shared auth cannot be used with WPA. + */ + test_ap_wpa_psk_connection_base (NULL, "shared", + NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); +} + +static void +test_open_ap_wpa_psk_connection_5 (void) +{ + /* Test that a WPA-PSK connection filling the PSK, the auth algorithm, and + * key management is rejected when completion is attempted with an open AP. + */ + test_ap_wpa_psk_connection_base ("wpa-psk", "open", + NM_802_11_AP_FLAGS_NONE, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); +} + +/*****************************************************************************/ + +static void +test_ap_wpa_eap_connection_base (const char *key_mgmt, + const char *auth_alg, + guint32 flags, + guint32 wpa_flags, + guint32 rsn_flags, + gboolean add_wifi, + guint error_code) +{ + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_empty[] = { { NULL } }; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + src = nm_simple_connection_new (); + if (add_wifi) + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + fill_8021x (src, src_empty); + success = complete_connection ("blahblah", bssid, NM_802_11_MODE_INFRA, + flags, wpa_flags, rsn_flags, + FALSE, src, &error); + /* Failure expected */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, error_code); + + g_object_unref (src); +} + +enum { + IDX_NONE = 0, + IDX_OPEN, + IDX_PRIV, + IDX_WPA_PSK_PTKIP_GTKIP, + IDX_WPA_PSK_PTKIP_PCCMP_GTKIP, + IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP, + IDX_WPA_RSN_PSK_PCCMP_GCCMP, + IDX_RSN_PSK_PCCMP_GCCMP, + IDX_RSN_PSK_PTKIP_PCCMP_GTKIP, + IDX_WPA_8021X, + IDX_RSN_8021X, +}; + +static guint32 +flags_for_idx (guint32 idx) +{ + if (idx == IDX_OPEN) + return NM_802_11_AP_FLAGS_NONE; + else if ( idx == IDX_PRIV + || idx == IDX_WPA_PSK_PTKIP_GTKIP + || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP + || idx == IDX_RSN_PSK_PCCMP_GCCMP + || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP + || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP + || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP + || idx == IDX_WPA_8021X + || idx == IDX_RSN_8021X) + return NM_802_11_AP_FLAGS_PRIVACY; + else + g_assert_not_reached (); +} + +static guint32 +wpa_flags_for_idx (guint32 idx) +{ + if (idx == IDX_OPEN || idx == IDX_PRIV || idx == IDX_RSN_8021X + || idx == IDX_RSN_PSK_PCCMP_GCCMP || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP) + return NM_802_11_AP_SEC_NONE; + else if (idx == IDX_WPA_PSK_PTKIP_GTKIP) + return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP) + return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (NM_IN_SET (idx, IDX_WPA_PSK_PTKIP_PCCMP_GTKIP, IDX_WPA_RSN_PSK_PCCMP_GCCMP)) + return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (idx == IDX_WPA_8021X) + return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_802_1X; + else + g_assert_not_reached (); +} + +static guint32 +rsn_flags_for_idx (guint32 idx) +{ + if (idx == IDX_OPEN || idx == IDX_PRIV || idx == IDX_WPA_8021X + || idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP) + return NM_802_11_AP_SEC_NONE; + else if (idx == IDX_RSN_PSK_PCCMP_GCCMP) + return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP) + return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP) + return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP) + return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (idx == IDX_RSN_8021X) + return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_802_1X; + else + g_assert_not_reached (); +} + +static guint32 +error_code_for_idx (guint32 idx, guint num) +{ + if (idx == IDX_OPEN) + return NM_CONNECTION_ERROR_INVALID_SETTING; + else if (idx == IDX_PRIV) { + if (num <= 3) + return NM_CONNECTION_ERROR_MISSING_PROPERTY; + else + return NM_CONNECTION_ERROR_INVALID_PROPERTY; + } else if ( idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP + || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP + || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_RSN_PSK_PCCMP_GCCMP) + if (num == 4) + return NM_CONNECTION_ERROR_INVALID_PROPERTY; + else + return NM_CONNECTION_ERROR_INVALID_SETTING; + else + g_assert_not_reached (); +} + +static void +test_ap_wpa_eap_connection_1 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + + test_ap_wpa_eap_connection_base (NULL, NULL, + flags_for_idx (idx), + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + error_code_for_idx (idx, 1)); +} + +static void +test_ap_wpa_eap_connection_2 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + + test_ap_wpa_eap_connection_base (NULL, NULL, + flags_for_idx (idx), + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + TRUE, + error_code_for_idx (idx, 2)); +} + +static void +test_ap_wpa_eap_connection_3 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + + test_ap_wpa_eap_connection_base (NULL, "open", + flags_for_idx (idx), + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + error_code_for_idx (idx, 3)); +} + +static void +test_ap_wpa_eap_connection_4 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + + test_ap_wpa_eap_connection_base (NULL, "shared", + flags_for_idx (idx), + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + error_code_for_idx (idx, 4)); +} + +static void +test_ap_wpa_eap_connection_5 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + + test_ap_wpa_eap_connection_base ("wpa-eap", "open", + flags_for_idx (idx), + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + error_code_for_idx (idx, 5)); +} + +/*****************************************************************************/ + +static void +test_priv_ap_empty_connection (void) +{ + NMConnection *src, *expected; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that an empty connection is completed to a valid Static WEP + * connection when completed with an AP with the Privacy bit set. + */ + + src = nm_simple_connection_new (); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + + /* Static WEP connection expected */ + expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); + fill_wsec (expected, exp_wsec); + COMPARE (src, expected, success, error, 0, 0); + + g_object_unref (src); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_priv_ap_leap_connection_1 (gconstpointer add_wifi) +{ + NMConnection *src, *expected; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *leap_username = "Bill Smith"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0 }, + { NULL } }; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 }, + { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that an minimal LEAP connection specifying only key management and + * the LEAP username is completed to a full LEAP connection when completed + * with an AP with the Privacy bit set. + */ + + src = nm_simple_connection_new (); + if (add_wifi) + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + /* We expect success here; since LEAP APs just set the 'privacy' flag + * there's no way to determine from the AP's beacon whether it's static WEP, + * dynamic WEP, or LEAP. + */ + expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); + fill_wsec (expected, exp_wsec); + COMPARE (src, expected, success, error, 0, 0); + + g_object_unref (src); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_priv_ap_leap_connection_2 (void) +{ + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that an minimal LEAP connection specifying only key management and + * the LEAP auth alg is completed to a full LEAP connection when completed + * with an AP with the Privacy bit set. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + success = complete_connection ("blahblah", bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + /* We expect failure here, we need a LEAP username */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_priv_ap_dynamic_wep_1 (void) +{ + NMConnection *src, *expected; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + const KeyData both_8021x[] = { + { NM_SETTING_802_1X_EAP, "peap", 0 }, + { NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0 }, + { NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0 }, + { NULL } }; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that an minimal Dynamic WEP connection specifying key management, + * the auth algorithm, and valid 802.1x setting is completed to a valid + * Dynamic WEP connection when completed with an AP with the Privacy bit set. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + fill_8021x (src, both_8021x); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + + /* We expect a completed Dynamic WEP connection */ + expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); + fill_wsec (expected, exp_wsec); + fill_8021x (expected, both_8021x); + COMPARE (src, expected, success, error, 0, 0); + + g_object_unref (src); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_priv_ap_dynamic_wep_2 (void) +{ + NMConnection *src, *expected; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + const KeyData both_8021x[] = { + { NM_SETTING_802_1X_EAP, "peap", 0 }, + { NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0 }, + { NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0 }, + { NULL } }; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that an minimal Dynamic WEP connection specifying only the auth + * algorithm and a valid 802.1x setting is completed to a valid Dynamic + * WEP connection when completed with an AP with the Privacy bit set. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + fill_8021x (src, both_8021x); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + + /* We expect a completed Dynamic WEP connection */ + expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); + fill_wsec (expected, exp_wsec); + fill_8021x (expected, both_8021x); + COMPARE (src, expected, success, error, 0, 0); + + g_object_unref (src); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_priv_ap_dynamic_wep_3 (void) +{ + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", 0 }, + { NULL } }; + const KeyData src_8021x[] = { + { NM_SETTING_802_1X_EAP, "peap", 0 }, + { NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0 }, + { NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Ensure that a basic connection specifying 'shared' auth and an 802.1x + * setting is rejected, as 802.1x is incompatible with 'shared' auth. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + fill_8021x (src, src_8021x); + success = complete_connection ("blahblah", bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, + FALSE, + src, &error); + /* Expect failure; shared is not compatible with dynamic WEP */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_priv_ap_wpa_psk_connection_1 (void) +{ + /* Test that a basic WPA-PSK connection is rejected when completion is + * attempted with an AP with just the Privacy bit set. Lack of WPA/RSN + * flags means the AP provides Static/Dynamic WEP or LEAP, not WPA. + */ + test_ap_wpa_psk_connection_base (NULL, NULL, + NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); +} + +static void +test_priv_ap_wpa_psk_connection_2 (void) +{ + /* Test that a basic WPA-PSK connection is rejected when completion is + * attempted with an AP with just the Privacy bit set. Lack of WPA/RSN + * flags means the AP provides Static/Dynamic WEP or LEAP, not WPA. + */ + test_ap_wpa_psk_connection_base (NULL, NULL, + NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + TRUE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); +} + +static void +test_priv_ap_wpa_psk_connection_3 (void) +{ + /* Test that a basic WPA-PSK connection specifying only the auth algorithm + * is rejected when completion is attempted with an AP with just the Privacy + * bit set. Lack of WPA/RSN flags means the AP provides Static/Dynamic WEP + * or LEAP, not WPA. + */ + test_ap_wpa_psk_connection_base (NULL, "open", + NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); +} + +static void +test_priv_ap_wpa_psk_connection_4 (void) +{ + /* Test that a basic WPA-PSK connection specifying only the auth algorithm + * is rejected when completion is attempted with an AP with just the Privacy + * bit set. Lack of WPA/RSN flags means the AP provides Static/Dynamic WEP + * or LEAP, not WPA. Second, 'shared' auth is incompatible with WPA. + */ + test_ap_wpa_psk_connection_base (NULL, "shared", + NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); +} + +static void +test_priv_ap_wpa_psk_connection_5 (void) +{ + /* Test that a WPA-PSK connection specifying both the key management and + * auth algorithm is rejected when completion is attempted with an AP with + * just the Privacy bit set. Lack of WPA/RSN flags means the AP provides + * Static/Dynamic WEP or LEAP, not WPA. + */ + test_ap_wpa_psk_connection_base ("wpa-psk", "open", + NM_802_11_AP_FLAGS_PRIVACY, + NM_802_11_AP_SEC_NONE, + NM_802_11_AP_SEC_NONE, + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); +} + +/*****************************************************************************/ + +static void +test_wpa_ap_empty_connection (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *src, *expected; + const char *bssid = "01:02:03:04:05:06"; + const char *ssid = "blahblah"; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that a basic WPA-PSK connection specifying just key management and + * the auth algorithm is completed successfully when given an AP with WPA + * or RSN flags. + */ + + src = nm_simple_connection_new (); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, src, &error); + + /* WPA connection expected */ + expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); + fill_wsec (expected, exp_wsec); + COMPARE (src, expected, success, error, 0, 0); + + g_object_unref (src); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_wpa_ap_leap_connection_1 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *src; + const char *ssid = "blahblah"; + const char *bssid = "01:02:03:04:05:06"; + const char *leap_username = "Bill Smith"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that completion of a LEAP connection with a WPA-enabled AP is + * rejected since WPA APs (usually) do not support LEAP. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + success = complete_connection (ssid, bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + src, &error); + /* Expect failure here; WPA APs don't support old-school LEAP */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_wpa_ap_leap_connection_2 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that completion of a LEAP connection with a WPA-enabled AP is + * rejected since WPA APs (usually) do not support LEAP. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + success = complete_connection ("blahblah", bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + src, &error); + /* We expect failure here, we need a LEAP username */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_wpa_ap_dynamic_wep_connection (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *src; + const char *bssid = "01:02:03:04:05:06"; + const KeyData src_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, + { NULL } }; + gboolean success; + GError *error = NULL; + + /* Test that completion of a Dynamic WEP connection with a WPA-enabled AP is + * rejected since WPA APs (usually) do not support Dynamic WEP. + */ + + src = nm_simple_connection_new (); + fill_wifi_empty (src); + fill_wsec (src, src_wsec); + success = complete_connection ("blahblah", bssid, + NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + src, &error); + /* We expect failure here since Dynamic WEP is incompatible with WPA */ + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); + + g_object_unref (src); +} + +/*****************************************************************************/ + +static void +test_wpa_ap_wpa_psk_connection_1 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *expected; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + + expected = nm_simple_connection_new (); + fill_wsec (expected, exp_wsec); + test_ap_wpa_psk_connection_base (NULL, NULL, + NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); + g_object_unref (expected); +} + +static void +test_wpa_ap_wpa_psk_connection_2 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *expected; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + + expected = nm_simple_connection_new (); + fill_wsec (expected, exp_wsec); + test_ap_wpa_psk_connection_base (NULL, NULL, + NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + TRUE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); + g_object_unref (expected); +} + +static void +test_wpa_ap_wpa_psk_connection_3 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *expected; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + + expected = nm_simple_connection_new (); + fill_wsec (expected, exp_wsec); + test_ap_wpa_psk_connection_base (NULL, "open", + NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); + g_object_unref (expected); +} + +static void +test_wpa_ap_wpa_psk_connection_4 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + test_ap_wpa_psk_connection_base (NULL, "shared", + NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); +} + +static void +test_wpa_ap_wpa_psk_connection_5 (gconstpointer data) +{ + guint idx = GPOINTER_TO_UINT (data); + NMConnection *expected; + const KeyData exp_wsec[] = { + { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, + { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, + { NULL } }; + + expected = nm_simple_connection_new (); + fill_wsec (expected, exp_wsec); + test_ap_wpa_psk_connection_base ("wpa-psk", "open", + NM_802_11_AP_FLAGS_PRIVACY, + wpa_flags_for_idx (idx), + rsn_flags_for_idx (idx), + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); + g_object_unref (expected); +} + +/*****************************************************************************/ + +static void +test_strength_dbm (void) +{ + /* boundary conditions first */ + g_assert_cmpint (nm_wifi_utils_level_to_quality (-1), ==, 100); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-40), ==, 100); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-30), ==, 100); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-100), ==, 0); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-200), ==, 0); + + g_assert_cmpint (nm_wifi_utils_level_to_quality (-81), ==, 32); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-92), ==, 14); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-74), ==, 44); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-81), ==, 32); + g_assert_cmpint (nm_wifi_utils_level_to_quality (-66), ==, 57); +} + +static void +test_strength_percent (void) +{ + int i; + + /* boundary conditions first */ + g_assert_cmpint (nm_wifi_utils_level_to_quality (0), ==, 0); + g_assert_cmpint (nm_wifi_utils_level_to_quality (100), ==, 100); + g_assert_cmpint (nm_wifi_utils_level_to_quality (110), ==, 100); + + for (i = 0; i <= 100; i++) + g_assert_cmpint (nm_wifi_utils_level_to_quality (i), ==, i); +} + +static void +test_strength_wext (void) +{ + /* boundary conditions that we assume aren't WEXT first */ + g_assert_cmpint (nm_wifi_utils_level_to_quality (256), ==, 100); + g_assert_cmpint (nm_wifi_utils_level_to_quality (110), ==, 100); + + /* boundary conditions that we assume are WEXT */ + g_assert_cmpint (nm_wifi_utils_level_to_quality (111), ==, 0); + g_assert_cmpint (nm_wifi_utils_level_to_quality (150), ==, 0); + g_assert_cmpint (nm_wifi_utils_level_to_quality (225), ==, 100); + g_assert_cmpint (nm_wifi_utils_level_to_quality (255), ==, 100); + + g_assert_cmpint (nm_wifi_utils_level_to_quality (157), ==, 2); + g_assert_cmpint (nm_wifi_utils_level_to_quality (200), ==, 74); + g_assert_cmpint (nm_wifi_utils_level_to_quality (215), ==, 99); +} + +/*****************************************************************************/ + +NMTST_DEFINE (); + +int +main (int argc, char **argv) +{ + gsize i; + + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); + + g_test_add_func ("/wifi/lock_bssid", + test_lock_bssid); + + /* Open AP tests; make sure that connections to be completed that have + * various security-related settings already set cause the completion + * to fail. + */ + g_test_add_func ("/wifi/open_ap/empty_connection", + test_open_ap_empty_connection); + g_test_add_data_func ("/wifi/open_ap/leap_connection/1", + (gconstpointer) TRUE, + test_open_ap_leap_connection_1); + g_test_add_data_func ("/wifi/open_ap/leap_connection/1_no_add_wifi", + (gconstpointer) FALSE, + test_open_ap_leap_connection_1); + g_test_add_func ("/wifi/open_ap/leap_connection/2", + test_open_ap_leap_connection_2); + g_test_add_data_func ("/wifi/open_ap/wep_connection_true", + (gconstpointer) TRUE, + test_open_ap_wep_connection); + g_test_add_data_func ("/wifi/open_ap/wep_connection_false", + (gconstpointer) FALSE, + test_open_ap_wep_connection); + + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/1", + test_open_ap_wpa_psk_connection_1); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/2", + test_open_ap_wpa_psk_connection_2); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/3", + test_open_ap_wpa_psk_connection_3); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/4", + test_open_ap_wpa_psk_connection_4); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/5", + test_open_ap_wpa_psk_connection_5); + + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/1", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_1); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/2", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_2); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/3", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_3); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/4", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_4); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/5", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_5); + + /* WEP AP tests */ + g_test_add_func ("/wifi/priv_ap/empty_connection", + test_priv_ap_empty_connection); + g_test_add_data_func ("/wifi/priv_ap/leap_connection/1", + (gconstpointer) FALSE, + test_priv_ap_leap_connection_1); + g_test_add_func ("/wifi/priv_ap/leap_connection/2", + test_priv_ap_leap_connection_2); + + g_test_add_func ("/wifi/priv_ap/dynamic_wep/1", + test_priv_ap_dynamic_wep_1); + g_test_add_func ("/wifi/priv_ap/dynamic_wep/2", + test_priv_ap_dynamic_wep_2); + g_test_add_func ("/wifi/priv_ap/dynamic_wep/3", + test_priv_ap_dynamic_wep_3); + + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/1", + test_priv_ap_wpa_psk_connection_1); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/2", + test_priv_ap_wpa_psk_connection_2); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/3", + test_priv_ap_wpa_psk_connection_3); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/4", + test_priv_ap_wpa_psk_connection_4); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/5", + test_priv_ap_wpa_psk_connection_5); + + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/1", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_1); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/2", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_2); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/3", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_3); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/4", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_4); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/5", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_5); + +#define ADD_FUNC(func) do { \ + gchar *name_idx = g_strdup_printf ("/wifi/wpa_psk/" G_STRINGIFY (func) "/%zd", i); \ + g_test_add_data_func (name_idx, (gconstpointer) i, func); \ + g_free (name_idx); \ + } while (0) + + /* WPA-PSK tests */ + for (i = IDX_WPA_PSK_PTKIP_GTKIP; i <= IDX_WPA_RSN_PSK_PCCMP_GCCMP; i++) { + ADD_FUNC(test_wpa_ap_empty_connection); + ADD_FUNC(test_wpa_ap_leap_connection_1); + ADD_FUNC(test_wpa_ap_leap_connection_2); + ADD_FUNC(test_wpa_ap_dynamic_wep_connection); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_1); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_2); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_3); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_4); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_5); + ADD_FUNC(test_ap_wpa_eap_connection_1); + ADD_FUNC(test_ap_wpa_eap_connection_2); + ADD_FUNC(test_ap_wpa_eap_connection_3); + ADD_FUNC(test_ap_wpa_eap_connection_4); + ADD_FUNC(test_ap_wpa_eap_connection_5); + } + +#undef ADD_FUNC +#define ADD_FUNC(func) do { \ + gchar *name_idx = g_strdup_printf ("/wifi/rsn_psk/" G_STRINGIFY (func) "/%zd", i); \ + g_test_add_data_func (name_idx, (gconstpointer) i, func); \ + g_free (name_idx); \ + } while (0) + + /* RSN-PSK tests */ + for (i = IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP; i <= IDX_RSN_PSK_PTKIP_PCCMP_GTKIP; i++) { + ADD_FUNC(test_wpa_ap_empty_connection); + ADD_FUNC(test_wpa_ap_leap_connection_1); + ADD_FUNC(test_wpa_ap_leap_connection_2); + ADD_FUNC(test_wpa_ap_dynamic_wep_connection); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_1); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_2); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_3); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_4); + ADD_FUNC(test_wpa_ap_wpa_psk_connection_5); + ADD_FUNC(test_ap_wpa_eap_connection_1); + ADD_FUNC(test_ap_wpa_eap_connection_2); + ADD_FUNC(test_ap_wpa_eap_connection_3); + ADD_FUNC(test_ap_wpa_eap_connection_4); + ADD_FUNC(test_ap_wpa_eap_connection_5); + } + +#undef ADD_FUNC + + /* Scanned signal strength conversion tests */ + g_test_add_func ("/wifi/strength/dbm", + test_strength_dbm); + g_test_add_func ("/wifi/strength/percent", + test_strength_percent); + g_test_add_func ("/wifi/strength/wext", + test_strength_wext); + + return g_test_run (); +} diff --git a/src/devices/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c deleted file mode 100644 index dbe185b3..00000000 --- a/src/devices/wifi/tests/test-wifi-ap-utils.c +++ /dev/null @@ -1,1502 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2011 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include - -#include "nm-wifi-ap-utils.h" - -#include "nm-core-internal.h" - -#include "nm-test-utils-core.h" - -#define DEBUG 1 - -/*******************************************/ - -#define COMPARE(src, expected, success, error, edomain, ecode) \ -{ \ - if (expected) { \ - if (!success) { \ - g_assert (error != NULL); \ - g_warning ("Failed to complete connection: %s", error->message); \ - } \ - g_assert (success == TRUE); \ - g_assert (error == NULL); \ -\ - success = nm_connection_compare (src, expected, NM_SETTING_COMPARE_FLAG_EXACT); \ - if (success == FALSE && DEBUG) { \ - g_message ("\n- COMPLETED ---------------------------------\n"); \ - nm_connection_dump (src); \ - g_message ("+ EXPECTED ++++++++++++++++++++++++++++++++++++\n"); \ - nm_connection_dump (expected); \ - g_message ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); \ - } \ - g_assert (success == TRUE); \ - } else { \ - if (success) { \ - g_message ("\n- COMPLETED ---------------------------------\n"); \ - nm_connection_dump (src); \ - } \ - g_assert (success == FALSE); \ - g_assert_error (error, edomain, ecode); \ - } \ - \ - g_clear_error (&error); \ -} - -static gboolean -complete_connection (const char *ssid, - const char *bssid, - NM80211Mode mode, - guint32 flags, - guint32 wpa_flags, - guint32 rsn_flags, - gboolean lock_bssid, - NMConnection *src, - GError **error) -{ - GByteArray *tmp; - gboolean success; - NMSettingWireless *s_wifi; - - /* Add a wifi setting if one doesn't exist */ - s_wifi = nm_connection_get_setting_wireless (src); - if (!s_wifi) { - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (src, NM_SETTING (s_wifi)); - } - - tmp = g_byte_array_sized_new (strlen (ssid)); - g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid)); - - success = nm_ap_utils_complete_connection (tmp, - bssid, - mode, - flags, - wpa_flags, - rsn_flags, - src, - lock_bssid, - error); - g_byte_array_free (tmp, TRUE); - return success; -} - -typedef struct { - const char *key; - const char *str; - guint32 uint; -} KeyData; - -static void -set_items (NMSetting *setting, const KeyData *items) -{ - const KeyData *item; - GParamSpec *pspec; - GBytes *tmp; - - for (item = items; item && item->key; item++) { - g_assert (item->key); - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), item->key); - g_assert (pspec); - - if (pspec->value_type == G_TYPE_STRING) { - g_assert (item->uint == 0); - if (item->str) - g_object_set (G_OBJECT (setting), item->key, item->str, NULL); - } else if (pspec->value_type == G_TYPE_UINT) { - g_assert (item->str == NULL); - g_object_set (G_OBJECT (setting), item->key, item->uint, NULL); - } else if (pspec->value_type == G_TYPE_INT) { - gint foo = (gint) item->uint; - - g_assert (item->str == NULL); - g_object_set (G_OBJECT (setting), item->key, foo, NULL); - } else if (pspec->value_type == G_TYPE_BOOLEAN) { - gboolean foo = !! (item->uint); - - g_assert (item->str == NULL); - g_object_set (G_OBJECT (setting), item->key, foo, NULL); - } else if (pspec->value_type == G_TYPE_BYTES) { - g_assert (item->str); - tmp = g_bytes_new (item->str, strlen (item->str)); - g_object_set (G_OBJECT (setting), item->key, tmp, NULL); - g_bytes_unref (tmp); - } else { - /* Special types, check based on property name */ - if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PROTO)) - nm_setting_wireless_security_add_proto (NM_SETTING_WIRELESS_SECURITY (setting), item->str); - else if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PAIRWISE)) - nm_setting_wireless_security_add_pairwise (NM_SETTING_WIRELESS_SECURITY (setting), item->str); - else if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_GROUP)) - nm_setting_wireless_security_add_group (NM_SETTING_WIRELESS_SECURITY (setting), item->str); - else if (!strcmp (item->key, NM_SETTING_802_1X_EAP)) - nm_setting_802_1x_add_eap_method (NM_SETTING_802_1X (setting), item->str); - } - } -} - -static NMSettingWireless * -fill_wifi_empty (NMConnection *connection) -{ - NMSettingWireless *s_wifi; - - s_wifi = nm_connection_get_setting_wireless (connection); - if (!s_wifi) { - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - } - return s_wifi; -} - -static NMSettingWireless * -fill_wifi (NMConnection *connection, const KeyData items[]) -{ - NMSettingWireless *s_wifi; - - s_wifi = nm_connection_get_setting_wireless (connection); - if (!s_wifi) { - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - } - - set_items (NM_SETTING (s_wifi), items); - return s_wifi; -} - -static NMSettingWirelessSecurity * -fill_wsec (NMConnection *connection, const KeyData items[]) -{ - NMSettingWirelessSecurity *s_wsec; - - s_wsec = nm_connection_get_setting_wireless_security (connection); - if (!s_wsec) { - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wsec)); - } - - set_items (NM_SETTING (s_wsec), items); - return s_wsec; -} - -static NMSetting8021x * -fill_8021x (NMConnection *connection, const KeyData items[]) -{ - NMSetting8021x *s_8021x; - - s_8021x = nm_connection_get_setting_802_1x (connection); - if (!s_8021x) { - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - } - - set_items (NM_SETTING (s_8021x), items); - return s_8021x; -} - -static NMConnection * -create_basic (const char *ssid, - const char *bssid, - NM80211Mode mode) -{ - NMConnection *connection; - NMSettingWireless *s_wifi = NULL; - GBytes *tmp; - - connection = nm_simple_connection_new (); - - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - - /* SSID */ - tmp = g_bytes_new (ssid, strlen (ssid)); - g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, tmp, NULL); - g_bytes_unref (tmp); - - /* BSSID */ - if (bssid) - g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL); - - if (mode == NM_802_11_MODE_INFRA) - g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - else if (mode == NM_802_11_MODE_ADHOC) - g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, "adhoc", NULL); - else - g_assert_not_reached (); - - return connection; -} - -/*******************************************/ - -static void -test_lock_bssid (void) -{ - NMConnection *src, *expected; - const char *bssid = "01:02:03:04:05:06"; - const char *ssid = "blahblah"; - gboolean success; - GError *error = NULL; - - src = nm_simple_connection_new (); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - TRUE, - src, &error); - expected = create_basic (ssid, bssid, NM_802_11_MODE_INFRA); - COMPARE (src, expected, success, error, 0, 0); - - g_object_unref (src); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_open_ap_empty_connection (void) -{ - NMConnection *src, *expected; - const char *bssid = "01:02:03:04:05:06"; - const char *ssid = "blahblah"; - gboolean success; - GError *error = NULL; - - /* Test that an empty source connection is correctly filled with the - * SSID and Infra modes of the given AP details. - */ - - src = nm_simple_connection_new (); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); - COMPARE (src, expected, success, error, 0, 0); - - g_object_unref (src); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_open_ap_leap_connection_1 (gconstpointer add_wifi) -{ - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "Bill Smith", 0 }, { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that a basic connection filled with a LEAP username is - * rejected when completion is attempted with an open AP. LEAP requires - * the AP to have the Privacy bit set. - */ - - src = nm_simple_connection_new (); - if (add_wifi) - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - - success = complete_connection ("blahblah", bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - /* We expect failure */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_open_ap_leap_connection_2 (void) -{ - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that a basic connection specifying IEEE8021x security (ie, Dynamic - * WEP or LEAP) is rejected when completion is attempted with an open AP. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - - success = complete_connection ("blahblah", bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - /* We expect failure */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_open_ap_wep_connection (gconstpointer add_wifi) -{ - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "11111111111111111111111111", 0 }, - { NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, NULL, 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that a static WEP connection is rejected when completion is - * attempted with an open AP. - */ - - src = nm_simple_connection_new (); - if (add_wifi) - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - success = complete_connection ("blahblah", bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - /* We expect failure */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_ap_wpa_psk_connection_base (const char *key_mgmt, - const char *auth_alg, - guint32 flags, - guint32 wpa_flags, - guint32 rsn_flags, - gboolean add_wifi, - guint error_code, - NMConnection *expected) -{ - NMConnection *src; - const char *ssid = "blahblah"; - const char *bssid = "01:02:03:04:05:06"; - const KeyData exp_wifi[] = { - { NM_SETTING_WIRELESS_SSID, ssid, 0 }, - { NM_SETTING_WIRELESS_MODE, "infrastructure", 0 }, - { NULL } }; - const KeyData both_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0 }, - { NM_SETTING_WIRELESS_SECURITY_PSK, "asdfasdfasdfasdfasdfafs", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - src = nm_simple_connection_new (); - if (add_wifi) - fill_wifi_empty (src); - fill_wsec (src, both_wsec); - success = complete_connection (ssid, bssid, NM_802_11_MODE_INFRA, - flags, wpa_flags, rsn_flags, - FALSE, src, &error); - if (expected) { - fill_wifi (expected, exp_wifi); - fill_wsec (expected, both_wsec); - } - COMPARE (src, expected, success, error, NM_CONNECTION_ERROR, error_code); - - g_object_unref (src); -} - -static void -test_open_ap_wpa_psk_connection_1 (void) -{ - /* Test that a WPA-PSK connection filling only the PSK itself and *not* - * filling the wifi setting is rejected when completion is attempted with - * an open AP. - */ - test_ap_wpa_psk_connection_base (NULL, NULL, - NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_SETTING, - NULL); -} - -static void -test_open_ap_wpa_psk_connection_2 (void) -{ - /* Test that a WPA-PSK connection filling only the PSK itself and also - * filling the wifi setting is rejected when completion is attempted with - * an open AP. - */ - test_ap_wpa_psk_connection_base (NULL, NULL, - NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - TRUE, - NM_CONNECTION_ERROR_INVALID_SETTING, - NULL); -} - -static void -test_open_ap_wpa_psk_connection_3 (void) -{ - /* Test that a WPA-PSK connection filling the PSK and setting the auth alg - * to 'open' is rejected when completion is attempted with an open AP. - */ - test_ap_wpa_psk_connection_base (NULL, "open", - NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_SETTING, - NULL); -} - -static void -test_open_ap_wpa_psk_connection_4 (void) -{ - /* Test that a WPA-PSK connection filling the PSK and setting the auth alg - * to 'shared' is rejected when completion is attempted with an open AP. - * Shared auth cannot be used with WPA. - */ - test_ap_wpa_psk_connection_base (NULL, "shared", - NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_SETTING, - NULL); -} - -static void -test_open_ap_wpa_psk_connection_5 (void) -{ - /* Test that a WPA-PSK connection filling the PSK, the auth algorithm, and - * key management is rejected when completion is attempted with an open AP. - */ - test_ap_wpa_psk_connection_base ("wpa-psk", "open", - NM_802_11_AP_FLAGS_NONE, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_SETTING, - NULL); -} - -/*******************************************/ - -static void -test_ap_wpa_eap_connection_base (const char *key_mgmt, - const char *auth_alg, - guint32 flags, - guint32 wpa_flags, - guint32 rsn_flags, - gboolean add_wifi, - guint error_code) -{ - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_empty[] = { { NULL } }; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - src = nm_simple_connection_new (); - if (add_wifi) - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - fill_8021x (src, src_empty); - success = complete_connection ("blahblah", bssid, NM_802_11_MODE_INFRA, - flags, wpa_flags, rsn_flags, - FALSE, src, &error); - /* Failure expected */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, error_code); - - g_object_unref (src); -} - -enum { - IDX_NONE = 0, - IDX_OPEN, - IDX_PRIV, - IDX_WPA_PSK_PTKIP_GTKIP, - IDX_WPA_PSK_PTKIP_PCCMP_GTKIP, - IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP, - IDX_WPA_RSN_PSK_PCCMP_GCCMP, - IDX_RSN_PSK_PCCMP_GCCMP, - IDX_RSN_PSK_PTKIP_PCCMP_GTKIP, - IDX_WPA_8021X, - IDX_RSN_8021X, -}; - -static guint32 -flags_for_idx (guint32 idx) -{ - if (idx == IDX_OPEN) - return NM_802_11_AP_FLAGS_NONE; - else if ( idx == IDX_PRIV - || idx == IDX_WPA_PSK_PTKIP_GTKIP - || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP - || idx == IDX_RSN_PSK_PCCMP_GCCMP - || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP - || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP - || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP - || idx == IDX_WPA_8021X - || idx == IDX_RSN_8021X) - return NM_802_11_AP_FLAGS_PRIVACY; - else - g_assert_not_reached (); -} - -static guint32 -wpa_flags_for_idx (guint32 idx) -{ - if (idx == IDX_OPEN || idx == IDX_PRIV || idx == IDX_RSN_8021X - || idx == IDX_RSN_PSK_PCCMP_GCCMP || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP) - return NM_802_11_AP_SEC_NONE; - else if (idx == IDX_WPA_PSK_PTKIP_GTKIP) - return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; - else if (idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP) - return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; - else if (NM_IN_SET (idx, IDX_WPA_PSK_PTKIP_PCCMP_GTKIP, IDX_WPA_RSN_PSK_PCCMP_GCCMP)) - return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK; - else if (idx == IDX_WPA_8021X) - return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_802_1X; - else - g_assert_not_reached (); -} - -static guint32 -rsn_flags_for_idx (guint32 idx) -{ - if (idx == IDX_OPEN || idx == IDX_PRIV || idx == IDX_WPA_8021X - || idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP) - return NM_802_11_AP_SEC_NONE; - else if (idx == IDX_RSN_PSK_PCCMP_GCCMP) - return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK; - else if (idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP) - return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; - else if (idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP) - return NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_KEY_MGMT_PSK; - else if (idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP) - return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK; - else if (idx == IDX_RSN_8021X) - return NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_802_1X; - else - g_assert_not_reached (); -} - -static guint32 -error_code_for_idx (guint32 idx, guint num) -{ - if (idx == IDX_OPEN) - return NM_CONNECTION_ERROR_INVALID_SETTING; - else if (idx == IDX_PRIV) { - if (num <= 3) - return NM_CONNECTION_ERROR_MISSING_PROPERTY; - else - return NM_CONNECTION_ERROR_INVALID_PROPERTY; - } else if ( idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP - || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP - || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_RSN_PSK_PCCMP_GCCMP) - if (num == 4) - return NM_CONNECTION_ERROR_INVALID_PROPERTY; - else - return NM_CONNECTION_ERROR_INVALID_SETTING; - else - g_assert_not_reached (); -} - -static void -test_ap_wpa_eap_connection_1 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - - test_ap_wpa_eap_connection_base (NULL, NULL, - flags_for_idx (idx), - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - error_code_for_idx (idx, 1)); -} - -static void -test_ap_wpa_eap_connection_2 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - - test_ap_wpa_eap_connection_base (NULL, NULL, - flags_for_idx (idx), - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - TRUE, - error_code_for_idx (idx, 2)); -} - -static void -test_ap_wpa_eap_connection_3 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - - test_ap_wpa_eap_connection_base (NULL, "open", - flags_for_idx (idx), - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - error_code_for_idx (idx, 3)); -} - -static void -test_ap_wpa_eap_connection_4 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - - test_ap_wpa_eap_connection_base (NULL, "shared", - flags_for_idx (idx), - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - error_code_for_idx (idx, 4)); -} - -static void -test_ap_wpa_eap_connection_5 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - - test_ap_wpa_eap_connection_base ("wpa-eap", "open", - flags_for_idx (idx), - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - error_code_for_idx (idx, 5)); -} - -/*******************************************/ - -static void -test_priv_ap_empty_connection (void) -{ - NMConnection *src, *expected; - const char *bssid = "01:02:03:04:05:06"; - const char *ssid = "blahblah"; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that an empty connection is completed to a valid Static WEP - * connection when completed with an AP with the Privacy bit set. - */ - - src = nm_simple_connection_new (); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - - /* Static WEP connection expected */ - expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); - fill_wsec (expected, exp_wsec); - COMPARE (src, expected, success, error, 0, 0); - - g_object_unref (src); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_priv_ap_leap_connection_1 (gconstpointer add_wifi) -{ - NMConnection *src, *expected; - const char *ssid = "blahblah"; - const char *bssid = "01:02:03:04:05:06"; - const char *leap_username = "Bill Smith"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0 }, - { NULL } }; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 }, - { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that an minimal LEAP connection specifying only key management and - * the LEAP username is completed to a full LEAP connection when completed - * with an AP with the Privacy bit set. - */ - - src = nm_simple_connection_new (); - if (add_wifi) - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - /* We expect success here; since LEAP APs just set the 'privacy' flag - * there's no way to determine from the AP's beacon whether it's static WEP, - * dynamic WEP, or LEAP. - */ - expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); - fill_wsec (expected, exp_wsec); - COMPARE (src, expected, success, error, 0, 0); - - g_object_unref (src); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_priv_ap_leap_connection_2 (void) -{ - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that an minimal LEAP connection specifying only key management and - * the LEAP auth alg is completed to a full LEAP connection when completed - * with an AP with the Privacy bit set. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - success = complete_connection ("blahblah", bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - /* We expect failure here, we need a LEAP username */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_priv_ap_dynamic_wep_1 (void) -{ - NMConnection *src, *expected; - const char *ssid = "blahblah"; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - const KeyData both_8021x[] = { - { NM_SETTING_802_1X_EAP, "peap", 0 }, - { NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0 }, - { NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0 }, - { NULL } }; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that an minimal Dynamic WEP connection specifying key management, - * the auth algorithm, and valid 802.1x setting is completed to a valid - * Dynamic WEP connection when completed with an AP with the Privacy bit set. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - fill_8021x (src, both_8021x); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - - /* We expect a completed Dynamic WEP connection */ - expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); - fill_wsec (expected, exp_wsec); - fill_8021x (expected, both_8021x); - COMPARE (src, expected, success, error, 0, 0); - - g_object_unref (src); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_priv_ap_dynamic_wep_2 (void) -{ - NMConnection *src, *expected; - const char *ssid = "blahblah"; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - const KeyData both_8021x[] = { - { NM_SETTING_802_1X_EAP, "peap", 0 }, - { NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0 }, - { NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0 }, - { NULL } }; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that an minimal Dynamic WEP connection specifying only the auth - * algorithm and a valid 802.1x setting is completed to a valid Dynamic - * WEP connection when completed with an AP with the Privacy bit set. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - fill_8021x (src, both_8021x); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - - /* We expect a completed Dynamic WEP connection */ - expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); - fill_wsec (expected, exp_wsec); - fill_8021x (expected, both_8021x); - COMPARE (src, expected, success, error, 0, 0); - - g_object_unref (src); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_priv_ap_dynamic_wep_3 (void) -{ - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", 0 }, - { NULL } }; - const KeyData src_8021x[] = { - { NM_SETTING_802_1X_EAP, "peap", 0 }, - { NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0 }, - { NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Ensure that a basic connection specifying 'shared' auth and an 802.1x - * setting is rejected, as 802.1x is incompatible with 'shared' auth. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - fill_8021x (src, src_8021x); - success = complete_connection ("blahblah", bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, - src, &error); - /* Expect failure; shared is not compatible with dynamic WEP */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_priv_ap_wpa_psk_connection_1 (void) -{ - /* Test that a basic WPA-PSK connection is rejected when completion is - * attempted with an AP with just the Privacy bit set. Lack of WPA/RSN - * flags means the AP provides Static/Dynamic WEP or LEAP, not WPA. - */ - test_ap_wpa_psk_connection_base (NULL, NULL, - NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - NULL); -} - -static void -test_priv_ap_wpa_psk_connection_2 (void) -{ - /* Test that a basic WPA-PSK connection is rejected when completion is - * attempted with an AP with just the Privacy bit set. Lack of WPA/RSN - * flags means the AP provides Static/Dynamic WEP or LEAP, not WPA. - */ - test_ap_wpa_psk_connection_base (NULL, NULL, - NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - TRUE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - NULL); -} - -static void -test_priv_ap_wpa_psk_connection_3 (void) -{ - /* Test that a basic WPA-PSK connection specifying only the auth algorithm - * is rejected when completion is attempted with an AP with just the Privacy - * bit set. Lack of WPA/RSN flags means the AP provides Static/Dynamic WEP - * or LEAP, not WPA. - */ - test_ap_wpa_psk_connection_base (NULL, "open", - NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - NULL); -} - -static void -test_priv_ap_wpa_psk_connection_4 (void) -{ - /* Test that a basic WPA-PSK connection specifying only the auth algorithm - * is rejected when completion is attempted with an AP with just the Privacy - * bit set. Lack of WPA/RSN flags means the AP provides Static/Dynamic WEP - * or LEAP, not WPA. Second, 'shared' auth is incompatible with WPA. - */ - test_ap_wpa_psk_connection_base (NULL, "shared", - NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - NULL); -} - -static void -test_priv_ap_wpa_psk_connection_5 (void) -{ - /* Test that a WPA-PSK connection specifying both the key management and - * auth algorithm is rejected when completion is attempted with an AP with - * just the Privacy bit set. Lack of WPA/RSN flags means the AP provides - * Static/Dynamic WEP or LEAP, not WPA. - */ - test_ap_wpa_psk_connection_base ("wpa-psk", "open", - NM_802_11_AP_FLAGS_PRIVACY, - NM_802_11_AP_SEC_NONE, - NM_802_11_AP_SEC_NONE, - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - NULL); -} - -/*******************************************/ - -static void -test_wpa_ap_empty_connection (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *src, *expected; - const char *bssid = "01:02:03:04:05:06"; - const char *ssid = "blahblah"; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that a basic WPA-PSK connection specifying just key management and - * the auth algorithm is completed successfully when given an AP with WPA - * or RSN flags. - */ - - src = nm_simple_connection_new (); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, src, &error); - - /* WPA connection expected */ - expected = create_basic (ssid, NULL, NM_802_11_MODE_INFRA); - fill_wsec (expected, exp_wsec); - COMPARE (src, expected, success, error, 0, 0); - - g_object_unref (src); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_wpa_ap_leap_connection_1 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *src; - const char *ssid = "blahblah"; - const char *bssid = "01:02:03:04:05:06"; - const char *leap_username = "Bill Smith"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that completion of a LEAP connection with a WPA-enabled AP is - * rejected since WPA APs (usually) do not support LEAP. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - success = complete_connection (ssid, bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - src, &error); - /* Expect failure here; WPA APs don't support old-school LEAP */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_wpa_ap_leap_connection_2 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that completion of a LEAP connection with a WPA-enabled AP is - * rejected since WPA APs (usually) do not support LEAP. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - success = complete_connection ("blahblah", bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - src, &error); - /* We expect failure here, we need a LEAP username */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_wpa_ap_dynamic_wep_connection (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *src; - const char *bssid = "01:02:03:04:05:06"; - const KeyData src_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, - { NULL } }; - gboolean success; - GError *error = NULL; - - /* Test that completion of a Dynamic WEP connection with a WPA-enabled AP is - * rejected since WPA APs (usually) do not support Dynamic WEP. - */ - - src = nm_simple_connection_new (); - fill_wifi_empty (src); - fill_wsec (src, src_wsec); - success = complete_connection ("blahblah", bssid, - NM_802_11_MODE_INFRA, NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - src, &error); - /* We expect failure here since Dynamic WEP is incompatible with WPA */ - COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); - - g_object_unref (src); -} - -/*******************************************/ - -static void -test_wpa_ap_wpa_psk_connection_1 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *expected; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - - expected = nm_simple_connection_new (); - fill_wsec (expected, exp_wsec); - test_ap_wpa_psk_connection_base (NULL, NULL, - NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - expected); - g_object_unref (expected); -} - -static void -test_wpa_ap_wpa_psk_connection_2 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *expected; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - - expected = nm_simple_connection_new (); - fill_wsec (expected, exp_wsec); - test_ap_wpa_psk_connection_base (NULL, NULL, - NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - TRUE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - expected); - g_object_unref (expected); -} - -static void -test_wpa_ap_wpa_psk_connection_3 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *expected; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - - expected = nm_simple_connection_new (); - fill_wsec (expected, exp_wsec); - test_ap_wpa_psk_connection_base (NULL, "open", - NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - expected); - g_object_unref (expected); -} - -static void -test_wpa_ap_wpa_psk_connection_4 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - test_ap_wpa_psk_connection_base (NULL, "shared", - NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - NULL); -} - -static void -test_wpa_ap_wpa_psk_connection_5 (gconstpointer data) -{ - guint idx = GPOINTER_TO_UINT (data); - NMConnection *expected; - const KeyData exp_wsec[] = { - { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, - { NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 }, - { NULL } }; - - expected = nm_simple_connection_new (); - fill_wsec (expected, exp_wsec); - test_ap_wpa_psk_connection_base ("wpa-psk", "open", - NM_802_11_AP_FLAGS_PRIVACY, - wpa_flags_for_idx (idx), - rsn_flags_for_idx (idx), - FALSE, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - expected); - g_object_unref (expected); -} - -/*******************************************/ - -static void -test_strength_dbm (void) -{ - /* boundary conditions first */ - g_assert_cmpint (nm_ap_utils_level_to_quality (-1), ==, 100); - g_assert_cmpint (nm_ap_utils_level_to_quality (-40), ==, 100); - g_assert_cmpint (nm_ap_utils_level_to_quality (-30), ==, 100); - g_assert_cmpint (nm_ap_utils_level_to_quality (-100), ==, 0); - g_assert_cmpint (nm_ap_utils_level_to_quality (-200), ==, 0); - - g_assert_cmpint (nm_ap_utils_level_to_quality (-81), ==, 32); - g_assert_cmpint (nm_ap_utils_level_to_quality (-92), ==, 14); - g_assert_cmpint (nm_ap_utils_level_to_quality (-74), ==, 44); - g_assert_cmpint (nm_ap_utils_level_to_quality (-81), ==, 32); - g_assert_cmpint (nm_ap_utils_level_to_quality (-66), ==, 57); -} - -static void -test_strength_percent (void) -{ - int i; - - /* boundary conditions first */ - g_assert_cmpint (nm_ap_utils_level_to_quality (0), ==, 0); - g_assert_cmpint (nm_ap_utils_level_to_quality (100), ==, 100); - g_assert_cmpint (nm_ap_utils_level_to_quality (110), ==, 100); - - for (i = 0; i <= 100; i++) - g_assert_cmpint (nm_ap_utils_level_to_quality (i), ==, i); -} - -static void -test_strength_wext (void) -{ - /* boundary conditions that we assume aren't WEXT first */ - g_assert_cmpint (nm_ap_utils_level_to_quality (256), ==, 100); - g_assert_cmpint (nm_ap_utils_level_to_quality (110), ==, 100); - - /* boundary conditions that we assume are WEXT */ - g_assert_cmpint (nm_ap_utils_level_to_quality (111), ==, 0); - g_assert_cmpint (nm_ap_utils_level_to_quality (150), ==, 0); - g_assert_cmpint (nm_ap_utils_level_to_quality (225), ==, 100); - g_assert_cmpint (nm_ap_utils_level_to_quality (255), ==, 100); - - g_assert_cmpint (nm_ap_utils_level_to_quality (157), ==, 2); - g_assert_cmpint (nm_ap_utils_level_to_quality (200), ==, 74); - g_assert_cmpint (nm_ap_utils_level_to_quality (215), ==, 99); -} - -/*******************************************/ - -NMTST_DEFINE (); - -int -main (int argc, char **argv) -{ - gsize i; - - nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); - - g_test_add_func ("/wifi/lock_bssid", - test_lock_bssid); - - /* Open AP tests; make sure that connections to be completed that have - * various security-related settings already set cause the completion - * to fail. - */ - g_test_add_func ("/wifi/open_ap/empty_connection", - test_open_ap_empty_connection); - g_test_add_data_func ("/wifi/open_ap/leap_connection/1", - (gconstpointer) TRUE, - test_open_ap_leap_connection_1); - g_test_add_data_func ("/wifi/open_ap/leap_connection/1_no_add_wifi", - (gconstpointer) FALSE, - test_open_ap_leap_connection_1); - g_test_add_func ("/wifi/open_ap/leap_connection/2", - test_open_ap_leap_connection_2); - g_test_add_data_func ("/wifi/open_ap/wep_connection_true", - (gconstpointer) TRUE, - test_open_ap_wep_connection); - g_test_add_data_func ("/wifi/open_ap/wep_connection_false", - (gconstpointer) FALSE, - test_open_ap_wep_connection); - - g_test_add_func ("/wifi/open_ap/wpa_psk_connection/1", - test_open_ap_wpa_psk_connection_1); - g_test_add_func ("/wifi/open_ap/wpa_psk_connection/2", - test_open_ap_wpa_psk_connection_2); - g_test_add_func ("/wifi/open_ap/wpa_psk_connection/3", - test_open_ap_wpa_psk_connection_3); - g_test_add_func ("/wifi/open_ap/wpa_psk_connection/4", - test_open_ap_wpa_psk_connection_4); - g_test_add_func ("/wifi/open_ap/wpa_psk_connection/5", - test_open_ap_wpa_psk_connection_5); - - g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/1", - (gconstpointer) IDX_OPEN, - test_ap_wpa_eap_connection_1); - g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/2", - (gconstpointer) IDX_OPEN, - test_ap_wpa_eap_connection_2); - g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/3", - (gconstpointer) IDX_OPEN, - test_ap_wpa_eap_connection_3); - g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/4", - (gconstpointer) IDX_OPEN, - test_ap_wpa_eap_connection_4); - g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/5", - (gconstpointer) IDX_OPEN, - test_ap_wpa_eap_connection_5); - - /* WEP AP tests */ - g_test_add_func ("/wifi/priv_ap/empty_connection", - test_priv_ap_empty_connection); - g_test_add_data_func ("/wifi/priv_ap/leap_connection/1", - (gconstpointer) FALSE, - test_priv_ap_leap_connection_1); - g_test_add_func ("/wifi/priv_ap/leap_connection/2", - test_priv_ap_leap_connection_2); - - g_test_add_func ("/wifi/priv_ap/dynamic_wep/1", - test_priv_ap_dynamic_wep_1); - g_test_add_func ("/wifi/priv_ap/dynamic_wep/2", - test_priv_ap_dynamic_wep_2); - g_test_add_func ("/wifi/priv_ap/dynamic_wep/3", - test_priv_ap_dynamic_wep_3); - - g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/1", - test_priv_ap_wpa_psk_connection_1); - g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/2", - test_priv_ap_wpa_psk_connection_2); - g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/3", - test_priv_ap_wpa_psk_connection_3); - g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/4", - test_priv_ap_wpa_psk_connection_4); - g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/5", - test_priv_ap_wpa_psk_connection_5); - - g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/1", - (gconstpointer) IDX_PRIV, - test_ap_wpa_eap_connection_1); - g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/2", - (gconstpointer) IDX_PRIV, - test_ap_wpa_eap_connection_2); - g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/3", - (gconstpointer) IDX_PRIV, - test_ap_wpa_eap_connection_3); - g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/4", - (gconstpointer) IDX_PRIV, - test_ap_wpa_eap_connection_4); - g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/5", - (gconstpointer) IDX_PRIV, - test_ap_wpa_eap_connection_5); - -#define ADD_FUNC(func) do { \ - gchar *name_idx = g_strdup_printf ("/wifi/wpa_psk/" G_STRINGIFY (func) "/%zd", i); \ - g_test_add_data_func (name_idx, (gconstpointer) i, func); \ - g_free (name_idx); \ - } while (0) - - /* WPA-PSK tests */ - for (i = IDX_WPA_PSK_PTKIP_GTKIP; i <= IDX_WPA_RSN_PSK_PCCMP_GCCMP; i++) { - ADD_FUNC(test_wpa_ap_empty_connection); - ADD_FUNC(test_wpa_ap_leap_connection_1); - ADD_FUNC(test_wpa_ap_leap_connection_2); - ADD_FUNC(test_wpa_ap_dynamic_wep_connection); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_1); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_2); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_3); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_4); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_5); - ADD_FUNC(test_ap_wpa_eap_connection_1); - ADD_FUNC(test_ap_wpa_eap_connection_2); - ADD_FUNC(test_ap_wpa_eap_connection_3); - ADD_FUNC(test_ap_wpa_eap_connection_4); - ADD_FUNC(test_ap_wpa_eap_connection_5); - } - -#undef ADD_FUNC -#define ADD_FUNC(func) do { \ - gchar *name_idx = g_strdup_printf ("/wifi/rsn_psk/" G_STRINGIFY (func) "/%zd", i); \ - g_test_add_data_func (name_idx, (gconstpointer) i, func); \ - g_free (name_idx); \ - } while (0) - - /* RSN-PSK tests */ - for (i = IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP; i <= IDX_RSN_PSK_PTKIP_PCCMP_GTKIP; i++) { - ADD_FUNC(test_wpa_ap_empty_connection); - ADD_FUNC(test_wpa_ap_leap_connection_1); - ADD_FUNC(test_wpa_ap_leap_connection_2); - ADD_FUNC(test_wpa_ap_dynamic_wep_connection); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_1); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_2); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_3); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_4); - ADD_FUNC(test_wpa_ap_wpa_psk_connection_5); - ADD_FUNC(test_ap_wpa_eap_connection_1); - ADD_FUNC(test_ap_wpa_eap_connection_2); - ADD_FUNC(test_ap_wpa_eap_connection_3); - ADD_FUNC(test_ap_wpa_eap_connection_4); - ADD_FUNC(test_ap_wpa_eap_connection_5); - } - -#undef ADD_FUNC - - /* Scanned signal strength conversion tests */ - g_test_add_func ("/wifi/strength/dbm", - test_strength_dbm); - g_test_add_func ("/wifi/strength/percent", - test_strength_percent); - g_test_add_func ("/wifi/strength/wext", - test_strength_wext); - - return g_test_run (); -} diff --git a/src/devices/wwan/Makefile.am b/src/devices/wwan/Makefile.am deleted file mode 100644 index 0d061a79..00000000 --- a/src/devices/wwan/Makefile.am +++ /dev/null @@ -1,96 +0,0 @@ -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/settings \ - -I${top_srcdir}/src/platform \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-wwan"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(LIBSYSTEMD_CFLAGS) \ - $(MM_GLIB_CFLAGS) - -BUILT_SOURCES = $(null) - -pkglib_LTLIBRARIES = libnm-wwan.la libnm-device-plugin-wwan.la - -########################################################### - -GLIB_GENERATED = nm-modem-enum-types.h nm-modem-enum-types.c -GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM -GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM --fhead '\#include "nm-default.h"\n' -nm_modem_enum_types_sources = $(srcdir)/nm-modem.h - -BUILT_SOURCES += $(GLIB_GENERATED) - -libnm_wwan_la_SOURCES = \ - nm-modem-broadband.c \ - nm-modem-broadband.h \ - nm-modem-manager.c \ - nm-modem-manager.h \ - nm-modem.c \ - nm-modem.h \ - \ - $(GLIB_GENERATED) - -if WITH_OFONO -libnm_wwan_la_SOURCES += \ - nm-modem-ofono.c \ - nm-modem-ofono.h \ - $(NULL) -endif - -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 = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(GLIB_LIBS) \ - $(LIBSYSTEMD_LIBS) \ - $(MM_GLIB_LIBS) - -########################################################### - -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 - -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 \ - $(GLIB_LIBS) - -########################################################### - -CLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = $(SYMBOL_VIS_FILE) $(WWAN_SYMBOL_VIS_FILE) - -if ENABLE_TESTS - -check-local: - $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-wwan.so $(SYMBOL_VIS_FILE) - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-wwan.so $(top_builddir)/src/NetworkManager --version >/dev/null - $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-wwan.so $(WWAN_SYMBOL_VIS_FILE) - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-wwan.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - diff --git a/src/devices/wwan/Makefile.in b/src/devices/wwan/Makefile.in deleted file mode 100644 index 22ba0f30..00000000 --- a/src/devices/wwan/Makefile.in +++ /dev/null @@ -1,921 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@WITH_OFONO_TRUE@am__append_1 = \ -@WITH_OFONO_TRUE@ nm-modem-ofono.c \ -@WITH_OFONO_TRUE@ nm-modem-ofono.h \ -@WITH_OFONO_TRUE@ $(NULL) - -subdir = src/devices/wwan -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(pkglib_LTLIBRARIES) -am__DEPENDENCIES_1 = -libnm_device_plugin_wwan_la_DEPENDENCIES = \ - $(top_builddir)/introspection/libnmdbus.la libnm-wwan.la \ - $(am__DEPENDENCIES_1) -am_libnm_device_plugin_wwan_la_OBJECTS = nm-wwan-factory.lo \ - nm-device-modem.lo -libnm_device_plugin_wwan_la_OBJECTS = \ - $(am_libnm_device_plugin_wwan_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_device_plugin_wwan_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(libnm_device_plugin_wwan_la_LDFLAGS) \ - $(LDFLAGS) -o $@ -libnm_wwan_la_DEPENDENCIES = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) -am__libnm_wwan_la_SOURCES_DIST = nm-modem-broadband.c \ - nm-modem-broadband.h nm-modem-manager.c nm-modem-manager.h \ - nm-modem.c nm-modem.h nm-modem-enum-types.h \ - nm-modem-enum-types.c nm-modem-ofono.c nm-modem-ofono.h -am__objects_1 = nm-modem-enum-types.lo -@WITH_OFONO_TRUE@am__objects_2 = nm-modem-ofono.lo -am_libnm_wwan_la_OBJECTS = nm-modem-broadband.lo nm-modem-manager.lo \ - nm-modem.lo $(am__objects_1) $(am__objects_2) -libnm_wwan_la_OBJECTS = $(am_libnm_wwan_la_OBJECTS) -libnm_wwan_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_wwan_la_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libnm_device_plugin_wwan_la_SOURCES) \ - $(libnm_wwan_la_SOURCES) -DIST_SOURCES = $(libnm_device_plugin_wwan_la_SOURCES) \ - $(am__libnm_wwan_la_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/src/devices \ - -I${top_srcdir}/src/settings \ - -I${top_srcdir}/src/platform \ - -I${top_builddir}/introspection \ - -I${top_srcdir}/shared \ - -I$(top_builddir)/shared \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-wwan"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(LIBSYSTEMD_CFLAGS) \ - $(MM_GLIB_CFLAGS) - -BUILT_SOURCES = $(null) $(GLIB_GENERATED) -pkglib_LTLIBRARIES = libnm-wwan.la libnm-device-plugin-wwan.la - -########################################################### -GLIB_GENERATED = nm-modem-enum-types.h nm-modem-enum-types.c -GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM -GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM --fhead '\#include "nm-default.h"\n' -nm_modem_enum_types_sources = $(srcdir)/nm-modem.h -libnm_wwan_la_SOURCES = nm-modem-broadband.c nm-modem-broadband.h \ - nm-modem-manager.c nm-modem-manager.h nm-modem.c nm-modem.h \ - $(GLIB_GENERATED) $(am__append_1) -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 = \ - $(top_builddir)/introspection/libnmdbus.la \ - $(GLIB_LIBS) \ - $(LIBSYSTEMD_LIBS) \ - $(MM_GLIB_LIBS) - - -########################################################### -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 - -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 \ - $(GLIB_LIBS) - - -########################################################### -CLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = $(SYMBOL_VIS_FILE) $(WWAN_SYMBOL_VIS_FILE) -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/devices/wwan/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/devices/wwan/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnm-device-plugin-wwan.la: $(libnm_device_plugin_wwan_la_OBJECTS) $(libnm_device_plugin_wwan_la_DEPENDENCIES) $(EXTRA_libnm_device_plugin_wwan_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_device_plugin_wwan_la_LINK) -rpath $(pkglibdir) $(libnm_device_plugin_wwan_la_OBJECTS) $(libnm_device_plugin_wwan_la_LIBADD) $(LIBS) - -libnm-wwan.la: $(libnm_wwan_la_OBJECTS) $(libnm_wwan_la_DEPENDENCIES) $(EXTRA_libnm_wwan_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_wwan_la_LINK) -rpath $(pkglibdir) $(libnm_wwan_la_OBJECTS) $(libnm_wwan_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-device-modem.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-modem-broadband.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-modem-enum-types.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-modem-manager.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-modem-ofono.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-modem.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-wwan-factory.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-am - -clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: all check check-am install install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ - clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkglibLTLIBRARIES install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - -include $(GLIB_MAKEFILE) - -@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-wwan.so $(SYMBOL_VIS_FILE) -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-device-plugin-wwan.so $(top_builddir)/src/NetworkManager --version >/dev/null -@ENABLE_TESTS_TRUE@ $(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-wwan.so $(WWAN_SYMBOL_VIS_FILE) -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/.libs/libnm-wwan.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/devices/wwan/exports.ver b/src/devices/wwan/exports.ver deleted file mode 100644 index 24cd848c..00000000 --- a/src/devices/wwan/exports.ver +++ /dev/null @@ -1,6 +0,0 @@ -{ -global: - nm_device_factory_create; -local: - *; -}; diff --git a/src/devices/wwan/libnm-wwan.ver b/src/devices/wwan/libnm-wwan.ver new file mode 100644 index 00000000..23412de6 --- /dev/null +++ b/src/devices/wwan/libnm-wwan.ver @@ -0,0 +1,30 @@ +{ +global: + nm_modem_act_stage1_prepare; + nm_modem_act_stage2_config; + nm_modem_check_connection_compatible; + nm_modem_complete_connection; + nm_modem_deactivate; + nm_modem_deactivate_async; + nm_modem_deactivate_async_finish; + nm_modem_device_state_changed; + nm_modem_get_capabilities; + nm_modem_get_control_port; + nm_modem_get_data_port; + nm_modem_get_driver; + nm_modem_get_iid; + nm_modem_get_path; + nm_modem_get_secrets; + nm_modem_get_state; + nm_modem_get_type; + nm_modem_get_uid; + nm_modem_ip4_pre_commit; + nm_modem_manager_get_type; + nm_modem_owns_port; + nm_modem_set_mm_enabled; + nm_modem_stage3_ip4_config_start; + nm_modem_stage3_ip6_config_start; + nm_modem_state_to_string; +local: + *; +}; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index b277b15b..7a70a0bf 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -20,25 +20,30 @@ #include "nm-default.h" +#include "nm-device-modem.h" + #include -#include "nm-device-modem.h" #include "nm-modem.h" -#include "nm-device-private.h" +#include "devices/nm-device-private.h" #include "nm-rfkill-manager.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings-connection.h" #include "nm-modem-broadband.h" #include "NetworkManagerUtils.h" #include "nm-core-internal.h" -#include "nm-device-logging.h" -_LOG_DECLARE_SELF(NMDeviceModem); +#include "introspection/org.freedesktop.NetworkManager.Device.Modem.h" -#include "nmdbus-device-modem.h" +#include "devices/nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceModem); -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)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_MODEM, + PROP_CAPABILITIES, + PROP_CURRENT_CAPABILITIES, +); typedef struct { NMModem *modem; @@ -47,13 +52,19 @@ typedef struct { gboolean rf_enabled; } NMDeviceModemPrivate; -enum { - PROP_0, - PROP_MODEM, - PROP_CAPABILITIES, - PROP_CURRENT_CAPABILITIES, +struct _NMDeviceModem { + NMDevice parent; + NMDeviceModemPrivate _priv; +}; + +struct _NMDeviceModemClass { + NMDeviceClass parent; }; +G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) + +#define NM_DEVICE_MODEM_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceModem, NM_IS_DEVICE_MODEM) + /*****************************************************************************/ static void @@ -230,7 +241,7 @@ modem_ip6_config_result (NMModem *modem, case NM_ACT_STAGE_RETURN_FAILURE: nm_device_ip_method_failed (device, AF_INET6, reason); break; - case NM_ACT_STAGE_RETURN_STOP: + case NM_ACT_STAGE_RETURN_IP_FAIL: /* all done */ nm_device_activate_schedule_ip6_config_result (device); break; @@ -249,16 +260,11 @@ static void data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); - const char *old = nm_device_get_ip_iface (self); - const char *new = nm_modem_get_data_port (modem); - gboolean changed = FALSE; - - if (new && g_strcmp0 (new, old)) - changed = TRUE; + gboolean changed; /* We set the IP iface in the device as soon as we know it, so that we * properly ifup it if needed */ - nm_device_set_ip_iface (self, new); + changed = nm_device_set_ip_iface (self, nm_modem_get_data_port (modem)); /* Disable IPv6 immediately on the interface since NM handles IPv6 * internally, and leaving it enabled could allow the kernel's IPv6 @@ -276,12 +282,14 @@ ids_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) static void modem_state_cb (NMModem *modem, - NMModemState new_state, - NMModemState old_state, + int new_state_i, + int old_state_i, gpointer user_data) { + NMModemState new_state = new_state_i; + NMModemState old_state = old_state_i; NMDevice *device = NM_DEVICE (user_data); - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device); NMDeviceState dev_state = nm_device_get_state (device); if (new_state <= NM_MODEM_STATE_DISABLING && @@ -335,9 +343,10 @@ modem_removed_cb (NMModem *modem, gpointer user_data) static gboolean owns_iface (NMDevice *device, const char *iface) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device); + + g_return_val_if_fail (priv->modem, FALSE); - g_assert (priv->modem); return nm_modem_owns_port (priv->modem, iface); } @@ -350,7 +359,7 @@ device_state_changed (NMDevice *device, NMDeviceStateReason reason) { NMDeviceModem *self = NM_DEVICE_MODEM (device); - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self); NMSettingsConnection *connection = nm_device_get_settings_connection (device); g_assert (priv->modem); @@ -394,7 +403,7 @@ get_generic_capabilities (NMDevice *device) static const char * get_type_description (NMDevice *device) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device); if (NM_FLAGS_HAS (priv->current_caps, NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)) return "gsm"; @@ -409,7 +418,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection)) return FALSE; - return nm_modem_check_connection_compatible (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, connection); + return nm_modem_check_connection_compatible (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, connection); } static gboolean @@ -444,7 +453,7 @@ complete_connection (NMDevice *device, const GSList *existing_connections, GError **error) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device); return nm_modem_complete_connection (priv->modem, connection, existing_connections, error); } @@ -452,10 +461,10 @@ complete_connection (NMDevice *device, static void deactivate (NMDevice *device) { - nm_modem_deactivate (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, device); + nm_modem_deactivate (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, device); } -/***********************************************************/ +/*****************************************************************************/ static gboolean deactivate_async_finish (NMDevice *self, @@ -490,14 +499,14 @@ deactivate_async (NMDevice *self, callback, user_data, deactivate_async); - nm_modem_deactivate_async (NM_DEVICE_MODEM_GET_PRIVATE (self)->modem, + nm_modem_deactivate_async (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) self)->modem, self, cancellable, (GAsyncReadyCallback) modem_deactivate_async_ready, simple); } -/***********************************************************/ +/*****************************************************************************/ static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) @@ -512,7 +521,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) req = nm_device_get_act_request (device); g_assert (req); - return nm_modem_act_stage1_prepare (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, req, reason); + return nm_modem_act_stage1_prepare (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, req, reason); } static NMActStageReturn @@ -523,7 +532,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) req = nm_device_get_act_request (device); g_assert (req); - return nm_modem_act_stage2_config (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, req, reason); + return nm_modem_act_stage2_config (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, req, reason); } static NMActStageReturn @@ -531,7 +540,7 @@ act_stage3_ip4_config_start (NMDevice *device, NMIP4Config **out_config, NMDeviceStateReason *reason) { - return nm_modem_stage3_ip4_config_start (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, + return nm_modem_stage3_ip4_config_start (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, device, NM_DEVICE_CLASS (nm_device_modem_parent_class), reason); @@ -540,7 +549,7 @@ act_stage3_ip4_config_start (NMDevice *device, static void ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) { - nm_modem_ip4_pre_commit (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, device, config); + nm_modem_ip4_pre_commit (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, device, config); } static NMActStageReturn @@ -548,7 +557,7 @@ act_stage3_ip6_config_start (NMDevice *device, NMIP6Config **out_config, NMDeviceStateReason *reason) { - return nm_modem_stage3_ip6_config_start (NM_DEVICE_MODEM_GET_PRIVATE (device)->modem, + return nm_modem_stage3_ip6_config_start (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, nm_device_get_act_request (device), reason); } @@ -572,7 +581,7 @@ get_ip_iface_identifier (NMDevice *device, NMUtilsIPv6IfaceId *out_iid) static gboolean get_enabled (NMDevice *device) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device); NMModemState modem_state = nm_modem_get_state (priv->modem); return priv->rf_enabled && (modem_state >= NM_MODEM_STATE_LOCKED); @@ -621,58 +630,6 @@ is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) /*****************************************************************************/ -NMDevice * -nm_device_modem_new (NMModem *modem) -{ - NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE; - NMDeviceModemCapabilities current_caps = NM_DEVICE_MODEM_CAPABILITY_NONE; - NMDevice *device; - const char *data_port; - - g_return_val_if_fail (NM_IS_MODEM (modem), NULL); - - /* Load capabilities */ - nm_modem_get_capabilities (modem, &caps, ¤t_caps); - - device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_MODEM, - NM_DEVICE_UDI, nm_modem_get_path (modem), - NM_DEVICE_IFACE, nm_modem_get_uid (modem), - NM_DEVICE_DRIVER, nm_modem_get_driver (modem), - NM_DEVICE_TYPE_DESC, "Broadband", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_MODEM, - NM_DEVICE_RFKILL_TYPE, RFKILL_TYPE_WWAN, - NM_DEVICE_MODEM_MODEM, modem, - NM_DEVICE_MODEM_CAPABILITIES, caps, - NM_DEVICE_MODEM_CURRENT_CAPABILITIES, current_caps, - NULL); - - /* If the data port is known, set it as the IP interface immediately */ - data_port = nm_modem_get_data_port (modem); - if (data_port) { - nm_device_set_ip_iface (device, data_port); - nm_device_ipv6_sysctl_set (device, "disable_ipv6", "1"); - } - - return device; -} - -static void -nm_device_modem_init (NMDeviceModem *self) -{ -} - -static void -constructed (GObject *object) -{ - G_OBJECT_CLASS (nm_device_modem_parent_class)->constructed (object); - - /* DHCP is always done by the modem firmware, not by the network, and - * by the time we get around to DHCP the firmware should already know - * the IP addressing details. So the DHCP timeout can be much shorter. - */ - nm_device_set_dhcp_timeout (NM_DEVICE (object), 15); -} - static void set_modem (NMDeviceModem *self, NMModem *modem) { @@ -701,22 +658,23 @@ set_modem (NMDeviceModem *self, NMModem *modem) g_signal_connect (modem, "notify::" NM_MODEM_SIM_OPERATOR_ID, G_CALLBACK (ids_changed_cb), self); } +/*****************************************************************************/ + static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) object); switch (prop_id) { case PROP_MODEM: - /* construct-only */ - set_modem (NM_DEVICE_MODEM (object), g_value_get_object (value)); + g_value_set_object (value, priv->modem); break; case PROP_CAPABILITIES: - priv->caps = g_value_get_uint (value); + g_value_set_uint (value, priv->caps); break; case PROP_CURRENT_CAPABILITIES: - priv->current_caps = g_value_get_uint (value); + g_value_set_uint (value, priv->current_caps); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -725,20 +683,21 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) object); switch (prop_id) { case PROP_MODEM: - g_value_set_object (value, priv->modem); + /* construct-only */ + set_modem (NM_DEVICE_MODEM (object), g_value_get_object (value)); break; case PROP_CAPABILITIES: - g_value_set_uint (value, priv->caps); + priv->caps = g_value_get_uint (value); break; case PROP_CURRENT_CAPABILITIES: - g_value_set_uint (value, priv->current_caps); + priv->current_caps = g_value_get_uint (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -746,10 +705,64 @@ get_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + +static void +nm_device_modem_init (NMDeviceModem *self) +{ +} + +static void +constructed (GObject *object) +{ + G_OBJECT_CLASS (nm_device_modem_parent_class)->constructed (object); + + /* DHCP is always done by the modem firmware, not by the network, and + * by the time we get around to DHCP the firmware should already know + * the IP addressing details. So the DHCP timeout can be much shorter. + */ + nm_device_set_dhcp_timeout (NM_DEVICE (object), 15); +} + +NMDevice * +nm_device_modem_new (NMModem *modem) +{ + NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE; + NMDeviceModemCapabilities current_caps = NM_DEVICE_MODEM_CAPABILITY_NONE; + NMDevice *device; + const char *data_port; + + g_return_val_if_fail (NM_IS_MODEM (modem), NULL); + + /* Load capabilities */ + nm_modem_get_capabilities (modem, &caps, ¤t_caps); + + device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_MODEM, + NM_DEVICE_UDI, nm_modem_get_path (modem), + NM_DEVICE_IFACE, nm_modem_get_uid (modem), + NM_DEVICE_DRIVER, nm_modem_get_driver (modem), + NM_DEVICE_TYPE_DESC, "Broadband", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_MODEM, + NM_DEVICE_RFKILL_TYPE, RFKILL_TYPE_WWAN, + NM_DEVICE_MODEM_MODEM, modem, + NM_DEVICE_MODEM_CAPABILITIES, caps, + NM_DEVICE_MODEM_CURRENT_CAPABILITIES, current_caps, + NULL); + + /* If the data port is known, set it as the IP interface immediately */ + data_port = nm_modem_get_data_port (modem); + if (data_port) { + nm_device_set_ip_iface (device, data_port); + nm_device_ipv6_sysctl_set (device, "disable_ipv6", "1"); + } + + return device; +} + static void dispose (GObject *object) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) object); if (priv->modem) g_signal_handlers_disconnect_by_data (priv->modem, NM_DEVICE_MODEM (object)); @@ -764,9 +777,6 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) GObjectClass *object_class = G_OBJECT_CLASS (mclass); NMDeviceClass *device_class = NM_DEVICE_CLASS (mclass); - g_type_class_add_private (object_class, sizeof (NMDeviceModemPrivate)); - - /* Virtual methods */ object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; @@ -793,27 +803,25 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) device_class->state_changed = device_state_changed; - /* Properties */ - g_object_class_install_property - (object_class, PROP_MODEM, - g_param_spec_object (NM_DEVICE_MODEM_MODEM, "", "", - NM_TYPE_MODEM, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_CAPABILITIES, - g_param_spec_uint (NM_DEVICE_MODEM_CAPABILITIES, "", "", - 0, G_MAXUINT32, NM_DEVICE_MODEM_CAPABILITY_NONE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_CURRENT_CAPABILITIES, - g_param_spec_uint (NM_DEVICE_MODEM_CURRENT_CAPABILITIES, "", "", - 0, G_MAXUINT32, NM_DEVICE_MODEM_CAPABILITY_NONE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_MODEM] = + g_param_spec_object (NM_DEVICE_MODEM_MODEM, "", "", + NM_TYPE_MODEM, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_CAPABILITIES] = + g_param_spec_uint (NM_DEVICE_MODEM_CAPABILITIES, "", "", + 0, G_MAXUINT32, NM_DEVICE_MODEM_CAPABILITY_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_CURRENT_CAPABILITIES] = + g_param_spec_uint (NM_DEVICE_MODEM_CURRENT_CAPABILITIES, "", "", + 0, G_MAXUINT32, NM_DEVICE_MODEM_CAPABILITY_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (mclass), NMDBUS_TYPE_DEVICE_MODEM_SKELETON, diff --git a/src/devices/wwan/nm-device-modem.h b/src/devices/wwan/nm-device-modem.h index 1cf399e1..65bda8b6 100644 --- a/src/devices/wwan/nm-device-modem.h +++ b/src/devices/wwan/nm-device-modem.h @@ -21,7 +21,7 @@ #ifndef __NETWORKMANAGER_DEVICE_MODEM_H__ #define __NETWORKMANAGER_DEVICE_MODEM_H__ -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-modem.h" #define NM_TYPE_DEVICE_MODEM (nm_device_modem_get_type ()) @@ -35,14 +35,8 @@ #define NM_DEVICE_MODEM_CAPABILITIES "modem-capabilities" #define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities" -typedef struct { - NMDevice parent; -} NMDeviceModem; - -typedef struct { - NMDeviceClass parent; - -} NMDeviceModemClass; +typedef struct _NMDeviceModem NMDeviceModem; +typedef struct _NMDeviceModemClass NMDeviceModemClass; GType nm_device_modem_get_type (void); diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 727c8409..e1fc4546 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -20,27 +20,39 @@ #include "nm-default.h" +#include "nm-modem-broadband.h" + #include #include #include -#include "nm-modem-broadband.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" -#include "nm-device-private.h" -#include "nm-platform.h" +#include "devices/nm-device-private.h" +#include "platform/nm-platform.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" #define NM_MODEM_BROADBAND_MODEM "modem" -G_DEFINE_TYPE (NMModemBroadband, nm_modem_broadband, NM_TYPE_MODEM) +#define MODEM_CAPS_3GPP(caps) (caps & (MM_MODEM_CAPABILITY_GSM_UMTS | \ + MM_MODEM_CAPABILITY_LTE | \ + MM_MODEM_CAPABILITY_LTE_ADVANCED)) + +#define MODEM_CAPS_3GPP2(caps) (caps & (MM_MODEM_CAPABILITY_CDMA_EVDO)) + +/* Maximum time to keep the DBus call waiting for a connection result */ +#define MODEM_CONNECT_TIMEOUT_SECS 120 + +/*****************************************************************************/ typedef enum { - CONNECT_STEP_FIRST, - CONNECT_STEP_WAIT_FOR_SIM, - CONNECT_STEP_UNLOCK, - CONNECT_STEP_WAIT_FOR_READY, - CONNECT_STEP_CONNECT, - CONNECT_STEP_LAST + CONNECT_STEP_FIRST, + CONNECT_STEP_WAIT_FOR_SIM, + CONNECT_STEP_UNLOCK, + CONNECT_STEP_WAIT_FOR_READY, + CONNECT_STEP_CONNECT, + CONNECT_STEP_LAST, } ConnectStep; typedef struct { @@ -57,7 +69,13 @@ typedef struct { GError *first_error; } ConnectContext; -struct _NMModemBroadbandPrivate { +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_MODEM, +); + +typedef struct { /* The modem object from dbus */ MMObject *modem_object; /* Per-interface objects */ @@ -73,21 +91,20 @@ struct _NMModemBroadbandPrivate { MMBearerIpConfig *ipv6_config; guint32 pin_tries; -}; +} NMModemBroadbandPrivate; -enum { - PROP_0, - PROP_MODEM, +struct _NMModemBroadband { + NMModem parent; + NMModemBroadbandPrivate _priv; }; -#define MODEM_CAPS_3GPP(caps) (caps & (MM_MODEM_CAPABILITY_GSM_UMTS | \ - MM_MODEM_CAPABILITY_LTE | \ - MM_MODEM_CAPABILITY_LTE_ADVANCED)) +struct _NMModemBroadbandClass { + NMModemClass parent; +}; -#define MODEM_CAPS_3GPP2(caps) (caps & (MM_MODEM_CAPABILITY_CDMA_EVDO)) +G_DEFINE_TYPE (NMModemBroadband, nm_modem_broadband, NM_TYPE_MODEM) -/* Maximum time to keep the DBus call waiting for a connection result */ -#define MODEM_CONNECT_TIMEOUT_SECS 120 +#define NM_MODEM_BROADBAND_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMModemBroadband, NM_IS_MODEM_BROADBAND) /*****************************************************************************/ @@ -172,7 +189,7 @@ get_capabilities (NMModem *_self, /* For now, we don't care about the capability combinations, just merge all * combinations in a single mask */ - if (mm_modem_get_supported_capabilities (self->priv->modem_iface, &supported, &n_supported)) { + if (mm_modem_get_supported_capabilities (self->_priv.modem_iface, &supported, &n_supported)) { guint i; for (i = 0; i < n_supported; i++) @@ -182,7 +199,7 @@ get_capabilities (NMModem *_self, } *modem_caps = (NMDeviceModemCapabilities) all_supported; - *current_caps = (NMDeviceModemCapabilities) mm_modem_get_current_capabilities (self->priv->modem_iface); + *current_caps = (NMDeviceModemCapabilities) mm_modem_get_current_capabilities (self->_priv.modem_iface); } static gboolean @@ -193,7 +210,7 @@ owns_port (NMModem *_self, const char *iface) guint n_ports = 0, i; gboolean owns = FALSE; - mm_modem_peek_ports (self->priv->modem_iface, &ports, &n_ports); + mm_modem_peek_ports (self->_priv.modem_iface, &ports, &n_ports); for (i = 0; i < n_ports && !owns; i++) owns = (g_strcmp0 (iface, ports[i].name) == 0); return owns; @@ -206,7 +223,7 @@ ask_for_pin (NMModemBroadband *self) { guint32 tries; - tries = self->priv->pin_tries++; + tries = self->_priv.pin_tries++; nm_modem_get_secrets (NM_MODEM (self), NM_SETTING_GSM_SETTING_NAME, tries ? TRUE : FALSE, @@ -312,8 +329,8 @@ create_gsm_connect_properties (NMConnection *connection) static void connect_context_clear (NMModemBroadband *self) { - if (self->priv->ctx) { - ConnectContext *ctx = self->priv->ctx; + if (self->_priv.ctx) { + ConnectContext *ctx = self->_priv.ctx; g_clear_error (&ctx->first_error); g_clear_pointer (&ctx->ip_types, (GDestroyNotify) g_array_unref); @@ -322,7 +339,7 @@ connect_context_clear (NMModemBroadband *self) g_clear_object (&ctx->connect_properties); g_clear_object (&ctx->self); g_slice_free (ConnectContext, ctx); - self->priv->ctx = NULL; + self->_priv.ctx = NULL; } } @@ -333,20 +350,20 @@ connect_ready (MMModemSimple *simple_iface, GAsyncResult *res, NMModemBroadband *self) { - ConnectContext *ctx = self->priv->ctx; + ConnectContext *ctx = self->_priv.ctx; GError *error = NULL; NMModemIPMethod ip4_method = NM_MODEM_IP_METHOD_UNKNOWN; NMModemIPMethod ip6_method = NM_MODEM_IP_METHOD_UNKNOWN; - self->priv->bearer = mm_modem_simple_connect_finish (simple_iface, res, &error); + self->_priv.bearer = mm_modem_simple_connect_finish (simple_iface, res, &error); if (!ctx) return; - if (!self->priv->bearer) { + if (!self->_priv.bearer) { if (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_PIN) || (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_UNAUTHORIZED) && - mm_modem_get_unlock_required (self->priv->modem_iface) == MM_MODEM_LOCK_SIM_PIN)) { + mm_modem_get_unlock_required (self->_priv.modem_iface) == MM_MODEM_LOCK_SIM_PIN)) { g_error_free (error); /* Request PIN */ @@ -379,13 +396,13 @@ connect_ready (MMModemSimple *simple_iface, } /* Grab IP configurations */ - self->priv->ipv4_config = mm_bearer_get_ipv4_config (self->priv->bearer); - if (self->priv->ipv4_config) - ip4_method = get_bearer_ip_method (self->priv->ipv4_config); + self->_priv.ipv4_config = mm_bearer_get_ipv4_config (self->_priv.bearer); + if (self->_priv.ipv4_config) + ip4_method = get_bearer_ip_method (self->_priv.ipv4_config); - self->priv->ipv6_config = mm_bearer_get_ipv6_config (self->priv->bearer); - if (self->priv->ipv6_config) - ip6_method = get_bearer_ip_method (self->priv->ipv6_config); + self->_priv.ipv6_config = mm_bearer_get_ipv6_config (self->_priv.bearer); + if (self->_priv.ipv6_config) + ip6_method = get_bearer_ip_method (self->_priv.ipv6_config); if (ip4_method == NM_MODEM_IP_METHOD_UNKNOWN && ip6_method == NM_MODEM_IP_METHOD_UNKNOWN) { @@ -396,10 +413,10 @@ connect_ready (MMModemSimple *simple_iface, } g_object_set (self, - NM_MODEM_DATA_PORT, mm_bearer_get_interface (self->priv->bearer), + NM_MODEM_DATA_PORT, mm_bearer_get_interface (self->_priv.bearer), NM_MODEM_IP4_METHOD, ip4_method, NM_MODEM_IP6_METHOD, ip6_method, - NM_MODEM_IP_TIMEOUT, mm_bearer_get_ip_timeout (self->priv->bearer), + NM_MODEM_IP_TIMEOUT, mm_bearer_get_ip_timeout (self->_priv.bearer), NULL); ctx->step++; @@ -416,13 +433,13 @@ send_pin_ready (MMSim *sim, GAsyncResult *result, NMModemBroadband *self) if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - if (!self->priv->ctx || self->priv->ctx->step != CONNECT_STEP_UNLOCK) + if (!self->_priv.ctx || self->_priv.ctx->step != CONNECT_STEP_UNLOCK) g_return_if_reached (); if (error) { if (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_PIN) || (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_UNAUTHORIZED) && - mm_modem_get_unlock_required (self->priv->modem_iface) == MM_MODEM_LOCK_SIM_PIN)) { + mm_modem_get_unlock_required (self->_priv.modem_iface) == MM_MODEM_LOCK_SIM_PIN)) { ask_for_pin (self); } else { g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, translate_mm_error (self, error)); @@ -430,14 +447,14 @@ send_pin_ready (MMSim *sim, GAsyncResult *result, NMModemBroadband *self) return; } - self->priv->ctx->step++; + self->_priv.ctx->step++; connect_context_step (self); } static void connect_context_step (NMModemBroadband *self) { - ConnectContext *ctx = self->priv->ctx; + ConnectContext *ctx = self->_priv.ctx; switch (ctx->step) { case CONNECT_STEP_FIRST: @@ -445,7 +462,7 @@ connect_context_step (NMModemBroadband *self) /* fall through */ case CONNECT_STEP_WAIT_FOR_SIM: - if (MODEM_CAPS_3GPP (ctx->caps) && !self->priv->sim_iface) { + if (MODEM_CAPS_3GPP (ctx->caps) && !self->_priv.sim_iface) { /* Have to wait for the SIM to show up */ break; } @@ -454,13 +471,13 @@ connect_context_step (NMModemBroadband *self) case CONNECT_STEP_UNLOCK: if ( MODEM_CAPS_3GPP (ctx->caps) - && mm_modem_get_unlock_required (self->priv->modem_iface) == MM_MODEM_LOCK_SIM_PIN) { + && mm_modem_get_unlock_required (self->_priv.modem_iface) == MM_MODEM_LOCK_SIM_PIN) { NMSettingGsm *s_gsm = nm_connection_get_setting_gsm (ctx->connection); const char *pin = nm_setting_gsm_get_pin (s_gsm); /* If we have a PIN already, send it. If we don't, get it. */ if (pin) { - mm_sim_send_pin (self->priv->sim_iface, + mm_sim_send_pin (self->_priv.sim_iface, pin, ctx->cancellable, (GAsyncReadyCallback) send_pin_ready, @@ -476,7 +493,7 @@ connect_context_step (NMModemBroadband *self) case CONNECT_STEP_WAIT_FOR_READY: { GError *error = NULL; - if (mm_modem_get_state (self->priv->modem_iface) <= MM_MODEM_STATE_LOCKED) + if (mm_modem_get_state (self->_priv.modem_iface) <= MM_MODEM_STATE_LOCKED) break; /* Create core connect properties based on the modem capabilities */ @@ -532,7 +549,7 @@ connect_context_step (NMModemBroadband *self) nm_modem_ip_type_to_string (current), ctx->ip_type_tries + 1); - mm_modem_simple_connect (self->priv->simple_iface, + mm_modem_simple_connect (self->_priv.simple_iface, ctx->connect_properties, NULL, (GAsyncReadyCallback) connect_ready, @@ -544,7 +561,7 @@ connect_context_step (NMModemBroadband *self) /* fall through */ case CONNECT_STEP_LAST: - if (self->priv->ipv4_config || self->priv->ipv6_config) { + if (self->_priv.ipv4_config || self->_priv.ipv6_config) { g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, TRUE, NM_DEVICE_STATE_REASON_NONE); } else { /* If we have a saved error from a previous attempt, use it */ @@ -571,9 +588,9 @@ act_stage1_prepare (NMModem *_self, NMModemBroadband *self = NM_MODEM_BROADBAND (_self); /* Make sure we can get the Simple interface from the modem */ - if (!self->priv->simple_iface) { - self->priv->simple_iface = mm_object_get_modem_simple (self->priv->modem_object); - if (!self->priv->simple_iface) { + if (!self->_priv.simple_iface) { + self->_priv.simple_iface = mm_object_get_modem_simple (self->_priv.modem_object); + if (!self->_priv.simple_iface) { _LOGW ("cannot access the Simple mobile broadband modem interface"); *reason = NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED; return NM_ACT_STAGE_RETURN_FAILURE; @@ -583,12 +600,12 @@ act_stage1_prepare (NMModem *_self, connect_context_clear (self); /* Allocate new context for this connect stage attempt */ - self->priv->ctx = g_slice_new0 (ConnectContext); - self->priv->ctx->caps = mm_modem_get_current_capabilities (self->priv->modem_iface); - self->priv->ctx->cancellable = g_cancellable_new (); - self->priv->ctx->connection = g_object_ref (connection); + self->_priv.ctx = g_slice_new0 (ConnectContext); + self->_priv.ctx->caps = mm_modem_get_current_capabilities (self->_priv.modem_iface); + self->_priv.ctx->cancellable = g_cancellable_new (); + self->_priv.ctx->connection = g_object_ref (connection); - g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (self->priv->simple_iface), MODEM_CONNECT_TIMEOUT_SECS * 1000); + g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (self->_priv.simple_iface), MODEM_CONNECT_TIMEOUT_SECS * 1000); connect_context_step (self); return NM_ACT_STAGE_RETURN_POSTPONE; @@ -603,7 +620,7 @@ check_connection_compatible (NMModem *_self, NMConnection *connection) MMModemCapability modem_caps; NMSettingConnection *s_con; - modem_caps = mm_modem_get_current_capabilities (self->priv->modem_iface); + modem_caps = mm_modem_get_current_capabilities (self->_priv.modem_iface); s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); @@ -650,7 +667,7 @@ complete_connection (NMModem *_self, MMModemCapability modem_caps; NMSettingPpp *s_ppp; - modem_caps = mm_modem_get_current_capabilities (self->priv->modem_iface); + modem_caps = mm_modem_get_current_capabilities (self->_priv.modem_iface); /* PPP settings common to 3GPP and 3GPP2 */ s_ppp = nm_connection_get_setting_ppp (connection); @@ -827,12 +844,12 @@ set_mm_enabled (NMModem *_self, NMModemBroadband *self = NM_MODEM_BROADBAND (_self); if (enabled) { - mm_modem_enable (self->priv->modem_iface, + mm_modem_enable (self->_priv.modem_iface, NULL, /* cancellable */ (GAsyncReadyCallback)modem_enable_ready, g_object_ref (self)); } else { - mm_modem_disable (self->priv->modem_iface, + mm_modem_disable (self->_priv.modem_iface, NULL, /* cancellable */ (GAsyncReadyCallback)modem_disable_ready, g_object_ref (self)); @@ -861,7 +878,7 @@ static gboolean static_stage3_ip4_done (NMModemBroadband *self) { GError *error = NULL; - NMIP4Config *config = NULL; + gs_unref_object NMIP4Config *config = NULL; const char *data_port; const gchar *address_string; const gchar *gw_string; @@ -871,13 +888,13 @@ static_stage3_ip4_done (NMModemBroadband *self) const gchar **dns; guint i; - g_assert (self->priv->ipv4_config); - g_assert (self->priv->bearer); + g_assert (self->_priv.ipv4_config); + g_assert (self->_priv.bearer); _LOGI ("IPv4 static configuration:"); /* Fully fail if invalid IP address retrieved */ - address_string = mm_bearer_ip_config_get_address (self->priv->ipv4_config); + address_string = mm_bearer_ip_config_get_address (self->_priv.ipv4_config); if (!ip4_string_to_num (address_string, &address_network)) { error = g_error_new (NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, @@ -888,17 +905,17 @@ static_stage3_ip4_done (NMModemBroadband *self) } /* Missing gateway not a hard failure */ - gw_string = mm_bearer_ip_config_get_gateway (self->priv->ipv4_config); + gw_string = mm_bearer_ip_config_get_gateway (self->_priv.ipv4_config); ip4_string_to_num (gw_string, &gw); - data_port = mm_bearer_get_interface (self->priv->bearer); + data_port = mm_bearer_get_interface (self->_priv.bearer); g_assert (data_port); config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); memset (&address, 0, sizeof (address)); address.address = address_network; address.peer_address = address_network; - address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv4_config); + address.plen = mm_bearer_ip_config_get_prefix (self->_priv.ipv4_config); address.addr_source = NM_IP_CONFIG_SOURCE_WWAN; if (address.plen <= 32) nm_ip4_config_add_address (config, &address); @@ -911,7 +928,7 @@ static_stage3_ip4_done (NMModemBroadband *self) } /* DNS servers */ - dns = mm_bearer_ip_config_get_dns (self->priv->ipv4_config); + dns = mm_bearer_ip_config_get_dns (self->_priv.ipv4_config); for (i = 0; dns && dns[i]; i++) { if ( ip4_string_to_num (dns[i], &address_network) && address_network > 0) { @@ -955,13 +972,13 @@ stage3_ip6_done (NMModemBroadband *self) const gchar **dns; guint i; - g_assert (self->priv->ipv6_config); + g_assert (self->_priv.ipv6_config); memset (&address, 0, sizeof (address)); - ip_method = get_bearer_ip_method (self->priv->ipv6_config); + ip_method = get_bearer_ip_method (self->_priv.ipv6_config); - address_string = mm_bearer_ip_config_get_address (self->priv->ipv6_config); + address_string = mm_bearer_ip_config_get_address (self->_priv.ipv6_config); if (!address_string) { /* DHCP/SLAAC is allowed to skip addresses; other methods require it */ if (ip_method != NM_MODEM_IP_METHOD_AUTO) { @@ -985,17 +1002,17 @@ stage3_ip6_done (NMModemBroadband *self) _LOGI ("IPv6 base configuration:"); - data_port = mm_bearer_get_interface (self->priv->bearer); + data_port = mm_bearer_get_interface (self->_priv.bearer); g_assert (data_port); config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); - address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv6_config); + address.plen = mm_bearer_ip_config_get_prefix (self->_priv.ipv6_config); if (address.plen <= 128) nm_ip6_config_add_address (config, &address); _LOGI (" address %s/%d", address_string, address.plen); - address_string = mm_bearer_ip_config_get_gateway (self->priv->ipv6_config); + address_string = mm_bearer_ip_config_get_gateway (self->_priv.ipv6_config); if (address_string) { if (!inet_pton (AF_INET6, address_string, (void *) &(address.address))) { error = g_error_new (NM_DEVICE_ERROR, @@ -1017,7 +1034,7 @@ stage3_ip6_done (NMModemBroadband *self) } /* DNS servers */ - dns = mm_bearer_ip_config_get_dns (self->priv->ipv6_config); + dns = mm_bearer_ip_config_get_dns (self->_priv.ipv6_config); for (i = 0; dns[i]; i++) { struct in6_addr addr; @@ -1125,14 +1142,14 @@ disconnect (NMModem *modem, } /* If no simple iface, we're done */ - if (!ctx->self->priv->simple_iface) { + if (!ctx->self->_priv.simple_iface) { disconnect_context_complete (ctx); return; } _LOGD ("notifying ModemManager about the modem disconnection"); ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL; - mm_modem_simple_disconnect (ctx->self->priv->simple_iface, + mm_modem_simple_disconnect (ctx->self->_priv.simple_iface, NULL, /* bearer path; if NULL given ALL get disconnected */ cancellable, (GAsyncReadyCallback) simple_disconnect_ready, @@ -1149,11 +1166,11 @@ deactivate_cleanup (NMModem *_self, NMDevice *device) /* TODO: cancel SimpleConnect() if any */ /* Cleanup IPv4 addresses and routes */ - g_clear_object (&self->priv->ipv4_config); - g_clear_object (&self->priv->ipv6_config); - g_clear_object (&self->priv->bearer); + g_clear_object (&self->_priv.ipv4_config); + g_clear_object (&self->_priv.ipv6_config); + g_clear_object (&self->_priv.bearer); - self->priv->pin_tries = 0; + self->_priv.pin_tries = 0; /* Chain up parent's */ NM_MODEM_CLASS (nm_modem_broadband_parent_class)->deactivate_cleanup (_self, device); @@ -1202,7 +1219,7 @@ modem_state_changed (MMModem *modem, mm_state_to_nm (new_state), mm_modem_state_change_reason_get_string (reason)); - if (self->priv->ctx && self->priv->ctx->step == CONNECT_STEP_WAIT_FOR_READY) + if (self->_priv.ctx && self->_priv.ctx->step == CONNECT_STEP_WAIT_FOR_READY) connect_context_step (self); } @@ -1223,40 +1240,6 @@ mm_ip_family_to_nm (MMBearerIpFamily family) return nm_type; } -NMModem * -nm_modem_broadband_new (GObject *object, GError **error) -{ - NMModem *modem; - MMObject *modem_object; - MMModem *modem_iface; - gchar *drivers; - - g_return_val_if_fail (MM_IS_OBJECT (object), NULL); - modem_object = MM_OBJECT (object); - - /* Ensure we have the 'Modem' interface and the primary port at least */ - modem_iface = mm_object_peek_modem (modem_object); - g_return_val_if_fail (!!modem_iface, NULL); - g_return_val_if_fail (!!mm_modem_get_primary_port (modem_iface), NULL); - - /* Build a single string with all drivers listed */ - drivers = g_strjoinv (", ", (gchar **)mm_modem_get_drivers (modem_iface)); - - modem = g_object_new (NM_TYPE_MODEM_BROADBAND, - NM_MODEM_PATH, mm_object_get_path (modem_object), - NM_MODEM_UID, mm_modem_get_primary_port (modem_iface), - NM_MODEM_CONTROL_PORT, mm_modem_get_primary_port (modem_iface), - NM_MODEM_DATA_PORT, NULL, /* We don't know it until bearer created */ - NM_MODEM_IP_TYPES, mm_ip_family_to_nm (mm_modem_get_supported_ip_families (modem_iface)), - NM_MODEM_STATE, mm_state_to_nm (mm_modem_get_state (modem_iface)), - NM_MODEM_DEVICE_ID, mm_modem_get_device_identifier (modem_iface), - NM_MODEM_BROADBAND_MODEM, modem_object, - NM_MODEM_DRIVER, drivers, - NULL); - g_free (drivers); - return modem; -} - static void get_sim_ready (MMModem *modem, GAsyncResult *res, @@ -1267,20 +1250,20 @@ get_sim_ready (MMModem *modem, new_sim = mm_modem_get_sim_finish (modem, res, &error); - if (new_sim != self->priv->sim_iface) { - g_clear_object (&self->priv->sim_iface); - self->priv->sim_iface = new_sim; + if (new_sim != self->_priv.sim_iface) { + g_clear_object (&self->_priv.sim_iface); + self->_priv.sim_iface = new_sim; } else g_clear_object (&new_sim); - if (self->priv->sim_iface) { + if (self->_priv.sim_iface) { g_object_set (G_OBJECT (self), - NM_MODEM_SIM_ID, mm_sim_get_identifier (self->priv->sim_iface), - NM_MODEM_SIM_OPERATOR_ID, mm_sim_get_operator_identifier (self->priv->sim_iface), + NM_MODEM_SIM_ID, mm_sim_get_identifier (self->_priv.sim_iface), + NM_MODEM_SIM_OPERATOR_ID, mm_sim_get_operator_identifier (self->_priv.sim_iface), NULL); /* If we're waiting for the SIM during a connect, proceed with the connect */ - if (self->priv->ctx && self->priv->ctx->step == CONNECT_STEP_WAIT_FOR_SIM) + if (self->_priv.ctx && self->_priv.ctx->step == CONNECT_STEP_WAIT_FOR_SIM) connect_context_step (self); } else { _NMLOG (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND) @@ -1297,10 +1280,10 @@ sim_changed (MMModem *modem, GParamSpec *pspec, gpointer user_data) { NMModemBroadband *self = NM_MODEM_BROADBAND (user_data); - g_return_if_fail (modem == self->priv->modem_iface); + g_return_if_fail (modem == self->_priv.modem_iface); - if (mm_modem_get_sim_path (self->priv->modem_iface)) { - mm_modem_get_sim (self->priv->modem_iface, + if (mm_modem_get_sim_path (self->_priv.modem_iface)) { + mm_modem_get_sim (self->_priv.modem_iface, NULL, /* cancellable */ (GAsyncReadyCallback) get_sim_ready, g_object_ref (self)); @@ -1316,7 +1299,7 @@ supported_ip_families_changed (MMModem *modem, GParamSpec *pspec, gpointer user_ { NMModemBroadband *self = NM_MODEM_BROADBAND (user_data); - g_return_if_fail (modem == self->priv->modem_iface); + g_return_if_fail (modem == self->_priv.modem_iface); g_object_set (G_OBJECT (self), NM_MODEM_IP_TYPES, @@ -1324,12 +1307,24 @@ supported_ip_families_changed (MMModem *modem, GParamSpec *pspec, gpointer user_ NULL); } +/*****************************************************************************/ + static void -nm_modem_broadband_init (NMModemBroadband *self) +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - NM_TYPE_MODEM_BROADBAND, - NMModemBroadbandPrivate); + NMModemBroadband *self = NM_MODEM_BROADBAND (object); + + switch (prop_id) { + case PROP_MODEM: + g_value_set_object (value, self->_priv.modem_object); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void @@ -1343,19 +1338,19 @@ set_property (GObject *object, switch (prop_id) { case PROP_MODEM: /* construct-only */ - self->priv->modem_object = g_value_dup_object (value); - self->priv->modem_iface = mm_object_get_modem (self->priv->modem_object); - g_assert (self->priv->modem_iface != NULL); - g_signal_connect (self->priv->modem_iface, + self->_priv.modem_object = g_value_dup_object (value); + self->_priv.modem_iface = mm_object_get_modem (self->_priv.modem_object); + g_assert (self->_priv.modem_iface != NULL); + g_signal_connect (self->_priv.modem_iface, "state-changed", G_CALLBACK (modem_state_changed), self); - g_signal_connect (self->priv->modem_iface, + g_signal_connect (self->_priv.modem_iface, "notify::sim", G_CALLBACK (sim_changed), self); - sim_changed (self->priv->modem_iface, NULL, self); - g_signal_connect (self->priv->modem_iface, + sim_changed (self->_priv.modem_iface, NULL, self); + g_signal_connect (self->_priv.modem_iface, "notify::supported-ip-families", G_CALLBACK (supported_ip_families_changed), self); @@ -1369,22 +1364,45 @@ set_property (GObject *object, } } +/*****************************************************************************/ + static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +nm_modem_broadband_init (NMModemBroadband *self) { - NMModemBroadband *self = NM_MODEM_BROADBAND (object); +} - switch (prop_id) { - case PROP_MODEM: - g_value_set_object (value, self->priv->modem_object); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } +NMModem * +nm_modem_broadband_new (GObject *object, GError **error) +{ + NMModem *modem; + MMObject *modem_object; + MMModem *modem_iface; + gchar *drivers; + + g_return_val_if_fail (MM_IS_OBJECT (object), NULL); + modem_object = MM_OBJECT (object); + + /* Ensure we have the 'Modem' interface and the primary port at least */ + modem_iface = mm_object_peek_modem (modem_object); + g_return_val_if_fail (!!modem_iface, NULL); + g_return_val_if_fail (!!mm_modem_get_primary_port (modem_iface), NULL); + + /* Build a single string with all drivers listed */ + drivers = g_strjoinv (", ", (gchar **)mm_modem_get_drivers (modem_iface)); + + modem = g_object_new (NM_TYPE_MODEM_BROADBAND, + NM_MODEM_PATH, mm_object_get_path (modem_object), + NM_MODEM_UID, mm_modem_get_primary_port (modem_iface), + NM_MODEM_CONTROL_PORT, mm_modem_get_primary_port (modem_iface), + NM_MODEM_DATA_PORT, NULL, /* We don't know it until bearer created */ + NM_MODEM_IP_TYPES, mm_ip_family_to_nm (mm_modem_get_supported_ip_families (modem_iface)), + NM_MODEM_STATE, (int) mm_state_to_nm (mm_modem_get_state (modem_iface)), + NM_MODEM_DEVICE_ID, mm_modem_get_device_identifier (modem_iface), + NM_MODEM_BROADBAND_MODEM, modem_object, + NM_MODEM_DRIVER, drivers, + NULL); + g_free (drivers); + return modem; } static void @@ -1393,13 +1411,13 @@ dispose (GObject *object) NMModemBroadband *self = NM_MODEM_BROADBAND (object); connect_context_clear (self); - g_clear_object (&self->priv->ipv4_config); - g_clear_object (&self->priv->ipv6_config); - g_clear_object (&self->priv->bearer); - g_clear_object (&self->priv->modem_iface); - g_clear_object (&self->priv->simple_iface); - g_clear_object (&self->priv->sim_iface); - g_clear_object (&self->priv->modem_object); + g_clear_object (&self->_priv.ipv4_config); + g_clear_object (&self->_priv.ipv6_config); + g_clear_object (&self->_priv.bearer); + g_clear_object (&self->_priv.modem_iface); + g_clear_object (&self->_priv.simple_iface); + g_clear_object (&self->_priv.sim_iface); + g_clear_object (&self->_priv.modem_object); G_OBJECT_CLASS (nm_modem_broadband_parent_class)->dispose (object); } @@ -1410,9 +1428,6 @@ nm_modem_broadband_class_init (NMModemBroadbandClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMModemClass *modem_class = NM_MODEM_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMModemBroadbandPrivate)); - - /* Virtual methods */ object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; @@ -1430,11 +1445,11 @@ nm_modem_broadband_class_init (NMModemBroadbandClass *klass) modem_class->act_stage1_prepare = act_stage1_prepare; modem_class->owns_port = owns_port; - /* Properties */ - g_object_class_install_property - (object_class, PROP_MODEM, - g_param_spec_object (NM_MODEM_BROADBAND_MODEM, "", "", - MM_GDBUS_TYPE_OBJECT, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_MODEM] = + g_param_spec_object (NM_MODEM_BROADBAND_MODEM, "", "", + MM_GDBUS_TYPE_OBJECT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/devices/wwan/nm-modem-broadband.h b/src/devices/wwan/nm-modem-broadband.h index 6607f7f5..4948cb3b 100644 --- a/src/devices/wwan/nm-modem-broadband.h +++ b/src/devices/wwan/nm-modem-broadband.h @@ -30,18 +30,8 @@ #define NM_IS_MODEM_BROADBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_MODEM_BROADBAND)) #define NM_MODEM_BROADBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MODEM_BROADBAND, NMModemBroadbandClass)) -typedef struct _NMModemBroadband NMModemBroadband; -typedef struct _NMModemBroadbandClass NMModemBroadbandClass; -typedef struct _NMModemBroadbandPrivate NMModemBroadbandPrivate; - -struct _NMModemBroadband { - NMModem parent; - NMModemBroadbandPrivate *priv; -}; - -struct _NMModemBroadbandClass { - NMModemClass parent; -}; +typedef struct _NMModemBroadband NMModemBroadband; +typedef struct _NMModemBroadbandClass NMModemBroadbandClass; GType nm_modem_broadband_get_type (void); diff --git a/src/devices/wwan/nm-modem-enum-types.c b/src/devices/wwan/nm-modem-enum-types.c deleted file mode 100644 index f999b084..00000000 --- a/src/devices/wwan/nm-modem-enum-types.c +++ /dev/null @@ -1,87 +0,0 @@ - - - -/* Generated by glib-mkenums. Do not edit */ - -#include "config.h" - -#include "nm-modem-enum-types.h" -#include "nm-default.h" - -#include "nm-modem.h" - -GType -nm_modem_ip_method_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_MODEM_IP_METHOD_UNKNOWN, "NM_MODEM_IP_METHOD_UNKNOWN", "unknown" }, - { NM_MODEM_IP_METHOD_PPP, "NM_MODEM_IP_METHOD_PPP", "ppp" }, - { NM_MODEM_IP_METHOD_STATIC, "NM_MODEM_IP_METHOD_STATIC", "static" }, - { NM_MODEM_IP_METHOD_AUTO, "NM_MODEM_IP_METHOD_AUTO", "auto" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMModemIPMethod"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_modem_ip_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_MODEM_IP_TYPE_UNKNOWN, "NM_MODEM_IP_TYPE_UNKNOWN", "unknown" }, - { NM_MODEM_IP_TYPE_IPV4, "NM_MODEM_IP_TYPE_IPV4", "ipv4" }, - { NM_MODEM_IP_TYPE_IPV6, "NM_MODEM_IP_TYPE_IPV6", "ipv6" }, - { NM_MODEM_IP_TYPE_IPV4V6, "NM_MODEM_IP_TYPE_IPV4V6", "ipv4v6" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMModemIPType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_modem_state_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_MODEM_STATE_UNKNOWN, "NM_MODEM_STATE_UNKNOWN", "unknown" }, - { NM_MODEM_STATE_FAILED, "NM_MODEM_STATE_FAILED", "failed" }, - { NM_MODEM_STATE_INITIALIZING, "NM_MODEM_STATE_INITIALIZING", "initializing" }, - { NM_MODEM_STATE_LOCKED, "NM_MODEM_STATE_LOCKED", "locked" }, - { NM_MODEM_STATE_DISABLED, "NM_MODEM_STATE_DISABLED", "disabled" }, - { NM_MODEM_STATE_DISABLING, "NM_MODEM_STATE_DISABLING", "disabling" }, - { NM_MODEM_STATE_ENABLING, "NM_MODEM_STATE_ENABLING", "enabling" }, - { NM_MODEM_STATE_ENABLED, "NM_MODEM_STATE_ENABLED", "enabled" }, - { NM_MODEM_STATE_SEARCHING, "NM_MODEM_STATE_SEARCHING", "searching" }, - { NM_MODEM_STATE_REGISTERED, "NM_MODEM_STATE_REGISTERED", "registered" }, - { NM_MODEM_STATE_DISCONNECTING, "NM_MODEM_STATE_DISCONNECTING", "disconnecting" }, - { NM_MODEM_STATE_CONNECTING, "NM_MODEM_STATE_CONNECTING", "connecting" }, - { NM_MODEM_STATE_CONNECTED, "NM_MODEM_STATE_CONNECTED", "connected" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMModemState"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} - - - diff --git a/src/devices/wwan/nm-modem-enum-types.h b/src/devices/wwan/nm-modem-enum-types.h deleted file mode 100644 index ccbe6201..00000000 --- a/src/devices/wwan/nm-modem-enum-types.h +++ /dev/null @@ -1,23 +0,0 @@ - - - -/* Generated by glib-mkenums. Do not edit */ - -#ifndef __NM_MODEM_ENUM_TYPES_H__ -#define __NM_MODEM_ENUM_TYPES_H__ - -#include - -G_BEGIN_DECLS -GType nm_modem_ip_method_get_type (void) G_GNUC_CONST; -#define NM_TYPE_MODEM_IP_METHOD (nm_modem_ip_method_get_type ()) -GType nm_modem_ip_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_MODEM_IP_TYPE (nm_modem_ip_type_get_type ()) -GType nm_modem_state_get_type (void) G_GNUC_CONST; -#define NM_TYPE_MODEM_STATE (nm_modem_state_get_type ()) -G_END_DECLS - -#endif /* __NM_MODEM_ENUM_TYPES_H__ */ - - - diff --git a/src/devices/wwan/nm-modem-manager.c b/src/devices/wwan/nm-modem-manager.c index 964485fc..b1f6d92e 100644 --- a/src/devices/wwan/nm-modem-manager.c +++ b/src/devices/wwan/nm-modem-manager.c @@ -43,9 +43,16 @@ #define MODEM_POKE_INTERVAL 120 -G_DEFINE_TYPE (NMModemManager, nm_modem_manager, G_TYPE_OBJECT) +/*****************************************************************************/ -struct _NMModemManagerPrivate { +enum { + MODEM_ADDED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct { GDBusConnection *dbus_connection; MMManager *modem_manager; guint mm_launch_id; @@ -57,17 +64,23 @@ struct _NMModemManagerPrivate { GDBusProxy *ofono_proxy; #endif - /* Common */ GHashTable *modems; +} NMModemManagerPrivate; + +struct _NMModemManager { + GObject parent; + NMModemManagerPrivate _priv; }; -enum { - MODEM_ADDED, - LAST_SIGNAL, +struct _NMModemManagerClass { + GObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; -/************************************************************************/ +G_DEFINE_TYPE (NMModemManager, nm_modem_manager, G_TYPE_OBJECT) + +#define NM_MODEM_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMModemManager, NM_IS_MODEM_MANAGER) + +/*****************************************************************************/ static void handle_new_modem (NMModemManager *self, NMModem *modem) @@ -75,13 +88,13 @@ handle_new_modem (NMModemManager *self, NMModem *modem) const char *path; path = nm_modem_get_path (modem); - if (g_hash_table_lookup (self->priv->modems, path)) { + if (g_hash_table_lookup (self->_priv.modems, path)) { g_warn_if_reached (); return; } /* Track the new modem */ - g_hash_table_insert (self->priv->modems, g_strdup (path), modem); + g_hash_table_insert (self->_priv.modems, g_strdup (path), modem); g_signal_emit (self, signals[MODEM_ADDED], 0, modem); } @@ -95,12 +108,12 @@ remove_one_modem (gpointer key, gpointer value, gpointer user_data) static void clear_modem_manager (NMModemManager *self) { - if (!self->priv->modem_manager) + if (!self->_priv.modem_manager) return; - nm_clear_g_signal_handler (self->priv->modem_manager, &self->priv->mm_name_owner_changed_id); - nm_clear_g_signal_handler (self->priv->modem_manager, &self->priv->mm_object_added_id); - nm_clear_g_signal_handler (self->priv->modem_manager, &self->priv->mm_object_removed_id); - g_clear_object (&self->priv->modem_manager); + nm_clear_g_signal_handler (self->_priv.modem_manager, &self->_priv.mm_name_owner_changed_id); + nm_clear_g_signal_handler (self->_priv.modem_manager, &self->_priv.mm_object_added_id); + nm_clear_g_signal_handler (self->_priv.modem_manager, &self->_priv.mm_object_removed_id); + g_clear_object (&self->_priv.modem_manager); } static void @@ -115,7 +128,7 @@ modem_object_added (MMManager *modem_manager, /* Ensure we don't have the same modem already */ path = mm_object_get_path (modem_object); - if (g_hash_table_lookup (self->priv->modems, path)) { + if (g_hash_table_lookup (self->_priv.modems, path)) { nm_log_warn (LOGD_MB, "modem with path %s already exists, ignoring", path); return; } @@ -153,12 +166,12 @@ modem_object_removed (MMManager *manager, const gchar *path; path = mm_object_get_path (modem_object); - modem = (NMModem *) g_hash_table_lookup (self->priv->modems, path); + modem = (NMModem *) g_hash_table_lookup (self->_priv.modems, path); if (!modem) return; nm_modem_emit_removed (modem); - g_hash_table_remove (self->priv->modems, path); + g_hash_table_remove (self->_priv.modems, path); } static void @@ -169,9 +182,9 @@ modem_manager_available (NMModemManager *self) nm_log_info (LOGD_MB, "ModemManager available in the bus"); /* Update initial modems list */ - modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (self->priv->modem_manager)); + modems = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (self->_priv.modem_manager)); for (l = modems; l; l = g_list_next (l)) - modem_object_added (self->priv->modem_manager, MM_OBJECT (l->data), self); + modem_object_added (self->_priv.modem_manager, MM_OBJECT (l->data), self); g_list_free_full (modems, (GDestroyNotify) g_object_unref); } @@ -187,7 +200,7 @@ modem_manager_name_owner_changed (MMManager *modem_manager, gchar *name_owner; /* Quit poking, if any */ - nm_clear_g_source (&self->priv->mm_launch_id); + nm_clear_g_source (&self->_priv.mm_launch_id); name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (modem_manager)); if (!name_owner) { @@ -226,7 +239,7 @@ ofono_create_modem (NMModemManager *self, const char *path) * receive ModemAdded signals before GetModems() returns, so some of the * modems returned from GetModems() may already have been created. */ - if (!g_hash_table_lookup (self->priv->modems, path)) { + if (!g_hash_table_lookup (self->_priv.modems, path)) { modem = nm_modem_ofono_new (path); if (modem) handle_new_modem (self, modem); @@ -256,10 +269,10 @@ ofono_signal_cb (GDBusProxy *proxy, g_variant_get (parameters, "(o)", &object_path); nm_log_info (LOGD_MB, "oFono modem removed: %s", object_path); - modem = (NMModem *) g_hash_table_lookup (self->priv->modems, object_path); + modem = (NMModem *) g_hash_table_lookup (self->_priv.modems, object_path); if (modem) { nm_modem_emit_removed (modem); - g_hash_table_remove (self->priv->modems, object_path); + g_hash_table_remove (self->_priv.modems, object_path); } else { nm_log_warn (LOGD_MB, "could not remove modem %s, not found in table", object_path); @@ -297,11 +310,11 @@ ofono_check_name_owner (NMModemManager *self) { gs_free char *name_owner = NULL; - name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (self->priv->ofono_proxy)); + name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (self->_priv.ofono_proxy)); if (name_owner) { nm_log_info (LOGD_MB, "oFono is now available"); - g_dbus_proxy_call (self->priv->ofono_proxy, + g_dbus_proxy_call (self->_priv.ofono_proxy, "GetModems", NULL, G_DBUS_CALL_FLAGS_NONE, @@ -316,7 +329,7 @@ ofono_check_name_owner (NMModemManager *self) nm_log_info (LOGD_MB, "oFono disappeared from bus"); /* Remove any oFono modems that might be left around */ - g_hash_table_iter_init (&iter, self->priv->modems); + g_hash_table_iter_init (&iter, self->_priv.modems); while (g_hash_table_iter_next (&iter, NULL, (gpointer) &modem)) { if (NM_IS_MODEM_OFONO (modem)) { nm_modem_emit_removed (modem); @@ -340,18 +353,18 @@ ofono_proxy_new_cb (GObject *source_object, GAsyncResult *res, gpointer user_dat gs_unref_object NMModemManager *self = NM_MODEM_MANAGER (user_data); gs_free_error GError *error = NULL; - self->priv->ofono_proxy = g_dbus_proxy_new_finish (res, &error); + self->_priv.ofono_proxy = g_dbus_proxy_new_finish (res, &error); if (error) { nm_log_warn (LOGD_MB, "error getting oFono bus proxy: %s", error->message); return; } - g_signal_connect (self->priv->ofono_proxy, + g_signal_connect (self->_priv.ofono_proxy, "notify::g-name-owner", G_CALLBACK (ofono_name_owner_changed), self); - g_signal_connect (self->priv->ofono_proxy, + g_signal_connect (self->_priv.ofono_proxy, "g-signal", G_CALLBACK (ofono_signal_cb), self); @@ -362,8 +375,8 @@ ofono_proxy_new_cb (GObject *source_object, GAsyncResult *res, gpointer user_dat static void ensure_ofono_client (NMModemManager *self) { - g_assert (self->priv->dbus_connection); - g_dbus_proxy_new (self->priv->dbus_connection, + g_assert (self->_priv.dbus_connection); + g_dbus_proxy_new (self->_priv.dbus_connection, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, OFONO_DBUS_SERVICE, @@ -408,7 +421,7 @@ static void modem_manager_poke (NMModemManager *self) { /* If there is no current owner right away, ensure we poke to get one */ - g_dbus_connection_call (self->priv->dbus_connection, + g_dbus_connection_call (self->_priv.dbus_connection, "org.freedesktop.ModemManager1", "/org/freedesktop/ModemManager1", DBUS_INTERFACE_PEER, @@ -427,7 +440,7 @@ modem_manager_check_name_owner (NMModemManager *self) { gs_free gchar *name_owner = NULL; - name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (self->priv->modem_manager)); + name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (self->_priv.modem_manager)); if (name_owner) { /* Available! */ modem_manager_available (self); @@ -448,10 +461,10 @@ manager_new_ready (GObject *source, GError *error = NULL; - g_return_if_fail (!self->priv->modem_manager); + g_return_if_fail (!self->_priv.modem_manager); - self->priv->modem_manager = mm_manager_new_finish (res, &error); - if (!self->priv->modem_manager) { + self->_priv.modem_manager = mm_manager_new_finish (res, &error); + if (!self->_priv.modem_manager) { /* We're not really supposed to get any error here. If we do get one, * though, just re-schedule the MMManager creation after some time. * During this period, name-owner changes won't be followed. */ @@ -461,18 +474,18 @@ manager_new_ready (GObject *source, schedule_modem_manager_relaunch (self, MODEM_POKE_INTERVAL); } else { /* Setup signals in the GDBusObjectManagerClient */ - self->priv->mm_name_owner_changed_id = - g_signal_connect (self->priv->modem_manager, + self->_priv.mm_name_owner_changed_id = + g_signal_connect (self->_priv.modem_manager, "notify::name-owner", G_CALLBACK (modem_manager_name_owner_changed), self); - self->priv->mm_object_added_id = - g_signal_connect (self->priv->modem_manager, + self->_priv.mm_object_added_id = + g_signal_connect (self->_priv.modem_manager, "object-added", G_CALLBACK (modem_object_added), self); - self->priv->mm_object_removed_id = - g_signal_connect (self->priv->modem_manager, + self->_priv.mm_object_removed_id = + g_signal_connect (self->_priv.modem_manager, "object-removed", G_CALLBACK (modem_object_removed), self); @@ -487,13 +500,13 @@ manager_new_ready (GObject *source, static void ensure_modem_manager (NMModemManager *self) { - g_assert (self->priv->dbus_connection); + g_assert (self->_priv.dbus_connection); /* Create the GDBusObjectManagerClient. We do not request to autostart, as * we don't really want the MMManager creation to fail. We can always poke * later on if we want to request the autostart */ - if (!self->priv->modem_manager) { - mm_manager_new (self->priv->dbus_connection, + if (!self->_priv.modem_manager) { + mm_manager_new (self->_priv.dbus_connection, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START, NULL, (GAsyncReadyCallback)manager_new_ready, @@ -508,7 +521,7 @@ ensure_modem_manager (NMModemManager *self) static gboolean mm_launch_cb (NMModemManager *self) { - self->priv->mm_launch_id = 0; + self->_priv.mm_launch_id = 0; ensure_modem_manager (self); return G_SOURCE_REMOVE; } @@ -520,9 +533,9 @@ schedule_modem_manager_relaunch (NMModemManager *self, /* No need to pass an extra reference to self; timeout/idle will be * cancelled if the object gets disposed. */ if (n_seconds) - self->priv->mm_launch_id = g_timeout_add_seconds (n_seconds, (GSourceFunc)mm_launch_cb, self); + self->_priv.mm_launch_id = g_timeout_add_seconds (n_seconds, (GSourceFunc)mm_launch_cb, self); else - self->priv->mm_launch_id = g_idle_add ((GSourceFunc)mm_launch_cb, self); + self->_priv.mm_launch_id = g_idle_add ((GSourceFunc)mm_launch_cb, self); } static void @@ -533,8 +546,8 @@ bus_get_ready (GObject *source, gs_unref_object NMModemManager *self = NM_MODEM_MANAGER (user_data); gs_free_error GError *error = NULL; - self->priv->dbus_connection = g_bus_get_finish (res, &error); - if (!self->priv->dbus_connection) { + self->_priv.dbus_connection = g_bus_get_finish (res, &error); + if (!self->_priv.dbus_connection) { nm_log_warn (LOGD_MB, "error getting bus connection: %s", error->message); return; } @@ -546,16 +559,13 @@ bus_get_ready (GObject *source, #endif } -/************************************************************************/ +/*****************************************************************************/ static void nm_modem_manager_init (NMModemManager *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_MODEM_MANAGER, NMModemManagerPrivate); + self->_priv.modems = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - self->priv->modems = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - - // FIXME: this doesn't handle bus-daemon restart g_bus_get (G_BUS_TYPE_SYSTEM, NULL, (GAsyncReadyCallback)bus_get_ready, @@ -567,26 +577,25 @@ dispose (GObject *object) { NMModemManager *self = NM_MODEM_MANAGER (object); - nm_clear_g_source (&self->priv->mm_launch_id); + nm_clear_g_source (&self->_priv.mm_launch_id); clear_modem_manager (self); #if WITH_OFONO - if (self->priv->ofono_proxy) { - g_signal_handlers_disconnect_by_func (self->priv->ofono_proxy, ofono_name_owner_changed, self); - g_signal_handlers_disconnect_by_func (self->priv->ofono_proxy, ofono_signal_cb, self); - g_clear_object (&self->priv->ofono_proxy); + if (self->_priv.ofono_proxy) { + g_signal_handlers_disconnect_by_func (self->_priv.ofono_proxy, ofono_name_owner_changed, self); + g_signal_handlers_disconnect_by_func (self->_priv.ofono_proxy, ofono_signal_cb, self); + g_clear_object (&self->_priv.ofono_proxy); } #endif - g_clear_object (&self->priv->dbus_connection); + g_clear_object (&self->_priv.dbus_connection); - if (self->priv->modems) { - g_hash_table_foreach_remove (self->priv->modems, remove_one_modem, object); - g_hash_table_destroy (self->priv->modems); + if (self->_priv.modems) { + g_hash_table_foreach_remove (self->_priv.modems, remove_one_modem, object); + g_hash_table_destroy (self->_priv.modems); } - /* Chain up to the parent class */ G_OBJECT_CLASS (nm_modem_manager_parent_class)->dispose (object); } @@ -595,15 +604,12 @@ nm_modem_manager_class_init (NMModemManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMModemManagerPrivate)); - object_class->dispose = dispose; signals[MODEM_ADDED] = - g_signal_new (NM_MODEM_MANAGER_MODEM_ADDED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemManagerClass, modem_added), - NULL, NULL, NULL, - G_TYPE_NONE, 1, NM_TYPE_MODEM); + g_signal_new (NM_MODEM_MANAGER_MODEM_ADDED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, NM_TYPE_MODEM); } diff --git a/src/devices/wwan/nm-modem-manager.h b/src/devices/wwan/nm-modem-manager.h index b0014c6a..65594dfa 100644 --- a/src/devices/wwan/nm-modem-manager.h +++ b/src/devices/wwan/nm-modem-manager.h @@ -25,23 +25,17 @@ #include "nm-modem.h" -#define NM_TYPE_MODEM_MANAGER (nm_modem_manager_get_type ()) -#define NM_MODEM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MODEM_MANAGER, NMModemManager)) +#define NM_TYPE_MODEM_MANAGER (nm_modem_manager_get_type ()) +#define NM_MODEM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MODEM_MANAGER, NMModemManager)) +#define NM_MODEM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_MODEM_MANAGER, NMModemManagerClass)) +#define NM_IS_MODEM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_MODEM_MANAGER)) +#define NM_IS_MODEM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_MODEM_MANAGER)) +#define NM_MODEM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MODEM_MANAGER, NMModemManagerClass)) #define NM_MODEM_MANAGER_MODEM_ADDED "modem-added" -typedef struct _NMModemManagerPrivate NMModemManagerPrivate; - -typedef struct { - GObject parent; - NMModemManagerPrivate *priv; -} NMModemManager; - -typedef struct { - GObjectClass parent; - - void (*modem_added) (NMModemManager *self, NMModem *modem); -} NMModemManagerClass; +typedef struct _NMModemManager NMModemManager; +typedef struct _NMModemManagerClass NMModemManagerClass; GType nm_modem_manager_get_type (void); diff --git a/src/devices/wwan/nm-modem-ofono.c b/src/devices/wwan/nm-modem-ofono.c index 86492d3d..41d422aa 100644 --- a/src/devices/wwan/nm-modem-ofono.c +++ b/src/devices/wwan/nm-modem-ofono.c @@ -25,13 +25,10 @@ #include #include "nm-core-internal.h" -#include "nm-device-private.h" +#include "devices/nm-device-private.h" #include "nm-modem.h" -#include "nm-platform.h" - -G_DEFINE_TYPE (NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM) - -#define NM_MODEM_OFONO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MODEM_OFONO, NMModemOfonoPrivate)) +#include "platform/nm-platform.h" +#include "nm-ip4-config.h" #define VARIANT_IS_OF_TYPE_BOOLEAN(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_BOOLEAN) )) #define VARIANT_IS_OF_TYPE_STRING(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_STRING) )) @@ -39,6 +36,8 @@ G_DEFINE_TYPE (NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM) #define VARIANT_IS_OF_TYPE_STRING_ARRAY(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_STRING_ARRAY) )) #define VARIANT_IS_OF_TYPE_DICTIONARY(v) ((v) != NULL && ( g_variant_is_of_type ((v), G_VARIANT_TYPE_DICTIONARY) )) +/*****************************************************************************/ + typedef struct { GHashTable *connect_properties; @@ -58,6 +57,19 @@ typedef struct { NMIP4Config *ip4_config; } NMModemOfonoPrivate; +struct _NMModemOfono { + NMModem parent; + NMModemOfonoPrivate _priv; +}; + +struct _NMModemOfonoClass { + NMModemClass parent; +}; + +G_DEFINE_TYPE (NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM) + +#define NM_MODEM_OFONO_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMModemOfono, NM_IS_MODEM_OFONO) + /*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_MB @@ -239,7 +251,7 @@ disconnect (NMModem *modem, user_data, disconnect); } - /* Setup cancellable */ + ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL; if (disconnect_context_complete_if_cancelled (ctx)) return; @@ -261,17 +273,16 @@ disconnect (NMModem *modem, } static void -deactivate_cleanup (NMModem *_self, NMDevice *device) +deactivate_cleanup (NMModem *modem, NMDevice *device) { - NMModemOfono *self = NM_MODEM_OFONO (_self); + NMModemOfono *self = NM_MODEM_OFONO (modem); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); /* TODO: cancel SimpleConnect() if any */ g_clear_object (&priv->ip4_config); - /* Chain up parent's */ - NM_MODEM_CLASS (nm_modem_ofono_parent_class)->deactivate_cleanup (_self, device); + NM_MODEM_CLASS (nm_modem_ofono_parent_class)->deactivate_cleanup (modem, device); } @@ -700,30 +711,6 @@ modem_get_properties_done (GDBusProxy *proxy, GAsyncResult *result, gpointer use g_variant_unref (v_properties); } -NMModem * -nm_modem_ofono_new (const char *path) -{ - gs_free char *basename = NULL; - - g_return_val_if_fail (path != NULL, NULL); - - nm_log_info (LOGD_MB, "ofono: creating new Ofono modem path %s", path); - - /* Use short modem name (not its object path) as the NM device name (which - * comes from NM_MODEM_UID)and the device ID. - */ - basename = g_path_get_basename (path); - - return (NMModem *) g_object_new (NM_TYPE_MODEM_OFONO, - NM_MODEM_PATH, path, - NM_MODEM_UID, basename, - NM_MODEM_DEVICE_ID, basename, - NM_MODEM_CONTROL_PORT, "ofono", /* mandatory */ - NM_MODEM_DRIVER, "ofono", - NM_MODEM_STATE, NM_MODEM_STATE_INITIALIZING, - NULL); -} - static void stage1_prepare_done (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) { @@ -933,11 +920,11 @@ out: } static NMActStageReturn -static_stage3_ip4_config_start (NMModem *_self, +static_stage3_ip4_config_start (NMModem *modem, NMActRequest *req, NMDeviceStateReason *reason) { - NMModemOfono *self = NM_MODEM_OFONO (_self); + NMModemOfono *self = NM_MODEM_OFONO (modem); NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; GError *error = NULL; @@ -1123,6 +1110,8 @@ modem_proxy_new_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) g_object_ref (self)); } +/*****************************************************************************/ + static void nm_modem_ofono_init (NMModemOfono *self) { @@ -1144,6 +1133,30 @@ constructed (GObject *object) g_object_ref (self)); } +NMModem * +nm_modem_ofono_new (const char *path) +{ + gs_free char *basename = NULL; + + g_return_val_if_fail (path != NULL, NULL); + + nm_log_info (LOGD_MB, "ofono: creating new Ofono modem path %s", path); + + /* Use short modem name (not its object path) as the NM device name (which + * comes from NM_MODEM_UID)and the device ID. + */ + basename = g_path_get_basename (path); + + return (NMModem *) g_object_new (NM_TYPE_MODEM_OFONO, + NM_MODEM_PATH, path, + NM_MODEM_UID, basename, + NM_MODEM_DEVICE_ID, basename, + NM_MODEM_CONTROL_PORT, "ofono", /* mandatory */ + NM_MODEM_DRIVER, "ofono", + NM_MODEM_STATE, (int) NM_MODEM_STATE_INITIALIZING, + NULL); +} + static void dispose (GObject *object) { @@ -1182,9 +1195,6 @@ nm_modem_ofono_class_init (NMModemOfonoClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMModemClass *modem_class = NM_MODEM_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMModemOfonoPrivate)); - - /* Virtual methods */ object_class->constructed = constructed; object_class->dispose = dispose; @@ -1194,9 +1204,6 @@ nm_modem_ofono_class_init (NMModemOfonoClass *klass) modem_class->deactivate_cleanup = deactivate_cleanup; modem_class->check_connection_compatible = check_connection_compatible; - /* same as nm-modem-broadband */ modem_class->act_stage1_prepare = act_stage1_prepare; - - /* same as nm-modem-broadband */ modem_class->static_stage3_ip4_config_start = static_stage3_ip4_config_start; } diff --git a/src/devices/wwan/nm-modem-ofono.h b/src/devices/wwan/nm-modem-ofono.h index 5965526d..d9cb68ac 100644 --- a/src/devices/wwan/nm-modem-ofono.h +++ b/src/devices/wwan/nm-modem-ofono.h @@ -38,13 +38,8 @@ #define OFONO_DBUS_INTERFACE_CONNECTION_CONTEXT "org.ofono.ConnectionContext" #define OFONO_DBUS_INTERFACE_SIM_MANAGER "org.ofono.SimManager" -typedef struct { - NMModem parent; -} NMModemOfono; - -typedef struct { - NMModemClass parent; -} NMModemOfonoClass; +typedef struct _NMModemOfono NMModemOfono; +typedef struct _NMModemOfonoClass NMModemOfonoClass; GType nm_modem_ofono_get_type (void); diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 459d212a..04c95a2b 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -28,19 +28,20 @@ #include #include "nm-core-internal.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-setting-connection.h" #include "NetworkManagerUtils.h" -#include "nm-device-private.h" -#include "nm-modem-enum-types.h" +#include "devices/nm-device-private.h" #include "nm-route-manager.h" +#include "nm-act-request.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" +#include "ppp/nm-ppp-manager-call.h" +#include "ppp/nm-ppp-status.h" -G_DEFINE_TYPE (NMModem, nm_modem, G_TYPE_OBJECT) - -#define NM_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MODEM, NMModemPrivate)) +/*****************************************************************************/ -enum { - PROP_0, +NM_GOBJECT_PROPERTIES_DEFINE (NMModem, PROP_CONTROL_PORT, PROP_DATA_PORT, PROP_PATH, @@ -54,11 +55,24 @@ enum { PROP_SIM_ID, PROP_IP_TYPES, PROP_SIM_OPERATOR_ID, +); - LAST_PROP +enum { + PPP_STATS, + PPP_FAILED, + PREPARE_RESULT, + IP4_CONFIG_RESULT, + IP6_CONFIG_RESULT, + AUTH_REQUESTED, + AUTH_RESULT, + REMOVED, + STATE_CHANGED, + LAST_SIGNAL, }; -typedef struct { +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct _NMModemPrivate { char *uid; char *path; char *driver; @@ -88,22 +102,9 @@ typedef struct { guint32 out_bytes; } NMModemPrivate; -enum { - PPP_STATS, - PPP_FAILED, - PREPARE_RESULT, - IP4_CONFIG_RESULT, - IP6_CONFIG_RESULT, - AUTH_REQUESTED, - AUTH_RESULT, - REMOVED, - STATE_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_TYPE (NMModem, nm_modem, G_TYPE_OBJECT) +#define NM_MODEM_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMModem, NM_IS_MODEM) /*****************************************************************************/ /* State/enabled/connected */ @@ -156,8 +157,8 @@ nm_modem_set_state (NMModem *self, reason ? reason : "none"); priv->state = new_state; - g_object_notify (G_OBJECT (self), NM_MODEM_STATE); - g_signal_emit (self, signals[STATE_CHANGED], 0, new_state, old_state, reason); + _notify (self, PROP_STATE); + g_signal_emit (self, signals[STATE_CHANGED], 0, (int) new_state, (int) old_state, reason); } } @@ -399,7 +400,7 @@ set_data_port (NMModem *self, const char *new_data_port) if (g_strcmp0 (priv->data_port, new_data_port) != 0) { g_free (priv->data_port); priv->data_port = g_strdup (new_data_port); - g_object_notify (G_OBJECT (self), NM_MODEM_DATA_PORT); + _notify (self, PROP_DATA_PORT); } } @@ -558,18 +559,20 @@ ppp_stage3_ip_config_start (NMModem *self, if (port_speed_is_zero (priv->data_port)) baud_override = 57600; - priv->ppp_manager = nm_ppp_manager_new (priv->data_port); - if (nm_ppp_manager_start (priv->ppp_manager, req, ppp_name, ip_timeout, baud_override, &error)) { - g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED, + priv->ppp_manager = nm_ppp_manager_create (priv->data_port, &error); + if ( priv->ppp_manager + && nm_ppp_manager_start (priv->ppp_manager, req, ppp_name, + ip_timeout, baud_override, &error)) { + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, G_CALLBACK (ppp_state_changed), self); - g_signal_connect (priv->ppp_manager, "ip4-config", + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, G_CALLBACK (ppp_ip4_config), self); - g_signal_connect (priv->ppp_manager, "ip6-config", + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP6_CONFIG, G_CALLBACK (ppp_ip6_config), self); - g_signal_connect (priv->ppp_manager, "stats", + g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATS, G_CALLBACK (ppp_stats), self); @@ -580,7 +583,7 @@ ppp_stage3_ip_config_start (NMModem *self, error->message); g_error_free (error); - nm_exported_object_clear_and_unexport (&priv->ppp_manager); + g_clear_object (&priv->ppp_manager); *reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED; ret = NM_ACT_STAGE_RETURN_FAILURE; @@ -618,7 +621,7 @@ nm_modem_stage3_ip4_config_start (NMModem *self, /* Only Disabled and Auto methods make sense for WWAN */ if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) - return NM_ACT_STAGE_RETURN_STOP; + return NM_ACT_STAGE_RETURN_SUCCESS; if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) != 0) { nm_log_warn (LOGD_MB | LOGD_IP4, @@ -643,7 +646,7 @@ nm_modem_stage3_ip4_config_start (NMModem *self, break; default: nm_log_info (LOGD_MB, "(%s): IPv4 configuration disabled", nm_modem_get_uid (self)); - ret = NM_ACT_STAGE_RETURN_STOP; + ret = NM_ACT_STAGE_RETURN_IP_FAIL; break; } @@ -737,7 +740,7 @@ nm_modem_stage3_ip6_config_start (NMModem *self, /* Only Ignore and Auto methods make sense for WWAN */ if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) - return NM_ACT_STAGE_RETURN_STOP; + return NM_ACT_STAGE_RETURN_IP_DONE; if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) != 0) { nm_log_warn (LOGD_MB | LOGD_IP6, @@ -762,7 +765,7 @@ nm_modem_stage3_ip6_config_start (NMModem *self, break; default: nm_log_info (LOGD_MB, "(%s): IPv6 configuration disabled", nm_modem_get_uid (self)); - ret = NM_ACT_STAGE_RETURN_STOP; + ret = NM_ACT_STAGE_RETURN_IP_FAIL; break; } @@ -817,6 +820,7 @@ nm_modem_get_secrets (NMModem *self, if (request_new) flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; priv->secrets_id = nm_act_request_get_secrets (priv->act_request, + FALSE, setting_name, flags, hint, @@ -867,6 +871,7 @@ nm_modem_act_stage1_prepare (NMModem *self, flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; priv->secrets_id = nm_act_request_get_secrets (req, + FALSE, setting_name, flags, hints ? g_ptr_array_index (hints, 0) : NULL, @@ -1000,7 +1005,7 @@ deactivate_cleanup (NMModem *self, NMDevice *device) priv->in_bytes = priv->out_bytes = 0; - nm_exported_object_clear_and_unexport (&priv->ppp_manager); + g_clear_object (&priv->ppp_manager); if (device) { g_return_if_fail (NM_IS_DEVICE (device)); @@ -1136,10 +1141,10 @@ deactivate_step (DeactivateContext *ctx) case DEACTIVATE_CONTEXT_STEP_PPP_MANAGER_STOP: /* If we have a PPP manager, stop it */ if (ctx->ppp_manager) { - nm_ppp_manager_stop (ctx->ppp_manager, - ctx->cancellable, - (GAsyncReadyCallback) ppp_manager_stop_ready, - ctx); + nm_ppp_manager_stop_async (ctx->ppp_manager, + ctx->cancellable, + (GAsyncReadyCallback) ppp_manager_stop_ready, + ctx); return; } ctx->step++; @@ -1333,49 +1338,11 @@ nm_modem_get_capabilities (NMModem *self, /*****************************************************************************/ -static void -nm_modem_init (NMModem *self) -{ -} - -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMModemPrivate *priv; - - object = G_OBJECT_CLASS (nm_modem_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_MODEM_GET_PRIVATE (object); - - if (!priv->data_port && !priv->control_port) { - nm_log_err (LOGD_PLATFORM, "neither modem command nor data interface provided"); - goto err; - } - - if (!priv->path) { - nm_log_err (LOGD_PLATFORM, "D-Bus path not provided"); - goto err; - } - - return object; - -err: - g_object_unref (object); - return NULL; -} - static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (object); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE ((NMModem *) object); switch (prop_id) { case PROP_PATH: @@ -1403,7 +1370,7 @@ get_property (GObject *object, guint prop_id, g_value_set_uint (value, priv->mm_ip_timeout); break; case PROP_STATE: - g_value_set_enum (value, priv->state); + g_value_set_int (value, priv->state); break; case PROP_DEVICE_ID: g_value_set_string (value, priv->device_id); @@ -1427,7 +1394,7 @@ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (object); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE ((NMModem *) object); const char *s; switch (prop_id) { @@ -1440,9 +1407,11 @@ set_property (GObject *object, guint prop_id, priv->driver = g_value_dup_string (value); break; case PROP_CONTROL_PORT: + /* Construct only */ priv->control_port = g_value_dup_string (value); break; case PROP_DATA_PORT: + g_free (priv->data_port); priv->data_port = g_value_dup_string (value); break; case PROP_UID: @@ -1459,10 +1428,11 @@ set_property (GObject *object, guint prop_id, priv->mm_ip_timeout = g_value_get_uint (value); break; case PROP_STATE: - priv->state = g_value_get_enum (value); + /* construct-only */ + priv->state = g_value_get_int (value); break; case PROP_DEVICE_ID: - /* construct only */ + /* construct-only */ priv->device_id = g_value_dup_string (value); break; case PROP_SIM_ID: @@ -1484,10 +1454,53 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + +static void +nm_modem_init (NMModem *self) +{ + self->_priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_MODEM, NMModemPrivate); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + GObject *object; + NMModemPrivate *priv; + + object = G_OBJECT_CLASS (nm_modem_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (!object) + return NULL; + + priv = NM_MODEM_GET_PRIVATE ((NMModem *) object); + + if (!priv->data_port && !priv->control_port) { + nm_log_err (LOGD_PLATFORM, "neither modem command nor data interface provided"); + goto err; + } + + if (!priv->path) { + nm_log_err (LOGD_PLATFORM, "D-Bus path not provided"); + goto err; + } + + return object; + +err: + g_object_unref (object); + return NULL; +} + +/*****************************************************************************/ + static void dispose (GObject *object) { - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (object); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE ((NMModem *) object); if (priv->act_request) { g_object_unref (priv->act_request); @@ -1500,7 +1513,7 @@ dispose (GObject *object) static void finalize (GObject *object) { - NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (object); + NMModemPrivate *priv = NM_MODEM_GET_PRIVATE ((NMModem *) object); g_free (priv->uid); g_free (priv->path); @@ -1521,7 +1534,6 @@ nm_modem_class_init (NMModemClass *klass) g_type_class_add_private (object_class, sizeof (NMModemPrivate)); - /* Virtual methods */ object_class->constructor = constructor; object_class->set_property = set_property; object_class->get_property = get_property; @@ -1532,131 +1544,113 @@ nm_modem_class_init (NMModemClass *klass) klass->stage3_ip6_config_request = stage3_ip6_config_request; klass->deactivate_cleanup = deactivate_cleanup; - /* Properties */ - - g_object_class_install_property - (object_class, PROP_UID, - g_param_spec_string (NM_MODEM_UID, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_PATH, - g_param_spec_string (NM_MODEM_PATH, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_DRIVER, - g_param_spec_string (NM_MODEM_DRIVER, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_CONTROL_PORT, - g_param_spec_string (NM_MODEM_CONTROL_PORT, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_DATA_PORT, - g_param_spec_string (NM_MODEM_DATA_PORT, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_IP4_METHOD, - g_param_spec_uint (NM_MODEM_IP4_METHOD, "", "", - NM_MODEM_IP_METHOD_UNKNOWN, - NM_MODEM_IP_METHOD_AUTO, - NM_MODEM_IP_METHOD_UNKNOWN, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_IP6_METHOD, - g_param_spec_uint (NM_MODEM_IP6_METHOD, "", "", - NM_MODEM_IP_METHOD_UNKNOWN, - NM_MODEM_IP_METHOD_AUTO, - NM_MODEM_IP_METHOD_UNKNOWN, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_IP_TIMEOUT, - g_param_spec_uint (NM_MODEM_IP_TIMEOUT, "", "", - 0, 360, 20, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_STATE, - g_param_spec_enum (NM_MODEM_STATE, "", "", - NM_TYPE_MODEM_STATE, - NM_MODEM_STATE_UNKNOWN, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_DEVICE_ID, - g_param_spec_string (NM_MODEM_DEVICE_ID, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_SIM_ID, - g_param_spec_string (NM_MODEM_SIM_ID, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_IP_TYPES, - g_param_spec_uint (NM_MODEM_IP_TYPES, - "IP Types", - "Supported IP types", - 0, G_MAXUINT32, NM_MODEM_IP_TYPE_IPV4, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property - (object_class, PROP_SIM_OPERATOR_ID, - g_param_spec_string (NM_MODEM_SIM_OPERATOR_ID, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); - - /* Signals */ + obj_properties[PROP_UID] = + g_param_spec_string (NM_MODEM_UID, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_PATH] = + g_param_spec_string (NM_MODEM_PATH, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_DRIVER] = + g_param_spec_string (NM_MODEM_DRIVER, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_CONTROL_PORT] = + g_param_spec_string (NM_MODEM_CONTROL_PORT, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_DATA_PORT] = + g_param_spec_string (NM_MODEM_DATA_PORT, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_IP4_METHOD] = + g_param_spec_uint (NM_MODEM_IP4_METHOD, "", "", + NM_MODEM_IP_METHOD_UNKNOWN, + NM_MODEM_IP_METHOD_AUTO, + NM_MODEM_IP_METHOD_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_IP6_METHOD] = + g_param_spec_uint (NM_MODEM_IP6_METHOD, "", "", + NM_MODEM_IP_METHOD_UNKNOWN, + NM_MODEM_IP_METHOD_AUTO, + NM_MODEM_IP_METHOD_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_IP_TIMEOUT] = + g_param_spec_uint (NM_MODEM_IP_TIMEOUT, "", "", + 0, 360, 20, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_STATE] = + g_param_spec_int (NM_MODEM_STATE, "", "", + NM_MODEM_STATE_UNKNOWN, _NM_MODEM_STATE_LAST, NM_MODEM_STATE_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_DEVICE_ID] = + g_param_spec_string (NM_MODEM_DEVICE_ID, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_SIM_ID] = + g_param_spec_string (NM_MODEM_SIM_ID, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_IP_TYPES] = + g_param_spec_uint (NM_MODEM_IP_TYPES, + "IP Types", + "Supported IP types", + 0, G_MAXUINT32, NM_MODEM_IP_TYPE_IPV4, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_SIM_OPERATOR_ID] = + g_param_spec_string (NM_MODEM_SIM_OPERATOR_ID, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[PPP_STATS] = - g_signal_new ("ppp-stats", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, ppp_stats), - NULL, NULL, NULL, - G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); + g_signal_new ("ppp-stats", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); signals[PPP_FAILED] = - g_signal_new ("ppp-failed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, ppp_failed), - NULL, NULL, NULL, - G_TYPE_NONE, 1, G_TYPE_UINT); + g_signal_new ("ppp-failed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_UINT); signals[IP4_CONFIG_RESULT] = - g_signal_new (NM_MODEM_IP4_CONFIG_RESULT, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, ip4_config_result), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_POINTER); + g_signal_new (NM_MODEM_IP4_CONFIG_RESULT, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_POINTER); /** * NMModem::ip6-config-result: @@ -1672,50 +1666,44 @@ nm_modem_class_init (NMModemClass *klass) * should be started after applying @config to the data port. */ signals[IP6_CONFIG_RESULT] = - g_signal_new (NM_MODEM_IP6_CONFIG_RESULT, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, ip6_config_result), - NULL, NULL, NULL, - G_TYPE_NONE, 3, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_POINTER); + g_signal_new (NM_MODEM_IP6_CONFIG_RESULT, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 3, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_POINTER); signals[PREPARE_RESULT] = - g_signal_new (NM_MODEM_PREPARE_RESULT, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, prepare_result), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_BOOLEAN, G_TYPE_UINT); + g_signal_new (NM_MODEM_PREPARE_RESULT, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_BOOLEAN, G_TYPE_UINT); signals[AUTH_REQUESTED] = - g_signal_new (NM_MODEM_AUTH_REQUESTED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, auth_requested), - NULL, NULL, NULL, - G_TYPE_NONE, 0); + g_signal_new (NM_MODEM_AUTH_REQUESTED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); signals[AUTH_RESULT] = - g_signal_new (NM_MODEM_AUTH_RESULT, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, auth_result), - NULL, NULL, NULL, - G_TYPE_NONE, 1, G_TYPE_POINTER); + g_signal_new (NM_MODEM_AUTH_RESULT, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_POINTER); signals[REMOVED] = - g_signal_new (NM_MODEM_REMOVED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, removed), - NULL, NULL, NULL, - G_TYPE_NONE, 0); + g_signal_new (NM_MODEM_REMOVED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); signals[STATE_CHANGED] = - g_signal_new (NM_MODEM_STATE_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMModemClass, state_changed), - NULL, NULL, NULL, - G_TYPE_NONE, 2, NM_TYPE_MODEM_STATE, NM_TYPE_MODEM_STATE); + g_signal_new (NM_MODEM_STATE_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); } diff --git a/src/devices/wwan/nm-modem.h b/src/devices/wwan/nm-modem.h index 8f797d44..c590b9e4 100644 --- a/src/devices/wwan/nm-modem.h +++ b/src/devices/wwan/nm-modem.h @@ -22,8 +22,8 @@ #ifndef __NETWORKMANAGER_MODEM_H__ #define __NETWORKMANAGER_MODEM_H__ -#include "ppp-manager/nm-ppp-manager.h" -#include "nm-device.h" +#include "ppp/nm-ppp-manager.h" +#include "devices/nm-device.h" #define NM_TYPE_MODEM (nm_modem_get_type ()) #define NM_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MODEM, NMModem)) @@ -76,7 +76,7 @@ typedef enum { * combination of flags is possible. For example, (%NM_MODEM_IP_TYPE_IPV4 | * %NM_MODEM_IP_TYPE_IPV6) indicates that the modem supports IPv4 and IPv6 * but not simultaneously on the same bearer. - */ + */ typedef enum { NM_MODEM_IP_TYPE_UNKNOWN = 0x0, NM_MODEM_IP_TYPE_IPV4 = 0x1, @@ -98,11 +98,16 @@ typedef enum { /*< underscore_name=nm_modem_state >*/ NM_MODEM_STATE_DISCONNECTING = 10, NM_MODEM_STATE_CONNECTING = 11, NM_MODEM_STATE_CONNECTED = 12, + + _NM_MODEM_STATE_LAST0, + _NM_MODEM_STATE_LAST = _NM_MODEM_STATE_LAST0 -1, } NMModemState; +struct _NMModemPrivate; typedef struct { GObject parent; + struct _NMModemPrivate *_priv; } NMModem; typedef struct { @@ -153,26 +158,6 @@ typedef struct { void (*deactivate_cleanup) (NMModem *self, NMDevice *device); gboolean (*owns_port) (NMModem *self, const char *iface); - - /* Signals */ - void (*ppp_stats) (NMModem *self, guint32 in_bytes, guint32 out_bytes); - void (*ppp_failed) (NMModem *self, NMDeviceStateReason reason); - - void (*prepare_result) (NMModem *self, gboolean success, NMDeviceStateReason reason); - void (*ip4_config_result) (NMModem *self, NMIP4Config *config, GError *error); - void (*ip6_config_result) (NMModem *self, - NMIP6Config *config, - gboolean do_slaac, - GError *error); - - void (*auth_requested) (NMModem *self); - void (*auth_result) (NMModem *self, GError *error); - - void (*state_changed) (NMModem *self, - NMModemState new_state, - NMModemState old_state); - - void (*removed) (NMModem *self); } NMModemClass; GType nm_modem_get_type (void); diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c index 507935fc..fa4c8dbb 100644 --- a/src/devices/wwan/nm-wwan-factory.c +++ b/src/devices/wwan/nm-wwan-factory.c @@ -23,28 +23,47 @@ #include #include -#include "nm-device-factory.h" -#include "nm-wwan-factory.h" +#include "devices/nm-device-factory.h" #include "nm-setting-gsm.h" #include "nm-setting-cdma.h" #include "nm-modem-manager.h" #include "nm-device-modem.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" -static GType nm_wwan_factory_get_type (void); - -static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); +/*****************************************************************************/ -G_DEFINE_TYPE_EXTENDED (NMWwanFactory, nm_wwan_factory, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) - -#define NM_WWAN_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_WWAN_FACTORY, NMWwanFactoryPrivate)) +#define NM_TYPE_WWAN_FACTORY (nm_wwan_factory_get_type ()) +#define NM_WWAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WWAN_FACTORY, NMWwanFactory)) +#define NM_WWAN_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WWAN_FACTORY, NMWwanFactoryClass)) +#define NM_IS_WWAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WWAN_FACTORY)) +#define NM_IS_WWAN_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WWAN_FACTORY)) +#define NM_WWAN_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WWAN_FACTORY, NMWwanFactoryClass)) typedef struct { NMModemManager *mm; } NMWwanFactoryPrivate; -/************************************************************************/ +typedef struct { + NMDeviceFactory parent; + NMWwanFactoryPrivate _priv; +} NMWwanFactory; + +typedef struct { + NMDeviceFactoryClass parent; +} NMWwanFactoryClass; + +static GType nm_wwan_factory_get_type (void); + +G_DEFINE_TYPE (NMWwanFactory, nm_wwan_factory, NM_TYPE_DEVICE_FACTORY) + +#define NM_WWAN_FACTORY_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMWwanFactory, NM_IS_WWAN_FACTORY) + +/*****************************************************************************/ + +NM_DEVICE_FACTORY_DECLARE_TYPES ( + NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_WWAN_NET) + NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME) +) G_MODULE_EXPORT NMDeviceFactory * nm_device_factory_create (GError **error) @@ -52,7 +71,7 @@ nm_device_factory_create (GError **error) return (NMDeviceFactory *) g_object_new (NM_TYPE_WWAN_FACTORY, NULL); } -/************************************************************************/ +/*****************************************************************************/ static void modem_added_cb (NMModemManager *manager, @@ -89,11 +108,6 @@ modem_added_cb (NMModemManager *manager, } -NM_DEVICE_FACTORY_DECLARE_TYPES ( - NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_WWAN_NET) - NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME) -) - static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, @@ -121,17 +135,11 @@ start (NMDeviceFactory *factory) self); } -static void -nm_wwan_factory_init (NMWwanFactory *self) -{ -} +/*****************************************************************************/ static void -device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) +nm_wwan_factory_init (NMWwanFactory *self) { - factory_iface->get_supported_types = get_supported_types; - factory_iface->create_device = create_device; - factory_iface->start = start; } static void @@ -152,8 +160,11 @@ static void nm_wwan_factory_class_init (NMWwanFactoryClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof (NMWwanFactoryPrivate)); + NMDeviceFactoryClass *factory_class = NM_DEVICE_FACTORY_CLASS (klass); object_class->dispose = dispose; + + factory_class->get_supported_types = get_supported_types; + factory_class->create_device = create_device; + factory_class->start = start; } diff --git a/src/devices/wwan/nm-wwan-factory.h b/src/devices/wwan/nm-wwan-factory.h deleted file mode 100644 index 61bdcb1e..00000000 --- a/src/devices/wwan/nm-wwan-factory.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2014 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_WWAN_FACTORY_H__ -#define __NETWORKMANAGER_WWAN_FACTORY_H__ - -#define NM_TYPE_WWAN_FACTORY (nm_wwan_factory_get_type ()) -#define NM_WWAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WWAN_FACTORY, NMWwanFactory)) - -typedef struct { - GObject parent; -} NMWwanFactory; - -typedef struct { - GObjectClass parent; -} NMWwanFactoryClass; - -#endif /* __NETWORKMANAGER_WWAN_FACTORY_H__ */ diff --git a/src/devices/wwan/wwan-exports.ver b/src/devices/wwan/wwan-exports.ver deleted file mode 100644 index 23412de6..00000000 --- a/src/devices/wwan/wwan-exports.ver +++ /dev/null @@ -1,30 +0,0 @@ -{ -global: - nm_modem_act_stage1_prepare; - nm_modem_act_stage2_config; - nm_modem_check_connection_compatible; - nm_modem_complete_connection; - nm_modem_deactivate; - nm_modem_deactivate_async; - nm_modem_deactivate_async_finish; - nm_modem_device_state_changed; - nm_modem_get_capabilities; - nm_modem_get_control_port; - nm_modem_get_data_port; - nm_modem_get_driver; - nm_modem_get_iid; - nm_modem_get_path; - nm_modem_get_secrets; - nm_modem_get_state; - nm_modem_get_type; - nm_modem_get_uid; - nm_modem_ip4_pre_commit; - nm_modem_manager_get_type; - nm_modem_owns_port; - nm_modem_set_mm_enabled; - nm_modem_stage3_ip4_config_start; - nm_modem_stage3_ip6_config_start; - nm_modem_state_to_string; -local: - *; -}; diff --git a/src/dhcp-manager/Makefile.am b/src/dhcp-manager/Makefile.am deleted file mode 100644 index 42954127..00000000 --- a/src/dhcp-manager/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -libexec_PROGRAMS = nm-dhcp-helper - -nm_dhcp_helper_SOURCES = \ - nm-dhcp-helper.c \ - nm-dhcp-helper-api.h \ - $(NULL) - -nm_dhcp_helper_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - -I$(top_srcdir)/shared \ - -I${top_builddir}/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""nm-dhcp-helper"\" \ - -DNMRUNDIR=\"$(nmrundir)\" - -nm_dhcp_helper_LDADD = $(GLIB_LIBS) diff --git a/src/dhcp-manager/Makefile.in b/src/dhcp-manager/Makefile.in deleted file mode 100644 index 5309cde6..00000000 --- a/src/dhcp-manager/Makefile.in +++ /dev/null @@ -1,822 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -libexec_PROGRAMS = nm-dhcp-helper$(EXEEXT) -subdir = src/dhcp-manager -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(libexecdir)" -PROGRAMS = $(libexec_PROGRAMS) -am_nm_dhcp_helper_OBJECTS = nm_dhcp_helper-nm-dhcp-helper.$(OBJEXT) -nm_dhcp_helper_OBJECTS = $(am_nm_dhcp_helper_OBJECTS) -am__DEPENDENCIES_1 = -nm_dhcp_helper_DEPENDENCIES = $(am__DEPENDENCIES_1) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(nm_dhcp_helper_SOURCES) -DIST_SOURCES = $(nm_dhcp_helper_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -nm_dhcp_helper_SOURCES = \ - nm-dhcp-helper.c \ - nm-dhcp-helper-api.h \ - $(NULL) - -nm_dhcp_helper_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - -I$(top_srcdir)/shared \ - -I${top_builddir}/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""nm-dhcp-helper"\" \ - -DNMRUNDIR=\"$(nmrundir)\" - -nm_dhcp_helper_LDADD = $(GLIB_LIBS) -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dhcp-manager/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/dhcp-manager/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-libexecPROGRAMS: $(libexec_PROGRAMS) - @$(NORMAL_INSTALL) - @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ - fi; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p \ - || test -f $$p1 \ - ; then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' \ - -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-libexecPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' \ - `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(libexecdir)" && rm -f $$files - -clean-libexecPROGRAMS: - @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -nm-dhcp-helper$(EXEEXT): $(nm_dhcp_helper_OBJECTS) $(nm_dhcp_helper_DEPENDENCIES) $(EXTRA_nm_dhcp_helper_DEPENDENCIES) - @rm -f nm-dhcp-helper$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(nm_dhcp_helper_OBJECTS) $(nm_dhcp_helper_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm_dhcp_helper-nm-dhcp-helper.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -nm_dhcp_helper-nm-dhcp-helper.o: nm-dhcp-helper.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dhcp_helper_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm_dhcp_helper-nm-dhcp-helper.o -MD -MP -MF $(DEPDIR)/nm_dhcp_helper-nm-dhcp-helper.Tpo -c -o nm_dhcp_helper-nm-dhcp-helper.o `test -f 'nm-dhcp-helper.c' || echo '$(srcdir)/'`nm-dhcp-helper.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm_dhcp_helper-nm-dhcp-helper.Tpo $(DEPDIR)/nm_dhcp_helper-nm-dhcp-helper.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nm-dhcp-helper.c' object='nm_dhcp_helper-nm-dhcp-helper.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dhcp_helper_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm_dhcp_helper-nm-dhcp-helper.o `test -f 'nm-dhcp-helper.c' || echo '$(srcdir)/'`nm-dhcp-helper.c - -nm_dhcp_helper-nm-dhcp-helper.obj: nm-dhcp-helper.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dhcp_helper_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm_dhcp_helper-nm-dhcp-helper.obj -MD -MP -MF $(DEPDIR)/nm_dhcp_helper-nm-dhcp-helper.Tpo -c -o nm_dhcp_helper-nm-dhcp-helper.obj `if test -f 'nm-dhcp-helper.c'; then $(CYGPATH_W) 'nm-dhcp-helper.c'; else $(CYGPATH_W) '$(srcdir)/nm-dhcp-helper.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm_dhcp_helper-nm-dhcp-helper.Tpo $(DEPDIR)/nm_dhcp_helper-nm-dhcp-helper.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nm-dhcp-helper.c' object='nm_dhcp_helper-nm-dhcp-helper.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nm_dhcp_helper_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm_dhcp_helper-nm-dhcp-helper.obj `if test -f 'nm-dhcp-helper.c'; then $(CYGPATH_W) 'nm-dhcp-helper.c'; else $(CYGPATH_W) '$(srcdir)/nm-dhcp-helper.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(libexecdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-libexecPROGRAMS - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-libexecPROGRAMS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libexecPROGRAMS clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-libexecPROGRAMS install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ - uninstall-libexecPROGRAMS - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/dhcp-manager/nm-dhcp-client-logging.h b/src/dhcp-manager/nm-dhcp-client-logging.h deleted file mode 100644 index 8dd18bf2..00000000 --- a/src/dhcp-manager/nm-dhcp-client-logging.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2016 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ -#define __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ - -#include "nm-dhcp-client.h" - -#define _NMLOG_PREFIX_NAME "dhcp" -#define _NMLOG_DOMAIN LOGD_DHCP -#define _NMLOG(level, ...) \ - G_STMT_START { \ - const NMLogLevel _level = (level); \ - \ - /* we check first for LOGD_DHCP instead of the correct domain. - * In the worst case, we guess wrong and enter the block. - * - * Same for the _NMLOG_ENABLED() macro. Probably it would be more - * expensive to determine the correct value then what we could - * safe. */ \ - if (nm_logging_enabled (_level, _NMLOG_DOMAIN)) { \ - NMDhcpClient *_self = (NMDhcpClient *) (self); \ - const char *__ifname = _self ? nm_dhcp_client_get_iface (_self) : NULL; \ - const NMLogDomain _domain = !_self \ - ? LOGD_DHCP \ - : (nm_dhcp_client_get_ipv6 (_self) ? LOGD_DHCP6 : LOGD_DHCP4); \ - \ - nm_log (_level, _domain, \ - "%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, \ - (_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \ - NM_PRINT_FMT_QUOTED (__ifname, " (", __ifname, ")", "") \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -#define _NMLOG2(level, domain, ifname, ...) \ - G_STMT_START { \ - const NMLogLevel _level = (level); \ - const NMLogDomain _domain = (domain); \ - \ - /* we check first for LOGD_DHCP instead of the correct domain. - * In the worst case, we guess wrong and enter the block. - * - * Same for the _NMLOG_ENABLED() macro. Probably it would be more - * expensive to determine the correct value then what we could - * safe. */ \ - if (nm_logging_enabled (_level, _domain)) { \ - const char *__ifname = (ifname); \ - \ - nm_log (_level, _domain, \ - "%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, \ - (_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \ - NM_PRINT_FMT_QUOTED (__ifname, " (", __ifname, ")", "") \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -#endif /* __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ */ diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c deleted file mode 100644 index 3be2ea03..00000000 --- a/src/dhcp-manager/nm-dhcp-client.c +++ /dev/null @@ -1,967 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2010 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include "nm-dhcp-client.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "NetworkManagerUtils.h" -#include "nm-utils.h" -#include "nm-dhcp-utils.h" -#include "nm-platform.h" - -#include "nm-dhcp-client-logging.h" - -typedef struct { - char * iface; - int ifindex; - GByteArray * hwaddr; - gboolean ipv6; - char * uuid; - guint32 priority; - guint32 timeout; - GByteArray * duid; - GBytes * client_id; - char * hostname; - char * fqdn; - - NMDhcpState state; - pid_t pid; - guint timeout_id; - guint watch_id; - gboolean info_only; - -} NMDhcpClientPrivate; - -#define NM_DHCP_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_CLIENT, NMDhcpClientPrivate)) - -G_DEFINE_TYPE_EXTENDED (NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, {}) - -enum { - SIGNAL_STATE_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { - PROP_0, - PROP_IFACE, - PROP_IFINDEX, - PROP_HWADDR, - PROP_IPV6, - PROP_UUID, - PROP_PRIORITY, - PROP_TIMEOUT, - LAST_PROP -}; - -/********************************************/ - -pid_t -nm_dhcp_client_get_pid (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), -1); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->pid; -} - -const char * -nm_dhcp_client_get_iface (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->iface; -} - -int -nm_dhcp_client_get_ifindex (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), -1); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->ifindex; -} - -gboolean -nm_dhcp_client_get_ipv6 (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->ipv6; -} - -const char * -nm_dhcp_client_get_uuid (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->uuid; -} - -const GByteArray * -nm_dhcp_client_get_duid (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->duid; -} - -const GByteArray * -nm_dhcp_client_get_hw_addr (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->hwaddr; -} - -guint32 -nm_dhcp_client_get_priority (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), G_MAXUINT32); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->priority; -} - -GBytes * -nm_dhcp_client_get_client_id (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->client_id; -} - -void -nm_dhcp_client_set_client_id (NMDhcpClient *self, GBytes *client_id) -{ - NMDhcpClientPrivate *priv; - - g_return_if_fail (NM_IS_DHCP_CLIENT (self)); - - priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - if (priv->client_id && client_id && g_bytes_equal (priv->client_id, client_id)) - return; - g_clear_pointer (&priv->client_id, g_bytes_unref); - priv->client_id = client_id ? g_bytes_ref (client_id) : NULL; -} - -const char * -nm_dhcp_client_get_hostname (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->hostname; -} - -const char * -nm_dhcp_client_get_fqdn (NMDhcpClient *self) -{ - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); - - return NM_DHCP_CLIENT_GET_PRIVATE (self)->fqdn; -} - -/********************************************/ - -static const char *state_table[NM_DHCP_STATE_MAX + 1] = { - [NM_DHCP_STATE_UNKNOWN] = "unknown", - [NM_DHCP_STATE_BOUND] = "bound", - [NM_DHCP_STATE_TIMEOUT] = "timeout", - [NM_DHCP_STATE_EXPIRE] = "expire", - [NM_DHCP_STATE_DONE] = "done", - [NM_DHCP_STATE_FAIL] = "fail", -}; - -static const char * -state_to_string (NMDhcpState state) -{ - if ((gsize) state < G_N_ELEMENTS (state_table)) - return state_table[state]; - return NULL; -} - -static NMDhcpState -reason_to_state (NMDhcpClient *self, const char *iface, const char *reason) -{ - if (g_ascii_strcasecmp (reason, "bound") == 0 || - g_ascii_strcasecmp (reason, "bound6") == 0 || - g_ascii_strcasecmp (reason, "renew") == 0 || - g_ascii_strcasecmp (reason, "renew6") == 0 || - g_ascii_strcasecmp (reason, "reboot") == 0 || - g_ascii_strcasecmp (reason, "rebind") == 0 || - g_ascii_strcasecmp (reason, "rebind6") == 0) - return NM_DHCP_STATE_BOUND; - else if (g_ascii_strcasecmp (reason, "timeout") == 0) - return NM_DHCP_STATE_TIMEOUT; - else if (g_ascii_strcasecmp (reason, "nak") == 0 || - g_ascii_strcasecmp (reason, "expire") == 0 || - g_ascii_strcasecmp (reason, "expire6") == 0) - return NM_DHCP_STATE_EXPIRE; - else if (g_ascii_strcasecmp (reason, "end") == 0) - return NM_DHCP_STATE_DONE; - else if (g_ascii_strcasecmp (reason, "fail") == 0 || - g_ascii_strcasecmp (reason, "abend") == 0) - return NM_DHCP_STATE_FAIL; - - _LOGD ("unmapped DHCP state '%s'", reason); - return NM_DHCP_STATE_UNKNOWN; -} - -/********************************************/ - -static void -timeout_cleanup (NMDhcpClient *self) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - nm_clear_g_source (&priv->timeout_id); -} - -static void -watch_cleanup (NMDhcpClient *self) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - nm_clear_g_source (&priv->watch_id); -} - -void -nm_dhcp_client_stop_pid (pid_t pid, const char *iface) -{ - char *name = iface ? g_strdup_printf ("dhcp-client-%s", iface) : NULL; - - g_return_if_fail (pid > 1); - - nm_utils_kill_child_sync (pid, SIGTERM, LOGD_DHCP, name ? name : "dhcp-client", NULL, - 1000 / 2, 1000 / 20); - g_free (name); -} - -static void -stop (NMDhcpClient *self, gboolean release, const GByteArray *duid) -{ - NMDhcpClientPrivate *priv; - - g_return_if_fail (NM_IS_DHCP_CLIENT (self)); - - priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - if (priv->pid > 0) { - /* Clean up the watch handler since we're explicitly killing the daemon */ - watch_cleanup (self); - nm_dhcp_client_stop_pid (priv->pid, priv->iface); - } - priv->pid = -1; - priv->info_only = FALSE; -} - -void -nm_dhcp_client_set_state (NMDhcpClient *self, - NMDhcpState new_state, - GObject *ip_config, - GHashTable *options) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - gs_free char *event_id = NULL; - - if (new_state >= NM_DHCP_STATE_BOUND) - timeout_cleanup (self); - if (new_state >= NM_DHCP_STATE_TIMEOUT) - watch_cleanup (self); - - if (new_state == NM_DHCP_STATE_BOUND) { - g_assert ( (priv->ipv6 && NM_IS_IP6_CONFIG (ip_config)) - || (!priv->ipv6 && NM_IS_IP4_CONFIG (ip_config))); - g_assert (options); - g_assert_cmpint (g_hash_table_size (options), >, 0); - } else { - g_assert (ip_config == NULL); - g_assert (options == NULL); - } - - /* The client may send same-state transitions for RENEW/REBIND events and - * the lease may have changed, so handle same-state transitions for the - * BOUND state. Ignore same-state transitions for other events since - * the lease won't have changed and the state was already handled. - */ - if ((priv->state == new_state) && (new_state != NM_DHCP_STATE_BOUND)) - return; - - if (priv->ipv6 && new_state == NM_DHCP_STATE_BOUND) { - char *start, *iaid; - - iaid = g_hash_table_lookup (options, "iaid"); - start = g_hash_table_lookup (options, "life_starts"); - if (iaid && start) - event_id = g_strdup_printf ("%s|%s", iaid, start); - } - - _LOGI ("state changed %s -> %s%s%s%s", - state_to_string (priv->state), - state_to_string (new_state), - NM_PRINT_FMT_QUOTED (event_id, ", event ID=\"", event_id, "\"", "")); - - priv->state = new_state; - g_signal_emit (G_OBJECT (self), - signals[SIGNAL_STATE_CHANGED], 0, - new_state, - ip_config, - options, - event_id); -} - -static gboolean -transaction_timeout (gpointer user_data) -{ - NMDhcpClient *self = NM_DHCP_CLIENT (user_data); - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - priv->timeout_id = 0; - _LOGW ("request timed out"); - nm_dhcp_client_set_state (self, NM_DHCP_STATE_TIMEOUT, NULL, NULL); - return G_SOURCE_REMOVE; -} - -static void -daemon_watch_cb (GPid pid, gint status, gpointer user_data) -{ - NMDhcpClient *self = NM_DHCP_CLIENT (user_data); - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - NMDhcpState new_state; - - g_return_if_fail (priv->watch_id); - priv->watch_id = 0; - - if (WIFEXITED (status)) - _LOGI ("client pid %d exited with status %d", pid, WEXITSTATUS (status)); - else if (WIFSIGNALED (status)) - _LOGI ("client pid %d killed by signal %d", pid, WTERMSIG (status)); - else if (WIFSTOPPED(status)) - _LOGI ("client pid %d stopped by signal %d", pid, WSTOPSIG (status)); - else if (WIFCONTINUED (status)) - _LOGI ("client pid %d resumed (by SIGCONT)", pid); - else - _LOGW ("client died abnormally"); - - if (!WIFEXITED (status)) - new_state = NM_DHCP_STATE_FAIL; - else - new_state = NM_DHCP_STATE_DONE; - - priv->pid = -1; - - nm_dhcp_client_set_state (self, new_state, NULL, NULL); -} - -void -nm_dhcp_client_start_timeout (NMDhcpClient *self) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - /* Set up a timeout on the transaction to kill it after the timeout */ - g_assert (priv->timeout_id == 0); - priv->timeout_id = g_timeout_add_seconds (priv->timeout, - transaction_timeout, - self); -} - -void -nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - g_return_if_fail (priv->pid == -1); - priv->pid = pid; - - nm_dhcp_client_start_timeout (self); - - g_return_if_fail (priv->watch_id == 0); - priv->watch_id = g_child_watch_add (pid, daemon_watch_cb, self); -} - -gboolean -nm_dhcp_client_start_ip4 (NMDhcpClient *self, - const char *dhcp_client_id, - const char *dhcp_anycast_addr, - const char *hostname, - const char *fqdn, - const char *last_ip4_address) -{ - NMDhcpClientPrivate *priv; - gs_unref_bytes GBytes *tmp = NULL; - - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE); - - priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - g_return_val_if_fail (priv->pid == -1, FALSE); - g_return_val_if_fail (priv->ipv6 == FALSE, FALSE); - g_return_val_if_fail (priv->uuid != NULL, FALSE); - - _LOGI ("activation: beginning transaction (timeout in %d seconds)", priv->timeout); - - if (dhcp_client_id) - tmp = nm_dhcp_utils_client_id_string_to_bytes (dhcp_client_id); - nm_dhcp_client_set_client_id (self, tmp); - - g_clear_pointer (&priv->hostname, g_free); - priv->hostname = g_strdup (hostname); - g_free (priv->fqdn); - priv->fqdn = g_strdup (fqdn); - - return NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, dhcp_anycast_addr, last_ip4_address); -} - -static GByteArray * -generate_duid_from_machine_id (void) -{ - GByteArray *duid; - GChecksum *sum; - guint8 buffer[32]; /* SHA256 digest size */ - gsize sumlen = sizeof (buffer); - const guint16 duid_type = g_htons (4); - uuid_t uuid; - GRand *generator; - guint i; - gs_free char *machine_id_s = NULL; - gs_free char *str = NULL; - - machine_id_s = nm_utils_machine_id_read (); - if (nm_utils_machine_id_parse (machine_id_s, uuid)) { - /* Hash the machine ID so it's not leaked to the network */ - sum = g_checksum_new (G_CHECKSUM_SHA256); - g_checksum_update (sum, (const guchar *) &uuid, sizeof (uuid)); - g_checksum_get_digest (sum, buffer, &sumlen); - g_checksum_free (sum); - } else { - nm_log_warn (LOGD_DHCP, "dhcp: failed to read " SYSCONFDIR "/machine-id " - "or " LOCALSTATEDIR "/lib/dbus/machine-id to generate " - "DHCPv6 DUID; creating non-persistent random DUID."); - - generator = g_rand_new (); - for (i = 0; i < sizeof (buffer) / sizeof (guint32); i++) - ((guint32 *) buffer)[i] = g_rand_int (generator); - g_rand_free (generator); - } - - /* Generate a DHCP Unique Identifier for DHCPv6 using the - * DUID-UUID method (see RFC 6355 section 4). Format is: - * - * u16: type (DUID-UUID = 4) - * u8[16]: UUID bytes - */ - duid = g_byte_array_sized_new (18); - g_byte_array_append (duid, (guint8 *) &duid_type, sizeof (duid_type)); - - /* Since SHA256 is 256 bits, but UUID is 128 bits, we just take the first - * 128 bits of the SHA256 as the DUID-UUID. - */ - g_byte_array_append (duid, buffer, 16); - - nm_log_dbg (LOGD_DHCP, "dhcp: generated DUID %s", - (str = nm_dhcp_utils_duid_to_string (duid))); - return duid; -} - -static GByteArray * -get_duid (NMDhcpClient *self) -{ - static GByteArray *duid = NULL; - GByteArray *copy = NULL; - - if (G_UNLIKELY (duid == NULL)) { - duid = generate_duid_from_machine_id (); - g_assert (duid); - } - - if (G_LIKELY (duid)) { - copy = g_byte_array_sized_new (duid->len); - g_byte_array_append (copy, duid->data, duid->len); - } - - return copy; -} - -gboolean -nm_dhcp_client_start_ip6 (NMDhcpClient *self, - const char *dhcp_anycast_addr, - const struct in6_addr *ll_addr, - const char *hostname, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy) -{ - NMDhcpClientPrivate *priv; - gs_free char *str = NULL; - - g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE); - - priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - g_return_val_if_fail (priv->pid == -1, FALSE); - g_return_val_if_fail (priv->ipv6 == TRUE, FALSE); - g_return_val_if_fail (priv->uuid != NULL, FALSE); - - /* If we don't have one yet, read the default DUID for this DHCPv6 client - * from the client-specific persistent configuration. - */ - if (!priv->duid) - priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self); - - _LOGD ("DUID is '%s'", (str = nm_dhcp_utils_duid_to_string (priv->duid))); - - g_clear_pointer (&priv->hostname, g_free); - priv->hostname = g_strdup (hostname); - - priv->info_only = info_only; - - _LOGI ("activation: beginning transaction (timeout in %d seconds)", - priv->timeout); - - return NM_DHCP_CLIENT_GET_CLASS (self)->ip6_start (self, - dhcp_anycast_addr, - ll_addr, - info_only, - privacy, - priv->duid); -} - -void -nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name) -{ - guint64 start_time; - pid_t pid, ppid; - const char *exe; - char proc_path[NM_STRLEN ("/proc/%lu/cmdline") + 100]; - gs_free char *pid_contents = NULL, *proc_contents = NULL; - - /* Check for an existing instance and stop it */ - if (!g_file_get_contents (pid_file, &pid_contents, NULL, NULL)) - return; - - pid = _nm_utils_ascii_str_to_int64 (pid_contents, 10, 1, G_MAXINT64, 0); - if (pid <= 0) - goto out; - - start_time = nm_utils_get_start_time_for_pid (pid, NULL, &ppid); - if (start_time == 0) - goto out; - - nm_sprintf_buf (proc_path, "/proc/%lu/cmdline", (long unsigned) pid); - if (!g_file_get_contents (proc_path, &proc_contents, NULL, NULL)) - goto out; - - exe = strrchr (proc_contents, '/'); - if (exe) - exe++; - else - exe = proc_contents; - if (!nm_streq0 (exe, binary_name)) - goto out; - - if (ppid == getpid ()) { - /* the process is our own child. */ - nm_utils_kill_child_sync (pid, SIGTERM, LOGD_DHCP, "dhcp-client", NULL, 1000 / 2, 1000 / 20); - } else { - nm_utils_kill_process_sync (pid, start_time, SIGTERM, LOGD_DHCP, - "dhcp-client", 1000 / 2, 1000 / 20, 2000); - } - -out: - if (remove (pid_file) == -1) { - nm_log_dbg (LOGD_DHCP, "dhcp: could not remove pid file \"%s\": %d (%s)", - pid_file, errno, g_strerror (errno)); - } -} - -void -nm_dhcp_client_stop (NMDhcpClient *self, gboolean release) -{ - NMDhcpClientPrivate *priv; - pid_t old_pid = 0; - - g_return_if_fail (NM_IS_DHCP_CLIENT (self)); - - priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - /* Kill the DHCP client */ - old_pid = priv->pid; - NM_DHCP_CLIENT_GET_CLASS (self)->stop (self, release, priv->duid); - if (old_pid > 0) - _LOGI ("canceled DHCP transaction, DHCP client pid %d", old_pid); - else - _LOGI ("canceled DHCP transaction"); - g_assert (priv->pid == -1); - - nm_dhcp_client_set_state (self, NM_DHCP_STATE_DONE, NULL, NULL); -} - -/********************************************/ - -static char * -bytearray_variant_to_string (NMDhcpClient *self, 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 (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 (length); - for (i = 0; i < length; i++) { - c = array[i]; - - /* 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); - } - str = g_string_append_c (str, '\0'); - - converted = str->str; - if (!g_utf8_validate (converted, -1, NULL)) - _LOGW ("option '%s' couldn't be converted to UTF-8", key); - g_string_free (str, FALSE); - return converted; -} - -#define OLD_TAG "old_" -#define NEW_TAG "new_" - -static void -maybe_add_option (NMDhcpClient *self, - GHashTable *hash, - const char *key, - GVariant *value) -{ - char *str_value = NULL; - const char **p; - static const char *ignored_keys[] = { - "interface", - "pid", - "reason", - "dhcp_message_type", - NULL - }; - - g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BYTESTRING)); - - if (g_str_has_prefix (key, OLD_TAG)) - return; - - /* Filter out stuff that's not actually new DHCP options */ - for (p = ignored_keys; *p; p++) { - if (!strcmp (*p, key)) - return; - } - - if (g_str_has_prefix (key, NEW_TAG)) - key += NM_STRLEN (NEW_TAG); - if (!key[0]) - return; - - str_value = bytearray_variant_to_string (self, value, key); - if (str_value) - g_hash_table_insert (hash, g_strdup (key), str_value); -} - -gboolean -nm_dhcp_client_handle_event (gpointer unused, - const char *iface, - gint pid, - GVariant *options, - const char *reason, - NMDhcpClient *self) -{ - NMDhcpClientPrivate *priv; - guint32 old_state; - guint32 new_state; - GHashTable *str_options = NULL; - GObject *ip_config = NULL; - - 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 (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); - - if (g_strcmp0 (priv->iface, iface) != 0) - return FALSE; - if (priv->pid != pid) - return FALSE; - - old_state = priv->state; - new_state = reason_to_state (self, priv->iface, reason); - _LOGD ("DHCP reason '%s' -> state '%s'", - 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_variant_iter_init (&iter, options); - while (g_variant_iter_next (&iter, "{&sv}", &name, &value)) { - maybe_add_option (self, str_options, name, value); - g_variant_unref (value); - } - - /* Create the IP config */ - g_warn_if_fail (g_hash_table_size (str_options)); - if (g_hash_table_size (str_options)) { - if (priv->ipv6) { - ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (priv->ifindex, - priv->iface, - str_options, - priv->priority, - priv->info_only); - } else { - ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (priv->ifindex, - priv->iface, - str_options, - priv->priority); - } - - /* Fail if no valid IP config was received */ - if (ip_config == NULL) { - _LOGW ("client bound but IP config not received"); - new_state = NM_DHCP_STATE_FAIL; - g_clear_pointer (&str_options, g_hash_table_unref); - } - } - } - - nm_dhcp_client_set_state (self, new_state, ip_config, str_options); - - if (str_options) - g_hash_table_destroy (str_options); - g_clear_object (&ip_config); - - return TRUE; -} - -/********************************************/ - -static void -nm_dhcp_client_init (NMDhcpClient *self) -{ - NM_DHCP_CLIENT_GET_PRIVATE (self)->pid = -1; -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_IFACE: - g_value_set_string (value, priv->iface); - break; - case PROP_IFINDEX: - g_value_set_int (value, priv->ifindex); - break; - case PROP_HWADDR: - g_value_set_boxed (value, priv->hwaddr); - break; - case PROP_IPV6: - g_value_set_boolean (value, priv->ipv6); - break; - case PROP_UUID: - g_value_set_string (value, priv->uuid); - break; - case PROP_PRIORITY: - g_value_set_uint (value, priv->priority); - break; - case PROP_TIMEOUT: - g_value_set_uint (value, priv->timeout); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_IFACE: - /* construct-only */ - priv->iface = g_value_dup_string (value); - break; - case PROP_IFINDEX: - /* construct-only */ - priv->ifindex = g_value_get_int (value); - g_warn_if_fail (priv->ifindex > 0); - break; - case PROP_HWADDR: - /* construct only */ - priv->hwaddr = g_value_dup_boxed (value); - break; - case PROP_IPV6: - /* construct-only */ - priv->ipv6 = g_value_get_boolean (value); - break; - case PROP_UUID: - /* construct-only */ - priv->uuid = g_value_dup_string (value); - break; - case PROP_PRIORITY: - /* construct-only */ - priv->priority = g_value_get_uint (value); - break; - case PROP_TIMEOUT: - priv->timeout = g_value_get_uint (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - NMDhcpClient *self = NM_DHCP_CLIENT (object); - NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); - - /* Stopping the client is left up to the controlling device - * explicitly since we may want to quit NetworkManager but not terminate - * the DHCP client. - */ - - watch_cleanup (self); - timeout_cleanup (self); - - g_clear_pointer (&priv->iface, g_free); - g_clear_pointer (&priv->hostname, g_free); - g_clear_pointer (&priv->fqdn, g_free); - g_clear_pointer (&priv->uuid, g_free); - g_clear_pointer (&priv->client_id, g_bytes_unref); - - if (priv->hwaddr) { - g_byte_array_free (priv->hwaddr, TRUE); - priv->hwaddr = NULL; - } - - if (priv->duid) { - g_byte_array_free (priv->duid, TRUE); - priv->duid = NULL; - } - - G_OBJECT_CLASS (nm_dhcp_client_parent_class)->dispose (object); -} - -static void -nm_dhcp_client_class_init (NMDhcpClientClass *client_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (client_class); - - g_type_class_add_private (client_class, sizeof (NMDhcpClientPrivate)); - - /* virtual methods */ - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - client_class->stop = stop; - client_class->get_duid = get_duid; - - g_object_class_install_property - (object_class, PROP_IFACE, - g_param_spec_string (NM_DHCP_CLIENT_INTERFACE, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_IFINDEX, - g_param_spec_int (NM_DHCP_CLIENT_IFINDEX, "", "", - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_HWADDR, - g_param_spec_boxed (NM_DHCP_CLIENT_HWADDR, "", "", - G_TYPE_BYTE_ARRAY, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_IPV6, - g_param_spec_boolean (NM_DHCP_CLIENT_IPV6, "", "", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_UUID, - g_param_spec_string (NM_DHCP_CLIENT_UUID, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_PRIORITY, - g_param_spec_uint (NM_DHCP_CLIENT_PRIORITY, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TIMEOUT, - g_param_spec_uint (NM_DHCP_CLIENT_TIMEOUT, "", "", - 0, G_MAXUINT, 45, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /* signals */ - signals[SIGNAL_STATE_CHANGED] = - g_signal_new (NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDhcpClientClass, state_changed), - NULL, NULL, NULL, - G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_OBJECT, G_TYPE_HASH_TABLE, G_TYPE_STRING); -} - diff --git a/src/dhcp-manager/nm-dhcp-client.h b/src/dhcp-manager/nm-dhcp-client.h deleted file mode 100644 index 5779d4ed..00000000 --- a/src/dhcp-manager/nm-dhcp-client.h +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2010 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_CLIENT_H__ -#define __NETWORKMANAGER_DHCP_CLIENT_H__ - -#include -#include -#include -#include - -#define NM_TYPE_DHCP_CLIENT (nm_dhcp_client_get_type ()) -#define NM_DHCP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClient)) -#define NM_DHCP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_CLIENT, NMDhcpClientClass)) -#define NM_IS_DHCP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_CLIENT)) -#define NM_IS_DHCP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_CLIENT)) -#define NM_DHCP_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClientClass)) - -#define NM_DHCP_CLIENT_INTERFACE "iface" -#define NM_DHCP_CLIENT_IFINDEX "ifindex" -#define NM_DHCP_CLIENT_HWADDR "hwaddr" -#define NM_DHCP_CLIENT_IPV6 "ipv6" -#define NM_DHCP_CLIENT_UUID "uuid" -#define NM_DHCP_CLIENT_PRIORITY "priority" -#define NM_DHCP_CLIENT_TIMEOUT "timeout" - -#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed" - -typedef enum { - NM_DHCP_STATE_UNKNOWN = 0, - NM_DHCP_STATE_BOUND, /* new lease or lease changed */ - NM_DHCP_STATE_TIMEOUT, /* timed out contacting server */ - NM_DHCP_STATE_DONE, /* client quit or stopped */ - NM_DHCP_STATE_EXPIRE, /* lease expired or NAKed */ - NM_DHCP_STATE_FAIL, /* failed for some reason */ - __NM_DHCP_STATE_MAX, - NM_DHCP_STATE_MAX = __NM_DHCP_STATE_MAX - 1, -} NMDhcpState; - -typedef struct { - GObject parent; -} NMDhcpClient; - -typedef struct { - GObjectClass parent; - - /* Methods */ - - gboolean (*ip4_start) (NMDhcpClient *self, - const char *anycast_addr, - const char *last_ip4_address); - - gboolean (*ip6_start) (NMDhcpClient *self, - const char *anycast_addr, - const struct in6_addr *ll_addr, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy, - const GByteArray *duid); - - void (*stop) (NMDhcpClient *self, - gboolean release, - const GByteArray *duid); - - /** - * get_duid: - * @self: the #NMDhcpClient - * - * Attempts to find an existing DHCPv6 DUID for this client in the DHCP - * client's persistent configuration. Returned DUID should be the binary - * representation of the DUID. If no DUID is found, %NULL should be - * returned. - */ - GByteArray * (*get_duid) (NMDhcpClient *self); - - /* Signals */ - void (*state_changed) (NMDhcpClient *self, - NMDhcpState state, - GObject *ip_config, - GHashTable *options); -} NMDhcpClientClass; - -GType nm_dhcp_client_get_type (void); - -typedef const char *(*NMDhcpClientGetPathFunc) (void); - -typedef GSList * (*NMDhcpClientGetLeaseConfigsFunc) (const char *iface, - int ifindex, - const char *uuid, - gboolean ipv6, - guint32 default_route_metric); - -void _nm_dhcp_client_register (GType gtype, - const char *name, - NMDhcpClientGetPathFunc get_path_func, - NMDhcpClientGetLeaseConfigsFunc get_lease_configs_func); - -pid_t nm_dhcp_client_get_pid (NMDhcpClient *self); - -const char *nm_dhcp_client_get_iface (NMDhcpClient *self); - -int nm_dhcp_client_get_ifindex (NMDhcpClient *self); - -gboolean nm_dhcp_client_get_ipv6 (NMDhcpClient *self); - -const char *nm_dhcp_client_get_uuid (NMDhcpClient *self); - -const GByteArray *nm_dhcp_client_get_duid (NMDhcpClient *self); - -const GByteArray *nm_dhcp_client_get_hw_addr (NMDhcpClient *self); - -guint32 nm_dhcp_client_get_priority (NMDhcpClient *self); - -GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self); - -const char *nm_dhcp_client_get_hostname (NMDhcpClient *self); - -const char *nm_dhcp_client_get_fqdn (NMDhcpClient *self); - -gboolean nm_dhcp_client_start_ip4 (NMDhcpClient *self, - const char *dhcp_client_id, - const char *dhcp_anycast_addr, - const char *hostname, - const char *fqdn, - const char *last_ip4_address); - -gboolean nm_dhcp_client_start_ip6 (NMDhcpClient *self, - const char *dhcp_anycast_addr, - const struct in6_addr *ll_addr, - const char *hostname, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy); - -void nm_dhcp_client_stop (NMDhcpClient *self, gboolean release); - -/* Backend helpers for subclasses */ -void nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name); - -void nm_dhcp_client_stop_pid (pid_t pid, const char *iface); - -void nm_dhcp_client_start_timeout (NMDhcpClient *self); - -void nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid); - -void nm_dhcp_client_set_state (NMDhcpClient *self, - NMDhcpState new_state, - GObject *ip_config, /* NMIP4Config or NMIP6Config */ - GHashTable *options); /* str:str hash */ - -gboolean nm_dhcp_client_handle_event (gpointer unused, - const char *iface, - gint pid, - GVariant *options, - const char *reason, - NMDhcpClient *self); - -void nm_dhcp_client_set_client_id (NMDhcpClient *self, GBytes *client_id); - -#endif /* __NETWORKMANAGER_DHCP_CLIENT_H__ */ - diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c deleted file mode 100644 index 8d4c54ae..00000000 --- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c +++ /dev/null @@ -1,755 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "nm-dhcp-dhclient-utils.h" - -#include -#include -#include - -#include "nm-dhcp-utils.h" -#include "nm-ip4-config.h" -#include "nm-utils.h" -#include "nm-platform.h" -#include "NetworkManagerUtils.h" - -#define CLIENTID_TAG "send dhcp-client-identifier" - -#define HOSTNAME4_TAG "send host-name" -#define HOSTNAME4_FORMAT HOSTNAME4_TAG " \"%s\"; # added by NetworkManager" - -#define FQDN_TAG_PREFIX "send fqdn." -#define FQDN_TAG FQDN_TAG_PREFIX "fqdn" -#define FQDN_FORMAT FQDN_TAG " \"%s\"; # added by NetworkManager" - -#define ALSOREQ_TAG "also request " - -static void -add_also_request (GPtrArray *array, const char *item) -{ - int i; - - for (i = 0; i < array->len; i++) { - if (!strcmp (g_ptr_array_index (array, i), item)) - return; - } - g_ptr_array_add (array, g_strdup (item)); -} - -static void -add_hostname4 (GString *str, const char *hostname, const char *fqdn) -{ - char *plain_hostname, *dot; - - if (fqdn) { - g_string_append_printf (str, FQDN_FORMAT "\n", fqdn); - g_string_append (str, - "send fqdn.encoded on;\n" - "send fqdn.server-update on;\n"); - } else if (hostname) { - plain_hostname = g_strdup (hostname); - dot = strchr (plain_hostname, '.'); - /* get rid of the domain */ - if (dot) - *dot = '\0'; - - g_string_append_printf (str, HOSTNAME4_FORMAT "\n", plain_hostname); - g_free (plain_hostname); - } -} - -static void -add_ip4_config (GString *str, GBytes *client_id, const char *hostname, const char *fqdn) -{ - if (client_id) { - const char *p; - gsize l; - guint i; - - p = g_bytes_get_data (client_id, &l); - g_assert (p); - - /* Allow type 0 (non-hardware address) to be represented as a string - * as long as all the characters are printable. - */ - for (i = 1; (p[0] == 0) && i < l; i++) { - if (!g_ascii_isprint (p[i])) - break; - } - - g_string_append (str, CLIENTID_TAG " "); - if (i < l) { - /* Unprintable; convert to a hex string */ - for (i = 0; i < l; i++) { - if (i > 0) - g_string_append_c (str, ':'); - g_string_append_printf (str, "%02x", (guint8) p[i]); - } - } else { - /* Printable; just add to the line minus the 'type' */ - g_string_append_c (str, '"'); - g_string_append_len (str, p + 1, l - 1); - g_string_append_c (str, '"'); - } - g_string_append (str, "; # added by NetworkManager\n"); - } - - add_hostname4 (str, hostname, fqdn); - - g_string_append_c (str, '\n'); - - /* Define options for classless static routes */ - g_string_append (str, - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"); - g_string_append (str, - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"); - /* Web Proxy Auto-Discovery option (bgo #368423) */ - g_string_append (str, "option wpad code 252 = string;\n"); - - g_string_append_c (str, '\n'); -} - -static void -add_hostname6 (GString *str, const char *hostname) -{ - /* dhclient only supports the fqdn.fqdn for DHCPv6 and requires a fully- - * qualified name for this option, so we must require one here too. - */ - if (hostname && strchr (hostname, '.')) { - g_string_append_printf (str, FQDN_FORMAT "\n", hostname); - g_string_append (str, - "send fqdn.encoded on;\n" - "send fqdn.server-update on;\n"); - g_string_append_c (str, '\n'); - } -} - -static GBytes * -read_client_id (const char *str) -{ - gs_free char *s = NULL; - char *p; - - g_assert (!strncmp (str, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG))); - - str += NM_STRLEN (CLIENTID_TAG); - while (g_ascii_isspace (*str)) - str++; - - if (*str == '"') { - s = g_strdup (str + 1); - p = strrchr (s, '"'); - if (p) - *p = '\0'; - else - return NULL; - } else - s = g_strdup (str); - - g_strchomp (s); - if (s[strlen (s) - 1] == ';') - s[strlen (s) - 1] = '\0'; - - return nm_dhcp_utils_client_id_string_to_bytes (s); -} - -GBytes * -nm_dhcp_dhclient_get_client_id_from_config_file (const char *path) -{ - gs_free char *contents = NULL; - gs_strfreev char **lines = NULL; - char **line; - - g_return_val_if_fail (path != NULL, NULL); - - if (!g_file_test (path, G_FILE_TEST_EXISTS)) - return NULL; - - if (!g_file_get_contents (path, &contents, NULL, NULL)) - return NULL; - - lines = g_strsplit_set (contents, "\n\r", 0); - for (line = lines; lines && *line; line++) { - if (!strncmp (*line, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG))) - return read_client_id (*line); - } - return NULL; -} - -char * -nm_dhcp_dhclient_create_config (const char *interface, - gboolean is_ip6, - GBytes *client_id, - const char *anycast_addr, - const char *hostname, - const char *fqdn, - const char *orig_path, - const char *orig_contents, - GBytes **out_new_client_id) -{ - GString *new_contents; - GPtrArray *alsoreq, *fqdn_opts; - int i; - - g_return_val_if_fail (!anycast_addr || nm_utils_hwaddr_valid (anycast_addr, ETH_ALEN), NULL); - - new_contents = g_string_new (_("# Created by NetworkManager\n")); - alsoreq = g_ptr_array_sized_new (5); - fqdn_opts = g_ptr_array_sized_new (5); - - if (orig_contents) { - char **lines, **line; - gboolean in_alsoreq = FALSE; - - g_string_append_printf (new_contents, _("# Merged from %s\n\n"), orig_path); - - lines = g_strsplit_set (orig_contents, "\n\r", 0); - for (line = lines; lines && *line; line++) { - char *p = *line; - - if (!strlen (g_strstrip (p))) - continue; - - if (!strncmp (p, CLIENTID_TAG, strlen (CLIENTID_TAG))) { - /* Override config file "dhcp-client-id" and use one from the connection */ - if (client_id) - continue; - - /* Otherwise capture and return the existing client id */ - if (out_new_client_id) - *out_new_client_id = read_client_id (p); - } - - /* Override config file hostname and use one from the connection */ - if (hostname || fqdn) { - if (strncmp (p, HOSTNAME4_TAG, strlen (HOSTNAME4_TAG)) == 0) - continue; - if (strncmp (p, FQDN_TAG, strlen (FQDN_TAG)) == 0) - continue; - } - - /* To let user's FQDN options (except "fqdn.fqdn") override the - * default ones set by NM, add them later - */ - if (!strncmp (p, FQDN_TAG_PREFIX, NM_STRLEN (FQDN_TAG_PREFIX))) { - g_ptr_array_add (fqdn_opts, g_strdup (p + NM_STRLEN (FQDN_TAG_PREFIX))); - continue; - } - - /* Ignore 'script' since we pass our own */ - if (g_str_has_prefix (p, "script ")) - continue; - - /* Check for "also require" */ - if (!strncmp (p, ALSOREQ_TAG, strlen (ALSOREQ_TAG))) { - in_alsoreq = TRUE; - p += strlen (ALSOREQ_TAG); - } - - if (in_alsoreq) { - char **areq, **aiter; - - /* Grab each 'also require' option and save for later */ - areq = g_strsplit_set (p, "\t ,", -1); - for (aiter = areq; aiter && *aiter; aiter++) { - if (!strlen (g_strstrip (*aiter))) - continue; - - if (*aiter[0] == ';') { - /* all done */ - in_alsoreq = FALSE; - break; - } - - if (!g_ascii_isalnum ((*aiter)[0])) - continue; - - if ((*aiter)[strlen (*aiter) - 1] == ';') { - /* Remove the EOL marker */ - (*aiter)[strlen (*aiter) - 1] = '\0'; - in_alsoreq = FALSE; - } - - add_also_request (alsoreq, *aiter); - } - - if (areq) - g_strfreev (areq); - - continue; - } - - /* Existing configuration line is OK, add it to new configuration */ - g_string_append (new_contents, *line); - g_string_append_c (new_contents, '\n'); - } - - if (lines) - g_strfreev (lines); - } else - g_string_append_c (new_contents, '\n'); - - if (is_ip6) { - add_hostname6 (new_contents, hostname); - add_also_request (alsoreq, "dhcp6.name-servers"); - add_also_request (alsoreq, "dhcp6.domain-search"); - add_also_request (alsoreq, "dhcp6.client-id"); - } else { - add_ip4_config (new_contents, client_id, hostname, fqdn); - add_also_request (alsoreq, "rfc3442-classless-static-routes"); - add_also_request (alsoreq, "ms-classless-static-routes"); - add_also_request (alsoreq, "static-routes"); - add_also_request (alsoreq, "wpad"); - add_also_request (alsoreq, "ntp-servers"); - } - - /* And add it to the dhclient configuration */ - for (i = 0; i < alsoreq->len; i++) { - char *t = g_ptr_array_index (alsoreq, i); - - g_string_append_printf (new_contents, "also request %s;\n", t); - g_free (t); - } - g_ptr_array_free (alsoreq, TRUE); - - for (i = 0; i < fqdn_opts->len; i++) { - char *t = g_ptr_array_index (fqdn_opts, i); - - if (i == 0) - g_string_append_printf (new_contents, "\n# FQDN options from %s\n", orig_path); - g_string_append_printf (new_contents, FQDN_TAG_PREFIX "%s\n", t); - g_free (t); - } - g_ptr_array_free (fqdn_opts, TRUE); - - g_string_append_c (new_contents, '\n'); - - if (anycast_addr) { - g_string_append_printf (new_contents, "interface \"%s\" {\n" - " initial-interval 1; \n" - " anycast-mac ethernet %s;\n" - "}\n", - interface, anycast_addr); - } - - return g_string_free (new_contents, FALSE); -} - -/* Roughly follow what dhclient's quotify_buf() and pretty_escape() functions do */ -char * -nm_dhcp_dhclient_escape_duid (const GByteArray *duid) -{ - char *escaped; - const guint8 *s = duid->data; - char *d; - - d = escaped = g_malloc0 ((duid->len * 4) + 1); - while (s < (duid->data + duid->len)) { - if (!g_ascii_isprint (*s)) { - *d++ = '\\'; - *d++ = '0' + ((*s >> 6) & 0x7); - *d++ = '0' + ((*s >> 3) & 0x7); - *d++ = '0' + (*s++ & 0x7); - } else if (*s == '"' || *s == '\'' || *s == '$' || - *s == '`' || *s == '\\' || *s == '|' || - *s == '&') { - *d++ = '\\'; - *d++ = *s++; - } else - *d++ = *s++; - } - return escaped; -} - -static inline gboolean -isoctal (const guint8 *p) -{ - return ( p[0] >= '0' && p[0] <= '3' - && p[1] >= '0' && p[1] <= '7' - && p[2] >= '0' && p[2] <= '7'); -} - -GByteArray * -nm_dhcp_dhclient_unescape_duid (const char *duid) -{ - GByteArray *unescaped; - const guint8 *p = (const guint8 *) duid; - guint i, len; - guint8 octal; - - len = strlen (duid); - unescaped = g_byte_array_sized_new (len); - for (i = 0; i < len; i++) { - if (p[i] == '\\') { - i++; - if (isdigit (p[i])) { - /* Octal escape sequence */ - if (i + 2 >= len || !isoctal (p + i)) - goto error; - octal = ((p[i] - '0') << 6) + ((p[i + 1] - '0') << 3) + (p[i + 2] - '0'); - g_byte_array_append (unescaped, &octal, 1); - i += 2; - } else { - /* One of ", ', $, `, \, |, or & */ - g_warn_if_fail (p[i] == '"' || p[i] == '\'' || p[i] == '$' || - p[i] == '`' || p[i] == '\\' || p[i] == '|' || - p[i] == '&'); - g_byte_array_append (unescaped, &p[i], 1); - } - } else - g_byte_array_append (unescaped, &p[i], 1); - } - - return unescaped; - -error: - g_byte_array_free (unescaped, TRUE); - return NULL; -} - -#define DUID_PREFIX "default-duid \"" - -GByteArray * -nm_dhcp_dhclient_read_duid (const char *leasefile, GError **error) -{ - GByteArray *duid = NULL; - char *contents; - char **line, **split, *p, *e; - - if (!g_file_test (leasefile, G_FILE_TEST_EXISTS)) - return NULL; - - if (!g_file_get_contents (leasefile, &contents, NULL, error)) - return NULL; - - split = g_strsplit_set (contents, "\n\r", -1); - for (line = split; line && *line && (duid == NULL); line++) { - p = g_strstrip (*line); - if (g_str_has_prefix (p, DUID_PREFIX)) { - p += strlen (DUID_PREFIX); - - /* look for trailing "; */ - e = p + strlen (p) - 2; - if (strcmp (e, "\";") != 0) - continue; - *e = '\0'; - - duid = nm_dhcp_dhclient_unescape_duid (p); - } - } - g_free (contents); - g_strfreev (split); - - return duid; -} - -gboolean -nm_dhcp_dhclient_save_duid (const char *leasefile, - const char *escaped_duid, - GError **error) -{ - char **lines = NULL, **iter, *l; - GString *s; - gboolean success; - gsize len = 0; - - g_return_val_if_fail (leasefile != NULL, FALSE); - g_return_val_if_fail (escaped_duid != NULL, FALSE); - - if (g_file_test (leasefile, G_FILE_TEST_EXISTS)) { - char *contents = NULL; - - if (!g_file_get_contents (leasefile, &contents, &len, error)) { - g_prefix_error (error, "failed to read lease file %s: ", leasefile); - return FALSE; - } - - /* If the file already contains an uncommented DUID, leave it */ - g_assert (contents); - lines = g_strsplit_set (contents, "\n\r", -1); - g_free (contents); - for (iter = lines; iter && *iter; iter++) { - l = *iter; - while (g_ascii_isspace (*l)) - l++; - if (g_str_has_prefix (l, DUID_PREFIX)) { - g_strfreev (lines); - return TRUE; - } - } - } - - s = g_string_sized_new (len + 50); - g_string_append_printf (s, DUID_PREFIX "%s\";\n", escaped_duid); - - /* Preserve existing leasefile contents */ - if (lines) { - for (iter = lines; iter && *iter; iter++) - g_string_append (s, *iter[0] ? *iter : "\n"); - g_strfreev (lines); - } - - success = g_file_set_contents (leasefile, s->str, -1, error); - if (!success) - g_prefix_error (error, "failed to set DUID in lease file %s: ", leasefile); - - g_string_free (s, TRUE); - return success; -} - -static void -add_lease_option (GHashTable *hash, char *line) -{ - char *spc; - size_t len; - - /* Find the space after "option" */ - spc = strchr (line, ' '); - if (!spc) - return; - - /* Find the option tag's data, which is after the second space */ - if (g_str_has_prefix (line, "option ")) { - while (g_ascii_isspace (*spc)) - spc++; - spc = strchr (spc + 1, ' '); - if (!spc) - return; - } - - /* Split the line at the space */ - *spc = '\0'; - spc++; - - /* Kill the ';' at the end of the line, if any */ - len = strlen (spc); - if (*(spc + len - 1) == ';') - *(spc + len - 1) = '\0'; - - /* Strip leading quote */ - while (g_ascii_isspace (*spc)) - spc++; - if (*spc == '"') - spc++; - - /* Strip trailing quote */ - len = strlen (spc); - if (len > 0 && spc[len - 1] == '"') - spc[len - 1] = '\0'; - - if (spc[0]) - g_hash_table_insert (hash, g_strdup (line), g_strdup (spc)); -} - -#define LEASE_INVALID G_MININT64 -static GTimeSpan -lease_validity_span (const char *str_expire, GDateTime *now) -{ - GDateTime *expire = NULL; - struct tm expire_tm; - GTimeSpan span; - - g_return_val_if_fail (now != NULL, LEASE_INVALID); - g_return_val_if_fail (str_expire != NULL, LEASE_INVALID); - - /* Skip initial number (day of week?) */ - if (!isdigit (*str_expire++)) - return LEASE_INVALID; - if (!isspace (*str_expire++)) - return LEASE_INVALID; - /* Read lease expiration (in UTC) */ - if (!strptime (str_expire, "%t%Y/%m/%d %H:%M:%S", &expire_tm)) - return LEASE_INVALID; - - expire = g_date_time_new_utc (expire_tm.tm_year + 1900, - expire_tm.tm_mon + 1, - expire_tm.tm_mday, - expire_tm.tm_hour, - expire_tm.tm_min, - expire_tm.tm_sec); - if (!expire) - return LEASE_INVALID; - - span = g_date_time_difference (expire, now); - g_date_time_unref (expire); - - /* GDateTime only supports a range of less then 10000 years, so span can - * not overflow or be equal to LEASE_INVALID */ - return span; -} - -/** - * nm_dhcp_dhclient_read_lease_ip_configs: - * @iface: the interface name to match leases with - * @ifindex: interface index of @iface - * @contents: the contents of a dhclient leasefile - * @ipv6: whether to read IPv4 or IPv6 leases - * @now: the current UTC date/time; pass %NULL to automatically use current - * UTC time. Testcases may need a different value for 'now' - * - * Reads dhclient leases from @contents and parses them into either - * #NMIP4Config or #NMIP6Config objects depending on the value of @ipv6. - * - * Returns: a #GSList of #NMIP4Config objects (if @ipv6 is %FALSE) or a list of - * #NMIP6Config objects (if @ipv6 is %TRUE) containing the lease data. - */ -GSList * -nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, - int ifindex, - const char *contents, - gboolean ipv6, - GDateTime *now) -{ - GSList *parsed = NULL, *iter, *leases = NULL; - char **line, **split = NULL; - GHashTable *hash = NULL; - gint32 now_monotonic_ts; - - g_return_val_if_fail (contents != NULL, NULL); - - split = g_strsplit_set (contents, "\n\r", -1); - if (!split) - return NULL; - - for (line = split; line && *line; line++) { - *line = g_strstrip (*line); - - if (*line[0] == '#') { - /* Comment */ - } else if (!strcmp (*line, "}")) { - /* Lease ends */ - parsed = g_slist_append (parsed, hash); - hash = NULL; - } else if (!strcmp (*line, "lease {")) { - /* Beginning of a new lease */ - if (hash) { - /* Ignore malformed lease that doesn't end before new one starts */ - g_hash_table_destroy (hash); - } - - hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - } else if (hash && strlen (*line)) - add_lease_option (hash, *line); - } - g_strfreev (split); - - /* Check if the last lease in the file was properly ended */ - if (hash) { - /* Ignore malformed lease that doesn't end before new one starts */ - g_hash_table_destroy (hash); - hash = NULL; - } - - if (now) - g_date_time_ref (now); - else - now = g_date_time_new_now_utc (); - now_monotonic_ts = nm_utils_get_monotonic_timestamp_s (); - - for (iter = parsed; iter; iter = g_slist_next (iter)) { - NMIP4Config *ip4; - NMPlatformIP4Address address; - const char *value; - GTimeSpan expiry; - guint32 tmp, gw = 0; - - hash = iter->data; - - /* Make sure this lease is for the interface we want */ - value = g_hash_table_lookup (hash, "interface"); - if (!value || strcmp (value, iface)) - continue; - - value = g_hash_table_lookup (hash, "expire"); - if (!value) - continue; - expiry = lease_validity_span (value, now); - if (expiry == LEASE_INVALID) - continue; - - /* scale expiry to seconds (and CLAMP into the range of guint32) */ - expiry = CLAMP (expiry / G_TIME_SPAN_SECOND, 0, NM_PLATFORM_LIFETIME_PERMANENT-1); - if (expiry <= 0) { - /* the address is already expired. Don't even add it. */ - continue; - } - - memset (&address, 0, sizeof (address)); - - /* IP4 address */ - value = g_hash_table_lookup (hash, "fixed-address"); - if (!value) - continue; - if (!inet_pton (AF_INET, value, &address.address)) - continue; - address.peer_address = address.address; - - /* Gateway */ - value = g_hash_table_lookup (hash, "option routers"); - if (!value) - continue; - if (!inet_pton (AF_INET, value, &gw)) - continue; - - /* Netmask */ - value = g_hash_table_lookup (hash, "option subnet-mask"); - if (value && inet_pton (AF_INET, value, &tmp)) - address.plen = nm_utils_ip4_netmask_to_prefix (tmp); - - /* Get default netmask for the IP according to appropriate class. */ - if (!address.plen) - address.plen = nm_utils_ip4_get_default_prefix (address.address); - - address.timestamp = now_monotonic_ts; - address.lifetime = address.preferred = expiry; - address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; - - ip4 = nm_ip4_config_new (ifindex); - nm_ip4_config_add_address (ip4, &address); - nm_ip4_config_set_gateway (ip4, gw); - - value = g_hash_table_lookup (hash, "option domain-name-servers"); - if (value) { - char **dns, **dns_iter; - - dns = g_strsplit_set (value, ",", -1); - for (dns_iter = dns; dns_iter && *dns_iter; dns_iter++) { - if (inet_pton (AF_INET, *dns_iter, &tmp)) - nm_ip4_config_add_nameserver (ip4, tmp); - } - if (dns) - g_strfreev (dns); - } - - value = g_hash_table_lookup (hash, "option domain-name"); - if (value && value[0]) - nm_ip4_config_add_domain (ip4, value); - - /* FIXME: static routes */ - - leases = g_slist_append (leases, ip4); - } - - g_date_time_unref (now); - g_slist_free_full (parsed, (GDestroyNotify) g_hash_table_destroy); - return leases; -} - diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.h b/src/dhcp-manager/nm-dhcp-dhclient-utils.h deleted file mode 100644 index 83d5a23d..00000000 --- a/src/dhcp-manager/nm-dhcp-dhclient-utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2010 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_DHCLIENT_UTILS_H__ -#define __NETWORKMANAGER_DHCP_DHCLIENT_UTILS_H__ - -#include -#include - -char *nm_dhcp_dhclient_create_config (const char *interface, - gboolean is_ip6, - GBytes *client_id, - const char *anycast_addr, - const char *hostname, - const char *fqdn, - const char *orig_path, - const char *orig_contents, - GBytes **out_new_client_id); - -char *nm_dhcp_dhclient_escape_duid (const GByteArray *duid); - -GByteArray *nm_dhcp_dhclient_unescape_duid (const char *duid); - -GByteArray *nm_dhcp_dhclient_read_duid (const char *leasefile, GError **error); - -gboolean nm_dhcp_dhclient_save_duid (const char *leasefile, - const char *escaped_duid, - GError **error); - -GSList *nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, - int ifindex, - const char *contents, - gboolean ipv6, - GDateTime *now); - -GBytes *nm_dhcp_dhclient_get_client_id_from_config_file (const char *path); - -#endif /* __NETWORKMANAGER_DHCP_DHCLIENT_UTILS_H__ */ - diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c deleted file mode 100644 index bd020624..00000000 --- a/src/dhcp-manager/nm-dhcp-dhclient.c +++ /dev/null @@ -1,683 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-dhcp-dhclient.c - dhclient specific hooks for NetworkManager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2012 Red Hat, Inc. - */ - -#include -#define __CONFIG_H__ - -#define _XOPEN_SOURCE -#include -#undef _XOPEN_SOURCE - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-dhcp-dhclient.h" -#include "nm-utils.h" -#include "nm-dhcp-dhclient-utils.h" -#include "nm-dhcp-manager.h" -#include "NetworkManagerUtils.h" -#include "nm-dhcp-listener.h" -#include "nm-dhcp-client-logging.h" - -G_DEFINE_TYPE (NMDhcpDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT) - -#define NM_DHCP_DHCLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientPrivate)) - -typedef struct { - char *conf_file; - const char *def_leasefile; - char *lease_file; - char *pid_file; - NMDhcpListener *dhcp_listener; -} NMDhcpDhclientPrivate; - -static const char * -nm_dhcp_dhclient_get_path (void) -{ - const char *path = NULL; - - if (WITH_DHCLIENT) - path = nm_utils_find_helper ("dhclient", DHCLIENT_PATH, NULL); - return path; -} - -/** - * get_dhclient_leasefile(): - * @iface: the interface name of the device on which DHCP will be done - * @uuid: the connection UUID to which the returned lease should belong - * @ipv6: %TRUE for IPv6, %FALSE for IPv4 - * @out_preferred_path: on return, the "most preferred" leasefile path - * - * Returns the path of an existing leasefile (if any) for this interface and - * connection UUID. Also returns the "most preferred" leasefile path, which - * may be different than any found leasefile. - * - * Returns: an existing leasefile, or %NULL if no matching leasefile could be found - */ -static char * -get_dhclient_leasefile (const char *iface, - const char *uuid, - gboolean ipv6, - char **out_preferred_path) -{ - char *path; - - /* /var/lib/NetworkManager is the preferred leasefile path */ - path = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s-%s.lease", - ipv6 ? "6" : "", - uuid, - iface); - if (out_preferred_path) - *out_preferred_path = g_strdup (path); - - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - - /* If the leasefile we're looking for doesn't exist yet in the new location - * (eg, /var/lib/NetworkManager) then look in old locations to maintain - * backwards compatibility with external tools (like dracut) that put - * leasefiles there. - */ - - /* Old Debian, SUSE, and Mandriva location */ - g_free (path); - path = g_strdup_printf (LOCALSTATEDIR "/lib/dhcp/dhclient%s-%s-%s.lease", - ipv6 ? "6" : "", uuid, iface); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - - /* Old Red Hat and Fedora location */ - g_free (path); - path = g_strdup_printf (LOCALSTATEDIR "/lib/dhclient/dhclient%s-%s-%s.lease", - ipv6 ? "6" : "", uuid, iface); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - - /* Fail */ - g_free (path); - return NULL; -} - -static GSList * -nm_dhcp_dhclient_get_lease_ip_configs (const char *iface, - int ifindex, - const char *uuid, - gboolean ipv6, - guint32 default_route_metric) -{ - char *contents = NULL; - char *leasefile; - GSList *leases = NULL; - - leasefile = get_dhclient_leasefile (iface, uuid, FALSE, NULL); - if (!leasefile) - return NULL; - - if ( g_file_test (leasefile, G_FILE_TEST_EXISTS) - && g_file_get_contents (leasefile, &contents, NULL, NULL) - && contents - && contents[0]) - leases = nm_dhcp_dhclient_read_lease_ip_configs (iface, ifindex, contents, ipv6, NULL); - - g_free (leasefile); - g_free (contents); - - return leases; -} - -static gboolean -merge_dhclient_config (NMDhcpDhclient *self, - const char *iface, - const char *conf_file, - gboolean is_ip6, - GBytes *client_id, - const char *anycast_addr, - const char *hostname, - const char *fqdn, - const char *orig_path, - GBytes **out_new_client_id, - GError **error) -{ - char *orig = NULL, *new; - gboolean success = FALSE; - - g_return_val_if_fail (iface != NULL, FALSE); - g_return_val_if_fail (conf_file != NULL, FALSE); - - if (orig_path && g_file_test (orig_path, G_FILE_TEST_EXISTS)) { - GError *read_error = NULL; - - if (!g_file_get_contents (orig_path, &orig, NULL, &read_error)) { - _LOGW ("error reading dhclient configuration %s: %s", - orig_path, read_error->message); - g_error_free (read_error); - } - } - - if (is_ip6 && hostname && !strchr (hostname, '.')) - _LOGW ("hostname is not a FQDN, it will be ignored"); - - new = nm_dhcp_dhclient_create_config (iface, is_ip6, client_id, anycast_addr, hostname, fqdn, orig_path, orig, out_new_client_id); - g_assert (new); - success = g_file_set_contents (conf_file, new, -1, error); - g_free (new); - g_free (orig); - - return success; -} - -static char * -find_existing_config (NMDhcpDhclient *self, const char *iface, const char *uuid, gboolean ipv6) -{ - char *path; - - /* NetworkManager-overridden configuration can be used to ship DHCP config - * with NetworkManager itself. It can be uuid-specific, device-specific - * or generic. - */ - if (uuid) { - path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", uuid); - _LOGD ("looking for existing config %s", path); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - g_free (path); - } - - path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface); - _LOGD ("looking for existing config %s", path); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - g_free (path); - - path = g_strdup_printf (NMCONFDIR "/dhclient%s.conf", ipv6 ? "6" : ""); - _LOGD ("looking for existing config %s", path); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - g_free (path); - - /* Distribution's dhclient configuration is used so that we can use - * configuration shipped with dhclient (if any). - * - * This replaces conditional compilation based on distribution name. Fedora - * and Debian store the configs in /etc/dhcp while upstream defaults to /etc - * which is then used by many other distributions. Some distributions - * (including Fedora) don't even provide a default configuration file. - */ - path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s-%s.conf", ipv6 ? "6" : "", iface); - _LOGD ("looking for existing config %s", path); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - g_free (path); - - path = g_strdup_printf (SYSCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface); - _LOGD ("looking for existing config %s", path); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - g_free (path); - - path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s.conf", ipv6 ? "6" : ""); - _LOGD ("looking for existing config %s", path); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - g_free (path); - - path = g_strdup_printf (SYSCONFDIR "/dhclient%s.conf", ipv6 ? "6" : ""); - _LOGD ("looking for existing config %s", path); - if (g_file_test (path, G_FILE_TEST_EXISTS)) - return path; - g_free (path); - - return NULL; -} - - -/* NM provides interface-specific options; thus the same dhclient config - * file cannot be used since DHCP transactions can happen in parallel. - * Since some distros don't have default per-interface dhclient config files, - * read their single config file and merge that into a custom per-interface - * config file along with the NM options. - */ -static char * -create_dhclient_config (NMDhcpDhclient *self, - const char *iface, - gboolean is_ip6, - const char *uuid, - GBytes *client_id, - const char *dhcp_anycast_addr, - const char *hostname, - const char *fqdn, - GBytes **out_new_client_id) -{ - char *orig = NULL, *new = NULL; - GError *error = NULL; - gboolean success = FALSE; - - g_return_val_if_fail (iface != NULL, NULL); - - new = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s.conf", is_ip6 ? "6" : "", iface); - _LOGD ("creating composite dhclient config %s", new); - - orig = find_existing_config (self, iface, uuid, is_ip6); - if (orig) - _LOGD ("merging existing dhclient config %s", orig); - else - _LOGD ("no existing dhclient configuration to merge"); - - error = NULL; - success = merge_dhclient_config (self, iface, new, is_ip6, client_id, dhcp_anycast_addr, - hostname, fqdn, orig, out_new_client_id, &error); - if (!success) { - _LOGW ("error creating dhclient configuration: %s", error->message); - g_error_free (error); - } - - g_free (orig); - return new; -} - - -static gboolean -dhclient_start (NMDhcpClient *client, - const char *mode_opt, - const GByteArray *duid, - gboolean release, - pid_t *out_pid) -{ - NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); - GPtrArray *argv = NULL; - pid_t pid; - GError *error = NULL; - const char *iface, *uuid, *system_bus_address, *dhclient_path = NULL; - char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL; - gboolean ipv6, success; - char *escaped, *preferred_leasefile_path = NULL; - - g_return_val_if_fail (priv->pid_file == NULL, FALSE); - - iface = nm_dhcp_client_get_iface (client); - uuid = nm_dhcp_client_get_uuid (client); - ipv6 = nm_dhcp_client_get_ipv6 (client); - - dhclient_path = nm_dhcp_dhclient_get_path (); - if (!dhclient_path) { - _LOGW ("dhclient could not be found"); - return FALSE; - } - - pid_file = g_strdup_printf (RUNSTATEDIR "/dhclient%s-%s.pid", - ipv6 ? "6" : "", - iface); - - /* Kill any existing dhclient from the pidfile */ - binary_name = g_path_get_basename (dhclient_path); - nm_dhcp_client_stop_existing (pid_file, binary_name); - g_free (binary_name); - - if (release) { - /* release doesn't use the pidfile after killing an old client */ - g_free (pid_file); - pid_file = NULL; - } - - g_free (priv->lease_file); - priv->lease_file = get_dhclient_leasefile (iface, uuid, ipv6, &preferred_leasefile_path); - if (!priv->lease_file) { - /* No existing leasefile, dhclient will create one at the preferred path */ - priv->lease_file = g_strdup (preferred_leasefile_path); - } else if (g_strcmp0 (priv->lease_file, preferred_leasefile_path) != 0) { - GFile *src = g_file_new_for_path (priv->lease_file); - GFile *dst = g_file_new_for_path (preferred_leasefile_path); - - /* Try to copy the existing leasefile to the preferred location */ - if (g_file_copy (src, dst, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error)) { - /* Success; use the preferred leasefile path */ - g_free (priv->lease_file); - priv->lease_file = g_strdup (g_file_get_path (dst)); - } else { - /* Failure; just use the existing leasefile */ - _LOGW ("failed to copy leasefile %s to %s: %s", - g_file_get_path (src), g_file_get_path (dst), - error->message); - g_clear_error (&error); - } - g_object_unref (src); - g_object_unref (dst); - } - g_free (preferred_leasefile_path); - - /* Save the DUID to the leasefile dhclient will actually use */ - if (ipv6) { - escaped = nm_dhcp_dhclient_escape_duid (duid); - success = nm_dhcp_dhclient_save_duid (priv->lease_file, escaped, &error); - g_free (escaped); - if (!success) { - _LOGW ("failed to save DUID to %s: %s", priv->lease_file, error->message); - g_free (pid_file); - return FALSE; - } - } - - argv = g_ptr_array_new (); - g_ptr_array_add (argv, (gpointer) dhclient_path); - - g_ptr_array_add (argv, (gpointer) "-d"); - - /* Be quiet. dhclient logs to syslog anyway. And we duplicate the syslog - * to stderr in case of NM running with --debug. - */ - g_ptr_array_add (argv, (gpointer) "-q"); - - if (release) - g_ptr_array_add (argv, (gpointer) "-r"); - - if (ipv6) { - g_ptr_array_add (argv, (gpointer) "-6"); - if (mode_opt) - g_ptr_array_add (argv, (gpointer) mode_opt); - } - g_ptr_array_add (argv, (gpointer) "-sf"); /* Set script file */ - g_ptr_array_add (argv, (gpointer) nm_dhcp_helper_path); - - if (pid_file) { - g_ptr_array_add (argv, (gpointer) "-pf"); /* Set pid file */ - g_ptr_array_add (argv, (gpointer) pid_file); - } - - g_ptr_array_add (argv, (gpointer) "-lf"); /* Set lease file */ - g_ptr_array_add (argv, (gpointer) priv->lease_file); - - if (priv->conf_file) { - g_ptr_array_add (argv, (gpointer) "-cf"); /* Set interface config file */ - g_ptr_array_add (argv, (gpointer) priv->conf_file); - } - - /* Usually the system bus address is well-known; but if it's supposed - * to be something else, we need to push it to dhclient, since dhclient - * sanitizes the environment it gives the action scripts. - */ - system_bus_address = getenv ("DBUS_SYSTEM_BUS_ADDRESS"); - if (system_bus_address) { - system_bus_address_env = g_strdup_printf ("DBUS_SYSTEM_BUS_ADDRESS=%s", system_bus_address); - g_ptr_array_add (argv, (gpointer) "-e"); - g_ptr_array_add (argv, (gpointer) system_bus_address_env); - } - - - g_ptr_array_add (argv, (gpointer) iface); - g_ptr_array_add (argv, NULL); - - cmd_str = g_strjoinv (" ", (gchar **) argv->pdata); - _LOGD ("running: %s", cmd_str); - g_free (cmd_str); - - if (g_spawn_async (NULL, (char **) argv->pdata, NULL, - G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, - nm_utils_setpgid, NULL, &pid, &error)) { - g_assert (pid > 0); - _LOGI ("dhclient started with pid %d", pid); - if (release == FALSE) - nm_dhcp_client_watch_child (client, pid); - priv->pid_file = pid_file; - } else { - _LOGW ("dhclient failed to start: '%s'", error->message); - g_error_free (error); - g_free (pid_file); - } - - if (out_pid) - *out_pid = pid; - - g_ptr_array_free (argv, TRUE); - g_free (system_bus_address_env); - return pid > 0 ? TRUE : FALSE; -} - -static gboolean -ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address) -{ - NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); - GBytes *client_id; - gs_unref_bytes GBytes *new_client_id = NULL; - const char *iface, *uuid, *hostname, *fqdn; - gboolean success = FALSE; - - iface = nm_dhcp_client_get_iface (client); - uuid = nm_dhcp_client_get_uuid (client); - client_id = nm_dhcp_client_get_client_id (client); - hostname = nm_dhcp_client_get_hostname (client); - fqdn = nm_dhcp_client_get_fqdn (client); - - priv->conf_file = create_dhclient_config (self, iface, FALSE, uuid, client_id, dhcp_anycast_addr, - hostname, fqdn, &new_client_id); - if (priv->conf_file) { - if (new_client_id) - nm_dhcp_client_set_client_id (client, new_client_id); - success = dhclient_start (client, NULL, NULL, FALSE, NULL); - } else - _LOGW ("error creating dhclient configuration file"); - - return success; -} - -static gboolean -ip6_start (NMDhcpClient *client, - const char *dhcp_anycast_addr, - const struct in6_addr *ll_addr, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy, - const GByteArray *duid) -{ - NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); - const char *iface, *uuid, *hostname; - - iface = nm_dhcp_client_get_iface (client); - uuid = nm_dhcp_client_get_uuid (client); - hostname = nm_dhcp_client_get_hostname (client); - - priv->conf_file = create_dhclient_config (self, iface, TRUE, uuid, NULL, dhcp_anycast_addr, hostname, NULL, NULL); - if (!priv->conf_file) { - _LOGW ("error creating dhclient configuration file"); - return FALSE; - } - - return dhclient_start (client, info_only ? "-S" : "-N", duid, FALSE, NULL); -} - -static void -stop (NMDhcpClient *client, gboolean release, const GByteArray *duid) -{ - NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); - - /* Chain up to parent */ - NM_DHCP_CLIENT_CLASS (nm_dhcp_dhclient_parent_class)->stop (client, release, duid); - - if (priv->conf_file) - if (remove (priv->conf_file) == -1) - _LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errno, g_strerror (errno)); - if (priv->pid_file) { - if (remove (priv->pid_file) == -1) - _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno)); - g_free (priv->pid_file); - priv->pid_file = NULL; - } - - if (release) { - pid_t rpid = -1; - - if (dhclient_start (client, NULL, duid, TRUE, &rpid)) { - /* Wait a few seconds for the release to happen */ - nm_dhcp_client_stop_pid (rpid, nm_dhcp_client_get_iface (client)); - } - } -} - -static void -state_changed (NMDhcpClient *client, - NMDhcpState state, - GObject *ip_config, - GHashTable *options) -{ - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client); - gs_unref_bytes GBytes *client_id = NULL; - - if (nm_dhcp_client_get_client_id (client)) - return; - if (state != NM_DHCP_STATE_BOUND) - return; - - client_id = nm_dhcp_dhclient_get_client_id_from_config_file (priv->conf_file); - nm_dhcp_client_set_client_id (client, client_id); -} - -static GByteArray * -get_duid (NMDhcpClient *client) -{ - NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); - GByteArray *duid = NULL; - char *leasefile; - GError *error = NULL; - - /* Look in interface-specific leasefile first for backwards compat */ - leasefile = get_dhclient_leasefile (nm_dhcp_client_get_iface (client), - nm_dhcp_client_get_uuid (client), - TRUE, - NULL); - if (leasefile) { - _LOGD ("looking for DUID in '%s'", leasefile); - duid = nm_dhcp_dhclient_read_duid (leasefile, &error); - - if (error) { - _LOGW ("failed to read leasefile '%s': %s", - leasefile, error->message); - g_clear_error (&error); - } - g_free (leasefile); - } - - if (!duid && priv->def_leasefile) { - /* Otherwise read the default machine-wide DUID */ - _LOGD ("looking for default DUID in '%s'", priv->def_leasefile); - duid = nm_dhcp_dhclient_read_duid (priv->def_leasefile, &error); - if (error) { - _LOGW ("failed to read leasefile '%s': %s", - priv->def_leasefile, - error->message); - g_clear_error (&error); - } - } - - /* return our DUID, otherwise let the parent class make a default DUID */ - return duid ? duid : NM_DHCP_CLIENT_CLASS (nm_dhcp_dhclient_parent_class)->get_duid (client); -} - -/***************************************************/ - -static const char *def_leasefiles[] = { - SYSCONFDIR "/dhclient6.leases", - LOCALSTATEDIR "/lib/dhcp/dhclient6.leases", - LOCALSTATEDIR "/lib/dhclient/dhclient6.leases", - NULL -}; - -static void -nm_dhcp_dhclient_init (NMDhcpDhclient *self) -{ - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); - const char **iter = &def_leasefiles[0]; - - while (iter && *iter) { - if (g_file_test (*iter, G_FILE_TEST_EXISTS)) { - priv->def_leasefile = *iter; - break; - } - iter++; - } - - /* Fallback option */ - if (!priv->def_leasefile) - priv->def_leasefile = SYSCONFDIR "/dhclient6.leases"; - - priv->dhcp_listener = g_object_ref (nm_dhcp_listener_get ()); - g_signal_connect (priv->dhcp_listener, - NM_DHCP_LISTENER_EVENT, - G_CALLBACK (nm_dhcp_client_handle_event), - self); -} - -static void -dispose (GObject *object) -{ - NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (object); - - if (priv->dhcp_listener) { - g_signal_handlers_disconnect_by_func (priv->dhcp_listener, - G_CALLBACK (nm_dhcp_client_handle_event), - NM_DHCP_DHCLIENT (object)); - g_clear_object (&priv->dhcp_listener); - } - - g_free (priv->pid_file); - g_free (priv->conf_file); - g_free (priv->lease_file); - - G_OBJECT_CLASS (nm_dhcp_dhclient_parent_class)->dispose (object); -} - -static void -nm_dhcp_dhclient_class_init (NMDhcpDhclientClass *dhclient_class) -{ - NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS (dhclient_class); - GObjectClass *object_class = G_OBJECT_CLASS (dhclient_class); - - g_type_class_add_private (dhclient_class, sizeof (NMDhcpDhclientPrivate)); - - /* virtual methods */ - object_class->dispose = dispose; - - client_class->ip4_start = ip4_start; - client_class->ip6_start = ip6_start; - client_class->stop = stop; - client_class->get_duid = get_duid; - client_class->state_changed = state_changed; -} - -static void __attribute__((constructor)) -register_dhcp_dhclient (void) -{ - nm_g_type_init (); - _nm_dhcp_client_register (NM_TYPE_DHCP_DHCLIENT, - "dhclient", - nm_dhcp_dhclient_get_path, - nm_dhcp_dhclient_get_lease_ip_configs); -} - diff --git a/src/dhcp-manager/nm-dhcp-dhclient.h b/src/dhcp-manager/nm-dhcp-dhclient.h deleted file mode 100644 index 7f0c855a..00000000 --- a/src/dhcp-manager/nm-dhcp-dhclient.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2010 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_DHCLIENT_H__ -#define __NETWORKMANAGER_DHCP_DHCLIENT_H__ - -#include "nm-dhcp-client.h" - -#define NM_TYPE_DHCP_DHCLIENT (nm_dhcp_dhclient_get_type ()) -#define NM_DHCP_DHCLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclient)) -#define NM_DHCP_DHCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) -#define NM_IS_DHCP_DHCLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_DHCLIENT)) -#define NM_IS_DHCP_DHCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_DHCLIENT)) -#define NM_DHCP_DHCLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) - -typedef struct { - NMDhcpClient parent; -} NMDhcpDhclient; - -typedef struct { - NMDhcpClientClass parent; -} NMDhcpDhclientClass; - -GType nm_dhcp_dhclient_get_type (void); - -#endif /* __NETWORKMANAGER_DHCP_DHCLIENT_H__ */ - diff --git a/src/dhcp-manager/nm-dhcp-dhcpcd.c b/src/dhcp-manager/nm-dhcp-dhcpcd.c deleted file mode 100644 index 17ec993a..00000000 --- a/src/dhcp-manager/nm-dhcp-dhcpcd.c +++ /dev/null @@ -1,246 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-dhcp-dhcpcd.c - dhcpcd specific hooks for NetworkManager - * - * Copyright (C) 2008 Roy Marples - * Copyright (C) 2010 Dan Williams - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "nm-dhcp-dhcpcd.h" -#include "nm-dhcp-manager.h" -#include "nm-utils.h" -#include "NetworkManagerUtils.h" -#include "nm-dhcp-listener.h" -#include "nm-dhcp-client-logging.h" - -G_DEFINE_TYPE (NMDhcpDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_CLIENT) - -#define NM_DHCP_DHCPCD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdPrivate)) - -typedef struct { - char *pid_file; - NMDhcpListener *dhcp_listener; -} NMDhcpDhcpcdPrivate; - -static const char * -nm_dhcp_dhcpcd_get_path (void) -{ - const char *path = NULL; - - if (WITH_DHCPCD) - path = nm_utils_find_helper ("dhcpcd", DHCPCD_PATH, NULL); - return path; -} - -static gboolean -ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address) -{ - NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client); - NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self); - GPtrArray *argv = NULL; - pid_t pid = -1; - GError *error = NULL; - char *pid_contents = NULL, *binary_name, *cmd_str, *dot; - const char *iface, *dhcpcd_path, *hostname, *fqdn; - gs_free char *prefix = NULL; - - g_return_val_if_fail (priv->pid_file == NULL, FALSE); - - iface = nm_dhcp_client_get_iface (client); - - /* dhcpcd does not allow custom pidfiles; the pidfile is always - * RUNDIR "dhcpcd-.pid". - */ - priv->pid_file = g_strdup_printf (RUNDIR "/dhcpcd-%s.pid", iface); - - dhcpcd_path = nm_dhcp_dhcpcd_get_path (); - if (!dhcpcd_path) { - _LOGW ("dhcpcd could not be found"); - return FALSE; - } - - /* Kill any existing dhcpcd from the pidfile */ - binary_name = g_path_get_basename (dhcpcd_path); - nm_dhcp_client_stop_existing (priv->pid_file, binary_name); - g_free (binary_name); - - argv = g_ptr_array_new (); - g_ptr_array_add (argv, (gpointer) dhcpcd_path); - - g_ptr_array_add (argv, (gpointer) "-B"); /* Don't background on lease (disable fork()) */ - - g_ptr_array_add (argv, (gpointer) "-K"); /* Disable built-in carrier detection */ - - g_ptr_array_add (argv, (gpointer) "-L"); /* Disable built-in IPv4LL */ - - /* --noarp. Don't request or claim the address by ARP; this also disables IPv4LL. */ - g_ptr_array_add (argv, (gpointer) "-A"); - - g_ptr_array_add (argv, (gpointer) "-G"); /* Let NM handle routing */ - - g_ptr_array_add (argv, (gpointer) "-c"); /* Set script file */ - g_ptr_array_add (argv, (gpointer) nm_dhcp_helper_path); - -#ifdef DHCPCD_SUPPORTS_IPV6 - /* IPv4-only for now. NetworkManager knows better than dhcpcd when to - * run IPv6, and dhcpcd's automatic Router Solicitations cause problems - * with devices that don't expect them. - */ - g_ptr_array_add (argv, (gpointer) "-4"); -#endif - - hostname = nm_dhcp_client_get_hostname (client); - fqdn = nm_dhcp_client_get_fqdn (client); - - if (fqdn) { - g_ptr_array_add (argv, (gpointer) "-h"); - g_ptr_array_add (argv, (gpointer) fqdn); - g_ptr_array_add (argv, (gpointer) "-F"); - g_ptr_array_add (argv, (gpointer) "both"); - } else if (hostname) { - prefix = strdup (hostname); - dot = strchr (prefix, '.'); - /* get rid of the domain */ - if (dot) - *dot = '\0'; - - g_ptr_array_add (argv, (gpointer) "-h"); /* Send hostname to DHCP server */ - g_ptr_array_add (argv, (gpointer) prefix); - } - - g_ptr_array_add (argv, (gpointer) iface); - g_ptr_array_add (argv, NULL); - - cmd_str = g_strjoinv (" ", (gchar **) argv->pdata); - _LOGD ("running: %s", cmd_str); - g_free (cmd_str); - - if (g_spawn_async (NULL, (char **) argv->pdata, NULL, - G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, - nm_utils_setpgid, NULL, &pid, &error)) { - g_assert (pid > 0); - _LOGI ("dhcpcd started with pid %d", pid); - nm_dhcp_client_watch_child (client, pid); - } else { - _LOGW ("dhcpcd failed to start, error: '%s'", error->message); - g_error_free (error); - } - - g_free (pid_contents); - g_ptr_array_free (argv, TRUE); - return pid > 0 ? TRUE : FALSE; -} - -static gboolean -ip6_start (NMDhcpClient *client, - const char *dhcp_anycast_addr, - const struct in6_addr *ll_addr, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy, - const GByteArray *duid) -{ - NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client); - - _LOGW ("the dhcpcd backend does not support IPv6"); - return FALSE; -} - -static void -stop (NMDhcpClient *client, gboolean release, const GByteArray *duid) -{ - NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client); - NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self); - - /* Chain up to parent */ - NM_DHCP_CLIENT_CLASS (nm_dhcp_dhcpcd_parent_class)->stop (client, release, duid); - - if (priv->pid_file) { - if (remove (priv->pid_file) == -1) - _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno)); - } - - /* FIXME: implement release... */ -} - -/***************************************************/ - -static void -nm_dhcp_dhcpcd_init (NMDhcpDhcpcd *self) -{ - NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self); - - priv->dhcp_listener = g_object_ref (nm_dhcp_listener_get ()); - g_signal_connect (priv->dhcp_listener, - NM_DHCP_LISTENER_EVENT, - G_CALLBACK (nm_dhcp_client_handle_event), - self); -} - -static void -dispose (GObject *object) -{ - NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (object); - - if (priv->dhcp_listener) { - g_signal_handlers_disconnect_by_func (priv->dhcp_listener, - G_CALLBACK (nm_dhcp_client_handle_event), - NM_DHCP_DHCPCD (object)); - g_clear_object (&priv->dhcp_listener); - } - - g_free (priv->pid_file); - - G_OBJECT_CLASS (nm_dhcp_dhcpcd_parent_class)->dispose (object); -} - -static void -nm_dhcp_dhcpcd_class_init (NMDhcpDhcpcdClass *dhcpcd_class) -{ - NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS (dhcpcd_class); - GObjectClass *object_class = G_OBJECT_CLASS (dhcpcd_class); - - g_type_class_add_private (dhcpcd_class, sizeof (NMDhcpDhcpcdPrivate)); - - /* virtual methods */ - object_class->dispose = dispose; - - client_class->ip4_start = ip4_start; - client_class->ip6_start = ip6_start; - client_class->stop = stop; -} - -static void __attribute__((constructor)) -register_dhcp_dhclient (void) -{ - nm_g_type_init (); - _nm_dhcp_client_register (NM_TYPE_DHCP_DHCPCD, - "dhcpcd", - nm_dhcp_dhcpcd_get_path, - NULL); -} - diff --git a/src/dhcp-manager/nm-dhcp-dhcpcd.h b/src/dhcp-manager/nm-dhcp-dhcpcd.h deleted file mode 100644 index 6f15ad22..00000000 --- a/src/dhcp-manager/nm-dhcp-dhcpcd.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2010 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_DHCPCD_H__ -#define __NETWORKMANAGER_DHCP_DHCPCD_H__ - -#include "nm-dhcp-client.h" - -#define NM_TYPE_DHCP_DHCPCD (nm_dhcp_dhcpcd_get_type ()) -#define NM_DHCP_DHCPCD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcd)) -#define NM_DHCP_DHCPCD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) -#define NM_IS_DHCP_DHCPCD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_DHCPCD)) -#define NM_IS_DHCP_DHCPCD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_DHCPCD)) -#define NM_DHCP_DHCPCD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) - -typedef struct { - NMDhcpClient parent; -} NMDhcpDhcpcd; - -typedef struct { - NMDhcpClientClass parent; -} NMDhcpDhcpcdClass; - -GType nm_dhcp_dhcpcd_get_type (void); - -#endif /* __NETWORKMANAGER_DHCP_DHCPCD_H__ */ - diff --git a/src/dhcp-manager/nm-dhcp-helper-api.h b/src/dhcp-manager/nm-dhcp-helper-api.h deleted file mode 100644 index a3eb171d..00000000 --- a/src/dhcp-manager/nm-dhcp-helper-api.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2016 Red Hat, Inc. - */ - -#ifndef __NM_DHCP_HELPER_API_H__ -#define __NM_DHCP_HELPER_API_H__ - -/******************************************************************************/ - -#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client" - -#define NM_DHCP_HELPER_SERVER_BUS_NAME "org.freedesktop.nm_dhcp_server" -#define NM_DHCP_HELPER_SERVER_OBJECT_PATH "/org/freedesktop/nm_dhcp_server" -#define NM_DHCP_HELPER_SERVER_INTERFACE_NAME "org.freedesktop.nm_dhcp_server" -#define NM_DHCP_HELPER_SERVER_METHOD_NOTIFY "Notify" - -/******************************************************************************/ - -#endif /* __NM_DHCP_HELPER_API_H__ */ diff --git a/src/dhcp-manager/nm-dhcp-helper.c b/src/dhcp-manager/nm-dhcp-helper.c deleted file mode 100644 index 9c6f69b8..00000000 --- a/src/dhcp-manager/nm-dhcp-helper.c +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2013 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-utils/nm-vpn-plugin-macros.h" - -#include "nm-dhcp-helper-api.h" - -/*****************************************************************************/ - -#ifdef NM_MORE_LOGGING -#define _NMLOG_ENABLED(level) TRUE -#else -#define _NMLOG_ENABLED(level) ((level) <= LOG_ERR) -#endif - -#define _NMLOG(always_enabled, level, ...) \ - G_STMT_START { \ - if ((always_enabled) || _NMLOG_ENABLED (level)) { \ - GTimeVal _tv; \ - \ - g_get_current_time (&_tv); \ - g_print ("nm-dhcp-helper[%ld] %-7s [%ld.%04ld] " _NM_UTILS_MACRO_FIRST (__VA_ARGS__) "\n", \ - (long) getpid (), \ - nm_utils_syslog_to_str (level), \ - _tv.tv_sec, _tv.tv_usec / 100 \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -#define _LOGD(...) _NMLOG(TRUE, LOG_INFO, __VA_ARGS__) -#define _LOGI(...) _NMLOG(TRUE, LOG_NOTICE, __VA_ARGS__) -#define _LOGW(...) _NMLOG(TRUE, LOG_WARNING, __VA_ARGS__) -#define _LOGE(...) _NMLOG(TRUE, LOG_ERR, __VA_ARGS__) - -#define _LOGd(...) _NMLOG(FALSE, LOG_INFO, __VA_ARGS__) -#define _LOGi(...) _NMLOG(FALSE, LOG_NOTICE, __VA_ARGS__) -#define _LOGw(...) _NMLOG(FALSE, LOG_WARNING, __VA_ARGS__) - -/*****************************************************************************/ - -static const char * ignore[] = {"PATH", "SHLVL", "_", "PWD", "dhc_dbus", NULL}; - -static GVariant * -build_signal_parameters (void) -{ - char **item; - GVariantBuilder builder; - - g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); - - /* List environment and format for dbus dict */ - for (item = environ; *item; item++) { - char *name, *val, **p; - - /* Split on the = */ - name = g_strdup (*item); - val = strchr (name, '='); - if (!val || val == name) - goto next; - *val++ = '\0'; - - /* Ignore non-DCHP-related environment variables */ - for (p = (char **) ignore; *p; p++) { - if (strncmp (name, *p, strlen (*p)) == 0) - goto next; - } - - /* Value passed as a byte array rather than a string, because there are - * no character encoding guarantees with DHCP, and D-Bus requires - * strings to be UTF-8. - * - * Note that we can't use g_variant_new_bytestring() here, because that - * includes the trailing '\0'. (??!?) - */ - g_variant_builder_add (&builder, "{sv}", - name, - g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, - val, strlen (val), 1)); - - next: - g_free (name); - } - - return g_variant_ref_sink (g_variant_new ("(a{sv})", &builder)); -} - -static void -kill_pid (void) -{ - const char *pid_str; - pid_t pid = 0; - - pid_str = getenv ("pid"); - if (pid_str) - pid = strtol (pid_str, NULL, 10); - if (pid) { - _LOGI ("a fatal error occured, kill dhclient instance with pid %d\n", pid); - kill (pid, SIGTERM); - } -} - -int -main (int argc, char *argv[]) -{ - gs_unref_object GDBusConnection *connection = NULL; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *parameters = NULL; - gs_unref_variant GVariant *result = NULL; - gboolean success = FALSE; - guint try_count = 0; - gint64 time_end; - - nm_g_type_init (); - - connection = g_dbus_connection_new_for_address_sync ("unix:path=" NMRUNDIR "/private-dhcp", - G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, - NULL, NULL, &error); - if (!connection) { - g_dbus_error_strip_remote_error (error); - _LOGE ("could not connect to NetworkManager D-Bus socket: %s", - error->message); - goto out; - } - - parameters = build_signal_parameters (); - - time_end = g_get_monotonic_time () + (200 * 1000L); /* retry for at most 200 milliseconds */ - -do_notify: - try_count++; - result = g_dbus_connection_call_sync (connection, - NULL, - NM_DHCP_HELPER_SERVER_OBJECT_PATH, - NM_DHCP_HELPER_SERVER_INTERFACE_NAME, - NM_DHCP_HELPER_SERVER_METHOD_NOTIFY, - parameters, - NULL, - G_DBUS_CALL_FLAGS_NONE, - 1000, - NULL, - &error); - - if (!result) { - gs_free char *s_err = NULL; - - s_err = g_dbus_error_get_remote_error (error); - if (NM_IN_STRSET (s_err, "org.freedesktop.DBus.Error.UnknownMethod")) { - gint64 remaining_time = time_end - g_get_monotonic_time (); - - /* I am not sure that a race can actually happen, as we register the object - * on the server side during GDBusServer:new-connection signal. - * - * However, there was also a race for subscribing to an event, so let's just - * do some retry. */ - if (remaining_time > 0) { - _LOGi ("failure to call notify: %s (retry %u)", error->message, try_count); - g_usleep (NM_MIN (NM_CLAMP ((gint64) (100L * (1L << try_count)), 5000, 25000), remaining_time)); - g_clear_error (&error); - goto do_notify; - } - } - _LOGW ("failure to call notify: %s (try signal via Event)", error->message); - g_clear_error (&error); - - /* for backward compatibilty, try to emit the signal. There is no stable - * API between the dhcp-helper and NetworkManager. However, while upgrading - * the NetworkManager package, a newer helper might want to notify an - * older server, which still uses the "Event". */ - if (!g_dbus_connection_emit_signal (connection, - NULL, - "/", - NM_DHCP_CLIENT_DBUS_IFACE, - "Event", - parameters, - &error)) { - g_dbus_error_strip_remote_error (error); - _LOGE ("could not send DHCP Event signal: %s", error->message); - goto out; - } - /* We were able to send the asynchronous Event. Consider that a success. */ - success = TRUE; - } else - success = TRUE; - - if (!g_dbus_connection_flush_sync (connection, NULL, &error)) { - g_dbus_error_strip_remote_error (error); - _LOGE ("could not flush D-Bus connection: %s", error->message); - success = FALSE; - goto out; - } - -out: - if (!success) - kill_pid (); - return success ? EXIT_SUCCESS : EXIT_FAILURE; -} - diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c deleted file mode 100644 index 0df41973..00000000 --- a/src/dhcp-manager/nm-dhcp-listener.c +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 - 2016 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include "nm-dhcp-listener.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "nm-dhcp-helper-api.h" -#include "nm-core-internal.h" -#include "nm-bus-manager.h" -#include "NetworkManagerUtils.h" - -#define PRIV_SOCK_PATH NMRUNDIR "/private-dhcp" -#define PRIV_SOCK_TAG "dhcp" - -/*****************************************************************************/ - -typedef struct { - NMBusManager * dbus_mgr; - gulong new_conn_id; - gulong dis_conn_id; - GHashTable * connections; -} NMDhcpListenerPrivate; - -struct _NMDhcpListener { - GObject parent; - NMDhcpListenerPrivate _priv; -}; - -struct _NMDhcpListenerClass { - GObjectClass parent_class; -}; - -enum { - EVENT, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE (NMDhcpListener, nm_dhcp_listener, G_TYPE_OBJECT) - -#define NM_DHCP_LISTENER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDhcpListener, NM_IS_DHCP_LISTENER) - -NM_DEFINE_SINGLETON_GETTER (NMDhcpListener, nm_dhcp_listener_get, NM_TYPE_DHCP_LISTENER); - -/*****************************************************************************/ - -#define _NMLOG_PREFIX_NAME "dhcp-listener" -#define _NMLOG_DOMAIN LOGD_DHCP -#define _NMLOG(level, ...) \ - G_STMT_START { \ - const NMDhcpListener *_self = (self); \ - char _prefix[64]; \ - \ - nm_log ((level), (_NMLOG_DOMAIN), \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - (_self != singleton_instance \ - ? nm_sprintf_buf (_prefix, "%s[%p]", _NMLOG_PREFIX_NAME, _self) \ - : _NMLOG_PREFIX_NAME )\ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -/*****************************************************************************/ - -static char * -get_option (GVariant *options, const char *key) -{ - GVariant *value; - const guchar *bytes, *s; - gsize len; - char *converted, *d; - - 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. - */ - 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 (*s == '\0') - *d = ' '; - else if (*s > 127) - *d = '?'; - else - *d = *s; - } - *d = '\0'; - g_variant_unref (value); - - return converted; -} - -static void -_method_call (GDBusConnection *connection, - const char *sender, - const char *object_path, - const char *interface_name, - const char *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - NMDhcpListener *self = NM_DHCP_LISTENER (user_data); - char *iface = NULL; - char *pid_str = NULL; - char *reason = NULL; - gint pid; - gboolean handled = FALSE; - GVariant *options; - - if (!nm_streq0 (interface_name, NM_DHCP_HELPER_SERVER_INTERFACE_NAME)) - g_return_if_reached (); - if (!nm_streq0 (method_name, NM_DHCP_HELPER_SERVER_METHOD_NOTIFY)) - g_return_if_reached (); - if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})"))) - g_return_if_reached (); - - g_variant_get (parameters, "(@a{sv})", &options); - - iface = get_option (options, "interface"); - if (iface == NULL) { - _LOGW ("dhcp-event: didn't have associated interface."); - goto out; - } - - pid_str = get_option (options, "pid"); - pid = _nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1); - if (pid == -1) { - _LOGW ("dhcp-event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)"); - goto out; - } - - reason = get_option (options, "reason"); - if (reason == NULL) { - _LOGW ("dhcp-event: (pid %d) DHCP event didn't have a reason", pid); - goto out; - } - - g_signal_emit (self, signals[EVENT], 0, iface, pid, options, reason, &handled); - if (!handled) { - if (g_ascii_strcasecmp (reason, "RELEASE") == 0) { - /* Ignore event when the dhcp client gets killed and we receive its last message */ - _LOGD ("dhcp-event: (pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface); - } else - _LOGW ("dhcp-event: (pid %d) unhandled DHCP event for interface %s", pid, iface); - } - -out: - g_free (iface); - g_free (pid_str); - g_free (reason); - g_variant_unref (options); - g_dbus_method_invocation_return_value (invocation, NULL); -} - -static guint -_dbus_connection_register_object (NMDhcpListener *self, - GDBusConnection *connection, - GError **error) -{ - static GDBusArgInfo arg_info_notify_in = { - .ref_count = -1, - .name = "data", - .signature = "a{sv}", - .annotations = NULL, - }; - static GDBusArgInfo *arg_infos_notify[] = { - &arg_info_notify_in, - NULL, - }; - static GDBusMethodInfo method_info_notify = { - .ref_count = -1, - .name = NM_DHCP_HELPER_SERVER_METHOD_NOTIFY, - .in_args = arg_infos_notify, - .out_args = NULL, - .annotations = NULL, - }; - static GDBusMethodInfo *method_infos[] = { - &method_info_notify, - NULL, - }; - static GDBusInterfaceInfo interface_info = { - .ref_count = -1, - .name = NM_DHCP_HELPER_SERVER_INTERFACE_NAME, - .methods = method_infos, - .signals = NULL, - .properties = NULL, - .annotations = NULL, - }; - - static GDBusInterfaceVTable interface_vtable = { - .method_call = _method_call, - .get_property = NULL, - .set_property = NULL, - }; - - return g_dbus_connection_register_object (connection, - NM_DHCP_HELPER_SERVER_OBJECT_PATH, - &interface_info, - &interface_vtable, - self, - NULL, - error); -} - -static void -new_connection_cb (NMBusManager *mgr, - GDBusConnection *connection, - GDBusObjectManager *manager, - NMDhcpListener *self) -{ - NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self); - guint registration_id; - GError *error = NULL; - - /* it is important to register the object during the new-connection signal, - * as this avoids races with the connecting object. */ - registration_id = _dbus_connection_register_object (self, connection, &error); - if (!registration_id) { - _LOGE ("failure to register %s for connection %p: %s", - NM_DHCP_HELPER_SERVER_OBJECT_PATH, connection, error->message); - g_error_free (error); - return; - } - - g_hash_table_insert (priv->connections, connection, GUINT_TO_POINTER (registration_id)); -} - -static void -dis_connection_cb (NMBusManager *mgr, - GDBusConnection *connection, - NMDhcpListener *self) -{ - NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self); - guint id; - - id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->connections, connection)); - if (id) { - g_dbus_connection_unregister_object (connection, id); - g_hash_table_remove (priv->connections, connection); - } -} - -/***************************************************/ - -static void -nm_dhcp_listener_init (NMDhcpListener *self) -{ - NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self); - - /* Maps GDBusConnection :: signal-id */ - priv->connections = g_hash_table_new (NULL, NULL); - - priv->dbus_mgr = nm_bus_manager_get (); - - /* 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, - NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW "::" PRIV_SOCK_TAG, - G_CALLBACK (new_connection_cb), - self); - priv->dis_conn_id = g_signal_connect (priv->dbus_mgr, - NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG, - G_CALLBACK (dis_connection_cb), - self); -} - -static void -dispose (GObject *object) -{ - NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE ((NMDhcpListener *) object); - - nm_clear_g_signal_handler (priv->dbus_mgr, &priv->new_conn_id); - nm_clear_g_signal_handler (priv->dbus_mgr, &priv->dis_conn_id); - priv->dbus_mgr = NULL; - - g_clear_pointer (&priv->connections, g_hash_table_destroy); - - G_OBJECT_CLASS (nm_dhcp_listener_parent_class)->dispose (object); -} - -static void -nm_dhcp_listener_class_init (NMDhcpListenerClass *listener_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (listener_class); - - object_class->dispose = dispose; - - signals[EVENT] = - g_signal_new (NM_DHCP_LISTENER_EVENT, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, 0, - g_signal_accumulator_true_handled, - NULL, NULL, - G_TYPE_BOOLEAN, /* listeners return TRUE if handled */ - 4, - G_TYPE_STRING, /* iface */ - G_TYPE_INT, /* pid */ - G_TYPE_VARIANT, /* options */ - G_TYPE_STRING); /* reason */ -} diff --git a/src/dhcp-manager/nm-dhcp-listener.h b/src/dhcp-manager/nm-dhcp-listener.h deleted file mode 100644 index 3018b97a..00000000 --- a/src/dhcp-manager/nm-dhcp-listener.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_LISTENER_H__ -#define __NETWORKMANAGER_DHCP_LISTENER_H__ - -#define NM_TYPE_DHCP_LISTENER (nm_dhcp_listener_get_type ()) -#define NM_DHCP_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_LISTENER, NMDhcpListener)) -#define NM_IS_DHCP_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_LISTENER)) -#define NM_DHCP_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_LISTENER, NMDhcpListenerClass)) - -#define NM_DHCP_LISTENER_EVENT "event" - -typedef struct _NMDhcpListener NMDhcpListener; -typedef struct _NMDhcpListenerClass NMDhcpListenerClass; - -GType nm_dhcp_listener_get_type (void); - -NMDhcpListener *nm_dhcp_listener_get (void); - -#endif /* __NETWORKMANAGER_DHCP_LISTENER_H__ */ diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c deleted file mode 100644 index 50469c5c..00000000 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ /dev/null @@ -1,451 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-dhcp-manager.c - Handle the DHCP daemon for NetworkManager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2013 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - * - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-dhcp-manager.h" -#include "nm-dhcp-dhclient.h" -#include "nm-dhcp-dhcpcd.h" -#include "nm-dhcp-systemd.h" -#include "nm-config.h" -#include "NetworkManagerUtils.h" - -#define DHCP_TIMEOUT 45 /* default DHCP timeout, in seconds */ - -/* default to installed helper, but can be modified for testing */ -const char *nm_dhcp_helper_path = LIBEXECDIR "/nm-dhcp-helper"; - -typedef GSList * (*GetLeaseConfigFunc) (const char *iface, const char *uuid, gboolean ipv6); - -typedef struct { - GType client_type; - GHashTable * clients; - char * default_hostname; -} NMDhcpManagerPrivate; - -#define NM_DHCP_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_MANAGER, NMDhcpManagerPrivate)) - -G_DEFINE_TYPE (NMDhcpManager, nm_dhcp_manager, G_TYPE_OBJECT) - -/***************************************************/ - -typedef struct { - GType gtype; - const char *name; - NMDhcpClientGetPathFunc get_path_func; - NMDhcpClientGetLeaseConfigsFunc get_lease_configs_func; -} ClientDesc; - -static GSList *client_descs = NULL; - -void -_nm_dhcp_client_register (GType gtype, - const char *name, - NMDhcpClientGetPathFunc get_path_func, - NMDhcpClientGetLeaseConfigsFunc get_lease_configs_func) -{ - ClientDesc *desc; - GSList *iter; - - g_return_if_fail (gtype != G_TYPE_INVALID); - g_return_if_fail (name != NULL); - - for (iter = client_descs; iter; iter = iter->next) { - desc = iter->data; - g_return_if_fail (desc->gtype != gtype); - g_return_if_fail (strcmp (desc->name, name) != 0); - } - - desc = g_slice_new0 (ClientDesc); - desc->gtype = gtype; - desc->name = name; - desc->get_path_func = get_path_func; - desc->get_lease_configs_func = get_lease_configs_func; - client_descs = g_slist_prepend (client_descs, desc); -} - -static ClientDesc * -find_client_desc (const char *name, GType gtype) -{ - GSList *iter; - - g_return_val_if_fail (name || gtype, NULL); - - for (iter = client_descs; iter; iter = iter->next) { - ClientDesc *desc = iter->data; - - if (name && strcmp (desc->name, name) != 0) - continue; - if (gtype && desc->gtype != gtype) - continue; - return desc; - } - return NULL; -} - -static GType -is_client_enabled (const char *name) -{ - ClientDesc *desc; - - desc = find_client_desc (name, G_TYPE_INVALID); - if (desc && (!desc->get_path_func || desc->get_path_func())) - return desc->gtype; - - return G_TYPE_INVALID; -} - -/***************************************************/ - -static NMDhcpClient * -get_client_for_ifindex (NMDhcpManager *manager, int ifindex, gboolean ip6) -{ - NMDhcpManagerPrivate *priv; - GHashTableIter iter; - gpointer value; - - g_return_val_if_fail (NM_IS_DHCP_MANAGER (manager), NULL); - g_return_val_if_fail (ifindex > 0, NULL); - - priv = NM_DHCP_MANAGER_GET_PRIVATE (manager); - - g_hash_table_iter_init (&iter, priv->clients); - while (g_hash_table_iter_next (&iter, NULL, &value)) { - NMDhcpClient *candidate = NM_DHCP_CLIENT (value); - - if ( nm_dhcp_client_get_ifindex (candidate) == ifindex - && nm_dhcp_client_get_ipv6 (candidate) == ip6) - return candidate; - } - - return NULL; -} - -static void client_state_changed (NMDhcpClient *client, - NMDhcpState state, - GObject *ip_config, - GVariant *options, - const char *event_id, - NMDhcpManager *self); - -static void -remove_client (NMDhcpManager *self, NMDhcpClient *client) -{ - g_signal_handlers_disconnect_by_func (client, client_state_changed, self); - - /* Stopping the client is left up to the controlling device - * explicitly since we may want to quit NetworkManager but not terminate - * the DHCP client. - */ - - g_hash_table_remove (NM_DHCP_MANAGER_GET_PRIVATE (self)->clients, client); -} - -static void -client_state_changed (NMDhcpClient *client, - NMDhcpState state, - GObject *ip_config, - GVariant *options, - const char *event_id, - NMDhcpManager *self) -{ - if (state >= NM_DHCP_STATE_TIMEOUT) - remove_client (self, client); -} - -static NMDhcpClient * -client_start (NMDhcpManager *self, - const char *iface, - int ifindex, - const GByteArray *hwaddr, - const char *uuid, - guint32 priority, - gboolean ipv6, - const struct in6_addr *ipv6_ll_addr, - const char *dhcp_client_id, - guint32 timeout, - const char *dhcp_anycast_addr, - const char *hostname, - const char *fqdn, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy, - const char *last_ip4_address) -{ - NMDhcpManagerPrivate *priv; - NMDhcpClient *client; - gboolean success = FALSE; - - g_return_val_if_fail (self, NULL); - g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); - g_return_val_if_fail (ifindex > 0, NULL); - g_return_val_if_fail (uuid != NULL, NULL); - - priv = NM_DHCP_MANAGER_GET_PRIVATE (self); - - /* Ensure we have a usable DHCP client */ - if (priv->client_type == G_TYPE_INVALID) - return NULL; - - /* Kill any old client instance */ - client = get_client_for_ifindex (self, ifindex, ipv6); - if (client) { - g_object_ref (client); - remove_client (self, client); - nm_dhcp_client_stop (client, FALSE); - g_object_unref (client); - } - - /* And make a new one */ - client = g_object_new (priv->client_type, - NM_DHCP_CLIENT_INTERFACE, iface, - NM_DHCP_CLIENT_IFINDEX, ifindex, - NM_DHCP_CLIENT_HWADDR, hwaddr, - NM_DHCP_CLIENT_IPV6, ipv6, - NM_DHCP_CLIENT_UUID, uuid, - NM_DHCP_CLIENT_PRIORITY, priority, - NM_DHCP_CLIENT_TIMEOUT, timeout ? timeout : DHCP_TIMEOUT, - NULL); - g_hash_table_insert (NM_DHCP_MANAGER_GET_PRIVATE (self)->clients, client, g_object_ref (client)); - g_signal_connect (client, NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, G_CALLBACK (client_state_changed), self); - - if (ipv6) - success = nm_dhcp_client_start_ip6 (client, dhcp_anycast_addr, ipv6_ll_addr, hostname, info_only, privacy); - else - success = nm_dhcp_client_start_ip4 (client, dhcp_client_id, dhcp_anycast_addr, hostname, fqdn, last_ip4_address); - - if (!success) { - remove_client (self, client); - client = NULL; - } - - return client; -} - -static const char * -get_send_hostname (NMDhcpManager *self, const char *setting_hostname) -{ - NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (self); - - /* Always prefer the explicit dhcp-send-hostname if given */ - return setting_hostname ? setting_hostname : priv->default_hostname; -} - -/* Caller owns a reference to the NMDhcpClient on return */ -NMDhcpClient * -nm_dhcp_manager_start_ip4 (NMDhcpManager *self, - const char *iface, - int ifindex, - const GByteArray *hwaddr, - const char *uuid, - guint32 priority, - gboolean send_hostname, - const char *dhcp_hostname, - const char *dhcp_fqdn, - const char *dhcp_client_id, - guint32 timeout, - const char *dhcp_anycast_addr, - const char *last_ip_address) -{ - const char *hostname = NULL; - const char *fqdn = NULL; - - g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); - - if (send_hostname) { - hostname = get_send_hostname (self, dhcp_hostname); - fqdn = dhcp_fqdn; - } - return client_start (self, iface, ifindex, hwaddr, uuid, priority, FALSE, NULL, - dhcp_client_id, timeout, dhcp_anycast_addr, hostname, - fqdn, FALSE, 0, last_ip_address); -} - -/* Caller owns a reference to the NMDhcpClient on return */ -NMDhcpClient * -nm_dhcp_manager_start_ip6 (NMDhcpManager *self, - const char *iface, - int ifindex, - const GByteArray *hwaddr, - const struct in6_addr *ll_addr, - const char *uuid, - guint32 priority, - gboolean send_hostname, - const char *dhcp_hostname, - guint32 timeout, - const char *dhcp_anycast_addr, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy) -{ - const char *hostname = NULL; - - g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); - - if (send_hostname) - hostname = get_send_hostname (self, dhcp_hostname); - return client_start (self, iface, ifindex, hwaddr, uuid, priority, TRUE, - ll_addr, NULL, timeout, dhcp_anycast_addr, hostname, NULL, info_only, - privacy, NULL); -} - -void -nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostname) -{ - NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (manager); - - g_clear_pointer (&priv->default_hostname, g_free); - - /* Never send 'localhost'-type names to the DHCP server */ - if (!nm_utils_is_specific_hostname (hostname)) - return; - - priv->default_hostname = g_strdup (hostname); -} - -GSList * -nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, - const char *iface, - int ifindex, - const char *uuid, - gboolean ipv6, - guint32 default_route_metric) -{ - NMDhcpManagerPrivate *priv; - ClientDesc *desc; - - g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); - g_return_val_if_fail (iface != NULL, NULL); - g_return_val_if_fail (ifindex >= -1, NULL); - g_return_val_if_fail (uuid != NULL, NULL); - - priv = NM_DHCP_MANAGER_GET_PRIVATE (self); - if (priv->client_type == G_TYPE_INVALID) - return NULL; - - desc = find_client_desc (NULL, priv->client_type); - if (desc && desc->get_lease_configs_func) - return desc->get_lease_configs_func (iface, ifindex, uuid, ipv6, default_route_metric); - return NULL; -} - -/***************************************************/ - -NM_DEFINE_SINGLETON_GETTER (NMDhcpManager, nm_dhcp_manager_get, NM_TYPE_DHCP_MANAGER); - -static void -nm_dhcp_manager_init (NMDhcpManager *self) -{ - NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (self); - NMConfig *config = nm_config_get (); - const char *client; - GSList *iter; - GType type = G_TYPE_INVALID; - - for (iter = client_descs; iter; iter = iter->next) { - ClientDesc *desc = iter->data; - - nm_log_dbg (LOGD_DHCP, "dhcp-init: Registered DHCP client '%s' (%s)", - desc->name, g_type_name (desc->gtype)); - } - - /* Client-specific setup */ - client = nm_config_get_dhcp_client (config); - if (nm_config_get_configure_and_quit (config)) { - if (g_strcmp0 (client, "internal") != 0) - nm_log_warn (LOGD_DHCP, "dhcp-init: Using internal DHCP client since configure-and-quit is set."); - client = "internal"; - } - - if (client) - type = is_client_enabled (client); - - if (type == G_TYPE_INVALID) { - if (client) - nm_log_warn (LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client); - - type = is_client_enabled ("dhclient"); - if (type == G_TYPE_INVALID) - type = is_client_enabled ("dhcpcd"); - if (type == G_TYPE_INVALID) - type = is_client_enabled ("internal"); - } - - if (type == G_TYPE_INVALID) - nm_log_warn (LOGD_DHCP, "dhcp-init: No usable DHCP client found! DHCP configurations will fail"); - else - nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", find_client_desc (NULL, type)->name); - - priv->client_type = type; - priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, - (GDestroyNotify) g_object_unref); -} - -static void -dispose (GObject *object) -{ - NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (object); - GList *values, *iter; - - if (priv->clients) { - values = g_hash_table_get_values (priv->clients); - for (iter = values; iter; iter = g_list_next (iter)) - remove_client (NM_DHCP_MANAGER (object), NM_DHCP_CLIENT (iter->data)); - g_list_free (values); - } - - G_OBJECT_CLASS (nm_dhcp_manager_parent_class)->dispose (object); -} - -static void -finalize (GObject *object) -{ - NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (object); - - g_free (priv->default_hostname); - - if (priv->clients) - g_hash_table_destroy (priv->clients); - - G_OBJECT_CLASS (nm_dhcp_manager_parent_class)->finalize (object); -} - -static void -nm_dhcp_manager_class_init (NMDhcpManagerClass *manager_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (manager_class); - - g_type_class_add_private (manager_class, sizeof (NMDhcpManagerPrivate)); - - /* virtual methods */ - object_class->finalize = finalize; - object_class->dispose = dispose; -} diff --git a/src/dhcp-manager/nm-dhcp-manager.h b/src/dhcp-manager/nm-dhcp-manager.h deleted file mode 100644 index df92c91c..00000000 --- a/src/dhcp-manager/nm-dhcp-manager.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-dhcp-manager.c - Handle the DHCP daemon for NetworkManager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2010 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_MANAGER_H__ -#define __NETWORKMANAGER_DHCP_MANAGER_H__ - -#include "nm-dhcp-client.h" -#include "nm-ip4-config.h" -#include "nm-dhcp4-config.h" - -#define NM_TYPE_DHCP_MANAGER (nm_dhcp_manager_get_type ()) -#define NM_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_MANAGER, NMDhcpManager)) -#define NM_DHCP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_MANAGER, NMDhcpManagerClass)) -#define NM_IS_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_MANAGER)) -#define NM_IS_DHCP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_MANAGER)) -#define NM_DHCP_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_MANAGER, NMDhcpManagerClass)) - -typedef struct { - GObject parent; -} NMDhcpManager; - -typedef struct { - GObjectClass parent; -} NMDhcpManagerClass; - -GType nm_dhcp_manager_get_type (void); - -NMDhcpManager *nm_dhcp_manager_get (void); - -void nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, - const char *hostname); - -NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager, - const char *iface, - int ifindex, - const GByteArray *hwaddr, - const char *uuid, - guint32 priority, - gboolean send_hostname, - const char *dhcp_hostname, - const char *dhcp_fqdn, - const char *dhcp_client_id, - guint32 timeout, - const char *dhcp_anycast_addr, - const char *last_ip_address); - -NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager, - const char *iface, - int ifindex, - const GByteArray *hwaddr, - const struct in6_addr *ll_addr, - const char *uuid, - guint32 priority, - gboolean send_hostname, - const char *dhcp_hostname, - guint32 timeout, - const char *dhcp_anycast_addr, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy); - -GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, - const char *iface, - int ifindex, - const char *uuid, - gboolean ipv6, - guint32 default_route_metric); - -/* For testing only */ -extern const char* nm_dhcp_helper_path; - -#endif /* __NETWORKMANAGER_DHCP_MANAGER_H__ */ diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c deleted file mode 100644 index ac8eb60a..00000000 --- a/src/dhcp-manager/nm-dhcp-systemd.c +++ /dev/null @@ -1,1050 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-dhcp-systemd.h" -#include "nm-utils.h" -#include "nm-dhcp-utils.h" -#include "NetworkManagerUtils.h" -#include "nm-platform.h" -#include "nm-dhcp-client-logging.h" -#include "nm-sd.h" - -#include "sd-dhcp-client.h" -#include "sd-dhcp6-client.h" - -G_DEFINE_TYPE (NMDhcpSystemd, nm_dhcp_systemd, NM_TYPE_DHCP_CLIENT) - -#define NM_DHCP_SYSTEMD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdPrivate)) - -typedef struct { - sd_dhcp_client *client4; - sd_dhcp6_client *client6; - char *lease_file; - - guint request_count; - - gboolean privacy; - gboolean info_only; -} NMDhcpSystemdPrivate; - -/************************************************************/ - -#define DHCP_OPTION_NIS_DOMAIN 40 -#define DHCP_OPTION_NIS_SERVERS 41 -#define DHCP_OPTION_DOMAIN_SEARCH 119 -#define DHCP_OPTION_MS_ROUTES 249 -#define DHCP_OPTION_WPAD 252 - -/* Internal values */ -#define DHCP_OPTION_IP_ADDRESS 1024 -#define DHCP_OPTION_EXPIRY 1025 -#define DHCP6_OPTION_IP_ADDRESS 1026 -#define DHCP6_OPTION_PREFIXLEN 1027 -#define DHCP6_OPTION_PREFERRED_LIFE 1028 -#define DHCP6_OPTION_MAX_LIFE 1029 -#define DHCP6_OPTION_STARTS 1030 -#define DHCP6_OPTION_LIFE_STARTS 1031 -#define DHCP6_OPTION_RENEW 1032 -#define DHCP6_OPTION_REBIND 1033 -#define DHCP6_OPTION_IAID 1034 - -typedef struct { - guint num; - const char *name; - gboolean include; -} ReqOption; - -#define REQPREFIX "requested_" - -static const ReqOption dhcp4_requests[] = { - { SD_DHCP_OPTION_SUBNET_MASK, REQPREFIX "subnet_mask", TRUE }, - { SD_DHCP_OPTION_TIME_OFFSET, REQPREFIX "time_offset", TRUE }, - { SD_DHCP_OPTION_ROUTER, REQPREFIX "routers", TRUE }, - { SD_DHCP_OPTION_DOMAIN_NAME_SERVER, REQPREFIX "domain_name_servers", TRUE }, - { SD_DHCP_OPTION_HOST_NAME, REQPREFIX "host_name", TRUE }, - { SD_DHCP_OPTION_DOMAIN_NAME, REQPREFIX "domain_name", TRUE }, - { SD_DHCP_OPTION_INTERFACE_MTU, REQPREFIX "interface_mtu", TRUE }, - { SD_DHCP_OPTION_BROADCAST, REQPREFIX "broadcast_address", TRUE }, - { SD_DHCP_OPTION_STATIC_ROUTE, REQPREFIX "static_routes", TRUE }, - { DHCP_OPTION_NIS_DOMAIN, REQPREFIX "nis_domain", TRUE }, - { DHCP_OPTION_NIS_SERVERS, REQPREFIX "nis_servers", TRUE }, - { SD_DHCP_OPTION_NTP_SERVER, REQPREFIX "ntp_servers", TRUE }, - { SD_DHCP_OPTION_SERVER_IDENTIFIER, REQPREFIX "dhcp_server_identifier", TRUE }, - { DHCP_OPTION_DOMAIN_SEARCH, REQPREFIX "domain_search", TRUE }, - { SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, REQPREFIX "rfc3442_classless_static_routes", TRUE }, - { DHCP_OPTION_MS_ROUTES, REQPREFIX "ms_classless_static_routes", TRUE }, - { DHCP_OPTION_WPAD, REQPREFIX "wpad", TRUE }, - - /* Internal values */ - { SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME, REQPREFIX "expiry", FALSE }, - { SD_DHCP_OPTION_CLIENT_IDENTIFIER, REQPREFIX "dhcp_client_identifier", FALSE }, - { DHCP_OPTION_IP_ADDRESS, REQPREFIX "ip_address", FALSE }, - { 0, NULL, FALSE } -}; - -static const ReqOption dhcp6_requests[] = { - { SD_DHCP6_OPTION_CLIENTID, REQPREFIX "dhcp6_client_id", TRUE }, - - /* Don't request server ID by default; some servers don't reply to - * Information Requests that request the Server ID. - */ - { SD_DHCP6_OPTION_SERVERID, REQPREFIX "dhcp6_server_id", FALSE }, - - { SD_DHCP6_OPTION_DNS_SERVERS, REQPREFIX "dhcp6_name_servers", TRUE }, - { SD_DHCP6_OPTION_DOMAIN_LIST, REQPREFIX "dhcp6_domain_search", TRUE }, - { SD_DHCP6_OPTION_SNTP_SERVERS, REQPREFIX "dhcp6_sntp_servers", TRUE }, - - /* Internal values */ - { DHCP6_OPTION_IP_ADDRESS, REQPREFIX "ip6_address", FALSE }, - { DHCP6_OPTION_PREFIXLEN, REQPREFIX "ip6_prefixlen", FALSE }, - { DHCP6_OPTION_PREFERRED_LIFE, REQPREFIX "preferred_life", FALSE }, - { DHCP6_OPTION_MAX_LIFE, REQPREFIX "max_life", FALSE }, - { DHCP6_OPTION_STARTS, REQPREFIX "starts", FALSE }, - { DHCP6_OPTION_LIFE_STARTS, REQPREFIX "life_starts", FALSE }, - { DHCP6_OPTION_RENEW, REQPREFIX "renew", FALSE }, - { DHCP6_OPTION_REBIND, REQPREFIX "rebind", FALSE }, - { DHCP6_OPTION_IAID, REQPREFIX "iaid", FALSE }, - { 0, NULL, FALSE } -}; - -static void -take_option (GHashTable *options, - const ReqOption *requests, - guint option, - char *value) -{ - guint i; - - g_return_if_fail (value != NULL); - - for (i = 0; requests[i].name; i++) { - if (requests[i].num == option) { - g_hash_table_insert (options, - (gpointer) (requests[i].name + NM_STRLEN (REQPREFIX)), - value); - break; - } - } - /* Option should always be found */ - g_assert (requests[i].name); -} - -static void -add_option (GHashTable *options, const ReqOption *requests, guint option, const char *value) -{ - if (options) - take_option (options, requests, option, g_strdup (value)); -} - -static void -add_option_u32 (GHashTable *options, const ReqOption *requests, guint option, guint32 value) -{ - if (options) - take_option (options, requests, option, g_strdup_printf ("%u", value)); -} - -static void -add_option_u64 (GHashTable *options, const ReqOption *requests, guint option, guint64 value) -{ - if (options) - take_option (options, requests, option, g_strdup_printf ("%" G_GUINT64_FORMAT, value)); -} - -static void -add_requests_to_options (GHashTable *options, const ReqOption *requests) -{ - guint i; - - for (i = 0; options && requests[i].name; i++) { - if (requests[i].include) - g_hash_table_insert (options, (gpointer) requests[i].name, g_strdup ("1")); - } -} - -#define LOG_LEASE(domain, ...) \ -G_STMT_START { \ - if (log_lease) { \ - _LOG2I ((domain), (iface), __VA_ARGS__); \ - } \ -} G_STMT_END - -static NMIP4Config * -lease_to_ip4_config (const char *iface, - int ifindex, - sd_dhcp_lease *lease, - GHashTable *options, - guint32 default_priority, - gboolean log_lease, - GError **error) -{ - NMIP4Config *ip4_config = NULL; - struct in_addr tmp_addr; - const struct in_addr *addr_list; - char buf[INET_ADDRSTRLEN]; - const char *str; - guint32 lifetime = 0, i; - NMPlatformIP4Address address; - GString *l; - gs_free sd_dhcp_route **routes = NULL; - guint16 mtu; - int r, num; - guint64 end_time; - const void *data; - gsize data_len; - gboolean metered = FALSE; - gboolean static_default_gateway = FALSE; - - g_return_val_if_fail (lease != NULL, NULL); - - ip4_config = nm_ip4_config_new (ifindex); - - /* Address */ - sd_dhcp_lease_get_address (lease, &tmp_addr); - memset (&address, 0, sizeof (address)); - address.address = tmp_addr.s_addr; - address.peer_address = tmp_addr.s_addr; - str = nm_utils_inet4_ntop (tmp_addr.s_addr, NULL); - LOG_LEASE (LOGD_DHCP4, " address %s", str); - add_option (options, dhcp4_requests, DHCP_OPTION_IP_ADDRESS, str); - - /* Prefix/netmask */ - sd_dhcp_lease_get_netmask (lease, &tmp_addr); - address.plen = nm_utils_ip4_netmask_to_prefix (tmp_addr.s_addr); - LOG_LEASE (LOGD_DHCP4, " plen %d", address.plen); - add_option (options, - dhcp4_requests, - SD_DHCP_OPTION_SUBNET_MASK, - nm_utils_inet4_ntop (tmp_addr.s_addr, NULL)); - - /* Lease time */ - sd_dhcp_lease_get_lifetime (lease, &lifetime); - address.timestamp = nm_utils_get_monotonic_timestamp_s (); - address.lifetime = address.preferred = lifetime; - end_time = (guint64) time (NULL) + lifetime; - LOG_LEASE (LOGD_DHCP4, " expires in %" G_GUINT32_FORMAT " seconds", lifetime); - add_option_u64 (options, - dhcp4_requests, - SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME, - end_time); - - address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; - nm_ip4_config_add_address (ip4_config, &address); - - /* DNS Servers */ - num = sd_dhcp_lease_get_dns (lease, &addr_list); - if (num > 0) { - l = g_string_sized_new (30); - for (i = 0; i < num; i++) { - if (addr_list[i].s_addr) { - nm_ip4_config_add_nameserver (ip4_config, addr_list[i].s_addr); - str = nm_utils_inet4_ntop (addr_list[i].s_addr, NULL); - LOG_LEASE (LOGD_DHCP4, " nameserver '%s'", str); - g_string_append_printf (l, "%s%s", l->len ? " " : "", str); - } - } - if (l->len) - add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME_SERVER, l->str); - g_string_free (l, TRUE); - } - - /* Domain Name */ - r = sd_dhcp_lease_get_domainname (lease, &str); - if (r == 0) { - /* Multiple domains sometimes stuffed into option 15 "Domain Name". - * As systemd escapes such characters, split them at \\032. */ - char **domains = g_strsplit (str, "\\032", 0); - char **s; - - for (s = domains; *s; s++) { - LOG_LEASE (LOGD_DHCP4, " domain name '%s'", *s); - nm_ip4_config_add_domain (ip4_config, *s); - } - g_strfreev (domains); - add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME, str); - } - - /* Hostname */ - r = sd_dhcp_lease_get_hostname (lease, &str); - if (r == 0) { - LOG_LEASE (LOGD_DHCP4, " hostname '%s'", str); - add_option (options, dhcp4_requests, SD_DHCP_OPTION_HOST_NAME, str); - } - - /* Routes */ - num = sd_dhcp_lease_get_routes (lease, &routes); - if (num > 0) { - l = g_string_sized_new (30); - for (i = 0; i < num; i++) { - NMPlatformIP4Route route = { 0 }; - const char *gw_str; - guint8 plen; - struct in_addr a; - - if (sd_dhcp_route_get_destination (routes[i], &a) < 0) - continue; - route.network = a.s_addr; - - if ( sd_dhcp_route_get_destination_prefix_length (routes[i], &plen) < 0 - || plen > 32) - continue; - route.plen = plen; - - if (sd_dhcp_route_get_gateway (routes[i], &a) < 0) - continue; - route.gateway = a.s_addr; - - if (route.plen) { - route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = default_priority; - nm_ip4_config_add_route (ip4_config, &route); - - str = nm_utils_inet4_ntop (route.network, buf); - gw_str = nm_utils_inet4_ntop (route.gateway, NULL); - LOG_LEASE (LOGD_DHCP4, " static route %s/%d gw %s", str, route.plen, gw_str); - - g_string_append_printf (l, "%s%s/%d %s", l->len ? " " : "", str, route.plen, gw_str); - } else { - if (!static_default_gateway) { - static_default_gateway = TRUE; - nm_ip4_config_set_gateway (ip4_config, route.gateway); - - str = nm_utils_inet4_ntop (route.gateway, NULL); - LOG_LEASE (LOGD_DHCP4, " gateway %s", str); - add_option (options, dhcp4_requests, SD_DHCP_OPTION_ROUTER, str); - } - } - } - if (l->len) - add_option (options, dhcp4_requests, SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, l->str); - g_string_free (l, TRUE); - } - - /* If the DHCP server returns both a Classless Static Routes option and a - * Router option, the DHCP client MUST ignore the Router option [RFC 3442]. - * Be more lenient and ignore the Router option only if Classless Static - * Routes contain a default gateway (as other DHCP backends do). - */ - /* Gateway */ - if (!static_default_gateway) { - r = sd_dhcp_lease_get_router (lease, &tmp_addr); - if (r == 0) { - nm_ip4_config_set_gateway (ip4_config, tmp_addr.s_addr); - str = nm_utils_inet4_ntop (tmp_addr.s_addr, NULL); - LOG_LEASE (LOGD_DHCP4, " gateway %s", str); - add_option (options, dhcp4_requests, SD_DHCP_OPTION_ROUTER, str); - } - } - - /* MTU */ - r = sd_dhcp_lease_get_mtu (lease, &mtu); - if (r == 0 && mtu) { - nm_ip4_config_set_mtu (ip4_config, mtu, NM_IP_CONFIG_SOURCE_DHCP); - add_option_u32 (options, dhcp4_requests, SD_DHCP_OPTION_INTERFACE_MTU, mtu); - LOG_LEASE (LOGD_DHCP4, " mtu %u", mtu); - } - - /* NTP servers */ - num = sd_dhcp_lease_get_ntp (lease, &addr_list); - if (num > 0) { - l = g_string_sized_new (30); - for (i = 0; i < num; i++) { - str = nm_utils_inet4_ntop (addr_list[i].s_addr, buf); - LOG_LEASE (LOGD_DHCP4, " ntp server '%s'", str); - g_string_append_printf (l, "%s%s", l->len ? " " : "", str); - } - add_option (options, dhcp4_requests, SD_DHCP_OPTION_NTP_SERVER, l->str); - g_string_free (l, TRUE); - } - - r = sd_dhcp_lease_get_vendor_specific (lease, &data, &data_len); - if (r >= 0) - metered = !!memmem (data, data_len, "ANDROID_METERED", NM_STRLEN ("ANDROID_METERED")); - nm_ip4_config_set_metered (ip4_config, metered); - - return ip4_config; -} - -/************************************************************/ - -static char * -get_leasefile_path (const char *iface, const char *uuid, gboolean ipv6) -{ - return g_strdup_printf (NMSTATEDIR "/internal%s-%s-%s.lease", - ipv6 ? "6" : "", - uuid, - iface); -} - -static GSList * -nm_dhcp_systemd_get_lease_ip_configs (const char *iface, - int ifindex, - const char *uuid, - gboolean ipv6, - guint32 default_route_metric) -{ - GSList *leases = NULL; - gs_free char *path = NULL; - sd_dhcp_lease *lease = NULL; - NMIP4Config *ip4_config; - int r; - - if (ipv6) - return NULL; - - path = get_leasefile_path (iface, uuid, FALSE); - r = dhcp_lease_load (&lease, path); - if (r == 0 && lease) { - ip4_config = lease_to_ip4_config (iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL); - if (ip4_config) - leases = g_slist_append (leases, ip4_config); - sd_dhcp_lease_unref (lease); - } - - return leases; -} - -/************************************************************/ - -static void -_save_client_id (NMDhcpSystemd *self, - uint8_t type, - const uint8_t *client_id, - size_t len) -{ - gs_unref_bytes GBytes *b = NULL; - gs_free char *buf = NULL; - - g_return_if_fail (self != NULL); - g_return_if_fail (client_id != NULL); - g_return_if_fail (len > 0); - - if (!nm_dhcp_client_get_client_id (NM_DHCP_CLIENT (self))) { - buf = g_malloc (len + 1); - buf[0] = type; - memcpy (buf + 1, client_id, len); - b = g_bytes_new (buf, len + 1); - nm_dhcp_client_set_client_id (NM_DHCP_CLIENT (self), b); - } -} - -static void -bound4_handle (NMDhcpSystemd *self) -{ - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); - const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self)); - sd_dhcp_lease *lease; - NMIP4Config *ip4_config; - GHashTable *options; - GError *error = NULL; - int r; - - r = sd_dhcp_client_get_lease (priv->client4, &lease); - if (r < 0 || !lease) { - _LOGW ("no lease!"); - nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); - return; - } - - _LOGD ("lease available"); - - options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); - ip4_config = lease_to_ip4_config (iface, - nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), - lease, - options, - nm_dhcp_client_get_priority (NM_DHCP_CLIENT (self)), - TRUE, - &error); - if (ip4_config) { - const uint8_t *client_id = NULL; - size_t client_id_len = 0; - uint8_t type = 0; - - add_requests_to_options (options, dhcp4_requests); - dhcp_lease_save (lease, priv->lease_file); - - sd_dhcp_client_get_client_id(priv->client4, &type, &client_id, &client_id_len); - if (client_id) - _save_client_id (self, type, client_id, client_id_len); - - nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), - NM_DHCP_STATE_BOUND, - G_OBJECT (ip4_config), - options); - } else { - _LOGW ("%s", error->message); - nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); - g_clear_error (&error); - } - - g_hash_table_destroy (options); - g_clear_object (&ip4_config); -} - -static void -dhcp_event_cb (sd_dhcp_client *client, int event, gpointer user_data) -{ - NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data); - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); - - g_assert (priv->client4 == client); - - _LOGD ("client event %d", event); - - switch (event) { - case SD_DHCP_CLIENT_EVENT_EXPIRED: - nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_EXPIRE, NULL, NULL); - break; - case SD_DHCP_CLIENT_EVENT_STOP: - nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_FAIL, NULL, NULL); - break; - case SD_DHCP_CLIENT_EVENT_RENEW: - case SD_DHCP_CLIENT_EVENT_IP_CHANGE: - case SD_DHCP_CLIENT_EVENT_IP_ACQUIRE: - bound4_handle (self); - break; - default: - _LOGW ("unhandled DHCP event %d", event); - break; - } -} - -static guint16 -get_arp_type (const GByteArray *hwaddr) -{ - if (hwaddr->len == ETH_ALEN) - return ARPHRD_ETHER; - else if (hwaddr->len == INFINIBAND_ALEN) - return ARPHRD_INFINIBAND; - else - return ARPHRD_NONE; -} - -static gboolean -ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address) -{ - NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client); - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); - const char *iface = nm_dhcp_client_get_iface (client); - const GByteArray *hwaddr; - sd_dhcp_lease *lease = NULL; - GBytes *override_client_id; - const uint8_t *client_id = NULL; - size_t client_id_len = 0; - struct in_addr last_addr = { 0 }; - const char *hostname, *fqdn; - int r, i; - gboolean success = FALSE; - guint16 arp_type; - - g_assert (priv->client4 == NULL); - g_assert (priv->client6 == NULL); - - g_free (priv->lease_file); - priv->lease_file = get_leasefile_path (iface, nm_dhcp_client_get_uuid (client), FALSE); - - r = sd_dhcp_client_new (&priv->client4); - if (r < 0) { - _LOGW ("failed to create client (%d)", r); - return FALSE; - } - - _LOGT ("dhcp-client4: set %p", priv->client4); - - r = sd_dhcp_client_attach_event (priv->client4, NULL, 0); - if (r < 0) { - _LOGW ("failed to attach event (%d)", r); - goto error; - } - - hwaddr = nm_dhcp_client_get_hw_addr (client); - if (hwaddr) { - arp_type= get_arp_type (hwaddr); - if (arp_type == ARPHRD_NONE) { - _LOGW ("failed to determine ARP type"); - goto error; - } - - r = sd_dhcp_client_set_mac (priv->client4, - hwaddr->data, - hwaddr->len, - arp_type); - if (r < 0) { - _LOGW ("failed to set MAC address (%d)", r); - goto error; - } - } - - r = sd_dhcp_client_set_ifindex (priv->client4, nm_dhcp_client_get_ifindex (client)); - if (r < 0) { - _LOGW ("failed to set ififindex (%d)", r); - goto error; - } - - r = sd_dhcp_client_set_callback (priv->client4, dhcp_event_cb, client); - if (r < 0) { - _LOGW ("failed to set callback (%d)", r); - goto error; - } - - r = sd_dhcp_client_set_request_broadcast (priv->client4, true); - if (r < 0) { - _LOGW ("failed to enable broadcast mode (%d)", r); - goto error; - } - - dhcp_lease_load (&lease, priv->lease_file); - - if (last_ip4_address) - inet_pton (AF_INET, last_ip4_address, &last_addr); - else if (lease) - sd_dhcp_lease_get_address (lease, &last_addr); - - if (last_addr.s_addr) { - r = sd_dhcp_client_set_request_address (priv->client4, &last_addr); - if (r < 0) { - _LOGW ("failed to set last IPv4 address (%d)", r); - goto error; - } - } - - override_client_id = nm_dhcp_client_get_client_id (client); - if (override_client_id) { - client_id = g_bytes_get_data (override_client_id, &client_id_len); - g_assert (client_id && client_id_len); - sd_dhcp_client_set_client_id (priv->client4, - client_id[0], - client_id + 1, - client_id_len - 1); - } else if (lease) { - r = sd_dhcp_lease_get_client_id (lease, (const void **) &client_id, &client_id_len); - if (r == 0 && client_id_len) { - sd_dhcp_client_set_client_id (priv->client4, - client_id[0], - client_id + 1, - client_id_len - 1); - _save_client_id (NM_DHCP_SYSTEMD (client), - client_id[0], - client_id + 1, - client_id_len - 1); - } - } - - - /* Add requested options */ - for (i = 0; dhcp4_requests[i].name; i++) { - if (dhcp4_requests[i].include) - sd_dhcp_client_set_request_option (priv->client4, dhcp4_requests[i].num); - } - - hostname = nm_dhcp_client_get_hostname (client); - if (hostname) { - char *prefix, *dot; - - prefix = strdup (hostname); - dot = strchr (prefix, '.'); - /* get rid of the domain */ - if (dot) - *dot = '\0'; - - r = sd_dhcp_client_set_hostname (priv->client4, prefix); - free (prefix); - - if (r < 0) { - _LOGW ("failed to set DHCP hostname (%d)", r); - goto error; - } - } - - fqdn = nm_dhcp_client_get_fqdn (client); - if (fqdn) { - r = sd_dhcp_client_set_hostname (priv->client4, fqdn); - if (r < 0) { - _LOGW ("failed to set DHCP FQDN (%d)", r); - goto error; - } - } - - r = sd_dhcp_client_start (priv->client4); - if (r < 0) { - _LOGW ("failed to start client (%d)", r); - goto error; - } - - nm_dhcp_client_start_timeout (client); - - success = TRUE; - -error: - sd_dhcp_lease_unref (lease); - if (!success) - priv->client4 = sd_dhcp_client_unref (priv->client4); - return success; -} - -static NMIP6Config * -lease_to_ip6_config (const char *iface, - int ifindex, - sd_dhcp6_lease *lease, - GHashTable *options, - gboolean log_lease, - gboolean info_only, - GError **error) -{ - struct in6_addr tmp_addr, *dns; - uint32_t lft_pref, lft_valid; - NMIP6Config *ip6_config; - const char *addr_str; - char **domains; - GString *str; - int num, i; - gint32 ts; - - g_return_val_if_fail (lease, NULL); - ip6_config = nm_ip6_config_new (ifindex); - ts = nm_utils_get_monotonic_timestamp_s (); - str = g_string_sized_new (30); - - /* Addresses */ - sd_dhcp6_lease_reset_address_iter (lease); - while (sd_dhcp6_lease_get_address (lease, &tmp_addr, &lft_pref, &lft_valid) >= 0) { - NMPlatformIP6Address address = { - .plen = 128, - .address = tmp_addr, - .timestamp = ts, - .lifetime = lft_valid, - .preferred = lft_pref, - .addr_source = NM_IP_CONFIG_SOURCE_DHCP, - }; - - nm_ip6_config_add_address (ip6_config, &address); - - addr_str = nm_utils_inet6_ntop (&tmp_addr, NULL); - g_string_append_printf (str, "%s%s", str->len ? " " : "", addr_str); - - LOG_LEASE (LOGD_DHCP6, - " address %s", - nm_platform_ip6_address_to_string (&address, NULL, 0)); - }; - - if (str->len) { - add_option (options, dhcp6_requests, DHCP6_OPTION_IP_ADDRESS, str->str); - g_string_set_size (str , 0); - } - - if (!info_only && nm_ip6_config_get_num_addresses (ip6_config) == 0) { - g_string_free (str, TRUE); - g_object_unref (ip6_config); - g_set_error_literal (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "no address received in managed mode"); - return NULL; - } - - /* DNS servers */ - num = sd_dhcp6_lease_get_dns (lease, &dns); - if (num > 0) { - for (i = 0; i < num; i++) { - nm_ip6_config_add_nameserver (ip6_config, &dns[i]); - addr_str = nm_utils_inet6_ntop (&dns[i], NULL); - g_string_append_printf (str, "%s%s", str->len ? " " : "", addr_str); - LOG_LEASE (LOGD_DHCP6, " nameserver %s", addr_str); - } - add_option (options, dhcp6_requests, SD_DHCP6_OPTION_DNS_SERVERS, str->str); - g_string_set_size (str, 0); - } - - /* Search domains */ - num = sd_dhcp6_lease_get_domains (lease, &domains); - if (num > 0) { - for (i = 0; i < num; i++) { - nm_ip6_config_add_search (ip6_config, domains[i]); - g_string_append_printf (str, "%s%s", str->len ? " " : "", domains[i]); - LOG_LEASE (LOGD_DHCP6, " domain name '%s'", domains[i]); - } - add_option (options, dhcp6_requests, SD_DHCP6_OPTION_DOMAIN_LIST, str->str); - g_string_set_size (str, 0); - } - - g_string_free (str, TRUE); - - return ip6_config; -} - -static void -bound6_handle (NMDhcpSystemd *self) -{ - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); - const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self)); - gs_unref_object NMIP6Config *ip6_config = NULL; - gs_unref_hashtable GHashTable *options = NULL; - gs_free_error GError *error = NULL; - sd_dhcp6_lease *lease; - int r; - - r = sd_dhcp6_client_get_lease (priv->client6, &lease); - if (r < 0 || !lease) { - _LOGW (" no lease!"); - nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); - return; - } - - _LOGD ("lease available"); - - options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); - ip6_config = lease_to_ip6_config (iface, - nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), - lease, - options, - TRUE, - priv->info_only, - &error); - - if (ip6_config) { - nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), - NM_DHCP_STATE_BOUND, - G_OBJECT (ip6_config), - options); - } else { - _LOGW ("%s", error->message); - nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); - } -} - -static void -dhcp6_event_cb (sd_dhcp6_client *client, int event, gpointer user_data) -{ - NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data); - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); - - g_assert (priv->client6 == client); - - _LOGD ("client event %d", event); - - switch (event) { - case SD_DHCP6_CLIENT_EVENT_RETRANS_MAX: - nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_TIMEOUT, NULL, NULL); - break; - case SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE: - case SD_DHCP6_CLIENT_EVENT_STOP: - nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_FAIL, NULL, NULL); - break; - case SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE: - case SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST: - bound6_handle (self); - break; - default: - _LOGW ("unhandled event %d", event); - break; - } -} - -static gboolean -ip6_start (NMDhcpClient *client, - const char *dhcp_anycast_addr, - const struct in6_addr *ll_addr, - gboolean info_only, - NMSettingIP6ConfigPrivacy privacy, - const GByteArray *duid) -{ - NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client); - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); - const char *iface = nm_dhcp_client_get_iface (client); - const GByteArray *hwaddr; - int r, i; - - g_assert (priv->client4 == NULL); - g_assert (priv->client6 == NULL); - g_return_val_if_fail (duid != NULL, FALSE); - - g_free (priv->lease_file); - priv->lease_file = get_leasefile_path (iface, nm_dhcp_client_get_uuid (client), TRUE); - priv->info_only = info_only; - - r = sd_dhcp6_client_new (&priv->client6); - if (r < 0) { - _LOGW ("failed to create client (%d)", r); - return FALSE; - } - - _LOGT ("dhcp-client6: set %p", priv->client4); - - if (info_only) - sd_dhcp6_client_set_information_request (priv->client6, 1); - - /* NM stores the entire DUID which includes the uint16 "type", while systemd - * wants the type passed separately from the following data. - */ - r = sd_dhcp6_client_set_duid (priv->client6, - ntohs (((const guint16 *) duid->data)[0]), - duid->data + 2, - duid->len - 2); - if (r < 0) { - _LOGW ("failed to set DUID (%d)", r); - return FALSE; - } - - r = sd_dhcp6_client_attach_event (priv->client6, NULL, 0); - if (r < 0) { - _LOGW ("failed to attach event (%d)", r); - goto error; - } - - hwaddr = nm_dhcp_client_get_hw_addr (client); - if (hwaddr) { - r = sd_dhcp6_client_set_mac (priv->client6, - hwaddr->data, - hwaddr->len, - get_arp_type (hwaddr)); - if (r < 0) { - _LOGW ("failed to set MAC address (%d)", r); - goto error; - } - } - - r = sd_dhcp6_client_set_ifindex (priv->client6, nm_dhcp_client_get_ifindex (client)); - if (r < 0) { - _LOGW ("failed to set ifindex (%d)", r); - goto error; - } - - r = sd_dhcp6_client_set_callback (priv->client6, dhcp6_event_cb, client); - if (r < 0) { - _LOGW ("failed to set callback (%d)", r); - goto error; - } - - /* Add requested options */ - for (i = 0; dhcp6_requests[i].name; i++) { - if (dhcp6_requests[i].include) - sd_dhcp6_client_set_request_option (priv->client6, dhcp6_requests[i].num); - } - - r = sd_dhcp6_client_set_local_address (priv->client6, ll_addr); - if (r < 0) { - _LOGW ("failed to set local address (%d)", r); - goto error; - } - - r = sd_dhcp6_client_start (priv->client6); - if (r < 0) { - _LOGW ("failed to start client (%d)", r); - goto error; - } - - nm_dhcp_client_start_timeout (client); - - return TRUE; - -error: - sd_dhcp6_client_unref (priv->client6); - priv->client6 = NULL; - return FALSE; -} - -static void -stop (NMDhcpClient *client, gboolean release, const GByteArray *duid) -{ - NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client); - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); - int r = 0; - - _LOGT ("dhcp-client%d: stop %p", - priv->client4 ? '4' : '6', - priv->client4 ? (gpointer) priv->client4 : (gpointer) priv->client6); - - if (priv->client4) { - sd_dhcp_client_set_callback (priv->client4, NULL, NULL); - r = sd_dhcp_client_stop (priv->client4); - } else if (priv->client6) { - sd_dhcp6_client_set_callback (priv->client6, NULL, NULL); - r = sd_dhcp6_client_stop (priv->client6); - } - - if (r) - _LOGW ("failed to stop client (%d)", r); -} - -/***************************************************/ - -static void -nm_dhcp_systemd_init (NMDhcpSystemd *self) -{ -} - -static void -dispose (GObject *object) -{ - NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (object); - - g_clear_pointer (&priv->lease_file, g_free); - - if (priv->client4) { - sd_dhcp_client_stop (priv->client4); - sd_dhcp_client_unref (priv->client4); - priv->client4 = NULL; - } - - if (priv->client6) { - sd_dhcp6_client_stop (priv->client6); - sd_dhcp6_client_unref (priv->client6); - priv->client6 = NULL; - } - - G_OBJECT_CLASS (nm_dhcp_systemd_parent_class)->dispose (object); -} - -static void -nm_dhcp_systemd_class_init (NMDhcpSystemdClass *sdhcp_class) -{ - NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS (sdhcp_class); - GObjectClass *object_class = G_OBJECT_CLASS (sdhcp_class); - - g_type_class_add_private (sdhcp_class, sizeof (NMDhcpSystemdPrivate)); - - /* virtual methods */ - object_class->dispose = dispose; - - client_class->ip4_start = ip4_start; - client_class->ip6_start = ip6_start; - client_class->stop = stop; -} - -static void __attribute__((constructor)) -register_dhcp_dhclient (void) -{ - nm_g_type_init (); - _nm_dhcp_client_register (NM_TYPE_DHCP_SYSTEMD, - "internal", - NULL, - nm_dhcp_systemd_get_lease_ip_configs); -} - diff --git a/src/dhcp-manager/nm-dhcp-systemd.h b/src/dhcp-manager/nm-dhcp-systemd.h deleted file mode 100644 index ff24bfcd..00000000 --- a/src/dhcp-manager/nm-dhcp-systemd.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2014 Red Hat, Inc. - */ - -#ifndef NM_DHCP_SYSTEMD_H -#define NM_DHCP_SYSTEMD_H - -#include "nm-dhcp-client.h" - -#define NM_TYPE_DHCP_SYSTEMD (nm_dhcp_systemd_get_type ()) -#define NM_DHCP_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemd)) -#define NM_DHCP_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdClass)) -#define NM_IS_DHCP_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_SYSTEMD)) -#define NM_IS_DHCP_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_SYSTEMD)) -#define NM_DHCP_SYSTEMD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdClass)) - -typedef struct { - NMDhcpClient parent; -} NMDhcpSystemd; - -typedef struct { - NMDhcpClientClass parent; -} NMDhcpSystemdClass; - -GType nm_dhcp_systemd_get_type (void); - -#endif /* NM_DHCP_SYSTEMD_H */ - diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c deleted file mode 100644 index 593d8c5d..00000000 --- a/src/dhcp-manager/nm-dhcp-utils.c +++ /dev/null @@ -1,739 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2010 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-dhcp-utils.h" -#include "nm-utils.h" -#include "NetworkManagerUtils.h" -#include "nm-platform.h" -#include "nm-dhcp-client-logging.h" -#include "nm-core-internal.h" - -/********************************************/ - -static gboolean -ip4_process_dhcpcd_rfc3442_routes (const char *iface, - const char *str, - guint32 priority, - NMIP4Config *ip4_config, - guint32 *gwaddr) -{ - char **routes, **r; - gboolean have_routes = FALSE; - - routes = g_strsplit (str, " ", 0); - if (g_strv_length (routes) == 0) - goto out; - - if ((g_strv_length (routes) % 2) != 0) { - _LOG2W (LOGD_DHCP4, iface, " classless static routes provided, but invalid"); - goto out; - } - - for (r = routes; *r; r += 2) { - char *slash; - NMPlatformIP4Route route; - int rt_cidr = 32; - guint32 rt_addr, rt_route; - - slash = strchr(*r, '/'); - if (slash) { - *slash = '\0'; - errno = 0; - rt_cidr = strtol (slash + 1, NULL, 10); - if (errno || rt_cidr > 32) { - _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route cidr: '%s'", slash + 1); - continue; - } - } - if (inet_pton (AF_INET, *r, &rt_addr) <= 0) { - _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route address: '%s'", *r); - continue; - } - if (inet_pton (AF_INET, *(r + 1), &rt_route) <= 0) { - _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route gateway: '%s'", *(r + 1)); - continue; - } - - have_routes = TRUE; - if (rt_cidr == 0 && rt_addr == 0) { - /* FIXME: how to handle multiple routers? */ - *gwaddr = rt_route; - } else { - _LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1)); - memset (&route, 0, sizeof (route)); - route.network = rt_addr; - route.plen = rt_cidr; - route.gateway = rt_route; - route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = priority; - nm_ip4_config_add_route (ip4_config, &route); - } - } - -out: - g_strfreev (routes); - return have_routes; -} - -static const char ** -process_dhclient_rfc3442_route (const char **octets, - NMPlatformIP4Route *route, - gboolean *success) -{ - const char **o = octets; - int addr_len = 0, i = 0; - long int tmp; - char *next_hop; - guint32 tmp_addr; - - *success = FALSE; - - if (!*o) - return o; /* no prefix */ - - tmp = strtol (*o, NULL, 10); - if (tmp < 0 || tmp > 32) /* 32 == max IP4 prefix length */ - return o; - - memset (route, 0, sizeof (*route)); - route->plen = tmp; - o++; - - if (tmp > 0) - addr_len = ((tmp - 1) / 8) + 1; - - /* ensure there's at least the address + next hop left */ - if (g_strv_length ((char **) o) < addr_len + 4) - goto error; - - if (tmp) { - const char *addr[4] = { "0", "0", "0", "0" }; - char *str_addr; - - for (i = 0; i < addr_len; i++) - addr[i] = *o++; - - str_addr = g_strjoin (".", addr[0], addr[1], addr[2], addr[3], NULL); - if (inet_pton (AF_INET, str_addr, &tmp_addr) <= 0) { - g_free (str_addr); - goto error; - } - g_free (str_addr); - tmp_addr &= nm_utils_ip4_prefix_to_netmask ((guint32) tmp); - route->network = tmp_addr; - } - - /* Handle next hop */ - next_hop = g_strjoin (".", o[0], o[1], o[2], o[3], NULL); - if (inet_pton (AF_INET, next_hop, &tmp_addr) <= 0) { - g_free (next_hop); - goto error; - } - route->gateway = tmp_addr; - g_free (next_hop); - - *success = TRUE; - return o + 4; /* advance to past the next hop */ - -error: - return o; -} - -static gboolean -ip4_process_dhclient_rfc3442_routes (const char *iface, - const char *str, - guint32 priority, - NMIP4Config *ip4_config, - guint32 *gwaddr) -{ - char **octets, **o; - gboolean have_routes = FALSE; - NMPlatformIP4Route route; - gboolean success; - - o = octets = g_strsplit_set (str, " .", 0); - if (g_strv_length (octets) < 5) { - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str); - goto out; - } - - while (*o) { - memset (&route, 0, sizeof (route)); - o = (char **) process_dhclient_rfc3442_route ((const char **) o, &route, &success); - if (!success) { - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes"); - break; - } - - have_routes = TRUE; - if (!route.plen) { - /* gateway passed as classless static route */ - *gwaddr = route.gateway; - } else { - char addr[INET_ADDRSTRLEN]; - - /* normal route */ - route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = priority; - nm_ip4_config_add_route (ip4_config, &route); - - _LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s", - nm_utils_inet4_ntop (route.network, addr), route.plen, - nm_utils_inet4_ntop (route.gateway, NULL)); - } - } - -out: - g_strfreev (octets); - return have_routes; -} - -static gboolean -ip4_process_classless_routes (const char *iface, - GHashTable *options, - guint32 priority, - NMIP4Config *ip4_config, - guint32 *gwaddr) -{ - const char *str, *p; - - g_return_val_if_fail (options != NULL, FALSE); - g_return_val_if_fail (ip4_config != NULL, FALSE); - - *gwaddr = 0; - - /* dhcpd/dhclient in Fedora has support for rfc3442 implemented using a - * slightly different format: - * - * option classless-static-routes = array of (destination-descriptor ip-address); - * - * which results in: - * - * 0 192.168.0.113 25.129.210.177.132 192.168.0.113 7.2 10.34.255.6 - * - * dhcpcd supports classless static routes natively and uses this same - * option identifier with the following format: - * - * 192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41 - */ - str = g_hash_table_lookup (options, "classless_static_routes"); - - /* dhclient doesn't have actual support for rfc3442 classless static routes - * upstream. Thus, people resort to defining the option in dhclient.conf - * and using arbitrary formats like so: - * - * option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; - * - * See https://lists.isc.org/pipermail/dhcp-users/2008-December/007629.html - */ - if (!str) - str = g_hash_table_lookup (options, "rfc3442_classless_static_routes"); - - /* Microsoft version; same as rfc3442 but with a different option # (249) */ - if (!str) - str = g_hash_table_lookup (options, "ms_classless_static_routes"); - - if (!str || !strlen (str)) - return FALSE; - - p = str; - while (*p) { - if (!g_ascii_isdigit (*p) && (*p != ' ') && (*p != '.') && (*p != '/')) { - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str); - return FALSE; - } - p++; - }; - - if (strchr (str, '/')) { - /* dhcpcd format */ - return ip4_process_dhcpcd_rfc3442_routes (iface, str, priority, ip4_config, gwaddr); - } - - return ip4_process_dhclient_rfc3442_routes (iface, str, priority, ip4_config, gwaddr); -} - -static void -process_classful_routes (const char *iface, - GHashTable *options, - guint32 priority, - NMIP4Config *ip4_config) -{ - const char *str; - char **searches, **s; - - str = g_hash_table_lookup (options, "static_routes"); - if (!str) - return; - - searches = g_strsplit (str, " ", 0); - if ((g_strv_length (searches) % 2)) { - _LOG2I (LOGD_DHCP, iface, " static routes provided, but invalid"); - goto out; - } - - for (s = searches; *s; s += 2) { - NMPlatformIP4Route route; - guint32 rt_addr, rt_route; - - if (inet_pton (AF_INET, *s, &rt_addr) <= 0) { - _LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route address: '%s'", *s); - continue; - } - if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) { - _LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route gateway: '%s'", *(s + 1)); - continue; - } - - // FIXME: ensure the IP address and route are sane - - memset (&route, 0, sizeof (route)); - route.network = rt_addr; - /* RFC 2132, updated by RFC 3442: - The Static Routes option (option 33) does not provide a subnet mask - for each route - it is assumed that the subnet mask is implicit in - whatever network number is specified in each route entry */ - route.plen = nm_utils_ip4_get_default_prefix (rt_addr); - if (rt_addr & ~nm_utils_ip4_prefix_to_netmask (route.plen)) { - /* RFC 943: target not "this network"; using host routing */ - route.plen = 32; - } - route.gateway = rt_route; - route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = priority; - - nm_ip4_config_add_route (ip4_config, &route); - _LOG2I (LOGD_DHCP, iface, " static route %s", - nm_platform_ip4_route_to_string (&route, NULL, 0)); - } - -out: - g_strfreev (searches); -} - -static void -process_domain_search (const char *iface, - const char *str, - GFunc add_func, - gpointer user_data) -{ - char **searches, **s; - char *unescaped, *p; - int i; - - g_return_if_fail (str != NULL); - g_return_if_fail (add_func != NULL); - - p = unescaped = g_strdup (str); - do { - p = strstr (p, "\\032"); - if (!p) - break; - - /* Clear the escaped space with real spaces */ - for (i = 0; i < 4; i++) - *p++ = ' '; - } while (*p++); - - if (strchr (unescaped, '\\')) { - _LOG2W (LOGD_DHCP, iface, " invalid domain search: '%s'", unescaped); - goto out; - } - - searches = g_strsplit (unescaped, " ", 0); - for (s = searches; *s; s++) { - if (strlen (*s)) { - _LOG2I (LOGD_DHCP, iface, " domain search '%s'", *s); - add_func (*s, user_data); - } - } - g_strfreev (searches); - -out: - g_free (unescaped); -} - -static void -ip4_add_domain_search (gpointer data, gpointer user_data) -{ - nm_ip4_config_add_search (NM_IP4_CONFIG (user_data), (const char *) data); -} - -NMIP4Config * -nm_dhcp_utils_ip4_config_from_options (int ifindex, - const char *iface, - GHashTable *options, - guint32 priority) -{ - NMIP4Config *ip4_config = NULL; - guint32 tmp_addr; - in_addr_t addr; - NMPlatformIP4Address address; - char *str = NULL; - guint32 gwaddr = 0; - guint8 plen = 0; - - g_return_val_if_fail (options != NULL, NULL); - - ip4_config = nm_ip4_config_new (ifindex); - memset (&address, 0, sizeof (address)); - address.timestamp = nm_utils_get_monotonic_timestamp_s (); - - str = g_hash_table_lookup (options, "ip_address"); - if (str && (inet_pton (AF_INET, str, &addr) > 0)) - _LOG2I (LOGD_DHCP4, iface, " address %s", str); - else - goto error; - - str = g_hash_table_lookup (options, "subnet_mask"); - if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) { - plen = nm_utils_ip4_netmask_to_prefix (tmp_addr); - _LOG2I (LOGD_DHCP4, iface, " plen %d (%s)", plen, str); - } else { - /* Get default netmask for the IP according to appropriate class. */ - plen = nm_utils_ip4_get_default_prefix (addr); - _LOG2I (LOGD_DHCP4, iface, " plen %d (default)", plen); - } - nm_platform_ip4_address_set_addr (&address, addr, plen); - - /* Routes: if the server returns classless static routes, we MUST ignore - * the 'static_routes' option. - */ - if (!ip4_process_classless_routes (iface, options, priority, ip4_config, &gwaddr)) - process_classful_routes (iface, options, priority, ip4_config); - - if (gwaddr) { - _LOG2I (LOGD_DHCP4, iface, " gateway %s", nm_utils_inet4_ntop (gwaddr, NULL)); - nm_ip4_config_set_gateway (ip4_config, gwaddr); - } else { - /* If the gateway wasn't provided as a classless static route with a - * subnet length of 0, try to find it using the old-style 'routers' option. - */ - str = g_hash_table_lookup (options, "routers"); - if (str) { - char **routers = g_strsplit (str, " ", 0); - char **s; - - for (s = routers; *s; s++) { - /* FIXME: how to handle multiple routers? */ - if (inet_pton (AF_INET, *s, &gwaddr) > 0) { - nm_ip4_config_set_gateway (ip4_config, gwaddr); - _LOG2I (LOGD_DHCP4, iface, " gateway %s", *s); - break; - } else - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid gateway '%s'", *s); - } - g_strfreev (routers); - } - } - - /* - * RFC 2132, section 9.7 - * DHCP clients use the contents of the 'server identifier' field - * as the destination address for any DHCP messages unicast to - * the DHCP server. - * - * Some ISP's provide leases from central servers that are on - * different subnets that the address offered. If the host - * does not configure the interface as the default route, the - * dhcp server may not be reachable via unicast, and a host - * specific route is needed. - **/ - str = g_hash_table_lookup (options, "dhcp_server_identifier"); - if (str) { - if (inet_pton (AF_INET, str, &tmp_addr) > 0) { - - _LOG2I (LOGD_DHCP4, iface, " server identifier %s", str); - if ( nm_utils_ip4_address_clear_host_address(tmp_addr, address.plen) != nm_utils_ip4_address_clear_host_address(address.address, address.plen) - && !nm_ip4_config_get_direct_route_for_host (ip4_config, tmp_addr)) { - /* DHCP server not on assigned subnet and the no direct route was returned. Add route */ - NMPlatformIP4Route route = { 0 }; - - route.network = tmp_addr; - route.plen = 32; - /* this will be a device route if gwaddr is 0 */ - route.gateway = gwaddr; - route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = priority; - nm_ip4_config_add_route (ip4_config, &route); - _LOG2D (LOGD_IP, iface, "adding route for server identifier: %s", - nm_platform_ip4_route_to_string (&route, NULL, 0)); - } - } - else - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid server identifier '%s'", str); - } - - str = g_hash_table_lookup (options, "dhcp_lease_time"); - if (str) { - address.lifetime = address.preferred = strtoul (str, NULL, 10); - _LOG2I (LOGD_DHCP4, iface, " lease time %u", address.lifetime); - } - - address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; - nm_ip4_config_add_address (ip4_config, &address); - - str = g_hash_table_lookup (options, "host_name"); - if (str) - _LOG2I (LOGD_DHCP4, iface, " hostname '%s'", str); - - str = g_hash_table_lookup (options, "domain_name_servers"); - if (str) { - char **dns = g_strsplit (str, " ", 0); - char **s; - - for (s = dns; *s; s++) { - if (inet_pton (AF_INET, *s, &tmp_addr) > 0) { - if (tmp_addr) { - nm_ip4_config_add_nameserver (ip4_config, tmp_addr); - _LOG2I (LOGD_DHCP4, iface, " nameserver '%s'", *s); - } - } else - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid nameserver '%s'", *s); - } - g_strfreev (dns); - } - - str = g_hash_table_lookup (options, "domain_name"); - if (str) { - char **domains = g_strsplit (str, " ", 0); - char **s; - - for (s = domains; *s; s++) { - _LOG2I (LOGD_DHCP4, iface, " domain name '%s'", *s); - nm_ip4_config_add_domain (ip4_config, *s); - } - g_strfreev (domains); - } - - str = g_hash_table_lookup (options, "domain_search"); - if (str) - process_domain_search (iface, str, ip4_add_domain_search, ip4_config); - - str = g_hash_table_lookup (options, "netbios_name_servers"); - if (str) { - char **nbns = g_strsplit (str, " ", 0); - char **s; - - for (s = nbns; *s; s++) { - if (inet_pton (AF_INET, *s, &tmp_addr) > 0) { - if (tmp_addr) { - nm_ip4_config_add_wins (ip4_config, tmp_addr); - _LOG2I (LOGD_DHCP4, iface, " wins '%s'", *s); - } - } else - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid WINS server '%s'", *s); - } - g_strfreev (nbns); - } - - str = g_hash_table_lookup (options, "interface_mtu"); - if (str) { - int int_mtu; - - errno = 0; - int_mtu = strtol (str, NULL, 10); - if ((errno == EINVAL) || (errno == ERANGE)) - goto error; - - if (int_mtu > 576) - nm_ip4_config_set_mtu (ip4_config, int_mtu, NM_IP_CONFIG_SOURCE_DHCP); - } - - str = g_hash_table_lookup (options, "nis_domain"); - if (str) { - _LOG2I (LOGD_DHCP4, iface, " NIS domain '%s'", str); - nm_ip4_config_set_nis_domain (ip4_config, str); - } - - str = g_hash_table_lookup (options, "nis_servers"); - if (str) { - char **nis = g_strsplit (str, " ", 0); - char **s; - - for (s = nis; *s; s++) { - if (inet_pton (AF_INET, *s, &tmp_addr) > 0) { - if (tmp_addr) { - nm_ip4_config_add_nis_server (ip4_config, tmp_addr); - _LOG2I (LOGD_DHCP4, iface, " nis '%s'", *s); - } - } else - _LOG2W (LOGD_DHCP4, iface, "ignoring invalid NIS server '%s'", *s); - } - g_strfreev (nis); - } - - str = g_hash_table_lookup (options, "vendor_encapsulated_options"); - nm_ip4_config_set_metered (ip4_config, str && strstr (str, "ANDROID_METERED")); - - return ip4_config; - -error: - g_object_unref (ip4_config); - return NULL; -} - -/********************************************/ - -static void -ip6_add_domain_search (gpointer data, gpointer user_data) -{ - nm_ip6_config_add_search (NM_IP6_CONFIG (user_data), (const char *) data); -} - -NMIP6Config * -nm_dhcp_utils_ip6_config_from_options (int ifindex, - const char *iface, - GHashTable *options, - guint32 priority, - gboolean info_only) -{ - NMIP6Config *ip6_config = NULL; - struct in6_addr tmp_addr; - NMPlatformIP6Address address; - char *str = NULL; - GHashTableIter iter; - gpointer key, value; - - g_return_val_if_fail (options != NULL, NULL); - - memset (&address, 0, sizeof (address)); - address.plen = 128; - address.timestamp = nm_utils_get_monotonic_timestamp_s (); - - g_hash_table_iter_init (&iter, options); - while (g_hash_table_iter_next (&iter, &key, &value)) { - _LOG2D (LOGD_DHCP6, iface, "(%s): option '%s'=>'%s'", - iface, (const char *) key, (const char *) value); - } - - ip6_config = nm_ip6_config_new (ifindex); - - str = g_hash_table_lookup (options, "max_life"); - if (str) { - address.lifetime = strtoul (str, NULL, 10); - _LOG2I (LOGD_DHCP6, iface, " valid_lft %u", address.lifetime); - } - - str = g_hash_table_lookup (options, "preferred_life"); - if (str) { - address.preferred = strtoul (str, NULL, 10); - _LOG2I (LOGD_DHCP6, iface, " preferred_lft %u", address.preferred); - } - - str = g_hash_table_lookup (options, "ip6_address"); - if (str) { - if (!inet_pton (AF_INET6, str, &tmp_addr)) { - _LOG2W (LOGD_DHCP6, iface, "(%s): DHCP returned invalid address '%s'", - iface, str); - goto error; - } - - address.address = tmp_addr; - address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; - nm_ip6_config_add_address (ip6_config, &address); - _LOG2I (LOGD_DHCP6, iface, " address %s", str); - } else if (info_only == FALSE) { - /* No address in Managed mode is a hard error */ - goto error; - } - - str = g_hash_table_lookup (options, "host_name"); - if (str) - _LOG2I (LOGD_DHCP6, iface, " hostname '%s'", str); - - str = g_hash_table_lookup (options, "dhcp6_name_servers"); - if (str) { - char **dns = g_strsplit (str, " ", 0); - char **s; - - for (s = dns; *s; s++) { - if (inet_pton (AF_INET6, *s, &tmp_addr) > 0) { - if (!IN6_IS_ADDR_UNSPECIFIED (&tmp_addr)) { - nm_ip6_config_add_nameserver (ip6_config, &tmp_addr); - _LOG2I (LOGD_DHCP6, iface, " nameserver '%s'", *s); - } - } else - _LOG2W (LOGD_DHCP6, iface, "ignoring invalid nameserver '%s'", *s); - } - g_strfreev (dns); - } - - str = g_hash_table_lookup (options, "dhcp6_domain_search"); - if (str) - process_domain_search (iface, str, ip6_add_domain_search, ip6_config); - - return ip6_config; - -error: - g_object_unref (ip6_config); - return NULL; -} - -char * -nm_dhcp_utils_duid_to_string (const GByteArray *duid) -{ - g_return_val_if_fail (duid != NULL, NULL); - - return _nm_utils_bin2str (duid->data, duid->len, FALSE); -} - -/** - * nm_dhcp_utils_client_id_string_to_bytes: - * @client_id: the client ID string - * - * Accepts either a hex string ("aa:bb:cc") representing a binary client ID - * (the first byte is assumed to be the 'type' field per RFC 2132 section 9.14), - * or a string representing a non-hardware-address client ID, in which case - * the 'type' field is set to 0. - * - * Returns: the binary client ID suitable for sending over the wire - * to the DHCP server. - */ -GBytes * -nm_dhcp_utils_client_id_string_to_bytes (const char *client_id) -{ - GBytes *bytes = NULL; - guint len; - char *c; - - g_return_val_if_fail (client_id && client_id[0], NULL); - - /* Try as hex encoded */ - if (strchr (client_id, ':')) - bytes = nm_utils_hexstr2bin (client_id); - if (!bytes) { - /* Fall back to string */ - len = strlen (client_id); - c = g_malloc (len + 1); - c[0] = 0; /* type: non-hardware address per RFC 2132 section 9.14 */ - memcpy (c + 1, client_id, len); - bytes = g_bytes_new_take (c, len + 1); - } - - return bytes; -} - diff --git a/src/dhcp-manager/nm-dhcp-utils.h b/src/dhcp-manager/nm-dhcp-utils.h deleted file mode 100644 index 6540b1ff..00000000 --- a/src/dhcp-manager/nm-dhcp-utils.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2014 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DHCP_UTILS_H__ -#define __NETWORKMANAGER_DHCP_UTILS_H__ - -#include - -#include -#include - -NMIP4Config *nm_dhcp_utils_ip4_config_from_options (int ifindex, - const char *iface, - GHashTable *options, - guint priority); - -NMIP6Config *nm_dhcp_utils_ip6_config_from_options (int ifindex, - const char *iface, - GHashTable *options, - guint priority, - gboolean info_only); - -char * nm_dhcp_utils_duid_to_string (const GByteArray *duid); - -GBytes * nm_dhcp_utils_client_id_string_to_bytes (const char *client_id); - -#endif /* __NETWORKMANAGER_DHCP_UTILS_H__ */ - diff --git a/src/dhcp-manager/tests/Makefile.am b/src/dhcp-manager/tests/Makefile.am deleted file mode 100644 index b26cea14..00000000 --- a/src/dhcp-manager/tests/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I${top_builddir}/shared \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I$(top_srcdir)/src/dhcp-manager \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/platform \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DTESTDIR="\"$(abs_srcdir)\"" - -noinst_PROGRAMS = \ - test-dhcp-dhclient \ - test-dhcp-utils - -####### dhclient leases test ####### - -test_dhcp_dhclient_SOURCES = \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.h \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.h \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c \ - test-dhcp-dhclient.c - -test_dhcp_dhclient_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### DHCP utils test ####### - -test_dhcp_utils_SOURCES = \ - test-dhcp-utils.c - -test_dhcp_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -################################# - -@VALGRIND_RULES@ -TESTS = test-dhcp-dhclient test-dhcp-utils - -EXTRA_DIST = \ - test-dhclient-duid.leases \ - test-dhclient-commented-duid.leases \ - leases/basic.leases \ - leases/malformed1.leases \ - leases/malformed2.leases \ - leases/malformed3.leases - diff --git a/src/dhcp-manager/tests/Makefile.in b/src/dhcp-manager/tests/Makefile.in deleted file mode 100644 index 3f5f1466..00000000 --- a/src/dhcp-manager/tests/Makefile.in +++ /dev/null @@ -1,1213 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-dhcp-dhclient$(EXEEXT) test-dhcp-utils$(EXEEXT) -TESTS = test-dhcp-dhclient$(EXEEXT) test-dhcp-utils$(EXEEXT) -subdir = src/dhcp-manager/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_dhcp_dhclient_OBJECTS = nm-dhcp-dhclient-utils.$(OBJEXT) \ - nm-dhcp-utils.$(OBJEXT) test-dhcp-dhclient.$(OBJEXT) -test_dhcp_dhclient_OBJECTS = $(am_test_dhcp_dhclient_OBJECTS) -test_dhcp_dhclient_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -am_test_dhcp_utils_OBJECTS = test-dhcp-utils.$(OBJEXT) -test_dhcp_utils_OBJECTS = $(am_test_dhcp_utils_OBJECTS) -test_dhcp_utils_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_dhcp_dhclient_SOURCES) $(test_dhcp_utils_SOURCES) -DIST_SOURCES = $(test_dhcp_dhclient_SOURCES) \ - $(test_dhcp_utils_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I${top_builddir}/shared \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I$(top_srcdir)/src/dhcp-manager \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/platform \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DTESTDIR="\"$(abs_srcdir)\"" - - -####### dhclient leases test ####### -test_dhcp_dhclient_SOURCES = \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.h \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.h \ - $(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c \ - test-dhcp-dhclient.c - -test_dhcp_dhclient_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### DHCP utils test ####### -test_dhcp_utils_SOURCES = \ - test-dhcp-utils.c - -test_dhcp_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -EXTRA_DIST = \ - test-dhclient-duid.leases \ - test-dhclient-commented-duid.leases \ - leases/basic.leases \ - leases/malformed1.leases \ - leases/malformed2.leases \ - leases/malformed3.leases - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dhcp-manager/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/dhcp-manager/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-dhcp-dhclient$(EXEEXT): $(test_dhcp_dhclient_OBJECTS) $(test_dhcp_dhclient_DEPENDENCIES) $(EXTRA_test_dhcp_dhclient_DEPENDENCIES) - @rm -f test-dhcp-dhclient$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_dhcp_dhclient_OBJECTS) $(test_dhcp_dhclient_LDADD) $(LIBS) - -test-dhcp-utils$(EXEEXT): $(test_dhcp_utils_OBJECTS) $(test_dhcp_utils_DEPENDENCIES) $(EXTRA_test_dhcp_utils_DEPENDENCIES) - @rm -f test-dhcp-utils$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_dhcp_utils_OBJECTS) $(test_dhcp_utils_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-dhclient-utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-dhcp-utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dhcp-dhclient.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dhcp-utils.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -nm-dhcp-dhclient-utils.o: $(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-dhclient-utils.o -MD -MP -MF $(DEPDIR)/nm-dhcp-dhclient-utils.Tpo -c -o nm-dhcp-dhclient-utils.o `test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c' || echo '$(srcdir)/'`$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-dhclient-utils.Tpo $(DEPDIR)/nm-dhcp-dhclient-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c' object='nm-dhcp-dhclient-utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-dhclient-utils.o `test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c' || echo '$(srcdir)/'`$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c - -nm-dhcp-dhclient-utils.obj: $(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-dhclient-utils.obj -MD -MP -MF $(DEPDIR)/nm-dhcp-dhclient-utils.Tpo -c -o nm-dhcp-dhclient-utils.obj `if test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c'; then $(CYGPATH_W) '$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-dhclient-utils.Tpo $(DEPDIR)/nm-dhcp-dhclient-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c' object='nm-dhcp-dhclient-utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-dhclient-utils.obj `if test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c'; then $(CYGPATH_W) '$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/dhcp-manager/nm-dhcp-dhclient-utils.c'; fi` - -nm-dhcp-utils.o: $(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-utils.o -MD -MP -MF $(DEPDIR)/nm-dhcp-utils.Tpo -c -o nm-dhcp-utils.o `test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c' || echo '$(srcdir)/'`$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-utils.Tpo $(DEPDIR)/nm-dhcp-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c' object='nm-dhcp-utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-utils.o `test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c' || echo '$(srcdir)/'`$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c - -nm-dhcp-utils.obj: $(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-dhcp-utils.obj -MD -MP -MF $(DEPDIR)/nm-dhcp-utils.Tpo -c -o nm-dhcp-utils.obj `if test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c'; then $(CYGPATH_W) '$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-dhcp-utils.Tpo $(DEPDIR)/nm-dhcp-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c' object='nm-dhcp-utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-dhcp-utils.obj `if test -f '$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c'; then $(CYGPATH_W) '$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/dhcp-manager/nm-dhcp-utils.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-dhcp-dhclient.log: test-dhcp-dhclient$(EXEEXT) - @p='test-dhcp-dhclient$(EXEEXT)'; \ - b='test-dhcp-dhclient'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-dhcp-utils.log: test-dhcp-utils$(EXEEXT) - @p='test-dhcp-utils$(EXEEXT)'; \ - b='test-dhcp-utils'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -################################# - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/dhcp-manager/tests/leases/basic.leases b/src/dhcp-manager/tests/leases/basic.leases deleted file mode 100644 index 703d9247..00000000 --- a/src/dhcp-manager/tests/leases/basic.leases +++ /dev/null @@ -1,31 +0,0 @@ -lease { - interface "wlan0"; - fixed-address 192.168.1.180; - option subnet-mask 255.255.255.0; - option routers 192.168.1.1; - option dhcp-lease-time 600; - option dhcp-message-type 5; - option domain-name-servers 192.168.1.1; - option dhcp-server-identifier 192.168.1.1; - option broadcast-address 192.168.1.255; - renew 5 2013/11/01 19:56:15; - rebind 5 2013/11/01 20:00:44; - expire 5 2013/11/01 20:01:59; -} -lease { - interface "wlan0"; - fixed-address 10.77.52.141; - option subnet-mask 255.0.0.0; - option dhcp-lease-time 1200; - option routers 10.77.52.254; - option dhcp-message-type 5; - option dhcp-server-identifier 10.77.52.254; - option domain-name-servers 8.8.8.8,8.8.4.4; - option dhcp-renewal-time 600; - option dhcp-rebinding-time 1050; - option domain-name "morriesguest.local"; - renew 5 2013/11/01 20:01:08; - rebind 5 2013/11/01 20:05:00; - expire 5 2013/11/01 20:06:15; -} - diff --git a/src/dhcp-manager/tests/leases/malformed1.leases b/src/dhcp-manager/tests/leases/malformed1.leases deleted file mode 100644 index 401d982a..00000000 --- a/src/dhcp-manager/tests/leases/malformed1.leases +++ /dev/null @@ -1,15 +0,0 @@ -# missing fixed-address option -lease { - interface "wlan0"; - option subnet-mask 255.255.255.0; - option routers 192.168.1.1; - option dhcp-lease-time 600; - option dhcp-message-type 5; - option domain-name-servers 192.168.1.1; - option dhcp-server-identifier 192.168.1.1; - option broadcast-address 192.168.1.255; - renew 5 2013/11/01 19:56:15; - rebind 5 2013/11/01 20:00:44; - expire 5 2013/11/01 20:01:59; -} - diff --git a/src/dhcp-manager/tests/leases/malformed2.leases b/src/dhcp-manager/tests/leases/malformed2.leases deleted file mode 100644 index adf5f6de..00000000 --- a/src/dhcp-manager/tests/leases/malformed2.leases +++ /dev/null @@ -1,15 +0,0 @@ -# missing routers option -lease { - interface "wlan0"; - fixed-address 192.168.1.180; - option subnet-mask 255.255.255.0; - option dhcp-lease-time 600; - option dhcp-message-type 5; - option domain-name-servers 192.168.1.1; - option dhcp-server-identifier 192.168.1.1; - option broadcast-address 192.168.1.255; - renew 5 2013/11/01 19:56:15; - rebind 5 2013/11/01 20:00:44; - expire 5 2013/11/01 20:01:59; -} - diff --git a/src/dhcp-manager/tests/leases/malformed3.leases b/src/dhcp-manager/tests/leases/malformed3.leases deleted file mode 100644 index a2afc8b6..00000000 --- a/src/dhcp-manager/tests/leases/malformed3.leases +++ /dev/null @@ -1,15 +0,0 @@ -# missing expire time -lease { - interface "wlan0"; - fixed-address 192.168.1.180; - option subnet-mask 255.255.255.0; - option routers 192.168.1.1; - option dhcp-lease-time 600; - option dhcp-message-type 5; - option domain-name-servers 192.168.1.1; - option dhcp-server-identifier 192.168.1.1; - option broadcast-address 192.168.1.255; - renew 5 2013/11/01 19:56:15; - rebind 5 2013/11/01 20:00:44; -} - diff --git a/src/dhcp-manager/tests/test-dhclient-commented-duid.leases b/src/dhcp-manager/tests/test-dhclient-commented-duid.leases deleted file mode 100644 index 3e46ae7d..00000000 --- a/src/dhcp-manager/tests/test-dhclient-commented-duid.leases +++ /dev/null @@ -1,2 +0,0 @@ -#default-duid "\000\001\000\001\030y\246\023`g \354Lp"; - diff --git a/src/dhcp-manager/tests/test-dhclient-duid.leases b/src/dhcp-manager/tests/test-dhclient-duid.leases deleted file mode 100644 index 229331d4..00000000 --- a/src/dhcp-manager/tests/test-dhclient-duid.leases +++ /dev/null @@ -1,2 +0,0 @@ -default-duid "\000\001\000\001\030y\246\023`g \354Lp"; - diff --git a/src/dhcp-manager/tests/test-dhcp-dhclient.c b/src/dhcp-manager/tests/test-dhcp-dhclient.c deleted file mode 100644 index 77849c8c..00000000 --- a/src/dhcp-manager/tests/test-dhcp-dhclient.c +++ /dev/null @@ -1,876 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2010 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include -#include -#include - -#include "NetworkManagerUtils.h" -#include "nm-dhcp-dhclient-utils.h" -#include "nm-dhcp-utils.h" -#include "nm-utils.h" -#include "nm-ip4-config.h" -#include "nm-platform.h" - -#include "nm-test-utils-core.h" - -#define DEBUG 1 - -static void -test_config (const char *orig, - const char *expected, - gboolean ipv6, - const char *hostname, - const char *fqdn, - const char *dhcp_client_id, - GBytes *expected_new_client_id, - const char *iface, - const char *anycast_addr) -{ - gs_free char *new = NULL; - gs_unref_bytes GBytes *client_id = NULL; - gs_unref_bytes GBytes *new_client_id = NULL; - - if (dhcp_client_id) { - client_id = nm_dhcp_utils_client_id_string_to_bytes (dhcp_client_id); - g_assert (client_id); - } - - new = nm_dhcp_dhclient_create_config (iface, - ipv6, - client_id, - anycast_addr, - hostname, - fqdn, - "/path/to/dhclient.conf", - orig, - &new_client_id); - g_assert (new != NULL); - -#if DEBUG - if ( strlen (new) != strlen (expected) - || strcmp (new, expected)) { - g_message ("\n- NEW ---------------------------------\n" - "%s" - "+ EXPECTED ++++++++++++++++++++++++++++++\n" - "%s" - "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - new, expected); - } -#endif - g_assert_cmpstr (new, ==, expected); - - if (expected_new_client_id) { - g_assert (new_client_id); - g_assert (g_bytes_equal (new_client_id, expected_new_client_id)); - } else - g_assert (new_client_id == NULL); -} - -/*******************************************/ - -static const char *orig_missing_expected = \ - "# Created by NetworkManager\n" - "\n\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_orig_missing (void) -{ - test_config (NULL, orig_missing_expected, FALSE, NULL, NULL, NULL, NULL, "eth0", NULL); -} - -/*******************************************/ - -static const char *override_client_id_orig = \ - "send dhcp-client-identifier 00:30:04:20:7A:08;\n"; - -static const char *override_client_id_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n" - "send dhcp-client-identifier 11:22:33:44:55:66; # added by NetworkManager\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_override_client_id (void) -{ - test_config (override_client_id_orig, override_client_id_expected, - FALSE, NULL, NULL, - "11:22:33:44:55:66", - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *quote_client_id_expected = \ - "# Created by NetworkManager\n" - "\n" - "send dhcp-client-identifier \"1234\"; # added by NetworkManager\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_quote_client_id (void) -{ - test_config (NULL, quote_client_id_expected, - FALSE, NULL, NULL, - "1234", - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *ascii_client_id_expected = \ - "# Created by NetworkManager\n" - "\n" - "send dhcp-client-identifier \"qb:cd:ef:12:34:56\"; # added by NetworkManager\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_ascii_client_id (void) -{ - test_config (NULL, ascii_client_id_expected, - FALSE, NULL, NULL, - "qb:cd:ef:12:34:56", - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *hex_single_client_id_expected = \ - "# Created by NetworkManager\n" - "\n" - "send dhcp-client-identifier ab:cd:0e:12:34:56; # added by NetworkManager\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_hex_single_client_id (void) -{ - test_config (NULL, hex_single_client_id_expected, - FALSE, NULL, NULL, - "ab:cd:e:12:34:56", - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *existing_hex_client_id_orig = \ - "send dhcp-client-identifier 00:30:04:20:7A:08;\n"; - -static const char *existing_hex_client_id_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n" - "send dhcp-client-identifier 00:30:04:20:7A:08;\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_existing_hex_client_id (void) -{ - gs_unref_bytes GBytes *new_client_id = NULL; - const guint8 bytes[] = { 0x00, 0x30, 0x04,0x20, 0x7A, 0x08 }; - - new_client_id = g_bytes_new (bytes, sizeof (bytes)); - test_config (existing_hex_client_id_orig, existing_hex_client_id_expected, - FALSE, NULL, NULL, - NULL, - new_client_id, - "eth0", - NULL); -} - -/*******************************************/ - -#define EACID "qb:cd:ef:12:34:56" - -static const char *existing_ascii_client_id_orig = \ - "send dhcp-client-identifier \"" EACID "\";\n"; - -static const char *existing_ascii_client_id_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n" - "send dhcp-client-identifier \"" EACID "\";\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_existing_ascii_client_id (void) -{ - gs_unref_bytes GBytes *new_client_id = NULL; - char buf[NM_STRLEN (EACID) + 1] = { 0 }; - - memcpy (buf + 1, EACID, NM_STRLEN (EACID)); - new_client_id = g_bytes_new (buf, sizeof (buf)); - test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected, - FALSE, NULL, NULL, - NULL, - new_client_id, - "eth0", - NULL); -} -/*******************************************/ - -static const char *fqdn_expected = \ - "# Created by NetworkManager\n" - "\n" - "send fqdn.fqdn \"foo.bar.com\"; # added by NetworkManager\n" - "send fqdn.encoded on;\n" - "send fqdn.server-update on;\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n\n"; - -static void -test_fqdn (void) -{ - test_config (NULL, fqdn_expected, - FALSE, NULL, - "foo.bar.com", NULL, - NULL, - "eth0", - NULL); -} - -static const char *fqdn_options_override_orig = \ - "\n" - "send fqdn.fqdn \"foobar.com\"\n" /* NM must ignore this ... */ - "send fqdn.encoded off;\n" /* ... and honor these */ - "send fqdn.server-update off;\n"; - -static const char *fqdn_options_override_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n" - "send fqdn.fqdn \"example2.com\"; # added by NetworkManager\n" - "send fqdn.encoded on;\n" - "send fqdn.server-update on;\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n" - "# FQDN options from /path/to/dhclient.conf\n" - "send fqdn.encoded off;\n" - "send fqdn.server-update off;\n\n"; - -static void -test_fqdn_options_override (void) -{ - test_config (fqdn_options_override_orig, - fqdn_options_override_expected, - FALSE, NULL, - "example2.com", NULL, - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *override_hostname_orig = \ - "send host-name \"foobar\";\n"; - -static const char *override_hostname_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n" - "send host-name \"blahblah\"; # added by NetworkManager\n" - "\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_override_hostname (void) -{ - test_config (override_hostname_orig, override_hostname_expected, - FALSE, "blahblah", NULL, - NULL, - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *override_hostname6_orig = \ - "send fqdn.fqdn \"foobar\";\n"; - -static const char *override_hostname6_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n" - "send fqdn.fqdn \"blahblah.local\"; # added by NetworkManager\n" - "send fqdn.encoded on;\n" - "send fqdn.server-update on;\n" - "\n" - "also request dhcp6.name-servers;\n" - "also request dhcp6.domain-search;\n" - "also request dhcp6.client-id;\n" - "\n"; - -static void -test_override_hostname6 (void) -{ - test_config (override_hostname6_orig, override_hostname6_expected, - TRUE, "blahblah.local", NULL, - NULL, - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *nonfqdn_hostname6_expected = \ - "# Created by NetworkManager\n" - "\n" - "also request dhcp6.name-servers;\n" - "also request dhcp6.domain-search;\n" - "also request dhcp6.client-id;\n" - "\n"; - -static void -test_nonfqdn_hostname6 (void) -{ - /* Non-FQDN hostname can't be used with dhclient */ - test_config (NULL, nonfqdn_hostname6_expected, - TRUE, "blahblah", - NULL, NULL, - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *existing_alsoreq_orig = \ - "also request something;\n" - "also request another-thing;\n" - ; - -static const char *existing_alsoreq_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request something;\n" - "also request another-thing;\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_existing_alsoreq (void) -{ - test_config (existing_alsoreq_orig, existing_alsoreq_expected, - FALSE, NULL, - NULL, - NULL, - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static const char *existing_multiline_alsoreq_orig = \ - "also request something another-thing yet-another-thing\n" - " foobar baz blah;\n" - ; - -static const char *existing_multiline_alsoreq_expected = \ - "# Created by NetworkManager\n" - "# Merged from /path/to/dhclient.conf\n" - "\n\n" - "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" - "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" - "option wpad code 252 = string;\n" - "\n" - "also request something;\n" - "also request another-thing;\n" - "also request yet-another-thing;\n" - "also request foobar;\n" - "also request baz;\n" - "also request blah;\n" - "also request rfc3442-classless-static-routes;\n" - "also request ms-classless-static-routes;\n" - "also request static-routes;\n" - "also request wpad;\n" - "also request ntp-servers;\n" - "\n"; - -static void -test_existing_multiline_alsoreq (void) -{ - test_config (existing_multiline_alsoreq_orig, existing_multiline_alsoreq_expected, - FALSE, NULL, NULL, - NULL, - NULL, - "eth0", - NULL); -} - -/*******************************************/ - -static void -test_one_duid (const char *escaped, const guint8 *unescaped, guint len) -{ - GByteArray *t; - char *w; - - t = nm_dhcp_dhclient_unescape_duid (escaped); - g_assert (t); - g_assert_cmpint (t->len, ==, len); - g_assert_cmpint (memcmp (t->data, unescaped, len), ==, 0); - g_byte_array_free (t, TRUE); - - t = g_byte_array_sized_new (len); - g_byte_array_append (t, unescaped, len); - w = nm_dhcp_dhclient_escape_duid (t); - g_assert (w); - g_assert_cmpint (strlen (escaped), ==, strlen (w)); - g_assert_cmpstr (escaped, ==, w); - - g_byte_array_free (t, TRUE); - g_free (w); -} - -static void -test_duids (void) -{ - const guint8 test1_u[] = { 0x00, 0x01, 0x00, 0x01, 0x13, 0x6f, 0x13, 0x6e, - 0x00, 0x22, 0xfa, 0x8c, 0xd6, 0xc2 }; - const char *test1_s = "\\000\\001\\000\\001\\023o\\023n\\000\\\"\\372\\214\\326\\302"; - - const guint8 test2_u[] = { 0x00, 0x01, 0x00, 0x01, 0x17, 0x57, 0xee, 0x39, - 0x00, 0x23, 0x15, 0x08, 0x7E, 0xac }; - const char *test2_s = "\\000\\001\\000\\001\\027W\\3569\\000#\\025\\010~\\254"; - - const guint8 test3_u[] = { 0x00, 0x01, 0x00, 0x01, 0x17, 0x58, 0xe8, 0x58, - 0x00, 0x23, 0x15, 0x08, 0x7e, 0xac }; - const char *test3_s = "\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254"; - - const guint8 test4_u[] = { 0x00, 0x01, 0x00, 0x01, 0x15, 0xd5, 0x31, 0x97, - 0x00, 0x16, 0xeb, 0x04, 0x45, 0x18 }; - const char *test4_s = "\\000\\001\\000\\001\\025\\3251\\227\\000\\026\\353\\004E\\030"; - - const char *bad_s = "\\000\\001\\000\\001\\425\\3251\\227\\000\\026\\353\\004E\\030"; - - test_one_duid (test1_s, test1_u, sizeof (test1_u)); - test_one_duid (test2_s, test2_u, sizeof (test2_u)); - test_one_duid (test3_s, test3_u, sizeof (test3_u)); - test_one_duid (test4_s, test4_u, sizeof (test4_u)); - - /* Invalid octal digit */ - g_assert (nm_dhcp_dhclient_unescape_duid (bad_s) == NULL); -} - -static void -test_read_duid_from_leasefile (void) -{ - const guint8 expected[] = { 0x00, 0x01, 0x00, 0x01, 0x18, 0x79, 0xa6, - 0x13, 0x60, 0x67, 0x20, 0xec, 0x4c, 0x70 }; - GByteArray *duid; - GError *error = NULL; - - duid = nm_dhcp_dhclient_read_duid (TESTDIR "/test-dhclient-duid.leases", &error); - g_assert_no_error (error); - g_assert (duid); - g_assert_cmpint (duid->len, ==, sizeof (expected)); - g_assert_cmpint (memcmp (duid->data, expected, duid->len), ==, 0); - - g_byte_array_free (duid, TRUE); -} - -static void -test_read_commented_duid_from_leasefile (void) -{ - GByteArray *duid; - GError *error = NULL; - - duid = nm_dhcp_dhclient_read_duid (TESTDIR "/test-dhclient-commented-duid.leases", &error); - g_assert_no_error (error); - g_assert (duid == NULL); -} - -static void -test_write_duid (void) -{ - const char *duid = "\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254"; - const char *expected_contents = "default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n"; - GError *error = NULL; - char *contents = NULL; - gboolean success; - const char *path = "test-dhclient-write-duid.leases"; - - success = nm_dhcp_dhclient_save_duid (path, duid, &error); - g_assert_no_error (error); - g_assert (success); - - success = g_file_get_contents (path, &contents, NULL, &error); - g_assert_no_error (error); - g_assert (success); - - unlink (path); - g_assert_cmpstr (expected_contents, ==, contents); - - g_free (contents); -} - -static void -test_write_existing_duid (void) -{ - const char *duid = "\\000\\001\\000\\001\\023o\\023n\\000\\\"\\372\\214\\326\\302"; - const char *expected_contents = "default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n"; - GError *error = NULL; - char *contents = NULL; - gboolean success; - const char *path = "test-dhclient-write-existing-duid.leases"; - - success = g_file_set_contents (path, expected_contents, -1, &error); - g_assert_no_error (error); - g_assert (success); - - /* Save other DUID; should be a no-op */ - success = nm_dhcp_dhclient_save_duid (path, duid, &error); - g_assert_no_error (error); - g_assert (success); - - /* reread original contents */ - success = g_file_get_contents (path, &contents, NULL, &error); - g_assert_no_error (error); - g_assert (success); - - unlink (path); - g_assert_cmpstr (expected_contents, ==, contents); - - g_free (contents); -} - -static void -test_write_existing_commented_duid (void) -{ - #define DUID "\\000\\001\\000\\001\\023o\\023n\\000\\\"\\372\\214\\326\\302" - #define ORIG_CONTENTS "#default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n" - const char *expected_contents = \ - "default-duid \"" DUID "\";\n" - ORIG_CONTENTS; - GError *error = NULL; - char *contents = NULL; - gboolean success; - const char *path = "test-dhclient-write-existing-commented-duid.leases"; - - success = g_file_set_contents (path, ORIG_CONTENTS, -1, &error); - g_assert_no_error (error); - g_assert (success); - - /* Save other DUID; should be a no-op */ - success = nm_dhcp_dhclient_save_duid (path, DUID, &error); - g_assert_no_error (error); - g_assert (success); - - /* reread original contents */ - success = g_file_get_contents (path, &contents, NULL, &error); - g_assert_no_error (error); - g_assert (success); - - unlink (path); - g_assert_cmpstr (expected_contents, ==, contents); - - g_free (contents); -} - -/*******************************************/ - -static void -test_read_lease_ip4_config_basic (void) -{ - GError *error = NULL; - char *contents = NULL; - gboolean success; - const char *path = TESTDIR "/leases/basic.leases"; - GSList *leases; - GDateTime *now; - NMIP4Config *config; - const NMPlatformIP4Address *addr; - guint32 expected_addr; - - success = g_file_get_contents (path, &contents, NULL, &error); - g_assert_no_error (error); - g_assert (success); - - /* Date from before the least expiration */ - now = g_date_time_new_utc (2013, 11, 1, 19, 55, 32); - leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); - g_assert_cmpint (g_slist_length (leases), ==, 2); - - /* IP4Config #1 */ - config = g_slist_nth_data (leases, 0); - g_assert (NM_IS_IP4_CONFIG (config)); - - /* Address */ - g_assert_cmpint (nm_ip4_config_get_num_addresses (config), ==, 1); - g_assert (inet_aton ("192.168.1.180", (struct in_addr *) &expected_addr)); - addr = nm_ip4_config_get_address (config, 0); - g_assert_cmpint (addr->address, ==, expected_addr); - g_assert_cmpint (addr->peer_address, ==, expected_addr); - g_assert_cmpint (addr->plen, ==, 24); - - /* Gateway */ - g_assert (inet_aton ("192.168.1.1", (struct in_addr *) &expected_addr)); - g_assert_cmpint (nm_ip4_config_get_gateway (config), ==, expected_addr); - - /* DNS */ - g_assert_cmpint (nm_ip4_config_get_num_nameservers (config), ==, 1); - g_assert (inet_aton ("192.168.1.1", (struct in_addr *) &expected_addr)); - g_assert_cmpint (nm_ip4_config_get_nameserver (config, 0), ==, expected_addr); - - g_assert_cmpint (nm_ip4_config_get_num_domains (config), ==, 0); - - /* IP4Config #2 */ - config = g_slist_nth_data (leases, 1); - g_assert (NM_IS_IP4_CONFIG (config)); - - /* Address */ - g_assert_cmpint (nm_ip4_config_get_num_addresses (config), ==, 1); - g_assert (inet_aton ("10.77.52.141", (struct in_addr *) &expected_addr)); - addr = nm_ip4_config_get_address (config, 0); - g_assert_cmpint (addr->address, ==, expected_addr); - g_assert_cmpint (addr->peer_address, ==, expected_addr); - g_assert_cmpint (addr->plen, ==, 8); - - /* Gateway */ - g_assert (inet_aton ("10.77.52.254", (struct in_addr *) &expected_addr)); - g_assert_cmpint (nm_ip4_config_get_gateway (config), ==, expected_addr); - - /* DNS */ - g_assert_cmpint (nm_ip4_config_get_num_nameservers (config), ==, 2); - g_assert (inet_aton ("8.8.8.8", (struct in_addr *) &expected_addr)); - g_assert_cmpint (nm_ip4_config_get_nameserver (config, 0), ==, expected_addr); - g_assert (inet_aton ("8.8.4.4", (struct in_addr *) &expected_addr)); - g_assert_cmpint (nm_ip4_config_get_nameserver (config, 1), ==, expected_addr); - - /* Domains */ - g_assert_cmpint (nm_ip4_config_get_num_domains (config), ==, 1); - g_assert_cmpstr (nm_ip4_config_get_domain (config, 0), ==, "morriesguest.local"); - - g_slist_free_full (leases, g_object_unref); - g_date_time_unref (now); - g_free (contents); -} - -static void -test_read_lease_ip4_config_expired (void) -{ - GError *error = NULL; - char *contents = NULL; - gboolean success; - const char *path = TESTDIR "/leases/basic.leases"; - GSList *leases; - GDateTime *now; - - success = g_file_get_contents (path, &contents, NULL, &error); - g_assert_no_error (error); - g_assert (success); - - /* Date from *after* the lease expiration */ - now = g_date_time_new_utc (2013, 12, 1, 19, 55, 32); - leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); - g_assert (leases == NULL); - - g_date_time_unref (now); - g_free (contents); -} - -static void -test_read_lease_ip4_config_expect_failure (gconstpointer user_data) -{ - GError *error = NULL; - char *contents = NULL; - gboolean success; - GSList *leases; - GDateTime *now; - - success = g_file_get_contents ((const char *) user_data, &contents, NULL, &error); - g_assert_no_error (error); - g_assert (success); - - /* Date from before the least expiration */ - now = g_date_time_new_utc (2013, 11, 1, 1, 1, 1); - leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); - g_assert (leases == NULL); - - g_date_time_unref (now); - g_free (contents); -} - -/*******************************************/ - -NMTST_DEFINE (); - -int -main (int argc, char **argv) -{ - nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT"); - - g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing); - g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id); - g_test_add_func ("/dhcp/dhclient/quote_client_id", test_quote_client_id); - g_test_add_func ("/dhcp/dhclient/ascii_client_id", test_ascii_client_id); - g_test_add_func ("/dhcp/dhclient/hex_single_client_id", test_hex_single_client_id); - g_test_add_func ("/dhcp/dhclient/existing-hex-client-id", test_existing_hex_client_id); - g_test_add_func ("/dhcp/dhclient/existing-ascii-client-id", test_existing_ascii_client_id); - g_test_add_func ("/dhcp/dhclient/fqdn", test_fqdn); - g_test_add_func ("/dhcp/dhclient/fqdn_options_override", test_fqdn_options_override); - g_test_add_func ("/dhcp/dhclient/override_hostname", test_override_hostname); - g_test_add_func ("/dhcp/dhclient/override_hostname6", test_override_hostname6); - g_test_add_func ("/dhcp/dhclient/nonfqdn_hostname6", test_nonfqdn_hostname6); - g_test_add_func ("/dhcp/dhclient/existing_alsoreq", test_existing_alsoreq); - g_test_add_func ("/dhcp/dhclient/existing_multiline_alsoreq", test_existing_multiline_alsoreq); - g_test_add_func ("/dhcp/dhclient/duids", test_duids); - - g_test_add_func ("/dhcp/dhclient/read_duid_from_leasefile", test_read_duid_from_leasefile); - g_test_add_func ("/dhcp/dhclient/read_commented_duid_from_leasefile", test_read_commented_duid_from_leasefile); - - g_test_add_func ("/dhcp/dhclient/write_duid", test_write_duid); - g_test_add_func ("/dhcp/dhclient/write_existing_duid", test_write_existing_duid); - g_test_add_func ("/dhcp/dhclient/write_existing_commented_duid", test_write_existing_commented_duid); - - g_test_add_func ("/dhcp/dhclient/leases/ip4-config/basic", test_read_lease_ip4_config_basic); - g_test_add_func ("/dhcp/dhclient/leases/ip4-config/expired", test_read_lease_ip4_config_expired); - g_test_add_data_func ("/dhcp/dhclient/leases/ip4-config/missing-address", - TESTDIR "/leases/malformed1.leases", - test_read_lease_ip4_config_expect_failure); - g_test_add_data_func ("/dhcp/dhclient/leases/ip4-config/missing-gateway", - TESTDIR "/leases/malformed2.leases", - test_read_lease_ip4_config_expect_failure); - g_test_add_data_func ("/dhcp/dhclient/leases/ip4-config/missing-expire", - TESTDIR "/leases/malformed3.leases", - test_read_lease_ip4_config_expect_failure); - - return g_test_run (); -} - diff --git a/src/dhcp-manager/tests/test-dhcp-utils.c b/src/dhcp-manager/tests/test-dhcp-utils.c deleted file mode 100644 index 89d693ed..00000000 --- a/src/dhcp-manager/tests/test-dhcp-utils.c +++ /dev/null @@ -1,748 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 - 2014 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include -#include -#include - -#include "nm-utils.h" - -#include "nm-dhcp-utils.h" -#include "nm-platform.h" - -#include "nm-test-utils-core.h" - -typedef struct { - const char *name; - const char *value; -} Option; - -static GHashTable * -fill_table (const Option *test_options, GHashTable *table) -{ - const Option *opt; - - if (!table) - table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); - for (opt = test_options; opt->name; opt++) - g_hash_table_insert (table, (gpointer) opt->name, (gpointer) opt->value); - return table; -} - -static const Option generic_options[] = { - { "subnet_mask", "255.255.255.0" }, - { "ip_address", "192.168.1.106" }, - { "network_number", "192.168.1.0" }, - { "expiry", "1232324877" }, - { "dhcp_lease_time", "3600" }, - { "dhcp_server_identifier", "192.168.1.1" }, - { "routers", "192.168.1.1" }, - { "domain_name_servers", "216.254.95.2 216.231.41.2" }, - { "dhcp_message_type", "5" }, - { "broadcast_address", "192.168.1.255" }, - { "domain_search", "foobar.com blah.foobar.com" }, - { "host_name", "nmreallywhipsthe" }, - { "domain_name", "lamasass.com" }, - { "interface_mtu", "987" }, - { "static_routes", "10.1.1.5 10.1.1.1 100.99.88.56 10.1.1.1" }, - { NULL, NULL } -}; - -static void -test_generic_options (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address *address; - const NMPlatformIP4Route *route; - guint32 tmp; - const char *expected_addr = "192.168.1.106"; - const char *expected_gw = "192.168.1.1"; - const char *expected_dns1 = "216.254.95.2"; - const char *expected_dns2 = "216.231.41.2"; - const char *expected_search1 = "foobar.com"; - const char *expected_search2 = "blah.foobar.com"; - const char *expected_route1_dest = "10.1.1.5"; - const char *expected_route1_gw = "10.1.1.1"; - const char *expected_route2_dest = "100.99.88.56"; - const char *expected_route2_gw = "10.1.1.1"; - - options = fill_table (generic_options, NULL); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* IP4 address */ - g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); - address = nm_ip4_config_get_address (ip4_config, 0); - g_assert (inet_pton (AF_INET, expected_addr, &tmp) > 0); - g_assert (address->address == tmp); - g_assert (address->peer_address == tmp); - g_assert_cmpint (address->plen, ==, 24); - - /* Gateway */ - g_assert (inet_pton (AF_INET, expected_gw, &tmp) > 0); - g_assert (nm_ip4_config_get_gateway (ip4_config) == tmp); - - g_assert_cmpint (nm_ip4_config_get_num_wins (ip4_config), ==, 0); - - g_assert_cmpint (nm_ip4_config_get_mtu (ip4_config), ==, 987); - - /* Domain searches */ - g_assert_cmpint (nm_ip4_config_get_num_searches (ip4_config), ==, 2); - g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 0), ==, expected_search1); - g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 1), ==, expected_search2); - - /* DNS servers */ - g_assert_cmpint (nm_ip4_config_get_num_nameservers (ip4_config), ==, 2); - g_assert (inet_pton (AF_INET, expected_dns1, &tmp) > 0); - g_assert (nm_ip4_config_get_nameserver (ip4_config, 0) == tmp); - g_assert (inet_pton (AF_INET, expected_dns2, &tmp) > 0); - g_assert (nm_ip4_config_get_nameserver (ip4_config, 1) == tmp); - - /* Routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); - - /* Route #1 */ - route = nm_ip4_config_get_route (ip4_config, 0); - g_assert (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0); - g_assert (route->network == tmp); - g_assert (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0); - g_assert (route->gateway == tmp); - g_assert_cmpint (route->plen, ==, 32); - g_assert_cmpint (route->metric, ==, 0); - - /* Route #2 */ - route = nm_ip4_config_get_route (ip4_config, 1); - g_assert (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0); - g_assert (route->network == tmp); - g_assert (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0); - g_assert (route->gateway == tmp); - g_assert_cmpint (route->plen, ==, 32); - g_assert_cmpint (route->metric, ==, 0); - - g_hash_table_destroy (options); -} - -static void -test_wins_options (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address *address; - guint32 tmp; - const char *expected_wins1 = "63.12.199.5"; - const char *expected_wins2 = "150.4.88.120"; - static const Option data[] = { - { "netbios_name_servers", "63.12.199.5 150.4.88.120" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* IP4 address */ - g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); - address = nm_ip4_config_get_address (ip4_config, 0); - g_assert (address); - g_assert_cmpint (nm_ip4_config_get_num_wins (ip4_config), ==, 2); - g_assert (inet_pton (AF_INET, expected_wins1, &tmp) > 0); - g_assert (nm_ip4_config_get_wins (ip4_config, 0) == tmp); - g_assert (inet_pton (AF_INET, expected_wins2, &tmp) > 0); - g_assert (nm_ip4_config_get_wins (ip4_config, 1) == tmp); - - g_hash_table_destroy (options); -} - -static void -test_vendor_option_metered (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - static const Option data[] = { - { "vendor_encapsulated_options", "ANDROID_METERED" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_assert (nm_ip4_config_get_metered (ip4_config) == FALSE); - g_hash_table_destroy (options); - g_clear_object (&ip4_config); - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_assert (nm_ip4_config_get_metered (ip4_config) == TRUE); - g_hash_table_destroy (options); -} - -static void -ip4_test_route (NMIP4Config *ip4_config, - guint route_num, - const char *expected_dest, - const char *expected_gw, - guint expected_prefix) -{ - const NMPlatformIP4Route *route; - guint32 tmp; - - g_assert (expected_prefix <= 32); - - route = nm_ip4_config_get_route (ip4_config, route_num); - g_assert (inet_pton (AF_INET, expected_dest, &tmp) > 0); - g_assert (route->network == tmp); - g_assert (inet_pton (AF_INET, expected_gw, &tmp) > 0); - g_assert (route->gateway == tmp); - g_assert_cmpint (route->plen, ==, expected_prefix); - g_assert_cmpint (route->metric, ==, 0); -} - -static void -ip4_test_gateway (NMIP4Config *ip4_config, const char *expected_gw) -{ - guint32 tmp; - - g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); - g_assert (inet_pton (AF_INET, expected_gw, &tmp) > 0); - g_assert (nm_ip4_config_get_gateway (ip4_config) == tmp); -} - -static void -test_classless_static_routes_1 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "192.168.10.0"; - const char *expected_route1_gw = "192.168.1.1"; - const char *expected_route2_dest = "10.0.0.0"; - const char *expected_route2_gw = "10.17.66.41"; - static const Option data[] = { - /* dhclient custom format */ - { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 8 10 10 17 66 41" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 8); - - g_hash_table_destroy (options); -} - -static void -test_classless_static_routes_2 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "192.168.10.0"; - const char *expected_route1_gw = "192.168.1.1"; - const char *expected_route2_dest = "10.0.0.0"; - const char *expected_route2_gw = "10.17.66.41"; - static const Option data[] = { - /* dhcpcd format */ - { "classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 8); - - g_hash_table_destroy (options); -} - -static void -test_fedora_dhclient_classless_static_routes (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "129.210.177.128"; - const char *expected_route1_gw = "192.168.0.113"; - const char *expected_route2_dest = "2.0.0.0"; - const char *expected_route2_gw = "10.34.255.6"; - const char *expected_gateway = "192.168.0.113"; - static const Option data[] = { - /* Fedora dhclient format */ - { "classless_static_routes", "0 192.168.0.113 25.129.210.177.132 192.168.0.113 7.2 10.34.255.6" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 25); - ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 7); - - /* Gateway */ - ip4_test_gateway (ip4_config, expected_gateway); - - g_hash_table_destroy (options); -} - -static void -test_dhclient_invalid_classless_routes_1 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "192.168.10.0"; - const char *expected_route1_gw = "192.168.1.1"; - static const Option data[] = { - /* dhclient format */ - { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 45 10 17 66 41" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*ignoring invalid classless static routes*"); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_test_assert_expected_messages (); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - - g_hash_table_destroy (options); -} - -static void -test_dhcpcd_invalid_classless_routes_1 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "10.1.1.5"; - const char *expected_route1_gw = "10.1.1.1"; - const char *expected_route2_dest = "100.99.88.56"; - const char *expected_route2_gw = "10.1.1.1"; - static const Option data[] = { - /* dhcpcd format */ - { "classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.adfadf/44 10.17.66.41" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*ignoring invalid classless static routes*"); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_test_assert_expected_messages (); - - /* Test falling back to old-style static routes if the classless static - * routes are invalid. - */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); - ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); - - g_hash_table_destroy (options); -} - -static void -test_dhclient_invalid_classless_routes_2 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "10.1.1.5"; - const char *expected_route1_gw = "10.1.1.1"; - const char *expected_route2_dest = "100.99.88.56"; - const char *expected_route2_gw = "10.1.1.1"; - static const Option data[] = { - { "rfc3442_classless_static_routes", "45 10 17 66 41 24 192 168 10 192 168 1 1" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*ignoring invalid classless static routes*"); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_test_assert_expected_messages (); - - /* Test falling back to old-style static routes if the classless static - * routes are invalid. - */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); - ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); - - g_hash_table_destroy (options); -} - -static void -test_dhcpcd_invalid_classless_routes_2 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "10.1.1.5"; - const char *expected_route1_gw = "10.1.1.1"; - const char *expected_route2_dest = "100.99.88.56"; - const char *expected_route2_gw = "10.1.1.1"; - static const Option data[] = { - { "classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*ignoring invalid classless static routes*"); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_test_assert_expected_messages (); - - /* Test falling back to old-style static routes if the classless static - * routes are invalid. - */ - - /* Routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); - ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); - - g_hash_table_destroy (options); -} - -static void -test_dhclient_invalid_classless_routes_3 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "192.168.10.0"; - const char *expected_route1_gw = "192.168.1.1"; - static const Option data[] = { - { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*ignoring invalid classless static routes*"); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_test_assert_expected_messages (); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - - g_hash_table_destroy (options); -} - -static void -test_dhcpcd_invalid_classless_routes_3 (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "192.168.10.0"; - const char *expected_route1_gw = "192.168.1.1"; - static Option data[] = { - { "classless_static_routes", "192.168.10.0/24 192.168.1.1 128/32 10.17.66.41" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*DHCP provided invalid classless static route*"); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_test_assert_expected_messages (); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - - g_hash_table_destroy (options); -} - -static void -test_dhclient_gw_in_classless_routes (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "192.168.10.0"; - const char *expected_route1_gw = "192.168.1.1"; - const char *expected_gateway = "192.2.3.4"; - static Option data[] = { - { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 0 192 2 3 4" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - - /* Gateway */ - ip4_test_gateway (ip4_config, expected_gateway); - - g_hash_table_destroy (options); -} - -static void -test_dhcpcd_gw_in_classless_routes (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_route1_dest = "192.168.10.0"; - const char *expected_route1_gw = "192.168.1.1"; - const char *expected_gateway = "192.2.3.4"; - static Option data[] = { - { "classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* IP4 routes */ - g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); - ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); - - /* Gateway */ - ip4_test_gateway (ip4_config, expected_gateway); - - g_hash_table_destroy (options); -} - -static void -test_escaped_domain_searches (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const char *expected_search0 = "host1"; - const char *expected_search1 = "host2"; - const char *expected_search2 = "host3"; - static const Option data[] = { - { "domain_search", "host1\\032host2\\032host3" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - /* domain searches */ - g_assert_cmpint (nm_ip4_config_get_num_searches (ip4_config), ==, 3); - g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 0), ==, expected_search0); - g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 1), ==, expected_search1); - g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 2), ==, expected_search2); - - g_hash_table_destroy (options); -} - -static void -test_invalid_escaped_domain_searches (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - static const Option data[] = { - { "domain_search", "host1\\aahost2\\032host3" }, - { NULL, NULL } - }; - - options = fill_table (generic_options, NULL); - options = fill_table (data, options); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*invalid domain search*"); - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - g_test_assert_expected_messages (); - - /* domain searches */ - g_assert_cmpint (nm_ip4_config_get_num_searches (ip4_config), ==, 0); - - g_hash_table_destroy (options); -} - -static void -test_ip4_missing_prefix (const char *ip, guint32 expected_prefix) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address *address; - - options = fill_table (generic_options, NULL); - g_hash_table_insert (options, "ip_address", (gpointer) ip); - g_hash_table_remove (options, "subnet_mask"); - - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); - address = nm_ip4_config_get_address (ip4_config, 0); - g_assert (address); - g_assert_cmpint (address->plen, ==, expected_prefix); - - g_hash_table_destroy (options); -} - -static void -test_ip4_missing_prefix_24 (void) -{ - test_ip4_missing_prefix ("192.168.1.10", 24); -} - -static void -test_ip4_missing_prefix_16 (void) -{ - test_ip4_missing_prefix ("172.16.54.50", 16); -} - -static void -test_ip4_missing_prefix_8 (void) -{ - test_ip4_missing_prefix ("10.1.2.3", 8); -} - -static void -test_ip4_prefix_classless (void) -{ - GHashTable *options; - gs_unref_object NMIP4Config *ip4_config = NULL; - const NMPlatformIP4Address *address; - - /* Ensure that the missing-subnet-mask handler doesn't mangle classless - * subnet masks at all. The handler should trigger only if the server - * doesn't send the subnet mask. - */ - - options = fill_table (generic_options, NULL); - g_hash_table_insert (options, "ip_address", "172.16.54.22"); - g_hash_table_insert (options, "subnet_mask", "255.255.252.0"); - - ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); - g_assert (ip4_config); - - g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); - address = nm_ip4_config_get_address (ip4_config, 0); - g_assert (address); - g_assert_cmpint (address->plen, ==, 22); - - g_hash_table_destroy (options); -} - -#define COMPARE_ID(src, is_str, expected, expected_len) \ -G_STMT_START { \ - gs_unref_bytes GBytes *b = NULL; \ - const char *p; \ - gsize l; \ - \ - b = nm_dhcp_utils_client_id_string_to_bytes (src); \ - g_assert (b); \ - p = g_bytes_get_data (b, &l); \ - if (is_str) { \ - g_assert_cmpint (l, ==, expected_len + 1); \ - g_assert_cmpint (((const char *) p)[0], ==, 0); \ - g_assert (memcmp (p + 1, expected, expected_len) == 0); \ - } else { \ - g_assert_cmpint (l, ==, expected_len); \ - g_assert (memcmp (p, expected, expected_len) == 0); \ - } \ -} G_STMT_END - -static void -test_client_id_from_string (void) -{ - const char *nothex = "asdfasdfasdfasdfasdfasdfasdf"; - const char *allhex = "00:11:22:33:4:55:66:77:88"; - const guint8 allhex_bin[] = { 0x00, 0x11, 0x22, 0x33, 0x04, 0x55, 0x66, 0x77, 0x88 }; - const char *somehex = "00:11:22:33:44:55:asdfasdfasdf:99:10"; - const char *nocolons = "0011223344559910"; - const char *endcolon = "00:11:22:33:44:55:"; - - COMPARE_ID (nothex, TRUE, nothex, strlen (nothex)); - COMPARE_ID (allhex, FALSE, allhex_bin, sizeof (allhex_bin)); - COMPARE_ID (somehex, TRUE, somehex, strlen (somehex)); - COMPARE_ID (nocolons, TRUE, nocolons, strlen (nocolons)); - COMPARE_ID (endcolon, TRUE, endcolon, strlen (endcolon)); -} - -NMTST_DEFINE (); - -int main (int argc, char **argv) -{ - nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); - - g_test_add_func ("/dhcp/generic-options", test_generic_options); - g_test_add_func ("/dhcp/wins-options", test_wins_options); - g_test_add_func ("/dhcp/classless-static-routes-1", test_classless_static_routes_1); - g_test_add_func ("/dhcp/classless-static-routes-2", test_classless_static_routes_2); - g_test_add_func ("/dhcp/fedora-dhclient-classless-static-routes", test_fedora_dhclient_classless_static_routes); - g_test_add_func ("/dhcp/dhclient-invalid-classless-routes-1", test_dhclient_invalid_classless_routes_1); - g_test_add_func ("/dhcp/dhcpcd-invalid-classless-routes-1", test_dhcpcd_invalid_classless_routes_1); - g_test_add_func ("/dhcp/dhclient-invalid-classless-routes-2", test_dhclient_invalid_classless_routes_2); - g_test_add_func ("/dhcp/dhcpcd-invalid-classless-routes-2", test_dhcpcd_invalid_classless_routes_2); - g_test_add_func ("/dhcp/dhclient-invalid-classless-routes-3", test_dhclient_invalid_classless_routes_3); - g_test_add_func ("/dhcp/dhcpcd-invalid-classless-routes-3", test_dhcpcd_invalid_classless_routes_3); - g_test_add_func ("/dhcp/dhclient-gw-in-classless-routes", test_dhclient_gw_in_classless_routes); - g_test_add_func ("/dhcp/dhcpcd-gw-in-classless-routes", test_dhcpcd_gw_in_classless_routes); - g_test_add_func ("/dhcp/escaped-domain-searches", test_escaped_domain_searches); - g_test_add_func ("/dhcp/invalid-escaped-domain-searches", test_invalid_escaped_domain_searches); - g_test_add_func ("/dhcp/ip4-missing-prefix-24", test_ip4_missing_prefix_24); - g_test_add_func ("/dhcp/ip4-missing-prefix-16", test_ip4_missing_prefix_16); - g_test_add_func ("/dhcp/ip4-missing-prefix-8", test_ip4_missing_prefix_8); - g_test_add_func ("/dhcp/ip4-prefix-classless", test_ip4_prefix_classless); - g_test_add_func ("/dhcp/client-id-from-string", test_client_id_from_string); - g_test_add_func ("/dhcp/vendor-option-metered", test_vendor_option_metered); - - return g_test_run (); -} - diff --git a/src/dhcp/nm-dhcp-client-logging.h b/src/dhcp/nm-dhcp-client-logging.h new file mode 100644 index 00000000..8dd18bf2 --- /dev/null +++ b/src/dhcp/nm-dhcp-client-logging.h @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2016 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ +#define __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ + +#include "nm-dhcp-client.h" + +#define _NMLOG_PREFIX_NAME "dhcp" +#define _NMLOG_DOMAIN LOGD_DHCP +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMLogLevel _level = (level); \ + \ + /* we check first for LOGD_DHCP instead of the correct domain. + * In the worst case, we guess wrong and enter the block. + * + * Same for the _NMLOG_ENABLED() macro. Probably it would be more + * expensive to determine the correct value then what we could + * safe. */ \ + if (nm_logging_enabled (_level, _NMLOG_DOMAIN)) { \ + NMDhcpClient *_self = (NMDhcpClient *) (self); \ + const char *__ifname = _self ? nm_dhcp_client_get_iface (_self) : NULL; \ + const NMLogDomain _domain = !_self \ + ? LOGD_DHCP \ + : (nm_dhcp_client_get_ipv6 (_self) ? LOGD_DHCP6 : LOGD_DHCP4); \ + \ + nm_log (_level, _domain, \ + "%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG_PREFIX_NAME, \ + (_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \ + NM_PRINT_FMT_QUOTED (__ifname, " (", __ifname, ")", "") \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +#define _NMLOG2(level, domain, ifname, ...) \ + G_STMT_START { \ + const NMLogLevel _level = (level); \ + const NMLogDomain _domain = (domain); \ + \ + /* we check first for LOGD_DHCP instead of the correct domain. + * In the worst case, we guess wrong and enter the block. + * + * Same for the _NMLOG_ENABLED() macro. Probably it would be more + * expensive to determine the correct value then what we could + * safe. */ \ + if (nm_logging_enabled (_level, _domain)) { \ + const char *__ifname = (ifname); \ + \ + nm_log (_level, _domain, \ + "%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG_PREFIX_NAME, \ + (_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \ + NM_PRINT_FMT_QUOTED (__ifname, " (", __ifname, ")", "") \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +#endif /* __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ */ diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c new file mode 100644 index 00000000..ba7c6dbf --- /dev/null +++ b/src/dhcp/nm-dhcp-client.c @@ -0,0 +1,997 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2010 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include "nm-dhcp-client.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "NetworkManagerUtils.h" +#include "nm-utils.h" +#include "nm-dhcp-utils.h" +#include "platform/nm-platform.h" + +#include "nm-dhcp-client-logging.h" + +/*****************************************************************************/ + +enum { + SIGNAL_STATE_CHANGED, + SIGNAL_PREFIX_DELEGATED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_IFACE, + PROP_IFINDEX, + PROP_HWADDR, + PROP_IPV6, + PROP_UUID, + PROP_PRIORITY, + PROP_TIMEOUT, +); + +typedef struct _NMDhcpClientPrivate { + char * iface; + int ifindex; + GByteArray * hwaddr; + gboolean ipv6; + char * uuid; + guint32 priority; + guint32 timeout; + GByteArray * duid; + GBytes * client_id; + char * hostname; + char * fqdn; + + NMDhcpState state; + pid_t pid; + guint timeout_id; + guint watch_id; + gboolean info_only; +} NMDhcpClientPrivate; + +G_DEFINE_TYPE_EXTENDED (NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, {}) + +#define NM_DHCP_CLIENT_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMDhcpClient, NM_IS_DHCP_CLIENT) + +/*****************************************************************************/ + +pid_t +nm_dhcp_client_get_pid (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), -1); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->pid; +} + +const char * +nm_dhcp_client_get_iface (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->iface; +} + +int +nm_dhcp_client_get_ifindex (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), -1); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->ifindex; +} + +gboolean +nm_dhcp_client_get_ipv6 (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->ipv6; +} + +const char * +nm_dhcp_client_get_uuid (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->uuid; +} + +const GByteArray * +nm_dhcp_client_get_duid (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->duid; +} + +const GByteArray * +nm_dhcp_client_get_hw_addr (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->hwaddr; +} + +guint32 +nm_dhcp_client_get_priority (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), G_MAXUINT32); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->priority; +} + +GBytes * +nm_dhcp_client_get_client_id (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->client_id; +} + +void +nm_dhcp_client_set_client_id (NMDhcpClient *self, GBytes *client_id) +{ + NMDhcpClientPrivate *priv; + + g_return_if_fail (NM_IS_DHCP_CLIENT (self)); + + priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + if (priv->client_id && client_id && g_bytes_equal (priv->client_id, client_id)) + return; + g_clear_pointer (&priv->client_id, g_bytes_unref); + priv->client_id = client_id ? g_bytes_ref (client_id) : NULL; +} + +const char * +nm_dhcp_client_get_hostname (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->hostname; +} + +const char * +nm_dhcp_client_get_fqdn (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->fqdn; +} + +/*****************************************************************************/ + +static const char *state_table[NM_DHCP_STATE_MAX + 1] = { + [NM_DHCP_STATE_UNKNOWN] = "unknown", + [NM_DHCP_STATE_BOUND] = "bound", + [NM_DHCP_STATE_TIMEOUT] = "timeout", + [NM_DHCP_STATE_EXPIRE] = "expire", + [NM_DHCP_STATE_DONE] = "done", + [NM_DHCP_STATE_FAIL] = "fail", +}; + +static const char * +state_to_string (NMDhcpState state) +{ + if ((gsize) state < G_N_ELEMENTS (state_table)) + return state_table[state]; + return NULL; +} + +static NMDhcpState +reason_to_state (NMDhcpClient *self, const char *iface, const char *reason) +{ + if (g_ascii_strcasecmp (reason, "bound") == 0 || + g_ascii_strcasecmp (reason, "bound6") == 0 || + g_ascii_strcasecmp (reason, "renew") == 0 || + g_ascii_strcasecmp (reason, "renew6") == 0 || + g_ascii_strcasecmp (reason, "reboot") == 0 || + g_ascii_strcasecmp (reason, "rebind") == 0 || + g_ascii_strcasecmp (reason, "rebind6") == 0) + return NM_DHCP_STATE_BOUND; + else if (g_ascii_strcasecmp (reason, "timeout") == 0) + return NM_DHCP_STATE_TIMEOUT; + else if (g_ascii_strcasecmp (reason, "nak") == 0 || + g_ascii_strcasecmp (reason, "expire") == 0 || + g_ascii_strcasecmp (reason, "expire6") == 0) + return NM_DHCP_STATE_EXPIRE; + else if (g_ascii_strcasecmp (reason, "end") == 0) + return NM_DHCP_STATE_DONE; + else if (g_ascii_strcasecmp (reason, "fail") == 0 || + g_ascii_strcasecmp (reason, "abend") == 0) + return NM_DHCP_STATE_FAIL; + + _LOGD ("unmapped DHCP state '%s'", reason); + return NM_DHCP_STATE_UNKNOWN; +} + +/*****************************************************************************/ + +static void +timeout_cleanup (NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + nm_clear_g_source (&priv->timeout_id); +} + +static void +watch_cleanup (NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + nm_clear_g_source (&priv->watch_id); +} + +void +nm_dhcp_client_stop_pid (pid_t pid, const char *iface) +{ + char *name = iface ? g_strdup_printf ("dhcp-client-%s", iface) : NULL; + + g_return_if_fail (pid > 1); + + nm_utils_kill_child_sync (pid, SIGTERM, LOGD_DHCP, name ? name : "dhcp-client", NULL, + 1000 / 2, 1000 / 20); + g_free (name); +} + +static void +stop (NMDhcpClient *self, gboolean release, const GByteArray *duid) +{ + NMDhcpClientPrivate *priv; + + g_return_if_fail (NM_IS_DHCP_CLIENT (self)); + + priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + if (priv->pid > 0) { + /* Clean up the watch handler since we're explicitly killing the daemon */ + watch_cleanup (self); + nm_dhcp_client_stop_pid (priv->pid, priv->iface); + } + priv->pid = -1; + priv->info_only = FALSE; +} + +void +nm_dhcp_client_set_state (NMDhcpClient *self, + NMDhcpState new_state, + GObject *ip_config, + GHashTable *options) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + gs_free char *event_id = NULL; + + if (new_state >= NM_DHCP_STATE_BOUND) + timeout_cleanup (self); + if (new_state >= NM_DHCP_STATE_TIMEOUT) + watch_cleanup (self); + + if (new_state == NM_DHCP_STATE_BOUND) { + g_assert ( (priv->ipv6 && NM_IS_IP6_CONFIG (ip_config)) + || (!priv->ipv6 && NM_IS_IP4_CONFIG (ip_config))); + g_assert (options); + g_assert_cmpint (g_hash_table_size (options), >, 0); + } else { + g_assert (ip_config == NULL); + g_assert (options == NULL); + } + + /* The client may send same-state transitions for RENEW/REBIND events and + * the lease may have changed, so handle same-state transitions for the + * BOUND state. Ignore same-state transitions for other events since + * the lease won't have changed and the state was already handled. + */ + if ((priv->state == new_state) && (new_state != NM_DHCP_STATE_BOUND)) + return; + + if (priv->ipv6 && new_state == NM_DHCP_STATE_BOUND) { + char *start, *iaid; + + iaid = g_hash_table_lookup (options, "iaid"); + start = g_hash_table_lookup (options, "life_starts"); + if (iaid && start) + event_id = g_strdup_printf ("%s|%s", iaid, start); + } + + _LOGI ("state changed %s -> %s%s%s%s", + state_to_string (priv->state), + state_to_string (new_state), + NM_PRINT_FMT_QUOTED (event_id, ", event ID=\"", event_id, "\"", "")); + + priv->state = new_state; + g_signal_emit (G_OBJECT (self), + signals[SIGNAL_STATE_CHANGED], 0, + new_state, + ip_config, + options, + event_id); +} + +static gboolean +transaction_timeout (gpointer user_data) +{ + NMDhcpClient *self = NM_DHCP_CLIENT (user_data); + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + priv->timeout_id = 0; + _LOGW ("request timed out"); + nm_dhcp_client_set_state (self, NM_DHCP_STATE_TIMEOUT, NULL, NULL); + return G_SOURCE_REMOVE; +} + +static void +daemon_watch_cb (GPid pid, gint status, gpointer user_data) +{ + NMDhcpClient *self = NM_DHCP_CLIENT (user_data); + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + NMDhcpState new_state; + + g_return_if_fail (priv->watch_id); + priv->watch_id = 0; + + if (WIFEXITED (status)) + _LOGI ("client pid %d exited with status %d", pid, WEXITSTATUS (status)); + else if (WIFSIGNALED (status)) + _LOGI ("client pid %d killed by signal %d", pid, WTERMSIG (status)); + else if (WIFSTOPPED(status)) + _LOGI ("client pid %d stopped by signal %d", pid, WSTOPSIG (status)); + else if (WIFCONTINUED (status)) + _LOGI ("client pid %d resumed (by SIGCONT)", pid); + else + _LOGW ("client died abnormally"); + + if (!WIFEXITED (status)) + new_state = NM_DHCP_STATE_FAIL; + else + new_state = NM_DHCP_STATE_DONE; + + priv->pid = -1; + + nm_dhcp_client_set_state (self, new_state, NULL, NULL); +} + +void +nm_dhcp_client_start_timeout (NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + /* Set up a timeout on the transaction to kill it after the timeout */ + g_assert (priv->timeout_id == 0); + priv->timeout_id = g_timeout_add_seconds (priv->timeout, + transaction_timeout, + self); +} + +void +nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + g_return_if_fail (priv->pid == -1); + priv->pid = pid; + + nm_dhcp_client_start_timeout (self); + + g_return_if_fail (priv->watch_id == 0); + priv->watch_id = g_child_watch_add (pid, daemon_watch_cb, self); +} + +gboolean +nm_dhcp_client_start_ip4 (NMDhcpClient *self, + const char *dhcp_client_id, + const char *dhcp_anycast_addr, + const char *hostname, + const char *fqdn, + const char *last_ip4_address) +{ + NMDhcpClientPrivate *priv; + gs_unref_bytes GBytes *tmp = NULL; + + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE); + + priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + g_return_val_if_fail (priv->pid == -1, FALSE); + g_return_val_if_fail (priv->ipv6 == FALSE, FALSE); + g_return_val_if_fail (priv->uuid != NULL, FALSE); + + _LOGI ("activation: beginning transaction (timeout in %d seconds)", priv->timeout); + + if (dhcp_client_id) + tmp = nm_dhcp_utils_client_id_string_to_bytes (dhcp_client_id); + nm_dhcp_client_set_client_id (self, tmp); + + g_clear_pointer (&priv->hostname, g_free); + priv->hostname = g_strdup (hostname); + g_free (priv->fqdn); + priv->fqdn = g_strdup (fqdn); + + return NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, dhcp_anycast_addr, last_ip4_address); +} + +static GByteArray * +generate_duid_from_machine_id (void) +{ + GByteArray *duid; + GChecksum *sum; + guint8 buffer[32]; /* SHA256 digest size */ + gsize sumlen = sizeof (buffer); + const guint16 duid_type = g_htons (4); + uuid_t uuid; + GRand *generator; + guint i; + gs_free char *machine_id_s = NULL; + gs_free char *str = NULL; + + machine_id_s = nm_utils_machine_id_read (); + if (nm_utils_machine_id_parse (machine_id_s, uuid)) { + /* Hash the machine ID so it's not leaked to the network */ + sum = g_checksum_new (G_CHECKSUM_SHA256); + g_checksum_update (sum, (const guchar *) &uuid, sizeof (uuid)); + g_checksum_get_digest (sum, buffer, &sumlen); + g_checksum_free (sum); + } else { + nm_log_warn (LOGD_DHCP, "dhcp: failed to read " SYSCONFDIR "/machine-id " + "or " LOCALSTATEDIR "/lib/dbus/machine-id to generate " + "DHCPv6 DUID; creating non-persistent random DUID."); + + generator = g_rand_new (); + for (i = 0; i < sizeof (buffer) / sizeof (guint32); i++) + ((guint32 *) buffer)[i] = g_rand_int (generator); + g_rand_free (generator); + } + + /* Generate a DHCP Unique Identifier for DHCPv6 using the + * DUID-UUID method (see RFC 6355 section 4). Format is: + * + * u16: type (DUID-UUID = 4) + * u8[16]: UUID bytes + */ + duid = g_byte_array_sized_new (18); + g_byte_array_append (duid, (guint8 *) &duid_type, sizeof (duid_type)); + + /* Since SHA256 is 256 bits, but UUID is 128 bits, we just take the first + * 128 bits of the SHA256 as the DUID-UUID. + */ + g_byte_array_append (duid, buffer, 16); + + nm_log_dbg (LOGD_DHCP, "dhcp: generated DUID %s", + (str = nm_dhcp_utils_duid_to_string (duid))); + return duid; +} + +static GByteArray * +get_duid (NMDhcpClient *self) +{ + static GByteArray *duid = NULL; + GByteArray *copy = NULL; + + if (G_UNLIKELY (duid == NULL)) { + duid = generate_duid_from_machine_id (); + g_assert (duid); + } + + if (G_LIKELY (duid)) { + copy = g_byte_array_sized_new (duid->len); + g_byte_array_append (copy, duid->data, duid->len); + } + + return copy; +} + +gboolean +nm_dhcp_client_start_ip6 (NMDhcpClient *self, + const char *dhcp_anycast_addr, + const struct in6_addr *ll_addr, + const char *hostname, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + guint needed_prefixes) +{ + NMDhcpClientPrivate *priv; + gs_free char *str = NULL; + + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE); + + priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + g_return_val_if_fail (priv->pid == -1, FALSE); + g_return_val_if_fail (priv->ipv6 == TRUE, FALSE); + g_return_val_if_fail (priv->uuid != NULL, FALSE); + + /* If we don't have one yet, read the default DUID for this DHCPv6 client + * from the client-specific persistent configuration. + */ + if (!priv->duid) + priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self); + + _LOGD ("DUID is '%s'", (str = nm_dhcp_utils_duid_to_string (priv->duid))); + + g_clear_pointer (&priv->hostname, g_free); + priv->hostname = g_strdup (hostname); + + priv->info_only = info_only; + + _LOGI ("activation: beginning transaction (timeout in %d seconds)", + priv->timeout); + + return NM_DHCP_CLIENT_GET_CLASS (self)->ip6_start (self, + dhcp_anycast_addr, + ll_addr, + info_only, + privacy, + priv->duid, + needed_prefixes); +} + +void +nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name) +{ + guint64 start_time; + pid_t pid, ppid; + const char *exe; + char proc_path[NM_STRLEN ("/proc/%lu/cmdline") + 100]; + gs_free char *pid_contents = NULL, *proc_contents = NULL; + + /* Check for an existing instance and stop it */ + if (!g_file_get_contents (pid_file, &pid_contents, NULL, NULL)) + return; + + pid = _nm_utils_ascii_str_to_int64 (pid_contents, 10, 1, G_MAXINT64, 0); + if (pid <= 0) + goto out; + + start_time = nm_utils_get_start_time_for_pid (pid, NULL, &ppid); + if (start_time == 0) + goto out; + + nm_sprintf_buf (proc_path, "/proc/%lu/cmdline", (long unsigned) pid); + if (!g_file_get_contents (proc_path, &proc_contents, NULL, NULL)) + goto out; + + exe = strrchr (proc_contents, '/'); + if (exe) + exe++; + else + exe = proc_contents; + if (!nm_streq0 (exe, binary_name)) + goto out; + + if (ppid == getpid ()) { + /* the process is our own child. */ + nm_utils_kill_child_sync (pid, SIGTERM, LOGD_DHCP, "dhcp-client", NULL, 1000 / 2, 1000 / 20); + } else { + nm_utils_kill_process_sync (pid, start_time, SIGTERM, LOGD_DHCP, + "dhcp-client", 1000 / 2, 1000 / 20, 2000); + } + +out: + if (remove (pid_file) == -1) { + nm_log_dbg (LOGD_DHCP, "dhcp: could not remove pid file \"%s\": %d (%s)", + pid_file, errno, g_strerror (errno)); + } +} + +void +nm_dhcp_client_stop (NMDhcpClient *self, gboolean release) +{ + NMDhcpClientPrivate *priv; + pid_t old_pid = 0; + + g_return_if_fail (NM_IS_DHCP_CLIENT (self)); + + priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + /* Kill the DHCP client */ + old_pid = priv->pid; + NM_DHCP_CLIENT_GET_CLASS (self)->stop (self, release, priv->duid); + if (old_pid > 0) + _LOGI ("canceled DHCP transaction, DHCP client pid %d", old_pid); + else + _LOGI ("canceled DHCP transaction"); + g_assert (priv->pid == -1); + + nm_dhcp_client_set_state (self, NM_DHCP_STATE_DONE, NULL, NULL); +} + +/*****************************************************************************/ + +static char * +bytearray_variant_to_string (NMDhcpClient *self, 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 (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 (length); + for (i = 0; i < length; i++) { + c = array[i]; + + /* 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); + } + str = g_string_append_c (str, '\0'); + + converted = str->str; + if (!g_utf8_validate (converted, -1, NULL)) + _LOGW ("option '%s' couldn't be converted to UTF-8", key); + g_string_free (str, FALSE); + return converted; +} + +#define OLD_TAG "old_" +#define NEW_TAG "new_" + +static void +maybe_add_option (NMDhcpClient *self, + GHashTable *hash, + const char *key, + GVariant *value) +{ + char *str_value = NULL; + const char **p; + static const char *ignored_keys[] = { + "interface", + "pid", + "reason", + "dhcp_message_type", + NULL + }; + + g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BYTESTRING)); + + if (g_str_has_prefix (key, OLD_TAG)) + return; + + /* Filter out stuff that's not actually new DHCP options */ + for (p = ignored_keys; *p; p++) { + if (!strcmp (*p, key)) + return; + } + + if (g_str_has_prefix (key, NEW_TAG)) + key += NM_STRLEN (NEW_TAG); + if (!key[0]) + return; + + str_value = bytearray_variant_to_string (self, value, key); + if (str_value) + g_hash_table_insert (hash, g_strdup (key), str_value); +} + +gboolean +nm_dhcp_client_handle_event (gpointer unused, + const char *iface, + gint pid, + GVariant *options, + const char *reason, + NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv; + guint32 old_state; + guint32 new_state; + GHashTable *str_options = NULL; + GObject *ip_config = NULL; + NMPlatformIP6Address prefix = { 0, }; + + 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 (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); + + if (g_strcmp0 (priv->iface, iface) != 0) + return FALSE; + if (priv->pid != pid) + return FALSE; + + old_state = priv->state; + new_state = reason_to_state (self, priv->iface, reason); + _LOGD ("DHCP reason '%s' -> state '%s'", + 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_variant_iter_init (&iter, options); + while (g_variant_iter_next (&iter, "{&sv}", &name, &value)) { + maybe_add_option (self, str_options, name, value); + g_variant_unref (value); + } + + if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) { + GHashTableIter hash_iter; + gpointer key, val; + + g_hash_table_iter_init (&hash_iter, str_options); + while (g_hash_table_iter_next (&hash_iter, &key, &val)) + _LOGD ("option '%s'=>'%s'", (const char *) key, (const char *) val); + } + + /* Create the IP config */ + g_warn_if_fail (g_hash_table_size (str_options)); + if (g_hash_table_size (str_options)) { + if (priv->ipv6) { + prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options); + ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (priv->ifindex, + priv->iface, + str_options, + priv->priority, + priv->info_only); + } else { + ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (priv->ifindex, + priv->iface, + str_options, + priv->priority); + } + } + } + + if (!IN6_IS_ADDR_UNSPECIFIED (&prefix.address)) { + /* If we got an IPv6 prefix to delegate, we don't change the state + * of the DHCP client instance. Instead, we just signal the prefix + * to the device. */ + g_signal_emit (G_OBJECT (self), + signals[SIGNAL_PREFIX_DELEGATED], 0, + &prefix); + } else { + /* Fail if no valid IP config was received */ + if (new_state == NM_DHCP_STATE_BOUND && ip_config == NULL) { + _LOGW ("client bound but IP config not received"); + new_state = NM_DHCP_STATE_FAIL; + g_clear_pointer (&str_options, g_hash_table_unref); + } + + nm_dhcp_client_set_state (self, new_state, ip_config, str_options); + } + + if (str_options) + g_hash_table_destroy (str_options); + g_clear_object (&ip_config); + + return TRUE; +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE ((NMDhcpClient *) object); + + switch (prop_id) { + case PROP_IFACE: + g_value_set_string (value, priv->iface); + break; + case PROP_IFINDEX: + g_value_set_int (value, priv->ifindex); + break; + case PROP_HWADDR: + g_value_set_boxed (value, priv->hwaddr); + break; + case PROP_IPV6: + g_value_set_boolean (value, priv->ipv6); + break; + case PROP_UUID: + g_value_set_string (value, priv->uuid); + break; + case PROP_PRIORITY: + g_value_set_uint (value, priv->priority); + break; + case PROP_TIMEOUT: + g_value_set_uint (value, priv->timeout); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE ((NMDhcpClient *) object); + + switch (prop_id) { + case PROP_IFACE: + /* construct-only */ + priv->iface = g_value_dup_string (value); + break; + case PROP_IFINDEX: + /* construct-only */ + priv->ifindex = g_value_get_int (value); + g_warn_if_fail (priv->ifindex > 0); + break; + case PROP_HWADDR: + /* construct-only */ + priv->hwaddr = g_value_dup_boxed (value); + break; + case PROP_IPV6: + /* construct-only */ + priv->ipv6 = g_value_get_boolean (value); + break; + case PROP_UUID: + /* construct-only */ + priv->uuid = g_value_dup_string (value); + break; + case PROP_PRIORITY: + /* construct-only */ + priv->priority = g_value_get_uint (value); + break; + case PROP_TIMEOUT: + priv->timeout = g_value_get_uint (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_dhcp_client_init (NMDhcpClient *self) +{ + NMDhcpClientPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_DHCP_CLIENT, NMDhcpClientPrivate); + self->_priv = priv; + + priv->pid = -1; +} + +static void +dispose (GObject *object) +{ + NMDhcpClient *self = NM_DHCP_CLIENT (object); + NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); + + /* Stopping the client is left up to the controlling device + * explicitly since we may want to quit NetworkManager but not terminate + * the DHCP client. + */ + + watch_cleanup (self); + timeout_cleanup (self); + + g_clear_pointer (&priv->iface, g_free); + g_clear_pointer (&priv->hostname, g_free); + g_clear_pointer (&priv->fqdn, g_free); + g_clear_pointer (&priv->uuid, g_free); + g_clear_pointer (&priv->client_id, g_bytes_unref); + + if (priv->hwaddr) { + g_byte_array_free (priv->hwaddr, TRUE); + priv->hwaddr = NULL; + } + + if (priv->duid) { + g_byte_array_free (priv->duid, TRUE); + priv->duid = NULL; + } + + G_OBJECT_CLASS (nm_dhcp_client_parent_class)->dispose (object); +} + +static void +nm_dhcp_client_class_init (NMDhcpClientClass *client_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (client_class); + + g_type_class_add_private (client_class, sizeof (NMDhcpClientPrivate)); + + object_class->dispose = dispose; + object_class->get_property = get_property; + object_class->set_property = set_property; + + client_class->stop = stop; + client_class->get_duid = get_duid; + + obj_properties[PROP_IFACE] = + g_param_spec_string (NM_DHCP_CLIENT_INTERFACE, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_IFINDEX] = + g_param_spec_int (NM_DHCP_CLIENT_IFINDEX, "", "", + -1, G_MAXINT, -1, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_HWADDR] = + g_param_spec_boxed (NM_DHCP_CLIENT_HWADDR, "", "", + G_TYPE_BYTE_ARRAY, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_IPV6] = + g_param_spec_boolean (NM_DHCP_CLIENT_IPV6, "", "", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_UUID] = + g_param_spec_string (NM_DHCP_CLIENT_UUID, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_PRIORITY] = + g_param_spec_uint (NM_DHCP_CLIENT_PRIORITY, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TIMEOUT] = + g_param_spec_uint (NM_DHCP_CLIENT_TIMEOUT, "", "", + 0, G_MAXUINT, 45, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + signals[SIGNAL_STATE_CHANGED] = + g_signal_new (NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDhcpClientClass, state_changed), + NULL, NULL, NULL, + G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_OBJECT, G_TYPE_HASH_TABLE, G_TYPE_STRING); + + signals[SIGNAL_PREFIX_DELEGATED] = + g_signal_new (NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDhcpClientClass, state_changed), + NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_POINTER); +} diff --git a/src/dhcp/nm-dhcp-client.h b/src/dhcp/nm-dhcp-client.h new file mode 100644 index 00000000..7a083ae7 --- /dev/null +++ b/src/dhcp/nm-dhcp-client.h @@ -0,0 +1,185 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2010 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DHCP_CLIENT_H__ +#define __NETWORKMANAGER_DHCP_CLIENT_H__ + +#include +#include +#include +#include + +#define NM_TYPE_DHCP_CLIENT (nm_dhcp_client_get_type ()) +#define NM_DHCP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClient)) +#define NM_DHCP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_CLIENT, NMDhcpClientClass)) +#define NM_IS_DHCP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_CLIENT)) +#define NM_IS_DHCP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_CLIENT)) +#define NM_DHCP_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClientClass)) + +#define NM_DHCP_CLIENT_INTERFACE "iface" +#define NM_DHCP_CLIENT_IFINDEX "ifindex" +#define NM_DHCP_CLIENT_HWADDR "hwaddr" +#define NM_DHCP_CLIENT_IPV6 "ipv6" +#define NM_DHCP_CLIENT_UUID "uuid" +#define NM_DHCP_CLIENT_PRIORITY "priority" +#define NM_DHCP_CLIENT_TIMEOUT "timeout" + +#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed" +#define NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED "prefix-delegated" + +typedef enum { + NM_DHCP_STATE_UNKNOWN = 0, + NM_DHCP_STATE_BOUND, /* new lease or lease changed */ + NM_DHCP_STATE_TIMEOUT, /* timed out contacting server */ + NM_DHCP_STATE_DONE, /* client quit or stopped */ + NM_DHCP_STATE_EXPIRE, /* lease expired or NAKed */ + NM_DHCP_STATE_FAIL, /* failed for some reason */ + __NM_DHCP_STATE_MAX, + NM_DHCP_STATE_MAX = __NM_DHCP_STATE_MAX - 1, +} NMDhcpState; + +struct _NMDhcpClientPrivate; + +typedef struct { + GObject parent; + struct _NMDhcpClientPrivate *_priv; +} NMDhcpClient; + +typedef struct { + GObjectClass parent; + + /* Methods */ + + gboolean (*ip4_start) (NMDhcpClient *self, + const char *anycast_addr, + const char *last_ip4_address); + + gboolean (*ip6_start) (NMDhcpClient *self, + const char *anycast_addr, + const struct in6_addr *ll_addr, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + const GByteArray *duid, + guint needed_prefixes); + + void (*stop) (NMDhcpClient *self, + gboolean release, + const GByteArray *duid); + + /** + * get_duid: + * @self: the #NMDhcpClient + * + * Attempts to find an existing DHCPv6 DUID for this client in the DHCP + * client's persistent configuration. Returned DUID should be the binary + * representation of the DUID. If no DUID is found, %NULL should be + * returned. + */ + GByteArray * (*get_duid) (NMDhcpClient *self); + + /* Signals */ + void (*state_changed) (NMDhcpClient *self, + NMDhcpState state, + GObject *ip_config, + GHashTable *options); +} NMDhcpClientClass; + +GType nm_dhcp_client_get_type (void); + +pid_t nm_dhcp_client_get_pid (NMDhcpClient *self); + +const char *nm_dhcp_client_get_iface (NMDhcpClient *self); + +int nm_dhcp_client_get_ifindex (NMDhcpClient *self); + +gboolean nm_dhcp_client_get_ipv6 (NMDhcpClient *self); + +const char *nm_dhcp_client_get_uuid (NMDhcpClient *self); + +const GByteArray *nm_dhcp_client_get_duid (NMDhcpClient *self); + +const GByteArray *nm_dhcp_client_get_hw_addr (NMDhcpClient *self); + +guint32 nm_dhcp_client_get_priority (NMDhcpClient *self); + +GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self); + +const char *nm_dhcp_client_get_hostname (NMDhcpClient *self); + +const char *nm_dhcp_client_get_fqdn (NMDhcpClient *self); + +gboolean nm_dhcp_client_start_ip4 (NMDhcpClient *self, + const char *dhcp_client_id, + const char *dhcp_anycast_addr, + const char *hostname, + const char *fqdn, + const char *last_ip4_address); + +gboolean nm_dhcp_client_start_ip6 (NMDhcpClient *self, + const char *dhcp_anycast_addr, + const struct in6_addr *ll_addr, + const char *hostname, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + guint needed_prefixes); + +void nm_dhcp_client_stop (NMDhcpClient *self, gboolean release); + +/* Backend helpers for subclasses */ +void nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name); + +void nm_dhcp_client_stop_pid (pid_t pid, const char *iface); + +void nm_dhcp_client_start_timeout (NMDhcpClient *self); + +void nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid); + +void nm_dhcp_client_set_state (NMDhcpClient *self, + NMDhcpState new_state, + GObject *ip_config, /* NMIP4Config or NMIP6Config */ + GHashTable *options); /* str:str hash */ + +gboolean nm_dhcp_client_handle_event (gpointer unused, + const char *iface, + gint pid, + GVariant *options, + const char *reason, + NMDhcpClient *self); + +void nm_dhcp_client_set_client_id (NMDhcpClient *self, GBytes *client_id); + +/***************************************************************************** + * Client data + *****************************************************************************/ + +typedef struct { + GType (*get_type)(void); + const char *name; + const char *(*get_path) (void); + GSList *(*get_lease_ip_configs) (const char *iface, + int ifindex, + const char *uuid, + gboolean ipv6, + guint32 default_route_metric); +} NMDhcpClientFactory; + +extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient; +extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcd; +extern const NMDhcpClientFactory _nm_dhcp_client_factory_internal; + +#endif /* __NETWORKMANAGER_DHCP_CLIENT_H__ */ diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c new file mode 100644 index 00000000..8cc25ab5 --- /dev/null +++ b/src/dhcp/nm-dhcp-dhclient-utils.c @@ -0,0 +1,775 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-dhcp-dhclient-utils.h" + +#include +#include +#include + +#include "nm-dhcp-utils.h" +#include "nm-ip4-config.h" +#include "nm-utils.h" +#include "platform/nm-platform.h" +#include "NetworkManagerUtils.h" + +#define CLIENTID_TAG "send dhcp-client-identifier" + +#define HOSTNAME4_TAG "send host-name" +#define HOSTNAME4_FORMAT HOSTNAME4_TAG " \"%s\"; # added by NetworkManager" + +#define FQDN_TAG_PREFIX "send fqdn." +#define FQDN_TAG FQDN_TAG_PREFIX "fqdn" +#define FQDN_FORMAT FQDN_TAG " \"%s\"; # added by NetworkManager" + +#define ALSOREQ_TAG "also request " +#define REQ_TAG "request " + +static void +add_request (GPtrArray *array, const char *item) +{ + int i; + + for (i = 0; i < array->len; i++) { + if (!strcmp (g_ptr_array_index (array, i), item)) + return; + } + g_ptr_array_add (array, g_strdup (item)); +} + +static gboolean +grab_request_options (GPtrArray *store, const char* line) +{ + char **areq, **aiter; + gboolean end = FALSE; + + /* Grab each 'request' or 'also request' option and save for later */ + areq = g_strsplit_set (line, "\t ,", -1); + for (aiter = areq; aiter && *aiter; aiter++) { + if (!strlen (g_strstrip (*aiter))) + continue; + + if (*aiter[0] == ';') { + /* all done */ + end = TRUE; + break; + } + + if (!g_ascii_isalnum ((*aiter)[0])) + continue; + + if ((*aiter)[strlen (*aiter) - 1] == ';') { + /* Remove the EOL marker */ + (*aiter)[strlen (*aiter) - 1] = '\0'; + end = TRUE; + } + + add_request (store, *aiter); + } + + if (areq) + g_strfreev (areq); + + return end; +} + + +static void +add_hostname4 (GString *str, const char *hostname, const char *fqdn) +{ + char *plain_hostname, *dot; + + if (fqdn) { + g_string_append_printf (str, FQDN_FORMAT "\n", fqdn); + g_string_append (str, + "send fqdn.encoded on;\n" + "send fqdn.server-update on;\n"); + } else if (hostname) { + plain_hostname = g_strdup (hostname); + dot = strchr (plain_hostname, '.'); + /* get rid of the domain */ + if (dot) + *dot = '\0'; + + g_string_append_printf (str, HOSTNAME4_FORMAT "\n", plain_hostname); + g_free (plain_hostname); + } +} + +static void +add_ip4_config (GString *str, GBytes *client_id, const char *hostname, const char *fqdn) +{ + if (client_id) { + const char *p; + gsize l; + guint i; + + p = g_bytes_get_data (client_id, &l); + g_assert (p); + + /* Allow type 0 (non-hardware address) to be represented as a string + * as long as all the characters are printable. + */ + for (i = 1; (p[0] == 0) && i < l; i++) { + if (!g_ascii_isprint (p[i])) + break; + } + + g_string_append (str, CLIENTID_TAG " "); + if (i < l) { + /* Unprintable; convert to a hex string */ + for (i = 0; i < l; i++) { + if (i > 0) + g_string_append_c (str, ':'); + g_string_append_printf (str, "%02x", (guint8) p[i]); + } + } else { + /* Printable; just add to the line minus the 'type' */ + g_string_append_c (str, '"'); + g_string_append_len (str, p + 1, l - 1); + g_string_append_c (str, '"'); + } + g_string_append (str, "; # added by NetworkManager\n"); + } + + add_hostname4 (str, hostname, fqdn); + + g_string_append_c (str, '\n'); + + /* Define options for classless static routes */ + g_string_append (str, + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"); + g_string_append (str, + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"); + /* Web Proxy Auto-Discovery option (bgo #368423) */ + g_string_append (str, "option wpad code 252 = string;\n"); + + g_string_append_c (str, '\n'); +} + +static void +add_hostname6 (GString *str, const char *hostname) +{ + /* dhclient only supports the fqdn.fqdn for DHCPv6 and requires a fully- + * qualified name for this option, so we must require one here too. + */ + if (hostname && strchr (hostname, '.')) { + g_string_append_printf (str, FQDN_FORMAT "\n", hostname); + g_string_append (str, + "send fqdn.encoded on;\n" + "send fqdn.server-update on;\n"); + g_string_append_c (str, '\n'); + } +} + +static GBytes * +read_client_id (const char *str) +{ + gs_free char *s = NULL; + char *p; + + g_assert (!strncmp (str, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG))); + + str += NM_STRLEN (CLIENTID_TAG); + while (g_ascii_isspace (*str)) + str++; + + if (*str == '"') { + s = g_strdup (str + 1); + p = strrchr (s, '"'); + if (p) + *p = '\0'; + else + return NULL; + } else + s = g_strdup (str); + + g_strchomp (s); + if (s[strlen (s) - 1] == ';') + s[strlen (s) - 1] = '\0'; + + return nm_dhcp_utils_client_id_string_to_bytes (s); +} + +GBytes * +nm_dhcp_dhclient_get_client_id_from_config_file (const char *path) +{ + gs_free char *contents = NULL; + gs_strfreev char **lines = NULL; + char **line; + + g_return_val_if_fail (path != NULL, NULL); + + if (!g_file_test (path, G_FILE_TEST_EXISTS)) + return NULL; + + if (!g_file_get_contents (path, &contents, NULL, NULL)) + return NULL; + + lines = g_strsplit_set (contents, "\n\r", 0); + for (line = lines; lines && *line; line++) { + if (!strncmp (*line, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG))) + return read_client_id (*line); + } + return NULL; +} + +char * +nm_dhcp_dhclient_create_config (const char *interface, + gboolean is_ip6, + GBytes *client_id, + const char *anycast_addr, + const char *hostname, + const char *fqdn, + const char *orig_path, + const char *orig_contents, + GBytes **out_new_client_id) +{ + GString *new_contents; + GPtrArray *fqdn_opts, *reqs; + int i; + + g_return_val_if_fail (!anycast_addr || nm_utils_hwaddr_valid (anycast_addr, ETH_ALEN), NULL); + + new_contents = g_string_new (_("# Created by NetworkManager\n")); + fqdn_opts = g_ptr_array_sized_new (5); + reqs = g_ptr_array_new_full (5, g_free); + + if (orig_contents) { + char **lines, **line; + gboolean in_alsoreq = FALSE; + gboolean in_req = FALSE; + + g_string_append_printf (new_contents, _("# Merged from %s\n\n"), orig_path); + + lines = g_strsplit_set (orig_contents, "\n\r", 0); + for (line = lines; lines && *line; line++) { + char *p = *line; + + if (!strlen (g_strstrip (p))) + continue; + + if (!strncmp (p, CLIENTID_TAG, strlen (CLIENTID_TAG))) { + /* Override config file "dhcp-client-id" and use one from the connection */ + if (client_id) + continue; + + /* Otherwise capture and return the existing client id */ + if (out_new_client_id) + *out_new_client_id = read_client_id (p); + } + + /* Override config file hostname and use one from the connection */ + if (hostname || fqdn) { + if (strncmp (p, HOSTNAME4_TAG, strlen (HOSTNAME4_TAG)) == 0) + continue; + if (strncmp (p, FQDN_TAG, strlen (FQDN_TAG)) == 0) + continue; + } + + /* To let user's FQDN options (except "fqdn.fqdn") override the + * default ones set by NM, add them later + */ + if (!strncmp (p, FQDN_TAG_PREFIX, NM_STRLEN (FQDN_TAG_PREFIX))) { + g_ptr_array_add (fqdn_opts, g_strdup (p + NM_STRLEN (FQDN_TAG_PREFIX))); + continue; + } + + /* Ignore 'script' since we pass our own */ + if (g_str_has_prefix (p, "script ")) + continue; + + /* Check for "request" */ + if (!strncmp (p, REQ_TAG, strlen (REQ_TAG))) { + in_req = TRUE; + p += strlen (REQ_TAG); + g_ptr_array_set_size (reqs, 0); + } + + /* Save all request options for later use */ + if (in_req) { + in_req = !grab_request_options (reqs, p); + continue; + } + + /* Check for "also require" */ + if (!strncmp (p, ALSOREQ_TAG, strlen (ALSOREQ_TAG))) { + in_alsoreq = TRUE; + p += strlen (ALSOREQ_TAG); + } + + if (in_alsoreq) { + in_alsoreq = !grab_request_options (reqs, p); + continue; + } + + /* Existing configuration line is OK, add it to new configuration */ + g_string_append (new_contents, *line); + g_string_append_c (new_contents, '\n'); + } + + if (lines) + g_strfreev (lines); + } else + g_string_append_c (new_contents, '\n'); + + if (is_ip6) { + add_hostname6 (new_contents, hostname); + add_request (reqs, "dhcp6.name-servers"); + add_request (reqs, "dhcp6.domain-search"); + add_request (reqs, "dhcp6.client-id"); + } else { + add_ip4_config (new_contents, client_id, hostname, fqdn); + add_request (reqs, "rfc3442-classless-static-routes"); + add_request (reqs, "ms-classless-static-routes"); + add_request (reqs, "static-routes"); + add_request (reqs, "wpad"); + add_request (reqs, "ntp-servers"); + } + + /* And add it to the dhclient configuration */ + for (i = 0; i < reqs->len; i++) + g_string_append_printf (new_contents, "also request %s;\n", (char *) reqs->pdata[i]); + g_ptr_array_free (reqs, TRUE); + + for (i = 0; i < fqdn_opts->len; i++) { + char *t = g_ptr_array_index (fqdn_opts, i); + + if (i == 0) + g_string_append_printf (new_contents, "\n# FQDN options from %s\n", orig_path); + g_string_append_printf (new_contents, FQDN_TAG_PREFIX "%s\n", t); + g_free (t); + } + g_ptr_array_free (fqdn_opts, TRUE); + + g_string_append_c (new_contents, '\n'); + + if (anycast_addr) { + g_string_append_printf (new_contents, "interface \"%s\" {\n" + " initial-interval 1; \n" + " anycast-mac ethernet %s;\n" + "}\n", + interface, anycast_addr); + } + + return g_string_free (new_contents, FALSE); +} + +/* Roughly follow what dhclient's quotify_buf() and pretty_escape() functions do */ +char * +nm_dhcp_dhclient_escape_duid (const GByteArray *duid) +{ + char *escaped; + const guint8 *s = duid->data; + char *d; + + d = escaped = g_malloc0 ((duid->len * 4) + 1); + while (s < (duid->data + duid->len)) { + if (!g_ascii_isprint (*s)) { + *d++ = '\\'; + *d++ = '0' + ((*s >> 6) & 0x7); + *d++ = '0' + ((*s >> 3) & 0x7); + *d++ = '0' + (*s++ & 0x7); + } else if (*s == '"' || *s == '\'' || *s == '$' || + *s == '`' || *s == '\\' || *s == '|' || + *s == '&') { + *d++ = '\\'; + *d++ = *s++; + } else + *d++ = *s++; + } + return escaped; +} + +static inline gboolean +isoctal (const guint8 *p) +{ + return ( p[0] >= '0' && p[0] <= '3' + && p[1] >= '0' && p[1] <= '7' + && p[2] >= '0' && p[2] <= '7'); +} + +GByteArray * +nm_dhcp_dhclient_unescape_duid (const char *duid) +{ + GByteArray *unescaped; + const guint8 *p = (const guint8 *) duid; + guint i, len; + guint8 octal; + + len = strlen (duid); + unescaped = g_byte_array_sized_new (len); + for (i = 0; i < len; i++) { + if (p[i] == '\\') { + i++; + if (isdigit (p[i])) { + /* Octal escape sequence */ + if (i + 2 >= len || !isoctal (p + i)) + goto error; + octal = ((p[i] - '0') << 6) + ((p[i + 1] - '0') << 3) + (p[i + 2] - '0'); + g_byte_array_append (unescaped, &octal, 1); + i += 2; + } else { + /* One of ", ', $, `, \, |, or & */ + g_warn_if_fail (p[i] == '"' || p[i] == '\'' || p[i] == '$' || + p[i] == '`' || p[i] == '\\' || p[i] == '|' || + p[i] == '&'); + g_byte_array_append (unescaped, &p[i], 1); + } + } else + g_byte_array_append (unescaped, &p[i], 1); + } + + return unescaped; + +error: + g_byte_array_free (unescaped, TRUE); + return NULL; +} + +#define DUID_PREFIX "default-duid \"" + +GByteArray * +nm_dhcp_dhclient_read_duid (const char *leasefile, GError **error) +{ + GByteArray *duid = NULL; + char *contents; + char **line, **split, *p, *e; + + if (!g_file_test (leasefile, G_FILE_TEST_EXISTS)) + return NULL; + + if (!g_file_get_contents (leasefile, &contents, NULL, error)) + return NULL; + + split = g_strsplit_set (contents, "\n\r", -1); + for (line = split; line && *line && (duid == NULL); line++) { + p = g_strstrip (*line); + if (g_str_has_prefix (p, DUID_PREFIX)) { + p += strlen (DUID_PREFIX); + + /* look for trailing "; */ + e = p + strlen (p) - 2; + if (strcmp (e, "\";") != 0) + continue; + *e = '\0'; + + duid = nm_dhcp_dhclient_unescape_duid (p); + } + } + g_free (contents); + g_strfreev (split); + + return duid; +} + +gboolean +nm_dhcp_dhclient_save_duid (const char *leasefile, + const char *escaped_duid, + GError **error) +{ + char **lines = NULL, **iter, *l; + GString *s; + gboolean success; + gsize len = 0; + + g_return_val_if_fail (leasefile != NULL, FALSE); + g_return_val_if_fail (escaped_duid != NULL, FALSE); + + if (g_file_test (leasefile, G_FILE_TEST_EXISTS)) { + char *contents = NULL; + + if (!g_file_get_contents (leasefile, &contents, &len, error)) { + g_prefix_error (error, "failed to read lease file %s: ", leasefile); + return FALSE; + } + + /* If the file already contains an uncommented DUID, leave it */ + g_assert (contents); + lines = g_strsplit_set (contents, "\n\r", -1); + g_free (contents); + for (iter = lines; iter && *iter; iter++) { + l = *iter; + while (g_ascii_isspace (*l)) + l++; + if (g_str_has_prefix (l, DUID_PREFIX)) { + g_strfreev (lines); + return TRUE; + } + } + } + + s = g_string_sized_new (len + 50); + g_string_append_printf (s, DUID_PREFIX "%s\";\n", escaped_duid); + + /* Preserve existing leasefile contents */ + if (lines) { + for (iter = lines; iter && *iter; iter++) + g_string_append (s, *iter[0] ? *iter : "\n"); + g_strfreev (lines); + } + + success = g_file_set_contents (leasefile, s->str, -1, error); + if (!success) + g_prefix_error (error, "failed to set DUID in lease file %s: ", leasefile); + + g_string_free (s, TRUE); + return success; +} + +static void +add_lease_option (GHashTable *hash, char *line) +{ + char *spc; + size_t len; + + /* Find the space after "option" */ + spc = strchr (line, ' '); + if (!spc) + return; + + /* Find the option tag's data, which is after the second space */ + if (g_str_has_prefix (line, "option ")) { + while (g_ascii_isspace (*spc)) + spc++; + spc = strchr (spc + 1, ' '); + if (!spc) + return; + } + + /* Split the line at the space */ + *spc = '\0'; + spc++; + + /* Kill the ';' at the end of the line, if any */ + len = strlen (spc); + if (*(spc + len - 1) == ';') + *(spc + len - 1) = '\0'; + + /* Strip leading quote */ + while (g_ascii_isspace (*spc)) + spc++; + if (*spc == '"') + spc++; + + /* Strip trailing quote */ + len = strlen (spc); + if (len > 0 && spc[len - 1] == '"') + spc[len - 1] = '\0'; + + if (spc[0]) + g_hash_table_insert (hash, g_strdup (line), g_strdup (spc)); +} + +#define LEASE_INVALID G_MININT64 +static GTimeSpan +lease_validity_span (const char *str_expire, GDateTime *now) +{ + GDateTime *expire = NULL; + struct tm expire_tm; + GTimeSpan span; + + g_return_val_if_fail (now != NULL, LEASE_INVALID); + g_return_val_if_fail (str_expire != NULL, LEASE_INVALID); + + /* Skip initial number (day of week?) */ + if (!isdigit (*str_expire++)) + return LEASE_INVALID; + if (!isspace (*str_expire++)) + return LEASE_INVALID; + /* Read lease expiration (in UTC) */ + if (!strptime (str_expire, "%t%Y/%m/%d %H:%M:%S", &expire_tm)) + return LEASE_INVALID; + + expire = g_date_time_new_utc (expire_tm.tm_year + 1900, + expire_tm.tm_mon + 1, + expire_tm.tm_mday, + expire_tm.tm_hour, + expire_tm.tm_min, + expire_tm.tm_sec); + if (!expire) + return LEASE_INVALID; + + span = g_date_time_difference (expire, now); + g_date_time_unref (expire); + + /* GDateTime only supports a range of less then 10000 years, so span can + * not overflow or be equal to LEASE_INVALID */ + return span; +} + +/** + * nm_dhcp_dhclient_read_lease_ip_configs: + * @iface: the interface name to match leases with + * @ifindex: interface index of @iface + * @contents: the contents of a dhclient leasefile + * @ipv6: whether to read IPv4 or IPv6 leases + * @now: the current UTC date/time; pass %NULL to automatically use current + * UTC time. Testcases may need a different value for 'now' + * + * Reads dhclient leases from @contents and parses them into either + * #NMIP4Config or #NMIP6Config objects depending on the value of @ipv6. + * + * Returns: a #GSList of #NMIP4Config objects (if @ipv6 is %FALSE) or a list of + * #NMIP6Config objects (if @ipv6 is %TRUE) containing the lease data. + */ +GSList * +nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, + int ifindex, + const char *contents, + gboolean ipv6, + GDateTime *now) +{ + GSList *parsed = NULL, *iter, *leases = NULL; + char **line, **split = NULL; + GHashTable *hash = NULL; + gint32 now_monotonic_ts; + + g_return_val_if_fail (contents != NULL, NULL); + + split = g_strsplit_set (contents, "\n\r", -1); + if (!split) + return NULL; + + for (line = split; line && *line; line++) { + *line = g_strstrip (*line); + + if (*line[0] == '#') { + /* Comment */ + } else if (!strcmp (*line, "}")) { + /* Lease ends */ + parsed = g_slist_append (parsed, hash); + hash = NULL; + } else if (!strcmp (*line, "lease {")) { + /* Beginning of a new lease */ + if (hash) { + /* Ignore malformed lease that doesn't end before new one starts */ + g_hash_table_destroy (hash); + } + + hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + } else if (hash && strlen (*line)) + add_lease_option (hash, *line); + } + g_strfreev (split); + + /* Check if the last lease in the file was properly ended */ + if (hash) { + /* Ignore malformed lease that doesn't end before new one starts */ + g_hash_table_destroy (hash); + hash = NULL; + } + + if (now) + g_date_time_ref (now); + else + now = g_date_time_new_now_utc (); + now_monotonic_ts = nm_utils_get_monotonic_timestamp_s (); + + for (iter = parsed; iter; iter = g_slist_next (iter)) { + NMIP4Config *ip4; + NMPlatformIP4Address address; + const char *value; + GTimeSpan expiry; + guint32 tmp, gw = 0; + + hash = iter->data; + + /* Make sure this lease is for the interface we want */ + value = g_hash_table_lookup (hash, "interface"); + if (!value || strcmp (value, iface)) + continue; + + value = g_hash_table_lookup (hash, "expire"); + if (!value) + continue; + expiry = lease_validity_span (value, now); + if (expiry == LEASE_INVALID) + continue; + + /* scale expiry to seconds (and CLAMP into the range of guint32) */ + expiry = CLAMP (expiry / G_TIME_SPAN_SECOND, 0, NM_PLATFORM_LIFETIME_PERMANENT-1); + if (expiry <= 0) { + /* the address is already expired. Don't even add it. */ + continue; + } + + memset (&address, 0, sizeof (address)); + + /* IP4 address */ + value = g_hash_table_lookup (hash, "fixed-address"); + if (!value) + continue; + if (!inet_pton (AF_INET, value, &address.address)) + continue; + address.peer_address = address.address; + + /* Gateway */ + value = g_hash_table_lookup (hash, "option routers"); + if (!value) + continue; + if (!inet_pton (AF_INET, value, &gw)) + continue; + + /* Netmask */ + value = g_hash_table_lookup (hash, "option subnet-mask"); + if (value && inet_pton (AF_INET, value, &tmp)) + address.plen = nm_utils_ip4_netmask_to_prefix (tmp); + + /* Get default netmask for the IP according to appropriate class. */ + if (!address.plen) + address.plen = nm_utils_ip4_get_default_prefix (address.address); + + address.timestamp = now_monotonic_ts; + address.lifetime = address.preferred = expiry; + address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; + + ip4 = nm_ip4_config_new (ifindex); + nm_ip4_config_add_address (ip4, &address); + nm_ip4_config_set_gateway (ip4, gw); + + value = g_hash_table_lookup (hash, "option domain-name-servers"); + if (value) { + char **dns, **dns_iter; + + dns = g_strsplit_set (value, ",", -1); + for (dns_iter = dns; dns_iter && *dns_iter; dns_iter++) { + if (inet_pton (AF_INET, *dns_iter, &tmp)) + nm_ip4_config_add_nameserver (ip4, tmp); + } + if (dns) + g_strfreev (dns); + } + + value = g_hash_table_lookup (hash, "option domain-name"); + if (value && value[0]) + nm_ip4_config_add_domain (ip4, value); + + /* FIXME: static routes */ + + leases = g_slist_append (leases, ip4); + } + + g_date_time_unref (now); + g_slist_free_full (parsed, (GDestroyNotify) g_hash_table_destroy); + return leases; +} + diff --git a/src/dhcp/nm-dhcp-dhclient-utils.h b/src/dhcp/nm-dhcp-dhclient-utils.h new file mode 100644 index 00000000..83d5a23d --- /dev/null +++ b/src/dhcp/nm-dhcp-dhclient-utils.h @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2010 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DHCP_DHCLIENT_UTILS_H__ +#define __NETWORKMANAGER_DHCP_DHCLIENT_UTILS_H__ + +#include +#include + +char *nm_dhcp_dhclient_create_config (const char *interface, + gboolean is_ip6, + GBytes *client_id, + const char *anycast_addr, + const char *hostname, + const char *fqdn, + const char *orig_path, + const char *orig_contents, + GBytes **out_new_client_id); + +char *nm_dhcp_dhclient_escape_duid (const GByteArray *duid); + +GByteArray *nm_dhcp_dhclient_unescape_duid (const char *duid); + +GByteArray *nm_dhcp_dhclient_read_duid (const char *leasefile, GError **error); + +gboolean nm_dhcp_dhclient_save_duid (const char *leasefile, + const char *escaped_duid, + GError **error); + +GSList *nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, + int ifindex, + const char *contents, + gboolean ipv6, + GDateTime *now); + +GBytes *nm_dhcp_dhclient_get_client_id_from_config_file (const char *path); + +#endif /* __NETWORKMANAGER_DHCP_DHCLIENT_UTILS_H__ */ + diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c new file mode 100644 index 00000000..64d93744 --- /dev/null +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -0,0 +1,706 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-dhcp-dhclient.c - dhclient specific hooks for NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2012 Red Hat, Inc. + */ + +#include +#define __CONFIG_H__ + +#define _XOPEN_SOURCE +#include +#undef _XOPEN_SOURCE + +#include "nm-default.h" + +#if WITH_DHCLIENT + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-utils.h" +#include "nm-dhcp-dhclient-utils.h" +#include "nm-dhcp-manager.h" +#include "NetworkManagerUtils.h" +#include "nm-dhcp-listener.h" +#include "nm-dhcp-client-logging.h" + +/*****************************************************************************/ + +#define NM_TYPE_DHCP_DHCLIENT (nm_dhcp_dhclient_get_type ()) +#define NM_DHCP_DHCLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclient)) +#define NM_DHCP_DHCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) +#define NM_IS_DHCP_DHCLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_DHCLIENT)) +#define NM_IS_DHCP_DHCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_DHCLIENT)) +#define NM_DHCP_DHCLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) + +typedef struct _NMDhcpDhclient NMDhcpDhclient; +typedef struct _NMDhcpDhclientClass NMDhcpDhclientClass; + +static GType nm_dhcp_dhclient_get_type (void); + +/*****************************************************************************/ + +typedef struct { + char *conf_file; + const char *def_leasefile; + char *lease_file; + char *pid_file; + NMDhcpListener *dhcp_listener; +} NMDhcpDhclientPrivate; + +struct _NMDhcpDhclient { + NMDhcpClient parent; + NMDhcpDhclientPrivate _priv; +}; + +struct _NMDhcpDhclientClass { + NMDhcpClientClass parent; +}; + +G_DEFINE_TYPE (NMDhcpDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT) + +#define NM_DHCP_DHCLIENT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcpDhclient, NM_IS_DHCP_DHCLIENT) + +/*****************************************************************************/ + +static const char * +nm_dhcp_dhclient_get_path (void) +{ + return nm_utils_find_helper ("dhclient", DHCLIENT_PATH, NULL); +} + +/** + * get_dhclient_leasefile(): + * @iface: the interface name of the device on which DHCP will be done + * @uuid: the connection UUID to which the returned lease should belong + * @ipv6: %TRUE for IPv6, %FALSE for IPv4 + * @out_preferred_path: on return, the "most preferred" leasefile path + * + * Returns the path of an existing leasefile (if any) for this interface and + * connection UUID. Also returns the "most preferred" leasefile path, which + * may be different than any found leasefile. + * + * Returns: an existing leasefile, or %NULL if no matching leasefile could be found + */ +static char * +get_dhclient_leasefile (const char *iface, + const char *uuid, + gboolean ipv6, + char **out_preferred_path) +{ + char *path; + + /* /var/lib/NetworkManager is the preferred leasefile path */ + path = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s-%s.lease", + ipv6 ? "6" : "", + uuid, + iface); + if (out_preferred_path) + *out_preferred_path = g_strdup (path); + + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + + /* If the leasefile we're looking for doesn't exist yet in the new location + * (eg, /var/lib/NetworkManager) then look in old locations to maintain + * backwards compatibility with external tools (like dracut) that put + * leasefiles there. + */ + + /* Old Debian, SUSE, and Mandriva location */ + g_free (path); + path = g_strdup_printf (LOCALSTATEDIR "/lib/dhcp/dhclient%s-%s-%s.lease", + ipv6 ? "6" : "", uuid, iface); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + + /* Old Red Hat and Fedora location */ + g_free (path); + path = g_strdup_printf (LOCALSTATEDIR "/lib/dhclient/dhclient%s-%s-%s.lease", + ipv6 ? "6" : "", uuid, iface); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + + /* Fail */ + g_free (path); + return NULL; +} + +static GSList * +nm_dhcp_dhclient_get_lease_ip_configs (const char *iface, + int ifindex, + const char *uuid, + gboolean ipv6, + guint32 default_route_metric) +{ + char *contents = NULL; + char *leasefile; + GSList *leases = NULL; + + leasefile = get_dhclient_leasefile (iface, uuid, FALSE, NULL); + if (!leasefile) + return NULL; + + if ( g_file_test (leasefile, G_FILE_TEST_EXISTS) + && g_file_get_contents (leasefile, &contents, NULL, NULL) + && contents + && contents[0]) + leases = nm_dhcp_dhclient_read_lease_ip_configs (iface, ifindex, contents, ipv6, NULL); + + g_free (leasefile); + g_free (contents); + + return leases; +} + +static gboolean +merge_dhclient_config (NMDhcpDhclient *self, + const char *iface, + const char *conf_file, + gboolean is_ip6, + GBytes *client_id, + const char *anycast_addr, + const char *hostname, + const char *fqdn, + const char *orig_path, + GBytes **out_new_client_id, + GError **error) +{ + char *orig = NULL, *new; + gboolean success = FALSE; + + g_return_val_if_fail (iface != NULL, FALSE); + g_return_val_if_fail (conf_file != NULL, FALSE); + + if (orig_path && g_file_test (orig_path, G_FILE_TEST_EXISTS)) { + GError *read_error = NULL; + + if (!g_file_get_contents (orig_path, &orig, NULL, &read_error)) { + _LOGW ("error reading dhclient configuration %s: %s", + orig_path, read_error->message); + g_error_free (read_error); + } + } + + if (is_ip6 && hostname && !strchr (hostname, '.')) + _LOGW ("hostname is not a FQDN, it will be ignored"); + + new = nm_dhcp_dhclient_create_config (iface, is_ip6, client_id, anycast_addr, hostname, fqdn, orig_path, orig, out_new_client_id); + g_assert (new); + success = g_file_set_contents (conf_file, new, -1, error); + g_free (new); + g_free (orig); + + return success; +} + +static char * +find_existing_config (NMDhcpDhclient *self, const char *iface, const char *uuid, gboolean ipv6) +{ + char *path; + + /* NetworkManager-overridden configuration can be used to ship DHCP config + * with NetworkManager itself. It can be uuid-specific, device-specific + * or generic. + */ + if (uuid) { + path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", uuid); + _LOGD ("looking for existing config %s", path); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + g_free (path); + } + + path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface); + _LOGD ("looking for existing config %s", path); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + g_free (path); + + path = g_strdup_printf (NMCONFDIR "/dhclient%s.conf", ipv6 ? "6" : ""); + _LOGD ("looking for existing config %s", path); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + g_free (path); + + /* Distribution's dhclient configuration is used so that we can use + * configuration shipped with dhclient (if any). + * + * This replaces conditional compilation based on distribution name. Fedora + * and Debian store the configs in /etc/dhcp while upstream defaults to /etc + * which is then used by many other distributions. Some distributions + * (including Fedora) don't even provide a default configuration file. + */ + path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s-%s.conf", ipv6 ? "6" : "", iface); + _LOGD ("looking for existing config %s", path); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + g_free (path); + + path = g_strdup_printf (SYSCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface); + _LOGD ("looking for existing config %s", path); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + g_free (path); + + path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s.conf", ipv6 ? "6" : ""); + _LOGD ("looking for existing config %s", path); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + g_free (path); + + path = g_strdup_printf (SYSCONFDIR "/dhclient%s.conf", ipv6 ? "6" : ""); + _LOGD ("looking for existing config %s", path); + if (g_file_test (path, G_FILE_TEST_EXISTS)) + return path; + g_free (path); + + return NULL; +} + + +/* NM provides interface-specific options; thus the same dhclient config + * file cannot be used since DHCP transactions can happen in parallel. + * Since some distros don't have default per-interface dhclient config files, + * read their single config file and merge that into a custom per-interface + * config file along with the NM options. + */ +static char * +create_dhclient_config (NMDhcpDhclient *self, + const char *iface, + gboolean is_ip6, + const char *uuid, + GBytes *client_id, + const char *dhcp_anycast_addr, + const char *hostname, + const char *fqdn, + GBytes **out_new_client_id) +{ + char *orig = NULL, *new = NULL; + GError *error = NULL; + gboolean success = FALSE; + + g_return_val_if_fail (iface != NULL, NULL); + + new = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s.conf", is_ip6 ? "6" : "", iface); + _LOGD ("creating composite dhclient config %s", new); + + orig = find_existing_config (self, iface, uuid, is_ip6); + if (orig) + _LOGD ("merging existing dhclient config %s", orig); + else + _LOGD ("no existing dhclient configuration to merge"); + + error = NULL; + success = merge_dhclient_config (self, iface, new, is_ip6, client_id, dhcp_anycast_addr, + hostname, fqdn, orig, out_new_client_id, &error); + if (!success) { + _LOGW ("error creating dhclient configuration: %s", error->message); + g_error_free (error); + } + + g_free (orig); + return new; +} + + +static gboolean +dhclient_start (NMDhcpClient *client, + const char *mode_opt, + const GByteArray *duid, + gboolean release, + pid_t *out_pid, + int prefixes) +{ + NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + GPtrArray *argv = NULL; + pid_t pid; + GError *error = NULL; + const char *iface, *uuid, *system_bus_address, *dhclient_path = NULL; + char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL; + gboolean ipv6, success; + char *escaped, *preferred_leasefile_path = NULL; + + g_return_val_if_fail (priv->pid_file == NULL, FALSE); + + iface = nm_dhcp_client_get_iface (client); + uuid = nm_dhcp_client_get_uuid (client); + ipv6 = nm_dhcp_client_get_ipv6 (client); + + dhclient_path = nm_dhcp_dhclient_get_path (); + if (!dhclient_path) { + _LOGW ("dhclient could not be found"); + return FALSE; + } + + pid_file = g_strdup_printf (RUNSTATEDIR "/dhclient%s-%s.pid", + ipv6 ? "6" : "", + iface); + + /* Kill any existing dhclient from the pidfile */ + binary_name = g_path_get_basename (dhclient_path); + nm_dhcp_client_stop_existing (pid_file, binary_name); + g_free (binary_name); + + if (release) { + /* release doesn't use the pidfile after killing an old client */ + g_free (pid_file); + pid_file = NULL; + } + + g_free (priv->lease_file); + priv->lease_file = get_dhclient_leasefile (iface, uuid, ipv6, &preferred_leasefile_path); + if (!priv->lease_file) { + /* No existing leasefile, dhclient will create one at the preferred path */ + priv->lease_file = g_strdup (preferred_leasefile_path); + } else if (g_strcmp0 (priv->lease_file, preferred_leasefile_path) != 0) { + GFile *src = g_file_new_for_path (priv->lease_file); + GFile *dst = g_file_new_for_path (preferred_leasefile_path); + + /* Try to copy the existing leasefile to the preferred location */ + if (g_file_copy (src, dst, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error)) { + /* Success; use the preferred leasefile path */ + g_free (priv->lease_file); + priv->lease_file = g_strdup (g_file_get_path (dst)); + } else { + /* Failure; just use the existing leasefile */ + _LOGW ("failed to copy leasefile %s to %s: %s", + g_file_get_path (src), g_file_get_path (dst), + error->message); + g_clear_error (&error); + } + g_object_unref (src); + g_object_unref (dst); + } + g_free (preferred_leasefile_path); + + /* Save the DUID to the leasefile dhclient will actually use */ + if (ipv6) { + escaped = nm_dhcp_dhclient_escape_duid (duid); + success = nm_dhcp_dhclient_save_duid (priv->lease_file, escaped, &error); + g_free (escaped); + if (!success) { + _LOGW ("failed to save DUID to %s: %s", priv->lease_file, error->message); + g_free (pid_file); + return FALSE; + } + } + + argv = g_ptr_array_new (); + g_ptr_array_add (argv, (gpointer) dhclient_path); + + g_ptr_array_add (argv, (gpointer) "-d"); + + /* Be quiet. dhclient logs to syslog anyway. And we duplicate the syslog + * to stderr in case of NM running with --debug. + */ + g_ptr_array_add (argv, (gpointer) "-q"); + + if (release) + g_ptr_array_add (argv, (gpointer) "-r"); + + if (ipv6) { + g_ptr_array_add (argv, (gpointer) "-6"); + if (mode_opt) + g_ptr_array_add (argv, (gpointer) mode_opt); + while (prefixes--) + g_ptr_array_add (argv, (gpointer) "-P"); + } + g_ptr_array_add (argv, (gpointer) "-sf"); /* Set script file */ + g_ptr_array_add (argv, (gpointer) nm_dhcp_helper_path); + + if (pid_file) { + g_ptr_array_add (argv, (gpointer) "-pf"); /* Set pid file */ + g_ptr_array_add (argv, (gpointer) pid_file); + } + + g_ptr_array_add (argv, (gpointer) "-lf"); /* Set lease file */ + g_ptr_array_add (argv, (gpointer) priv->lease_file); + + if (priv->conf_file) { + g_ptr_array_add (argv, (gpointer) "-cf"); /* Set interface config file */ + g_ptr_array_add (argv, (gpointer) priv->conf_file); + } + + /* Usually the system bus address is well-known; but if it's supposed + * to be something else, we need to push it to dhclient, since dhclient + * sanitizes the environment it gives the action scripts. + */ + system_bus_address = getenv ("DBUS_SYSTEM_BUS_ADDRESS"); + if (system_bus_address) { + system_bus_address_env = g_strdup_printf ("DBUS_SYSTEM_BUS_ADDRESS=%s", system_bus_address); + g_ptr_array_add (argv, (gpointer) "-e"); + g_ptr_array_add (argv, (gpointer) system_bus_address_env); + } + + + g_ptr_array_add (argv, (gpointer) iface); + g_ptr_array_add (argv, NULL); + + cmd_str = g_strjoinv (" ", (gchar **) argv->pdata); + _LOGD ("running: %s", cmd_str); + g_free (cmd_str); + + if (g_spawn_async (NULL, (char **) argv->pdata, NULL, + G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, + nm_utils_setpgid, NULL, &pid, &error)) { + g_assert (pid > 0); + _LOGI ("dhclient started with pid %d", pid); + if (release == FALSE) + nm_dhcp_client_watch_child (client, pid); + priv->pid_file = pid_file; + } else { + _LOGW ("dhclient failed to start: '%s'", error->message); + g_error_free (error); + g_free (pid_file); + } + + if (out_pid) + *out_pid = pid; + + g_ptr_array_free (argv, TRUE); + g_free (system_bus_address_env); + return pid > 0 ? TRUE : FALSE; +} + +static gboolean +ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address) +{ + NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + GBytes *client_id; + gs_unref_bytes GBytes *new_client_id = NULL; + const char *iface, *uuid, *hostname, *fqdn; + gboolean success = FALSE; + + iface = nm_dhcp_client_get_iface (client); + uuid = nm_dhcp_client_get_uuid (client); + client_id = nm_dhcp_client_get_client_id (client); + hostname = nm_dhcp_client_get_hostname (client); + fqdn = nm_dhcp_client_get_fqdn (client); + + priv->conf_file = create_dhclient_config (self, iface, FALSE, uuid, client_id, dhcp_anycast_addr, + hostname, fqdn, &new_client_id); + if (priv->conf_file) { + if (new_client_id) + nm_dhcp_client_set_client_id (client, new_client_id); + success = dhclient_start (client, NULL, NULL, FALSE, NULL, 0); + } else + _LOGW ("error creating dhclient configuration file"); + + return success; +} + +static gboolean +ip6_start (NMDhcpClient *client, + const char *dhcp_anycast_addr, + const struct in6_addr *ll_addr, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + const GByteArray *duid, + guint needed_prefixes) +{ + NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + const char *iface, *uuid, *hostname; + + iface = nm_dhcp_client_get_iface (client); + uuid = nm_dhcp_client_get_uuid (client); + hostname = nm_dhcp_client_get_hostname (client); + + priv->conf_file = create_dhclient_config (self, iface, TRUE, uuid, NULL, dhcp_anycast_addr, hostname, NULL, NULL); + if (!priv->conf_file) { + _LOGW ("error creating dhclient configuration file"); + return FALSE; + } + + return dhclient_start (client, info_only ? "-S" : "-N", duid, FALSE, NULL, needed_prefixes); +} + +static void +stop (NMDhcpClient *client, gboolean release, const GByteArray *duid) +{ + NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + + /* Chain up to parent */ + NM_DHCP_CLIENT_CLASS (nm_dhcp_dhclient_parent_class)->stop (client, release, duid); + + if (priv->conf_file) + if (remove (priv->conf_file) == -1) + _LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errno, g_strerror (errno)); + if (priv->pid_file) { + if (remove (priv->pid_file) == -1) + _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno)); + g_free (priv->pid_file); + priv->pid_file = NULL; + } + + if (release) { + pid_t rpid = -1; + + if (dhclient_start (client, NULL, duid, TRUE, &rpid, 0)) { + /* Wait a few seconds for the release to happen */ + nm_dhcp_client_stop_pid (rpid, nm_dhcp_client_get_iface (client)); + } + } +} + +static void +state_changed (NMDhcpClient *client, + NMDhcpState state, + GObject *ip_config, + GHashTable *options) +{ + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE ((NMDhcpDhclient *) client); + gs_unref_bytes GBytes *client_id = NULL; + + if (nm_dhcp_client_get_client_id (client)) + return; + if (state != NM_DHCP_STATE_BOUND) + return; + + client_id = nm_dhcp_dhclient_get_client_id_from_config_file (priv->conf_file); + nm_dhcp_client_set_client_id (client, client_id); +} + +static GByteArray * +get_duid (NMDhcpClient *client) +{ + NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + GByteArray *duid = NULL; + char *leasefile; + GError *error = NULL; + + /* Look in interface-specific leasefile first for backwards compat */ + leasefile = get_dhclient_leasefile (nm_dhcp_client_get_iface (client), + nm_dhcp_client_get_uuid (client), + TRUE, + NULL); + if (leasefile) { + _LOGD ("looking for DUID in '%s'", leasefile); + duid = nm_dhcp_dhclient_read_duid (leasefile, &error); + + if (error) { + _LOGW ("failed to read leasefile '%s': %s", + leasefile, error->message); + g_clear_error (&error); + } + g_free (leasefile); + } + + if (!duid && priv->def_leasefile) { + /* Otherwise read the default machine-wide DUID */ + _LOGD ("looking for default DUID in '%s'", priv->def_leasefile); + duid = nm_dhcp_dhclient_read_duid (priv->def_leasefile, &error); + if (error) { + _LOGW ("failed to read leasefile '%s': %s", + priv->def_leasefile, + error->message); + g_clear_error (&error); + } + } + + /* return our DUID, otherwise let the parent class make a default DUID */ + return duid ? duid : NM_DHCP_CLIENT_CLASS (nm_dhcp_dhclient_parent_class)->get_duid (client); +} + +/*****************************************************************************/ + +static const char *def_leasefiles[] = { + SYSCONFDIR "/dhclient6.leases", + LOCALSTATEDIR "/lib/dhcp/dhclient6.leases", + LOCALSTATEDIR "/lib/dhclient/dhclient6.leases", + NULL +}; + +static void +nm_dhcp_dhclient_init (NMDhcpDhclient *self) +{ + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + const char **iter = &def_leasefiles[0]; + + while (iter && *iter) { + if (g_file_test (*iter, G_FILE_TEST_EXISTS)) { + priv->def_leasefile = *iter; + break; + } + iter++; + } + + /* Fallback option */ + if (!priv->def_leasefile) + priv->def_leasefile = SYSCONFDIR "/dhclient6.leases"; + + priv->dhcp_listener = g_object_ref (nm_dhcp_listener_get ()); + g_signal_connect (priv->dhcp_listener, + NM_DHCP_LISTENER_EVENT, + G_CALLBACK (nm_dhcp_client_handle_event), + self); +} + +static void +dispose (GObject *object) +{ + NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE ((NMDhcpDhclient *) object); + + if (priv->dhcp_listener) { + g_signal_handlers_disconnect_by_func (priv->dhcp_listener, + G_CALLBACK (nm_dhcp_client_handle_event), + NM_DHCP_DHCLIENT (object)); + g_clear_object (&priv->dhcp_listener); + } + + nm_clear_g_free (&priv->pid_file); + nm_clear_g_free (&priv->conf_file); + nm_clear_g_free (&priv->lease_file); + + G_OBJECT_CLASS (nm_dhcp_dhclient_parent_class)->dispose (object); +} + +static void +nm_dhcp_dhclient_class_init (NMDhcpDhclientClass *dhclient_class) +{ + NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS (dhclient_class); + GObjectClass *object_class = G_OBJECT_CLASS (dhclient_class); + + object_class->dispose = dispose; + + client_class->ip4_start = ip4_start; + client_class->ip6_start = ip6_start; + client_class->stop = stop; + client_class->get_duid = get_duid; + client_class->state_changed = state_changed; +} + +const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient = { + .name = "dhclient", + .get_type = nm_dhcp_dhclient_get_type, + .get_path = nm_dhcp_dhclient_get_path, + .get_lease_ip_configs = nm_dhcp_dhclient_get_lease_ip_configs, +}; + +#endif /* WITH_DHCLIENT */ diff --git a/src/dhcp/nm-dhcp-dhcpcd.c b/src/dhcp/nm-dhcp-dhcpcd.c new file mode 100644 index 00000000..c8643881 --- /dev/null +++ b/src/dhcp/nm-dhcp-dhcpcd.c @@ -0,0 +1,265 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-dhcp-dhcpcd.c - dhcpcd specific hooks for NetworkManager + * + * Copyright (C) 2008 Roy Marples + * Copyright (C) 2010 Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "nm-default.h" + +#if WITH_DHCPCD + +#include +#include +#include +#include +#include +#include +#include + +#include "nm-dhcp-manager.h" +#include "nm-utils.h" +#include "NetworkManagerUtils.h" +#include "nm-dhcp-listener.h" +#include "nm-dhcp-client-logging.h" + +/*****************************************************************************/ + +#define NM_TYPE_DHCP_DHCPCD (nm_dhcp_dhcpcd_get_type ()) +#define NM_DHCP_DHCPCD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcd)) +#define NM_DHCP_DHCPCD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) +#define NM_IS_DHCP_DHCPCD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_DHCPCD)) +#define NM_IS_DHCP_DHCPCD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_DHCPCD)) +#define NM_DHCP_DHCPCD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) + +typedef struct _NMDhcpDhcpcd NMDhcpDhcpcd; +typedef struct _NMDhcpDhcpcdClass NMDhcpDhcpcdClass; + +static GType nm_dhcp_dhcpcd_get_type (void); + +/*****************************************************************************/ + +typedef struct { + char *pid_file; + NMDhcpListener *dhcp_listener; +} NMDhcpDhcpcdPrivate; + +struct _NMDhcpDhcpcd { + NMDhcpClient parent; + NMDhcpDhcpcdPrivate _priv; +}; + +struct _NMDhcpDhcpcdClass { + NMDhcpClientClass parent; +}; + +G_DEFINE_TYPE (NMDhcpDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_CLIENT) + +#define NM_DHCP_DHCPCD_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcpDhcpcd, NM_IS_DHCP_DHCPCD) + +/*****************************************************************************/ + +static const char * +nm_dhcp_dhcpcd_get_path (void) +{ + return nm_utils_find_helper ("dhcpcd", DHCPCD_PATH, NULL); +} + +static gboolean +ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address) +{ + NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client); + NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self); + GPtrArray *argv = NULL; + pid_t pid = -1; + GError *error = NULL; + char *pid_contents = NULL, *binary_name, *cmd_str, *dot; + const char *iface, *dhcpcd_path, *hostname, *fqdn; + gs_free char *prefix = NULL; + + g_return_val_if_fail (priv->pid_file == NULL, FALSE); + + iface = nm_dhcp_client_get_iface (client); + + /* dhcpcd does not allow custom pidfiles; the pidfile is always + * RUNDIR "dhcpcd-.pid". + */ + priv->pid_file = g_strdup_printf (RUNDIR "/dhcpcd-%s.pid", iface); + + dhcpcd_path = nm_dhcp_dhcpcd_get_path (); + if (!dhcpcd_path) { + _LOGW ("dhcpcd could not be found"); + return FALSE; + } + + /* Kill any existing dhcpcd from the pidfile */ + binary_name = g_path_get_basename (dhcpcd_path); + nm_dhcp_client_stop_existing (priv->pid_file, binary_name); + g_free (binary_name); + + argv = g_ptr_array_new (); + g_ptr_array_add (argv, (gpointer) dhcpcd_path); + + g_ptr_array_add (argv, (gpointer) "-B"); /* Don't background on lease (disable fork()) */ + + g_ptr_array_add (argv, (gpointer) "-K"); /* Disable built-in carrier detection */ + + g_ptr_array_add (argv, (gpointer) "-L"); /* Disable built-in IPv4LL */ + + /* --noarp. Don't request or claim the address by ARP; this also disables IPv4LL. */ + g_ptr_array_add (argv, (gpointer) "-A"); + + g_ptr_array_add (argv, (gpointer) "-G"); /* Let NM handle routing */ + + g_ptr_array_add (argv, (gpointer) "-c"); /* Set script file */ + g_ptr_array_add (argv, (gpointer) nm_dhcp_helper_path); + +#ifdef DHCPCD_SUPPORTS_IPV6 + /* IPv4-only for now. NetworkManager knows better than dhcpcd when to + * run IPv6, and dhcpcd's automatic Router Solicitations cause problems + * with devices that don't expect them. + */ + g_ptr_array_add (argv, (gpointer) "-4"); +#endif + + hostname = nm_dhcp_client_get_hostname (client); + fqdn = nm_dhcp_client_get_fqdn (client); + + if (fqdn) { + g_ptr_array_add (argv, (gpointer) "-h"); + g_ptr_array_add (argv, (gpointer) fqdn); + g_ptr_array_add (argv, (gpointer) "-F"); + g_ptr_array_add (argv, (gpointer) "both"); + } else if (hostname) { + prefix = strdup (hostname); + dot = strchr (prefix, '.'); + /* get rid of the domain */ + if (dot) + *dot = '\0'; + + g_ptr_array_add (argv, (gpointer) "-h"); /* Send hostname to DHCP server */ + g_ptr_array_add (argv, (gpointer) prefix); + } + + g_ptr_array_add (argv, (gpointer) iface); + g_ptr_array_add (argv, NULL); + + cmd_str = g_strjoinv (" ", (gchar **) argv->pdata); + _LOGD ("running: %s", cmd_str); + g_free (cmd_str); + + if (g_spawn_async (NULL, (char **) argv->pdata, NULL, + G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, + nm_utils_setpgid, NULL, &pid, &error)) { + g_assert (pid > 0); + _LOGI ("dhcpcd started with pid %d", pid); + nm_dhcp_client_watch_child (client, pid); + } else { + _LOGW ("dhcpcd failed to start, error: '%s'", error->message); + g_error_free (error); + } + + g_free (pid_contents); + g_ptr_array_free (argv, TRUE); + return pid > 0 ? TRUE : FALSE; +} + +static gboolean +ip6_start (NMDhcpClient *client, + const char *dhcp_anycast_addr, + const struct in6_addr *ll_addr, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + const GByteArray *duid, + guint needed_prefixes) +{ + NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client); + + _LOGW ("the dhcpcd backend does not support IPv6"); + return FALSE; +} + +static void +stop (NMDhcpClient *client, gboolean release, const GByteArray *duid) +{ + NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client); + NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self); + + /* Chain up to parent */ + NM_DHCP_CLIENT_CLASS (nm_dhcp_dhcpcd_parent_class)->stop (client, release, duid); + + if (priv->pid_file) { + if (remove (priv->pid_file) == -1) + _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno)); + } + + /* FIXME: implement release... */ +} + +/*****************************************************************************/ + +static void +nm_dhcp_dhcpcd_init (NMDhcpDhcpcd *self) +{ + NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self); + + priv->dhcp_listener = g_object_ref (nm_dhcp_listener_get ()); + g_signal_connect (priv->dhcp_listener, + NM_DHCP_LISTENER_EVENT, + G_CALLBACK (nm_dhcp_client_handle_event), + self); +} + +static void +dispose (GObject *object) +{ + NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE ((NMDhcpDhcpcd *) object); + + if (priv->dhcp_listener) { + g_signal_handlers_disconnect_by_func (priv->dhcp_listener, + G_CALLBACK (nm_dhcp_client_handle_event), + NM_DHCP_DHCPCD (object)); + g_clear_object (&priv->dhcp_listener); + } + + nm_clear_g_free (&priv->pid_file); + + G_OBJECT_CLASS (nm_dhcp_dhcpcd_parent_class)->dispose (object); +} + +static void +nm_dhcp_dhcpcd_class_init (NMDhcpDhcpcdClass *dhcpcd_class) +{ + NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS (dhcpcd_class); + GObjectClass *object_class = G_OBJECT_CLASS (dhcpcd_class); + + object_class->dispose = dispose; + + client_class->ip4_start = ip4_start; + client_class->ip6_start = ip6_start; + client_class->stop = stop; +} + +const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcd = { + .name = "dhcpcd", + .get_type = nm_dhcp_dhcpcd_get_type, + .get_path = nm_dhcp_dhcpcd_get_path, + .get_lease_ip_configs = NULL, +}; + +#endif /* WITH_DHCPCD */ diff --git a/src/dhcp/nm-dhcp-helper-api.h b/src/dhcp/nm-dhcp-helper-api.h new file mode 100644 index 00000000..58344215 --- /dev/null +++ b/src/dhcp/nm-dhcp-helper-api.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2016 Red Hat, Inc. + */ + +#ifndef __NM_DHCP_HELPER_API_H__ +#define __NM_DHCP_HELPER_API_H__ + +/*****************************************************************************/ + +#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client" + +#define NM_DHCP_HELPER_SERVER_BUS_NAME "org.freedesktop.nm_dhcp_server" +#define NM_DHCP_HELPER_SERVER_OBJECT_PATH "/org/freedesktop/nm_dhcp_server" +#define NM_DHCP_HELPER_SERVER_INTERFACE_NAME "org.freedesktop.nm_dhcp_server" +#define NM_DHCP_HELPER_SERVER_METHOD_NOTIFY "Notify" + +/*****************************************************************************/ + +#endif /* __NM_DHCP_HELPER_API_H__ */ diff --git a/src/dhcp/nm-dhcp-helper.c b/src/dhcp/nm-dhcp-helper.c new file mode 100644 index 00000000..f50c5cec --- /dev/null +++ b/src/dhcp/nm-dhcp-helper.c @@ -0,0 +1,227 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2007 - 2013 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include +#include +#include +#include + +#include "nm-utils/nm-vpn-plugin-macros.h" + +#include "nm-dhcp-helper-api.h" + +/*****************************************************************************/ + +#ifdef NM_MORE_LOGGING +#define _NMLOG_ENABLED(level) TRUE +#else +#define _NMLOG_ENABLED(level) ((level) <= LOG_ERR) +#endif + +#define _NMLOG(always_enabled, level, ...) \ + G_STMT_START { \ + if ((always_enabled) || _NMLOG_ENABLED (level)) { \ + GTimeVal _tv; \ + \ + g_get_current_time (&_tv); \ + g_print ("nm-dhcp-helper[%ld] %-7s [%ld.%04ld] " _NM_UTILS_MACRO_FIRST (__VA_ARGS__) "\n", \ + (long) getpid (), \ + nm_utils_syslog_to_str (level), \ + _tv.tv_sec, _tv.tv_usec / 100 \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +#define _LOGD(...) _NMLOG(TRUE, LOG_INFO, __VA_ARGS__) +#define _LOGI(...) _NMLOG(TRUE, LOG_NOTICE, __VA_ARGS__) +#define _LOGW(...) _NMLOG(TRUE, LOG_WARNING, __VA_ARGS__) +#define _LOGE(...) _NMLOG(TRUE, LOG_ERR, __VA_ARGS__) + +#define _LOGd(...) _NMLOG(FALSE, LOG_INFO, __VA_ARGS__) +#define _LOGi(...) _NMLOG(FALSE, LOG_NOTICE, __VA_ARGS__) +#define _LOGw(...) _NMLOG(FALSE, LOG_WARNING, __VA_ARGS__) + +/*****************************************************************************/ + +static const char * ignore[] = {"PATH", "SHLVL", "_", "PWD", "dhc_dbus", NULL}; + +static GVariant * +build_signal_parameters (void) +{ + char **item; + GVariantBuilder builder; + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + + /* List environment and format for dbus dict */ + for (item = environ; *item; item++) { + char *name, *val, **p; + + /* Split on the = */ + name = g_strdup (*item); + val = strchr (name, '='); + if (!val || val == name) + goto next; + *val++ = '\0'; + + /* Ignore non-DCHP-related environment variables */ + for (p = (char **) ignore; *p; p++) { + if (strncmp (name, *p, strlen (*p)) == 0) + goto next; + } + + /* Value passed as a byte array rather than a string, because there are + * no character encoding guarantees with DHCP, and D-Bus requires + * strings to be UTF-8. + * + * Note that we can't use g_variant_new_bytestring() here, because that + * includes the trailing '\0'. (??!?) + */ + g_variant_builder_add (&builder, "{sv}", + name, + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + val, strlen (val), 1)); + + next: + g_free (name); + } + + return g_variant_ref_sink (g_variant_new ("(a{sv})", &builder)); +} + +static void +kill_pid (void) +{ + const char *pid_str; + pid_t pid = 0; + + pid_str = getenv ("pid"); + if (pid_str) + pid = strtol (pid_str, NULL, 10); + if (pid) { + _LOGI ("a fatal error occured, kill dhclient instance with pid %d\n", pid); + kill (pid, SIGTERM); + } +} + +int +main (int argc, char *argv[]) +{ + gs_unref_object GDBusConnection *connection = NULL; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *parameters = NULL; + gs_unref_variant GVariant *result = NULL; + gboolean success = FALSE; + guint try_count = 0; + gint64 time_end; + + nm_g_type_init (); + + /* FIXME: g_dbus_connection_new_for_address_sync() tries to connect to the socket in + * non-blocking mode, which can easily fail with EAGAIN, causing the creation of the + * socket to fail with "Could not connect: Resource temporarily unavailable". + * + * We should instead create the GIOStream ourself and block on connecting to + * the socket. */ + connection = g_dbus_connection_new_for_address_sync ("unix:path=" NMRUNDIR "/private-dhcp", + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, + NULL, NULL, &error); + if (!connection) { + g_dbus_error_strip_remote_error (error); + _LOGE ("could not connect to NetworkManager D-Bus socket: %s", + error->message); + goto out; + } + + parameters = build_signal_parameters (); + + time_end = g_get_monotonic_time () + (200 * 1000L); /* retry for at most 200 milliseconds */ + +do_notify: + try_count++; + result = g_dbus_connection_call_sync (connection, + NULL, + NM_DHCP_HELPER_SERVER_OBJECT_PATH, + NM_DHCP_HELPER_SERVER_INTERFACE_NAME, + NM_DHCP_HELPER_SERVER_METHOD_NOTIFY, + parameters, + NULL, + G_DBUS_CALL_FLAGS_NONE, + 1000, + NULL, + &error); + + if (!result) { + gs_free char *s_err = NULL; + + s_err = g_dbus_error_get_remote_error (error); + if (NM_IN_STRSET (s_err, "org.freedesktop.DBus.Error.UnknownMethod")) { + gint64 remaining_time = time_end - g_get_monotonic_time (); + + /* I am not sure that a race can actually happen, as we register the object + * on the server side during GDBusServer:new-connection signal. + * + * However, there was also a race for subscribing to an event, so let's just + * do some retry. */ + if (remaining_time > 0) { + _LOGi ("failure to call notify: %s (retry %u)", error->message, try_count); + g_usleep (NM_MIN (NM_CLAMP ((gint64) (100L * (1L << try_count)), 5000, 25000), remaining_time)); + g_clear_error (&error); + goto do_notify; + } + } + _LOGW ("failure to call notify: %s (try signal via Event)", error->message); + g_clear_error (&error); + + /* for backward compatibilty, try to emit the signal. There is no stable + * API between the dhcp-helper and NetworkManager. However, while upgrading + * the NetworkManager package, a newer helper might want to notify an + * older server, which still uses the "Event". */ + if (!g_dbus_connection_emit_signal (connection, + NULL, + "/", + NM_DHCP_CLIENT_DBUS_IFACE, + "Event", + parameters, + &error)) { + g_dbus_error_strip_remote_error (error); + _LOGE ("could not send DHCP Event signal: %s", error->message); + goto out; + } + /* We were able to send the asynchronous Event. Consider that a success. */ + success = TRUE; + } else + success = TRUE; + + if (!g_dbus_connection_flush_sync (connection, NULL, &error)) { + g_dbus_error_strip_remote_error (error); + _LOGE ("could not flush D-Bus connection: %s", error->message); + success = FALSE; + goto out; + } + +out: + if (!success) + kill_pid (); + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} + diff --git a/src/dhcp/nm-dhcp-listener.c b/src/dhcp/nm-dhcp-listener.c new file mode 100644 index 00000000..56bd9d17 --- /dev/null +++ b/src/dhcp/nm-dhcp-listener.c @@ -0,0 +1,345 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 - 2016 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include "nm-dhcp-listener.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "nm-dhcp-helper-api.h" +#include "nm-dhcp-client.h" +#include "nm-core-internal.h" +#include "nm-bus-manager.h" +#include "NetworkManagerUtils.h" + +#define PRIV_SOCK_PATH NMRUNDIR "/private-dhcp" +#define PRIV_SOCK_TAG "dhcp" + +/*****************************************************************************/ + +const NMDhcpClientFactory *const _nm_dhcp_manager_factories[3] = { + /* the order here matters, as we will try the plugins in this order to find + * the first available plugin. */ + +#if WITH_DHCLIENT + &_nm_dhcp_client_factory_dhclient, +#endif +#if WITH_DHCPCD + &_nm_dhcp_client_factory_dhcpcd, +#endif + &_nm_dhcp_client_factory_internal, +}; + +/*****************************************************************************/ + +typedef struct { + NMBusManager * dbus_mgr; + gulong new_conn_id; + gulong dis_conn_id; + GHashTable * connections; +} NMDhcpListenerPrivate; + +struct _NMDhcpListener { + GObject parent; + NMDhcpListenerPrivate _priv; +}; + +struct _NMDhcpListenerClass { + GObjectClass parent; +}; + +enum { + EVENT, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +G_DEFINE_TYPE (NMDhcpListener, nm_dhcp_listener, G_TYPE_OBJECT) + +#define NM_DHCP_LISTENER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDhcpListener, NM_IS_DHCP_LISTENER) + +NM_DEFINE_SINGLETON_GETTER (NMDhcpListener, nm_dhcp_listener_get, NM_TYPE_DHCP_LISTENER); + +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "dhcp-listener" +#define _NMLOG_DOMAIN LOGD_DHCP +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMDhcpListener *_self = (self); \ + char _prefix[64]; \ + \ + nm_log ((level), (_NMLOG_DOMAIN), \ + "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + (_self != singleton_instance \ + ? nm_sprintf_buf (_prefix, "%s[%p]", _NMLOG_PREFIX_NAME, _self) \ + : _NMLOG_PREFIX_NAME )\ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + +/*****************************************************************************/ + +static char * +get_option (GVariant *options, const char *key) +{ + GVariant *value; + const guchar *bytes, *s; + gsize len; + char *converted, *d; + + 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. + */ + 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 (*s == '\0') + *d = ' '; + else if (*s > 127) + *d = '?'; + else + *d = *s; + } + *d = '\0'; + g_variant_unref (value); + + return converted; +} + +static void +_method_call (GDBusConnection *connection, + const char *sender, + const char *object_path, + const char *interface_name, + const char *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + NMDhcpListener *self = NM_DHCP_LISTENER (user_data); + char *iface = NULL; + char *pid_str = NULL; + char *reason = NULL; + gint pid; + gboolean handled = FALSE; + GVariant *options; + + if (!nm_streq0 (interface_name, NM_DHCP_HELPER_SERVER_INTERFACE_NAME)) + g_return_if_reached (); + if (!nm_streq0 (method_name, NM_DHCP_HELPER_SERVER_METHOD_NOTIFY)) + g_return_if_reached (); + if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})"))) + g_return_if_reached (); + + g_variant_get (parameters, "(@a{sv})", &options); + + iface = get_option (options, "interface"); + if (iface == NULL) { + _LOGW ("dhcp-event: didn't have associated interface."); + goto out; + } + + pid_str = get_option (options, "pid"); + pid = _nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1); + if (pid == -1) { + _LOGW ("dhcp-event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)"); + goto out; + } + + reason = get_option (options, "reason"); + if (reason == NULL) { + _LOGW ("dhcp-event: (pid %d) DHCP event didn't have a reason", pid); + goto out; + } + + g_signal_emit (self, signals[EVENT], 0, iface, pid, options, reason, &handled); + if (!handled) { + if (g_ascii_strcasecmp (reason, "RELEASE") == 0) { + /* Ignore event when the dhcp client gets killed and we receive its last message */ + _LOGD ("dhcp-event: (pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface); + } else + _LOGW ("dhcp-event: (pid %d) unhandled DHCP event for interface %s", pid, iface); + } + +out: + g_free (iface); + g_free (pid_str); + g_free (reason); + g_variant_unref (options); + g_dbus_method_invocation_return_value (invocation, NULL); +} + +static guint +_dbus_connection_register_object (NMDhcpListener *self, + GDBusConnection *connection, + GError **error) +{ + static GDBusArgInfo arg_info_notify_in = { + .ref_count = -1, + .name = "data", + .signature = "a{sv}", + .annotations = NULL, + }; + static GDBusArgInfo *arg_infos_notify[] = { + &arg_info_notify_in, + NULL, + }; + static GDBusMethodInfo method_info_notify = { + .ref_count = -1, + .name = NM_DHCP_HELPER_SERVER_METHOD_NOTIFY, + .in_args = arg_infos_notify, + .out_args = NULL, + .annotations = NULL, + }; + static GDBusMethodInfo *method_infos[] = { + &method_info_notify, + NULL, + }; + static GDBusInterfaceInfo interface_info = { + .ref_count = -1, + .name = NM_DHCP_HELPER_SERVER_INTERFACE_NAME, + .methods = method_infos, + .signals = NULL, + .properties = NULL, + .annotations = NULL, + }; + + static GDBusInterfaceVTable interface_vtable = { + .method_call = _method_call, + .get_property = NULL, + .set_property = NULL, + }; + + return g_dbus_connection_register_object (connection, + NM_DHCP_HELPER_SERVER_OBJECT_PATH, + &interface_info, + &interface_vtable, + self, + NULL, + error); +} + +static void +new_connection_cb (NMBusManager *mgr, + GDBusConnection *connection, + GDBusObjectManager *manager, + NMDhcpListener *self) +{ + NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self); + guint registration_id; + GError *error = NULL; + + /* it is important to register the object during the new-connection signal, + * as this avoids races with the connecting object. */ + registration_id = _dbus_connection_register_object (self, connection, &error); + if (!registration_id) { + _LOGE ("failure to register %s for connection %p: %s", + NM_DHCP_HELPER_SERVER_OBJECT_PATH, connection, error->message); + g_error_free (error); + return; + } + + g_hash_table_insert (priv->connections, connection, GUINT_TO_POINTER (registration_id)); +} + +static void +dis_connection_cb (NMBusManager *mgr, + GDBusConnection *connection, + NMDhcpListener *self) +{ + NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self); + guint id; + + id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->connections, connection)); + if (id) { + g_dbus_connection_unregister_object (connection, id); + g_hash_table_remove (priv->connections, connection); + } +} + +/*****************************************************************************/ + +static void +nm_dhcp_listener_init (NMDhcpListener *self) +{ + NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self); + + /* Maps GDBusConnection :: signal-id */ + priv->connections = g_hash_table_new (NULL, NULL); + + priv->dbus_mgr = nm_bus_manager_get (); + + /* 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, + NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW "::" PRIV_SOCK_TAG, + G_CALLBACK (new_connection_cb), + self); + priv->dis_conn_id = g_signal_connect (priv->dbus_mgr, + NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG, + G_CALLBACK (dis_connection_cb), + self); +} + +static void +dispose (GObject *object) +{ + NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE ((NMDhcpListener *) object); + + nm_clear_g_signal_handler (priv->dbus_mgr, &priv->new_conn_id); + nm_clear_g_signal_handler (priv->dbus_mgr, &priv->dis_conn_id); + priv->dbus_mgr = NULL; + + g_clear_pointer (&priv->connections, g_hash_table_destroy); + + G_OBJECT_CLASS (nm_dhcp_listener_parent_class)->dispose (object); +} + +static void +nm_dhcp_listener_class_init (NMDhcpListenerClass *listener_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (listener_class); + + object_class->dispose = dispose; + + signals[EVENT] = + g_signal_new (NM_DHCP_LISTENER_EVENT, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, 0, + g_signal_accumulator_true_handled, + NULL, NULL, + G_TYPE_BOOLEAN, /* listeners return TRUE if handled */ + 4, + G_TYPE_STRING, /* iface */ + G_TYPE_INT, /* pid */ + G_TYPE_VARIANT, /* options */ + G_TYPE_STRING); /* reason */ +} diff --git a/src/dhcp/nm-dhcp-listener.h b/src/dhcp/nm-dhcp-listener.h new file mode 100644 index 00000000..3018b97a --- /dev/null +++ b/src/dhcp/nm-dhcp-listener.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DHCP_LISTENER_H__ +#define __NETWORKMANAGER_DHCP_LISTENER_H__ + +#define NM_TYPE_DHCP_LISTENER (nm_dhcp_listener_get_type ()) +#define NM_DHCP_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_LISTENER, NMDhcpListener)) +#define NM_IS_DHCP_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_LISTENER)) +#define NM_DHCP_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_LISTENER, NMDhcpListenerClass)) + +#define NM_DHCP_LISTENER_EVENT "event" + +typedef struct _NMDhcpListener NMDhcpListener; +typedef struct _NMDhcpListenerClass NMDhcpListenerClass; + +GType nm_dhcp_listener_get_type (void); + +NMDhcpListener *nm_dhcp_listener_get (void); + +#endif /* __NETWORKMANAGER_DHCP_LISTENER_H__ */ diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c new file mode 100644 index 00000000..9c1fbb38 --- /dev/null +++ b/src/dhcp/nm-dhcp-manager.c @@ -0,0 +1,442 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-dhcp-manager.c - Handle the DHCP daemon for NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2013 Red Hat, Inc. + * Copyright (C) 2006 - 2008 Novell, Inc. + * + */ + +#include "nm-default.h" + +#include "nm-dhcp-manager.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-config.h" +#include "NetworkManagerUtils.h" + +#define DHCP_TIMEOUT 45 /* default DHCP timeout, in seconds */ + +/*****************************************************************************/ + +typedef struct { + const NMDhcpClientFactory *client_factory; + GHashTable * clients; + char * default_hostname; +} NMDhcpManagerPrivate; + +struct _NMDhcpManager { + GObject parent; + NMDhcpManagerPrivate _priv; +}; + +struct _NMDhcpManagerClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMDhcpManager, nm_dhcp_manager, G_TYPE_OBJECT) + +#define NM_DHCP_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcpManager, NM_IS_DHCP_MANAGER) + +/*****************************************************************************/ + +/* default to installed helper, but can be modified for testing */ +const char *nm_dhcp_helper_path = LIBEXECDIR "/nm-dhcp-helper"; + +/*****************************************************************************/ + +static const NMDhcpClientFactory * +_client_factory_find_by_name (const char *name) +{ + int i; + + g_return_val_if_fail (name, NULL); + + for (i = 0; i < G_N_ELEMENTS (_nm_dhcp_manager_factories); i++) { + const NMDhcpClientFactory *f = _nm_dhcp_manager_factories[i]; + + if (f && nm_streq (f->name, name)) + return f; + } + return NULL; +} + +static const NMDhcpClientFactory * +_client_factory_available (const NMDhcpClientFactory *client_factory) +{ + if ( client_factory + && (!client_factory->get_path || client_factory->get_path ())) + return client_factory; + return NULL; +} + +/*****************************************************************************/ + +static NMDhcpClient * +get_client_for_ifindex (NMDhcpManager *manager, int ifindex, gboolean ip6) +{ + NMDhcpManagerPrivate *priv; + GHashTableIter iter; + gpointer value; + + g_return_val_if_fail (NM_IS_DHCP_MANAGER (manager), NULL); + g_return_val_if_fail (ifindex > 0, NULL); + + priv = NM_DHCP_MANAGER_GET_PRIVATE (manager); + + g_hash_table_iter_init (&iter, priv->clients); + while (g_hash_table_iter_next (&iter, NULL, &value)) { + NMDhcpClient *candidate = NM_DHCP_CLIENT (value); + + if ( nm_dhcp_client_get_ifindex (candidate) == ifindex + && nm_dhcp_client_get_ipv6 (candidate) == ip6) + return candidate; + } + + return NULL; +} + +static void client_state_changed (NMDhcpClient *client, + NMDhcpState state, + GObject *ip_config, + GVariant *options, + const char *event_id, + NMDhcpManager *self); + +static void +remove_client (NMDhcpManager *self, NMDhcpClient *client) +{ + g_signal_handlers_disconnect_by_func (client, client_state_changed, self); + + /* Stopping the client is left up to the controlling device + * explicitly since we may want to quit NetworkManager but not terminate + * the DHCP client. + */ + + g_hash_table_remove (NM_DHCP_MANAGER_GET_PRIVATE (self)->clients, client); +} + +static void +client_state_changed (NMDhcpClient *client, + NMDhcpState state, + GObject *ip_config, + GVariant *options, + const char *event_id, + NMDhcpManager *self) +{ + if (state >= NM_DHCP_STATE_TIMEOUT) + remove_client (self, client); +} + +static NMDhcpClient * +client_start (NMDhcpManager *self, + const char *iface, + int ifindex, + const GByteArray *hwaddr, + const char *uuid, + guint32 priority, + gboolean ipv6, + const struct in6_addr *ipv6_ll_addr, + const char *dhcp_client_id, + guint32 timeout, + const char *dhcp_anycast_addr, + const char *hostname, + const char *fqdn, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + const char *last_ip4_address, + guint needed_prefixes) +{ + NMDhcpManagerPrivate *priv; + NMDhcpClient *client; + gboolean success = FALSE; + + g_return_val_if_fail (self, NULL); + g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); + g_return_val_if_fail (ifindex > 0, NULL); + g_return_val_if_fail (uuid != NULL, NULL); + + priv = NM_DHCP_MANAGER_GET_PRIVATE (self); + + /* Ensure we have a usable DHCP client */ + if (!priv->client_factory) + return NULL; + + /* Kill any old client instance */ + client = get_client_for_ifindex (self, ifindex, ipv6); + if (client) { + g_object_ref (client); + remove_client (self, client); + nm_dhcp_client_stop (client, FALSE); + g_object_unref (client); + } + + /* And make a new one */ + client = g_object_new (priv->client_factory->get_type (), + NM_DHCP_CLIENT_INTERFACE, iface, + NM_DHCP_CLIENT_IFINDEX, ifindex, + NM_DHCP_CLIENT_HWADDR, hwaddr, + NM_DHCP_CLIENT_IPV6, ipv6, + NM_DHCP_CLIENT_UUID, uuid, + NM_DHCP_CLIENT_PRIORITY, priority, + NM_DHCP_CLIENT_TIMEOUT, timeout ? timeout : DHCP_TIMEOUT, + NULL); + g_hash_table_insert (NM_DHCP_MANAGER_GET_PRIVATE (self)->clients, client, g_object_ref (client)); + g_signal_connect (client, NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, G_CALLBACK (client_state_changed), self); + + if (ipv6) + success = nm_dhcp_client_start_ip6 (client, dhcp_anycast_addr, ipv6_ll_addr, hostname, info_only, privacy, needed_prefixes); + else + success = nm_dhcp_client_start_ip4 (client, dhcp_client_id, dhcp_anycast_addr, hostname, fqdn, last_ip4_address); + + if (!success) { + remove_client (self, client); + client = NULL; + } + + return client; +} + +static const char * +get_send_hostname (NMDhcpManager *self, const char *setting_hostname) +{ + NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (self); + + /* Always prefer the explicit dhcp-send-hostname if given */ + return setting_hostname ? setting_hostname : priv->default_hostname; +} + +/* Caller owns a reference to the NMDhcpClient on return */ +NMDhcpClient * +nm_dhcp_manager_start_ip4 (NMDhcpManager *self, + const char *iface, + int ifindex, + const GByteArray *hwaddr, + const char *uuid, + guint32 priority, + gboolean send_hostname, + const char *dhcp_hostname, + const char *dhcp_fqdn, + const char *dhcp_client_id, + guint32 timeout, + const char *dhcp_anycast_addr, + const char *last_ip_address) +{ + const char *hostname = NULL; + const char *fqdn = NULL; + + g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); + + if (send_hostname) { + hostname = get_send_hostname (self, dhcp_hostname); + fqdn = dhcp_fqdn; + } + return client_start (self, iface, ifindex, hwaddr, uuid, priority, FALSE, NULL, + dhcp_client_id, timeout, dhcp_anycast_addr, hostname, + fqdn, FALSE, 0, last_ip_address, 0); +} + +/* Caller owns a reference to the NMDhcpClient on return */ +NMDhcpClient * +nm_dhcp_manager_start_ip6 (NMDhcpManager *self, + const char *iface, + int ifindex, + const GByteArray *hwaddr, + const struct in6_addr *ll_addr, + const char *uuid, + guint32 priority, + gboolean send_hostname, + const char *dhcp_hostname, + guint32 timeout, + const char *dhcp_anycast_addr, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + guint needed_prefixes) +{ + const char *hostname = NULL; + + g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); + + if (send_hostname) + hostname = get_send_hostname (self, dhcp_hostname); + return client_start (self, iface, ifindex, hwaddr, uuid, priority, TRUE, + ll_addr, NULL, timeout, dhcp_anycast_addr, hostname, NULL, info_only, + privacy, NULL, needed_prefixes); +} + +void +nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostname) +{ + NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (manager); + + g_clear_pointer (&priv->default_hostname, g_free); + + /* Never send 'localhost'-type names to the DHCP server */ + if (!nm_utils_is_specific_hostname (hostname)) + return; + + priv->default_hostname = g_strdup (hostname); +} + +GSList * +nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, + const char *iface, + int ifindex, + const char *uuid, + gboolean ipv6, + guint32 default_route_metric) +{ + NMDhcpManagerPrivate *priv; + + g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); + g_return_val_if_fail (iface != NULL, NULL); + g_return_val_if_fail (ifindex >= -1, NULL); + g_return_val_if_fail (uuid != NULL, NULL); + + priv = NM_DHCP_MANAGER_GET_PRIVATE (self); + if ( priv->client_factory + && priv->client_factory->get_lease_ip_configs) + return priv->client_factory->get_lease_ip_configs (iface, ifindex, uuid, ipv6, default_route_metric); + return NULL; +} + +const char * +nm_dhcp_manager_get_config (NMDhcpManager *self) +{ + const NMDhcpClientFactory *factory; + + g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); + + factory = NM_DHCP_MANAGER_GET_PRIVATE (self)->client_factory; + return factory ? factory->name : NULL; +} + +/*****************************************************************************/ + +NM_DEFINE_SINGLETON_GETTER (NMDhcpManager, nm_dhcp_manager_get, NM_TYPE_DHCP_MANAGER); + +static void +nm_dhcp_manager_init (NMDhcpManager *self) +{ + NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (self); + NMConfig *config = nm_config_get (); + gs_free char *client_free = NULL; + const char *client; + int i; + const NMDhcpClientFactory *client_factory = NULL; + + for (i = 0; i < G_N_ELEMENTS (_nm_dhcp_manager_factories); i++) { + const NMDhcpClientFactory *f = _nm_dhcp_manager_factories[i]; + + if (!f) + continue; + + nm_log_dbg (LOGD_DHCP, "dhcp-init: enabled DHCP client '%s' (%s)%s", + f->name, g_type_name (f->get_type ()), + _client_factory_available (f) ? "" : " (not available)"); + } + + /* Client-specific setup */ + client_free = nm_config_data_get_value (nm_config_get_data_orig (config), + NM_CONFIG_KEYFILE_GROUP_MAIN, + NM_CONFIG_KEYFILE_KEY_MAIN_DHCP, + NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); + client = client_free; + if (nm_config_get_configure_and_quit (config)) { + client_factory = &_nm_dhcp_client_factory_internal; + if (client && !nm_streq (client, client_factory->name)) + nm_log_info (LOGD_DHCP, "dhcp-init: Using internal DHCP client since configure-and-quit is set."); + } else { + if (client) { + client_factory = _client_factory_available (_client_factory_find_by_name (client)); + if (!client_factory) + nm_log_warn (LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client); + } + if (!client_factory) { + client_factory = _client_factory_find_by_name (""NM_CONFIG_DEFAULT_MAIN_DHCP); + if (!client_factory) + nm_log_err (LOGD_DHCP, "dhcp-init: default DHCP client '%s' is not installed", NM_CONFIG_DEFAULT_MAIN_DHCP); + else { + client_factory = _client_factory_available (client_factory); + if (!client_factory) + nm_log_info (LOGD_DHCP, "dhcp-init: default DHCP client '%s' is not available", NM_CONFIG_DEFAULT_MAIN_DHCP); + } + } + if (!client_factory) { + for (i = 0; i < G_N_ELEMENTS (_nm_dhcp_manager_factories); i++) { + client_factory = _client_factory_available (_nm_dhcp_manager_factories[i]); + if (client_factory) + break; + } + } + } + + nm_assert (client_factory); + + nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", client_factory->name); + + priv->client_factory = client_factory; + priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal, + NULL, + (GDestroyNotify) g_object_unref); +} + +static void +dispose (GObject *object) +{ + NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE ((NMDhcpManager *) object); + GList *values, *iter; + + if (priv->clients) { + values = g_hash_table_get_values (priv->clients); + for (iter = values; iter; iter = g_list_next (iter)) + remove_client (NM_DHCP_MANAGER (object), NM_DHCP_CLIENT (iter->data)); + g_list_free (values); + } + + G_OBJECT_CLASS (nm_dhcp_manager_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE ((NMDhcpManager *) object); + + g_free (priv->default_hostname); + + if (priv->clients) + g_hash_table_destroy (priv->clients); + + G_OBJECT_CLASS (nm_dhcp_manager_parent_class)->finalize (object); +} + +static void +nm_dhcp_manager_class_init (NMDhcpManagerClass *manager_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (manager_class); + + object_class->finalize = finalize; + object_class->dispose = dispose; +} diff --git a/src/dhcp/nm-dhcp-manager.h b/src/dhcp/nm-dhcp-manager.h new file mode 100644 index 00000000..66fdd145 --- /dev/null +++ b/src/dhcp/nm-dhcp-manager.h @@ -0,0 +1,89 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-dhcp-manager.c - Handle the DHCP daemon for NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2010 Red Hat, Inc. + * Copyright (C) 2006 - 2008 Novell, Inc. + */ + +#ifndef __NETWORKMANAGER_DHCP_MANAGER_H__ +#define __NETWORKMANAGER_DHCP_MANAGER_H__ + +#include "nm-dhcp-client.h" +#include "nm-ip4-config.h" +#include "nm-dhcp4-config.h" + +#define NM_TYPE_DHCP_MANAGER (nm_dhcp_manager_get_type ()) +#define NM_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_MANAGER, NMDhcpManager)) +#define NM_DHCP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_MANAGER, NMDhcpManagerClass)) +#define NM_IS_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_MANAGER)) +#define NM_IS_DHCP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_MANAGER)) +#define NM_DHCP_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_MANAGER, NMDhcpManagerClass)) + +typedef struct _NMDhcpManager NMDhcpManager; +typedef struct _NMDhcpManagerClass NMDhcpManagerClass; + +GType nm_dhcp_manager_get_type (void); + +NMDhcpManager *nm_dhcp_manager_get (void); + +const char *nm_dhcp_manager_get_config (NMDhcpManager *self); + +void nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, + const char *hostname); + +NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager, + const char *iface, + int ifindex, + const GByteArray *hwaddr, + const char *uuid, + guint32 priority, + gboolean send_hostname, + const char *dhcp_hostname, + const char *dhcp_fqdn, + const char *dhcp_client_id, + guint32 timeout, + const char *dhcp_anycast_addr, + const char *last_ip_address); + +NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager, + const char *iface, + int ifindex, + const GByteArray *hwaddr, + const struct in6_addr *ll_addr, + const char *uuid, + guint32 priority, + gboolean send_hostname, + const char *dhcp_hostname, + guint32 timeout, + const char *dhcp_anycast_addr, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + guint needed_prefixes); + +GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, + const char *iface, + int ifindex, + const char *uuid, + gboolean ipv6, + guint32 default_route_metric); + +/* For testing only */ +extern const char* nm_dhcp_helper_path; + +extern const NMDhcpClientFactory *const _nm_dhcp_manager_factories[3]; + +#endif /* __NETWORKMANAGER_DHCP_MANAGER_H__ */ diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c new file mode 100644 index 00000000..7067275b --- /dev/null +++ b/src/dhcp/nm-dhcp-systemd.c @@ -0,0 +1,1070 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2014 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-utils.h" +#include "nm-dhcp-utils.h" +#include "NetworkManagerUtils.h" +#include "platform/nm-platform.h" +#include "nm-dhcp-client-logging.h" +#include "systemd/nm-sd.h" + +/*****************************************************************************/ + +#define NM_TYPE_DHCP_SYSTEMD (nm_dhcp_systemd_get_type ()) +#define NM_DHCP_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemd)) +#define NM_DHCP_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdClass)) +#define NM_IS_DHCP_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_SYSTEMD)) +#define NM_IS_DHCP_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_SYSTEMD)) +#define NM_DHCP_SYSTEMD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdClass)) + +typedef struct _NMDhcpSystemd NMDhcpSystemd; +typedef struct _NMDhcpSystemdClass NMDhcpSystemdClass; + +static GType nm_dhcp_systemd_get_type (void); + +/*****************************************************************************/ + +typedef struct { + sd_dhcp_client *client4; + sd_dhcp6_client *client6; + char *lease_file; + + guint request_count; + + gboolean privacy; + gboolean info_only; +} NMDhcpSystemdPrivate; + +struct _NMDhcpSystemd { + NMDhcpClient parent; + NMDhcpSystemdPrivate _priv; +}; + +struct _NMDhcpSystemdClass { + NMDhcpClientClass parent; +}; + +G_DEFINE_TYPE (NMDhcpSystemd, nm_dhcp_systemd, NM_TYPE_DHCP_CLIENT) + +#define NM_DHCP_SYSTEMD_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcpSystemd, NM_IS_DHCP_SYSTEMD) + +/*****************************************************************************/ + +#define DHCP_OPTION_NIS_DOMAIN 40 +#define DHCP_OPTION_NIS_SERVERS 41 +#define DHCP_OPTION_DOMAIN_SEARCH 119 +#define DHCP_OPTION_MS_ROUTES 249 +#define DHCP_OPTION_WPAD 252 + +/* Internal values */ +#define DHCP_OPTION_IP_ADDRESS 1024 +#define DHCP_OPTION_EXPIRY 1025 +#define DHCP6_OPTION_IP_ADDRESS 1026 +#define DHCP6_OPTION_PREFIXLEN 1027 +#define DHCP6_OPTION_PREFERRED_LIFE 1028 +#define DHCP6_OPTION_MAX_LIFE 1029 +#define DHCP6_OPTION_STARTS 1030 +#define DHCP6_OPTION_LIFE_STARTS 1031 +#define DHCP6_OPTION_RENEW 1032 +#define DHCP6_OPTION_REBIND 1033 +#define DHCP6_OPTION_IAID 1034 + +typedef struct { + guint num; + const char *name; + gboolean include; +} ReqOption; + +#define REQPREFIX "requested_" + +static const ReqOption dhcp4_requests[] = { + { SD_DHCP_OPTION_SUBNET_MASK, REQPREFIX "subnet_mask", TRUE }, + { SD_DHCP_OPTION_TIME_OFFSET, REQPREFIX "time_offset", TRUE }, + { SD_DHCP_OPTION_ROUTER, REQPREFIX "routers", TRUE }, + { SD_DHCP_OPTION_DOMAIN_NAME_SERVER, REQPREFIX "domain_name_servers", TRUE }, + { SD_DHCP_OPTION_HOST_NAME, REQPREFIX "host_name", TRUE }, + { SD_DHCP_OPTION_DOMAIN_NAME, REQPREFIX "domain_name", TRUE }, + { SD_DHCP_OPTION_INTERFACE_MTU, REQPREFIX "interface_mtu", TRUE }, + { SD_DHCP_OPTION_BROADCAST, REQPREFIX "broadcast_address", TRUE }, + { SD_DHCP_OPTION_STATIC_ROUTE, REQPREFIX "static_routes", TRUE }, + { DHCP_OPTION_NIS_DOMAIN, REQPREFIX "nis_domain", TRUE }, + { DHCP_OPTION_NIS_SERVERS, REQPREFIX "nis_servers", TRUE }, + { SD_DHCP_OPTION_NTP_SERVER, REQPREFIX "ntp_servers", TRUE }, + { SD_DHCP_OPTION_SERVER_IDENTIFIER, REQPREFIX "dhcp_server_identifier", TRUE }, + { DHCP_OPTION_DOMAIN_SEARCH, REQPREFIX "domain_search", TRUE }, + { SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, REQPREFIX "rfc3442_classless_static_routes", TRUE }, + { DHCP_OPTION_MS_ROUTES, REQPREFIX "ms_classless_static_routes", TRUE }, + { DHCP_OPTION_WPAD, REQPREFIX "wpad", TRUE }, + + /* Internal values */ + { SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME, REQPREFIX "expiry", FALSE }, + { SD_DHCP_OPTION_CLIENT_IDENTIFIER, REQPREFIX "dhcp_client_identifier", FALSE }, + { DHCP_OPTION_IP_ADDRESS, REQPREFIX "ip_address", FALSE }, + { 0, NULL, FALSE } +}; + +static const ReqOption dhcp6_requests[] = { + { SD_DHCP6_OPTION_CLIENTID, REQPREFIX "dhcp6_client_id", TRUE }, + + /* Don't request server ID by default; some servers don't reply to + * Information Requests that request the Server ID. + */ + { SD_DHCP6_OPTION_SERVERID, REQPREFIX "dhcp6_server_id", FALSE }, + + { SD_DHCP6_OPTION_DNS_SERVERS, REQPREFIX "dhcp6_name_servers", TRUE }, + { SD_DHCP6_OPTION_DOMAIN_LIST, REQPREFIX "dhcp6_domain_search", TRUE }, + { SD_DHCP6_OPTION_SNTP_SERVERS, REQPREFIX "dhcp6_sntp_servers", TRUE }, + + /* Internal values */ + { DHCP6_OPTION_IP_ADDRESS, REQPREFIX "ip6_address", FALSE }, + { DHCP6_OPTION_PREFIXLEN, REQPREFIX "ip6_prefixlen", FALSE }, + { DHCP6_OPTION_PREFERRED_LIFE, REQPREFIX "preferred_life", FALSE }, + { DHCP6_OPTION_MAX_LIFE, REQPREFIX "max_life", FALSE }, + { DHCP6_OPTION_STARTS, REQPREFIX "starts", FALSE }, + { DHCP6_OPTION_LIFE_STARTS, REQPREFIX "life_starts", FALSE }, + { DHCP6_OPTION_RENEW, REQPREFIX "renew", FALSE }, + { DHCP6_OPTION_REBIND, REQPREFIX "rebind", FALSE }, + { DHCP6_OPTION_IAID, REQPREFIX "iaid", FALSE }, + { 0, NULL, FALSE } +}; + +static void +take_option (GHashTable *options, + const ReqOption *requests, + guint option, + char *value) +{ + guint i; + + g_return_if_fail (value != NULL); + + for (i = 0; requests[i].name; i++) { + if (requests[i].num == option) { + g_hash_table_insert (options, + (gpointer) (requests[i].name + NM_STRLEN (REQPREFIX)), + value); + break; + } + } + /* Option should always be found */ + g_assert (requests[i].name); +} + +static void +add_option (GHashTable *options, const ReqOption *requests, guint option, const char *value) +{ + if (options) + take_option (options, requests, option, g_strdup (value)); +} + +static void +add_option_u32 (GHashTable *options, const ReqOption *requests, guint option, guint32 value) +{ + if (options) + take_option (options, requests, option, g_strdup_printf ("%u", value)); +} + +static void +add_option_u64 (GHashTable *options, const ReqOption *requests, guint option, guint64 value) +{ + if (options) + take_option (options, requests, option, g_strdup_printf ("%" G_GUINT64_FORMAT, value)); +} + +static void +add_requests_to_options (GHashTable *options, const ReqOption *requests) +{ + guint i; + + for (i = 0; options && requests[i].name; i++) { + if (requests[i].include) + g_hash_table_insert (options, (gpointer) requests[i].name, g_strdup ("1")); + } +} + +#define LOG_LEASE(domain, ...) \ +G_STMT_START { \ + if (log_lease) { \ + _LOG2I ((domain), (iface), __VA_ARGS__); \ + } \ +} G_STMT_END + +static NMIP4Config * +lease_to_ip4_config (const char *iface, + int ifindex, + sd_dhcp_lease *lease, + GHashTable *options, + guint32 default_priority, + gboolean log_lease, + GError **error) +{ + NMIP4Config *ip4_config = NULL; + struct in_addr tmp_addr; + const struct in_addr *addr_list; + char buf[INET_ADDRSTRLEN]; + const char *str; + guint32 lifetime = 0, i; + NMPlatformIP4Address address; + GString *l; + gs_free sd_dhcp_route **routes = NULL; + guint16 mtu; + int r, num; + guint64 end_time; + const void *data; + gsize data_len; + gboolean metered = FALSE; + gboolean static_default_gateway = FALSE; + + g_return_val_if_fail (lease != NULL, NULL); + + ip4_config = nm_ip4_config_new (ifindex); + + /* Address */ + sd_dhcp_lease_get_address (lease, &tmp_addr); + memset (&address, 0, sizeof (address)); + address.address = tmp_addr.s_addr; + address.peer_address = tmp_addr.s_addr; + str = nm_utils_inet4_ntop (tmp_addr.s_addr, NULL); + LOG_LEASE (LOGD_DHCP4, " address %s", str); + add_option (options, dhcp4_requests, DHCP_OPTION_IP_ADDRESS, str); + + /* Prefix/netmask */ + sd_dhcp_lease_get_netmask (lease, &tmp_addr); + address.plen = nm_utils_ip4_netmask_to_prefix (tmp_addr.s_addr); + LOG_LEASE (LOGD_DHCP4, " plen %d", address.plen); + add_option (options, + dhcp4_requests, + SD_DHCP_OPTION_SUBNET_MASK, + nm_utils_inet4_ntop (tmp_addr.s_addr, NULL)); + + /* Lease time */ + sd_dhcp_lease_get_lifetime (lease, &lifetime); + address.timestamp = nm_utils_get_monotonic_timestamp_s (); + address.lifetime = address.preferred = lifetime; + end_time = (guint64) time (NULL) + lifetime; + LOG_LEASE (LOGD_DHCP4, " expires in %" G_GUINT32_FORMAT " seconds", lifetime); + add_option_u64 (options, + dhcp4_requests, + SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME, + end_time); + + address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; + nm_ip4_config_add_address (ip4_config, &address); + + /* DNS Servers */ + num = sd_dhcp_lease_get_dns (lease, &addr_list); + if (num > 0) { + l = g_string_sized_new (30); + for (i = 0; i < num; i++) { + if (addr_list[i].s_addr) { + nm_ip4_config_add_nameserver (ip4_config, addr_list[i].s_addr); + str = nm_utils_inet4_ntop (addr_list[i].s_addr, NULL); + LOG_LEASE (LOGD_DHCP4, " nameserver '%s'", str); + g_string_append_printf (l, "%s%s", l->len ? " " : "", str); + } + } + if (l->len) + add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME_SERVER, l->str); + g_string_free (l, TRUE); + } + + /* Domain Name */ + r = sd_dhcp_lease_get_domainname (lease, &str); + if (r == 0) { + /* Multiple domains sometimes stuffed into option 15 "Domain Name". + * As systemd escapes such characters, split them at \\032. */ + char **domains = g_strsplit (str, "\\032", 0); + char **s; + + for (s = domains; *s; s++) { + LOG_LEASE (LOGD_DHCP4, " domain name '%s'", *s); + nm_ip4_config_add_domain (ip4_config, *s); + } + g_strfreev (domains); + add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME, str); + } + + /* Hostname */ + r = sd_dhcp_lease_get_hostname (lease, &str); + if (r == 0) { + LOG_LEASE (LOGD_DHCP4, " hostname '%s'", str); + add_option (options, dhcp4_requests, SD_DHCP_OPTION_HOST_NAME, str); + } + + /* Routes */ + num = sd_dhcp_lease_get_routes (lease, &routes); + if (num > 0) { + l = g_string_sized_new (30); + for (i = 0; i < num; i++) { + NMPlatformIP4Route route = { 0 }; + const char *gw_str; + guint8 plen; + struct in_addr a; + + if (sd_dhcp_route_get_destination (routes[i], &a) < 0) + continue; + route.network = a.s_addr; + + if ( sd_dhcp_route_get_destination_prefix_length (routes[i], &plen) < 0 + || plen > 32) + continue; + route.plen = plen; + + if (sd_dhcp_route_get_gateway (routes[i], &a) < 0) + continue; + route.gateway = a.s_addr; + + if (route.plen) { + route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; + route.metric = default_priority; + nm_ip4_config_add_route (ip4_config, &route); + + str = nm_utils_inet4_ntop (route.network, buf); + gw_str = nm_utils_inet4_ntop (route.gateway, NULL); + LOG_LEASE (LOGD_DHCP4, " static route %s/%d gw %s", str, route.plen, gw_str); + + g_string_append_printf (l, "%s%s/%d %s", l->len ? " " : "", str, route.plen, gw_str); + } else { + if (!static_default_gateway) { + static_default_gateway = TRUE; + nm_ip4_config_set_gateway (ip4_config, route.gateway); + + str = nm_utils_inet4_ntop (route.gateway, NULL); + LOG_LEASE (LOGD_DHCP4, " gateway %s", str); + add_option (options, dhcp4_requests, SD_DHCP_OPTION_ROUTER, str); + } + } + } + if (l->len) + add_option (options, dhcp4_requests, SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, l->str); + g_string_free (l, TRUE); + } + + /* If the DHCP server returns both a Classless Static Routes option and a + * Router option, the DHCP client MUST ignore the Router option [RFC 3442]. + * Be more lenient and ignore the Router option only if Classless Static + * Routes contain a default gateway (as other DHCP backends do). + */ + /* Gateway */ + if (!static_default_gateway) { + r = sd_dhcp_lease_get_router (lease, &tmp_addr); + if (r == 0) { + nm_ip4_config_set_gateway (ip4_config, tmp_addr.s_addr); + str = nm_utils_inet4_ntop (tmp_addr.s_addr, NULL); + LOG_LEASE (LOGD_DHCP4, " gateway %s", str); + add_option (options, dhcp4_requests, SD_DHCP_OPTION_ROUTER, str); + } + } + + /* MTU */ + r = sd_dhcp_lease_get_mtu (lease, &mtu); + if (r == 0 && mtu) { + nm_ip4_config_set_mtu (ip4_config, mtu, NM_IP_CONFIG_SOURCE_DHCP); + add_option_u32 (options, dhcp4_requests, SD_DHCP_OPTION_INTERFACE_MTU, mtu); + LOG_LEASE (LOGD_DHCP4, " mtu %u", mtu); + } + + /* NTP servers */ + num = sd_dhcp_lease_get_ntp (lease, &addr_list); + if (num > 0) { + l = g_string_sized_new (30); + for (i = 0; i < num; i++) { + str = nm_utils_inet4_ntop (addr_list[i].s_addr, buf); + LOG_LEASE (LOGD_DHCP4, " ntp server '%s'", str); + g_string_append_printf (l, "%s%s", l->len ? " " : "", str); + } + add_option (options, dhcp4_requests, SD_DHCP_OPTION_NTP_SERVER, l->str); + g_string_free (l, TRUE); + } + + r = sd_dhcp_lease_get_vendor_specific (lease, &data, &data_len); + if (r >= 0) + metered = !!memmem (data, data_len, "ANDROID_METERED", NM_STRLEN ("ANDROID_METERED")); + nm_ip4_config_set_metered (ip4_config, metered); + + return ip4_config; +} + +/*****************************************************************************/ + +static char * +get_leasefile_path (const char *iface, const char *uuid, gboolean ipv6) +{ + return g_strdup_printf (NMSTATEDIR "/internal%s-%s-%s.lease", + ipv6 ? "6" : "", + uuid, + iface); +} + +static GSList * +nm_dhcp_systemd_get_lease_ip_configs (const char *iface, + int ifindex, + const char *uuid, + gboolean ipv6, + guint32 default_route_metric) +{ + GSList *leases = NULL; + gs_free char *path = NULL; + sd_dhcp_lease *lease = NULL; + NMIP4Config *ip4_config; + int r; + + if (ipv6) + return NULL; + + path = get_leasefile_path (iface, uuid, FALSE); + r = dhcp_lease_load (&lease, path); + if (r == 0 && lease) { + ip4_config = lease_to_ip4_config (iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL); + if (ip4_config) + leases = g_slist_append (leases, ip4_config); + sd_dhcp_lease_unref (lease); + } + + return leases; +} + +/*****************************************************************************/ + +static void +_save_client_id (NMDhcpSystemd *self, + uint8_t type, + const uint8_t *client_id, + size_t len) +{ + gs_unref_bytes GBytes *b = NULL; + gs_free char *buf = NULL; + + g_return_if_fail (self != NULL); + g_return_if_fail (client_id != NULL); + g_return_if_fail (len > 0); + + if (!nm_dhcp_client_get_client_id (NM_DHCP_CLIENT (self))) { + buf = g_malloc (len + 1); + buf[0] = type; + memcpy (buf + 1, client_id, len); + b = g_bytes_new (buf, len + 1); + nm_dhcp_client_set_client_id (NM_DHCP_CLIENT (self), b); + } +} + +static void +bound4_handle (NMDhcpSystemd *self) +{ + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); + const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self)); + sd_dhcp_lease *lease; + NMIP4Config *ip4_config; + GHashTable *options; + GError *error = NULL; + int r; + + r = sd_dhcp_client_get_lease (priv->client4, &lease); + if (r < 0 || !lease) { + _LOGW ("no lease!"); + nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); + return; + } + + _LOGD ("lease available"); + + options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); + ip4_config = lease_to_ip4_config (iface, + nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), + lease, + options, + nm_dhcp_client_get_priority (NM_DHCP_CLIENT (self)), + TRUE, + &error); + if (ip4_config) { + const uint8_t *client_id = NULL; + size_t client_id_len = 0; + uint8_t type = 0; + + add_requests_to_options (options, dhcp4_requests); + dhcp_lease_save (lease, priv->lease_file); + + sd_dhcp_client_get_client_id(priv->client4, &type, &client_id, &client_id_len); + if (client_id) + _save_client_id (self, type, client_id, client_id_len); + + nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), + NM_DHCP_STATE_BOUND, + G_OBJECT (ip4_config), + options); + } else { + _LOGW ("%s", error->message); + nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); + g_clear_error (&error); + } + + g_hash_table_destroy (options); + g_clear_object (&ip4_config); +} + +static void +dhcp_event_cb (sd_dhcp_client *client, int event, gpointer user_data) +{ + NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); + + g_assert (priv->client4 == client); + + _LOGD ("client event %d", event); + + switch (event) { + case SD_DHCP_CLIENT_EVENT_EXPIRED: + nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_EXPIRE, NULL, NULL); + break; + case SD_DHCP_CLIENT_EVENT_STOP: + nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_FAIL, NULL, NULL); + break; + case SD_DHCP_CLIENT_EVENT_RENEW: + case SD_DHCP_CLIENT_EVENT_IP_CHANGE: + case SD_DHCP_CLIENT_EVENT_IP_ACQUIRE: + bound4_handle (self); + break; + default: + _LOGW ("unhandled DHCP event %d", event); + break; + } +} + +static guint16 +get_arp_type (const GByteArray *hwaddr) +{ + if (hwaddr->len == ETH_ALEN) + return ARPHRD_ETHER; + else if (hwaddr->len == INFINIBAND_ALEN) + return ARPHRD_INFINIBAND; + else + return ARPHRD_NONE; +} + +static gboolean +ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address) +{ + NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); + const char *iface = nm_dhcp_client_get_iface (client); + const GByteArray *hwaddr; + sd_dhcp_lease *lease = NULL; + GBytes *override_client_id; + const uint8_t *client_id = NULL; + size_t client_id_len = 0; + struct in_addr last_addr = { 0 }; + const char *hostname, *fqdn; + int r, i; + gboolean success = FALSE; + guint16 arp_type; + + g_assert (priv->client4 == NULL); + g_assert (priv->client6 == NULL); + + g_free (priv->lease_file); + priv->lease_file = get_leasefile_path (iface, nm_dhcp_client_get_uuid (client), FALSE); + + r = sd_dhcp_client_new (&priv->client4); + if (r < 0) { + _LOGW ("failed to create client (%d)", r); + return FALSE; + } + + _LOGT ("dhcp-client4: set %p", priv->client4); + + r = sd_dhcp_client_attach_event (priv->client4, NULL, 0); + if (r < 0) { + _LOGW ("failed to attach event (%d)", r); + goto error; + } + + hwaddr = nm_dhcp_client_get_hw_addr (client); + if (hwaddr) { + arp_type= get_arp_type (hwaddr); + if (arp_type == ARPHRD_NONE) { + _LOGW ("failed to determine ARP type"); + goto error; + } + + r = sd_dhcp_client_set_mac (priv->client4, + hwaddr->data, + hwaddr->len, + arp_type); + if (r < 0) { + _LOGW ("failed to set MAC address (%d)", r); + goto error; + } + } + + r = sd_dhcp_client_set_ifindex (priv->client4, nm_dhcp_client_get_ifindex (client)); + if (r < 0) { + _LOGW ("failed to set ififindex (%d)", r); + goto error; + } + + r = sd_dhcp_client_set_callback (priv->client4, dhcp_event_cb, client); + if (r < 0) { + _LOGW ("failed to set callback (%d)", r); + goto error; + } + + r = sd_dhcp_client_set_request_broadcast (priv->client4, true); + if (r < 0) { + _LOGW ("failed to enable broadcast mode (%d)", r); + goto error; + } + + dhcp_lease_load (&lease, priv->lease_file); + + if (last_ip4_address) + inet_pton (AF_INET, last_ip4_address, &last_addr); + else if (lease) + sd_dhcp_lease_get_address (lease, &last_addr); + + if (last_addr.s_addr) { + r = sd_dhcp_client_set_request_address (priv->client4, &last_addr); + if (r < 0) { + _LOGW ("failed to set last IPv4 address (%d)", r); + goto error; + } + } + + override_client_id = nm_dhcp_client_get_client_id (client); + if (override_client_id) { + client_id = g_bytes_get_data (override_client_id, &client_id_len); + g_assert (client_id && client_id_len); + sd_dhcp_client_set_client_id (priv->client4, + client_id[0], + client_id + 1, + client_id_len - 1); + } else if (lease) { + r = sd_dhcp_lease_get_client_id (lease, (const void **) &client_id, &client_id_len); + if (r == 0 && client_id_len) { + sd_dhcp_client_set_client_id (priv->client4, + client_id[0], + client_id + 1, + client_id_len - 1); + _save_client_id (NM_DHCP_SYSTEMD (client), + client_id[0], + client_id + 1, + client_id_len - 1); + } + } + + + /* Add requested options */ + for (i = 0; dhcp4_requests[i].name; i++) { + if (dhcp4_requests[i].include) + sd_dhcp_client_set_request_option (priv->client4, dhcp4_requests[i].num); + } + + hostname = nm_dhcp_client_get_hostname (client); + if (hostname) { + char *prefix, *dot; + + prefix = strdup (hostname); + dot = strchr (prefix, '.'); + /* get rid of the domain */ + if (dot) + *dot = '\0'; + + r = sd_dhcp_client_set_hostname (priv->client4, prefix); + free (prefix); + + if (r < 0) { + _LOGW ("failed to set DHCP hostname (%d)", r); + goto error; + } + } + + fqdn = nm_dhcp_client_get_fqdn (client); + if (fqdn) { + r = sd_dhcp_client_set_hostname (priv->client4, fqdn); + if (r < 0) { + _LOGW ("failed to set DHCP FQDN (%d)", r); + goto error; + } + } + + r = sd_dhcp_client_start (priv->client4); + if (r < 0) { + _LOGW ("failed to start client (%d)", r); + goto error; + } + + nm_dhcp_client_start_timeout (client); + + success = TRUE; + +error: + sd_dhcp_lease_unref (lease); + if (!success) + priv->client4 = sd_dhcp_client_unref (priv->client4); + return success; +} + +static NMIP6Config * +lease_to_ip6_config (const char *iface, + int ifindex, + sd_dhcp6_lease *lease, + GHashTable *options, + gboolean log_lease, + gboolean info_only, + GError **error) +{ + struct in6_addr tmp_addr, *dns; + uint32_t lft_pref, lft_valid; + NMIP6Config *ip6_config; + const char *addr_str; + char **domains; + GString *str; + int num, i; + gint32 ts; + + g_return_val_if_fail (lease, NULL); + ip6_config = nm_ip6_config_new (ifindex); + ts = nm_utils_get_monotonic_timestamp_s (); + str = g_string_sized_new (30); + + /* Addresses */ + sd_dhcp6_lease_reset_address_iter (lease); + while (sd_dhcp6_lease_get_address (lease, &tmp_addr, &lft_pref, &lft_valid) >= 0) { + NMPlatformIP6Address address = { + .plen = 128, + .address = tmp_addr, + .timestamp = ts, + .lifetime = lft_valid, + .preferred = lft_pref, + .addr_source = NM_IP_CONFIG_SOURCE_DHCP, + }; + + nm_ip6_config_add_address (ip6_config, &address); + + addr_str = nm_utils_inet6_ntop (&tmp_addr, NULL); + g_string_append_printf (str, "%s%s", str->len ? " " : "", addr_str); + + LOG_LEASE (LOGD_DHCP6, + " address %s", + nm_platform_ip6_address_to_string (&address, NULL, 0)); + }; + + if (str->len) { + add_option (options, dhcp6_requests, DHCP6_OPTION_IP_ADDRESS, str->str); + g_string_set_size (str , 0); + } + + if (!info_only && nm_ip6_config_get_num_addresses (ip6_config) == 0) { + g_string_free (str, TRUE); + g_object_unref (ip6_config); + g_set_error_literal (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "no address received in managed mode"); + return NULL; + } + + /* DNS servers */ + num = sd_dhcp6_lease_get_dns (lease, &dns); + if (num > 0) { + for (i = 0; i < num; i++) { + nm_ip6_config_add_nameserver (ip6_config, &dns[i]); + addr_str = nm_utils_inet6_ntop (&dns[i], NULL); + g_string_append_printf (str, "%s%s", str->len ? " " : "", addr_str); + LOG_LEASE (LOGD_DHCP6, " nameserver %s", addr_str); + } + add_option (options, dhcp6_requests, SD_DHCP6_OPTION_DNS_SERVERS, str->str); + g_string_set_size (str, 0); + } + + /* Search domains */ + num = sd_dhcp6_lease_get_domains (lease, &domains); + if (num > 0) { + for (i = 0; i < num; i++) { + nm_ip6_config_add_search (ip6_config, domains[i]); + g_string_append_printf (str, "%s%s", str->len ? " " : "", domains[i]); + LOG_LEASE (LOGD_DHCP6, " domain name '%s'", domains[i]); + } + add_option (options, dhcp6_requests, SD_DHCP6_OPTION_DOMAIN_LIST, str->str); + g_string_set_size (str, 0); + } + + g_string_free (str, TRUE); + + return ip6_config; +} + +static void +bound6_handle (NMDhcpSystemd *self) +{ + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); + const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self)); + gs_unref_object NMIP6Config *ip6_config = NULL; + gs_unref_hashtable GHashTable *options = NULL; + gs_free_error GError *error = NULL; + sd_dhcp6_lease *lease; + int r; + + r = sd_dhcp6_client_get_lease (priv->client6, &lease); + if (r < 0 || !lease) { + _LOGW (" no lease!"); + nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); + return; + } + + _LOGD ("lease available"); + + options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); + ip6_config = lease_to_ip6_config (iface, + nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), + lease, + options, + TRUE, + priv->info_only, + &error); + + if (ip6_config) { + nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), + NM_DHCP_STATE_BOUND, + G_OBJECT (ip6_config), + options); + } else { + _LOGW ("%s", error->message); + nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL); + } +} + +static void +dhcp6_event_cb (sd_dhcp6_client *client, int event, gpointer user_data) +{ + NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); + + g_assert (priv->client6 == client); + + _LOGD ("client event %d", event); + + switch (event) { + case SD_DHCP6_CLIENT_EVENT_RETRANS_MAX: + nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_TIMEOUT, NULL, NULL); + break; + case SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE: + case SD_DHCP6_CLIENT_EVENT_STOP: + nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_FAIL, NULL, NULL); + break; + case SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE: + case SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST: + bound6_handle (self); + break; + default: + _LOGW ("unhandled event %d", event); + break; + } +} + +static gboolean +ip6_start (NMDhcpClient *client, + const char *dhcp_anycast_addr, + const struct in6_addr *ll_addr, + gboolean info_only, + NMSettingIP6ConfigPrivacy privacy, + const GByteArray *duid, + guint needed_prefixes) +{ + NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); + const char *iface = nm_dhcp_client_get_iface (client); + const GByteArray *hwaddr; + int r, i; + + g_assert (priv->client4 == NULL); + g_assert (priv->client6 == NULL); + g_return_val_if_fail (duid != NULL, FALSE); + + g_free (priv->lease_file); + priv->lease_file = get_leasefile_path (iface, nm_dhcp_client_get_uuid (client), TRUE); + priv->info_only = info_only; + + r = sd_dhcp6_client_new (&priv->client6); + if (r < 0) { + _LOGW ("failed to create client (%d)", r); + return FALSE; + } + + if (needed_prefixes > 0) { + _LOGW ("dhcp-client6: prefix delegation not yet supported, won't supply %d prefixes\n", + needed_prefixes); + } + + _LOGT ("dhcp-client6: set %p", priv->client6); + + if (info_only) + sd_dhcp6_client_set_information_request (priv->client6, 1); + + /* NM stores the entire DUID which includes the uint16 "type", while systemd + * wants the type passed separately from the following data. + */ + r = sd_dhcp6_client_set_duid (priv->client6, + ntohs (((const guint16 *) duid->data)[0]), + duid->data + 2, + duid->len - 2); + if (r < 0) { + _LOGW ("failed to set DUID (%d)", r); + return FALSE; + } + + r = sd_dhcp6_client_attach_event (priv->client6, NULL, 0); + if (r < 0) { + _LOGW ("failed to attach event (%d)", r); + goto error; + } + + hwaddr = nm_dhcp_client_get_hw_addr (client); + if (hwaddr) { + r = sd_dhcp6_client_set_mac (priv->client6, + hwaddr->data, + hwaddr->len, + get_arp_type (hwaddr)); + if (r < 0) { + _LOGW ("failed to set MAC address (%d)", r); + goto error; + } + } + + r = sd_dhcp6_client_set_ifindex (priv->client6, nm_dhcp_client_get_ifindex (client)); + if (r < 0) { + _LOGW ("failed to set ifindex (%d)", r); + goto error; + } + + r = sd_dhcp6_client_set_callback (priv->client6, dhcp6_event_cb, client); + if (r < 0) { + _LOGW ("failed to set callback (%d)", r); + goto error; + } + + /* Add requested options */ + for (i = 0; dhcp6_requests[i].name; i++) { + if (dhcp6_requests[i].include) + sd_dhcp6_client_set_request_option (priv->client6, dhcp6_requests[i].num); + } + + r = sd_dhcp6_client_set_local_address (priv->client6, ll_addr); + if (r < 0) { + _LOGW ("failed to set local address (%d)", r); + goto error; + } + + r = sd_dhcp6_client_start (priv->client6); + if (r < 0) { + _LOGW ("failed to start client (%d)", r); + goto error; + } + + nm_dhcp_client_start_timeout (client); + + return TRUE; + +error: + sd_dhcp6_client_unref (priv->client6); + priv->client6 = NULL; + return FALSE; +} + +static void +stop (NMDhcpClient *client, gboolean release, const GByteArray *duid) +{ + NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client); + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self); + int r = 0; + + _LOGT ("dhcp-client%d: stop %p", + priv->client4 ? '4' : '6', + priv->client4 ? (gpointer) priv->client4 : (gpointer) priv->client6); + + if (priv->client4) { + sd_dhcp_client_set_callback (priv->client4, NULL, NULL); + r = sd_dhcp_client_stop (priv->client4); + } else if (priv->client6) { + sd_dhcp6_client_set_callback (priv->client6, NULL, NULL); + r = sd_dhcp6_client_stop (priv->client6); + } + + if (r) + _LOGW ("failed to stop client (%d)", r); +} + +/*****************************************************************************/ + +static void +nm_dhcp_systemd_init (NMDhcpSystemd *self) +{ +} + +static void +dispose (GObject *object) +{ + NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE ((NMDhcpSystemd *) object); + + g_clear_pointer (&priv->lease_file, g_free); + + if (priv->client4) { + sd_dhcp_client_stop (priv->client4); + sd_dhcp_client_unref (priv->client4); + priv->client4 = NULL; + } + + if (priv->client6) { + sd_dhcp6_client_stop (priv->client6); + sd_dhcp6_client_unref (priv->client6); + priv->client6 = NULL; + } + + G_OBJECT_CLASS (nm_dhcp_systemd_parent_class)->dispose (object); +} + +static void +nm_dhcp_systemd_class_init (NMDhcpSystemdClass *sdhcp_class) +{ + NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS (sdhcp_class); + GObjectClass *object_class = G_OBJECT_CLASS (sdhcp_class); + + object_class->dispose = dispose; + + client_class->ip4_start = ip4_start; + client_class->ip6_start = ip6_start; + client_class->stop = stop; +} + +const NMDhcpClientFactory _nm_dhcp_client_factory_internal = { + .name = "internal", + .get_type = nm_dhcp_systemd_get_type, + .get_path = NULL, + .get_lease_ip_configs = nm_dhcp_systemd_get_lease_ip_configs, +}; diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c new file mode 100644 index 00000000..e020ca33 --- /dev/null +++ b/src/dhcp/nm-dhcp-utils.c @@ -0,0 +1,779 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2010 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include +#include +#include +#include + +#include "nm-dhcp-utils.h" +#include "nm-utils.h" +#include "NetworkManagerUtils.h" +#include "platform/nm-platform.h" +#include "nm-dhcp-client-logging.h" +#include "nm-core-internal.h" + +/*****************************************************************************/ + +static gboolean +ip4_process_dhcpcd_rfc3442_routes (const char *iface, + const char *str, + guint32 priority, + NMIP4Config *ip4_config, + guint32 *gwaddr) +{ + char **routes, **r; + gboolean have_routes = FALSE; + + routes = g_strsplit (str, " ", 0); + if (g_strv_length (routes) == 0) + goto out; + + if ((g_strv_length (routes) % 2) != 0) { + _LOG2W (LOGD_DHCP4, iface, " classless static routes provided, but invalid"); + goto out; + } + + for (r = routes; *r; r += 2) { + char *slash; + NMPlatformIP4Route route; + int rt_cidr = 32; + guint32 rt_addr, rt_route; + + slash = strchr(*r, '/'); + if (slash) { + *slash = '\0'; + errno = 0; + rt_cidr = strtol (slash + 1, NULL, 10); + if (errno || rt_cidr > 32) { + _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route cidr: '%s'", slash + 1); + continue; + } + } + if (inet_pton (AF_INET, *r, &rt_addr) <= 0) { + _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route address: '%s'", *r); + continue; + } + if (inet_pton (AF_INET, *(r + 1), &rt_route) <= 0) { + _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route gateway: '%s'", *(r + 1)); + continue; + } + + have_routes = TRUE; + if (rt_cidr == 0 && rt_addr == 0) { + /* FIXME: how to handle multiple routers? */ + *gwaddr = rt_route; + } else { + _LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1)); + memset (&route, 0, sizeof (route)); + route.network = rt_addr; + route.plen = rt_cidr; + route.gateway = rt_route; + route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; + route.metric = priority; + nm_ip4_config_add_route (ip4_config, &route); + } + } + +out: + g_strfreev (routes); + return have_routes; +} + +static const char ** +process_dhclient_rfc3442_route (const char **octets, + NMPlatformIP4Route *route, + gboolean *success) +{ + const char **o = octets; + int addr_len = 0, i = 0; + long int tmp; + char *next_hop; + guint32 tmp_addr; + + *success = FALSE; + + if (!*o) + return o; /* no prefix */ + + tmp = strtol (*o, NULL, 10); + if (tmp < 0 || tmp > 32) /* 32 == max IP4 prefix length */ + return o; + + memset (route, 0, sizeof (*route)); + route->plen = tmp; + o++; + + if (tmp > 0) + addr_len = ((tmp - 1) / 8) + 1; + + /* ensure there's at least the address + next hop left */ + if (g_strv_length ((char **) o) < addr_len + 4) + goto error; + + if (tmp) { + const char *addr[4] = { "0", "0", "0", "0" }; + char *str_addr; + + for (i = 0; i < addr_len; i++) + addr[i] = *o++; + + str_addr = g_strjoin (".", addr[0], addr[1], addr[2], addr[3], NULL); + if (inet_pton (AF_INET, str_addr, &tmp_addr) <= 0) { + g_free (str_addr); + goto error; + } + g_free (str_addr); + tmp_addr &= nm_utils_ip4_prefix_to_netmask ((guint32) tmp); + route->network = tmp_addr; + } + + /* Handle next hop */ + next_hop = g_strjoin (".", o[0], o[1], o[2], o[3], NULL); + if (inet_pton (AF_INET, next_hop, &tmp_addr) <= 0) { + g_free (next_hop); + goto error; + } + route->gateway = tmp_addr; + g_free (next_hop); + + *success = TRUE; + return o + 4; /* advance to past the next hop */ + +error: + return o; +} + +static gboolean +ip4_process_dhclient_rfc3442_routes (const char *iface, + const char *str, + guint32 priority, + NMIP4Config *ip4_config, + guint32 *gwaddr) +{ + char **octets, **o; + gboolean have_routes = FALSE; + NMPlatformIP4Route route; + gboolean success; + + o = octets = g_strsplit_set (str, " .", 0); + if (g_strv_length (octets) < 5) { + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str); + goto out; + } + + while (*o) { + memset (&route, 0, sizeof (route)); + o = (char **) process_dhclient_rfc3442_route ((const char **) o, &route, &success); + if (!success) { + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes"); + break; + } + + have_routes = TRUE; + if (!route.plen) { + /* gateway passed as classless static route */ + *gwaddr = route.gateway; + } else { + char addr[INET_ADDRSTRLEN]; + + /* normal route */ + route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; + route.metric = priority; + nm_ip4_config_add_route (ip4_config, &route); + + _LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s", + nm_utils_inet4_ntop (route.network, addr), route.plen, + nm_utils_inet4_ntop (route.gateway, NULL)); + } + } + +out: + g_strfreev (octets); + return have_routes; +} + +static gboolean +ip4_process_classless_routes (const char *iface, + GHashTable *options, + guint32 priority, + NMIP4Config *ip4_config, + guint32 *gwaddr) +{ + const char *str, *p; + + g_return_val_if_fail (options != NULL, FALSE); + g_return_val_if_fail (ip4_config != NULL, FALSE); + + *gwaddr = 0; + + /* dhcpd/dhclient in Fedora has support for rfc3442 implemented using a + * slightly different format: + * + * option classless-static-routes = array of (destination-descriptor ip-address); + * + * which results in: + * + * 0 192.168.0.113 25.129.210.177.132 192.168.0.113 7.2 10.34.255.6 + * + * dhcpcd supports classless static routes natively and uses this same + * option identifier with the following format: + * + * 192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41 + */ + str = g_hash_table_lookup (options, "classless_static_routes"); + + /* dhclient doesn't have actual support for rfc3442 classless static routes + * upstream. Thus, people resort to defining the option in dhclient.conf + * and using arbitrary formats like so: + * + * option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; + * + * See https://lists.isc.org/pipermail/dhcp-users/2008-December/007629.html + */ + if (!str) + str = g_hash_table_lookup (options, "rfc3442_classless_static_routes"); + + /* Microsoft version; same as rfc3442 but with a different option # (249) */ + if (!str) + str = g_hash_table_lookup (options, "ms_classless_static_routes"); + + if (!str || !strlen (str)) + return FALSE; + + p = str; + while (*p) { + if (!g_ascii_isdigit (*p) && (*p != ' ') && (*p != '.') && (*p != '/')) { + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str); + return FALSE; + } + p++; + }; + + if (strchr (str, '/')) { + /* dhcpcd format */ + return ip4_process_dhcpcd_rfc3442_routes (iface, str, priority, ip4_config, gwaddr); + } + + return ip4_process_dhclient_rfc3442_routes (iface, str, priority, ip4_config, gwaddr); +} + +static void +process_classful_routes (const char *iface, + GHashTable *options, + guint32 priority, + NMIP4Config *ip4_config) +{ + const char *str; + char **searches, **s; + + str = g_hash_table_lookup (options, "static_routes"); + if (!str) + return; + + searches = g_strsplit (str, " ", 0); + if ((g_strv_length (searches) % 2)) { + _LOG2I (LOGD_DHCP, iface, " static routes provided, but invalid"); + goto out; + } + + for (s = searches; *s; s += 2) { + NMPlatformIP4Route route; + guint32 rt_addr, rt_route; + + if (inet_pton (AF_INET, *s, &rt_addr) <= 0) { + _LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route address: '%s'", *s); + continue; + } + if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) { + _LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route gateway: '%s'", *(s + 1)); + continue; + } + + // FIXME: ensure the IP address and route are sane + + memset (&route, 0, sizeof (route)); + route.network = rt_addr; + /* RFC 2132, updated by RFC 3442: + The Static Routes option (option 33) does not provide a subnet mask + for each route - it is assumed that the subnet mask is implicit in + whatever network number is specified in each route entry */ + route.plen = nm_utils_ip4_get_default_prefix (rt_addr); + if (rt_addr & ~nm_utils_ip4_prefix_to_netmask (route.plen)) { + /* RFC 943: target not "this network"; using host routing */ + route.plen = 32; + } + route.gateway = rt_route; + route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; + route.metric = priority; + + nm_ip4_config_add_route (ip4_config, &route); + _LOG2I (LOGD_DHCP, iface, " static route %s", + nm_platform_ip4_route_to_string (&route, NULL, 0)); + } + +out: + g_strfreev (searches); +} + +static void +process_domain_search (const char *iface, + const char *str, + GFunc add_func, + gpointer user_data) +{ + char **searches, **s; + char *unescaped, *p; + int i; + + g_return_if_fail (str != NULL); + g_return_if_fail (add_func != NULL); + + p = unescaped = g_strdup (str); + do { + p = strstr (p, "\\032"); + if (!p) + break; + + /* Clear the escaped space with real spaces */ + for (i = 0; i < 4; i++) + *p++ = ' '; + } while (*p++); + + if (strchr (unescaped, '\\')) { + _LOG2W (LOGD_DHCP, iface, " invalid domain search: '%s'", unescaped); + goto out; + } + + searches = g_strsplit (unescaped, " ", 0); + for (s = searches; *s; s++) { + if (strlen (*s)) { + _LOG2I (LOGD_DHCP, iface, " domain search '%s'", *s); + add_func (*s, user_data); + } + } + g_strfreev (searches); + +out: + g_free (unescaped); +} + +static void +ip4_add_domain_search (gpointer data, gpointer user_data) +{ + nm_ip4_config_add_search (NM_IP4_CONFIG (user_data), (const char *) data); +} + +NMIP4Config * +nm_dhcp_utils_ip4_config_from_options (int ifindex, + const char *iface, + GHashTable *options, + guint32 priority) +{ + NMIP4Config *ip4_config = NULL; + guint32 tmp_addr; + in_addr_t addr; + NMPlatformIP4Address address; + char *str = NULL; + guint32 gwaddr = 0; + guint8 plen = 0; + + g_return_val_if_fail (options != NULL, NULL); + + ip4_config = nm_ip4_config_new (ifindex); + memset (&address, 0, sizeof (address)); + address.timestamp = nm_utils_get_monotonic_timestamp_s (); + + str = g_hash_table_lookup (options, "ip_address"); + if (str && (inet_pton (AF_INET, str, &addr) > 0)) + _LOG2I (LOGD_DHCP4, iface, " address %s", str); + else + goto error; + + str = g_hash_table_lookup (options, "subnet_mask"); + if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) { + plen = nm_utils_ip4_netmask_to_prefix (tmp_addr); + _LOG2I (LOGD_DHCP4, iface, " plen %d (%s)", plen, str); + } else { + /* Get default netmask for the IP according to appropriate class. */ + plen = nm_utils_ip4_get_default_prefix (addr); + _LOG2I (LOGD_DHCP4, iface, " plen %d (default)", plen); + } + nm_platform_ip4_address_set_addr (&address, addr, plen); + + /* Routes: if the server returns classless static routes, we MUST ignore + * the 'static_routes' option. + */ + if (!ip4_process_classless_routes (iface, options, priority, ip4_config, &gwaddr)) + process_classful_routes (iface, options, priority, ip4_config); + + if (gwaddr) { + _LOG2I (LOGD_DHCP4, iface, " gateway %s", nm_utils_inet4_ntop (gwaddr, NULL)); + nm_ip4_config_set_gateway (ip4_config, gwaddr); + } else { + /* If the gateway wasn't provided as a classless static route with a + * subnet length of 0, try to find it using the old-style 'routers' option. + */ + str = g_hash_table_lookup (options, "routers"); + if (str) { + char **routers = g_strsplit (str, " ", 0); + char **s; + + for (s = routers; *s; s++) { + /* FIXME: how to handle multiple routers? */ + if (inet_pton (AF_INET, *s, &gwaddr) > 0) { + nm_ip4_config_set_gateway (ip4_config, gwaddr); + _LOG2I (LOGD_DHCP4, iface, " gateway %s", *s); + break; + } else + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid gateway '%s'", *s); + } + g_strfreev (routers); + } + } + + /* + * RFC 2132, section 9.7 + * DHCP clients use the contents of the 'server identifier' field + * as the destination address for any DHCP messages unicast to + * the DHCP server. + * + * Some ISP's provide leases from central servers that are on + * different subnets that the address offered. If the host + * does not configure the interface as the default route, the + * dhcp server may not be reachable via unicast, and a host + * specific route is needed. + **/ + str = g_hash_table_lookup (options, "dhcp_server_identifier"); + if (str) { + if (inet_pton (AF_INET, str, &tmp_addr) > 0) { + + _LOG2I (LOGD_DHCP4, iface, " server identifier %s", str); + if ( nm_utils_ip4_address_clear_host_address(tmp_addr, address.plen) != nm_utils_ip4_address_clear_host_address(address.address, address.plen) + && !nm_ip4_config_get_direct_route_for_host (ip4_config, tmp_addr)) { + /* DHCP server not on assigned subnet and the no direct route was returned. Add route */ + NMPlatformIP4Route route = { 0 }; + + route.network = tmp_addr; + route.plen = 32; + /* this will be a device route if gwaddr is 0 */ + route.gateway = gwaddr; + route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; + route.metric = priority; + nm_ip4_config_add_route (ip4_config, &route); + _LOG2D (LOGD_IP, iface, "adding route for server identifier: %s", + nm_platform_ip4_route_to_string (&route, NULL, 0)); + } + } + else + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid server identifier '%s'", str); + } + + str = g_hash_table_lookup (options, "dhcp_lease_time"); + if (str) { + address.lifetime = address.preferred = strtoul (str, NULL, 10); + _LOG2I (LOGD_DHCP4, iface, " lease time %u", address.lifetime); + } + + address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; + nm_ip4_config_add_address (ip4_config, &address); + + str = g_hash_table_lookup (options, "host_name"); + if (str) + _LOG2I (LOGD_DHCP4, iface, " hostname '%s'", str); + + str = g_hash_table_lookup (options, "domain_name_servers"); + if (str) { + char **dns = g_strsplit (str, " ", 0); + char **s; + + for (s = dns; *s; s++) { + if (inet_pton (AF_INET, *s, &tmp_addr) > 0) { + if (tmp_addr) { + nm_ip4_config_add_nameserver (ip4_config, tmp_addr); + _LOG2I (LOGD_DHCP4, iface, " nameserver '%s'", *s); + } + } else + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid nameserver '%s'", *s); + } + g_strfreev (dns); + } + + str = g_hash_table_lookup (options, "domain_name"); + if (str) { + char **domains = g_strsplit (str, " ", 0); + char **s; + + for (s = domains; *s; s++) { + _LOG2I (LOGD_DHCP4, iface, " domain name '%s'", *s); + nm_ip4_config_add_domain (ip4_config, *s); + } + g_strfreev (domains); + } + + str = g_hash_table_lookup (options, "domain_search"); + if (str) + process_domain_search (iface, str, ip4_add_domain_search, ip4_config); + + str = g_hash_table_lookup (options, "netbios_name_servers"); + if (str) { + char **nbns = g_strsplit (str, " ", 0); + char **s; + + for (s = nbns; *s; s++) { + if (inet_pton (AF_INET, *s, &tmp_addr) > 0) { + if (tmp_addr) { + nm_ip4_config_add_wins (ip4_config, tmp_addr); + _LOG2I (LOGD_DHCP4, iface, " wins '%s'", *s); + } + } else + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid WINS server '%s'", *s); + } + g_strfreev (nbns); + } + + str = g_hash_table_lookup (options, "interface_mtu"); + if (str) { + int int_mtu; + + errno = 0; + int_mtu = strtol (str, NULL, 10); + if ((errno == EINVAL) || (errno == ERANGE)) + goto error; + + if (int_mtu > 576) + nm_ip4_config_set_mtu (ip4_config, int_mtu, NM_IP_CONFIG_SOURCE_DHCP); + } + + str = g_hash_table_lookup (options, "nis_domain"); + if (str) { + _LOG2I (LOGD_DHCP4, iface, " NIS domain '%s'", str); + nm_ip4_config_set_nis_domain (ip4_config, str); + } + + str = g_hash_table_lookup (options, "nis_servers"); + if (str) { + char **nis = g_strsplit (str, " ", 0); + char **s; + + for (s = nis; *s; s++) { + if (inet_pton (AF_INET, *s, &tmp_addr) > 0) { + if (tmp_addr) { + nm_ip4_config_add_nis_server (ip4_config, tmp_addr); + _LOG2I (LOGD_DHCP4, iface, " nis '%s'", *s); + } + } else + _LOG2W (LOGD_DHCP4, iface, "ignoring invalid NIS server '%s'", *s); + } + g_strfreev (nis); + } + + str = g_hash_table_lookup (options, "vendor_encapsulated_options"); + nm_ip4_config_set_metered (ip4_config, str && strstr (str, "ANDROID_METERED")); + + return ip4_config; + +error: + g_object_unref (ip4_config); + return NULL; +} + +/*****************************************************************************/ + +static void +ip6_add_domain_search (gpointer data, gpointer user_data) +{ + nm_ip6_config_add_search (NM_IP6_CONFIG (user_data), (const char *) data); +} + +NMPlatformIP6Address +nm_dhcp_utils_ip6_prefix_from_options (GHashTable *options) +{ + gs_strfreev gchar **split_addr = NULL; + NMPlatformIP6Address address = { 0, }; + struct in6_addr tmp_addr; + char *str = NULL; + int prefix; + + g_return_val_if_fail (options != NULL, address); + + str = g_hash_table_lookup (options, "ip6_prefix"); + if (!str) + return address; + + split_addr = g_strsplit (str, "/", 2); + if (split_addr[0] == NULL && split_addr[1] == NULL) { + nm_log_warn (LOGD_DHCP6, "DHCP returned prefix without length '%s'", str); + return address; + } + + if (!inet_pton (AF_INET6, split_addr[0], &tmp_addr)) { + nm_log_warn (LOGD_DHCP6, "DHCP returned invalid prefix '%s'", str); + return address; + } + + prefix = _nm_utils_ascii_str_to_int64 (split_addr[1], 10, 0, 128, -1); + if (prefix < 0) { + nm_log_warn (LOGD_DHCP6, "DHCP returned prefix with invalid length '%s'", str); + return address; + } + + address.address = tmp_addr; + address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; + address.plen = prefix; + address.timestamp = nm_utils_get_monotonic_timestamp_s (); + + str = g_hash_table_lookup (options, "max_life"); + if (str) + address.lifetime = strtoul (str, NULL, 10); + + str = g_hash_table_lookup (options, "preferred_life"); + if (str) + address.preferred = strtoul (str, NULL, 10); + + return address; +} + +NMIP6Config * +nm_dhcp_utils_ip6_config_from_options (int ifindex, + const char *iface, + GHashTable *options, + guint32 priority, + gboolean info_only) +{ + NMIP6Config *ip6_config = NULL; + struct in6_addr tmp_addr; + NMPlatformIP6Address address; + char *str = NULL; + + g_return_val_if_fail (options != NULL, NULL); + + memset (&address, 0, sizeof (address)); + address.plen = 128; + address.timestamp = nm_utils_get_monotonic_timestamp_s (); + + ip6_config = nm_ip6_config_new (ifindex); + + str = g_hash_table_lookup (options, "max_life"); + if (str) { + address.lifetime = strtoul (str, NULL, 10); + _LOG2I (LOGD_DHCP6, iface, " valid_lft %u", address.lifetime); + } + + str = g_hash_table_lookup (options, "preferred_life"); + if (str) { + address.preferred = strtoul (str, NULL, 10); + _LOG2I (LOGD_DHCP6, iface, " preferred_lft %u", address.preferred); + } + + str = g_hash_table_lookup (options, "ip6_address"); + if (str) { + if (!inet_pton (AF_INET6, str, &tmp_addr)) { + _LOG2W (LOGD_DHCP6, iface, "(%s): DHCP returned invalid address '%s'", + iface, str); + goto error; + } + + address.address = tmp_addr; + address.addr_source = NM_IP_CONFIG_SOURCE_DHCP; + nm_ip6_config_add_address (ip6_config, &address); + _LOG2I (LOGD_DHCP6, iface, " address %s", str); + } else if (info_only == FALSE) { + /* No address in Managed mode is a hard error */ + goto error; + } + + str = g_hash_table_lookup (options, "host_name"); + if (str) + _LOG2I (LOGD_DHCP6, iface, " hostname '%s'", str); + + str = g_hash_table_lookup (options, "dhcp6_name_servers"); + if (str) { + char **dns = g_strsplit (str, " ", 0); + char **s; + + for (s = dns; *s; s++) { + if (inet_pton (AF_INET6, *s, &tmp_addr) > 0) { + if (!IN6_IS_ADDR_UNSPECIFIED (&tmp_addr)) { + nm_ip6_config_add_nameserver (ip6_config, &tmp_addr); + _LOG2I (LOGD_DHCP6, iface, " nameserver '%s'", *s); + } + } else + _LOG2W (LOGD_DHCP6, iface, "ignoring invalid nameserver '%s'", *s); + } + g_strfreev (dns); + } + + str = g_hash_table_lookup (options, "dhcp6_domain_search"); + if (str) + process_domain_search (iface, str, ip6_add_domain_search, ip6_config); + + return ip6_config; + +error: + g_object_unref (ip6_config); + return NULL; +} + +char * +nm_dhcp_utils_duid_to_string (const GByteArray *duid) +{ + g_return_val_if_fail (duid != NULL, NULL); + + return _nm_utils_bin2str (duid->data, duid->len, FALSE); +} + +/** + * nm_dhcp_utils_client_id_string_to_bytes: + * @client_id: the client ID string + * + * Accepts either a hex string ("aa:bb:cc") representing a binary client ID + * (the first byte is assumed to be the 'type' field per RFC 2132 section 9.14), + * or a string representing a non-hardware-address client ID, in which case + * the 'type' field is set to 0. + * + * Returns: the binary client ID suitable for sending over the wire + * to the DHCP server. + */ +GBytes * +nm_dhcp_utils_client_id_string_to_bytes (const char *client_id) +{ + GBytes *bytes = NULL; + guint len; + char *c; + + g_return_val_if_fail (client_id && client_id[0], NULL); + + /* Try as hex encoded */ + if (strchr (client_id, ':')) + bytes = nm_utils_hexstr2bin (client_id); + if (!bytes) { + /* Fall back to string */ + len = strlen (client_id); + c = g_malloc (len + 1); + c[0] = 0; /* type: non-hardware address per RFC 2132 section 9.14 */ + memcpy (c + 1, client_id, len); + bytes = g_bytes_new_take (c, len + 1); + } + + return bytes; +} + diff --git a/src/dhcp/nm-dhcp-utils.h b/src/dhcp/nm-dhcp-utils.h new file mode 100644 index 00000000..b45c5e89 --- /dev/null +++ b/src/dhcp/nm-dhcp-utils.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2014 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DHCP_UTILS_H__ +#define __NETWORKMANAGER_DHCP_UTILS_H__ + +#include + +#include +#include + +NMIP4Config *nm_dhcp_utils_ip4_config_from_options (int ifindex, + const char *iface, + GHashTable *options, + guint priority); + +NMIP6Config *nm_dhcp_utils_ip6_config_from_options (int ifindex, + const char *iface, + GHashTable *options, + guint priority, + gboolean info_only); + +NMPlatformIP6Address nm_dhcp_utils_ip6_prefix_from_options (GHashTable *options); + +char * nm_dhcp_utils_duid_to_string (const GByteArray *duid); + +GBytes * nm_dhcp_utils_client_id_string_to_bytes (const char *client_id); + +#endif /* __NETWORKMANAGER_DHCP_UTILS_H__ */ + diff --git a/src/dhcp/tests/leases/basic.leases b/src/dhcp/tests/leases/basic.leases new file mode 100644 index 00000000..703d9247 --- /dev/null +++ b/src/dhcp/tests/leases/basic.leases @@ -0,0 +1,31 @@ +lease { + interface "wlan0"; + fixed-address 192.168.1.180; + option subnet-mask 255.255.255.0; + option routers 192.168.1.1; + option dhcp-lease-time 600; + option dhcp-message-type 5; + option domain-name-servers 192.168.1.1; + option dhcp-server-identifier 192.168.1.1; + option broadcast-address 192.168.1.255; + renew 5 2013/11/01 19:56:15; + rebind 5 2013/11/01 20:00:44; + expire 5 2013/11/01 20:01:59; +} +lease { + interface "wlan0"; + fixed-address 10.77.52.141; + option subnet-mask 255.0.0.0; + option dhcp-lease-time 1200; + option routers 10.77.52.254; + option dhcp-message-type 5; + option dhcp-server-identifier 10.77.52.254; + option domain-name-servers 8.8.8.8,8.8.4.4; + option dhcp-renewal-time 600; + option dhcp-rebinding-time 1050; + option domain-name "morriesguest.local"; + renew 5 2013/11/01 20:01:08; + rebind 5 2013/11/01 20:05:00; + expire 5 2013/11/01 20:06:15; +} + diff --git a/src/dhcp/tests/leases/malformed1.leases b/src/dhcp/tests/leases/malformed1.leases new file mode 100644 index 00000000..401d982a --- /dev/null +++ b/src/dhcp/tests/leases/malformed1.leases @@ -0,0 +1,15 @@ +# missing fixed-address option +lease { + interface "wlan0"; + option subnet-mask 255.255.255.0; + option routers 192.168.1.1; + option dhcp-lease-time 600; + option dhcp-message-type 5; + option domain-name-servers 192.168.1.1; + option dhcp-server-identifier 192.168.1.1; + option broadcast-address 192.168.1.255; + renew 5 2013/11/01 19:56:15; + rebind 5 2013/11/01 20:00:44; + expire 5 2013/11/01 20:01:59; +} + diff --git a/src/dhcp/tests/leases/malformed2.leases b/src/dhcp/tests/leases/malformed2.leases new file mode 100644 index 00000000..adf5f6de --- /dev/null +++ b/src/dhcp/tests/leases/malformed2.leases @@ -0,0 +1,15 @@ +# missing routers option +lease { + interface "wlan0"; + fixed-address 192.168.1.180; + option subnet-mask 255.255.255.0; + option dhcp-lease-time 600; + option dhcp-message-type 5; + option domain-name-servers 192.168.1.1; + option dhcp-server-identifier 192.168.1.1; + option broadcast-address 192.168.1.255; + renew 5 2013/11/01 19:56:15; + rebind 5 2013/11/01 20:00:44; + expire 5 2013/11/01 20:01:59; +} + diff --git a/src/dhcp/tests/leases/malformed3.leases b/src/dhcp/tests/leases/malformed3.leases new file mode 100644 index 00000000..a2afc8b6 --- /dev/null +++ b/src/dhcp/tests/leases/malformed3.leases @@ -0,0 +1,15 @@ +# missing expire time +lease { + interface "wlan0"; + fixed-address 192.168.1.180; + option subnet-mask 255.255.255.0; + option routers 192.168.1.1; + option dhcp-lease-time 600; + option dhcp-message-type 5; + option domain-name-servers 192.168.1.1; + option dhcp-server-identifier 192.168.1.1; + option broadcast-address 192.168.1.255; + renew 5 2013/11/01 19:56:15; + rebind 5 2013/11/01 20:00:44; +} + diff --git a/src/dhcp/tests/test-dhclient-commented-duid.leases b/src/dhcp/tests/test-dhclient-commented-duid.leases new file mode 100644 index 00000000..3e46ae7d --- /dev/null +++ b/src/dhcp/tests/test-dhclient-commented-duid.leases @@ -0,0 +1,2 @@ +#default-duid "\000\001\000\001\030y\246\023`g \354Lp"; + diff --git a/src/dhcp/tests/test-dhclient-duid.leases b/src/dhcp/tests/test-dhclient-duid.leases new file mode 100644 index 00000000..229331d4 --- /dev/null +++ b/src/dhcp/tests/test-dhclient-duid.leases @@ -0,0 +1,2 @@ +default-duid "\000\001\000\001\030y\246\023`g \354Lp"; + diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c new file mode 100644 index 00000000..82f0c080 --- /dev/null +++ b/src/dhcp/tests/test-dhcp-dhclient.c @@ -0,0 +1,915 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2010 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include +#include +#include + +#include "NetworkManagerUtils.h" +#include "dhcp/nm-dhcp-dhclient-utils.h" +#include "dhcp/nm-dhcp-utils.h" +#include "nm-utils.h" +#include "nm-ip4-config.h" +#include "platform/nm-platform.h" + +#include "nm-test-utils-core.h" + +#define DEBUG 1 + +static void +test_config (const char *orig, + const char *expected, + gboolean ipv6, + const char *hostname, + const char *fqdn, + const char *dhcp_client_id, + GBytes *expected_new_client_id, + const char *iface, + const char *anycast_addr) +{ + gs_free char *new = NULL; + gs_unref_bytes GBytes *client_id = NULL; + gs_unref_bytes GBytes *new_client_id = NULL; + + if (dhcp_client_id) { + client_id = nm_dhcp_utils_client_id_string_to_bytes (dhcp_client_id); + g_assert (client_id); + } + + new = nm_dhcp_dhclient_create_config (iface, + ipv6, + client_id, + anycast_addr, + hostname, + fqdn, + "/path/to/dhclient.conf", + orig, + &new_client_id); + g_assert (new != NULL); + +#if DEBUG + if ( strlen (new) != strlen (expected) + || strcmp (new, expected)) { + g_message ("\n- NEW ---------------------------------\n" + "%s" + "+ EXPECTED ++++++++++++++++++++++++++++++\n" + "%s" + "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + new, expected); + } +#endif + g_assert_cmpstr (new, ==, expected); + + if (expected_new_client_id) { + g_assert (new_client_id); + g_assert (g_bytes_equal (new_client_id, expected_new_client_id)); + } else + g_assert (new_client_id == NULL); +} + +/*****************************************************************************/ + +static const char *orig_missing_expected = \ + "# Created by NetworkManager\n" + "\n\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_orig_missing (void) +{ + test_config (NULL, orig_missing_expected, FALSE, NULL, NULL, NULL, NULL, "eth0", NULL); +} + +/*****************************************************************************/ + +static const char *override_client_id_orig = \ + "send dhcp-client-identifier 00:30:04:20:7A:08;\n"; + +static const char *override_client_id_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n" + "send dhcp-client-identifier 11:22:33:44:55:66; # added by NetworkManager\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_override_client_id (void) +{ + test_config (override_client_id_orig, override_client_id_expected, + FALSE, NULL, NULL, + "11:22:33:44:55:66", + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *quote_client_id_expected = \ + "# Created by NetworkManager\n" + "\n" + "send dhcp-client-identifier \"1234\"; # added by NetworkManager\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_quote_client_id (void) +{ + test_config (NULL, quote_client_id_expected, + FALSE, NULL, NULL, + "1234", + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *ascii_client_id_expected = \ + "# Created by NetworkManager\n" + "\n" + "send dhcp-client-identifier \"qb:cd:ef:12:34:56\"; # added by NetworkManager\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_ascii_client_id (void) +{ + test_config (NULL, ascii_client_id_expected, + FALSE, NULL, NULL, + "qb:cd:ef:12:34:56", + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *hex_single_client_id_expected = \ + "# Created by NetworkManager\n" + "\n" + "send dhcp-client-identifier ab:cd:0e:12:34:56; # added by NetworkManager\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_hex_single_client_id (void) +{ + test_config (NULL, hex_single_client_id_expected, + FALSE, NULL, NULL, + "ab:cd:e:12:34:56", + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *existing_hex_client_id_orig = \ + "send dhcp-client-identifier 00:30:04:20:7A:08;\n"; + +static const char *existing_hex_client_id_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n" + "send dhcp-client-identifier 00:30:04:20:7A:08;\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_existing_hex_client_id (void) +{ + gs_unref_bytes GBytes *new_client_id = NULL; + const guint8 bytes[] = { 0x00, 0x30, 0x04,0x20, 0x7A, 0x08 }; + + new_client_id = g_bytes_new (bytes, sizeof (bytes)); + test_config (existing_hex_client_id_orig, existing_hex_client_id_expected, + FALSE, NULL, NULL, + NULL, + new_client_id, + "eth0", + NULL); +} + +/*****************************************************************************/ + +#define EACID "qb:cd:ef:12:34:56" + +static const char *existing_ascii_client_id_orig = \ + "send dhcp-client-identifier \"" EACID "\";\n"; + +static const char *existing_ascii_client_id_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n" + "send dhcp-client-identifier \"" EACID "\";\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_existing_ascii_client_id (void) +{ + gs_unref_bytes GBytes *new_client_id = NULL; + char buf[NM_STRLEN (EACID) + 1] = { 0 }; + + memcpy (buf + 1, EACID, NM_STRLEN (EACID)); + new_client_id = g_bytes_new (buf, sizeof (buf)); + test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected, + FALSE, NULL, NULL, + NULL, + new_client_id, + "eth0", + NULL); +} +/*****************************************************************************/ + +static const char *fqdn_expected = \ + "# Created by NetworkManager\n" + "\n" + "send fqdn.fqdn \"foo.bar.com\"; # added by NetworkManager\n" + "send fqdn.encoded on;\n" + "send fqdn.server-update on;\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n\n"; + +static void +test_fqdn (void) +{ + test_config (NULL, fqdn_expected, + FALSE, NULL, + "foo.bar.com", NULL, + NULL, + "eth0", + NULL); +} + +static const char *fqdn_options_override_orig = \ + "\n" + "send fqdn.fqdn \"foobar.com\"\n" /* NM must ignore this ... */ + "send fqdn.encoded off;\n" /* ... and honor these */ + "send fqdn.server-update off;\n"; + +static const char *fqdn_options_override_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n" + "send fqdn.fqdn \"example2.com\"; # added by NetworkManager\n" + "send fqdn.encoded on;\n" + "send fqdn.server-update on;\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n" + "# FQDN options from /path/to/dhclient.conf\n" + "send fqdn.encoded off;\n" + "send fqdn.server-update off;\n\n"; + +static void +test_fqdn_options_override (void) +{ + test_config (fqdn_options_override_orig, + fqdn_options_override_expected, + FALSE, NULL, + "example2.com", NULL, + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *override_hostname_orig = \ + "send host-name \"foobar\";\n"; + +static const char *override_hostname_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n" + "send host-name \"blahblah\"; # added by NetworkManager\n" + "\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_override_hostname (void) +{ + test_config (override_hostname_orig, override_hostname_expected, + FALSE, "blahblah", NULL, + NULL, + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *override_hostname6_orig = \ + "send fqdn.fqdn \"foobar\";\n"; + +static const char *override_hostname6_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n" + "send fqdn.fqdn \"blahblah.local\"; # added by NetworkManager\n" + "send fqdn.encoded on;\n" + "send fqdn.server-update on;\n" + "\n" + "also request dhcp6.name-servers;\n" + "also request dhcp6.domain-search;\n" + "also request dhcp6.client-id;\n" + "\n"; + +static void +test_override_hostname6 (void) +{ + test_config (override_hostname6_orig, override_hostname6_expected, + TRUE, "blahblah.local", NULL, + NULL, + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *nonfqdn_hostname6_expected = \ + "# Created by NetworkManager\n" + "\n" + "also request dhcp6.name-servers;\n" + "also request dhcp6.domain-search;\n" + "also request dhcp6.client-id;\n" + "\n"; + +static void +test_nonfqdn_hostname6 (void) +{ + /* Non-FQDN hostname can't be used with dhclient */ + test_config (NULL, nonfqdn_hostname6_expected, + TRUE, "blahblah", + NULL, NULL, + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *existing_alsoreq_orig = \ + "also request something;\n" + "also request another-thing;\n" + ; + +static const char *existing_alsoreq_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request something;\n" + "also request another-thing;\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_existing_alsoreq (void) +{ + test_config (existing_alsoreq_orig, existing_alsoreq_expected, + FALSE, NULL, + NULL, + NULL, + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *existing_req_orig = \ + "request something;\n" + "also request some-other-thing;\n" + "request another-thing;\n" + "also request yet-another-thing;\n" + ; + +static const char *existing_req_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request another-thing;\n" + "also request yet-another-thing;\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_existing_req (void) +{ + test_config (existing_req_orig, existing_req_expected, + FALSE, NULL, + NULL, + NULL, + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static const char *existing_multiline_alsoreq_orig = \ + "also request something another-thing yet-another-thing\n" + " foobar baz blah;\n" + ; + +static const char *existing_multiline_alsoreq_expected = \ + "# Created by NetworkManager\n" + "# Merged from /path/to/dhclient.conf\n" + "\n\n" + "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" + "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" + "option wpad code 252 = string;\n" + "\n" + "also request something;\n" + "also request another-thing;\n" + "also request yet-another-thing;\n" + "also request foobar;\n" + "also request baz;\n" + "also request blah;\n" + "also request rfc3442-classless-static-routes;\n" + "also request ms-classless-static-routes;\n" + "also request static-routes;\n" + "also request wpad;\n" + "also request ntp-servers;\n" + "\n"; + +static void +test_existing_multiline_alsoreq (void) +{ + test_config (existing_multiline_alsoreq_orig, existing_multiline_alsoreq_expected, + FALSE, NULL, NULL, + NULL, + NULL, + "eth0", + NULL); +} + +/*****************************************************************************/ + +static void +test_one_duid (const char *escaped, const guint8 *unescaped, guint len) +{ + GByteArray *t; + char *w; + + t = nm_dhcp_dhclient_unescape_duid (escaped); + g_assert (t); + g_assert_cmpint (t->len, ==, len); + g_assert_cmpint (memcmp (t->data, unescaped, len), ==, 0); + g_byte_array_free (t, TRUE); + + t = g_byte_array_sized_new (len); + g_byte_array_append (t, unescaped, len); + w = nm_dhcp_dhclient_escape_duid (t); + g_assert (w); + g_assert_cmpint (strlen (escaped), ==, strlen (w)); + g_assert_cmpstr (escaped, ==, w); + + g_byte_array_free (t, TRUE); + g_free (w); +} + +static void +test_duids (void) +{ + const guint8 test1_u[] = { 0x00, 0x01, 0x00, 0x01, 0x13, 0x6f, 0x13, 0x6e, + 0x00, 0x22, 0xfa, 0x8c, 0xd6, 0xc2 }; + const char *test1_s = "\\000\\001\\000\\001\\023o\\023n\\000\\\"\\372\\214\\326\\302"; + + const guint8 test2_u[] = { 0x00, 0x01, 0x00, 0x01, 0x17, 0x57, 0xee, 0x39, + 0x00, 0x23, 0x15, 0x08, 0x7E, 0xac }; + const char *test2_s = "\\000\\001\\000\\001\\027W\\3569\\000#\\025\\010~\\254"; + + const guint8 test3_u[] = { 0x00, 0x01, 0x00, 0x01, 0x17, 0x58, 0xe8, 0x58, + 0x00, 0x23, 0x15, 0x08, 0x7e, 0xac }; + const char *test3_s = "\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254"; + + const guint8 test4_u[] = { 0x00, 0x01, 0x00, 0x01, 0x15, 0xd5, 0x31, 0x97, + 0x00, 0x16, 0xeb, 0x04, 0x45, 0x18 }; + const char *test4_s = "\\000\\001\\000\\001\\025\\3251\\227\\000\\026\\353\\004E\\030"; + + const char *bad_s = "\\000\\001\\000\\001\\425\\3251\\227\\000\\026\\353\\004E\\030"; + + test_one_duid (test1_s, test1_u, sizeof (test1_u)); + test_one_duid (test2_s, test2_u, sizeof (test2_u)); + test_one_duid (test3_s, test3_u, sizeof (test3_u)); + test_one_duid (test4_s, test4_u, sizeof (test4_u)); + + /* Invalid octal digit */ + g_assert (nm_dhcp_dhclient_unescape_duid (bad_s) == NULL); +} + +static void +test_read_duid_from_leasefile (void) +{ + const guint8 expected[] = { 0x00, 0x01, 0x00, 0x01, 0x18, 0x79, 0xa6, + 0x13, 0x60, 0x67, 0x20, 0xec, 0x4c, 0x70 }; + GByteArray *duid; + GError *error = NULL; + + duid = nm_dhcp_dhclient_read_duid (TESTDIR "/test-dhclient-duid.leases", &error); + g_assert_no_error (error); + g_assert (duid); + g_assert_cmpint (duid->len, ==, sizeof (expected)); + g_assert_cmpint (memcmp (duid->data, expected, duid->len), ==, 0); + + g_byte_array_free (duid, TRUE); +} + +static void +test_read_commented_duid_from_leasefile (void) +{ + GByteArray *duid; + GError *error = NULL; + + duid = nm_dhcp_dhclient_read_duid (TESTDIR "/test-dhclient-commented-duid.leases", &error); + g_assert_no_error (error); + g_assert (duid == NULL); +} + +static void +test_write_duid (void) +{ + const char *duid = "\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254"; + const char *expected_contents = "default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n"; + GError *error = NULL; + char *contents = NULL; + gboolean success; + const char *path = "test-dhclient-write-duid.leases"; + + success = nm_dhcp_dhclient_save_duid (path, duid, &error); + g_assert_no_error (error); + g_assert (success); + + success = g_file_get_contents (path, &contents, NULL, &error); + g_assert_no_error (error); + g_assert (success); + + unlink (path); + g_assert_cmpstr (expected_contents, ==, contents); + + g_free (contents); +} + +static void +test_write_existing_duid (void) +{ + const char *duid = "\\000\\001\\000\\001\\023o\\023n\\000\\\"\\372\\214\\326\\302"; + const char *expected_contents = "default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n"; + GError *error = NULL; + char *contents = NULL; + gboolean success; + const char *path = "test-dhclient-write-existing-duid.leases"; + + success = g_file_set_contents (path, expected_contents, -1, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save other DUID; should be a no-op */ + success = nm_dhcp_dhclient_save_duid (path, duid, &error); + g_assert_no_error (error); + g_assert (success); + + /* reread original contents */ + success = g_file_get_contents (path, &contents, NULL, &error); + g_assert_no_error (error); + g_assert (success); + + unlink (path); + g_assert_cmpstr (expected_contents, ==, contents); + + g_free (contents); +} + +static void +test_write_existing_commented_duid (void) +{ + #define DUID "\\000\\001\\000\\001\\023o\\023n\\000\\\"\\372\\214\\326\\302" + #define ORIG_CONTENTS "#default-duid \"\\000\\001\\000\\001\\027X\\350X\\000#\\025\\010~\\254\";\n" + const char *expected_contents = \ + "default-duid \"" DUID "\";\n" + ORIG_CONTENTS; + GError *error = NULL; + char *contents = NULL; + gboolean success; + const char *path = "test-dhclient-write-existing-commented-duid.leases"; + + success = g_file_set_contents (path, ORIG_CONTENTS, -1, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save other DUID; should be a no-op */ + success = nm_dhcp_dhclient_save_duid (path, DUID, &error); + g_assert_no_error (error); + g_assert (success); + + /* reread original contents */ + success = g_file_get_contents (path, &contents, NULL, &error); + g_assert_no_error (error); + g_assert (success); + + unlink (path); + g_assert_cmpstr (expected_contents, ==, contents); + + g_free (contents); +} + +/*****************************************************************************/ + +static void +test_read_lease_ip4_config_basic (void) +{ + GError *error = NULL; + char *contents = NULL; + gboolean success; + const char *path = TESTDIR "/leases/basic.leases"; + GSList *leases; + GDateTime *now; + NMIP4Config *config; + const NMPlatformIP4Address *addr; + guint32 expected_addr; + + success = g_file_get_contents (path, &contents, NULL, &error); + g_assert_no_error (error); + g_assert (success); + + /* Date from before the least expiration */ + now = g_date_time_new_utc (2013, 11, 1, 19, 55, 32); + leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); + g_assert_cmpint (g_slist_length (leases), ==, 2); + + /* IP4Config #1 */ + config = g_slist_nth_data (leases, 0); + g_assert (NM_IS_IP4_CONFIG (config)); + + /* Address */ + g_assert_cmpint (nm_ip4_config_get_num_addresses (config), ==, 1); + g_assert (inet_aton ("192.168.1.180", (struct in_addr *) &expected_addr)); + addr = nm_ip4_config_get_address (config, 0); + g_assert_cmpint (addr->address, ==, expected_addr); + g_assert_cmpint (addr->peer_address, ==, expected_addr); + g_assert_cmpint (addr->plen, ==, 24); + + /* Gateway */ + g_assert (inet_aton ("192.168.1.1", (struct in_addr *) &expected_addr)); + g_assert_cmpint (nm_ip4_config_get_gateway (config), ==, expected_addr); + + /* DNS */ + g_assert_cmpint (nm_ip4_config_get_num_nameservers (config), ==, 1); + g_assert (inet_aton ("192.168.1.1", (struct in_addr *) &expected_addr)); + g_assert_cmpint (nm_ip4_config_get_nameserver (config, 0), ==, expected_addr); + + g_assert_cmpint (nm_ip4_config_get_num_domains (config), ==, 0); + + /* IP4Config #2 */ + config = g_slist_nth_data (leases, 1); + g_assert (NM_IS_IP4_CONFIG (config)); + + /* Address */ + g_assert_cmpint (nm_ip4_config_get_num_addresses (config), ==, 1); + g_assert (inet_aton ("10.77.52.141", (struct in_addr *) &expected_addr)); + addr = nm_ip4_config_get_address (config, 0); + g_assert_cmpint (addr->address, ==, expected_addr); + g_assert_cmpint (addr->peer_address, ==, expected_addr); + g_assert_cmpint (addr->plen, ==, 8); + + /* Gateway */ + g_assert (inet_aton ("10.77.52.254", (struct in_addr *) &expected_addr)); + g_assert_cmpint (nm_ip4_config_get_gateway (config), ==, expected_addr); + + /* DNS */ + g_assert_cmpint (nm_ip4_config_get_num_nameservers (config), ==, 2); + g_assert (inet_aton ("8.8.8.8", (struct in_addr *) &expected_addr)); + g_assert_cmpint (nm_ip4_config_get_nameserver (config, 0), ==, expected_addr); + g_assert (inet_aton ("8.8.4.4", (struct in_addr *) &expected_addr)); + g_assert_cmpint (nm_ip4_config_get_nameserver (config, 1), ==, expected_addr); + + /* Domains */ + g_assert_cmpint (nm_ip4_config_get_num_domains (config), ==, 1); + g_assert_cmpstr (nm_ip4_config_get_domain (config, 0), ==, "morriesguest.local"); + + g_slist_free_full (leases, g_object_unref); + g_date_time_unref (now); + g_free (contents); +} + +static void +test_read_lease_ip4_config_expired (void) +{ + GError *error = NULL; + char *contents = NULL; + gboolean success; + const char *path = TESTDIR "/leases/basic.leases"; + GSList *leases; + GDateTime *now; + + success = g_file_get_contents (path, &contents, NULL, &error); + g_assert_no_error (error); + g_assert (success); + + /* Date from *after* the lease expiration */ + now = g_date_time_new_utc (2013, 12, 1, 19, 55, 32); + leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); + g_assert (leases == NULL); + + g_date_time_unref (now); + g_free (contents); +} + +static void +test_read_lease_ip4_config_expect_failure (gconstpointer user_data) +{ + GError *error = NULL; + char *contents = NULL; + gboolean success; + GSList *leases; + GDateTime *now; + + success = g_file_get_contents ((const char *) user_data, &contents, NULL, &error); + g_assert_no_error (error); + g_assert (success); + + /* Date from before the least expiration */ + now = g_date_time_new_utc (2013, 11, 1, 1, 1, 1); + leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); + g_assert (leases == NULL); + + g_date_time_unref (now); + g_free (contents); +} + +/*****************************************************************************/ + +NMTST_DEFINE (); + +int +main (int argc, char **argv) +{ + nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT"); + + g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing); + g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id); + g_test_add_func ("/dhcp/dhclient/quote_client_id", test_quote_client_id); + g_test_add_func ("/dhcp/dhclient/ascii_client_id", test_ascii_client_id); + g_test_add_func ("/dhcp/dhclient/hex_single_client_id", test_hex_single_client_id); + g_test_add_func ("/dhcp/dhclient/existing-hex-client-id", test_existing_hex_client_id); + g_test_add_func ("/dhcp/dhclient/existing-ascii-client-id", test_existing_ascii_client_id); + g_test_add_func ("/dhcp/dhclient/fqdn", test_fqdn); + g_test_add_func ("/dhcp/dhclient/fqdn_options_override", test_fqdn_options_override); + g_test_add_func ("/dhcp/dhclient/override_hostname", test_override_hostname); + g_test_add_func ("/dhcp/dhclient/override_hostname6", test_override_hostname6); + g_test_add_func ("/dhcp/dhclient/nonfqdn_hostname6", test_nonfqdn_hostname6); + g_test_add_func ("/dhcp/dhclient/existing_req", test_existing_req); + g_test_add_func ("/dhcp/dhclient/existing_alsoreq", test_existing_alsoreq); + g_test_add_func ("/dhcp/dhclient/existing_multiline_alsoreq", test_existing_multiline_alsoreq); + g_test_add_func ("/dhcp/dhclient/duids", test_duids); + + g_test_add_func ("/dhcp/dhclient/read_duid_from_leasefile", test_read_duid_from_leasefile); + g_test_add_func ("/dhcp/dhclient/read_commented_duid_from_leasefile", test_read_commented_duid_from_leasefile); + + g_test_add_func ("/dhcp/dhclient/write_duid", test_write_duid); + g_test_add_func ("/dhcp/dhclient/write_existing_duid", test_write_existing_duid); + g_test_add_func ("/dhcp/dhclient/write_existing_commented_duid", test_write_existing_commented_duid); + + g_test_add_func ("/dhcp/dhclient/leases/ip4-config/basic", test_read_lease_ip4_config_basic); + g_test_add_func ("/dhcp/dhclient/leases/ip4-config/expired", test_read_lease_ip4_config_expired); + g_test_add_data_func ("/dhcp/dhclient/leases/ip4-config/missing-address", + TESTDIR "/leases/malformed1.leases", + test_read_lease_ip4_config_expect_failure); + g_test_add_data_func ("/dhcp/dhclient/leases/ip4-config/missing-gateway", + TESTDIR "/leases/malformed2.leases", + test_read_lease_ip4_config_expect_failure); + g_test_add_data_func ("/dhcp/dhclient/leases/ip4-config/missing-expire", + TESTDIR "/leases/malformed3.leases", + test_read_lease_ip4_config_expect_failure); + + return g_test_run (); +} + diff --git a/src/dhcp/tests/test-dhcp-utils.c b/src/dhcp/tests/test-dhcp-utils.c new file mode 100644 index 00000000..ffd63493 --- /dev/null +++ b/src/dhcp/tests/test-dhcp-utils.c @@ -0,0 +1,748 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 - 2014 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include +#include +#include + +#include "nm-utils.h" + +#include "dhcp/nm-dhcp-utils.h" +#include "platform/nm-platform.h" + +#include "nm-test-utils-core.h" + +typedef struct { + const char *name; + const char *value; +} Option; + +static GHashTable * +fill_table (const Option *test_options, GHashTable *table) +{ + const Option *opt; + + if (!table) + table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); + for (opt = test_options; opt->name; opt++) + g_hash_table_insert (table, (gpointer) opt->name, (gpointer) opt->value); + return table; +} + +static const Option generic_options[] = { + { "subnet_mask", "255.255.255.0" }, + { "ip_address", "192.168.1.106" }, + { "network_number", "192.168.1.0" }, + { "expiry", "1232324877" }, + { "dhcp_lease_time", "3600" }, + { "dhcp_server_identifier", "192.168.1.1" }, + { "routers", "192.168.1.1" }, + { "domain_name_servers", "216.254.95.2 216.231.41.2" }, + { "dhcp_message_type", "5" }, + { "broadcast_address", "192.168.1.255" }, + { "domain_search", "foobar.com blah.foobar.com" }, + { "host_name", "nmreallywhipsthe" }, + { "domain_name", "lamasass.com" }, + { "interface_mtu", "987" }, + { "static_routes", "10.1.1.5 10.1.1.1 100.99.88.56 10.1.1.1" }, + { NULL, NULL } +}; + +static void +test_generic_options (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const NMPlatformIP4Address *address; + const NMPlatformIP4Route *route; + guint32 tmp; + const char *expected_addr = "192.168.1.106"; + const char *expected_gw = "192.168.1.1"; + const char *expected_dns1 = "216.254.95.2"; + const char *expected_dns2 = "216.231.41.2"; + const char *expected_search1 = "foobar.com"; + const char *expected_search2 = "blah.foobar.com"; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; + + options = fill_table (generic_options, NULL); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* IP4 address */ + g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); + address = nm_ip4_config_get_address (ip4_config, 0); + g_assert (inet_pton (AF_INET, expected_addr, &tmp) > 0); + g_assert (address->address == tmp); + g_assert (address->peer_address == tmp); + g_assert_cmpint (address->plen, ==, 24); + + /* Gateway */ + g_assert (inet_pton (AF_INET, expected_gw, &tmp) > 0); + g_assert (nm_ip4_config_get_gateway (ip4_config) == tmp); + + g_assert_cmpint (nm_ip4_config_get_num_wins (ip4_config), ==, 0); + + g_assert_cmpint (nm_ip4_config_get_mtu (ip4_config), ==, 987); + + /* Domain searches */ + g_assert_cmpint (nm_ip4_config_get_num_searches (ip4_config), ==, 2); + g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 0), ==, expected_search1); + g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 1), ==, expected_search2); + + /* DNS servers */ + g_assert_cmpint (nm_ip4_config_get_num_nameservers (ip4_config), ==, 2); + g_assert (inet_pton (AF_INET, expected_dns1, &tmp) > 0); + g_assert (nm_ip4_config_get_nameserver (ip4_config, 0) == tmp); + g_assert (inet_pton (AF_INET, expected_dns2, &tmp) > 0); + g_assert (nm_ip4_config_get_nameserver (ip4_config, 1) == tmp); + + /* Routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); + + /* Route #1 */ + route = nm_ip4_config_get_route (ip4_config, 0); + g_assert (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0); + g_assert (route->network == tmp); + g_assert (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0); + g_assert (route->gateway == tmp); + g_assert_cmpint (route->plen, ==, 32); + g_assert_cmpint (route->metric, ==, 0); + + /* Route #2 */ + route = nm_ip4_config_get_route (ip4_config, 1); + g_assert (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0); + g_assert (route->network == tmp); + g_assert (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0); + g_assert (route->gateway == tmp); + g_assert_cmpint (route->plen, ==, 32); + g_assert_cmpint (route->metric, ==, 0); + + g_hash_table_destroy (options); +} + +static void +test_wins_options (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const NMPlatformIP4Address *address; + guint32 tmp; + const char *expected_wins1 = "63.12.199.5"; + const char *expected_wins2 = "150.4.88.120"; + static const Option data[] = { + { "netbios_name_servers", "63.12.199.5 150.4.88.120" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* IP4 address */ + g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); + address = nm_ip4_config_get_address (ip4_config, 0); + g_assert (address); + g_assert_cmpint (nm_ip4_config_get_num_wins (ip4_config), ==, 2); + g_assert (inet_pton (AF_INET, expected_wins1, &tmp) > 0); + g_assert (nm_ip4_config_get_wins (ip4_config, 0) == tmp); + g_assert (inet_pton (AF_INET, expected_wins2, &tmp) > 0); + g_assert (nm_ip4_config_get_wins (ip4_config, 1) == tmp); + + g_hash_table_destroy (options); +} + +static void +test_vendor_option_metered (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + static const Option data[] = { + { "vendor_encapsulated_options", "ANDROID_METERED" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_assert (nm_ip4_config_get_metered (ip4_config) == FALSE); + g_hash_table_destroy (options); + g_clear_object (&ip4_config); + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_assert (nm_ip4_config_get_metered (ip4_config) == TRUE); + g_hash_table_destroy (options); +} + +static void +ip4_test_route (NMIP4Config *ip4_config, + guint route_num, + const char *expected_dest, + const char *expected_gw, + guint expected_prefix) +{ + const NMPlatformIP4Route *route; + guint32 tmp; + + g_assert (expected_prefix <= 32); + + route = nm_ip4_config_get_route (ip4_config, route_num); + g_assert (inet_pton (AF_INET, expected_dest, &tmp) > 0); + g_assert (route->network == tmp); + g_assert (inet_pton (AF_INET, expected_gw, &tmp) > 0); + g_assert (route->gateway == tmp); + g_assert_cmpint (route->plen, ==, expected_prefix); + g_assert_cmpint (route->metric, ==, 0); +} + +static void +ip4_test_gateway (NMIP4Config *ip4_config, const char *expected_gw) +{ + guint32 tmp; + + g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); + g_assert (inet_pton (AF_INET, expected_gw, &tmp) > 0); + g_assert (nm_ip4_config_get_gateway (ip4_config) == tmp); +} + +static void +test_classless_static_routes_1 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_route2_dest = "10.0.0.0"; + const char *expected_route2_gw = "10.17.66.41"; + static const Option data[] = { + /* dhclient custom format */ + { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 8 10 10 17 66 41" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 8); + + g_hash_table_destroy (options); +} + +static void +test_classless_static_routes_2 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_route2_dest = "10.0.0.0"; + const char *expected_route2_gw = "10.17.66.41"; + static const Option data[] = { + /* dhcpcd format */ + { "classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); + ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 8); + + g_hash_table_destroy (options); +} + +static void +test_fedora_dhclient_classless_static_routes (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "129.210.177.128"; + const char *expected_route1_gw = "192.168.0.113"; + const char *expected_route2_dest = "2.0.0.0"; + const char *expected_route2_gw = "10.34.255.6"; + const char *expected_gateway = "192.168.0.113"; + static const Option data[] = { + /* Fedora dhclient format */ + { "classless_static_routes", "0 192.168.0.113 25.129.210.177.132 192.168.0.113 7.2 10.34.255.6" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 25); + ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 7); + + /* Gateway */ + ip4_test_gateway (ip4_config, expected_gateway); + + g_hash_table_destroy (options); +} + +static void +test_dhclient_invalid_classless_routes_1 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + static const Option data[] = { + /* dhclient format */ + { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 45 10 17 66 41" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ignoring invalid classless static routes*"); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_test_assert_expected_messages (); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); + + g_hash_table_destroy (options); +} + +static void +test_dhcpcd_invalid_classless_routes_1 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; + static const Option data[] = { + /* dhcpcd format */ + { "classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.adfadf/44 10.17.66.41" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ignoring invalid classless static routes*"); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_test_assert_expected_messages (); + + /* Test falling back to old-style static routes if the classless static + * routes are invalid. + */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); + ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); + + g_hash_table_destroy (options); +} + +static void +test_dhclient_invalid_classless_routes_2 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; + static const Option data[] = { + { "rfc3442_classless_static_routes", "45 10 17 66 41 24 192 168 10 192 168 1 1" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ignoring invalid classless static routes*"); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_test_assert_expected_messages (); + + /* Test falling back to old-style static routes if the classless static + * routes are invalid. + */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); + ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); + + g_hash_table_destroy (options); +} + +static void +test_dhcpcd_invalid_classless_routes_2 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "10.1.1.5"; + const char *expected_route1_gw = "10.1.1.1"; + const char *expected_route2_dest = "100.99.88.56"; + const char *expected_route2_gw = "10.1.1.1"; + static const Option data[] = { + { "classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ignoring invalid classless static routes*"); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_test_assert_expected_messages (); + + /* Test falling back to old-style static routes if the classless static + * routes are invalid. + */ + + /* Routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 2); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); + ip4_test_route (ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); + + g_hash_table_destroy (options); +} + +static void +test_dhclient_invalid_classless_routes_3 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + static const Option data[] = { + { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ignoring invalid classless static routes*"); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_test_assert_expected_messages (); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); + + g_hash_table_destroy (options); +} + +static void +test_dhcpcd_invalid_classless_routes_3 (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + static Option data[] = { + { "classless_static_routes", "192.168.10.0/24 192.168.1.1 128/32 10.17.66.41" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*DHCP provided invalid classless static route*"); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_test_assert_expected_messages (); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); + + g_hash_table_destroy (options); +} + +static void +test_dhclient_gw_in_classless_routes (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_gateway = "192.2.3.4"; + static Option data[] = { + { "rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 0 192 2 3 4" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); + + /* Gateway */ + ip4_test_gateway (ip4_config, expected_gateway); + + g_hash_table_destroy (options); +} + +static void +test_dhcpcd_gw_in_classless_routes (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_route1_dest = "192.168.10.0"; + const char *expected_route1_gw = "192.168.1.1"; + const char *expected_gateway = "192.2.3.4"; + static Option data[] = { + { "classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* IP4 routes */ + g_assert_cmpint (nm_ip4_config_get_num_routes (ip4_config), ==, 1); + ip4_test_route (ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); + + /* Gateway */ + ip4_test_gateway (ip4_config, expected_gateway); + + g_hash_table_destroy (options); +} + +static void +test_escaped_domain_searches (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const char *expected_search0 = "host1"; + const char *expected_search1 = "host2"; + const char *expected_search2 = "host3"; + static const Option data[] = { + { "domain_search", "host1\\032host2\\032host3" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + /* domain searches */ + g_assert_cmpint (nm_ip4_config_get_num_searches (ip4_config), ==, 3); + g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 0), ==, expected_search0); + g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 1), ==, expected_search1); + g_assert_cmpstr (nm_ip4_config_get_search (ip4_config, 2), ==, expected_search2); + + g_hash_table_destroy (options); +} + +static void +test_invalid_escaped_domain_searches (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + static const Option data[] = { + { "domain_search", "host1\\aahost2\\032host3" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*invalid domain search*"); + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + g_test_assert_expected_messages (); + + /* domain searches */ + g_assert_cmpint (nm_ip4_config_get_num_searches (ip4_config), ==, 0); + + g_hash_table_destroy (options); +} + +static void +test_ip4_missing_prefix (const char *ip, guint32 expected_prefix) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const NMPlatformIP4Address *address; + + options = fill_table (generic_options, NULL); + g_hash_table_insert (options, "ip_address", (gpointer) ip); + g_hash_table_remove (options, "subnet_mask"); + + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); + address = nm_ip4_config_get_address (ip4_config, 0); + g_assert (address); + g_assert_cmpint (address->plen, ==, expected_prefix); + + g_hash_table_destroy (options); +} + +static void +test_ip4_missing_prefix_24 (void) +{ + test_ip4_missing_prefix ("192.168.1.10", 24); +} + +static void +test_ip4_missing_prefix_16 (void) +{ + test_ip4_missing_prefix ("172.16.54.50", 16); +} + +static void +test_ip4_missing_prefix_8 (void) +{ + test_ip4_missing_prefix ("10.1.2.3", 8); +} + +static void +test_ip4_prefix_classless (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + const NMPlatformIP4Address *address; + + /* Ensure that the missing-subnet-mask handler doesn't mangle classless + * subnet masks at all. The handler should trigger only if the server + * doesn't send the subnet mask. + */ + + options = fill_table (generic_options, NULL); + g_hash_table_insert (options, "ip_address", "172.16.54.22"); + g_hash_table_insert (options, "subnet_mask", "255.255.252.0"); + + ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0); + g_assert (ip4_config); + + g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1); + address = nm_ip4_config_get_address (ip4_config, 0); + g_assert (address); + g_assert_cmpint (address->plen, ==, 22); + + g_hash_table_destroy (options); +} + +#define COMPARE_ID(src, is_str, expected, expected_len) \ +G_STMT_START { \ + gs_unref_bytes GBytes *b = NULL; \ + const char *p; \ + gsize l; \ + \ + b = nm_dhcp_utils_client_id_string_to_bytes (src); \ + g_assert (b); \ + p = g_bytes_get_data (b, &l); \ + if (is_str) { \ + g_assert_cmpint (l, ==, expected_len + 1); \ + g_assert_cmpint (((const char *) p)[0], ==, 0); \ + g_assert (memcmp (p + 1, expected, expected_len) == 0); \ + } else { \ + g_assert_cmpint (l, ==, expected_len); \ + g_assert (memcmp (p, expected, expected_len) == 0); \ + } \ +} G_STMT_END + +static void +test_client_id_from_string (void) +{ + const char *nothex = "asdfasdfasdfasdfasdfasdfasdf"; + const char *allhex = "00:11:22:33:4:55:66:77:88"; + const guint8 allhex_bin[] = { 0x00, 0x11, 0x22, 0x33, 0x04, 0x55, 0x66, 0x77, 0x88 }; + const char *somehex = "00:11:22:33:44:55:asdfasdfasdf:99:10"; + const char *nocolons = "0011223344559910"; + const char *endcolon = "00:11:22:33:44:55:"; + + COMPARE_ID (nothex, TRUE, nothex, strlen (nothex)); + COMPARE_ID (allhex, FALSE, allhex_bin, sizeof (allhex_bin)); + COMPARE_ID (somehex, TRUE, somehex, strlen (somehex)); + COMPARE_ID (nocolons, TRUE, nocolons, strlen (nocolons)); + COMPARE_ID (endcolon, TRUE, endcolon, strlen (endcolon)); +} + +NMTST_DEFINE (); + +int main (int argc, char **argv) +{ + nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); + + g_test_add_func ("/dhcp/generic-options", test_generic_options); + g_test_add_func ("/dhcp/wins-options", test_wins_options); + g_test_add_func ("/dhcp/classless-static-routes-1", test_classless_static_routes_1); + g_test_add_func ("/dhcp/classless-static-routes-2", test_classless_static_routes_2); + g_test_add_func ("/dhcp/fedora-dhclient-classless-static-routes", test_fedora_dhclient_classless_static_routes); + g_test_add_func ("/dhcp/dhclient-invalid-classless-routes-1", test_dhclient_invalid_classless_routes_1); + g_test_add_func ("/dhcp/dhcpcd-invalid-classless-routes-1", test_dhcpcd_invalid_classless_routes_1); + g_test_add_func ("/dhcp/dhclient-invalid-classless-routes-2", test_dhclient_invalid_classless_routes_2); + g_test_add_func ("/dhcp/dhcpcd-invalid-classless-routes-2", test_dhcpcd_invalid_classless_routes_2); + g_test_add_func ("/dhcp/dhclient-invalid-classless-routes-3", test_dhclient_invalid_classless_routes_3); + g_test_add_func ("/dhcp/dhcpcd-invalid-classless-routes-3", test_dhcpcd_invalid_classless_routes_3); + g_test_add_func ("/dhcp/dhclient-gw-in-classless-routes", test_dhclient_gw_in_classless_routes); + g_test_add_func ("/dhcp/dhcpcd-gw-in-classless-routes", test_dhcpcd_gw_in_classless_routes); + g_test_add_func ("/dhcp/escaped-domain-searches", test_escaped_domain_searches); + g_test_add_func ("/dhcp/invalid-escaped-domain-searches", test_invalid_escaped_domain_searches); + g_test_add_func ("/dhcp/ip4-missing-prefix-24", test_ip4_missing_prefix_24); + g_test_add_func ("/dhcp/ip4-missing-prefix-16", test_ip4_missing_prefix_16); + g_test_add_func ("/dhcp/ip4-missing-prefix-8", test_ip4_missing_prefix_8); + g_test_add_func ("/dhcp/ip4-prefix-classless", test_ip4_prefix_classless); + g_test_add_func ("/dhcp/client-id-from-string", test_client_id_from_string); + g_test_add_func ("/dhcp/vendor-option-metered", test_vendor_option_metered); + + return g_test_run (); +} + diff --git a/src/dns-manager/nm-dns-dnsmasq.c b/src/dns-manager/nm-dns-dnsmasq.c deleted file mode 100644 index 69b26068..00000000 --- a/src/dns-manager/nm-dns-dnsmasq.c +++ /dev/null @@ -1,697 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2010 Dan Williams - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "nm-dns-dnsmasq.h" -#include "nm-core-internal.h" -#include "nm-platform.h" -#include "nm-utils.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" -#include "nm-bus-manager.h" -#include "NetworkManagerUtils.h" - -G_DEFINE_TYPE (NMDnsDnsmasq, nm_dns_dnsmasq, NM_TYPE_DNS_PLUGIN) - -#define NM_DNS_DNSMASQ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasqPrivate)) - -#define PIDFILE NMRUNDIR "/dnsmasq.pid" -#define CONFDIR NMCONFDIR "/dnsmasq.d" - -#define DNSMASQ_DBUS_SERVICE "org.freedesktop.NetworkManager.dnsmasq" -#define DNSMASQ_DBUS_PATH "/uk/org/thekelleys/dnsmasq" - -typedef struct { - GDBusProxy *dnsmasq; - GCancellable *dnsmasq_cancellable; - GCancellable *update_cancellable; - gboolean running; - - GVariant *set_server_ex_args; -} NMDnsDnsmasqPrivate; - -/*****************************************************************************/ - -#define _NMLOG_DOMAIN LOGD_DNS -#define _NMLOG_PREFIX_NAME "dnsmasq" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s[%p]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, \ - (self) \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -/*****************************************************************************/ - -static char ** -get_ip4_rdns_domains (NMIP4Config *ip4) -{ - char **strv; - GPtrArray *domains = NULL; - int i; - - g_return_val_if_fail (ip4 != NULL, NULL); - - domains = g_ptr_array_sized_new (5); - - for (i = 0; i < nm_ip4_config_get_num_addresses (ip4); i++) { - const NMPlatformIP4Address *address = nm_ip4_config_get_address (ip4, i); - - nm_utils_get_reverse_dns_domains_ip4 (address->address, address->plen, domains); - } - - for (i = 0; i < nm_ip4_config_get_num_routes (ip4); i++) { - const NMPlatformIP4Route *route = nm_ip4_config_get_route (ip4, i); - - nm_utils_get_reverse_dns_domains_ip4 (route->network, route->plen, domains); - } - - /* Terminating NULL so we can use g_strfreev() to free it */ - g_ptr_array_add (domains, NULL); - - /* Free the array and return NULL if the only element was the ending NULL */ - strv = (char **) g_ptr_array_free (domains, (domains->len == 1)); - - return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE); -} - -static char ** -get_ip6_rdns_domains (NMIP6Config *ip6) -{ - char **strv; - GPtrArray *domains = NULL; - int i; - - g_return_val_if_fail (ip6 != NULL, NULL); - - domains = g_ptr_array_sized_new (5); - - for (i = 0; i < nm_ip6_config_get_num_addresses (ip6); i++) { - const NMPlatformIP6Address *address = nm_ip6_config_get_address (ip6, i); - - nm_utils_get_reverse_dns_domains_ip6 (&address->address, address->plen, domains); - } - - for (i = 0; i < nm_ip6_config_get_num_routes (ip6); i++) { - const NMPlatformIP6Route *route = nm_ip6_config_get_route (ip6, i); - - nm_utils_get_reverse_dns_domains_ip6 (&route->network, route->plen, domains); - } - - /* Terminating NULL so we can use g_strfreev() to free it */ - g_ptr_array_add (domains, NULL); - - /* Free the array and return NULL if the only element was the ending NULL */ - strv = (char **) g_ptr_array_free (domains, (domains->len == 1)); - - return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE); -} - -static void -add_dnsmasq_nameserver (NMDnsDnsmasq *self, - GVariantBuilder *servers, - const char *ip, - const char *domain) -{ - g_return_if_fail (ip); - - _LOGD ("adding nameserver '%s'%s%s%s", ip, - NM_PRINT_FMT_QUOTED (domain, " for domain \"", domain, "\"", "")); - - g_variant_builder_open (servers, G_VARIANT_TYPE ("as")); - - g_variant_builder_add (servers, "s", ip); - if (domain) - g_variant_builder_add (servers, "s", domain); - - g_variant_builder_close (servers); -} - -static gboolean -add_ip4_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP4Config *ip4, - const char *iface, gboolean split) -{ - char buf[INET_ADDRSTRLEN + 1 + IFNAMSIZ]; - char buf2[INET_ADDRSTRLEN]; - in_addr_t addr; - int nnameservers, i_nameserver, n, i; - gboolean added = FALSE; - - g_return_val_if_fail (iface, FALSE); - nnameservers = nm_ip4_config_get_num_nameservers (ip4); - - if (split) { - char **domains, **iter; - - if (nnameservers == 0) - return FALSE; - - for (i_nameserver = 0; i_nameserver < nnameservers; i_nameserver++) { - addr = nm_ip4_config_get_nameserver (ip4, i_nameserver); - g_snprintf (buf, sizeof (buf), "%s@%s", - nm_utils_inet4_ntop (addr, buf2), iface); - - /* searches are preferred over domains */ - n = nm_ip4_config_get_num_searches (ip4); - for (i = 0; i < n; i++) { - add_dnsmasq_nameserver (self, - servers, - buf, - nm_ip4_config_get_search (ip4, i)); - added = TRUE; - } - - if (n == 0) { - /* If not searches, use any domains */ - n = nm_ip4_config_get_num_domains (ip4); - for (i = 0; i < n; i++) { - add_dnsmasq_nameserver (self, - servers, - buf, - nm_ip4_config_get_domain (ip4, i)); - added = TRUE; - } - } - - /* Ensure reverse-DNS works by directing queries for in-addr.arpa - * domains to the split domain's nameserver. - */ - domains = get_ip4_rdns_domains (ip4); - if (domains) { - for (iter = domains; iter && *iter; iter++) - add_dnsmasq_nameserver (self, servers, buf, *iter); - g_strfreev (domains); - } - } - } - - /* If no searches or domains, just add the nameservers */ - if (!added) { - for (i = 0; i < nnameservers; i++) { - addr = nm_ip4_config_get_nameserver (ip4, i); - g_snprintf (buf, sizeof (buf), "%s@%s", - nm_utils_inet4_ntop (addr, buf2), iface); - add_dnsmasq_nameserver (self, servers, buf, NULL); - } - } - - return TRUE; -} - -static char * -ip6_addr_to_string (const struct in6_addr *addr, const char *iface) -{ - char buf[NM_UTILS_INET_ADDRSTRLEN]; - - if (IN6_IS_ADDR_V4MAPPED (addr)) - nm_utils_inet4_ntop (addr->s6_addr32[3], buf); - else - nm_utils_inet6_ntop (addr, buf); - - /* Need to scope link-local addresses with %. Before dnsmasq 2.58, - * only '@' was supported as delimiter. Since 2.58, '@' and '%' are - * supported. Due to a bug, since 2.73 only '%' works properly as "server" - * address. - */ - return g_strdup_printf ("%s%c%s", - buf, - IN6_IS_ADDR_LINKLOCAL (addr) ? '%' : '@', - iface); -} - -static void -add_global_config (NMDnsDnsmasq *self, GVariantBuilder *dnsmasq_servers, const NMGlobalDnsConfig *config) -{ - guint i, j; - - g_return_if_fail (config); - - for (i = 0; i < nm_global_dns_config_get_num_domains (config); i++) { - NMGlobalDnsDomain *domain = nm_global_dns_config_get_domain (config, i); - const char *const *servers = nm_global_dns_domain_get_servers (domain); - const char *name = nm_global_dns_domain_get_name (domain); - - g_return_if_fail (name); - - for (j = 0; servers && servers[j]; j++) { - if (!strcmp (name, "*")) - add_dnsmasq_nameserver (self, dnsmasq_servers, servers[j], NULL); - else - add_dnsmasq_nameserver (self, dnsmasq_servers, servers[j], name); - } - - } -} - -static gboolean -add_ip6_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP6Config *ip6, - const char *iface, gboolean split) -{ - const struct in6_addr *addr; - char *buf = NULL; - int nnameservers, i_nameserver, n, i; - gboolean added = FALSE; - - g_return_val_if_fail (iface, FALSE); - nnameservers = nm_ip6_config_get_num_nameservers (ip6); - - if (split) { - char **domains, **iter; - - if (nnameservers == 0) - return FALSE; - - for (i_nameserver = 0; i_nameserver < nnameservers; i_nameserver++) { - addr = nm_ip6_config_get_nameserver (ip6, i_nameserver); - buf = ip6_addr_to_string (addr, iface); - - /* searches are preferred over domains */ - n = nm_ip6_config_get_num_searches (ip6); - for (i = 0; i < n; i++) { - add_dnsmasq_nameserver (self, - servers, - buf, - nm_ip6_config_get_search (ip6, i)); - added = TRUE; - } - - if (n == 0) { - /* If not searches, use any domains */ - n = nm_ip6_config_get_num_domains (ip6); - for (i = 0; i < n; i++) { - add_dnsmasq_nameserver (self, - servers, - buf, - nm_ip6_config_get_domain (ip6, i)); - added = TRUE; - } - } - - /* Ensure reverse-DNS works by directing queries for ip6.arpa - * domains to the split domain's nameserver. - */ - domains = get_ip6_rdns_domains (ip6); - if (domains) { - for (iter = domains; iter && *iter; iter++) - add_dnsmasq_nameserver (self, servers, buf, *iter); - g_strfreev (domains); - } - - g_free (buf); - } - } - - /* If no searches or domains, just add the nameservers */ - if (!added) { - for (i = 0; i < nnameservers; i++) { - addr = nm_ip6_config_get_nameserver (ip6, i); - buf = ip6_addr_to_string (addr, iface); - if (buf) { - add_dnsmasq_nameserver (self, servers, buf, NULL); - g_free (buf); - } - } - } - - return TRUE; -} - -static gboolean -add_ip_config_data (NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsIPConfigData *data) -{ - if (NM_IS_IP4_CONFIG (data->config)) { - return add_ip4_config (self, - servers, - (NMIP4Config *) data->config, - data->iface, - data->type == NM_DNS_IP_CONFIG_TYPE_VPN); - } else if (NM_IS_IP6_CONFIG (data->config)) { - return add_ip6_config (self, - servers, - (NMIP6Config *) data->config, - data->iface, - data->type == NM_DNS_IP_CONFIG_TYPE_VPN); - } else - g_return_val_if_reached (FALSE); -} - -static void -dnsmasq_clear_cache_done (GDBusProxy *proxy, GAsyncResult *res, gpointer user_data) -{ - NMDnsDnsmasq *self; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *response = NULL; - - response = g_dbus_proxy_call_finish (proxy, res, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_DNS_DNSMASQ (user_data); - - if (!response) - _LOGW ("dnsmasq cache clear failed: %s", error->message); - else - _LOGD ("dnsmasq update successful, cache cleared"); -} - -static void -dnsmasq_update_done (GDBusProxy *proxy, GAsyncResult *res, gpointer user_data) -{ - NMDnsDnsmasq *self; - NMDnsDnsmasqPrivate *priv; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *response = NULL; - - response = g_dbus_proxy_call_finish (proxy, res, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_DNS_DNSMASQ (user_data); - priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); - - if (!response) - _LOGW ("dnsmasq update failed: %s", error->message); - else { - g_dbus_proxy_call (priv->dnsmasq, - "ClearCache", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->update_cancellable, - (GAsyncReadyCallback) dnsmasq_clear_cache_done, - self); - } -} - -static void -send_dnsmasq_update (NMDnsDnsmasq *self) -{ - NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); - - if (!priv->set_server_ex_args) - return; - - if (priv->running) { - _LOGD ("trying to update dnsmasq nameservers"); - - nm_clear_g_cancellable (&priv->update_cancellable); - priv->update_cancellable = g_cancellable_new (); - - g_dbus_proxy_call (priv->dnsmasq, - "SetServersEx", - priv->set_server_ex_args, - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->update_cancellable, - (GAsyncReadyCallback) dnsmasq_update_done, - self); - g_clear_pointer (&priv->set_server_ex_args, g_variant_unref); - } else - _LOGD ("dnsmasq not found on the bus. The nameserver update will be sent when dnsmasq appears"); -} - -static void -name_owner_changed (GObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - NMDnsDnsmasq *self = NM_DNS_DNSMASQ (user_data); - NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); - gs_free char *owner = NULL; - - owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object)); - if (owner) { - _LOGI ("dnsmasq appeared as %s", owner); - priv->running = TRUE; - send_dnsmasq_update (self); - } else { - _LOGI ("dnsmasq disappeared"); - priv->running = FALSE; - g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); - } -} - -static void -dnsmasq_proxy_cb (GObject *source, GAsyncResult *res, gpointer user_data) -{ - NMDnsDnsmasq *self; - NMDnsDnsmasqPrivate *priv; - gs_free_error GError *error = NULL; - gs_free char *owner = NULL; - GDBusProxy *proxy; - - proxy = g_dbus_proxy_new_finish (res, &error); - if ( !proxy - && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_DNS_DNSMASQ (user_data); - - if (!proxy) { - _LOGW ("failed to connect to dnsmasq via DBus: %s", error->message); - g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); - return; - } - - priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); - - priv->dnsmasq = proxy; - nm_clear_g_cancellable (&priv->dnsmasq_cancellable); - - _LOGD ("dnsmasq proxy creation successful"); - - g_signal_connect (priv->dnsmasq, "notify::g-name-owner", - G_CALLBACK (name_owner_changed), self); - owner = g_dbus_proxy_get_name_owner (priv->dnsmasq); - priv->running = (owner != NULL); - - if (priv->running) - send_dnsmasq_update (self); -} - -static void -start_dnsmasq (NMDnsDnsmasq *self) -{ - NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); - const char *dm_binary; - const char *argv[15]; - GPid pid = 0; - guint idx = 0; - NMBusManager *dbus_mgr; - GDBusConnection *connection; - - if (priv->running) { - /* the dnsmasq process is running. Nothing to do. */ - return; - } - - if (nm_dns_plugin_child_pid ((NMDnsPlugin *) self) > 0) { - /* if we already have a child process spawned, don't do - * it again. */ - return; - } - - dm_binary = nm_utils_find_helper ("dnsmasq", DNSMASQ_PATH, NULL); - if (!dm_binary) { - _LOGW ("could not find dnsmasq binary"); - return; - } - - argv[idx++] = dm_binary; - argv[idx++] = "--no-resolv"; /* Use only commandline */ - argv[idx++] = "--keep-in-foreground"; - argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */ - argv[idx++] = "--bind-interfaces"; - argv[idx++] = "--pid-file=" PIDFILE; - argv[idx++] = "--listen-address=127.0.0.1"; /* Should work for both 4 and 6 */ - argv[idx++] = "--cache-size=400"; - argv[idx++] = "--conf-file=/dev/null"; /* avoid loading /etc/dnsmasq.conf */ - argv[idx++] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */ - argv[idx++] = "--enable-dbus=" DNSMASQ_DBUS_SERVICE; - - /* dnsmasq exits if the conf dir is not present */ - if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR)) - argv[idx++] = "--conf-dir=" CONFDIR; - - argv[idx++] = NULL; - nm_assert (idx <= G_N_ELEMENTS (argv)); - - /* And finally spawn dnsmasq */ - pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq"); - if (!pid) - return; - - if ( priv->dnsmasq - || priv->dnsmasq_cancellable) { - /* we already have a proxy or are about to create it. - * We are done. */ - return; - } - - dbus_mgr = nm_bus_manager_get (); - g_return_if_fail (dbus_mgr); - - connection = nm_bus_manager_get_connection (dbus_mgr); - g_return_if_fail (connection); - - priv->dnsmasq_cancellable = g_cancellable_new (); - g_dbus_proxy_new (connection, - G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, - NULL, - DNSMASQ_DBUS_SERVICE, - DNSMASQ_DBUS_PATH, - DNSMASQ_DBUS_SERVICE, - priv->dnsmasq_cancellable, - dnsmasq_proxy_cb, - self); -} - -static gboolean -update (NMDnsPlugin *plugin, - const NMDnsIPConfigData **configs, - const NMGlobalDnsConfig *global_config, - const char *hostname) -{ - NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin); - NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); - GVariantBuilder servers; - - start_dnsmasq (self); - - g_variant_builder_init (&servers, G_VARIANT_TYPE ("aas")); - - if (global_config) - add_global_config (self, &servers, global_config); - else { - while (*configs) { - add_ip_config_data (self, &servers, *configs); - configs++; - } - } - - g_clear_pointer (&priv->set_server_ex_args, g_variant_unref); - priv->set_server_ex_args = g_variant_ref_sink (g_variant_new ("(aas)", &servers)); - - send_dnsmasq_update (self); - - return TRUE; -} - -/****************************************************************/ - -static void -child_quit (NMDnsPlugin *plugin, gint status) -{ - NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin); - NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); - gboolean failed = TRUE; - int err; - - if (WIFEXITED (status)) { - err = WEXITSTATUS (status); - if (err) { - _LOGW ("dnsmasq exited with error: %s", - nm_utils_dnsmasq_status_to_string (err, NULL, 0)); - } else { - _LOGD ("dnsmasq exited normally"); - failed = FALSE; - } - } else if (WIFSTOPPED (status)) - _LOGW ("dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status)); - else if (WIFSIGNALED (status)) - _LOGW ("dnsmasq died with signal %d", WTERMSIG (status)); - else - _LOGW ("dnsmasq died from an unknown cause"); - - priv->running = FALSE; - - if (failed) - g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); -} - -/****************************************************************/ - -static gboolean -is_caching (NMDnsPlugin *plugin) -{ - return TRUE; -} - -static const char * -get_name (NMDnsPlugin *plugin) -{ - return "dnsmasq"; -} - -/****************************************************************/ - -NMDnsPlugin * -nm_dns_dnsmasq_new (void) -{ - return g_object_new (NM_TYPE_DNS_DNSMASQ, NULL); -} - -static void -nm_dns_dnsmasq_init (NMDnsDnsmasq *self) -{ -} - -static void -dispose (GObject *object) -{ - NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (object); - - nm_clear_g_cancellable (&priv->dnsmasq_cancellable); - nm_clear_g_cancellable (&priv->update_cancellable); - - g_clear_object (&priv->dnsmasq); - - g_clear_pointer (&priv->set_server_ex_args, g_variant_unref); - - G_OBJECT_CLASS (nm_dns_dnsmasq_parent_class)->dispose (object); -} - -static void -nm_dns_dnsmasq_class_init (NMDnsDnsmasqClass *dns_class) -{ - NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (dns_class); - GObjectClass *object_class = G_OBJECT_CLASS (dns_class); - - g_type_class_add_private (dns_class, sizeof (NMDnsDnsmasqPrivate)); - - object_class->dispose = dispose; - - plugin_class->child_quit = child_quit; - plugin_class->is_caching = is_caching; - plugin_class->update = update; - plugin_class->get_name = get_name; -} - diff --git a/src/dns-manager/nm-dns-dnsmasq.h b/src/dns-manager/nm-dns-dnsmasq.h deleted file mode 100644 index f0393c12..00000000 --- a/src/dns-manager/nm-dns-dnsmasq.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2010 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DNS_DNSMASQ_H__ -#define __NETWORKMANAGER_DNS_DNSMASQ_H__ - -#include "nm-dns-plugin.h" - -#define NM_TYPE_DNS_DNSMASQ (nm_dns_dnsmasq_get_type ()) -#define NM_DNS_DNSMASQ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasq)) -#define NM_DNS_DNSMASQ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasqClass)) -#define NM_IS_DNS_DNSMASQ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_DNSMASQ)) -#define NM_IS_DNS_DNSMASQ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_DNSMASQ)) -#define NM_DNS_DNSMASQ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasqClass)) - -typedef struct { - NMDnsPlugin parent; -} NMDnsDnsmasq; - -typedef struct { - NMDnsPluginClass parent; -} NMDnsDnsmasqClass; - -GType nm_dns_dnsmasq_get_type (void); - -NMDnsPlugin *nm_dns_dnsmasq_new (void); - -#endif /* __NETWORKMANAGER_DNS_DNSMASQ_H__ */ - diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c deleted file mode 100644 index 5a758a9e..00000000 --- a/src/dns-manager/nm-dns-manager.c +++ /dev/null @@ -1,1800 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2004 - 2005 Colin Walters - * Copyright (C) 2004 - 2013 Red Hat, Inc. - * Copyright (C) 2005 - 2008 Novell, Inc. - * and others - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "nm-utils.h" -#include "nm-core-internal.h" -#include "nm-dns-manager.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" -#include "NetworkManagerUtils.h" -#include "nm-config.h" - -#include "nm-dns-plugin.h" -#include "nm-dns-dnsmasq.h" -#include "nm-dns-unbound.h" - -#if WITH_LIBSOUP -#include - -#ifdef SOUP_CHECK_VERSION -#if SOUP_CHECK_VERSION (2, 40, 0) -#define DOMAIN_IS_VALID(domain) (*(domain) && !soup_tld_domain_is_public_suffix (domain)) -#endif -#endif -#endif - -#ifndef DOMAIN_IS_VALID -#define DOMAIN_IS_VALID(domain) (*(domain)) -#endif - -#define HASH_LEN 20 - -#ifndef RESOLVCONF_PATH -#define RESOLVCONF_PATH "/sbin/resolvconf" -#endif - -#ifndef NETCONFIG_PATH -#define NETCONFIG_PATH "/sbin/netconfig" -#endif - -#define PLUGIN_RATELIMIT_INTERVAL 30 -#define PLUGIN_RATELIMIT_BURST 5 -#define PLUGIN_RATELIMIT_DELAY 300 - -enum { - CONFIG_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -typedef enum { - SR_SUCCESS, - SR_NOTFOUND, - SR_ERROR -} SpawnResult; - -/*********************************************************************************************/ - -#define _NMLOG_PREFIX_NAME "dns-mgr" -#define _NMLOG_DOMAIN LOGD_DNS -#define _NMLOG(level, ...) \ - G_STMT_START { \ - const NMLogLevel __level = (level); \ - \ - if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ - char __prefix[20]; \ - const NMDnsManager *const __self = (self); \ - \ - _nm_log (__level, _NMLOG_DOMAIN, 0, \ - "%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, \ - ((!__self || __self == singleton_instance) \ - ? "" \ - : nm_sprintf_buf (__prefix, "[%p]", __self)) \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -/*********************************************************************************************/ - -typedef struct { - GPtrArray *configs; - NMDnsIPConfigData *best_conf4, *best_conf6; - gboolean need_sort; - - char *hostname; - guint updates_queue; - - guint8 hash[HASH_LEN]; /* SHA1 hash of current DNS config */ - guint8 prev_hash[HASH_LEN]; /* Hash when begin_updates() was called */ - - NMDnsManagerResolvConfManager rc_manager; - NMDnsPlugin *plugin; - - NMConfig *config; - - gboolean dns_touched; - - struct { - guint64 ts; - guint num_restarts; - guint timer; - } plugin_ratelimit; -} NMDnsManagerPrivate; - -struct _NMDnsManager { - GObject parent; - NMDnsManagerPrivate _priv; -}; - -struct _NMDnsManagerClass { - GObjectClass parent; -}; - -G_DEFINE_TYPE (NMDnsManager, nm_dns_manager, G_TYPE_OBJECT) - -NM_DEFINE_SINGLETON_INSTANCE (NMDnsManager); - -#define NM_DNS_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDnsManager, NM_IS_DNS_MANAGER) - -/*****************************************************************************/ - -typedef struct { - GPtrArray *nameservers; - GPtrArray *searches; - GPtrArray *options; - const char *nis_domain; - GPtrArray *nis_servers; -} NMResolvConfData; - -NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_rc_manager_to_string, NMDnsManagerResolvConfManager, - NM_UTILS_LOOKUP_DEFAULT_WARN (NULL), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN, "unknown"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, "unmanaged"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE, "immutable"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK, "symlink"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE, "file"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF, "resolvconf"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG, "netconfig"), -); - -NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_config_type_to_string, NMDnsIPConfigType, - NM_UTILS_LOOKUP_DEFAULT_WARN (""), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_IP_CONFIG_TYPE_DEFAULT, "default"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE, "best"), - NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_IP_CONFIG_TYPE_VPN, "vpn"), -); - -static NMDnsIPConfigData * -ip_config_data_new (gpointer config, NMDnsIPConfigType type, const char *iface) -{ - NMDnsIPConfigData *data; - - data = g_slice_new0 (NMDnsIPConfigData); - data->config = g_object_ref (config); - data->iface = g_strdup (iface); - data->type = type; - - return data; -} - -static void -ip_config_data_destroy (gpointer ptr) -{ - NMDnsIPConfigData *data = ptr; - - if (!data) - return; - - g_object_unref (data->config); - g_free (data->iface); - g_slice_free (NMDnsIPConfigData, data); -} - -static gint -ip_config_data_compare (const NMDnsIPConfigData *a, const NMDnsIPConfigData *b) -{ - gboolean a_v4, b_v4; - gint a_prio, b_prio; - - a_v4 = NM_IS_IP4_CONFIG (a->config); - b_v4 = NM_IS_IP4_CONFIG (b->config); - - a_prio = a_v4 ? - nm_ip4_config_get_dns_priority ((NMIP4Config *) a->config) : - nm_ip6_config_get_dns_priority ((NMIP6Config *) a->config); - - b_prio = b_v4 ? - nm_ip4_config_get_dns_priority ((NMIP4Config *) b->config) : - nm_ip6_config_get_dns_priority ((NMIP6Config *) b->config); - - /* Configurations with lower priority value first */ - if (a_prio < b_prio) - return -1; - else if (a_prio > b_prio) - return 1; - - /* Sort also according to type */ - if (a->type > b->type) - return -1; - else if (a->type < b->type) - return 1; - - return 0; -} - -static gint -ip_config_data_ptr_compare (gconstpointer a, gconstpointer b) -{ - const NMDnsIPConfigData *const *ptr_a = a, *const *ptr_b = b; - - return ip_config_data_compare (*ptr_a, *ptr_b); -} - -static void -add_string_item (GPtrArray *array, const char *str) -{ - int i; - - g_return_if_fail (array != NULL); - g_return_if_fail (str != NULL); - - /* Check for dupes before adding */ - for (i = 0; i < array->len; i++) { - const char *candidate = g_ptr_array_index (array, i); - - if (candidate && !strcmp (candidate, str)) - return; - } - - /* No dupes, add the new item */ - g_ptr_array_add (array, g_strdup (str)); -} - -static void -add_dns_option_item (GPtrArray *array, const char *str, gboolean ipv6) -{ - if (_nm_utils_dns_option_find_idx (array, str) < 0) - g_ptr_array_add (array, g_strdup (str)); -} - -static void -merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src) -{ - guint32 num, num_domains, num_searches, i; - - num = nm_ip4_config_get_num_nameservers (src); - for (i = 0; i < num; i++) { - add_string_item (rc->nameservers, - nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (src, i), NULL)); - } - - num_domains = nm_ip4_config_get_num_domains (src); - num_searches = nm_ip4_config_get_num_searches (src); - - for (i = 0; i < num_searches; i++) { - const char *search; - - search = nm_ip4_config_get_search (src, i); - if (!DOMAIN_IS_VALID (search)) - continue; - add_string_item (rc->searches, search); - } - - if (num_domains > 1 || !num_searches) { - for (i = 0; i < num_domains; i++) { - const char *domain; - - domain = nm_ip4_config_get_domain (src, i); - if (!DOMAIN_IS_VALID (domain)) - continue; - add_string_item (rc->searches, domain); - } - } - - num = nm_ip4_config_get_num_dns_options (src); - for (i = 0; i < num; i++) { - const char *option; - - option = nm_ip4_config_get_dns_option (src, i); - add_dns_option_item (rc->options, option, FALSE); - } - - /* NIS stuff */ - num = nm_ip4_config_get_num_nis_servers (src); - for (i = 0; i < num; i++) { - add_string_item (rc->nis_servers, - nm_utils_inet4_ntop (nm_ip4_config_get_nis_server (src, i), NULL)); - } - - if (nm_ip4_config_get_nis_domain (src)) { - /* FIXME: handle multiple domains */ - if (!rc->nis_domain) - rc->nis_domain = nm_ip4_config_get_nis_domain (src); - } -} - -static void -merge_one_ip6_config (NMResolvConfData *rc, NMIP6Config *src, const char *iface) -{ - guint32 num, num_domains, num_searches, i; - - num = nm_ip6_config_get_num_nameservers (src); - for (i = 0; i < num; i++) { - const struct in6_addr *addr; - char buf[NM_UTILS_INET_ADDRSTRLEN + 50]; - - addr = nm_ip6_config_get_nameserver (src, i); - - /* inet_ntop is probably supposed to do this for us, but it doesn't */ - if (IN6_IS_ADDR_V4MAPPED (addr)) - nm_utils_inet4_ntop (addr->s6_addr32[3], buf); - else { - nm_utils_inet6_ntop (addr, buf); - if (IN6_IS_ADDR_LINKLOCAL (addr)) { - g_strlcat (buf, "%", sizeof (buf)); - g_strlcat (buf, iface, sizeof (buf)); - } - } - add_string_item (rc->nameservers, buf); - } - - num_domains = nm_ip6_config_get_num_domains (src); - num_searches = nm_ip6_config_get_num_searches (src); - - for (i = 0; i < num_searches; i++) { - const char *search; - - search = nm_ip6_config_get_search (src, i); - if (!DOMAIN_IS_VALID (search)) - continue; - add_string_item (rc->searches, search); - } - - if (num_domains > 1 || !num_searches) { - for (i = 0; i < num_domains; i++) { - const char *domain; - - domain = nm_ip6_config_get_domain (src, i); - if (!DOMAIN_IS_VALID (domain)) - continue; - add_string_item (rc->searches, domain); - } - } - - num = nm_ip6_config_get_num_dns_options (src); - for (i = 0; i < num; i++) { - const char *option; - - option = nm_ip6_config_get_dns_option (src, i); - add_dns_option_item (rc->options, option, TRUE); - } -} - -static void -merge_one_ip_config_data (NMDnsManager *self, - NMResolvConfData *rc, - NMDnsIPConfigData *data) -{ - if (NM_IS_IP4_CONFIG (data->config)) - merge_one_ip4_config (rc, (NMIP4Config *) data->config); - else if (NM_IS_IP6_CONFIG (data->config)) - merge_one_ip6_config (rc, (NMIP6Config *) data->config, data->iface); - else - g_return_if_reached (); -} - -static GPid -run_netconfig (NMDnsManager *self, GError **error, gint *stdin_fd) -{ - char *argv[5]; - gs_free char *tmp = NULL; - GPid pid = -1; - - argv[0] = NETCONFIG_PATH; - argv[1] = "modify"; - argv[2] = "--service"; - argv[3] = "NetworkManager"; - argv[4] = NULL; - - _LOGD ("spawning '%s'", - (tmp = g_strjoinv (" ", argv))); - - if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, - NULL, &pid, stdin_fd, NULL, NULL, error)) - return -1; - - return pid; -} - -static void -write_to_netconfig (NMDnsManager *self, gint fd, const char *key, const char *value) -{ - char *str; - int x; - - str = g_strdup_printf ("%s='%s'\n", key, value); - _LOGD ("writing to netconfig: %s", str); - x = write (fd, str, strlen (str)); - g_free (str); -} - -static SpawnResult -dispatch_netconfig (NMDnsManager *self, - char **searches, - char **nameservers, - const char *nis_domain, - char **nis_servers, - GError **error) -{ - char *str; - GPid pid; - gint fd; - int status; - - pid = run_netconfig (self, error, &fd); - if (pid <= 0) - return SR_NOTFOUND; - - /* NM is writing already-merged DNS information to netconfig, so it - * does not apply to a specific network interface. - */ - write_to_netconfig (self, fd, "INTERFACE", "NetworkManager"); - - if (searches) { - str = g_strjoinv (" ", searches); - write_to_netconfig (self, fd, "DNSSEARCH", str); - g_free (str); - } - - if (nameservers) { - str = g_strjoinv (" ", nameservers); - write_to_netconfig (self, fd, "DNSSERVERS", str); - g_free (str); - } - - if (nis_domain) - write_to_netconfig (self, fd, "NISDOMAIN", nis_domain); - - if (nis_servers) { - str = g_strjoinv (" ", nis_servers); - write_to_netconfig (self, fd, "NISSERVERS", str); - g_free (str); - } - - close (fd); - - /* Wait until the process exits */ - if (!nm_utils_kill_child_sync (pid, 0, LOGD_DNS, "netconfig", &status, 1000, 0)) { - int errsv = errno; - - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, - "Error waiting for netconfig to exit: %s", - strerror (errsv)); - return SR_ERROR; - } - if (!WIFEXITED (status) || WEXITSTATUS (status) != EXIT_SUCCESS) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, - "Error calling netconfig: %s %d", - WIFEXITED (status) ? "exited with status" : (WIFSIGNALED (status) ? "exited with signal" : "exited with unknown reason"), - WIFEXITED (status) ? WEXITSTATUS (status) : (WIFSIGNALED (status) ? WTERMSIG (status) : status)); - return SR_ERROR; - } - return SR_SUCCESS; -} - -static char * -create_resolv_conf (char **searches, - char **nameservers, - char **options) -{ - gs_free char *searches_str = NULL; - gs_free char *nameservers_str = NULL; - gs_free char *options_str = NULL; - char *tmp_str; - GString *str; - int i; - - if (searches) { - tmp_str = g_strjoinv (" ", searches); - searches_str = g_strconcat ("search ", tmp_str, "\n", NULL); - g_free (tmp_str); - } - - if (options) { - tmp_str = g_strjoinv (" ", options); - options_str = g_strconcat ("options ", tmp_str, "\n", NULL); - g_free (tmp_str); - } - - if (nameservers) { - int num = g_strv_length (nameservers); - - str = g_string_new (""); - for (i = 0; i < num; i++) { - if (i == 3) { - g_string_append (str, "# "); - g_string_append (str, "NOTE: the libc resolver may not support more than 3 nameservers."); - g_string_append (str, "\n# "); - g_string_append (str, "The nameservers listed below may not be recognized."); - g_string_append_c (str, '\n'); - } - - g_string_append (str, "nameserver "); - g_string_append (str, nameservers[i]); - g_string_append_c (str, '\n'); - } - nameservers_str = g_string_free (str, FALSE); - } - - return g_strdup_printf ("# Generated by NetworkManager\n%s%s%s", - searches_str ?: "", - nameservers_str ?: "", - options_str ?: ""); -} - -static gboolean -write_resolv_conf_contents (FILE *f, - const char *content, - GError **error) -{ - int errsv; - - if (fprintf (f, "%s", content) < 0) { - errsv = errno; - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not write " _PATH_RESCONF ": %s", - g_strerror (errsv)); - errno = errsv; - return FALSE; - } - - return TRUE; -} - -static gboolean -write_resolv_conf (FILE *f, - char **searches, - char **nameservers, - char **options, - GError **error) -{ - gs_free char *content = NULL; - - content = create_resolv_conf (searches, nameservers, options); - return write_resolv_conf_contents (f, content, error); -} - -static SpawnResult -dispatch_resolvconf (NMDnsManager *self, - char **searches, - char **nameservers, - char **options, - GError **error) -{ - gs_free char *cmd = NULL; - FILE *f; - gboolean success = FALSE; - int errnosv, err; - - if (!g_file_test (RESOLVCONF_PATH, G_FILE_TEST_IS_EXECUTABLE)) { - g_set_error_literal (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - RESOLVCONF_PATH " is not executable"); - return SR_NOTFOUND; - } - - if (!searches && !nameservers) { - _LOGI ("Removing DNS information from %s", RESOLVCONF_PATH); - - cmd = g_strconcat (RESOLVCONF_PATH, " -d ", "NetworkManager", NULL); - if (nm_spawn_process (cmd, error) != 0) - return SR_ERROR; - - return SR_SUCCESS; - } - - _LOGI ("Writing DNS information to %s", RESOLVCONF_PATH); - - cmd = g_strconcat (RESOLVCONF_PATH, " -a ", "NetworkManager", NULL); - if ((f = popen (cmd, "w")) == NULL) { - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not write to %s: %s", - RESOLVCONF_PATH, - g_strerror (errno)); - return SR_ERROR; - } - - success = write_resolv_conf (f, searches, nameservers, options, error); - err = pclose (f); - if (err < 0) { - errnosv = errno; - g_clear_error (error); - g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errnosv), - "Failed to close pipe to resolvconf: %d", errnosv); - return SR_ERROR; - } else if (err > 0) { - _LOGW ("resolvconf failed with status %d", err); - g_clear_error (error); - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "resolvconf failed with status %d", err); - return SR_ERROR; - } - - return success ? SR_SUCCESS : SR_ERROR; -} - -#define MY_RESOLV_CONF NMRUNDIR "/resolv.conf" -#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF ".tmp" -#define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager" - -static SpawnResult -update_resolv_conf (NMDnsManager *self, - char **searches, - char **nameservers, - char **options, - GError **error, - NMDnsManagerResolvConfManager rc_manager) -{ - FILE *f; - struct stat st; - gboolean success; - gs_free char *content = NULL; - SpawnResult write_file_result = SR_SUCCESS; - int errsv; - const char *rc_path = _PATH_RESCONF; - nm_auto_free char *rc_path_real = NULL; - - /* If we are not managing /etc/resolv.conf and it points to - * MY_RESOLV_CONF, don't write the private DNS configuration to - * MY_RESOLV_CONF otherwise we would overwrite the changes done by - * some external application. - * - * This is the only situation, where we don't try to update our - * internal resolv.conf file. */ - if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED) { - gs_free char *path = g_file_read_link (_PATH_RESCONF, NULL); - - if (g_strcmp0 (path, MY_RESOLV_CONF) == 0) { - _LOGD ("update-resolv-conf: not updating " _PATH_RESCONF - " since it points to " MY_RESOLV_CONF); - return SR_SUCCESS; - } - } - - content = create_resolv_conf (searches, nameservers, options); - - if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE) { - GError *local = NULL; - - rc_path_real = realpath (rc_path, NULL); - if (rc_path_real) - rc_path = rc_path_real; - - /* we first write to /etc/resolv.conf directly. If that fails, - * we still continue to write to runstatedir but remember the - * error. */ - if (!g_file_set_contents (rc_path, content, -1, &local)) { - _LOGT ("update-resolv-conf: write to %s failed (rc-manager=%s, %s)", - rc_path, _rc_manager_to_string (rc_manager), local->message); - write_file_result = SR_ERROR; - g_propagate_error (error, local); - error = NULL; - } else { - _LOGT ("update-resolv-conf: write to %s succeeded (rc-manager=%s)", - rc_path, _rc_manager_to_string (rc_manager)); - } - } - - if ((f = fopen (MY_RESOLV_CONF_TMP, "we")) == NULL) { - errsv = errno; - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not open %s: %s", - MY_RESOLV_CONF_TMP, - g_strerror (errsv)); - _LOGT ("update-resolv-conf: open temporary file %s failed (%s)", - MY_RESOLV_CONF_TMP, g_strerror (errsv)); - return SR_ERROR; - } - - success = write_resolv_conf_contents (f, content, error); - if (!success) { - errsv = errno; - _LOGT ("update-resolv-conf: write temporary file %s failed (%s)", - MY_RESOLV_CONF_TMP, g_strerror (errsv)); - } - - if (fclose (f) < 0) { - if (success) { - errsv = errno; - /* only set an error here if write_resolv_conf() was successful, - * since its error is more important. - */ - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not close %s: %s", - MY_RESOLV_CONF_TMP, - g_strerror (errsv)); - _LOGT ("update-resolv-conf: close temporary file %s failed (%s)", - MY_RESOLV_CONF_TMP, g_strerror (errsv)); - } - return SR_ERROR; - } else if (!success) - return SR_ERROR; - - if (rename (MY_RESOLV_CONF_TMP, MY_RESOLV_CONF) < 0) { - errsv = errno; - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not replace %s: %s", - MY_RESOLV_CONF, - g_strerror (errno)); - _LOGT ("update-resolv-conf: failed to rename temporary file %s to %s (%s)", - MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, g_strerror (errsv)); - return SR_ERROR; - } - - if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE) { - _LOGT ("update-resolv-conf: write internal file %s succeeded (rc-manager=%s)", - rc_path, _rc_manager_to_string (rc_manager)); - return write_file_result; - } - - if (rc_manager != NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK) { - _LOGT ("update-resolv-conf: write internal file %s succeeded", MY_RESOLV_CONF); - return SR_SUCCESS; - } - - /* A symlink pointing to NM's own resolv.conf (MY_RESOLV_CONF) is always - * overwritten to ensure that changes are indicated with inotify. Symlinks - * pointing to any other file are never overwritten. - */ - if (lstat (_PATH_RESCONF, &st) != 0) { - errsv = errno; - if (errsv != ENOENT) { - /* NM cannot read /etc/resolv.conf */ - _LOGT ("update-resolv-conf: write internal file %s succeeded but lstat(%s) failed (%s)", - MY_RESOLV_CONF, _PATH_RESCONF, g_strerror (errsv)); - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not lstat %s: %s", - _PATH_RESCONF, - g_strerror (errsv)); - return SR_ERROR; - } - } else { - if (S_ISLNK (st.st_mode)) { - if (stat (_PATH_RESCONF, &st) != -1) { - gs_free char *path = g_file_read_link (_PATH_RESCONF, NULL); - - if (!path || !nm_streq (path, MY_RESOLV_CONF)) { - /* It's not NM's symlink; do nothing */ - _LOGT ("update-resolv-conf: write internal file %s succeeded " - "but don't update %s as it points to %s", - MY_RESOLV_CONF, _PATH_RESCONF, path ?: ""); - return SR_SUCCESS; - } - - /* resolv.conf is a symlink owned by NM and the target is accessible - */ - } else { - /* resolv.conf is a symlink but the target is not accessible; - * some other program is probably managing resolv.conf and - * NM should not touch it. - */ - _LOGT ("update-resolv-conf: write internal file %s succeeded " - "but don't update %s as the symlinks points somewhere else", - MY_RESOLV_CONF, _PATH_RESCONF); - return SR_SUCCESS; - } - } - } - - /* By this point, either /etc/resolv.conf does not exist, is a regular - * file, or is a symlink already owned by NM. In all cases /etc/resolv.conf - * is replaced with a symlink pointing to NM's resolv.conf in /var/run/. - */ - if ( unlink (RESOLV_CONF_TMP) != 0 - && ((errsv = errno) != ENOENT)) { - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not unlink %s: %s", - RESOLV_CONF_TMP, - g_strerror (errsv)); - _LOGT ("update-resolv-conf: write internal file %s succeeded " - "but canot delete temporary file %s: %s", - MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv)); - return SR_ERROR; - } - - if (symlink (MY_RESOLV_CONF, RESOLV_CONF_TMP) == -1) { - errsv = errno; - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not create symlink %s pointing to %s: %s", - RESOLV_CONF_TMP, - MY_RESOLV_CONF, - g_strerror (errsv)); - _LOGT ("update-resolv-conf: write internal file %s succeeded " - "but failed to symlink %s: %s", - MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv)); - return SR_ERROR; - } - - if (rename (RESOLV_CONF_TMP, _PATH_RESCONF) == -1) { - errsv = errno; - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Could not rename %s to %s: %s", - RESOLV_CONF_TMP, - _PATH_RESCONF, - g_strerror (errsv)); - _LOGT ("update-resolv-conf: write internal file %s succeeded " - "but failed to rename temporary symlink %s to %s: %s", - MY_RESOLV_CONF, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv)); - return SR_ERROR; - } - - _LOGT ("update-resolv-conf: write internal file %s succeeded and update symlink %s", - MY_RESOLV_CONF, _PATH_RESCONF); - return SR_SUCCESS; -} - -static void -compute_hash (NMDnsManager *self, const NMGlobalDnsConfig *global, guint8 buffer[HASH_LEN]) -{ - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - GChecksum *sum; - gsize len = HASH_LEN; - guint i; - - sum = g_checksum_new (G_CHECKSUM_SHA1); - g_assert (len == g_checksum_type_get_length (G_CHECKSUM_SHA1)); - - if (global) - nm_global_dns_config_update_checksum (global, sum); - else { - for (i = 0; i < priv->configs->len; i++) { - NMDnsIPConfigData *data = priv->configs->pdata[i]; - - if (NM_IS_IP4_CONFIG (data->config)) - nm_ip4_config_hash ((NMIP4Config *) data->config, sum, TRUE); - else if (NM_IS_IP6_CONFIG (data->config)) - nm_ip6_config_hash ((NMIP6Config *) data->config, sum, TRUE); - } - } - - g_checksum_get_digest (sum, buffer, &len); - g_checksum_free (sum); -} - -static gboolean -merge_global_dns_config (NMResolvConfData *rc, NMGlobalDnsConfig *global_conf) -{ - NMGlobalDnsDomain *default_domain; - const char *const *searches; - const char *const *options; - const char *const *servers; - gint i; - - if (!global_conf) - return FALSE; - - searches = nm_global_dns_config_get_searches (global_conf); - options = nm_global_dns_config_get_options (global_conf); - - for (i = 0; searches && searches[i]; i++) { - if (DOMAIN_IS_VALID (searches[i])) - add_string_item (rc->searches, searches[i]); - } - - for (i = 0; options && options[i]; i++) - add_string_item (rc->options, options[i]); - - default_domain = nm_global_dns_config_lookup_domain (global_conf, "*"); - g_assert (default_domain); - servers = nm_global_dns_domain_get_servers (default_domain); - for (i = 0; servers && servers[i]; i++) - add_string_item (rc->nameservers, servers[i]); - - return TRUE; -} - -static const char * -get_nameserver_list (void *config, GString **str) -{ - NMIP4Config *ip4; - NMIP6Config *ip6; - guint num, i; - - nm_assert (str); - - if (*str) - g_string_truncate (*str, 0); - else - *str = g_string_sized_new (64); - - if (NM_IS_IP4_CONFIG (config)) { - ip4 = (NMIP4Config *) config; - num = nm_ip4_config_get_num_nameservers (ip4); - for (i = 0; i < num; i++) { - g_string_append (*str, - nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (ip4, i), - NULL)); - g_string_append_c (*str, ' '); - } - } else if (NM_IS_IP6_CONFIG (config)) { - ip6 = (NMIP6Config *) config; - num = nm_ip6_config_get_num_nameservers (ip6); - for (i = 0; i < num; i++) { - g_string_append (*str, - nm_utils_inet6_ntop (nm_ip6_config_get_nameserver (ip6, i), - NULL)); - g_string_append_c (*str, ' '); - } - } else - g_return_val_if_reached (NULL); - - return (*str)->str; -} - -static gboolean -update_dns (NMDnsManager *self, - gboolean no_caching, - GError **error) -{ - NMDnsManagerPrivate *priv; - NMResolvConfData rc; - const char *nis_domain = NULL; - char **searches = NULL; - char **options = NULL; - char **nameservers = NULL; - char **nis_servers = NULL; - int num, i, len; - gboolean caching = FALSE, update = TRUE; - gboolean resolv_conf_updated = FALSE; - SpawnResult result = SR_ERROR; - NMConfigData *data; - NMGlobalDnsConfig *global_config; - gs_free NMDnsIPConfigData **plugin_confs = NULL; - nm_auto_free_gstring GString *tmp_gstring = NULL; - - g_return_val_if_fail (!error || !*error, FALSE); - - priv = NM_DNS_MANAGER_GET_PRIVATE (self); - nm_clear_g_source (&priv->plugin_ratelimit.timer); - - if (NM_IN_SET (priv->rc_manager, NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, - NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE)) { - update = FALSE; - _LOGD ("update-dns: not updating resolv.conf"); - } else { - priv->dns_touched = TRUE; - _LOGD ("update-dns: updating resolv.conf"); - } - - data = nm_config_get_data (priv->config); - global_config = nm_config_data_get_global_dns_config (data); - - if (priv->need_sort) { - g_ptr_array_sort (priv->configs, ip_config_data_ptr_compare); - priv->need_sort = FALSE; - } - - /* Update hash with config we're applying */ - compute_hash (self, global_config, priv->hash); - - rc.nameservers = g_ptr_array_new (); - rc.searches = g_ptr_array_new (); - rc.options = g_ptr_array_new (); - rc.nis_domain = NULL; - rc.nis_servers = g_ptr_array_new (); - - if (global_config) - merge_global_dns_config (&rc, global_config); - else { - int prio, prev_prio = 0; - NMDnsIPConfigData *current; - gboolean skip = FALSE, v4; - - plugin_confs = g_new (NMDnsIPConfigData *, priv->configs->len + 1); - - for (i = 0; i < priv->configs->len; i++) { - current = priv->configs->pdata[i]; - v4 = NM_IS_IP4_CONFIG (current->config); - - prio = v4 ? - nm_ip4_config_get_dns_priority ((NMIP4Config *) current->config) : - nm_ip6_config_get_dns_priority ((NMIP6Config *) current->config); - - if (prev_prio < 0 && prio != prev_prio) { - skip = TRUE; - plugin_confs[i] = NULL; - } - - prev_prio = prio; - - _LOGT ("config: %8d %-7s v%c %-16s %s: %s", - prio, - _config_type_to_string (current->type), - v4 ? '4' : '6', - current->iface, - skip ? "" : "", - get_nameserver_list (current->config, &tmp_gstring)); - - if (!skip) { - merge_one_ip_config_data (self, &rc, current); - plugin_confs[i] = current; - } - } - plugin_confs[i] = NULL; - } - - /* If the hostname is a FQDN ("dcbw.example.com"), then add the domain part of it - * ("example.com") to the searches list, to ensure that we can still resolve its - * non-FQ form ("dcbw") too. (Also, if there are no other search domains specified, - * this makes a good default.) However, if the hostname is the top level of a domain - * (eg, "example.com"), then use the hostname itself as the search (since the user is - * unlikely to want "com" as a search domain). - */ - if (priv->hostname) { - const char *hostdomain = strchr (priv->hostname, '.'); - - if ( hostdomain - && !nm_utils_ipaddr_valid (AF_UNSPEC, priv->hostname)) { - hostdomain++; - if (DOMAIN_IS_VALID (hostdomain)) - add_string_item (rc.searches, hostdomain); - else if (DOMAIN_IS_VALID (priv->hostname)) - add_string_item (rc.searches, priv->hostname); - } - } - - /* Per 'man resolv.conf', the search list is limited to 6 domains - * totalling 256 characters. - */ - num = MIN (rc.searches->len, 6); - for (i = 0, len = 0; i < num; i++) { - len += strlen (rc.searches->pdata[i]) + 1; /* +1 for spaces */ - if (len > 256) - break; - } - g_ptr_array_set_size (rc.searches, i); - if (rc.searches->len) { - g_ptr_array_add (rc.searches, NULL); - searches = (char **) g_ptr_array_free (rc.searches, FALSE); - } else - g_ptr_array_free (rc.searches, TRUE); - - if (rc.options->len) { - g_ptr_array_add (rc.options, NULL); - options = (char **) g_ptr_array_free (rc.options, FALSE); - } else - g_ptr_array_free (rc.options, TRUE); - - if (rc.nameservers->len) { - g_ptr_array_add (rc.nameservers, NULL); - nameservers = (char **) g_ptr_array_free (rc.nameservers, FALSE); - } else - g_ptr_array_free (rc.nameservers, TRUE); - - if (rc.nis_servers->len) { - g_ptr_array_add (rc.nis_servers, NULL); - nis_servers = (char **) g_ptr_array_free (rc.nis_servers, FALSE); - } else - g_ptr_array_free (rc.nis_servers, TRUE); - - nis_domain = rc.nis_domain; - - /* Let any plugins do their thing first */ - if (priv->plugin) { - NMDnsPlugin *plugin = priv->plugin; - const char *plugin_name = nm_dns_plugin_get_name (plugin); - - if (nm_dns_plugin_is_caching (plugin)) { - if (no_caching) { - _LOGD ("update-dns: plugin %s ignored (caching disabled)", - plugin_name); - goto skip; - } - caching = TRUE; - } - - _LOGD ("update-dns: updating plugin %s", plugin_name); - if (!nm_dns_plugin_update (plugin, - (const NMDnsIPConfigData **) plugin_confs, - global_config, - priv->hostname)) { - _LOGW ("update-dns: plugin %s update failed", plugin_name); - - /* If the plugin failed to update, we shouldn't write out a local - * caching DNS configuration to resolv.conf. - */ - caching = FALSE; - } - - skip: - ; - } - - /* If caching was successful, we only send 127.0.0.1 to /etc/resolv.conf - * to ensure that the glibc resolver doesn't try to round-robin nameservers, - * but only uses the local caching nameserver. - */ - if (caching) { - if (nameservers) - g_strfreev (nameservers); - nameservers = g_new0 (char*, 2); - nameservers[0] = g_strdup ("127.0.0.1"); - } - - if (update) { - switch (priv->rc_manager) { - case NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK: - case NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: - result = update_resolv_conf (self, searches, nameservers, options, error, priv->rc_manager); - resolv_conf_updated = TRUE; - break; - case NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: - result = dispatch_resolvconf (self, searches, nameservers, options, error); - break; - case NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG: - result = dispatch_netconfig (self, searches, nameservers, nis_domain, - nis_servers, error); - break; - default: - g_assert_not_reached (); - } - - if (result == SR_NOTFOUND) { - _LOGD ("update-dns: program not available, writing to resolv.conf"); - g_clear_error (error); - result = update_resolv_conf (self, searches, nameservers, options, error, NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK); - resolv_conf_updated = TRUE; - } - } - - /* Unless we've already done it, update private resolv.conf in NMRUNDIR - ignoring any errors */ - if (!resolv_conf_updated) - update_resolv_conf (self, searches, nameservers, options, NULL, NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED); - - /* signal that resolv.conf was changed */ - if (update && result == SR_SUCCESS) - g_signal_emit (self, signals[CONFIG_CHANGED], 0); - - if (searches) - g_strfreev (searches); - if (options) - g_strfreev (options); - if (nameservers) - g_strfreev (nameservers); - if (nis_servers) - g_strfreev (nis_servers); - - return !update || result == SR_SUCCESS; -} - -static void -plugin_failed (NMDnsPlugin *plugin, gpointer user_data) -{ - NMDnsManager *self = NM_DNS_MANAGER (user_data); - GError *error = NULL; - - /* Errors with non-caching plugins aren't fatal */ - if (!nm_dns_plugin_is_caching (plugin)) - return; - - /* Disable caching until the next DNS update */ - if (!update_dns (self, TRUE, &error)) { - _LOGW ("could not commit DNS changes: %s", error->message); - g_clear_error (&error); - } -} - -static gboolean -plugin_child_quit_update_dns (gpointer user_data) -{ - GError *error = NULL; - NMDnsManager *self = NM_DNS_MANAGER (user_data); - - /* Let the plugin try to spawn the child again */ - if (!update_dns (self, FALSE, &error)) { - _LOGW ("could not commit DNS changes: %s", error->message); - g_clear_error (&error); - } - - return G_SOURCE_REMOVE; -} - -static void -plugin_child_quit (NMDnsPlugin *plugin, int exit_status, gpointer user_data) -{ - NMDnsManager *self = NM_DNS_MANAGER (user_data); - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - gint64 ts = nm_utils_get_monotonic_timestamp_ms (); - - _LOGW ("plugin %s child quit unexpectedly", nm_dns_plugin_get_name (plugin)); - - if ( !priv->plugin_ratelimit.ts - || (ts - priv->plugin_ratelimit.ts) / 1000 > PLUGIN_RATELIMIT_INTERVAL) { - priv->plugin_ratelimit.ts = ts; - priv->plugin_ratelimit.num_restarts = 0; - } else { - priv->plugin_ratelimit.num_restarts++; - if (priv->plugin_ratelimit.num_restarts > PLUGIN_RATELIMIT_BURST) { - _LOGW ("plugin %s child respawning too fast, delaying update for %u seconds", - nm_dns_plugin_get_name (plugin), PLUGIN_RATELIMIT_DELAY); - priv->plugin_ratelimit.timer = g_timeout_add_seconds (PLUGIN_RATELIMIT_DELAY, - plugin_child_quit_update_dns, - self); - return; - } - } - - plugin_child_quit_update_dns (self); -} - -static void -ip_config_dns_priority_changed (gpointer config, - GParamSpec *pspec, - NMDnsManager *self) -{ - NM_DNS_MANAGER_GET_PRIVATE (self)->need_sort = TRUE; -} - -static void -forget_data (NMDnsManager *self, NMDnsIPConfigData *data) -{ - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - if (data == priv->best_conf4) - priv->best_conf4 = NULL; - else if (data == priv->best_conf6) - priv->best_conf6 = NULL; - - g_signal_handlers_disconnect_by_func (data->config, ip_config_dns_priority_changed, self); -} - -static gboolean -nm_dns_manager_add_ip_config (NMDnsManager *self, - const char *iface, - gpointer config, - NMDnsIPConfigType cfg_type) -{ - NMDnsManagerPrivate *priv; - GError *error = NULL; - NMDnsIPConfigData *data; - gboolean v4 = NM_IS_IP4_CONFIG (config); - guint i; - - g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE); - g_return_val_if_fail (config, FALSE); - g_return_val_if_fail (iface && iface[0], FALSE); - - priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - for (i = 0; i < priv->configs->len; i++) { - data = priv->configs->pdata[i]; - if (data->config == config) { - if ( nm_streq (data->iface, iface) - && data->type == cfg_type) - return FALSE; - else { - forget_data (self, data); - g_ptr_array_remove_index_fast (priv->configs, i); - break; - } - } - } - - data = ip_config_data_new (config, cfg_type, iface); - g_ptr_array_add (priv->configs, data); - g_signal_connect (config, - v4 ? - "notify::" NM_IP4_CONFIG_DNS_PRIORITY : - "notify::" NM_IP6_CONFIG_DNS_PRIORITY, - (GCallback) ip_config_dns_priority_changed, self); - priv->need_sort = TRUE; - - if (cfg_type == NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE) { - /* Only one best-device per IP version is allowed */ - if (v4) { - if (priv->best_conf4) - priv->best_conf4->type = NM_DNS_IP_CONFIG_TYPE_DEFAULT; - priv->best_conf4 = data; - } else { - if (priv->best_conf6) - priv->best_conf6->type = NM_DNS_IP_CONFIG_TYPE_DEFAULT; - priv->best_conf6 = data; - } - } - - if (!priv->updates_queue && !update_dns (self, FALSE, &error)) { - _LOGW ("could not commit DNS changes: %s", error->message); - g_clear_error (&error); - } - - return TRUE; -} - -gboolean -nm_dns_manager_add_ip4_config (NMDnsManager *self, - const char *iface, - NMIP4Config *config, - NMDnsIPConfigType cfg_type) -{ - return nm_dns_manager_add_ip_config (self, iface, config, cfg_type); -} - -gboolean -nm_dns_manager_add_ip6_config (NMDnsManager *self, - const char *iface, - NMIP6Config *config, - NMDnsIPConfigType cfg_type) -{ - return nm_dns_manager_add_ip_config (self, iface, config, cfg_type); -} - -static gboolean -nm_dns_manager_remove_ip_config (NMDnsManager *self, gpointer config) -{ - NMDnsManagerPrivate *priv; - GError *error = NULL; - NMDnsIPConfigData *data; - guint i; - - g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE); - g_return_val_if_fail (config, FALSE); - - priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - for (i = 0; i < priv->configs->len; i++) { - data = priv->configs->pdata[i]; - - if (data->config == config) { - forget_data (self, data); - g_ptr_array_remove_index (priv->configs, i); - - if (!priv->updates_queue && !update_dns (self, FALSE, &error)) { - _LOGW ("could not commit DNS changes: %s", error->message); - g_clear_error (&error); - } - - return TRUE; - } - } - return FALSE; -} - -gboolean -nm_dns_manager_remove_ip4_config (NMDnsManager *self, NMIP4Config *config) -{ - return nm_dns_manager_remove_ip_config (self, config); -} - -gboolean -nm_dns_manager_remove_ip6_config (NMDnsManager *self, NMIP6Config *config) -{ - return nm_dns_manager_remove_ip_config (self, config); -} - -void -nm_dns_manager_set_initial_hostname (NMDnsManager *self, - const char *hostname) -{ - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - priv->hostname = g_strdup (hostname); -} - -void -nm_dns_manager_set_hostname (NMDnsManager *self, - const char *hostname) -{ - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - GError *error = NULL; - const char *filtered = NULL; - - /* Certain hostnames we don't want to include in resolv.conf 'searches' */ - if ( hostname - && nm_utils_is_specific_hostname (hostname) - && !strstr (hostname, ".in-addr.arpa") - && strchr (hostname, '.')) { - filtered = hostname; - } - - if ( (!priv->hostname && !filtered) - || (priv->hostname && filtered && !strcmp (priv->hostname, filtered))) - return; - - g_free (priv->hostname); - priv->hostname = g_strdup (filtered); - - if (!priv->updates_queue && !update_dns (self, FALSE, &error)) { - _LOGW ("could not commit DNS changes: %s", error->message); - g_clear_error (&error); - } -} - -gboolean -nm_dns_manager_get_resolv_conf_explicit (NMDnsManager *self) -{ - NMDnsManagerPrivate *priv; - - g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE); - - priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - if ( NM_IN_SET (priv->rc_manager, NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, - NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE) - || priv->plugin) - return FALSE; - - return TRUE; -} - -void -nm_dns_manager_begin_updates (NMDnsManager *self, const char *func) -{ - NMDnsManagerPrivate *priv; - - g_return_if_fail (self != NULL); - priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - /* Save current hash when starting a new batch */ - if (priv->updates_queue == 0) - memcpy (priv->prev_hash, priv->hash, sizeof (priv->hash)); - - priv->updates_queue++; - - _LOGD ("(%s): queueing DNS updates (%d)", func, priv->updates_queue); -} - -void -nm_dns_manager_end_updates (NMDnsManager *self, const char *func) -{ - NMDnsManagerPrivate *priv; - GError *error = NULL; - gboolean changed; - guint8 new[HASH_LEN]; - - g_return_if_fail (self != NULL); - - priv = NM_DNS_MANAGER_GET_PRIVATE (self); - g_return_if_fail (priv->updates_queue > 0); - - if (priv->need_sort) { - g_ptr_array_sort (priv->configs, ip_config_data_ptr_compare); - priv->need_sort = FALSE; - } - - compute_hash (self, nm_config_data_get_global_dns_config (nm_config_get_data (priv->config)), new); - changed = (memcmp (new, priv->prev_hash, sizeof (new)) != 0) ? TRUE : FALSE; - _LOGD ("(%s): DNS configuration %s", func, changed ? "changed" : "did not change"); - - priv->updates_queue--; - if ((priv->updates_queue > 0) || (changed == FALSE)) { - _LOGD ("(%s): no DNS changes to commit (%d)", func, priv->updates_queue); - return; - } - - /* Commit all the outstanding changes */ - _LOGD ("(%s): committing DNS changes (%d)", func, priv->updates_queue); - if (!update_dns (self, FALSE, &error)) { - _LOGW ("could not commit DNS changes: %s", error->message); - g_clear_error (&error); - } - - memset (priv->prev_hash, 0, sizeof (priv->prev_hash)); -} - -/******************************************************************/ - -static gboolean -_clear_plugin (NMDnsManager *self) -{ - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - if (priv->plugin) { - g_signal_handlers_disconnect_by_func (priv->plugin, plugin_failed, self); - g_signal_handlers_disconnect_by_func (priv->plugin, plugin_child_quit, self); - nm_dns_plugin_stop (priv->plugin); - g_clear_object (&priv->plugin); - return TRUE; - } - priv->plugin_ratelimit.ts = 0; - nm_clear_g_source (&priv->plugin_ratelimit.timer); - return FALSE; -} - -static NMDnsManagerResolvConfManager -_check_resconf_immutable (NMDnsManagerResolvConfManager rc_manager) -{ - struct stat st; - int fd, flags; - bool immutable = FALSE; - - switch (rc_manager) { - case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN: - case NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: - nm_assert_not_reached (); - /* fall-through */ - case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: - return NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED; - default: - - if (lstat (_PATH_RESCONF, &st) != 0) - return rc_manager; - - if (S_ISLNK (st.st_mode)) { - /* only regular files and directories can have extended file attributes. */ - switch (rc_manager) { - case NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK: - /* we don't care whether the link-target is immutable. - * If the symlink points to another file, rc-manager=symlink anyway backs off. - * Otherwise, we would only check whether our internal resolv.conf is immutable. */ - return NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK; - case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN: - case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: - case NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: - nm_assert_not_reached (); - /* fall-through */ - case NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: - case NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: - case NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG: - break; - } - } - - fd = open (_PATH_RESCONF, O_RDONLY | O_CLOEXEC); - if (fd != -1) { - if (ioctl (fd, FS_IOC_GETFLAGS, &flags) != -1) - immutable = NM_FLAGS_HAS (flags, FS_IMMUTABLE_FL); - close (fd); - } - return immutable ? NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE : rc_manager; - } -} - -NM_DEFINE_SINGLETON_GETTER (NMDnsManager, nm_dns_manager_get, NM_TYPE_DNS_MANAGER); - -static void -init_resolv_conf_mode (NMDnsManager *self, gboolean force_reload_plugin) -{ - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - NMDnsManagerResolvConfManager rc_manager; - const char *mode; - gboolean plugin_changed = FALSE; - - mode = nm_config_data_get_dns_mode (nm_config_get_data (priv->config)); - - if (nm_streq0 (mode, "none")) - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED; - else { - const char *man; - - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN; - man = nm_config_data_get_rc_manager (nm_config_get_data (priv->config)); - -again: - if (!man) { - /* nop */ - } else if (NM_IN_STRSET (man, "symlink", "none")) - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK; - else if (nm_streq (man, "file")) - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE; - else if (nm_streq (man, "resolvconf")) - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF; - else if (nm_streq (man, "netconfig")) - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG; - else if (nm_streq (man, "unmanaged")) - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED; - - if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN) { - if (man) { - _LOGW ("init: unknown resolv.conf manager \"%s\", fallback to \"%s\"", - man, ""NM_CONFIG_DEFAULT_DNS_RC_MANAGER); - } - man = ""NM_CONFIG_DEFAULT_DNS_RC_MANAGER; - rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK; - goto again; - } - } - - rc_manager = _check_resconf_immutable (rc_manager); - - if (nm_streq0 (mode, "dnsmasq")) { - if (force_reload_plugin || !NM_IS_DNS_DNSMASQ (priv->plugin)) { - _clear_plugin (self); - priv->plugin = nm_dns_dnsmasq_new (); - plugin_changed = TRUE; - } - } else if (nm_streq0 (mode, "unbound")) { - if (force_reload_plugin || !NM_IS_DNS_UNBOUND (priv->plugin)) { - _clear_plugin (self); - priv->plugin = nm_dns_unbound_new (); - plugin_changed = TRUE; - } - } else { - if (!NM_IN_STRSET (mode, "none", "default")) { - if (mode) - _LOGW ("init: unknown dns mode '%s'", mode); - mode = "default"; - } - if (_clear_plugin (self)) - plugin_changed = TRUE; - } - - if (plugin_changed && priv->plugin) { - g_signal_connect (priv->plugin, NM_DNS_PLUGIN_FAILED, G_CALLBACK (plugin_failed), self); - g_signal_connect (priv->plugin, NM_DNS_PLUGIN_CHILD_QUIT, G_CALLBACK (plugin_child_quit), self); - } - - if ( plugin_changed - || priv->rc_manager != rc_manager) { - priv->rc_manager = rc_manager; - _LOGI ("init: dns=%s, rc-manager=%s%s%s%s", - mode, _rc_manager_to_string (rc_manager), - NM_PRINT_FMT_QUOTED (priv->plugin, ", plugin=", nm_dns_plugin_get_name (priv->plugin), "", "")); - } -} - -static void -config_changed_cb (NMConfig *config, - NMConfigData *config_data, - NMConfigChangeFlags changes, - NMConfigData *old_data, - NMDnsManager *self) -{ - GError *error = NULL; - - if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_DNS_MODE | - NM_CONFIG_CHANGE_RC_MANAGER | - NM_CONFIG_CHANGE_CAUSE_SIGHUP | - NM_CONFIG_CHANGE_CAUSE_DNS_FULL)) { - /* reload the resolv-conf mode also on SIGHUP (when DNS_MODE didn't change). - * The reason is, that the configuration also depends on whether resolv.conf - * is immutable, thus, without the configuration changing, we always want to - * re-configure the mode. */ - init_resolv_conf_mode (self, - NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP - | NM_CONFIG_CHANGE_CAUSE_DNS_FULL)); - } - - if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP | - NM_CONFIG_CHANGE_CAUSE_SIGUSR1 | - NM_CONFIG_CHANGE_CAUSE_DNS_RC | - NM_CONFIG_CHANGE_CAUSE_DNS_FULL | - NM_CONFIG_CHANGE_DNS_MODE | - NM_CONFIG_CHANGE_RC_MANAGER | - NM_CONFIG_CHANGE_GLOBAL_DNS_CONFIG)) { - if (!update_dns (self, FALSE, &error)) { - _LOGW ("could not commit DNS changes: %s", error->message); - g_clear_error (&error); - } - } -} - -static void -nm_dns_manager_init (NMDnsManager *self) -{ - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - _LOGT ("creating..."); - - priv->config = g_object_ref (nm_config_get ()); - priv->configs = g_ptr_array_new_full (8, ip_config_data_destroy); - - /* Set the initial hash */ - compute_hash (self, NULL, NM_DNS_MANAGER_GET_PRIVATE (self)->hash); - - g_signal_connect (G_OBJECT (priv->config), - NM_CONFIG_SIGNAL_CONFIG_CHANGED, - G_CALLBACK (config_changed_cb), - self); - init_resolv_conf_mode (self, TRUE); -} - -static void -dispose (GObject *object) -{ - NMDnsManager *self = NM_DNS_MANAGER (object); - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - NMDnsIPConfigData *data; - GError *error = NULL; - guint i; - - _LOGT ("disposing"); - - _clear_plugin (self); - - /* If we're quitting, leave a valid resolv.conf in place, not one - * pointing to 127.0.0.1 if any plugins were active. Thus update - * DNS after disposing of all plugins. But if we haven't done any - * DNS updates yet, there's no reason to touch resolv.conf on shutdown. - */ - if (priv->dns_touched && !update_dns (self, TRUE, &error)) { - _LOGW ("could not commit DNS changes on shutdown: %s", error->message); - g_clear_error (&error); - priv->dns_touched = FALSE; - } - - if (priv->config) { - g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, self); - g_clear_object (&priv->config); - } - - if (priv->configs) { - for (i = 0; i < priv->configs->len; i++) { - data = priv->configs->pdata[i]; - forget_data (self, data); - } - g_ptr_array_free (priv->configs, TRUE); - priv->configs = NULL; - } - - nm_clear_g_source (&priv->plugin_ratelimit.timer); - - G_OBJECT_CLASS (nm_dns_manager_parent_class)->dispose (object); -} - -static void -finalize (GObject *object) -{ - NMDnsManager *self = NM_DNS_MANAGER (object); - NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); - - g_free (priv->hostname); - - G_OBJECT_CLASS (nm_dns_manager_parent_class)->finalize (object); -} - -static void -nm_dns_manager_class_init (NMDnsManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - /* virtual methods */ - object_class->dispose = dispose; - object_class->finalize = finalize; - - /* signals */ - signals[CONFIG_CHANGED] = - g_signal_new (NM_DNS_MANAGER_CONFIG_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - diff --git a/src/dns-manager/nm-dns-manager.h b/src/dns-manager/nm-dns-manager.h deleted file mode 100644 index 3deda582..00000000 --- a/src/dns-manager/nm-dns-manager.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2004 - 2005 Colin Walters - * Copyright (C) 2004 - 2013 Red Hat, Inc. - * Copyright (C) 2005 - 2008 Novell, Inc. - * and others - */ - -#ifndef __NETWORKMANAGER_DNS_MANAGER_H__ -#define __NETWORKMANAGER_DNS_MANAGER_H__ - -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" - -typedef enum { - NM_DNS_IP_CONFIG_TYPE_DEFAULT = 0, - NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE, - NM_DNS_IP_CONFIG_TYPE_VPN -} NMDnsIPConfigType; - -enum { - NM_DNS_PRIORITY_DEFAULT_NORMAL = 100, - NM_DNS_PRIORITY_DEFAULT_VPN = 50, -}; - -typedef struct { - gpointer config; - NMDnsIPConfigType type; - char *iface; -} NMDnsIPConfigData; - -#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ()) -#define NM_DNS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_DNS_MANAGER, NMDnsManager)) -#define NM_DNS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_DNS_MANAGER, NMDnsManagerClass)) -#define NM_IS_DNS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_DNS_MANAGER)) -#define NM_IS_DNS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_DNS_MANAGER)) -#define NM_DNS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_DNS_MANAGER, NMDnsManagerClass)) - -#define NM_DNS_MANAGER_CONFIG_CHANGED "config-changed" - -typedef struct _NMDnsManager NMDnsManager; -typedef struct _NMDnsManagerClass NMDnsManagerClass; - -GType nm_dns_manager_get_type (void); - -NMDnsManager * nm_dns_manager_get (void); - -/* Allow changes to be batched together */ -void nm_dns_manager_begin_updates (NMDnsManager *self, const char *func); -void nm_dns_manager_end_updates (NMDnsManager *self, const char *func); - -gboolean nm_dns_manager_add_ip4_config (NMDnsManager *self, - const char *iface, - NMIP4Config *config, - NMDnsIPConfigType cfg_type); - -gboolean nm_dns_manager_remove_ip4_config (NMDnsManager *self, NMIP4Config *config); - -gboolean nm_dns_manager_add_ip6_config (NMDnsManager *self, - const char *iface, - NMIP6Config *config, - NMDnsIPConfigType cfg_type); - -gboolean nm_dns_manager_remove_ip6_config (NMDnsManager *self, NMIP6Config *config); - -void nm_dns_manager_set_initial_hostname (NMDnsManager *self, - const char *hostname); -void nm_dns_manager_set_hostname (NMDnsManager *self, - const char *hostname); - -/** - * NMDnsManagerResolvConfManager - * @NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN: unspecified rc-manager. - * @NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: do not touch /etc/resolv.conf - * (but still write the internal copy -- unless it is symlinked by - * /etc/resolv.conf) - * @NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: similar to "unmanaged", - * but indicates that resolv.conf cannot be modified. - * @NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK: NM writes resolv.conf - * by symlinking it to the run state directory. - * @NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: Like SYMLINK, but instead of - * symlinking /etc/resolv.conf, write it as a file. - * @NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: NM is managing resolv.conf - through resolvconf - * @NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG: NM is managing resolv.conf - through netconfig - * - * NMDnsManager's management of resolv.conf - */ -typedef enum { - NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN, - NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, - NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE, - NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK, - NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE, - NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF, - NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG, -} NMDnsManagerResolvConfManager; - -gboolean nm_dns_manager_get_resolv_conf_explicit (NMDnsManager *self); - -#endif /* __NETWORKMANAGER_DNS_MANAGER_H__ */ diff --git a/src/dns-manager/nm-dns-plugin.c b/src/dns-manager/nm-dns-plugin.c deleted file mode 100644 index f065a1ce..00000000 --- a/src/dns-manager/nm-dns-plugin.c +++ /dev/null @@ -1,310 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2010 - 2012 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include - -#include "nm-core-internal.h" - -#include "nm-dns-plugin.h" -#include "NetworkManagerUtils.h" - -typedef struct { - GPid pid; - guint watch_id; - char *progname; - char *pidfile; -} NMDnsPluginPrivate; - -#define NM_DNS_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DNS_PLUGIN, NMDnsPluginPrivate)) - -G_DEFINE_TYPE_EXTENDED (NMDnsPlugin, nm_dns_plugin, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, {}) - -enum { - FAILED, - CHILD_QUIT, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -/******************************************************************************/ - -#define _NMLOG_PREFIX_NAME "dns-plugin" -#define _NMLOG_DOMAIN LOGD_DNS -#define _NMLOG(level, ...) \ - G_STMT_START { \ - const NMLogLevel __level = (level); \ - \ - if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ - char __prefix[20]; \ - const NMDnsPlugin *const __self = (self); \ - \ - _nm_log (__level, _NMLOG_DOMAIN, 0, \ - "%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, \ - (!__self \ - ? "" \ - : nm_sprintf_buf (__prefix, "[%p]", __self)) \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -/******************************************************************************/ - -gboolean -nm_dns_plugin_update (NMDnsPlugin *self, - const NMDnsIPConfigData **configs, - const NMGlobalDnsConfig *global_config, - const char *hostname) -{ - g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE); - - return NM_DNS_PLUGIN_GET_CLASS (self)->update (self, - configs, - global_config, - hostname); -} - -static gboolean -is_caching (NMDnsPlugin *self) -{ - return FALSE; -} - -gboolean -nm_dns_plugin_is_caching (NMDnsPlugin *self) -{ - return NM_DNS_PLUGIN_GET_CLASS (self)->is_caching (self); -} - -const char * -nm_dns_plugin_get_name (NMDnsPlugin *self) -{ - g_assert (NM_DNS_PLUGIN_GET_CLASS (self)->get_name); - return NM_DNS_PLUGIN_GET_CLASS (self)->get_name (self); -} - -/********************************************/ - -static void -_clear_pidfile (NMDnsPlugin *self) -{ - NMDnsPluginPrivate *priv = NM_DNS_PLUGIN_GET_PRIVATE (self); - - if (priv->pidfile) { - unlink (priv->pidfile); - g_clear_pointer (&priv->pidfile, g_free); - } -} - -static void -kill_existing (const char *progname, const char *pidfile, const char *kill_match) -{ - glong pid; - gs_free char *contents = NULL; - gs_free char *cmdline_contents = NULL; - guint64 start_time; - char proc_path[256]; - gs_free_error GError *error = NULL; - - if (!pidfile) - return; - - if (!kill_match) - g_return_if_reached (); - - if (!g_file_get_contents (pidfile, &contents, NULL, &error)) { - if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) - return; - goto out; - } - - pid = _nm_utils_ascii_str_to_int64 (contents, 10, 2, INT_MAX, -1); - if (pid == -1) - goto out; - - start_time = nm_utils_get_start_time_for_pid (pid, NULL, NULL); - if (start_time == 0) - goto out; - - nm_sprintf_buf (proc_path, "/proc/%ld/cmdline", pid); - if (!g_file_get_contents (proc_path, &cmdline_contents, NULL, NULL)) - goto out; - - if (!strstr (cmdline_contents, kill_match)) - goto out; - - nm_utils_kill_process_sync (pid, start_time, SIGKILL, _NMLOG_DOMAIN, - progname ?: "", - 0, 0, 1000); - -out: - unlink (pidfile); -} - -static void -watch_cb (GPid pid, gint status, gpointer user_data) -{ - NMDnsPlugin *self = NM_DNS_PLUGIN (user_data); - NMDnsPluginPrivate *priv = NM_DNS_PLUGIN_GET_PRIVATE (self); - - priv->pid = 0; - priv->watch_id = 0; - g_clear_pointer (&priv->progname, g_free); - _clear_pidfile (self); - - g_signal_emit (self, signals[CHILD_QUIT], 0, status); -} - -GPid -nm_dns_plugin_child_pid (NMDnsPlugin *self) -{ - NMDnsPluginPrivate *priv; - - g_return_val_if_fail (NM_IS_DNS_PLUGIN (self), 0); - - priv = NM_DNS_PLUGIN_GET_PRIVATE (self); - return priv->pid; -} - -GPid -nm_dns_plugin_child_spawn (NMDnsPlugin *self, - const char **argv, - const char *pidfile, - const char *kill_match) -{ - NMDnsPluginPrivate *priv; - GError *error = NULL; - GPid pid; - gs_free char *cmdline = NULL; - gs_free char *progname = NULL; - - g_return_val_if_fail (argv && argv[0], 0); - g_return_val_if_fail (NM_IS_DNS_PLUGIN (self), 0); - - priv = NM_DNS_PLUGIN_GET_PRIVATE (self); - - g_return_val_if_fail (!priv->pid, 0); - nm_assert (!priv->progname); - nm_assert (!priv->watch_id); - nm_assert (!priv->pidfile); - - progname = g_path_get_basename (argv[0]); - kill_existing (progname, pidfile, kill_match); - - _LOGI ("starting %s...", progname); - _LOGD ("command line: %s", - (cmdline = g_strjoinv (" ", (char **) argv))); - - if (!g_spawn_async (NULL, (char **) argv, NULL, - G_SPAWN_DO_NOT_REAP_CHILD, - nm_utils_setpgid, NULL, - &pid, - &error)) { - _LOGW ("failed to spawn %s: %s", - progname, error->message); - g_clear_error (&error); - return 0; - } - - _LOGD ("%s started with pid %d", progname, pid); - priv->watch_id = g_child_watch_add (pid, (GChildWatchFunc) watch_cb, self); - priv->pid = pid; - priv->progname = g_steal_pointer (&progname); - priv->pidfile = g_strdup (pidfile); - - return pid; -} - -gboolean -nm_dns_plugin_child_kill (NMDnsPlugin *self) -{ - NMDnsPluginPrivate *priv = NM_DNS_PLUGIN_GET_PRIVATE (self); - - nm_clear_g_source (&priv->watch_id); - if (priv->pid) { - nm_utils_kill_child_sync (priv->pid, SIGTERM, _NMLOG_DOMAIN, - priv->progname ?: "", NULL, 1000, 0); - priv->pid = 0; - g_clear_pointer (&priv->progname, g_free); - } - _clear_pidfile (self); - - return TRUE; -} - -void -nm_dns_plugin_stop (NMDnsPlugin *self) -{ - nm_dns_plugin_child_kill (self); -} - -/********************************************/ - -static void -nm_dns_plugin_init (NMDnsPlugin *self) -{ -} - -static void -dispose (GObject *object) -{ - NMDnsPlugin *self = NM_DNS_PLUGIN (object); - - nm_dns_plugin_stop (self); - - G_OBJECT_CLASS (nm_dns_plugin_parent_class)->dispose (object); -} - -static void -nm_dns_plugin_class_init (NMDnsPluginClass *plugin_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (plugin_class); - - g_type_class_add_private (plugin_class, sizeof (NMDnsPluginPrivate)); - - /* virtual methods */ - object_class->dispose = dispose; - plugin_class->is_caching = is_caching; - - /* signals */ - signals[FAILED] = - g_signal_new (NM_DNS_PLUGIN_FAILED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDnsPluginClass, failed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[CHILD_QUIT] = - g_signal_new (NM_DNS_PLUGIN_CHILD_QUIT, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDnsPluginClass, child_quit), - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); -} - diff --git a/src/dns-manager/nm-dns-plugin.h b/src/dns-manager/nm-dns-plugin.h deleted file mode 100644 index e24bc173..00000000 --- a/src/dns-manager/nm-dns-plugin.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2010 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DNS_PLUGIN_H__ -#define __NETWORKMANAGER_DNS_PLUGIN_H__ - -#include "nm-dns-manager.h" -#include "nm-config-data.h" - -#define NM_TYPE_DNS_PLUGIN (nm_dns_plugin_get_type ()) -#define NM_DNS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_PLUGIN, NMDnsPlugin)) -#define NM_DNS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_PLUGIN, NMDnsPluginClass)) -#define NM_IS_DNS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_PLUGIN)) -#define NM_IS_DNS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_PLUGIN)) -#define NM_DNS_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_PLUGIN, NMDnsPluginClass)) - -#define NM_DNS_PLUGIN_FAILED "failed" -#define NM_DNS_PLUGIN_CHILD_QUIT "child-quit" - -typedef struct { - GObject parent; -} NMDnsPlugin; - -typedef struct { - GObjectClass parent; - - /* Methods */ - - /* Called when DNS information is changed. 'configs' is an array - * of pointers to NMDnsIPConfigData sorted by priority. - * 'global_config' is the optional global DNS - * configuration. - */ - gboolean (*update) (NMDnsPlugin *self, - const NMDnsIPConfigData **configs, - const NMGlobalDnsConfig *global_config, - const char *hostname); - - /* Subclasses should override and return TRUE if they start a local - * caching nameserver that listens on localhost and would block any - * other local caching nameserver from operating. - */ - gboolean (*is_caching) (NMDnsPlugin *self); - - /* Subclasses should override this and return their plugin name */ - const char *(*get_name) (NMDnsPlugin *self); - - /* Signals */ - - /* Emitted by the plugin and consumed by NMDnsManager when - * some error happens with the nameserver subprocess. Causes NM to fall - * back to writing out a non-local-caching resolv.conf until the next - * DNS update. - */ - void (*failed) (NMDnsPlugin *self); - - /* Emitted by the plugin base class when the nameserver subprocess - * quits. This signal is consumed by the plugin subclasses and not - * by NMDnsManager. If the subclass decides the exit status (as returned - * by waitpid(2)) is fatal it should then emit the 'failed' signal. - */ - void (*child_quit) (NMDnsPlugin *self, gint status); -} NMDnsPluginClass; - -GType nm_dns_plugin_get_type (void); - -gboolean nm_dns_plugin_is_caching (NMDnsPlugin *self); - -const char *nm_dns_plugin_get_name (NMDnsPlugin *self); - -gboolean nm_dns_plugin_update (NMDnsPlugin *self, - const NMDnsIPConfigData **configs, - const NMGlobalDnsConfig *global_config, - const char *hostname); - -void nm_dns_plugin_stop (NMDnsPlugin *self); - -/* For subclasses/plugins */ - -/* Spawn a child process and watch for it to quit. 'argv' is the NULL-terminated - * argument vector to spawn the child with, where argv[0] is the full path to - * the child's executable. If 'pidfile' is given the process owning the PID - * contained in 'pidfile' will be killed if its command line matches 'kill_match' - * and the pidfile will be deleted. - */ -GPid nm_dns_plugin_child_spawn (NMDnsPlugin *self, - const char **argv, - const char *pidfile, - const char *kill_match); - -GPid nm_dns_plugin_child_pid (NMDnsPlugin *self); - -gboolean nm_dns_plugin_child_kill (NMDnsPlugin *self); - -#endif /* __NETWORKMANAGER_DNS_PLUGIN_H__ */ - diff --git a/src/dns-manager/nm-dns-unbound.c b/src/dns-manager/nm-dns-unbound.c deleted file mode 100644 index 66a287fd..00000000 --- a/src/dns-manager/nm-dns-unbound.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2014 Red Hat, Inc. - * Author: Pavel Å imerda - */ -#include "nm-default.h" - -#include "nm-dns-unbound.h" -#include "NetworkManagerUtils.h" - -G_DEFINE_TYPE (NMDnsUnbound, nm_dns_unbound, NM_TYPE_DNS_PLUGIN) - -/*******************************************/ - -static gboolean -update (NMDnsPlugin *plugin, - const NMDnsIPConfigData **configs, - const NMGlobalDnsConfig *global_config, - const char *hostname) -{ - /* TODO: We currently call a script installed with the dnssec-trigger - * package that queries all information itself. Later, the dependency - * on that package will be optional and the only hard dependency will - * be unbound. - * - * Unbound configuration should be later handled by this plugin directly, - * without calling custom scripts. The dnssec-trigger functionality - * may be eventually merged into NetworkManager. - */ - return nm_spawn_process (DNSSEC_TRIGGER_SCRIPT " --async --update", NULL) == 0; -} - -static gboolean -is_caching (NMDnsPlugin *plugin) -{ - return TRUE; -} - -static const char * -get_name (NMDnsPlugin *plugin) -{ - return "unbound"; -} - -/****************************************************************/ - -NMDnsPlugin * -nm_dns_unbound_new (void) -{ - return g_object_new (NM_TYPE_DNS_UNBOUND, NULL); -} - -static void -nm_dns_unbound_init (NMDnsUnbound *unbound) -{ -} - -static void -nm_dns_unbound_class_init (NMDnsUnboundClass *klass) -{ - NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (klass); - - plugin_class->update = update; - plugin_class->is_caching = is_caching; - plugin_class->get_name = get_name; -} diff --git a/src/dns-manager/nm-dns-unbound.h b/src/dns-manager/nm-dns-unbound.h deleted file mode 100644 index abc056b9..00000000 --- a/src/dns-manager/nm-dns-unbound.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2014 Red Hat, Inc. - */ -#ifndef __NETWORKMANAGER_DNS_UNBOUND_H__ -#define __NETWORKMANAGER_DNS_UNBOUND_H__ - -#include "nm-dns-plugin.h" - -#define NM_TYPE_DNS_UNBOUND (nm_dns_unbound_get_type ()) -#define NM_DNS_UNBOUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_UNBOUND, NMDnsUnbound)) -#define NM_DNS_UNBOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_UNBOUND, NMDnsUnboundClass)) -#define NM_IS_DNS_UNBOUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_UNBOUND)) -#define NM_IS_DNS_UNBOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_UNBOUND)) -#define NM_DNS_UNBOUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_UNBOUND, NMDnsUnboundClass)) - -typedef struct { - NMDnsPlugin parent; -} NMDnsUnbound; - -typedef struct { - NMDnsPluginClass parent; -} NMDnsUnboundClass; - -GType nm_dns_unbound_get_type (void); - -NMDnsPlugin *nm_dns_unbound_new (void); - -#endif /* __NETWORKMANAGER_DNS_UNBOUND_H__ */ diff --git a/src/dns/nm-dns-dnsmasq.c b/src/dns/nm-dns-dnsmasq.c new file mode 100644 index 00000000..5223638e --- /dev/null +++ b/src/dns/nm-dns-dnsmasq.c @@ -0,0 +1,672 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "nm-default.h" + +#include "nm-dns-dnsmasq.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "nm-core-internal.h" +#include "platform/nm-platform.h" +#include "nm-utils.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" +#include "nm-bus-manager.h" +#include "NetworkManagerUtils.h" + +#define PIDFILE NMRUNDIR "/dnsmasq.pid" +#define CONFDIR NMCONFDIR "/dnsmasq.d" + +#define DNSMASQ_DBUS_SERVICE "org.freedesktop.NetworkManager.dnsmasq" +#define DNSMASQ_DBUS_PATH "/uk/org/thekelleys/dnsmasq" + +/*****************************************************************************/ + +typedef struct { + GDBusProxy *dnsmasq; + GCancellable *dnsmasq_cancellable; + GCancellable *update_cancellable; + gboolean running; + + GVariant *set_server_ex_args; +} NMDnsDnsmasqPrivate; + +struct _NMDnsDnsmasq { + NMDnsPlugin parent; + NMDnsDnsmasqPrivate _priv; +}; + +struct _NMDnsDnsmasqClass { + NMDnsPluginClass parent; +}; + +G_DEFINE_TYPE (NMDnsDnsmasq, nm_dns_dnsmasq, NM_TYPE_DNS_PLUGIN) + +#define NM_DNS_DNSMASQ_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDnsDnsmasq, NM_IS_DNS_DNSMASQ) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_DNS +#define _NMLOG(level, ...) __NMLOG_DEFAULT_WITH_ADDR (level, _NMLOG_DOMAIN, "dnsmasq", __VA_ARGS__) + +/*****************************************************************************/ + +static char ** +get_ip4_rdns_domains (NMIP4Config *ip4) +{ + char **strv; + GPtrArray *domains = NULL; + int i; + + g_return_val_if_fail (ip4 != NULL, NULL); + + domains = g_ptr_array_sized_new (5); + + for (i = 0; i < nm_ip4_config_get_num_addresses (ip4); i++) { + const NMPlatformIP4Address *address = nm_ip4_config_get_address (ip4, i); + + nm_utils_get_reverse_dns_domains_ip4 (address->address, address->plen, domains); + } + + for (i = 0; i < nm_ip4_config_get_num_routes (ip4); i++) { + const NMPlatformIP4Route *route = nm_ip4_config_get_route (ip4, i); + + nm_utils_get_reverse_dns_domains_ip4 (route->network, route->plen, domains); + } + + /* Terminating NULL so we can use g_strfreev() to free it */ + g_ptr_array_add (domains, NULL); + + /* Free the array and return NULL if the only element was the ending NULL */ + strv = (char **) g_ptr_array_free (domains, (domains->len == 1)); + + return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE); +} + +static char ** +get_ip6_rdns_domains (NMIP6Config *ip6) +{ + char **strv; + GPtrArray *domains = NULL; + int i; + + g_return_val_if_fail (ip6 != NULL, NULL); + + domains = g_ptr_array_sized_new (5); + + for (i = 0; i < nm_ip6_config_get_num_addresses (ip6); i++) { + const NMPlatformIP6Address *address = nm_ip6_config_get_address (ip6, i); + + nm_utils_get_reverse_dns_domains_ip6 (&address->address, address->plen, domains); + } + + for (i = 0; i < nm_ip6_config_get_num_routes (ip6); i++) { + const NMPlatformIP6Route *route = nm_ip6_config_get_route (ip6, i); + + nm_utils_get_reverse_dns_domains_ip6 (&route->network, route->plen, domains); + } + + /* Terminating NULL so we can use g_strfreev() to free it */ + g_ptr_array_add (domains, NULL); + + /* Free the array and return NULL if the only element was the ending NULL */ + strv = (char **) g_ptr_array_free (domains, (domains->len == 1)); + + return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE); +} + +static void +add_dnsmasq_nameserver (NMDnsDnsmasq *self, + GVariantBuilder *servers, + const char *ip, + const char *domain) +{ + g_return_if_fail (ip); + + _LOGD ("adding nameserver '%s'%s%s%s", ip, + NM_PRINT_FMT_QUOTED (domain, " for domain \"", domain, "\"", "")); + + g_variant_builder_open (servers, G_VARIANT_TYPE ("as")); + + g_variant_builder_add (servers, "s", ip); + if (domain) + g_variant_builder_add (servers, "s", domain); + + g_variant_builder_close (servers); +} + +static gboolean +add_ip4_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP4Config *ip4, + const char *iface, gboolean split) +{ + char buf[INET_ADDRSTRLEN + 1 + IFNAMSIZ]; + char buf2[INET_ADDRSTRLEN]; + in_addr_t addr; + int nnameservers, i_nameserver, n, i; + gboolean added = FALSE; + + g_return_val_if_fail (iface, FALSE); + nnameservers = nm_ip4_config_get_num_nameservers (ip4); + + if (split) { + char **domains, **iter; + + if (nnameservers == 0) + return FALSE; + + for (i_nameserver = 0; i_nameserver < nnameservers; i_nameserver++) { + addr = nm_ip4_config_get_nameserver (ip4, i_nameserver); + g_snprintf (buf, sizeof (buf), "%s@%s", + nm_utils_inet4_ntop (addr, buf2), iface); + + /* searches are preferred over domains */ + n = nm_ip4_config_get_num_searches (ip4); + for (i = 0; i < n; i++) { + add_dnsmasq_nameserver (self, + servers, + buf, + nm_ip4_config_get_search (ip4, i)); + added = TRUE; + } + + if (n == 0) { + /* If not searches, use any domains */ + n = nm_ip4_config_get_num_domains (ip4); + for (i = 0; i < n; i++) { + add_dnsmasq_nameserver (self, + servers, + buf, + nm_ip4_config_get_domain (ip4, i)); + added = TRUE; + } + } + + /* Ensure reverse-DNS works by directing queries for in-addr.arpa + * domains to the split domain's nameserver. + */ + domains = get_ip4_rdns_domains (ip4); + if (domains) { + for (iter = domains; iter && *iter; iter++) + add_dnsmasq_nameserver (self, servers, buf, *iter); + g_strfreev (domains); + } + } + } + + /* If no searches or domains, just add the nameservers */ + if (!added) { + for (i = 0; i < nnameservers; i++) { + addr = nm_ip4_config_get_nameserver (ip4, i); + g_snprintf (buf, sizeof (buf), "%s@%s", + nm_utils_inet4_ntop (addr, buf2), iface); + add_dnsmasq_nameserver (self, servers, buf, NULL); + } + } + + return TRUE; +} + +static char * +ip6_addr_to_string (const struct in6_addr *addr, const char *iface) +{ + char buf[NM_UTILS_INET_ADDRSTRLEN]; + + if (IN6_IS_ADDR_V4MAPPED (addr)) + nm_utils_inet4_ntop (addr->s6_addr32[3], buf); + else + nm_utils_inet6_ntop (addr, buf); + + /* Need to scope link-local addresses with %. Before dnsmasq 2.58, + * only '@' was supported as delimiter. Since 2.58, '@' and '%' are + * supported. Due to a bug, since 2.73 only '%' works properly as "server" + * address. + */ + return g_strdup_printf ("%s%c%s", + buf, + IN6_IS_ADDR_LINKLOCAL (addr) ? '%' : '@', + iface); +} + +static void +add_global_config (NMDnsDnsmasq *self, GVariantBuilder *dnsmasq_servers, const NMGlobalDnsConfig *config) +{ + guint i, j; + + g_return_if_fail (config); + + for (i = 0; i < nm_global_dns_config_get_num_domains (config); i++) { + NMGlobalDnsDomain *domain = nm_global_dns_config_get_domain (config, i); + const char *const *servers = nm_global_dns_domain_get_servers (domain); + const char *name = nm_global_dns_domain_get_name (domain); + + g_return_if_fail (name); + + for (j = 0; servers && servers[j]; j++) { + if (!strcmp (name, "*")) + add_dnsmasq_nameserver (self, dnsmasq_servers, servers[j], NULL); + else + add_dnsmasq_nameserver (self, dnsmasq_servers, servers[j], name); + } + + } +} + +static gboolean +add_ip6_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP6Config *ip6, + const char *iface, gboolean split) +{ + const struct in6_addr *addr; + char *buf = NULL; + int nnameservers, i_nameserver, n, i; + gboolean added = FALSE; + + g_return_val_if_fail (iface, FALSE); + nnameservers = nm_ip6_config_get_num_nameservers (ip6); + + if (split) { + char **domains, **iter; + + if (nnameservers == 0) + return FALSE; + + for (i_nameserver = 0; i_nameserver < nnameservers; i_nameserver++) { + addr = nm_ip6_config_get_nameserver (ip6, i_nameserver); + buf = ip6_addr_to_string (addr, iface); + + /* searches are preferred over domains */ + n = nm_ip6_config_get_num_searches (ip6); + for (i = 0; i < n; i++) { + add_dnsmasq_nameserver (self, + servers, + buf, + nm_ip6_config_get_search (ip6, i)); + added = TRUE; + } + + if (n == 0) { + /* If not searches, use any domains */ + n = nm_ip6_config_get_num_domains (ip6); + for (i = 0; i < n; i++) { + add_dnsmasq_nameserver (self, + servers, + buf, + nm_ip6_config_get_domain (ip6, i)); + added = TRUE; + } + } + + /* Ensure reverse-DNS works by directing queries for ip6.arpa + * domains to the split domain's nameserver. + */ + domains = get_ip6_rdns_domains (ip6); + if (domains) { + for (iter = domains; iter && *iter; iter++) + add_dnsmasq_nameserver (self, servers, buf, *iter); + g_strfreev (domains); + } + + g_free (buf); + } + } + + /* If no searches or domains, just add the nameservers */ + if (!added) { + for (i = 0; i < nnameservers; i++) { + addr = nm_ip6_config_get_nameserver (ip6, i); + buf = ip6_addr_to_string (addr, iface); + if (buf) { + add_dnsmasq_nameserver (self, servers, buf, NULL); + g_free (buf); + } + } + } + + return TRUE; +} + +static gboolean +add_ip_config_data (NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsIPConfigData *data) +{ + if (NM_IS_IP4_CONFIG (data->config)) { + return add_ip4_config (self, + servers, + (NMIP4Config *) data->config, + data->iface, + data->type == NM_DNS_IP_CONFIG_TYPE_VPN); + } else if (NM_IS_IP6_CONFIG (data->config)) { + return add_ip6_config (self, + servers, + (NMIP6Config *) data->config, + data->iface, + data->type == NM_DNS_IP_CONFIG_TYPE_VPN); + } else + g_return_val_if_reached (FALSE); +} + +static void +dnsmasq_update_done (GDBusProxy *proxy, GAsyncResult *res, gpointer user_data) +{ + NMDnsDnsmasq *self; + NMDnsDnsmasqPrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *response = NULL; + + response = g_dbus_proxy_call_finish (proxy, res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_DNS_DNSMASQ (user_data); + priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); + + if (!response) + _LOGW ("dnsmasq update failed: %s", error->message); + else + _LOGD ("dnsmasq update successful"); +} + +static void +send_dnsmasq_update (NMDnsDnsmasq *self) +{ + NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); + + if (!priv->set_server_ex_args) + return; + + if (priv->running) { + _LOGD ("trying to update dnsmasq nameservers"); + + nm_clear_g_cancellable (&priv->update_cancellable); + priv->update_cancellable = g_cancellable_new (); + + g_dbus_proxy_call (priv->dnsmasq, + "SetServersEx", + priv->set_server_ex_args, + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->update_cancellable, + (GAsyncReadyCallback) dnsmasq_update_done, + self); + g_clear_pointer (&priv->set_server_ex_args, g_variant_unref); + } else + _LOGD ("dnsmasq not found on the bus. The nameserver update will be sent when dnsmasq appears"); +} + +static void +name_owner_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + NMDnsDnsmasq *self = NM_DNS_DNSMASQ (user_data); + NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); + gs_free char *owner = NULL; + + owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object)); + if (owner) { + _LOGI ("dnsmasq appeared as %s", owner); + priv->running = TRUE; + send_dnsmasq_update (self); + } else { + _LOGI ("dnsmasq disappeared"); + priv->running = FALSE; + g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); + } +} + +static void +dnsmasq_proxy_cb (GObject *source, GAsyncResult *res, gpointer user_data) +{ + NMDnsDnsmasq *self; + NMDnsDnsmasqPrivate *priv; + gs_free_error GError *error = NULL; + gs_free char *owner = NULL; + GDBusProxy *proxy; + + proxy = g_dbus_proxy_new_finish (res, &error); + if ( !proxy + && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_DNS_DNSMASQ (user_data); + + if (!proxy) { + _LOGW ("failed to connect to dnsmasq via DBus: %s", error->message); + g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); + return; + } + + priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); + + priv->dnsmasq = proxy; + nm_clear_g_cancellable (&priv->dnsmasq_cancellable); + + _LOGD ("dnsmasq proxy creation successful"); + + g_signal_connect (priv->dnsmasq, "notify::g-name-owner", + G_CALLBACK (name_owner_changed), self); + owner = g_dbus_proxy_get_name_owner (priv->dnsmasq); + priv->running = (owner != NULL); + + if (priv->running) + send_dnsmasq_update (self); +} + +static void +start_dnsmasq (NMDnsDnsmasq *self) +{ + NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); + const char *dm_binary; + const char *argv[15]; + GPid pid = 0; + guint idx = 0; + NMBusManager *dbus_mgr; + GDBusConnection *connection; + + if (priv->running) { + /* the dnsmasq process is running. Nothing to do. */ + return; + } + + if (nm_dns_plugin_child_pid ((NMDnsPlugin *) self) > 0) { + /* if we already have a child process spawned, don't do + * it again. */ + return; + } + + dm_binary = nm_utils_find_helper ("dnsmasq", DNSMASQ_PATH, NULL); + if (!dm_binary) { + _LOGW ("could not find dnsmasq binary"); + return; + } + + argv[idx++] = dm_binary; + argv[idx++] = "--no-resolv"; /* Use only commandline */ + argv[idx++] = "--keep-in-foreground"; + argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */ + argv[idx++] = "--bind-interfaces"; + argv[idx++] = "--pid-file=" PIDFILE; + argv[idx++] = "--listen-address=127.0.0.1"; /* Should work for both 4 and 6 */ + argv[idx++] = "--cache-size=400"; + argv[idx++] = "--clear-on-reload"; /* clear cache when dns server changes */ + argv[idx++] = "--conf-file=/dev/null"; /* avoid loading /etc/dnsmasq.conf */ + argv[idx++] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */ + argv[idx++] = "--enable-dbus=" DNSMASQ_DBUS_SERVICE; + + /* dnsmasq exits if the conf dir is not present */ + if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR)) + argv[idx++] = "--conf-dir=" CONFDIR; + + argv[idx++] = NULL; + nm_assert (idx <= G_N_ELEMENTS (argv)); + + /* And finally spawn dnsmasq */ + pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq"); + if (!pid) + return; + + if ( priv->dnsmasq + || priv->dnsmasq_cancellable) { + /* we already have a proxy or are about to create it. + * We are done. */ + return; + } + + dbus_mgr = nm_bus_manager_get (); + g_return_if_fail (dbus_mgr); + + connection = nm_bus_manager_get_connection (dbus_mgr); + g_return_if_fail (connection); + + priv->dnsmasq_cancellable = g_cancellable_new (); + g_dbus_proxy_new (connection, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + DNSMASQ_DBUS_SERVICE, + DNSMASQ_DBUS_PATH, + DNSMASQ_DBUS_SERVICE, + priv->dnsmasq_cancellable, + dnsmasq_proxy_cb, + self); +} + +static gboolean +update (NMDnsPlugin *plugin, + const NMDnsIPConfigData **configs, + const NMGlobalDnsConfig *global_config, + const char *hostname) +{ + NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin); + NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); + GVariantBuilder servers; + + start_dnsmasq (self); + + g_variant_builder_init (&servers, G_VARIANT_TYPE ("aas")); + + if (global_config) + add_global_config (self, &servers, global_config); + else { + while (*configs) { + add_ip_config_data (self, &servers, *configs); + configs++; + } + } + + g_clear_pointer (&priv->set_server_ex_args, g_variant_unref); + priv->set_server_ex_args = g_variant_ref_sink (g_variant_new ("(aas)", &servers)); + + send_dnsmasq_update (self); + + return TRUE; +} + +/*****************************************************************************/ + +static void +child_quit (NMDnsPlugin *plugin, gint status) +{ + NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin); + NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); + gboolean failed = TRUE; + int err; + + if (WIFEXITED (status)) { + err = WEXITSTATUS (status); + if (err) { + _LOGW ("dnsmasq exited with error: %s", + nm_utils_dnsmasq_status_to_string (err, NULL, 0)); + } else { + _LOGD ("dnsmasq exited normally"); + failed = FALSE; + } + } else if (WIFSTOPPED (status)) + _LOGW ("dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status)); + else if (WIFSIGNALED (status)) + _LOGW ("dnsmasq died with signal %d", WTERMSIG (status)); + else + _LOGW ("dnsmasq died from an unknown cause"); + + priv->running = FALSE; + + if (failed) + g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); +} + +/*****************************************************************************/ + +static gboolean +is_caching (NMDnsPlugin *plugin) +{ + return TRUE; +} + +static const char * +get_name (NMDnsPlugin *plugin) +{ + return "dnsmasq"; +} + +/*****************************************************************************/ + +static void +nm_dns_dnsmasq_init (NMDnsDnsmasq *self) +{ +} + +NMDnsPlugin * +nm_dns_dnsmasq_new (void) +{ + return g_object_new (NM_TYPE_DNS_DNSMASQ, NULL); +} + +static void +dispose (GObject *object) +{ + NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE ((NMDnsDnsmasq *) object); + + nm_clear_g_cancellable (&priv->dnsmasq_cancellable); + nm_clear_g_cancellable (&priv->update_cancellable); + + g_clear_object (&priv->dnsmasq); + + g_clear_pointer (&priv->set_server_ex_args, g_variant_unref); + + G_OBJECT_CLASS (nm_dns_dnsmasq_parent_class)->dispose (object); +} + +static void +nm_dns_dnsmasq_class_init (NMDnsDnsmasqClass *dns_class) +{ + NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (dns_class); + GObjectClass *object_class = G_OBJECT_CLASS (dns_class); + + object_class->dispose = dispose; + + plugin_class->child_quit = child_quit; + plugin_class->is_caching = is_caching; + plugin_class->update = update; + plugin_class->get_name = get_name; +} diff --git a/src/dns/nm-dns-dnsmasq.h b/src/dns/nm-dns-dnsmasq.h new file mode 100644 index 00000000..cbba434b --- /dev/null +++ b/src/dns/nm-dns-dnsmasq.h @@ -0,0 +1,38 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2010 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DNS_DNSMASQ_H__ +#define __NETWORKMANAGER_DNS_DNSMASQ_H__ + +#include "nm-dns-plugin.h" + +#define NM_TYPE_DNS_DNSMASQ (nm_dns_dnsmasq_get_type ()) +#define NM_DNS_DNSMASQ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasq)) +#define NM_DNS_DNSMASQ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasqClass)) +#define NM_IS_DNS_DNSMASQ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_DNSMASQ)) +#define NM_IS_DNS_DNSMASQ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_DNSMASQ)) +#define NM_DNS_DNSMASQ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_DNSMASQ, NMDnsDnsmasqClass)) + +typedef struct _NMDnsDnsmasq NMDnsDnsmasq; +typedef struct _NMDnsDnsmasqClass NMDnsDnsmasqClass; + +GType nm_dns_dnsmasq_get_type (void); + +NMDnsPlugin *nm_dns_dnsmasq_new (void); + +#endif /* __NETWORKMANAGER_DNS_DNSMASQ_H__ */ diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c new file mode 100644 index 00000000..dfd2fce1 --- /dev/null +++ b/src/dns/nm-dns-manager.c @@ -0,0 +1,2116 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2004 - 2005 Colin Walters + * Copyright (C) 2004 - 2013 Red Hat, Inc. + * Copyright (C) 2005 - 2008 Novell, Inc. + * and others + */ + +#include "nm-default.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "nm-utils.h" +#include "nm-core-internal.h" +#include "nm-dns-manager.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" +#include "NetworkManagerUtils.h" +#include "nm-config.h" +#include "devices/nm-device.h" +#include "nm-manager.h" + +#include "nm-dns-plugin.h" +#include "nm-dns-dnsmasq.h" +#include "nm-dns-systemd-resolved.h" +#include "nm-dns-unbound.h" + +#include "introspection/org.freedesktop.NetworkManager.DnsManager.h" + +#if WITH_LIBSOUP +#include + +#ifdef SOUP_CHECK_VERSION +#if SOUP_CHECK_VERSION (2, 40, 0) +#define DOMAIN_IS_VALID(domain) (*(domain) && !soup_tld_domain_is_public_suffix (domain)) +#endif +#endif +#endif + +#ifndef DOMAIN_IS_VALID +#define DOMAIN_IS_VALID(domain) (*(domain)) +#endif + +#define HASH_LEN 20 + +#ifndef RESOLVCONF_PATH +#define RESOLVCONF_PATH "/sbin/resolvconf" +#endif + +#ifndef NETCONFIG_PATH +#define NETCONFIG_PATH "/sbin/netconfig" +#endif + +#define PLUGIN_RATELIMIT_INTERVAL 30 +#define PLUGIN_RATELIMIT_BURST 5 +#define PLUGIN_RATELIMIT_DELAY 300 + +enum { + CONFIG_CHANGED, + + LAST_SIGNAL +}; + +NM_GOBJECT_PROPERTIES_DEFINE (NMDnsManager, + PROP_MODE, + PROP_RC_MANAGER, + PROP_CONFIGURATION, +); + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef enum { + SR_SUCCESS, + SR_NOTFOUND, + SR_ERROR +} SpawnResult; + +NM_DEFINE_SINGLETON_GETTER (NMDnsManager, nm_dns_manager_get, NM_TYPE_DNS_MANAGER); + +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "dns-mgr" +#define _NMLOG_DOMAIN LOGD_DNS +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ + char __prefix[20]; \ + const NMDnsManager *const __self = (self); \ + \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ + "%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG_PREFIX_NAME, \ + ((!__self || __self == singleton_instance) \ + ? "" \ + : nm_sprintf_buf (__prefix, "[%p]", __self)) \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +/*****************************************************************************/ + +typedef struct { + GPtrArray *configs; + GVariant *config_variant; + NMDnsIPConfigData *best_conf4, *best_conf6; + gboolean need_sort; + + char *hostname; + guint updates_queue; + + guint8 hash[HASH_LEN]; /* SHA1 hash of current DNS config */ + guint8 prev_hash[HASH_LEN]; /* Hash when begin_updates() was called */ + + NMDnsManagerResolvConfManager rc_manager; + char *mode; + NMDnsPlugin *plugin; + + NMConfig *config; + + gboolean dns_touched; + + struct { + guint64 ts; + guint num_restarts; + guint timer; + } plugin_ratelimit; +} NMDnsManagerPrivate; + +struct _NMDnsManager { + NMExportedObject parent; + NMDnsManagerPrivate _priv; +}; + +struct _NMDnsManagerClass { + NMExportedObjectClass parent; +}; + +G_DEFINE_TYPE (NMDnsManager, nm_dns_manager, NM_TYPE_EXPORTED_OBJECT) + +#define NM_DNS_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDnsManager, NM_IS_DNS_MANAGER) + +/*****************************************************************************/ + +typedef struct { + GPtrArray *nameservers; + GPtrArray *searches; + GPtrArray *options; + const char *nis_domain; + GPtrArray *nis_servers; +} NMResolvConfData; + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_rc_manager_to_string, NMDnsManagerResolvConfManager, + NM_UTILS_LOOKUP_DEFAULT_WARN (NULL), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, "unmanaged"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE, "immutable"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK, "symlink"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE, "file"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF, "resolvconf"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG, "netconfig"), +); + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_config_type_to_string, NMDnsIPConfigType, + NM_UTILS_LOOKUP_DEFAULT_WARN (""), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_IP_CONFIG_TYPE_DEFAULT, "default"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE, "best"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_IP_CONFIG_TYPE_VPN, "vpn"), +); + +static NMDnsIPConfigData * +ip_config_data_new (gpointer config, NMDnsIPConfigType type, const char *iface) +{ + NMDnsIPConfigData *data; + + data = g_slice_new0 (NMDnsIPConfigData); + data->config = g_object_ref (config); + data->iface = g_strdup (iface); + data->type = type; + + return data; +} + +static void +ip_config_data_destroy (gpointer ptr) +{ + NMDnsIPConfigData *data = ptr; + + if (!data) + return; + + g_object_unref (data->config); + g_free (data->iface); + g_slice_free (NMDnsIPConfigData, data); +} + +static gint +ip_config_data_compare (const NMDnsIPConfigData *a, const NMDnsIPConfigData *b) +{ + gboolean a_v4, b_v4; + gint a_prio, b_prio; + + a_v4 = NM_IS_IP4_CONFIG (a->config); + b_v4 = NM_IS_IP4_CONFIG (b->config); + + a_prio = a_v4 ? + nm_ip4_config_get_dns_priority ((NMIP4Config *) a->config) : + nm_ip6_config_get_dns_priority ((NMIP6Config *) a->config); + + b_prio = b_v4 ? + nm_ip4_config_get_dns_priority ((NMIP4Config *) b->config) : + nm_ip6_config_get_dns_priority ((NMIP6Config *) b->config); + + /* Configurations with lower priority value first */ + if (a_prio < b_prio) + return -1; + else if (a_prio > b_prio) + return 1; + + /* Sort also according to type */ + if (a->type > b->type) + return -1; + else if (a->type < b->type) + return 1; + + return 0; +} + +static gint +ip_config_data_ptr_compare (gconstpointer a, gconstpointer b) +{ + const NMDnsIPConfigData *const *ptr_a = a, *const *ptr_b = b; + + return ip_config_data_compare (*ptr_a, *ptr_b); +} + +static void +add_string_item (GPtrArray *array, const char *str) +{ + int i; + + g_return_if_fail (array != NULL); + g_return_if_fail (str != NULL); + + /* Check for dupes before adding */ + for (i = 0; i < array->len; i++) { + const char *candidate = g_ptr_array_index (array, i); + + if (candidate && !strcmp (candidate, str)) + return; + } + + /* No dupes, add the new item */ + g_ptr_array_add (array, g_strdup (str)); +} + +static void +add_dns_option_item (GPtrArray *array, const char *str, gboolean ipv6) +{ + if (_nm_utils_dns_option_find_idx (array, str) < 0) + g_ptr_array_add (array, g_strdup (str)); +} + +static void +merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src) +{ + guint32 num, num_domains, num_searches, i; + + num = nm_ip4_config_get_num_nameservers (src); + for (i = 0; i < num; i++) { + add_string_item (rc->nameservers, + nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (src, i), NULL)); + } + + num_domains = nm_ip4_config_get_num_domains (src); + num_searches = nm_ip4_config_get_num_searches (src); + + for (i = 0; i < num_searches; i++) { + const char *search; + + search = nm_ip4_config_get_search (src, i); + if (!DOMAIN_IS_VALID (search)) + continue; + add_string_item (rc->searches, search); + } + + if (num_domains > 1 || !num_searches) { + for (i = 0; i < num_domains; i++) { + const char *domain; + + domain = nm_ip4_config_get_domain (src, i); + if (!DOMAIN_IS_VALID (domain)) + continue; + add_string_item (rc->searches, domain); + } + } + + num = nm_ip4_config_get_num_dns_options (src); + for (i = 0; i < num; i++) { + const char *option; + + option = nm_ip4_config_get_dns_option (src, i); + add_dns_option_item (rc->options, option, FALSE); + } + + /* NIS stuff */ + num = nm_ip4_config_get_num_nis_servers (src); + for (i = 0; i < num; i++) { + add_string_item (rc->nis_servers, + nm_utils_inet4_ntop (nm_ip4_config_get_nis_server (src, i), NULL)); + } + + if (nm_ip4_config_get_nis_domain (src)) { + /* FIXME: handle multiple domains */ + if (!rc->nis_domain) + rc->nis_domain = nm_ip4_config_get_nis_domain (src); + } +} + +static void +merge_one_ip6_config (NMResolvConfData *rc, NMIP6Config *src, const char *iface) +{ + guint32 num, num_domains, num_searches, i; + + num = nm_ip6_config_get_num_nameservers (src); + for (i = 0; i < num; i++) { + const struct in6_addr *addr; + char buf[NM_UTILS_INET_ADDRSTRLEN + 50]; + + addr = nm_ip6_config_get_nameserver (src, i); + + /* inet_ntop is probably supposed to do this for us, but it doesn't */ + if (IN6_IS_ADDR_V4MAPPED (addr)) + nm_utils_inet4_ntop (addr->s6_addr32[3], buf); + else { + nm_utils_inet6_ntop (addr, buf); + if (IN6_IS_ADDR_LINKLOCAL (addr)) { + g_strlcat (buf, "%", sizeof (buf)); + g_strlcat (buf, iface, sizeof (buf)); + } + } + add_string_item (rc->nameservers, buf); + } + + num_domains = nm_ip6_config_get_num_domains (src); + num_searches = nm_ip6_config_get_num_searches (src); + + for (i = 0; i < num_searches; i++) { + const char *search; + + search = nm_ip6_config_get_search (src, i); + if (!DOMAIN_IS_VALID (search)) + continue; + add_string_item (rc->searches, search); + } + + if (num_domains > 1 || !num_searches) { + for (i = 0; i < num_domains; i++) { + const char *domain; + + domain = nm_ip6_config_get_domain (src, i); + if (!DOMAIN_IS_VALID (domain)) + continue; + add_string_item (rc->searches, domain); + } + } + + num = nm_ip6_config_get_num_dns_options (src); + for (i = 0; i < num; i++) { + const char *option; + + option = nm_ip6_config_get_dns_option (src, i); + add_dns_option_item (rc->options, option, TRUE); + } +} + +static void +merge_one_ip_config_data (NMResolvConfData *rc, + NMDnsIPConfigData *data) +{ + if (NM_IS_IP4_CONFIG (data->config)) + merge_one_ip4_config (rc, (NMIP4Config *) data->config); + else if (NM_IS_IP6_CONFIG (data->config)) + merge_one_ip6_config (rc, (NMIP6Config *) data->config, data->iface); + else + g_return_if_reached (); +} + +static GPid +run_netconfig (NMDnsManager *self, GError **error, gint *stdin_fd) +{ + char *argv[5]; + gs_free char *tmp = NULL; + GPid pid = -1; + + argv[0] = NETCONFIG_PATH; + argv[1] = "modify"; + argv[2] = "--service"; + argv[3] = "NetworkManager"; + argv[4] = NULL; + + _LOGD ("spawning '%s'", + (tmp = g_strjoinv (" ", argv))); + + if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, + NULL, &pid, stdin_fd, NULL, NULL, error)) + return -1; + + return pid; +} + +static void +write_to_netconfig (NMDnsManager *self, gint fd, const char *key, const char *value) +{ + char *str; + int x; + + str = g_strdup_printf ("%s='%s'\n", key, value); + _LOGD ("writing to netconfig: %s", str); + x = write (fd, str, strlen (str)); + g_free (str); +} + +static SpawnResult +dispatch_netconfig (NMDnsManager *self, + char **searches, + char **nameservers, + const char *nis_domain, + char **nis_servers, + GError **error) +{ + char *str; + GPid pid; + gint fd; + int status; + + pid = run_netconfig (self, error, &fd); + if (pid <= 0) + return SR_NOTFOUND; + + /* NM is writing already-merged DNS information to netconfig, so it + * does not apply to a specific network interface. + */ + write_to_netconfig (self, fd, "INTERFACE", "NetworkManager"); + + if (searches) { + str = g_strjoinv (" ", searches); + write_to_netconfig (self, fd, "DNSSEARCH", str); + g_free (str); + } + + if (nameservers) { + str = g_strjoinv (" ", nameservers); + write_to_netconfig (self, fd, "DNSSERVERS", str); + g_free (str); + } + + if (nis_domain) + write_to_netconfig (self, fd, "NISDOMAIN", nis_domain); + + if (nis_servers) { + str = g_strjoinv (" ", nis_servers); + write_to_netconfig (self, fd, "NISSERVERS", str); + g_free (str); + } + + close (fd); + + /* Wait until the process exits */ + if (!nm_utils_kill_child_sync (pid, 0, LOGD_DNS, "netconfig", &status, 1000, 0)) { + int errsv = errno; + + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, + "Error waiting for netconfig to exit: %s", + strerror (errsv)); + return SR_ERROR; + } + if (!WIFEXITED (status) || WEXITSTATUS (status) != EXIT_SUCCESS) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, + "Error calling netconfig: %s %d", + WIFEXITED (status) ? "exited with status" : (WIFSIGNALED (status) ? "exited with signal" : "exited with unknown reason"), + WIFEXITED (status) ? WEXITSTATUS (status) : (WIFSIGNALED (status) ? WTERMSIG (status) : status)); + return SR_ERROR; + } + return SR_SUCCESS; +} + +static char * +create_resolv_conf (char **searches, + char **nameservers, + char **options) +{ + gs_free char *searches_str = NULL; + gs_free char *nameservers_str = NULL; + gs_free char *options_str = NULL; + char *tmp_str; + GString *str; + int i; + + if (searches) { + tmp_str = g_strjoinv (" ", searches); + searches_str = g_strconcat ("search ", tmp_str, "\n", NULL); + g_free (tmp_str); + } + + if (options) { + tmp_str = g_strjoinv (" ", options); + options_str = g_strconcat ("options ", tmp_str, "\n", NULL); + g_free (tmp_str); + } + + if (nameservers) { + int num = g_strv_length (nameservers); + + str = g_string_new (""); + for (i = 0; i < num; i++) { + if (i == 3) { + g_string_append (str, "# "); + g_string_append (str, "NOTE: the libc resolver may not support more than 3 nameservers."); + g_string_append (str, "\n# "); + g_string_append (str, "The nameservers listed below may not be recognized."); + g_string_append_c (str, '\n'); + } + + g_string_append (str, "nameserver "); + g_string_append (str, nameservers[i]); + g_string_append_c (str, '\n'); + } + nameservers_str = g_string_free (str, FALSE); + } + + return g_strdup_printf ("# Generated by NetworkManager\n%s%s%s", + searches_str ?: "", + nameservers_str ?: "", + options_str ?: ""); +} + +static gboolean +write_resolv_conf_contents (FILE *f, + const char *content, + GError **error) +{ + int errsv; + + if (fprintf (f, "%s", content) < 0) { + errsv = errno; + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not write " _PATH_RESCONF ": %s", + g_strerror (errsv)); + errno = errsv; + return FALSE; + } + + return TRUE; +} + +static gboolean +write_resolv_conf (FILE *f, + char **searches, + char **nameservers, + char **options, + GError **error) +{ + gs_free char *content = NULL; + + content = create_resolv_conf (searches, nameservers, options); + return write_resolv_conf_contents (f, content, error); +} + +static SpawnResult +dispatch_resolvconf (NMDnsManager *self, + char **searches, + char **nameservers, + char **options, + GError **error) +{ + gs_free char *cmd = NULL; + FILE *f; + gboolean success = FALSE; + int errnosv, err; + + if (!g_file_test (RESOLVCONF_PATH, G_FILE_TEST_IS_EXECUTABLE)) { + g_set_error_literal (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + RESOLVCONF_PATH " is not executable"); + return SR_NOTFOUND; + } + + if (!searches && !nameservers) { + _LOGI ("Removing DNS information from %s", RESOLVCONF_PATH); + + cmd = g_strconcat (RESOLVCONF_PATH, " -d ", "NetworkManager", NULL); + if (nm_spawn_process (cmd, error) != 0) + return SR_ERROR; + + return SR_SUCCESS; + } + + _LOGI ("Writing DNS information to %s", RESOLVCONF_PATH); + + cmd = g_strconcat (RESOLVCONF_PATH, " -a ", "NetworkManager", NULL); + if ((f = popen (cmd, "w")) == NULL) { + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not write to %s: %s", + RESOLVCONF_PATH, + g_strerror (errno)); + return SR_ERROR; + } + + success = write_resolv_conf (f, searches, nameservers, options, error); + err = pclose (f); + if (err < 0) { + errnosv = errno; + g_clear_error (error); + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errnosv), + "Failed to close pipe to resolvconf: %d", errnosv); + return SR_ERROR; + } else if (err > 0) { + _LOGW ("resolvconf failed with status %d", err); + g_clear_error (error); + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "resolvconf failed with status %d", err); + return SR_ERROR; + } + + return success ? SR_SUCCESS : SR_ERROR; +} + +#define MY_RESOLV_CONF NMRUNDIR "/resolv.conf" +#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF ".tmp" +#define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager" + +static SpawnResult +update_resolv_conf (NMDnsManager *self, + char **searches, + char **nameservers, + char **options, + GError **error, + NMDnsManagerResolvConfManager rc_manager) +{ + FILE *f; + struct stat st; + gboolean success; + gs_free char *content = NULL; + SpawnResult write_file_result = SR_SUCCESS; + int errsv; + const char *rc_path = _PATH_RESCONF; + nm_auto_free char *rc_path_real = NULL; + + /* If we are not managing /etc/resolv.conf and it points to + * MY_RESOLV_CONF, don't write the private DNS configuration to + * MY_RESOLV_CONF otherwise we would overwrite the changes done by + * some external application. + * + * This is the only situation, where we don't try to update our + * internal resolv.conf file. */ + if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED) { + gs_free char *path = g_file_read_link (_PATH_RESCONF, NULL); + + if (g_strcmp0 (path, MY_RESOLV_CONF) == 0) { + _LOGD ("update-resolv-conf: not updating " _PATH_RESCONF + " since it points to " MY_RESOLV_CONF); + return SR_SUCCESS; + } + } + + content = create_resolv_conf (searches, nameservers, options); + + if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE) { + GError *local = NULL; + + rc_path_real = realpath (rc_path, NULL); + if (rc_path_real) + rc_path = rc_path_real; + + /* we first write to /etc/resolv.conf directly. If that fails, + * we still continue to write to runstatedir but remember the + * error. */ + if (!g_file_set_contents (rc_path, content, -1, &local)) { + _LOGT ("update-resolv-conf: write to %s failed (rc-manager=%s, %s)", + rc_path, _rc_manager_to_string (rc_manager), local->message); + write_file_result = SR_ERROR; + g_propagate_error (error, local); + error = NULL; + } else { + _LOGT ("update-resolv-conf: write to %s succeeded (rc-manager=%s)", + rc_path, _rc_manager_to_string (rc_manager)); + } + } + + if ((f = fopen (MY_RESOLV_CONF_TMP, "we")) == NULL) { + errsv = errno; + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not open %s: %s", + MY_RESOLV_CONF_TMP, + g_strerror (errsv)); + _LOGT ("update-resolv-conf: open temporary file %s failed (%s)", + MY_RESOLV_CONF_TMP, g_strerror (errsv)); + return SR_ERROR; + } + + success = write_resolv_conf_contents (f, content, error); + if (!success) { + errsv = errno; + _LOGT ("update-resolv-conf: write temporary file %s failed (%s)", + MY_RESOLV_CONF_TMP, g_strerror (errsv)); + } + + if (fclose (f) < 0) { + if (success) { + errsv = errno; + /* only set an error here if write_resolv_conf() was successful, + * since its error is more important. + */ + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not close %s: %s", + MY_RESOLV_CONF_TMP, + g_strerror (errsv)); + _LOGT ("update-resolv-conf: close temporary file %s failed (%s)", + MY_RESOLV_CONF_TMP, g_strerror (errsv)); + } + return SR_ERROR; + } else if (!success) + return SR_ERROR; + + if (rename (MY_RESOLV_CONF_TMP, MY_RESOLV_CONF) < 0) { + errsv = errno; + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not replace %s: %s", + MY_RESOLV_CONF, + g_strerror (errno)); + _LOGT ("update-resolv-conf: failed to rename temporary file %s to %s (%s)", + MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, g_strerror (errsv)); + return SR_ERROR; + } + + if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE) { + _LOGT ("update-resolv-conf: write internal file %s succeeded (rc-manager=%s)", + rc_path, _rc_manager_to_string (rc_manager)); + return write_file_result; + } + + if (rc_manager != NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK) { + _LOGT ("update-resolv-conf: write internal file %s succeeded", MY_RESOLV_CONF); + return SR_SUCCESS; + } + + /* A symlink pointing to NM's own resolv.conf (MY_RESOLV_CONF) is always + * overwritten to ensure that changes are indicated with inotify. Symlinks + * pointing to any other file are never overwritten. + */ + if (lstat (_PATH_RESCONF, &st) != 0) { + errsv = errno; + if (errsv != ENOENT) { + /* NM cannot read /etc/resolv.conf */ + _LOGT ("update-resolv-conf: write internal file %s succeeded but lstat(%s) failed (%s)", + MY_RESOLV_CONF, _PATH_RESCONF, g_strerror (errsv)); + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not lstat %s: %s", + _PATH_RESCONF, + g_strerror (errsv)); + return SR_ERROR; + } + } else { + if (S_ISLNK (st.st_mode)) { + if (stat (_PATH_RESCONF, &st) != -1) { + gs_free char *path = g_file_read_link (_PATH_RESCONF, NULL); + + if (!path || !nm_streq (path, MY_RESOLV_CONF)) { + /* It's not NM's symlink; do nothing */ + _LOGT ("update-resolv-conf: write internal file %s succeeded " + "but don't update %s as it points to %s", + MY_RESOLV_CONF, _PATH_RESCONF, path ?: ""); + return SR_SUCCESS; + } + + /* resolv.conf is a symlink owned by NM and the target is accessible + */ + } else { + /* resolv.conf is a symlink but the target is not accessible; + * some other program is probably managing resolv.conf and + * NM should not touch it. + */ + _LOGT ("update-resolv-conf: write internal file %s succeeded " + "but don't update %s as the symlinks points somewhere else", + MY_RESOLV_CONF, _PATH_RESCONF); + return SR_SUCCESS; + } + } + } + + /* By this point, either /etc/resolv.conf does not exist, is a regular + * file, or is a symlink already owned by NM. In all cases /etc/resolv.conf + * is replaced with a symlink pointing to NM's resolv.conf in /var/run/. + */ + if ( unlink (RESOLV_CONF_TMP) != 0 + && ((errsv = errno) != ENOENT)) { + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not unlink %s: %s", + RESOLV_CONF_TMP, + g_strerror (errsv)); + _LOGT ("update-resolv-conf: write internal file %s succeeded " + "but canot delete temporary file %s: %s", + MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv)); + return SR_ERROR; + } + + if (symlink (MY_RESOLV_CONF, RESOLV_CONF_TMP) == -1) { + errsv = errno; + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not create symlink %s pointing to %s: %s", + RESOLV_CONF_TMP, + MY_RESOLV_CONF, + g_strerror (errsv)); + _LOGT ("update-resolv-conf: write internal file %s succeeded " + "but failed to symlink %s: %s", + MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv)); + return SR_ERROR; + } + + if (rename (RESOLV_CONF_TMP, _PATH_RESCONF) == -1) { + errsv = errno; + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Could not rename %s to %s: %s", + RESOLV_CONF_TMP, + _PATH_RESCONF, + g_strerror (errsv)); + _LOGT ("update-resolv-conf: write internal file %s succeeded " + "but failed to rename temporary symlink %s to %s: %s", + MY_RESOLV_CONF, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv)); + return SR_ERROR; + } + + _LOGT ("update-resolv-conf: write internal file %s succeeded and update symlink %s", + MY_RESOLV_CONF, _PATH_RESCONF); + return SR_SUCCESS; +} + +static void +compute_hash (NMDnsManager *self, const NMGlobalDnsConfig *global, guint8 buffer[HASH_LEN]) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + GChecksum *sum; + gsize len = HASH_LEN; + guint i; + + sum = g_checksum_new (G_CHECKSUM_SHA1); + g_assert (len == g_checksum_type_get_length (G_CHECKSUM_SHA1)); + + if (global) + nm_global_dns_config_update_checksum (global, sum); + else { + for (i = 0; i < priv->configs->len; i++) { + NMDnsIPConfigData *data = priv->configs->pdata[i]; + + if (NM_IS_IP4_CONFIG (data->config)) + nm_ip4_config_hash ((NMIP4Config *) data->config, sum, TRUE); + else if (NM_IS_IP6_CONFIG (data->config)) + nm_ip6_config_hash ((NMIP6Config *) data->config, sum, TRUE); + } + } + + g_checksum_get_digest (sum, buffer, &len); + g_checksum_free (sum); +} + +static gboolean +merge_global_dns_config (NMResolvConfData *rc, NMGlobalDnsConfig *global_conf) +{ + NMGlobalDnsDomain *default_domain; + const char *const *searches; + const char *const *options; + const char *const *servers; + gint i; + + if (!global_conf) + return FALSE; + + searches = nm_global_dns_config_get_searches (global_conf); + options = nm_global_dns_config_get_options (global_conf); + + for (i = 0; searches && searches[i]; i++) { + if (DOMAIN_IS_VALID (searches[i])) + add_string_item (rc->searches, searches[i]); + } + + for (i = 0; options && options[i]; i++) + add_string_item (rc->options, options[i]); + + default_domain = nm_global_dns_config_lookup_domain (global_conf, "*"); + g_assert (default_domain); + servers = nm_global_dns_domain_get_servers (default_domain); + for (i = 0; servers && servers[i]; i++) + add_string_item (rc->nameservers, servers[i]); + + return TRUE; +} + +static const char * +get_nameserver_list (void *config, GString **str) +{ + NMIP4Config *ip4; + NMIP6Config *ip6; + guint num, i; + + nm_assert (str); + + if (*str) + g_string_truncate (*str, 0); + else + *str = g_string_sized_new (64); + + if (NM_IS_IP4_CONFIG (config)) { + ip4 = (NMIP4Config *) config; + num = nm_ip4_config_get_num_nameservers (ip4); + for (i = 0; i < num; i++) { + g_string_append (*str, + nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (ip4, i), + NULL)); + g_string_append_c (*str, ' '); + } + } else if (NM_IS_IP6_CONFIG (config)) { + ip6 = (NMIP6Config *) config; + num = nm_ip6_config_get_num_nameservers (ip6); + for (i = 0; i < num; i++) { + g_string_append (*str, + nm_utils_inet6_ntop (nm_ip6_config_get_nameserver (ip6, i), + NULL)); + g_string_append_c (*str, ' '); + } + } else + g_return_val_if_reached (NULL); + + return (*str)->str; +} + +static char ** +_ptrarray_to_strv (GPtrArray *parray) +{ + if (parray->len > 0) + g_ptr_array_add (parray, NULL); + return (char **) g_ptr_array_free (parray, parray->len == 0); +} + +static void +_collect_resolv_conf_data (NMDnsManager *self, /* only for logging context, no other side-effects */ + NMGlobalDnsConfig *global_config, + const GPtrArray *configs, + const char *hostname, + char ***out_searches, + char ***out_options, + char ***out_nameservers, + char ***out_nis_servers, + const char **out_nis_domain, + NMDnsIPConfigData ***out_plugin_confs) +{ + NMDnsIPConfigData **plugin_confs = NULL; + guint i, num, len; + NMResolvConfData rc = { + .nameservers = g_ptr_array_new (), + .searches = g_ptr_array_new (), + .options = g_ptr_array_new (), + .nis_domain = NULL, + .nis_servers = g_ptr_array_new (), + }; + + if (global_config) + merge_global_dns_config (&rc, global_config); + else { + nm_auto_free_gstring GString *tmp_gstring = NULL; + int prio, prev_prio = 0; + NMDnsIPConfigData *current; + gboolean skip = FALSE, v4; + + plugin_confs = g_new (NMDnsIPConfigData *, configs->len + 1); + + for (i = 0; i < configs->len; i++) { + current = configs->pdata[i]; + v4 = NM_IS_IP4_CONFIG (current->config); + + prio = v4 ? + nm_ip4_config_get_dns_priority ((NMIP4Config *) current->config) : + nm_ip6_config_get_dns_priority ((NMIP6Config *) current->config); + + if (prev_prio < 0 && prio != prev_prio) { + skip = TRUE; + plugin_confs[i] = NULL; + } + + prev_prio = prio; + + if ( ( v4 && nm_ip4_config_get_num_nameservers ((NMIP4Config *) current->config)) + || (!v4 && nm_ip6_config_get_num_nameservers ((NMIP6Config *) current->config))) { + _LOGT ("config: %8d %-7s v%c %-16s %s: %s", + prio, + _config_type_to_string (current->type), + v4 ? '4' : '6', + current->iface, + skip ? "" : "", + get_nameserver_list (current->config, &tmp_gstring)); + } + + if (!skip) { + merge_one_ip_config_data (&rc, current); + plugin_confs[i] = current; + } + } + plugin_confs[i] = NULL; + } + + /* If the hostname is a FQDN ("dcbw.example.com"), then add the domain part of it + * ("example.com") to the searches list, to ensure that we can still resolve its + * non-FQ form ("dcbw") too. (Also, if there are no other search domains specified, + * this makes a good default.) However, if the hostname is the top level of a domain + * (eg, "example.com"), then use the hostname itself as the search (since the user is + * unlikely to want "com" as a search domain). + */ + if (hostname) { + const char *hostdomain = strchr (hostname, '.'); + + if ( hostdomain + && !nm_utils_ipaddr_valid (AF_UNSPEC, hostname)) { + hostdomain++; + if (DOMAIN_IS_VALID (hostdomain)) + add_string_item (rc.searches, hostdomain); + else if (DOMAIN_IS_VALID (hostname)) + add_string_item (rc.searches, hostname); + } + } + + /* Per 'man resolv.conf', the search list is limited to 6 domains + * totalling 256 characters. + */ + num = MIN (rc.searches->len, 6u); + for (i = 0, len = 0; i < num; i++) { + len += strlen (rc.searches->pdata[i]) + 1; /* +1 for spaces */ + if (len > 256) + break; + } + g_ptr_array_set_size (rc.searches, i); + + *out_plugin_confs = plugin_confs; + *out_searches = _ptrarray_to_strv (rc.searches); + *out_options = _ptrarray_to_strv (rc.options); + *out_nameservers = _ptrarray_to_strv (rc.nameservers); + *out_nis_servers = _ptrarray_to_strv (rc.nis_servers); + *out_nis_domain = rc.nis_domain; +} + +static gboolean +update_dns (NMDnsManager *self, + gboolean no_caching, + GError **error) +{ + NMDnsManagerPrivate *priv; + const char *nis_domain = NULL; + gs_strfreev char **searches = NULL; + gs_strfreev char **options = NULL; + gs_strfreev char **nameservers = NULL; + gs_strfreev char **nis_servers = NULL; + gboolean caching = FALSE, update = TRUE; + gboolean resolv_conf_updated = FALSE; + SpawnResult result = SR_ERROR; + NMConfigData *data; + NMGlobalDnsConfig *global_config; + gs_free NMDnsIPConfigData **plugin_confs = NULL; + + g_return_val_if_fail (!error || !*error, FALSE); + + priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + nm_clear_g_source (&priv->plugin_ratelimit.timer); + + if (NM_IN_SET (priv->rc_manager, NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, + NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE)) { + update = FALSE; + _LOGD ("update-dns: not updating resolv.conf"); + } else { + priv->dns_touched = TRUE; + _LOGD ("update-dns: updating resolv.conf"); + } + + data = nm_config_get_data (priv->config); + global_config = nm_config_data_get_global_dns_config (data); + + if (priv->need_sort) { + g_ptr_array_sort (priv->configs, ip_config_data_ptr_compare); + priv->need_sort = FALSE; + } + + /* Update hash with config we're applying */ + compute_hash (self, global_config, priv->hash); + + _collect_resolv_conf_data (self, global_config, priv->configs, priv->hostname, + &searches, &options, &nameservers, &nis_servers, &nis_domain, + &plugin_confs); + + /* Let any plugins do their thing first */ + if (priv->plugin) { + NMDnsPlugin *plugin = priv->plugin; + const char *plugin_name = nm_dns_plugin_get_name (plugin); + + if (nm_dns_plugin_is_caching (plugin)) { + if (no_caching) { + _LOGD ("update-dns: plugin %s ignored (caching disabled)", + plugin_name); + goto skip; + } + caching = TRUE; + } + + _LOGD ("update-dns: updating plugin %s", plugin_name); + if (!nm_dns_plugin_update (plugin, + (const NMDnsIPConfigData **) plugin_confs, + global_config, + priv->hostname)) { + _LOGW ("update-dns: plugin %s update failed", plugin_name); + + /* If the plugin failed to update, we shouldn't write out a local + * caching DNS configuration to resolv.conf. + */ + caching = FALSE; + } + + skip: + ; + } + + /* If caching was successful, we only send 127.0.0.1 to /etc/resolv.conf + * to ensure that the glibc resolver doesn't try to round-robin nameservers, + * but only uses the local caching nameserver. + */ + if (caching) { + g_strfreev (nameservers); + nameservers = g_new0 (char*, 2); + nameservers[0] = g_strdup ("127.0.0.1"); + } + + if (update) { + switch (priv->rc_manager) { + case NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK: + case NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: + result = update_resolv_conf (self, searches, nameservers, options, error, priv->rc_manager); + resolv_conf_updated = TRUE; + break; + case NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: + result = dispatch_resolvconf (self, searches, nameservers, options, error); + break; + case NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG: + result = dispatch_netconfig (self, searches, nameservers, nis_domain, + nis_servers, error); + break; + default: + g_assert_not_reached (); + } + + if (result == SR_NOTFOUND) { + _LOGD ("update-dns: program not available, writing to resolv.conf"); + g_clear_error (error); + result = update_resolv_conf (self, searches, nameservers, options, error, NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK); + resolv_conf_updated = TRUE; + } + } + + /* Unless we've already done it, update private resolv.conf in NMRUNDIR + ignoring any errors */ + if (!resolv_conf_updated) + update_resolv_conf (self, searches, nameservers, options, NULL, NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED); + + /* signal that resolv.conf was changed */ + if (update && result == SR_SUCCESS) + g_signal_emit (self, signals[CONFIG_CHANGED], 0); + + g_clear_pointer (&priv->config_variant, g_variant_unref); + _notify (self, PROP_CONFIGURATION); + + return !update || result == SR_SUCCESS; +} + +static void +plugin_failed (NMDnsPlugin *plugin, gpointer user_data) +{ + NMDnsManager *self = NM_DNS_MANAGER (user_data); + GError *error = NULL; + + /* Errors with non-caching plugins aren't fatal */ + if (!nm_dns_plugin_is_caching (plugin)) + return; + + /* Disable caching until the next DNS update */ + if (!update_dns (self, TRUE, &error)) { + _LOGW ("could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } +} + +static gboolean +plugin_child_quit_update_dns (gpointer user_data) +{ + GError *error = NULL; + NMDnsManager *self = NM_DNS_MANAGER (user_data); + + /* Let the plugin try to spawn the child again */ + if (!update_dns (self, FALSE, &error)) { + _LOGW ("could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } + + return G_SOURCE_REMOVE; +} + +static void +plugin_child_quit (NMDnsPlugin *plugin, int exit_status, gpointer user_data) +{ + NMDnsManager *self = NM_DNS_MANAGER (user_data); + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + gint64 ts = nm_utils_get_monotonic_timestamp_ms (); + + _LOGW ("plugin %s child quit unexpectedly", nm_dns_plugin_get_name (plugin)); + + if ( !priv->plugin_ratelimit.ts + || (ts - priv->plugin_ratelimit.ts) / 1000 > PLUGIN_RATELIMIT_INTERVAL) { + priv->plugin_ratelimit.ts = ts; + priv->plugin_ratelimit.num_restarts = 0; + } else { + priv->plugin_ratelimit.num_restarts++; + if (priv->plugin_ratelimit.num_restarts > PLUGIN_RATELIMIT_BURST) { + _LOGW ("plugin %s child respawning too fast, delaying update for %u seconds", + nm_dns_plugin_get_name (plugin), PLUGIN_RATELIMIT_DELAY); + priv->plugin_ratelimit.timer = g_timeout_add_seconds (PLUGIN_RATELIMIT_DELAY, + plugin_child_quit_update_dns, + self); + return; + } + } + + plugin_child_quit_update_dns (self); +} + +static void +ip_config_dns_priority_changed (gpointer config, + GParamSpec *pspec, + NMDnsManager *self) +{ + NM_DNS_MANAGER_GET_PRIVATE (self)->need_sort = TRUE; +} + +static void +forget_data (NMDnsManager *self, NMDnsIPConfigData *data) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + if (data == priv->best_conf4) + priv->best_conf4 = NULL; + else if (data == priv->best_conf6) + priv->best_conf6 = NULL; + + g_signal_handlers_disconnect_by_func (data->config, ip_config_dns_priority_changed, self); +} + +static gboolean +nm_dns_manager_add_ip_config (NMDnsManager *self, + const char *iface, + gpointer config, + NMDnsIPConfigType cfg_type) +{ + NMDnsManagerPrivate *priv; + GError *error = NULL; + NMDnsIPConfigData *data; + gboolean v4 = NM_IS_IP4_CONFIG (config); + guint i; + + g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE); + g_return_val_if_fail (config, FALSE); + g_return_val_if_fail (iface && iface[0], FALSE); + + priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + for (i = 0; i < priv->configs->len; i++) { + data = priv->configs->pdata[i]; + if (data->config == config) { + if ( nm_streq (data->iface, iface) + && data->type == cfg_type) + return FALSE; + else { + forget_data (self, data); + g_ptr_array_remove_index_fast (priv->configs, i); + break; + } + } + } + + data = ip_config_data_new (config, cfg_type, iface); + g_ptr_array_add (priv->configs, data); + g_signal_connect (config, + v4 ? + "notify::" NM_IP4_CONFIG_DNS_PRIORITY : + "notify::" NM_IP6_CONFIG_DNS_PRIORITY, + (GCallback) ip_config_dns_priority_changed, self); + priv->need_sort = TRUE; + + if (cfg_type == NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE) { + /* Only one best-device per IP version is allowed */ + if (v4) { + if (priv->best_conf4) + priv->best_conf4->type = NM_DNS_IP_CONFIG_TYPE_DEFAULT; + priv->best_conf4 = data; + } else { + if (priv->best_conf6) + priv->best_conf6->type = NM_DNS_IP_CONFIG_TYPE_DEFAULT; + priv->best_conf6 = data; + } + } + + if (!priv->updates_queue && !update_dns (self, FALSE, &error)) { + _LOGW ("could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } + + return TRUE; +} + +gboolean +nm_dns_manager_add_ip4_config (NMDnsManager *self, + const char *iface, + NMIP4Config *config, + NMDnsIPConfigType cfg_type) +{ + return nm_dns_manager_add_ip_config (self, iface, config, cfg_type); +} + +gboolean +nm_dns_manager_add_ip6_config (NMDnsManager *self, + const char *iface, + NMIP6Config *config, + NMDnsIPConfigType cfg_type) +{ + return nm_dns_manager_add_ip_config (self, iface, config, cfg_type); +} + +static gboolean +nm_dns_manager_remove_ip_config (NMDnsManager *self, gpointer config) +{ + NMDnsManagerPrivate *priv; + GError *error = NULL; + NMDnsIPConfigData *data; + guint i; + + g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE); + g_return_val_if_fail (config, FALSE); + + priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + for (i = 0; i < priv->configs->len; i++) { + data = priv->configs->pdata[i]; + + if (data->config == config) { + forget_data (self, data); + g_ptr_array_remove_index (priv->configs, i); + + if (!priv->updates_queue && !update_dns (self, FALSE, &error)) { + _LOGW ("could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } + + return TRUE; + } + } + return FALSE; +} + +gboolean +nm_dns_manager_remove_ip4_config (NMDnsManager *self, NMIP4Config *config) +{ + return nm_dns_manager_remove_ip_config (self, config); +} + +gboolean +nm_dns_manager_remove_ip6_config (NMDnsManager *self, NMIP6Config *config) +{ + return nm_dns_manager_remove_ip_config (self, config); +} + +void +nm_dns_manager_set_initial_hostname (NMDnsManager *self, + const char *hostname) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + priv->hostname = g_strdup (hostname); +} + +void +nm_dns_manager_set_hostname (NMDnsManager *self, + const char *hostname) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + GError *error = NULL; + const char *filtered = NULL; + + /* Certain hostnames we don't want to include in resolv.conf 'searches' */ + if ( hostname + && nm_utils_is_specific_hostname (hostname) + && !strstr (hostname, ".in-addr.arpa") + && strchr (hostname, '.')) { + filtered = hostname; + } + + if ( (!priv->hostname && !filtered) + || (priv->hostname && filtered && !strcmp (priv->hostname, filtered))) + return; + + g_free (priv->hostname); + priv->hostname = g_strdup (filtered); + + if (!priv->updates_queue && !update_dns (self, FALSE, &error)) { + _LOGW ("could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } +} + +gboolean +nm_dns_manager_get_resolv_conf_explicit (NMDnsManager *self) +{ + NMDnsManagerPrivate *priv; + + g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE); + + priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + if ( NM_IN_SET (priv->rc_manager, NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, + NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE) + || priv->plugin) + return FALSE; + + return TRUE; +} + +void +nm_dns_manager_begin_updates (NMDnsManager *self, const char *func) +{ + NMDnsManagerPrivate *priv; + + g_return_if_fail (self != NULL); + priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + /* Save current hash when starting a new batch */ + if (priv->updates_queue == 0) + memcpy (priv->prev_hash, priv->hash, sizeof (priv->hash)); + + priv->updates_queue++; + + _LOGD ("(%s): queueing DNS updates (%d)", func, priv->updates_queue); +} + +void +nm_dns_manager_end_updates (NMDnsManager *self, const char *func) +{ + NMDnsManagerPrivate *priv; + GError *error = NULL; + gboolean changed; + guint8 new[HASH_LEN]; + + g_return_if_fail (self != NULL); + + priv = NM_DNS_MANAGER_GET_PRIVATE (self); + g_return_if_fail (priv->updates_queue > 0); + + if (priv->need_sort) { + g_ptr_array_sort (priv->configs, ip_config_data_ptr_compare); + priv->need_sort = FALSE; + } + + compute_hash (self, nm_config_data_get_global_dns_config (nm_config_get_data (priv->config)), new); + changed = (memcmp (new, priv->prev_hash, sizeof (new)) != 0) ? TRUE : FALSE; + _LOGD ("(%s): DNS configuration %s", func, changed ? "changed" : "did not change"); + + priv->updates_queue--; + if ((priv->updates_queue > 0) || (changed == FALSE)) { + _LOGD ("(%s): no DNS changes to commit (%d)", func, priv->updates_queue); + return; + } + + /* Commit all the outstanding changes */ + _LOGD ("(%s): committing DNS changes (%d)", func, priv->updates_queue); + if (!update_dns (self, FALSE, &error)) { + _LOGW ("could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } + + memset (priv->prev_hash, 0, sizeof (priv->prev_hash)); +} + +/*****************************************************************************/ + +static gboolean +_clear_plugin (NMDnsManager *self) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + if (priv->plugin) { + g_signal_handlers_disconnect_by_func (priv->plugin, plugin_failed, self); + g_signal_handlers_disconnect_by_func (priv->plugin, plugin_child_quit, self); + nm_dns_plugin_stop (priv->plugin); + g_clear_object (&priv->plugin); + return TRUE; + } + priv->plugin_ratelimit.ts = 0; + nm_clear_g_source (&priv->plugin_ratelimit.timer); + return FALSE; +} + +static NMDnsManagerResolvConfManager +_check_resconf_immutable (NMDnsManagerResolvConfManager rc_manager) +{ + struct stat st; + int fd, flags; + bool immutable = FALSE; + + switch (rc_manager) { + case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN: + case NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: + nm_assert_not_reached (); + /* fall-through */ + case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: + return NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED; + default: + + if (lstat (_PATH_RESCONF, &st) != 0) + return rc_manager; + + if (S_ISLNK (st.st_mode)) { + /* only regular files and directories can have extended file attributes. */ + switch (rc_manager) { + case NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK: + /* we don't care whether the link-target is immutable. + * If the symlink points to another file, rc-manager=symlink anyway backs off. + * Otherwise, we would only check whether our internal resolv.conf is immutable. */ + return NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK; + case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN: + case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: + case NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: + nm_assert_not_reached (); + /* fall-through */ + case NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: + case NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: + case NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG: + break; + } + } + + fd = open (_PATH_RESCONF, O_RDONLY | O_CLOEXEC); + if (fd != -1) { + if (ioctl (fd, FS_IOC_GETFLAGS, &flags) != -1) + immutable = NM_FLAGS_HAS (flags, FS_IMMUTABLE_FL); + close (fd); + } + return immutable ? NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE : rc_manager; + } +} + +static gboolean +_resolvconf_resolved_managed (void) +{ + static const char *const resolved_paths[] = { + "/run/systemd/resolve/resolv.conf", + "/lib/systemd/resolv.conf", + "/usr/lib/systemd/resolv.conf", + }; + GFile *f; + GFileInfo *info; + gboolean ret = FALSE; + + f = g_file_new_for_path (_PATH_RESCONF); + info = g_file_query_info (f, + G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK","\ + G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, + NULL, NULL); + + if (info && g_file_info_get_is_symlink (info)) { + ret = _nm_utils_strv_find_first ((gchar **) resolved_paths, + G_N_ELEMENTS (resolved_paths), + g_file_info_get_symlink_target (info)) >= 0; + } + + g_clear_object(&info); + g_clear_object(&f); + + return ret; +} + +static void +init_resolv_conf_mode (NMDnsManager *self, gboolean force_reload_plugin) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + NMDnsManagerResolvConfManager rc_manager; + const char *mode; + gboolean param_changed = FALSE, plugin_changed = FALSE; + + mode = nm_config_data_get_dns_mode (nm_config_get_data (priv->config)); + + if (nm_streq0 (mode, "none")) + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED; + else { + const char *man; + + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN; + man = nm_config_data_get_rc_manager (nm_config_get_data (priv->config)); + +again: + if (!man) { + /* nop */ + } else if (NM_IN_STRSET (man, "symlink", "none")) + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK; + else if (nm_streq (man, "file")) + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE; + else if (nm_streq (man, "resolvconf")) + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF; + else if (nm_streq (man, "netconfig")) + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG; + else if (nm_streq (man, "unmanaged")) + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED; + + if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN) { + if (man) { + _LOGW ("init: unknown resolv.conf manager \"%s\", fallback to \"%s\"", + man, ""NM_CONFIG_DEFAULT_MAIN_RC_MANAGER); + } + man = ""NM_CONFIG_DEFAULT_MAIN_RC_MANAGER; + rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK; + goto again; + } + } + + rc_manager = _check_resconf_immutable (rc_manager); + + if ( (!mode && _resolvconf_resolved_managed ()) + || nm_streq0 (mode, "systemd-resolved")) { + if ( force_reload_plugin + || !NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin)) { + _clear_plugin (self); + priv->plugin = nm_dns_systemd_resolved_new (); + plugin_changed = TRUE; + } + mode = "systemd-resolved"; + } else if (nm_streq0 (mode, "dnsmasq")) { + if (force_reload_plugin || !NM_IS_DNS_DNSMASQ (priv->plugin)) { + _clear_plugin (self); + priv->plugin = nm_dns_dnsmasq_new (); + plugin_changed = TRUE; + } + } else if (nm_streq0 (mode, "unbound")) { + if (force_reload_plugin || !NM_IS_DNS_UNBOUND (priv->plugin)) { + _clear_plugin (self); + priv->plugin = nm_dns_unbound_new (); + plugin_changed = TRUE; + } + } else { + if (!NM_IN_STRSET (mode, "none", "default")) { + if (mode) + _LOGW ("init: unknown dns mode '%s'", mode); + mode = "default"; + } + if (_clear_plugin (self)) + plugin_changed = TRUE; + } + + if (plugin_changed && priv->plugin) { + g_signal_connect (priv->plugin, NM_DNS_PLUGIN_FAILED, G_CALLBACK (plugin_failed), self); + g_signal_connect (priv->plugin, NM_DNS_PLUGIN_CHILD_QUIT, G_CALLBACK (plugin_child_quit), self); + } + + g_object_freeze_notify (G_OBJECT (self)); + + if (!nm_streq0 (priv->mode, mode)) { + g_free (priv->mode); + priv->mode = g_strdup (mode); + param_changed = TRUE; + _notify (self, PROP_MODE); + } + + if (priv->rc_manager != rc_manager) { + priv->rc_manager = rc_manager; + param_changed = TRUE; + _notify (self, PROP_RC_MANAGER); + } + + if (param_changed || plugin_changed) { + _LOGI ("init: dns=%s, rc-manager=%s%s%s%s", + mode, _rc_manager_to_string (rc_manager), + NM_PRINT_FMT_QUOTED (priv->plugin, ", plugin=", + nm_dns_plugin_get_name (priv->plugin), "", "")); + } + + g_object_thaw_notify (G_OBJECT (self)); +} + +static void +config_changed_cb (NMConfig *config, + NMConfigData *config_data, + NMConfigChangeFlags changes, + NMConfigData *old_data, + NMDnsManager *self) +{ + GError *error = NULL; + + if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_DNS_MODE | + NM_CONFIG_CHANGE_RC_MANAGER | + NM_CONFIG_CHANGE_CAUSE_SIGHUP | + NM_CONFIG_CHANGE_CAUSE_DNS_FULL)) { + /* reload the resolv-conf mode also on SIGHUP (when DNS_MODE didn't change). + * The reason is, that the configuration also depends on whether resolv.conf + * is immutable, thus, without the configuration changing, we always want to + * re-configure the mode. */ + init_resolv_conf_mode (self, + NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP + | NM_CONFIG_CHANGE_CAUSE_DNS_FULL)); + } + + if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP | + NM_CONFIG_CHANGE_CAUSE_SIGUSR1 | + NM_CONFIG_CHANGE_CAUSE_DNS_RC | + NM_CONFIG_CHANGE_CAUSE_DNS_FULL | + NM_CONFIG_CHANGE_DNS_MODE | + NM_CONFIG_CHANGE_RC_MANAGER | + NM_CONFIG_CHANGE_GLOBAL_DNS_CONFIG)) { + if (!update_dns (self, FALSE, &error)) { + _LOGW ("could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } + } +} + +static GVariant * +_get_global_config_variant (NMGlobalDnsConfig *global) +{ + NMGlobalDnsDomain *domain; + GVariantBuilder builder; + guint i, num; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}")); + num = nm_global_dns_config_get_num_domains (global); + for (i = 0; i < num; i++) { + GVariantBuilder conf_builder; + GVariantBuilder item_builder; + const char *domain_name; + const char * const *servers; + + g_variant_builder_init (&conf_builder, G_VARIANT_TYPE ("a{sv}")); + + domain = nm_global_dns_config_get_domain (global, i); + domain_name = nm_global_dns_domain_get_name (domain); + + if (domain_name && !nm_streq0 (domain_name, "*")) { + g_variant_builder_init (&item_builder, G_VARIANT_TYPE ("as")); + g_variant_builder_add (&item_builder, + "s", + domain_name); + g_variant_builder_add (&conf_builder, + "{sv}", + "domains", + g_variant_builder_end (&item_builder)); + } + + g_variant_builder_init (&item_builder, G_VARIANT_TYPE ("as")); + for (servers = nm_global_dns_domain_get_servers (domain); *servers; servers++) { + g_variant_builder_add (&item_builder, + "s", + *servers); + } + g_variant_builder_add (&conf_builder, + "{sv}", + "nameservers", + g_variant_builder_end (&item_builder)); + + g_variant_builder_add (&conf_builder, + "{sv}", + "priority", + g_variant_new_int32 (NM_DNS_PRIORITY_DEFAULT_NORMAL)); + + g_variant_builder_add (&builder, "a{sv}", &conf_builder); + } + + return g_variant_ref_sink (g_variant_builder_end (&builder)); +} + +static GVariant * +_get_config_variant (NMDnsManager *self) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + NMGlobalDnsConfig *global_config; + gs_free char *str = NULL; + GVariantBuilder builder; + NMConfigData *data; + guint i, j; + + if (priv->config_variant) + return priv->config_variant; + + data = nm_config_get_data (priv->config); + global_config = nm_config_data_get_global_dns_config (data); + if (global_config) { + priv->config_variant = _get_global_config_variant (global_config); + _LOGT ("current configuration: %s", (str = g_variant_print (priv->config_variant, TRUE))); + return priv->config_variant; + } + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}")); + + for (i = 0; i < priv->configs->len; i++) { + NMDnsIPConfigData *current = priv->configs->pdata[i]; + GVariantBuilder entry_builder; + GVariantBuilder strv_builder; + gboolean v4 = NM_IS_IP4_CONFIG (current->config); + gint priority; + + if (v4) { + NMIP4Config *config = NM_IP4_CONFIG (current->config); + guint num = nm_ip4_config_get_num_nameservers (config); + guint32 ns; + + if (!num) + continue; + + g_variant_builder_init (&entry_builder, G_VARIANT_TYPE ("a{sv}")); + + /* Add nameservers */ + g_variant_builder_init (&strv_builder, G_VARIANT_TYPE ("as")); + for (j = 0; j < num; j++) { + ns = nm_ip4_config_get_nameserver (config, j); + g_variant_builder_add (&strv_builder, + "s", + nm_utils_inet4_ntop (ns, NULL)); + } + g_variant_builder_add (&entry_builder, + "{sv}", + "nameservers", + g_variant_builder_end (&strv_builder)); + + /* Add domains */ + num = nm_ip4_config_get_num_domains (config); + if (num > 0) { + g_variant_builder_init (&strv_builder, G_VARIANT_TYPE ("as")); + for (j = 0; j < num; j++) { + g_variant_builder_add (&strv_builder, + "s", + nm_ip4_config_get_domain (config, j)); + } + g_variant_builder_add (&entry_builder, + "{sv}", + "domains", + g_variant_builder_end (&strv_builder)); + } + + priority = nm_ip4_config_get_dns_priority (config); + } else { + NMIP6Config *config = NM_IP6_CONFIG (current->config); + guint num = nm_ip6_config_get_num_nameservers (config); + const struct in6_addr *ns; + + if (!num) + continue; + + g_variant_builder_init (&entry_builder, G_VARIANT_TYPE ("a{sv}")); + + /* Add nameservers */ + g_variant_builder_init (&strv_builder, G_VARIANT_TYPE ("as")); + for (j = 0; j < num; j++) { + ns = nm_ip6_config_get_nameserver (config, j); + g_variant_builder_add (&strv_builder, + "s", + nm_utils_inet6_ntop (ns, NULL)); + } + g_variant_builder_add (&entry_builder, + "{sv}", + "nameservers", + g_variant_builder_end (&strv_builder)); + + /* Add domains */ + num = nm_ip6_config_get_num_domains (config); + if (num > 0) { + g_variant_builder_init (&strv_builder, G_VARIANT_TYPE ("as")); + for (j = 0; j < num; j++) { + g_variant_builder_add (&strv_builder, + "s", + nm_ip6_config_get_domain (config, j)); + } + g_variant_builder_add (&entry_builder, + "{sv}", + "domains", + g_variant_builder_end (&strv_builder)); + } + + priority = nm_ip6_config_get_dns_priority (config); + } + + /* Add device */ + if (current->iface) { + g_variant_builder_add (&entry_builder, + "{sv}", + "interface", + g_variant_new_string (current->iface)); + } + + /* Add priority */ + g_variant_builder_add (&entry_builder, + "{sv}", + "priority", + g_variant_new_int32 (priority)); + + /* Add VPN */ + g_variant_builder_add (&entry_builder, + "{sv}", + "vpn", + g_variant_new_boolean (current->type == NM_DNS_IP_CONFIG_TYPE_VPN)); + + g_variant_builder_add (&builder, "a{sv}", &entry_builder); + } + + priv->config_variant = g_variant_ref_sink (g_variant_builder_end (&builder)); + _LOGT ("current configuration: %s", (str = g_variant_print (priv->config_variant, TRUE))); + + return priv->config_variant; +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMDnsManager *self = NM_DNS_MANAGER (object); + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_MODE: + g_value_set_string (value, priv->mode); + break; + case PROP_RC_MANAGER: + g_value_set_string (value, _rc_manager_to_string (priv->rc_manager)); + break; + case PROP_CONFIGURATION: + g_value_set_variant (value, _get_config_variant (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_dns_manager_init (NMDnsManager *self) +{ + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + _LOGT ("creating..."); + + priv->config = g_object_ref (nm_config_get ()); + priv->configs = g_ptr_array_new_full (8, ip_config_data_destroy); + + /* Set the initial hash */ + compute_hash (self, NULL, NM_DNS_MANAGER_GET_PRIVATE (self)->hash); + + g_signal_connect (G_OBJECT (priv->config), + NM_CONFIG_SIGNAL_CONFIG_CHANGED, + G_CALLBACK (config_changed_cb), + self); + init_resolv_conf_mode (self, TRUE); +} + +static void +dispose (GObject *object) +{ + NMDnsManager *self = NM_DNS_MANAGER (object); + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + NMDnsIPConfigData *data; + GError *error = NULL; + guint i; + + _LOGT ("disposing"); + + _clear_plugin (self); + + /* If we're quitting, leave a valid resolv.conf in place, not one + * pointing to 127.0.0.1 if any plugins were active. Thus update + * DNS after disposing of all plugins. But if we haven't done any + * DNS updates yet, there's no reason to touch resolv.conf on shutdown. + */ + if (priv->dns_touched && !update_dns (self, TRUE, &error)) { + _LOGW ("could not commit DNS changes on shutdown: %s", error->message); + g_clear_error (&error); + priv->dns_touched = FALSE; + } + + if (priv->config) { + g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, self); + g_clear_object (&priv->config); + } + + if (priv->configs) { + for (i = 0; i < priv->configs->len; i++) { + data = priv->configs->pdata[i]; + forget_data (self, data); + } + g_ptr_array_free (priv->configs, TRUE); + priv->configs = NULL; + } + + nm_clear_g_source (&priv->plugin_ratelimit.timer); + + G_OBJECT_CLASS (nm_dns_manager_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + NMDnsManager *self = NM_DNS_MANAGER (object); + NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); + + g_free (priv->hostname); + g_free (priv->mode); + + G_OBJECT_CLASS (nm_dns_manager_parent_class)->finalize (object); +} + +static void +nm_dns_manager_class_init (NMDnsManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (klass); + + object_class->dispose = dispose; + object_class->finalize = finalize; + object_class->get_property = get_property; + + exported_object_class->export_path = NM_DBUS_PATH "/DnsManager"; + exported_object_class->export_on_construction = TRUE; + + obj_properties[PROP_MODE] = + g_param_spec_string (NM_DNS_MANAGER_MODE, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_RC_MANAGER] = + g_param_spec_string (NM_DNS_MANAGER_RC_MANAGER, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_CONFIGURATION] = + g_param_spec_variant (NM_DNS_MANAGER_CONFIGURATION, "", "", + G_VARIANT_TYPE ("aa{sv}"), + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + signals[CONFIG_CHANGED] = + g_signal_new (NM_DNS_MANAGER_CONFIG_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), + NMDBUS_TYPE_DNS_MANAGER_SKELETON, + NULL); +} + diff --git a/src/dns/nm-dns-manager.h b/src/dns/nm-dns-manager.h new file mode 100644 index 00000000..2fc2031b --- /dev/null +++ b/src/dns/nm-dns-manager.h @@ -0,0 +1,123 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2004 - 2005 Colin Walters + * Copyright (C) 2004 - 2013 Red Hat, Inc. + * Copyright (C) 2005 - 2008 Novell, Inc. + * and others + */ + +#ifndef __NETWORKMANAGER_DNS_MANAGER_H__ +#define __NETWORKMANAGER_DNS_MANAGER_H__ + +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" + +typedef enum { + NM_DNS_IP_CONFIG_TYPE_DEFAULT = 0, + NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE, + NM_DNS_IP_CONFIG_TYPE_VPN +} NMDnsIPConfigType; + +enum { + NM_DNS_PRIORITY_DEFAULT_NORMAL = 100, + NM_DNS_PRIORITY_DEFAULT_VPN = 50, +}; + +typedef struct { + gpointer config; + NMDnsIPConfigType type; + char *iface; +} NMDnsIPConfigData; + +#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ()) +#define NM_DNS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_DNS_MANAGER, NMDnsManager)) +#define NM_DNS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_DNS_MANAGER, NMDnsManagerClass)) +#define NM_IS_DNS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NM_TYPE_DNS_MANAGER)) +#define NM_IS_DNS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_DNS_MANAGER)) +#define NM_DNS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_DNS_MANAGER, NMDnsManagerClass)) + +/* properties */ +#define NM_DNS_MANAGER_MODE "mode" +#define NM_DNS_MANAGER_RC_MANAGER "rc-manager" +#define NM_DNS_MANAGER_CONFIGURATION "configuration" + +/* internal signals */ +#define NM_DNS_MANAGER_CONFIG_CHANGED "config-changed" + +typedef struct _NMDnsManager NMDnsManager; +typedef struct _NMDnsManagerClass NMDnsManagerClass; + +GType nm_dns_manager_get_type (void); + +NMDnsManager * nm_dns_manager_get (void); + +/* Allow changes to be batched together */ +void nm_dns_manager_begin_updates (NMDnsManager *self, const char *func); +void nm_dns_manager_end_updates (NMDnsManager *self, const char *func); + +gboolean nm_dns_manager_add_ip4_config (NMDnsManager *self, + const char *iface, + NMIP4Config *config, + NMDnsIPConfigType cfg_type); + +gboolean nm_dns_manager_remove_ip4_config (NMDnsManager *self, NMIP4Config *config); + +gboolean nm_dns_manager_add_ip6_config (NMDnsManager *self, + const char *iface, + NMIP6Config *config, + NMDnsIPConfigType cfg_type); + +gboolean nm_dns_manager_remove_ip6_config (NMDnsManager *self, NMIP6Config *config); + +void nm_dns_manager_set_initial_hostname (NMDnsManager *self, + const char *hostname); +void nm_dns_manager_set_hostname (NMDnsManager *self, + const char *hostname); + +/** + * NMDnsManagerResolvConfManager + * @NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN: unspecified rc-manager. + * @NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: do not touch /etc/resolv.conf + * (but still write the internal copy -- unless it is symlinked by + * /etc/resolv.conf) + * @NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: similar to "unmanaged", + * but indicates that resolv.conf cannot be modified. + * @NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK: NM writes resolv.conf + * by symlinking it to the run state directory. + * @NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: Like SYMLINK, but instead of + * symlinking /etc/resolv.conf, write it as a file. + * @NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: NM is managing resolv.conf + through resolvconf + * @NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG: NM is managing resolv.conf + through netconfig + * + * NMDnsManager's management of resolv.conf + */ +typedef enum { + NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN, + NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, + NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE, + NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK, + NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE, + NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF, + NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG, +} NMDnsManagerResolvConfManager; + +gboolean nm_dns_manager_get_resolv_conf_explicit (NMDnsManager *self); + +#endif /* __NETWORKMANAGER_DNS_MANAGER_H__ */ diff --git a/src/dns/nm-dns-plugin.c b/src/dns/nm-dns-plugin.c new file mode 100644 index 00000000..3a3bc646 --- /dev/null +++ b/src/dns/nm-dns-plugin.c @@ -0,0 +1,316 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2010 - 2012 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include "nm-dns-plugin.h" + +#include +#include +#include +#include +#include + +#include "nm-core-internal.h" +#include "NetworkManagerUtils.h" + +/*****************************************************************************/ + +enum { + FAILED, + CHILD_QUIT, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct _NMDnsPluginPrivate { + GPid pid; + guint watch_id; + char *progname; + char *pidfile; +} NMDnsPluginPrivate; + +G_DEFINE_TYPE_EXTENDED (NMDnsPlugin, nm_dns_plugin, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, {}) + +#define NM_DNS_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMDnsPlugin, NM_IS_DNS_PLUGIN) + +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "dns-plugin" +#define _NMLOG_DOMAIN LOGD_DNS +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ + char __prefix[20]; \ + const NMDnsPlugin *const __self = (self); \ + \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ + "%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG_PREFIX_NAME, \ + (!__self \ + ? "" \ + : nm_sprintf_buf (__prefix, "[%p]", __self)) \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +/*****************************************************************************/ + +gboolean +nm_dns_plugin_update (NMDnsPlugin *self, + const NMDnsIPConfigData **configs, + const NMGlobalDnsConfig *global_config, + const char *hostname) +{ + g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE); + + return NM_DNS_PLUGIN_GET_CLASS (self)->update (self, + configs, + global_config, + hostname); +} + +static gboolean +is_caching (NMDnsPlugin *self) +{ + return FALSE; +} + +gboolean +nm_dns_plugin_is_caching (NMDnsPlugin *self) +{ + return NM_DNS_PLUGIN_GET_CLASS (self)->is_caching (self); +} + +const char * +nm_dns_plugin_get_name (NMDnsPlugin *self) +{ + g_assert (NM_DNS_PLUGIN_GET_CLASS (self)->get_name); + return NM_DNS_PLUGIN_GET_CLASS (self)->get_name (self); +} + +/*****************************************************************************/ + +static void +_clear_pidfile (NMDnsPlugin *self) +{ + NMDnsPluginPrivate *priv = NM_DNS_PLUGIN_GET_PRIVATE (self); + + if (priv->pidfile) { + unlink (priv->pidfile); + g_clear_pointer (&priv->pidfile, g_free); + } +} + +static void +kill_existing (const char *progname, const char *pidfile, const char *kill_match) +{ + glong pid; + gs_free char *contents = NULL; + gs_free char *cmdline_contents = NULL; + guint64 start_time; + char proc_path[256]; + gs_free_error GError *error = NULL; + + if (!pidfile) + return; + + if (!kill_match) + g_return_if_reached (); + + if (!g_file_get_contents (pidfile, &contents, NULL, &error)) { + if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) + return; + goto out; + } + + pid = _nm_utils_ascii_str_to_int64 (contents, 10, 2, INT_MAX, -1); + if (pid == -1) + goto out; + + start_time = nm_utils_get_start_time_for_pid (pid, NULL, NULL); + if (start_time == 0) + goto out; + + nm_sprintf_buf (proc_path, "/proc/%ld/cmdline", pid); + if (!g_file_get_contents (proc_path, &cmdline_contents, NULL, NULL)) + goto out; + + if (!strstr (cmdline_contents, kill_match)) + goto out; + + nm_utils_kill_process_sync (pid, start_time, SIGKILL, _NMLOG_DOMAIN, + progname ?: "", + 0, 0, 1000); + +out: + unlink (pidfile); +} + +static void +watch_cb (GPid pid, gint status, gpointer user_data) +{ + NMDnsPlugin *self = NM_DNS_PLUGIN (user_data); + NMDnsPluginPrivate *priv = NM_DNS_PLUGIN_GET_PRIVATE (self); + + priv->pid = 0; + priv->watch_id = 0; + g_clear_pointer (&priv->progname, g_free); + _clear_pidfile (self); + + g_signal_emit (self, signals[CHILD_QUIT], 0, status); +} + +GPid +nm_dns_plugin_child_pid (NMDnsPlugin *self) +{ + NMDnsPluginPrivate *priv; + + g_return_val_if_fail (NM_IS_DNS_PLUGIN (self), 0); + + priv = NM_DNS_PLUGIN_GET_PRIVATE (self); + return priv->pid; +} + +GPid +nm_dns_plugin_child_spawn (NMDnsPlugin *self, + const char **argv, + const char *pidfile, + const char *kill_match) +{ + NMDnsPluginPrivate *priv; + GError *error = NULL; + GPid pid; + gs_free char *cmdline = NULL; + gs_free char *progname = NULL; + + g_return_val_if_fail (argv && argv[0], 0); + g_return_val_if_fail (NM_IS_DNS_PLUGIN (self), 0); + + priv = NM_DNS_PLUGIN_GET_PRIVATE (self); + + g_return_val_if_fail (!priv->pid, 0); + nm_assert (!priv->progname); + nm_assert (!priv->watch_id); + nm_assert (!priv->pidfile); + + progname = g_path_get_basename (argv[0]); + kill_existing (progname, pidfile, kill_match); + + _LOGI ("starting %s...", progname); + _LOGD ("command line: %s", + (cmdline = g_strjoinv (" ", (char **) argv))); + + if (!g_spawn_async (NULL, (char **) argv, NULL, + G_SPAWN_DO_NOT_REAP_CHILD, + nm_utils_setpgid, NULL, + &pid, + &error)) { + _LOGW ("failed to spawn %s: %s", + progname, error->message); + g_clear_error (&error); + return 0; + } + + _LOGD ("%s started with pid %d", progname, pid); + priv->watch_id = g_child_watch_add (pid, (GChildWatchFunc) watch_cb, self); + priv->pid = pid; + priv->progname = g_steal_pointer (&progname); + priv->pidfile = g_strdup (pidfile); + + return pid; +} + +gboolean +nm_dns_plugin_child_kill (NMDnsPlugin *self) +{ + NMDnsPluginPrivate *priv = NM_DNS_PLUGIN_GET_PRIVATE (self); + + nm_clear_g_source (&priv->watch_id); + if (priv->pid) { + nm_utils_kill_child_sync (priv->pid, SIGTERM, _NMLOG_DOMAIN, + priv->progname ?: "", NULL, 1000, 0); + priv->pid = 0; + g_clear_pointer (&priv->progname, g_free); + } + _clear_pidfile (self); + + return TRUE; +} + +void +nm_dns_plugin_stop (NMDnsPlugin *self) +{ + nm_dns_plugin_child_kill (self); +} + +/*****************************************************************************/ + +static void +nm_dns_plugin_init (NMDnsPlugin *self) +{ + self->_priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_DNS_PLUGIN, NMDnsPluginPrivate); +} + +static void +dispose (GObject *object) +{ + NMDnsPlugin *self = NM_DNS_PLUGIN (object); + + nm_dns_plugin_stop (self); + + G_OBJECT_CLASS (nm_dns_plugin_parent_class)->dispose (object); +} + +static void +nm_dns_plugin_class_init (NMDnsPluginClass *plugin_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (plugin_class); + + g_type_class_add_private (plugin_class, sizeof (NMDnsPluginPrivate)); + + object_class->dispose = dispose; + + plugin_class->is_caching = is_caching; + + /* Emitted by the plugin and consumed by NMDnsManager when + * some error happens with the nameserver subprocess. Causes NM to fall + * back to writing out a non-local-caching resolv.conf until the next + * DNS update. + */ + signals[FAILED] = + g_signal_new (NM_DNS_PLUGIN_FAILED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[CHILD_QUIT] = + g_signal_new (NM_DNS_PLUGIN_CHILD_QUIT, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDnsPluginClass, child_quit), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); +} diff --git a/src/dns/nm-dns-plugin.h b/src/dns/nm-dns-plugin.h new file mode 100644 index 00000000..12109441 --- /dev/null +++ b/src/dns/nm-dns-plugin.h @@ -0,0 +1,106 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2010 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DNS_PLUGIN_H__ +#define __NETWORKMANAGER_DNS_PLUGIN_H__ + +#include "nm-dns-manager.h" +#include "nm-config-data.h" + +#define NM_TYPE_DNS_PLUGIN (nm_dns_plugin_get_type ()) +#define NM_DNS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_PLUGIN, NMDnsPlugin)) +#define NM_DNS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_PLUGIN, NMDnsPluginClass)) +#define NM_IS_DNS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_PLUGIN)) +#define NM_IS_DNS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_PLUGIN)) +#define NM_DNS_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_PLUGIN, NMDnsPluginClass)) + +#define NM_DNS_PLUGIN_FAILED "failed" +#define NM_DNS_PLUGIN_CHILD_QUIT "child-quit" + +struct _NMDnsPluginPrivate; + +typedef struct { + GObject parent; + struct _NMDnsPluginPrivate *_priv; +} NMDnsPlugin; + +typedef struct { + GObjectClass parent; + + /* Methods */ + + /* Called when DNS information is changed. 'configs' is an array + * of pointers to NMDnsIPConfigData sorted by priority. + * 'global_config' is the optional global DNS + * configuration. + */ + gboolean (*update) (NMDnsPlugin *self, + const NMDnsIPConfigData **configs, + const NMGlobalDnsConfig *global_config, + const char *hostname); + + /* Subclasses should override and return TRUE if they start a local + * caching nameserver that listens on localhost and would block any + * other local caching nameserver from operating. + */ + gboolean (*is_caching) (NMDnsPlugin *self); + + /* Subclasses should override this and return their plugin name */ + const char *(*get_name) (NMDnsPlugin *self); + + /* Signals */ + + /* Emitted by the plugin base class when the nameserver subprocess + * quits. This signal is consumed by the plugin subclasses and not + * by NMDnsManager. If the subclass decides the exit status (as returned + * by waitpid(2)) is fatal it should then emit the 'failed' signal. + */ + void (*child_quit) (NMDnsPlugin *self, gint status); +} NMDnsPluginClass; + +GType nm_dns_plugin_get_type (void); + +gboolean nm_dns_plugin_is_caching (NMDnsPlugin *self); + +const char *nm_dns_plugin_get_name (NMDnsPlugin *self); + +gboolean nm_dns_plugin_update (NMDnsPlugin *self, + const NMDnsIPConfigData **configs, + const NMGlobalDnsConfig *global_config, + const char *hostname); + +void nm_dns_plugin_stop (NMDnsPlugin *self); + +/* For subclasses/plugins */ + +/* Spawn a child process and watch for it to quit. 'argv' is the NULL-terminated + * argument vector to spawn the child with, where argv[0] is the full path to + * the child's executable. If 'pidfile' is given the process owning the PID + * contained in 'pidfile' will be killed if its command line matches 'kill_match' + * and the pidfile will be deleted. + */ +GPid nm_dns_plugin_child_spawn (NMDnsPlugin *self, + const char **argv, + const char *pidfile, + const char *kill_match); + +GPid nm_dns_plugin_child_pid (NMDnsPlugin *self); + +gboolean nm_dns_plugin_child_kill (NMDnsPlugin *self); + +#endif /* __NETWORKMANAGER_DNS_PLUGIN_H__ */ diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c new file mode 100644 index 00000000..325088e2 --- /dev/null +++ b/src/dns/nm-dns-systemd-resolved.c @@ -0,0 +1,428 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Dan Williams + * Copyright (C) 2016 Sjoerd Simons + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "nm-default.h" + +#include "nm-dns-systemd-resolved.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "nm-core-internal.h" +#include "platform/nm-platform.h" +#include "nm-utils.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" +#include "nm-bus-manager.h" +#include "nm-manager.h" +#include "devices/nm-device.h" +#include "NetworkManagerUtils.h" + +#define SYSTEMD_RESOLVED_DBUS_SERVICE "org.freedesktop.resolve1" +#define SYSTEMD_RESOLVED_DBUS_PATH "/org/freedesktop/resolve1" + +/*****************************************************************************/ + +typedef struct { + int ifindex; + GList *configs; +} InterfaceConfig; + +/*****************************************************************************/ + +typedef struct { + GDBusProxy *resolve; + GCancellable *init_cancellable; + GCancellable *update_cancellable; + GQueue dns_updates; + GQueue domain_updates; +} NMDnsSystemdResolvedPrivate; + +struct _NMDnsSystemdResolved { + NMDnsPlugin parent; + NMDnsSystemdResolvedPrivate _priv; +}; + +struct _NMDnsSystemdResolvedClass { + NMDnsPluginClass parent; +}; + +G_DEFINE_TYPE (NMDnsSystemdResolved, nm_dns_systemd_resolved, NM_TYPE_DNS_PLUGIN) + +#define NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDnsSystemdResolved, NM_IS_DNS_SYSTEMD_RESOLVED) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_DNS +#define _NMLOG(level, ...) __NMLOG_DEFAULT_WITH_ADDR (level, _NMLOG_DOMAIN, "dns-sd-resolved", __VA_ARGS__) + +/*****************************************************************************/ + +static void +call_done (GObject *source, GAsyncResult *r, gpointer user_data) +{ + GVariant *v; + GError *error = NULL; + NMDnsSystemdResolved *self = (NMDnsSystemdResolved *) user_data; + + v = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), r, &error); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + if (error != NULL) { + _LOGW ("Failed: %s\n", error->message); + g_error_free (error); + } +} + +static void +add_interface_configuration (NMDnsSystemdResolved *self, + GArray *interfaces, + const NMDnsIPConfigData *data) +{ + int i; + InterfaceConfig *ic = NULL; + int ifindex; + NMDevice *device; + + if (NM_IS_IP4_CONFIG (data->config)) + ifindex = nm_ip4_config_get_ifindex (data->config); + else if (NM_IS_IP6_CONFIG (data->config)) + ifindex = nm_ip6_config_get_ifindex (data->config); + else + g_return_if_reached (); + + device = nm_manager_get_device_by_ifindex (nm_manager_get (), ifindex); + + if (!nm_device_get_managed (device, FALSE)) + return; + + for (i = 0; i < interfaces->len; i++) { + InterfaceConfig *tic = &g_array_index (interfaces, InterfaceConfig, i); + if (ifindex == tic->ifindex) { + ic = tic; + break; + } + } + + if (!ic) { + g_array_set_size (interfaces, interfaces->len + 1); + ic = &g_array_index (interfaces, InterfaceConfig, + interfaces->len - 1); + ic->ifindex = ifindex; + } + + ic->configs = g_list_append (ic->configs, data->config); +} + +static void +add_domain (GVariantBuilder *domains, + const char *domain, + gboolean never_default) +{ + /* If this link is never the default (e.g. only used for resources on this + * network) add a routing domain. */ + g_variant_builder_add (domains, "(sb)", domain, never_default); +} + +static void +update_add_ip6_config (NMDnsSystemdResolved *self, + GVariantBuilder *dns, + GVariantBuilder *domains, + const NMIP6Config *config) +{ + guint i, n; + + n = nm_ip6_config_get_num_nameservers (config); + for (i = 0 ; i < n; i++) { + const struct in6_addr *ip; + + g_variant_builder_open (dns, G_VARIANT_TYPE ("(iay)")); + g_variant_builder_add (dns, "i", AF_INET6); + ip = nm_ip6_config_get_nameserver (config, i), + + g_variant_builder_add_value (dns, g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, ip, 16, 1)); + g_variant_builder_close (dns); + } + + n = nm_ip6_config_get_num_searches (config); + if (n > 0) { + for (i = 0; i < n; i++) { + add_domain (domains, nm_ip6_config_get_search (config, i), + nm_ip6_config_get_never_default (config)); + } + } else { + n = nm_ip6_config_get_num_domains (config); + for (i = 0; i < n; i++) { + add_domain (domains, nm_ip6_config_get_domain (config, i), + nm_ip6_config_get_never_default (config)); + } + } +} + +static void +update_add_ip4_config (NMDnsSystemdResolved *self, + GVariantBuilder *dns, + GVariantBuilder *domains, + const NMIP4Config *config) +{ + guint i, n; + + n = nm_ip4_config_get_num_nameservers (config); + for (i = 0 ; i < n; i++) { + guint32 ns; + + g_variant_builder_open (dns, G_VARIANT_TYPE ("(iay)")); + g_variant_builder_add (dns, "i", AF_INET); + ns = nm_ip4_config_get_nameserver (config, i), + + g_variant_builder_add_value (dns, g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, &ns, 4, 1)); + g_variant_builder_close (dns); + } + + n = nm_ip4_config_get_num_searches (config); + if (n > 0) { + for (i = 0; i < n; i++) { + add_domain (domains, nm_ip4_config_get_search (config, i), + nm_ip4_config_get_never_default (config)); + } + } else { + n = nm_ip4_config_get_num_domains (config); + for (i = 0; i < n; i++) { + add_domain (domains, nm_ip4_config_get_domain (config, i), + nm_ip4_config_get_never_default (config)); + } + } +} + +static void +free_pending_updates (NMDnsSystemdResolved *self) +{ + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); + GVariant *v; + + while ((v = g_queue_pop_head (&priv->dns_updates)) != NULL) + g_variant_unref (v); + + while ((v = g_queue_pop_head (&priv->domain_updates)) != NULL) + g_variant_unref (v); +} + +static void +prepare_one_interface (NMDnsSystemdResolved *self, InterfaceConfig *ic) +{ + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); + GVariantBuilder dns, domains; + GList *l; + + g_variant_builder_init (&dns, G_VARIANT_TYPE ("(ia(iay))")); + g_variant_builder_add (&dns, "i", ic->ifindex); + g_variant_builder_open (&dns, G_VARIANT_TYPE ("a(iay)")); + + g_variant_builder_init (&domains, G_VARIANT_TYPE ("(ia(sb))")); + g_variant_builder_add (&domains, "i", ic->ifindex); + g_variant_builder_open (&domains, G_VARIANT_TYPE ("a(sb)")); + + for (l = ic->configs ; l != NULL ; l = g_list_next (l)) { + if (NM_IS_IP4_CONFIG (l->data)) + update_add_ip4_config (self, &dns, &domains, l->data); + else if (NM_IS_IP6_CONFIG (l->data)) + update_add_ip6_config (self, &dns, &domains, l->data); + else + g_assert_not_reached (); + } + g_variant_builder_close (&dns); + g_variant_builder_close (&domains); + + g_queue_push_tail (&priv->dns_updates, + g_variant_ref_sink (g_variant_builder_end (&dns))); + g_queue_push_tail (&priv->domain_updates, + g_variant_ref_sink (g_variant_builder_end (&domains))); +} + +static void +send_updates (NMDnsSystemdResolved *self) +{ + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); + GVariant *v; + + nm_clear_g_cancellable (&priv->update_cancellable); + + if (!priv->resolve) + return; + + priv->update_cancellable = g_cancellable_new (); + + while ((v = g_queue_pop_head (&priv->dns_updates)) != NULL) { + g_dbus_proxy_call (priv->resolve, "SetLinkDNS", v, + G_DBUS_CALL_FLAGS_NONE, + -1, priv->update_cancellable, call_done, self); + g_variant_unref (v); + } + + while ((v = g_queue_pop_head (&priv->domain_updates)) != NULL) { + g_dbus_proxy_call (priv->resolve, "SetLinkDomains", v, + G_DBUS_CALL_FLAGS_NONE, + -1, priv->update_cancellable, call_done, self); + g_variant_unref (v); + } +} + +static gboolean +update (NMDnsPlugin *plugin, + const NMDnsIPConfigData **configs, + const NMGlobalDnsConfig *global_config, + const char *hostname) +{ + NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (plugin); + GArray *interfaces = g_array_new (TRUE, TRUE, sizeof (InterfaceConfig)); + const NMDnsIPConfigData **c; + int i; + + for (c = configs; *c != NULL; c++) + add_interface_configuration (self, interfaces, *c); + + free_pending_updates (self); + + for (i = 0; i < interfaces->len; i++) { + InterfaceConfig *ic = &g_array_index (interfaces, InterfaceConfig, i); + + prepare_one_interface (self, ic); + g_list_free (ic->configs); + } + + g_array_free (interfaces, TRUE); + + send_updates (self); + + return TRUE; +} + +/*****************************************************************************/ + +static gboolean +is_caching (NMDnsPlugin *plugin) +{ + return TRUE; +} + +static const char * +get_name (NMDnsPlugin *plugin) +{ + return "systemd-resolved"; +} + +/*****************************************************************************/ + +static void +resolved_proxy_created (GObject *source, GAsyncResult *r, gpointer user_data) +{ + NMDnsSystemdResolved *self = (NMDnsSystemdResolved *) user_data; + NMDnsSystemdResolvedPrivate *priv; + gs_free_error GError *error = NULL; + GDBusProxy *resolve; + + resolve = g_dbus_proxy_new_finish (r, &error); + if ( !resolve + && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); + g_clear_object (&priv->init_cancellable); + if (!resolve) { + _LOGW ("failed to connect to resolved via DBus: %s", error->message); + g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); + return; + } + + priv->resolve = resolve; + send_updates (self); +} + +/*****************************************************************************/ + +static void +nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self) +{ + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); + NMBusManager *dbus_mgr; + GDBusConnection *connection; + + g_queue_init (&priv->dns_updates); + g_queue_init (&priv->domain_updates); + + dbus_mgr = nm_bus_manager_get (); + g_return_if_fail (dbus_mgr); + + connection = nm_bus_manager_get_connection (dbus_mgr); + g_return_if_fail (connection); + + priv->init_cancellable = g_cancellable_new (); + g_dbus_proxy_new (connection, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | + G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, + NULL, + SYSTEMD_RESOLVED_DBUS_SERVICE, + SYSTEMD_RESOLVED_DBUS_PATH, + SYSTEMD_RESOLVED_DBUS_SERVICE ".Manager", + priv->init_cancellable, + resolved_proxy_created, + self); +} + +NMDnsPlugin * +nm_dns_systemd_resolved_new (void) +{ + return g_object_new (NM_TYPE_DNS_SYSTEMD_RESOLVED, NULL); +} + +static void +dispose (GObject *object) +{ + NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (object); + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); + + free_pending_updates (self); + g_clear_object (&priv->resolve); + nm_clear_g_cancellable (&priv->init_cancellable); + nm_clear_g_cancellable (&priv->update_cancellable); + + G_OBJECT_CLASS (nm_dns_systemd_resolved_parent_class)->dispose (object); +} + +static void +nm_dns_systemd_resolved_class_init (NMDnsSystemdResolvedClass *dns_class) +{ + NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (dns_class); + GObjectClass *object_class = G_OBJECT_CLASS (dns_class); + + object_class->dispose = dispose; + + plugin_class->is_caching = is_caching; + plugin_class->update = update; + plugin_class->get_name = get_name; +} diff --git a/src/dns/nm-dns-systemd-resolved.h b/src/dns/nm-dns-systemd-resolved.h new file mode 100644 index 00000000..800a60c1 --- /dev/null +++ b/src/dns/nm-dns-systemd-resolved.h @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2016 Sjoerd Simons + */ + +#ifndef __NETWORKMANAGER_DNS_SYSTEMD_RESOLVED_H__ +#define __NETWORKMANAGER_DNS_SYSTEMD_RESOLVED_H__ + +#include "nm-dns-plugin.h" + +#define NM_TYPE_DNS_SYSTEMD_RESOLVED (nm_dns_systemd_resolved_get_type ()) +#define NM_DNS_SYSTEMD_RESOLVED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_SYSTEMD_RESOLVED, NMDnsSystemdResolved)) +#define NM_DNS_SYSTEMD_RESOLVED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_SYSTEMD_RESOLVED, NMDnsSystemdResolvedClass)) +#define NM_IS_DNS_SYSTEMD_RESOLVED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_SYSTEMD_RESOLVED)) +#define NM_IS_DNS_SYSTEMD_RESOLVED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_SYSTEMD_RESOLVED)) +#define NM_DNS_SYSTEMD_RESOLVED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_SYSTEMD_RESOLVED, NMDnsSystemdResolvedClass)) + +typedef struct _NMDnsSystemdResolved NMDnsSystemdResolved; +typedef struct _NMDnsSystemdResolvedClass NMDnsSystemdResolvedClass; + +GType nm_dns_systemd_resolved_get_type (void); + +NMDnsPlugin *nm_dns_systemd_resolved_new (void); + +#endif /* __NETWORKMANAGER_DNS_SYSTEMD_RESOLVED_H__ */ diff --git a/src/dns/nm-dns-unbound.c b/src/dns/nm-dns-unbound.c new file mode 100644 index 00000000..3659beac --- /dev/null +++ b/src/dns/nm-dns-unbound.c @@ -0,0 +1,91 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2014 Red Hat, Inc. + * Author: Pavel Å imerda + */ +#include "nm-default.h" + +#include "nm-dns-unbound.h" + +#include "NetworkManagerUtils.h" + +/*****************************************************************************/ + +struct _NMDnsUnbound { + NMDnsPlugin parent; +}; + +struct _NMDnsUnboundClass { + NMDnsPluginClass parent; +}; + +G_DEFINE_TYPE (NMDnsUnbound, nm_dns_unbound, NM_TYPE_DNS_PLUGIN) + +/*****************************************************************************/ + +static gboolean +update (NMDnsPlugin *plugin, + const NMDnsIPConfigData **configs, + const NMGlobalDnsConfig *global_config, + const char *hostname) +{ + /* TODO: We currently call a script installed with the dnssec-trigger + * package that queries all information itself. Later, the dependency + * on that package will be optional and the only hard dependency will + * be unbound. + * + * Unbound configuration should be later handled by this plugin directly, + * without calling custom scripts. The dnssec-trigger functionality + * may be eventually merged into NetworkManager. + */ + return nm_spawn_process (DNSSEC_TRIGGER_SCRIPT " --async --update", NULL) == 0; +} + +static gboolean +is_caching (NMDnsPlugin *plugin) +{ + return TRUE; +} + +static const char * +get_name (NMDnsPlugin *plugin) +{ + return "unbound"; +} + +/*****************************************************************************/ + +static void +nm_dns_unbound_init (NMDnsUnbound *unbound) +{ +} + +NMDnsPlugin * +nm_dns_unbound_new (void) +{ + return g_object_new (NM_TYPE_DNS_UNBOUND, NULL); +} + +static void +nm_dns_unbound_class_init (NMDnsUnboundClass *klass) +{ + NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (klass); + + plugin_class->update = update; + plugin_class->is_caching = is_caching; + plugin_class->get_name = get_name; +} diff --git a/src/dns/nm-dns-unbound.h b/src/dns/nm-dns-unbound.h new file mode 100644 index 00000000..100ff2c4 --- /dev/null +++ b/src/dns/nm-dns-unbound.h @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2014 Red Hat, Inc. + */ +#ifndef __NETWORKMANAGER_DNS_UNBOUND_H__ +#define __NETWORKMANAGER_DNS_UNBOUND_H__ + +#include "nm-dns-plugin.h" + +#define NM_TYPE_DNS_UNBOUND (nm_dns_unbound_get_type ()) +#define NM_DNS_UNBOUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_UNBOUND, NMDnsUnbound)) +#define NM_DNS_UNBOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_UNBOUND, NMDnsUnboundClass)) +#define NM_IS_DNS_UNBOUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_UNBOUND)) +#define NM_IS_DNS_UNBOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_UNBOUND)) +#define NM_DNS_UNBOUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_UNBOUND, NMDnsUnboundClass)) + +typedef struct _NMDnsUnbound NMDnsUnbound; +typedef struct _NMDnsUnboundClass NMDnsUnboundClass; + +GType nm_dns_unbound_get_type (void); + +NMDnsPlugin *nm_dns_unbound_new (void); + +#endif /* __NETWORKMANAGER_DNS_UNBOUND_H__ */ diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.c b/src/dnsmasq-manager/nm-dnsmasq-manager.c deleted file mode 100644 index 7b725944..00000000 --- a/src/dnsmasq-manager/nm-dnsmasq-manager.c +++ /dev/null @@ -1,388 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 - 2012 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "nm-dnsmasq-manager.h" -#include "nm-dnsmasq-utils.h" -#include "nm-utils.h" -#include "NetworkManagerUtils.h" -#include "nm-core-internal.h" - -#define _NMLOG_DOMAIN LOGD_SHARING -#define _NMLOG_PREFIX_NAME "dnsmasq-manager" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -typedef struct { - char *iface; - char *pidfile; - GPid pid; - guint dm_watch_id; -} NMDnsMasqManagerPrivate; - -#define NM_DNSMASQ_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManagerPrivate)) - -#define CONFDIR NMCONFDIR "/dnsmasq-shared.d" - -G_DEFINE_TYPE (NMDnsMasqManager, nm_dnsmasq_manager, G_TYPE_OBJECT) - -enum { - STATE_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -typedef struct { - GPtrArray *array; - GStringChunk *chunk; -} NMCmdLine; - -static NMCmdLine * -nm_cmd_line_new (void) -{ - NMCmdLine *cmd; - - cmd = g_slice_new (NMCmdLine); - cmd->array = g_ptr_array_new (); - cmd->chunk = g_string_chunk_new (1024); - - return cmd; -} - -static void -nm_cmd_line_destroy (NMCmdLine *cmd) -{ - g_ptr_array_free (cmd->array, TRUE); - g_string_chunk_free (cmd->chunk); - g_slice_free (NMCmdLine, cmd); -} - -static char * -nm_cmd_line_to_str (NMCmdLine *cmd) -{ - char *str; - - g_ptr_array_add (cmd->array, NULL); - str = g_strjoinv (" ", (gchar **) cmd->array->pdata); - g_ptr_array_remove_index (cmd->array, cmd->array->len - 1); - - return str; -} - -static void -nm_cmd_line_add_string (NMCmdLine *cmd, const char *str) -{ - g_ptr_array_add (cmd->array, g_string_chunk_insert (cmd->chunk, str)); -} - -/*******************************************/ - -static void -dm_watch_cb (GPid pid, gint status, gpointer user_data) -{ - NMDnsMasqManager *manager = NM_DNSMASQ_MANAGER (user_data); - NMDnsMasqManagerPrivate *priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); - guint err; - - if (WIFEXITED (status)) { - err = WEXITSTATUS (status); - if (err != 0) { - _LOGW ("dnsmasq exited with error: %s", - nm_utils_dnsmasq_status_to_string (err, NULL, 0)); - } - } else if (WIFSTOPPED (status)) { - _LOGW ("dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status)); - } else if (WIFSIGNALED (status)) { - _LOGW ("dnsmasq died with signal %d", WTERMSIG (status)); - } else { - _LOGW ("dnsmasq died from an unknown cause"); - } - - priv->pid = 0; - priv->dm_watch_id = 0; - - g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_DNSMASQ_STATUS_DEAD); -} - -static NMCmdLine * -create_dm_cmd_line (const char *iface, - const NMIP4Config *ip4_config, - const char *pidfile, - GError **error) -{ - NMCmdLine *cmd; - GString *s; - char first[INET_ADDRSTRLEN]; - char last[INET_ADDRSTRLEN]; - char localaddr[INET_ADDRSTRLEN]; - char *error_desc = NULL; - const char *dm_binary; - const NMPlatformIP4Address *listen_address; - - listen_address = nm_ip4_config_get_address (ip4_config, 0); - g_return_val_if_fail (listen_address, NULL); - - dm_binary = nm_utils_find_helper ("dnsmasq", DNSMASQ_PATH, error); - if (!dm_binary) - return NULL; - - /* Create dnsmasq command line */ - cmd = nm_cmd_line_new (); - nm_cmd_line_add_string (cmd, dm_binary); - - if (getenv ("NM_DNSMASQ_DEBUG")) { - nm_cmd_line_add_string (cmd, "--log-dhcp"); - nm_cmd_line_add_string (cmd, "--log-queries"); - } - - /* dnsmasq may read from it's default config file location, which if that - * location is a valid config file, it will combine with the options here - * and cause undesirable side-effects. Like sending bogus IP addresses - * as the gateway or whatever. So tell dnsmasq not to use any config file - * at all. - */ - nm_cmd_line_add_string (cmd, "--conf-file"); - - nm_cmd_line_add_string (cmd, "--no-hosts"); - nm_cmd_line_add_string (cmd, "--keep-in-foreground"); - nm_cmd_line_add_string (cmd, "--bind-interfaces"); - nm_cmd_line_add_string (cmd, "--except-interface=lo"); - nm_cmd_line_add_string (cmd, "--clear-on-reload"); - - /* Use strict order since in the case of VPN connections, the VPN's - * nameservers will be first in resolv.conf, and those need to be tried - * first by dnsmasq to successfully resolve names from the VPN. - */ - nm_cmd_line_add_string (cmd, "--strict-order"); - - s = g_string_new ("--listen-address="); - nm_utils_inet4_ntop (listen_address->address, localaddr); - g_string_append (s, localaddr); - nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); - - if (!nm_dnsmasq_utils_get_range (listen_address, first, last, &error_desc)) { - g_set_error_literal (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - error_desc); - _LOGW ("failed to find DHCP address ranges: %s", error_desc); - g_free (error_desc); - nm_cmd_line_destroy (cmd); - return NULL; - } - - s = g_string_new ("--dhcp-range="); - g_string_append_printf (s, "%s,%s,60m", first, last); - nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); - - if (!nm_ip4_config_get_never_default (ip4_config)) { - s = g_string_new ("--dhcp-option=option:router,"); - g_string_append (s, localaddr); - nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); - } - - nm_cmd_line_add_string (cmd, "--dhcp-lease-max=50"); - - s = g_string_new ("--pid-file="); - g_string_append (s, pidfile); - nm_cmd_line_add_string (cmd, s->str); - g_string_free (s, TRUE); - - /* dnsmasq exits if the conf dir is not present */ - if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR)) - nm_cmd_line_add_string (cmd, "--conf-dir=" CONFDIR); - - return cmd; -} - -static void -kill_existing_by_pidfile (const char *pidfile) -{ - char *contents = NULL; - pid_t pid; - char proc_path[250]; - char *cmdline_contents = NULL; - guint64 start_time; - const char *exe; - - if ( !pidfile - || !g_file_get_contents (pidfile, &contents, NULL, NULL)) - return; - - pid = _nm_utils_ascii_str_to_int64 (contents, 10, 1, G_MAXUINT64, 0); - if (pid == 0) - goto out; - - start_time = nm_utils_get_start_time_for_pid (pid, NULL, NULL); - if (start_time == 0) - goto out; - - nm_sprintf_buf (proc_path, "/proc/%lld/cmdline", (long long) pid); - if (!g_file_get_contents (proc_path, &cmdline_contents, NULL, NULL)) - goto out; - - exe = strrchr (cmdline_contents, '/'); - if ( (exe && strcmp (&exe[1], "dnsmasq") == 0) - || (strcmp (cmdline_contents, DNSMASQ_PATH) == 0)) { - nm_utils_kill_process_sync (pid, start_time, SIGKILL, LOGD_SHARING, - "dnsmasq", 0, 0, 500); - } - -out: - unlink (pidfile); - g_free (cmdline_contents); - g_free (contents); -} - -gboolean -nm_dnsmasq_manager_start (NMDnsMasqManager *manager, - NMIP4Config *ip4_config, - GError **error) -{ - NMDnsMasqManagerPrivate *priv; - NMCmdLine *dm_cmd; - gs_free char *cmd_str = NULL; - - g_return_val_if_fail (NM_IS_DNSMASQ_MANAGER (manager), FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - g_return_val_if_fail (nm_ip4_config_get_num_addresses (ip4_config) > 0, FALSE); - - priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); - - kill_existing_by_pidfile (priv->pidfile); - - dm_cmd = create_dm_cmd_line (priv->iface, ip4_config, priv->pidfile, error); - if (!dm_cmd) - return FALSE; - - g_ptr_array_add (dm_cmd->array, NULL); - - _LOGI ("starting dnsmasq..."); - _LOGD ("command line: %s", (cmd_str = nm_cmd_line_to_str (dm_cmd))); - - priv->pid = 0; - if (!g_spawn_async (NULL, (char **) dm_cmd->array->pdata, NULL, - G_SPAWN_DO_NOT_REAP_CHILD, - nm_utils_setpgid, NULL, - &priv->pid, error)) { - goto out; - } - - _LOGD ("dnsmasq started with pid %d", priv->pid); - - priv->dm_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) dm_watch_cb, manager); - - out: - if (dm_cmd) - nm_cmd_line_destroy (dm_cmd); - - return priv->pid > 0; -} - -void -nm_dnsmasq_manager_stop (NMDnsMasqManager *manager) -{ - NMDnsMasqManagerPrivate *priv; - - g_return_if_fail (NM_IS_DNSMASQ_MANAGER (manager)); - - priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); - - nm_clear_g_source (&priv->dm_watch_id); - - if (priv->pid) { - nm_utils_kill_child_async (priv->pid, SIGTERM, LOGD_SHARING, "dnsmasq", 2000, NULL, NULL); - priv->pid = 0; - } - - unlink (priv->pidfile); -} - -NMDnsMasqManager * -nm_dnsmasq_manager_new (const char *iface) -{ - NMDnsMasqManager *manager; - NMDnsMasqManagerPrivate *priv; - - manager = (NMDnsMasqManager *) g_object_new (NM_TYPE_DNSMASQ_MANAGER, NULL); - - priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); - priv->iface = g_strdup (iface); - priv->pidfile = g_strdup_printf (RUNSTATEDIR "/nm-dnsmasq-%s.pid", iface); - - return manager; -} - -static void -nm_dnsmasq_manager_init (NMDnsMasqManager *manager) -{ -} - -static void -finalize (GObject *object) -{ - NMDnsMasqManagerPrivate *priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (object); - - nm_dnsmasq_manager_stop (NM_DNSMASQ_MANAGER (object)); - - g_free (priv->iface); - g_free (priv->pidfile); - - G_OBJECT_CLASS (nm_dnsmasq_manager_parent_class)->finalize (object); -} - -static void -nm_dnsmasq_manager_class_init (NMDnsMasqManagerClass *manager_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (manager_class); - - g_type_class_add_private (manager_class, sizeof (NMDnsMasqManagerPrivate)); - - object_class->finalize = finalize; - - /* signals */ - signals[STATE_CHANGED] = - g_signal_new (NM_DNS_MASQ_MANAGER_STATE_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, 1, - G_TYPE_UINT); -} diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.h b/src/dnsmasq-manager/nm-dnsmasq-manager.h deleted file mode 100644 index b610b498..00000000 --- a/src/dnsmasq-manager/nm-dnsmasq-manager.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DNSMASQ_MANAGER_H__ -#define __NETWORKMANAGER_DNSMASQ_MANAGER_H__ - -#include "nm-ip4-config.h" - -#define NM_TYPE_DNSMASQ_MANAGER (nm_dnsmasq_manager_get_type ()) -#define NM_DNSMASQ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManager)) -#define NM_DNSMASQ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManagerClass)) -#define NM_IS_DNSMASQ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNSMASQ_MANAGER)) -#define NM_IS_DNSMASQ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNSMASQ_MANAGER)) -#define NM_DNSMASQ_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManagerClass)) - -/* signals */ -#define NM_DNS_MASQ_MANAGER_STATE_CHANGED "state-changed" - -typedef enum { - NM_DNSMASQ_STATUS_UNKNOWN, - - NM_DNSMASQ_STATUS_DEAD, - NM_DNSMASQ_STATUS_RUNNING, -} NMDnsMasqStatus; - -typedef struct { - GObject parent; -} NMDnsMasqManager; - -typedef struct { - GObjectClass parent; -} NMDnsMasqManagerClass; - -GType nm_dnsmasq_manager_get_type (void); - -NMDnsMasqManager *nm_dnsmasq_manager_new (const char *iface); - -gboolean nm_dnsmasq_manager_start (NMDnsMasqManager *manager, - NMIP4Config *ip4_config, - GError **error); - -void nm_dnsmasq_manager_stop (NMDnsMasqManager *manager); - -#endif /* __NETWORKMANAGER_DNSMASQ_MANAGER_H__ */ diff --git a/src/dnsmasq-manager/nm-dnsmasq-utils.c b/src/dnsmasq-manager/nm-dnsmasq-utils.c deleted file mode 100644 index 3786f37d..00000000 --- a/src/dnsmasq-manager/nm-dnsmasq-utils.c +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-dnsmasq-utils.h" -#include "nm-platform.h" -#include "nm-utils.h" - -gboolean -nm_dnsmasq_utils_get_range (const NMPlatformIP4Address *addr, - char *out_first, - char *out_last, - char **out_error_desc) -{ - guint32 host = addr->address; - guint8 prefix = addr->plen; - guint32 netmask = nm_utils_ip4_prefix_to_netmask (prefix); - guint32 first, last, reserved; - - g_return_val_if_fail (out_first != NULL, FALSE); - g_return_val_if_fail (out_last != NULL, FALSE); - - if (prefix > 30) { - if (out_error_desc) - *out_error_desc = g_strdup_printf ("Address prefix %d is too small for DHCP.", prefix); - return FALSE; - } - - /* Find the first available address *after* the local machine's IP */ - first = (host & netmask) + htonl (1); - - /* Shortcut: allow a max of 253 addresses; the - htonl(1) here is to assure - * that we don't set 'last' to the broadcast address of the network. */ - if (prefix < 24) - last = (host | ~nm_utils_ip4_prefix_to_netmask (24)) - htonl (1); - else - last = (host | ~netmask) - htonl(1); - - /* Figure out which range (either above the host address or below it) - * has more addresses. Reserve some addresses for static IPs. - */ - if (ntohl (host) - ntohl (first) > ntohl (last) - ntohl (host)) { - /* Range below the host's IP address */ - reserved = (guint32) ((ntohl (host) - ntohl (first)) / 10); - last = host - htonl (MIN (reserved, 8)) - htonl (1); - } else { - /* Range above host's IP address */ - reserved = (guint32) ((ntohl (last) - ntohl (host)) / 10); - first = host + htonl (MIN (reserved, 8)) + htonl (1); - } - - nm_utils_inet4_ntop (first, out_first); - nm_utils_inet4_ntop (last, out_last); - - return TRUE; -} - diff --git a/src/dnsmasq-manager/nm-dnsmasq-utils.h b/src/dnsmasq-manager/nm-dnsmasq-utils.h deleted file mode 100644 index 459dda04..00000000 --- a/src/dnsmasq-manager/nm-dnsmasq-utils.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_DNSMASQ_UTILS_H__ -#define __NETWORKMANAGER_DNSMASQ_UTILS_H__ - -#include "nm-platform.h" - -gboolean nm_dnsmasq_utils_get_range (const NMPlatformIP4Address *addr, - char *out_first, - char *out_last, - char **out_error_desc); - -#endif /* __NETWORKMANAGER_DNSMASQ_UTILS_H__ */ diff --git a/src/dnsmasq-manager/tests/Makefile.am b/src/dnsmasq-manager/tests/Makefile.am deleted file mode 100644 index 6d7a2a92..00000000 --- a/src/dnsmasq-manager/tests/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I${top_builddir}/shared \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I$(top_srcdir)/src/dnsmasq-manager \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/platform \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DTESTDIR="\"$(abs_srcdir)\"" - -noinst_PROGRAMS = test-dnsmasq-utils - -test_dnsmasq_utils_SOURCES = \ - test-dnsmasq-utils.c - -test_dnsmasq_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-dnsmasq-utils - diff --git a/src/dnsmasq-manager/tests/Makefile.in b/src/dnsmasq-manager/tests/Makefile.in deleted file mode 100644 index 8ba82f87..00000000 --- a/src/dnsmasq-manager/tests/Makefile.in +++ /dev/null @@ -1,1141 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-dnsmasq-utils$(EXEEXT) -TESTS = test-dnsmasq-utils$(EXEEXT) -subdir = src/dnsmasq-manager/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_dnsmasq_utils_OBJECTS = test-dnsmasq-utils.$(OBJEXT) -test_dnsmasq_utils_OBJECTS = $(am_test_dnsmasq_utils_OBJECTS) -test_dnsmasq_utils_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_dnsmasq_utils_SOURCES) -DIST_SOURCES = $(test_dnsmasq_utils_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I${top_builddir}/shared \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I$(top_srcdir)/src/dnsmasq-manager \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/platform \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DTESTDIR="\"$(abs_srcdir)\"" - -test_dnsmasq_utils_SOURCES = \ - test-dnsmasq-utils.c - -test_dnsmasq_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dnsmasq-manager/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/dnsmasq-manager/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-dnsmasq-utils$(EXEEXT): $(test_dnsmasq_utils_OBJECTS) $(test_dnsmasq_utils_DEPENDENCIES) $(EXTRA_test_dnsmasq_utils_DEPENDENCIES) - @rm -f test-dnsmasq-utils$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_dnsmasq_utils_OBJECTS) $(test_dnsmasq_utils_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dnsmasq-utils.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-dnsmasq-utils.log: test-dnsmasq-utils$(EXEEXT) - @p='test-dnsmasq-utils$(EXEEXT)'; \ - b='test-dnsmasq-utils'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/dnsmasq-manager/tests/test-dnsmasq-utils.c b/src/dnsmasq-manager/tests/test-dnsmasq-utils.c deleted file mode 100644 index cf6dab50..00000000 --- a/src/dnsmasq-manager/tests/test-dnsmasq-utils.c +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - * - */ - -#include "nm-default.h" - -#include - -#include "nm-dnsmasq-utils.h" - -#include "nm-test-utils-core.h" - -static void -test_address_ranges (void) -{ - NMPlatformIP4Address addr; - char first[INET_ADDRSTRLEN]; - char last[INET_ADDRSTRLEN]; - char *error_desc = NULL; - - addr = *nmtst_platform_ip4_address ("192.168.0.1", NULL, 24); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); - g_assert (error_desc == NULL); - g_assert_cmpstr (first, ==, "192.168.0.10"); - g_assert_cmpstr (last, ==, "192.168.0.254"); - - addr = *nmtst_platform_ip4_address ("192.168.0.99", NULL, 24); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); - g_assert (error_desc == NULL); - g_assert_cmpstr (first, ==, "192.168.0.108"); - g_assert_cmpstr (last, ==, "192.168.0.254"); - - addr = *nmtst_platform_ip4_address ("192.168.0.254", NULL, 24); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); - g_assert (error_desc == NULL); - g_assert_cmpstr (first, ==, "192.168.0.1"); - g_assert_cmpstr (last, ==, "192.168.0.245"); - - /* Smaller networks */ - addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 30); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); - g_assert (error_desc == NULL); - g_assert_cmpstr (first, ==, "1.2.3.2"); - g_assert_cmpstr (last, ==, "1.2.3.2"); - - addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 29); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); - g_assert (error_desc == NULL); - g_assert_cmpstr (first, ==, "1.2.3.2"); - g_assert_cmpstr (last, ==, "1.2.3.6"); - - addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 28); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); - g_assert (error_desc == NULL); - g_assert_cmpstr (first, ==, "1.2.3.3"); - g_assert_cmpstr (last, ==, "1.2.3.14"); - - addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 26); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); - g_assert (error_desc == NULL); - g_assert_cmpstr (first, ==, "1.2.3.8"); - g_assert_cmpstr (last, ==, "1.2.3.62"); - - addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 31); - g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc) == FALSE); - g_assert (error_desc); - g_free (error_desc); -} - -/*******************************************/ - -NMTST_DEFINE (); - -int -main (int argc, char **argv) -{ - nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); - - g_test_add_func ("/dnsmasq-manager/address-ranges", test_address_ranges); - - return g_test_run (); -} - diff --git a/src/dnsmasq/nm-dnsmasq-manager.c b/src/dnsmasq/nm-dnsmasq-manager.c new file mode 100644 index 00000000..9b24e69e --- /dev/null +++ b/src/dnsmasq/nm-dnsmasq-manager.c @@ -0,0 +1,395 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 - 2012 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-dnsmasq-manager.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "nm-dnsmasq-utils.h" +#include "nm-utils.h" +#include "NetworkManagerUtils.h" +#include "nm-core-internal.h" + +#define CONFDIR NMCONFDIR "/dnsmasq-shared.d" + +/*****************************************************************************/ + +enum { + STATE_CHANGED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct { + char *iface; + char *pidfile; + GPid pid; + guint dm_watch_id; +} NMDnsMasqManagerPrivate; + +struct _NMDnsMasqManager { + GObject parent; + NMDnsMasqManagerPrivate _priv; +}; + +struct _NMDnsMasqManagerClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMDnsMasqManager, nm_dnsmasq_manager, G_TYPE_OBJECT) + +#define NM_DNSMASQ_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDnsMasqManager, NM_IS_DNSMASQ_MANAGER) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SHARING +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "dnsmasq-manager", __VA_ARGS__) + +/*****************************************************************************/ + +typedef struct { + GPtrArray *array; + GStringChunk *chunk; +} NMCmdLine; + +static NMCmdLine * +nm_cmd_line_new (void) +{ + NMCmdLine *cmd; + + cmd = g_slice_new (NMCmdLine); + cmd->array = g_ptr_array_new (); + cmd->chunk = g_string_chunk_new (1024); + + return cmd; +} + +static void +nm_cmd_line_destroy (NMCmdLine *cmd) +{ + g_ptr_array_free (cmd->array, TRUE); + g_string_chunk_free (cmd->chunk); + g_slice_free (NMCmdLine, cmd); +} + +static char * +nm_cmd_line_to_str (NMCmdLine *cmd) +{ + char *str; + + g_ptr_array_add (cmd->array, NULL); + str = g_strjoinv (" ", (gchar **) cmd->array->pdata); + g_ptr_array_remove_index (cmd->array, cmd->array->len - 1); + + return str; +} + +static void +nm_cmd_line_add_string (NMCmdLine *cmd, const char *str) +{ + g_ptr_array_add (cmd->array, g_string_chunk_insert (cmd->chunk, str)); +} + +/*****************************************************************************/ + +static void +dm_watch_cb (GPid pid, gint status, gpointer user_data) +{ + NMDnsMasqManager *manager = NM_DNSMASQ_MANAGER (user_data); + NMDnsMasqManagerPrivate *priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); + guint err; + + if (WIFEXITED (status)) { + err = WEXITSTATUS (status); + if (err != 0) { + _LOGW ("dnsmasq exited with error: %s", + nm_utils_dnsmasq_status_to_string (err, NULL, 0)); + } + } else if (WIFSTOPPED (status)) { + _LOGW ("dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status)); + } else if (WIFSIGNALED (status)) { + _LOGW ("dnsmasq died with signal %d", WTERMSIG (status)); + } else { + _LOGW ("dnsmasq died from an unknown cause"); + } + + priv->pid = 0; + priv->dm_watch_id = 0; + + g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_DNSMASQ_STATUS_DEAD); +} + +static NMCmdLine * +create_dm_cmd_line (const char *iface, + const NMIP4Config *ip4_config, + const char *pidfile, + GError **error) +{ + NMCmdLine *cmd; + GString *s; + char first[INET_ADDRSTRLEN]; + char last[INET_ADDRSTRLEN]; + char localaddr[INET_ADDRSTRLEN]; + char *error_desc = NULL; + const char *dm_binary; + const NMPlatformIP4Address *listen_address; + + listen_address = nm_ip4_config_get_address (ip4_config, 0); + g_return_val_if_fail (listen_address, NULL); + + dm_binary = nm_utils_find_helper ("dnsmasq", DNSMASQ_PATH, error); + if (!dm_binary) + return NULL; + + /* Create dnsmasq command line */ + cmd = nm_cmd_line_new (); + nm_cmd_line_add_string (cmd, dm_binary); + + if (getenv ("NM_DNSMASQ_DEBUG")) { + nm_cmd_line_add_string (cmd, "--log-dhcp"); + nm_cmd_line_add_string (cmd, "--log-queries"); + } + + /* dnsmasq may read from it's default config file location, which if that + * location is a valid config file, it will combine with the options here + * and cause undesirable side-effects. Like sending bogus IP addresses + * as the gateway or whatever. So tell dnsmasq not to use any config file + * at all. + */ + nm_cmd_line_add_string (cmd, "--conf-file"); + + nm_cmd_line_add_string (cmd, "--no-hosts"); + nm_cmd_line_add_string (cmd, "--keep-in-foreground"); + nm_cmd_line_add_string (cmd, "--bind-interfaces"); + nm_cmd_line_add_string (cmd, "--except-interface=lo"); + nm_cmd_line_add_string (cmd, "--clear-on-reload"); + + /* Use strict order since in the case of VPN connections, the VPN's + * nameservers will be first in resolv.conf, and those need to be tried + * first by dnsmasq to successfully resolve names from the VPN. + */ + nm_cmd_line_add_string (cmd, "--strict-order"); + + s = g_string_new ("--listen-address="); + nm_utils_inet4_ntop (listen_address->address, localaddr); + g_string_append (s, localaddr); + nm_cmd_line_add_string (cmd, s->str); + g_string_free (s, TRUE); + + if (!nm_dnsmasq_utils_get_range (listen_address, first, last, &error_desc)) { + g_set_error_literal (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + error_desc); + _LOGW ("failed to find DHCP address ranges: %s", error_desc); + g_free (error_desc); + nm_cmd_line_destroy (cmd); + return NULL; + } + + s = g_string_new ("--dhcp-range="); + g_string_append_printf (s, "%s,%s,60m", first, last); + nm_cmd_line_add_string (cmd, s->str); + g_string_free (s, TRUE); + + if (!nm_ip4_config_get_never_default (ip4_config)) { + s = g_string_new ("--dhcp-option=option:router,"); + g_string_append (s, localaddr); + nm_cmd_line_add_string (cmd, s->str); + g_string_free (s, TRUE); + } + + nm_cmd_line_add_string (cmd, "--dhcp-lease-max=50"); + + s = g_string_new ("--pid-file="); + g_string_append (s, pidfile); + nm_cmd_line_add_string (cmd, s->str); + g_string_free (s, TRUE); + + /* dnsmasq exits if the conf dir is not present */ + if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR)) + nm_cmd_line_add_string (cmd, "--conf-dir=" CONFDIR); + + return cmd; +} + +static void +kill_existing_by_pidfile (const char *pidfile) +{ + char *contents = NULL; + pid_t pid; + char proc_path[250]; + char *cmdline_contents = NULL; + guint64 start_time; + const char *exe; + + if ( !pidfile + || !g_file_get_contents (pidfile, &contents, NULL, NULL)) + return; + + pid = _nm_utils_ascii_str_to_int64 (contents, 10, 1, G_MAXUINT64, 0); + if (pid == 0) + goto out; + + start_time = nm_utils_get_start_time_for_pid (pid, NULL, NULL); + if (start_time == 0) + goto out; + + nm_sprintf_buf (proc_path, "/proc/%lld/cmdline", (long long) pid); + if (!g_file_get_contents (proc_path, &cmdline_contents, NULL, NULL)) + goto out; + + exe = strrchr (cmdline_contents, '/'); + if ( (exe && strcmp (&exe[1], "dnsmasq") == 0) + || (strcmp (cmdline_contents, DNSMASQ_PATH) == 0)) { + nm_utils_kill_process_sync (pid, start_time, SIGKILL, LOGD_SHARING, + "dnsmasq", 0, 0, 500); + } + +out: + unlink (pidfile); + g_free (cmdline_contents); + g_free (contents); +} + +gboolean +nm_dnsmasq_manager_start (NMDnsMasqManager *manager, + NMIP4Config *ip4_config, + GError **error) +{ + NMDnsMasqManagerPrivate *priv; + NMCmdLine *dm_cmd; + gs_free char *cmd_str = NULL; + + g_return_val_if_fail (NM_IS_DNSMASQ_MANAGER (manager), FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + g_return_val_if_fail (nm_ip4_config_get_num_addresses (ip4_config) > 0, FALSE); + + priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); + + kill_existing_by_pidfile (priv->pidfile); + + dm_cmd = create_dm_cmd_line (priv->iface, ip4_config, priv->pidfile, error); + if (!dm_cmd) + return FALSE; + + g_ptr_array_add (dm_cmd->array, NULL); + + _LOGI ("starting dnsmasq..."); + _LOGD ("command line: %s", (cmd_str = nm_cmd_line_to_str (dm_cmd))); + + priv->pid = 0; + if (!g_spawn_async (NULL, (char **) dm_cmd->array->pdata, NULL, + G_SPAWN_DO_NOT_REAP_CHILD, + nm_utils_setpgid, NULL, + &priv->pid, error)) { + goto out; + } + + _LOGD ("dnsmasq started with pid %d", priv->pid); + + priv->dm_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) dm_watch_cb, manager); + + out: + if (dm_cmd) + nm_cmd_line_destroy (dm_cmd); + + return priv->pid > 0; +} + +void +nm_dnsmasq_manager_stop (NMDnsMasqManager *manager) +{ + NMDnsMasqManagerPrivate *priv; + + g_return_if_fail (NM_IS_DNSMASQ_MANAGER (manager)); + + priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); + + nm_clear_g_source (&priv->dm_watch_id); + + if (priv->pid) { + nm_utils_kill_child_async (priv->pid, SIGTERM, LOGD_SHARING, "dnsmasq", 2000, NULL, NULL); + priv->pid = 0; + } + + unlink (priv->pidfile); +} + +/*****************************************************************************/ + +static void +nm_dnsmasq_manager_init (NMDnsMasqManager *manager) +{ +} + +NMDnsMasqManager * +nm_dnsmasq_manager_new (const char *iface) +{ + NMDnsMasqManager *manager; + NMDnsMasqManagerPrivate *priv; + + manager = (NMDnsMasqManager *) g_object_new (NM_TYPE_DNSMASQ_MANAGER, NULL); + + priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager); + priv->iface = g_strdup (iface); + priv->pidfile = g_strdup_printf (RUNSTATEDIR "/nm-dnsmasq-%s.pid", iface); + + return manager; +} + +static void +finalize (GObject *object) +{ + NMDnsMasqManagerPrivate *priv = NM_DNSMASQ_MANAGER_GET_PRIVATE ((NMDnsMasqManager *) object); + + nm_dnsmasq_manager_stop (NM_DNSMASQ_MANAGER (object)); + + g_free (priv->iface); + g_free (priv->pidfile); + + G_OBJECT_CLASS (nm_dnsmasq_manager_parent_class)->finalize (object); +} + +static void +nm_dnsmasq_manager_class_init (NMDnsMasqManagerClass *manager_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (manager_class); + + object_class->finalize = finalize; + + signals[STATE_CHANGED] = + g_signal_new (NM_DNS_MASQ_MANAGER_STATE_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, + G_TYPE_UINT); +} diff --git a/src/dnsmasq/nm-dnsmasq-manager.h b/src/dnsmasq/nm-dnsmasq-manager.h new file mode 100644 index 00000000..a0ad295c --- /dev/null +++ b/src/dnsmasq/nm-dnsmasq-manager.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DNSMASQ_MANAGER_H__ +#define __NETWORKMANAGER_DNSMASQ_MANAGER_H__ + +#include "nm-ip4-config.h" + +#define NM_TYPE_DNSMASQ_MANAGER (nm_dnsmasq_manager_get_type ()) +#define NM_DNSMASQ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManager)) +#define NM_DNSMASQ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManagerClass)) +#define NM_IS_DNSMASQ_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNSMASQ_MANAGER)) +#define NM_IS_DNSMASQ_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNSMASQ_MANAGER)) +#define NM_DNSMASQ_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNSMASQ_MANAGER, NMDnsMasqManagerClass)) + +/* signals */ +#define NM_DNS_MASQ_MANAGER_STATE_CHANGED "state-changed" + +typedef enum { + NM_DNSMASQ_STATUS_UNKNOWN, + NM_DNSMASQ_STATUS_DEAD, + NM_DNSMASQ_STATUS_RUNNING, +} NMDnsMasqStatus; + +typedef struct _NMDnsMasqManager NMDnsMasqManager; +typedef struct _NMDnsMasqManagerClass NMDnsMasqManagerClass; + +GType nm_dnsmasq_manager_get_type (void); + +NMDnsMasqManager *nm_dnsmasq_manager_new (const char *iface); + +gboolean nm_dnsmasq_manager_start (NMDnsMasqManager *manager, + NMIP4Config *ip4_config, + GError **error); + +void nm_dnsmasq_manager_stop (NMDnsMasqManager *manager); + +#endif /* __NETWORKMANAGER_DNSMASQ_MANAGER_H__ */ diff --git a/src/dnsmasq/nm-dnsmasq-utils.c b/src/dnsmasq/nm-dnsmasq-utils.c new file mode 100644 index 00000000..e4f4324b --- /dev/null +++ b/src/dnsmasq/nm-dnsmasq-utils.c @@ -0,0 +1,78 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include +#include + +#include "nm-dnsmasq-utils.h" +#include "platform/nm-platform.h" +#include "nm-utils.h" + +gboolean +nm_dnsmasq_utils_get_range (const NMPlatformIP4Address *addr, + char *out_first, + char *out_last, + char **out_error_desc) +{ + guint32 host = addr->address; + guint8 prefix = addr->plen; + guint32 netmask = nm_utils_ip4_prefix_to_netmask (prefix); + guint32 first, last, reserved; + + g_return_val_if_fail (out_first != NULL, FALSE); + g_return_val_if_fail (out_last != NULL, FALSE); + + if (prefix > 30) { + if (out_error_desc) + *out_error_desc = g_strdup_printf ("Address prefix %d is too small for DHCP.", prefix); + return FALSE; + } + + /* Find the first available address *after* the local machine's IP */ + first = (host & netmask) + htonl (1); + + /* Shortcut: allow a max of 253 addresses; the - htonl(1) here is to assure + * that we don't set 'last' to the broadcast address of the network. */ + if (prefix < 24) + last = (host | ~nm_utils_ip4_prefix_to_netmask (24)) - htonl (1); + else + last = (host | ~netmask) - htonl(1); + + /* Figure out which range (either above the host address or below it) + * has more addresses. Reserve some addresses for static IPs. + */ + if (ntohl (host) - ntohl (first) > ntohl (last) - ntohl (host)) { + /* Range below the host's IP address */ + reserved = (guint32) ((ntohl (host) - ntohl (first)) / 10); + last = host - htonl (MIN (reserved, 8)) - htonl (1); + } else { + /* Range above host's IP address */ + reserved = (guint32) ((ntohl (last) - ntohl (host)) / 10); + first = host + htonl (MIN (reserved, 8)) + htonl (1); + } + + nm_utils_inet4_ntop (first, out_first); + nm_utils_inet4_ntop (last, out_last); + + return TRUE; +} + diff --git a/src/dnsmasq/nm-dnsmasq-utils.h b/src/dnsmasq/nm-dnsmasq-utils.h new file mode 100644 index 00000000..54b90309 --- /dev/null +++ b/src/dnsmasq/nm-dnsmasq-utils.h @@ -0,0 +1,31 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_DNSMASQ_UTILS_H__ +#define __NETWORKMANAGER_DNSMASQ_UTILS_H__ + +#include "platform/nm-platform.h" + +gboolean nm_dnsmasq_utils_get_range (const NMPlatformIP4Address *addr, + char *out_first, + char *out_last, + char **out_error_desc); + +#endif /* __NETWORKMANAGER_DNSMASQ_UTILS_H__ */ diff --git a/src/dnsmasq/tests/test-dnsmasq-utils.c b/src/dnsmasq/tests/test-dnsmasq-utils.c new file mode 100644 index 00000000..00ff6610 --- /dev/null +++ b/src/dnsmasq/tests/test-dnsmasq-utils.c @@ -0,0 +1,99 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + * + */ + +#include "nm-default.h" + +#include + +#include "dnsmasq/nm-dnsmasq-utils.h" + +#include "nm-test-utils-core.h" + +static void +test_address_ranges (void) +{ + NMPlatformIP4Address addr; + char first[INET_ADDRSTRLEN]; + char last[INET_ADDRSTRLEN]; + char *error_desc = NULL; + + addr = *nmtst_platform_ip4_address ("192.168.0.1", NULL, 24); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); + g_assert (error_desc == NULL); + g_assert_cmpstr (first, ==, "192.168.0.10"); + g_assert_cmpstr (last, ==, "192.168.0.254"); + + addr = *nmtst_platform_ip4_address ("192.168.0.99", NULL, 24); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); + g_assert (error_desc == NULL); + g_assert_cmpstr (first, ==, "192.168.0.108"); + g_assert_cmpstr (last, ==, "192.168.0.254"); + + addr = *nmtst_platform_ip4_address ("192.168.0.254", NULL, 24); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); + g_assert (error_desc == NULL); + g_assert_cmpstr (first, ==, "192.168.0.1"); + g_assert_cmpstr (last, ==, "192.168.0.245"); + + /* Smaller networks */ + addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 30); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); + g_assert (error_desc == NULL); + g_assert_cmpstr (first, ==, "1.2.3.2"); + g_assert_cmpstr (last, ==, "1.2.3.2"); + + addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 29); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); + g_assert (error_desc == NULL); + g_assert_cmpstr (first, ==, "1.2.3.2"); + g_assert_cmpstr (last, ==, "1.2.3.6"); + + addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 28); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); + g_assert (error_desc == NULL); + g_assert_cmpstr (first, ==, "1.2.3.3"); + g_assert_cmpstr (last, ==, "1.2.3.14"); + + addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 26); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc)); + g_assert (error_desc == NULL); + g_assert_cmpstr (first, ==, "1.2.3.8"); + g_assert_cmpstr (last, ==, "1.2.3.62"); + + addr = *nmtst_platform_ip4_address ("1.2.3.1", NULL, 31); + g_assert (nm_dnsmasq_utils_get_range (&addr, first, last, &error_desc) == FALSE); + g_assert (error_desc); + g_free (error_desc); +} + +/*****************************************************************************/ + +NMTST_DEFINE (); + +int +main (int argc, char **argv) +{ + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); + + g_test_add_func ("/dnsmasq/address-ranges", test_address_ranges); + + return g_test_run (); +} + diff --git a/src/main-utils.c b/src/main-utils.c index 6497ea25..9e3aa7bd 100644 --- a/src/main-utils.c +++ b/src/main-utils.c @@ -34,6 +34,7 @@ #include "main-utils.h" #include "NetworkManagerUtils.h" +#include "nm-config.h" static gboolean sighup_handler (gpointer user_data) @@ -139,11 +140,23 @@ nm_main_utils_ensure_statedir () void nm_main_utils_ensure_rundir () { + int errsv; + /* Setup runtime directory */ if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) { - fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, strerror (errno)); + errsv = errno; + fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, g_strerror (errsv)); exit (1); } + + nm_assert (g_str_has_prefix (NM_CONFIG_DEVICE_STATE_DIR, NMRUNDIR"/")); + if (g_mkdir (NM_CONFIG_DEVICE_STATE_DIR, 0755) != 0) { + errsv = errno; + if (errsv != EEXIST) { + fprintf (stderr, _("Cannot create '%s': %s"), NM_CONFIG_DEVICE_STATE_DIR, g_strerror (errsv)); + exit (1); + } + } } /** diff --git a/src/main.c b/src/main.c index 490dcfe9..20e6f30f 100644 --- a/src/main.c +++ b/src/main.c @@ -38,18 +38,18 @@ #include "nm-dbus-interface.h" #include "NetworkManagerUtils.h" #include "nm-manager.h" -#include "nm-linux-platform.h" +#include "platform/nm-linux-platform.h" #include "nm-bus-manager.h" -#include "nm-device.h" -#include "nm-dhcp-manager.h" +#include "devices/nm-device.h" +#include "dhcp/nm-dhcp-manager.h" #include "nm-config.h" #include "nm-session-monitor.h" #include "nm-dispatcher.h" -#include "nm-settings.h" +#include "settings/nm-settings.h" #include "nm-auth-manager.h" #include "nm-core-internal.h" #include "nm-exported-object.h" -#include "nm-sd.h" +#include "systemd/nm-sd.h" #if !defined(NM_DIST_VERSION) # define NM_DIST_VERSION VERSION @@ -85,8 +85,9 @@ _set_g_fatal_warnings (void) } static void -_init_nm_debug (const char *debug) +_init_nm_debug (NMConfig *config) { + gs_free char *debug = NULL; const guint D_RLIMIT_CORE = 1; const guint D_FATAL_WARNINGS = 2; GDebugKey keys[] = { @@ -96,6 +97,11 @@ _init_nm_debug (const char *debug) guint flags; const char *env = getenv ("NM_DEBUG"); + debug = nm_config_data_get_value (nm_config_get_data_orig (config), + NM_CONFIG_KEYFILE_GROUP_MAIN, + NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG, + NM_MANAGER_RELOAD_FLAGS_NONE); + flags = nm_utils_parse_debug_string (env, keys, G_N_ELEMENTS (keys)); flags |= nm_utils_parse_debug_string (debug, keys, G_N_ELEMENTS (keys)); @@ -272,7 +278,7 @@ main (int argc, char *argv[]) /* don't free these strings, we need them for the entire * process lifetime */ - nm_dhcp_helper_path = g_strdup_printf ("%s/src/dhcp-manager/nm-dhcp-helper", path); + nm_dhcp_helper_path = g_strdup_printf ("%s/src/dhcp/nm-dhcp-helper", path); g_free (path); } @@ -302,7 +308,7 @@ main (int argc, char *argv[]) exit (1); } - _init_nm_debug (nm_config_get_debug (config)); + _init_nm_debug (config); /* Initialize logging from config file *only* if not explicitly * specified by commandline. @@ -362,7 +368,10 @@ main (int argc, char *argv[]) #endif ); - nm_auth_manager_setup (nm_config_get_auth_polkit (config)); + nm_auth_manager_setup (nm_config_data_get_value_boolean (nm_config_get_data_orig (config), + NM_CONFIG_KEYFILE_GROUP_MAIN, + NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT, + NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL)); nm_manager_setup (); @@ -412,6 +421,13 @@ main (int argc, char *argv[]) } done: + + /* write the device-state to file. Note that we only persist the + * state here. We don't bother updating the state as devices + * change during regular operation. If NM is killed with SIGKILL, + * it misses to update the state. */ + nm_manager_write_device_state (nm_manager_get ()); + nm_exported_object_class_set_quitting (); nm_manager_stop (nm_manager_get ()); diff --git a/src/ndisc/nm-fake-ndisc.c b/src/ndisc/nm-fake-ndisc.c new file mode 100644 index 00000000..7a9fb110 --- /dev/null +++ b/src/ndisc/nm-fake-ndisc.c @@ -0,0 +1,412 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-fake-ndisc.c - Fake implementation of neighbor discovery + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-fake-ndisc.h" + +#include +#include + +#include "nm-ndisc-private.h" + +#define _NMLOG_PREFIX_NAME "ndisc-fake" + +/*****************************************************************************/ + +typedef struct { + guint id; + guint when; + + NMNDiscDHCPLevel dhcp_level; + GArray *gateways; + GArray *prefixes; + GArray *dns_servers; + GArray *dns_domains; + int hop_limit; + guint32 mtu; +} FakeRa; + +typedef struct { + struct in6_addr network; + int plen; + struct in6_addr gateway; + guint32 timestamp; + guint32 lifetime; + guint32 preferred; + NMNDiscPreference preference; +} FakePrefix; + +/*****************************************************************************/ + +enum { + RS_SENT, + LAST_SIGNAL, +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct { + guint receive_ra_id; + GSList *ras; +} NMFakeNDiscPrivate; + +struct _NMFakeRNDisc { + NMNDisc parent; + NMFakeNDiscPrivate _priv; +}; + +struct _NMFakeRNDiscClass { + NMNDiscClass parent; +}; + +G_DEFINE_TYPE (NMFakeNDisc, nm_fake_ndisc, NM_TYPE_NDISC) + +#define NM_FAKE_NDISC_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMFakeNDisc, NM_IS_FAKE_NDISC) + +/*****************************************************************************/ + +static void +fake_ra_free (gpointer data) +{ + FakeRa *ra = data; + + g_array_free (ra->gateways, TRUE); + g_array_free (ra->prefixes, TRUE); + g_array_free (ra->dns_servers, TRUE); + g_array_free (ra->dns_domains, TRUE); + g_free (ra); +} + +static void +ra_dns_domain_free (gpointer data) +{ + g_free (((NMNDiscDNSDomain *)(data))->domain); +} + +static FakeRa * +find_ra (GSList *ras, guint id) +{ + GSList *iter; + + for (iter = ras; iter; iter = iter->next) { + if (((FakeRa *) iter->data)->id == id) + return iter->data; + } + return NULL; +} + +guint +nm_fake_ndisc_add_ra (NMFakeNDisc *self, + guint seconds_after_previous, + NMNDiscDHCPLevel dhcp_level, + int hop_limit, + guint32 mtu) +{ + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE (self); + static guint counter = 1; + FakeRa *ra; + + ra = g_malloc0 (sizeof (*ra)); + ra->id = counter++; + ra->when = seconds_after_previous; + ra->dhcp_level = dhcp_level; + ra->hop_limit = hop_limit; + ra->mtu = mtu; + ra->gateways = g_array_new (FALSE, FALSE, sizeof (NMNDiscGateway)); + ra->prefixes = g_array_new (FALSE, FALSE, sizeof (FakePrefix)); + ra->dns_servers = g_array_new (FALSE, FALSE, sizeof (NMNDiscDNSServer)); + ra->dns_domains = g_array_new (FALSE, FALSE, sizeof (NMNDiscDNSDomain)); + g_array_set_clear_func (ra->dns_domains, ra_dns_domain_free); + + priv->ras = g_slist_append (priv->ras, ra); + return ra->id; +} + +void +nm_fake_ndisc_add_gateway (NMFakeNDisc *self, + guint ra_id, + const char *addr, + guint32 timestamp, + guint32 lifetime, + NMNDiscPreference preference) +{ + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE (self); + FakeRa *ra = find_ra (priv->ras, ra_id); + NMNDiscGateway *gw; + + g_assert (ra); + g_array_set_size (ra->gateways, ra->gateways->len + 1); + gw = &g_array_index (ra->gateways, NMNDiscGateway, ra->gateways->len - 1); + g_assert (inet_pton (AF_INET6, addr, &gw->address) == 1); + gw->timestamp = timestamp; + gw->lifetime = lifetime; + gw->preference = preference; +} + +void +nm_fake_ndisc_add_prefix (NMFakeNDisc *self, + guint ra_id, + const char *network, + guint plen, + const char *gateway, + guint32 timestamp, + guint32 lifetime, + guint32 preferred, + NMNDiscPreference preference) +{ + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE (self); + FakeRa *ra = find_ra (priv->ras, ra_id); + FakePrefix *prefix; + + g_assert (ra); + g_array_set_size (ra->prefixes, ra->prefixes->len + 1); + prefix = &g_array_index (ra->prefixes, FakePrefix, ra->prefixes->len - 1); + memset (prefix, 0, sizeof (*prefix)); + g_assert (inet_pton (AF_INET6, network, &prefix->network) == 1); + g_assert (inet_pton (AF_INET6, gateway, &prefix->gateway) == 1); + prefix->plen = plen; + prefix->timestamp = timestamp; + prefix->lifetime = lifetime; + prefix->preferred = preferred; + prefix->preference = preference; +} + +void +nm_fake_ndisc_add_dns_server (NMFakeNDisc *self, + guint ra_id, + const char *address, + guint32 timestamp, + guint32 lifetime) +{ + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE (self); + FakeRa *ra = find_ra (priv->ras, ra_id); + NMNDiscDNSServer *dns; + + g_assert (ra); + g_array_set_size (ra->dns_servers, ra->dns_servers->len + 1); + dns = &g_array_index (ra->dns_servers, NMNDiscDNSServer, ra->dns_servers->len - 1); + g_assert (inet_pton (AF_INET6, address, &dns->address) == 1); + dns->timestamp = timestamp; + dns->lifetime = lifetime; +} + +void +nm_fake_ndisc_add_dns_domain (NMFakeNDisc *self, + guint ra_id, + const char *domain, + guint32 timestamp, + guint32 lifetime) +{ + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE (self); + FakeRa *ra = find_ra (priv->ras, ra_id); + NMNDiscDNSDomain *dns; + + g_assert (ra); + g_array_set_size (ra->dns_domains, ra->dns_domains->len + 1); + dns = &g_array_index (ra->dns_domains, NMNDiscDNSDomain, ra->dns_domains->len - 1); + dns->domain = g_strdup (domain); + dns->timestamp = timestamp; + dns->lifetime = lifetime; +} + +gboolean +nm_fake_ndisc_done (NMFakeNDisc *self) +{ + return !NM_FAKE_NDISC_GET_PRIVATE (self)->ras; +} + +/*****************************************************************************/ + +static gboolean +send_rs (NMNDisc *ndisc, GError **error) +{ + g_signal_emit (ndisc, signals[RS_SENT], 0); + return TRUE; +} + +static gboolean +receive_ra (gpointer user_data) +{ + NMFakeNDisc *self = user_data; + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE (self); + NMNDisc *ndisc = NM_NDISC (self); + NMNDiscDataInternal *rdata = ndisc->rdata; + FakeRa *ra = priv->ras->data; + NMNDiscConfigMap changed = 0; + guint32 now = nm_utils_get_monotonic_timestamp_s (); + guint i; + NMNDiscDHCPLevel dhcp_level; + + priv->receive_ra_id = 0; + + /* preserve the "most managed" level on updates. */ + dhcp_level = MAX (rdata->public.dhcp_level, ra->dhcp_level); + + if (rdata->public.dhcp_level != dhcp_level) { + rdata->public.dhcp_level = dhcp_level; + changed |= NM_NDISC_CONFIG_DHCP_LEVEL; + } + + for (i = 0; i < ra->gateways->len; i++) { + NMNDiscGateway *item = &g_array_index (ra->gateways, NMNDiscGateway, i); + + if (nm_ndisc_add_gateway (ndisc, item)) + changed |= NM_NDISC_CONFIG_GATEWAYS; + } + + for (i = 0; i < ra->prefixes->len; i++) { + FakePrefix *item = &g_array_index (ra->prefixes, FakePrefix, i); + NMNDiscRoute route = { + .network = item->network, + .plen = item->plen, + .gateway = item->gateway, + .timestamp = item->timestamp, + .lifetime = item->lifetime, + .preference = item->preference, + }; + + g_assert (route.plen > 0 && route.plen <= 128); + + if (nm_ndisc_add_route (ndisc, &route)) + changed |= NM_NDISC_CONFIG_ROUTES; + + if (item->plen == 64) { + NMNDiscAddress address = { + .address = item->network, + .timestamp = item->timestamp, + .lifetime = item->lifetime, + .preferred = item->preferred, + .dad_counter = 0, + }; + + if (nm_ndisc_complete_and_add_address (ndisc, &address)) + changed |= NM_NDISC_CONFIG_ADDRESSES; + } + } + + for (i = 0; i < ra->dns_servers->len; i++) { + NMNDiscDNSServer *item = &g_array_index (ra->dns_servers, NMNDiscDNSServer, i); + + if (nm_ndisc_add_dns_server (ndisc, item)) + changed |= NM_NDISC_CONFIG_DNS_SERVERS; + } + + for (i = 0; i < ra->dns_domains->len; i++) { + NMNDiscDNSDomain *item = &g_array_index (ra->dns_domains, NMNDiscDNSDomain, i); + + if (nm_ndisc_add_dns_domain (ndisc, item)) + changed |= NM_NDISC_CONFIG_DNS_DOMAINS; + } + + if (rdata->public.mtu != ra->mtu) { + rdata->public.mtu = ra->mtu; + changed |= NM_NDISC_CONFIG_MTU; + } + + if (rdata->public.hop_limit != ra->hop_limit) { + rdata->public.hop_limit = ra->hop_limit; + changed |= NM_NDISC_CONFIG_HOP_LIMIT; + } + + priv->ras = g_slist_remove (priv->ras, priv->ras->data); + fake_ra_free (ra); + + nm_ndisc_ra_received (NM_NDISC (self), now, changed); + + /* Schedule next RA */ + if (priv->ras) { + ra = priv->ras->data; + priv->receive_ra_id = g_timeout_add_seconds (ra->when, receive_ra, self); + } + + return G_SOURCE_REMOVE; +} + +static void +start (NMNDisc *ndisc) +{ + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE ((NMFakeNDisc *) ndisc); + FakeRa *ra; + + /* Queue up the first fake RA */ + g_assert (priv->ras); + ra = priv->ras->data; + + g_assert (!priv->receive_ra_id); + priv->receive_ra_id = g_timeout_add_seconds (ra->when, receive_ra, ndisc); +} + +void +nm_fake_ndisc_emit_new_ras (NMFakeNDisc *self) +{ + if (!NM_FAKE_NDISC_GET_PRIVATE (self)->receive_ra_id) + start (NM_NDISC (self)); +} + +/*****************************************************************************/ + +static void +nm_fake_ndisc_init (NMFakeNDisc *fake_ndisc) +{ +} + +NMNDisc * +nm_fake_ndisc_new (int ifindex, const char *ifname) +{ + return g_object_new (NM_TYPE_FAKE_NDISC, + NM_NDISC_IFINDEX, ifindex, + NM_NDISC_IFNAME, ifname, + NM_NDISC_NODE_TYPE, (int) NM_NDISC_NODE_TYPE_HOST, + NM_NDISC_STABLE_TYPE, (int) NM_UTILS_STABLE_TYPE_UUID, + NM_NDISC_NETWORK_ID, "fake", + NULL); +} + +static void +dispose (GObject *object) +{ + NMFakeNDiscPrivate *priv = NM_FAKE_NDISC_GET_PRIVATE ((NMFakeNDisc *) object); + + nm_clear_g_source (&priv->receive_ra_id); + + g_slist_free_full (priv->ras, fake_ra_free); + priv->ras = NULL; + + G_OBJECT_CLASS (nm_fake_ndisc_parent_class)->dispose (object); +} + +static void +nm_fake_ndisc_class_init (NMFakeNDiscClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMNDiscClass *ndisc_class = NM_NDISC_CLASS (klass); + + object_class->dispose = dispose; + + ndisc_class->start = start; + ndisc_class->send_rs = send_rs; + + signals[RS_SENT] = + g_signal_new (NM_FAKE_NDISC_RS_SENT, + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); +} diff --git a/src/ndisc/nm-fake-ndisc.h b/src/ndisc/nm-fake-ndisc.h new file mode 100644 index 00000000..2544c456 --- /dev/null +++ b/src/ndisc/nm-fake-ndisc.h @@ -0,0 +1,81 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-fake-ndisc.h - Fake implementation of neighbor discovery + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_FAKE_NDISC_H__ +#define __NETWORKMANAGER_FAKE_NDISC_H__ + +#include "nm-ndisc.h" + +#define NM_TYPE_FAKE_NDISC (nm_fake_ndisc_get_type ()) +#define NM_FAKE_NDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_FAKE_NDISC, NMFakeNDisc)) +#define NM_FAKE_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_FAKE_NDISC, NMFakeNDiscClass)) +#define NM_IS_FAKE_NDISC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_FAKE_NDISC)) +#define NM_IS_FAKE_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_FAKE_NDISC)) +#define NM_FAKE_NDISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_FAKE_NDISC, NMFakeNDiscClass)) + +#define NM_FAKE_NDISC_RS_SENT "rs-sent" + +typedef struct _NMFakeRNDisc NMFakeNDisc; +typedef struct _NMFakeRNDiscClass NMFakeNDiscClass; + +GType nm_fake_ndisc_get_type (void); + +NMNDisc *nm_fake_ndisc_new (int ifindex, const char *ifname); + +guint nm_fake_ndisc_add_ra (NMFakeNDisc *self, + guint seconds, + NMNDiscDHCPLevel dhcp_level, + int hop_limit, + guint32 mtu); + +void nm_fake_ndisc_add_gateway (NMFakeNDisc *self, + guint ra_id, + const char *addr, + guint32 timestamp, + guint32 lifetime, + NMNDiscPreference preference); + +void nm_fake_ndisc_add_prefix (NMFakeNDisc *self, + guint ra_id, + const char *network, + guint plen, + const char *gateway, + guint32 timestamp, + guint32 lifetime, + guint32 preferred, + NMNDiscPreference preference); + +void nm_fake_ndisc_add_dns_server (NMFakeNDisc *self, + guint ra_id, + const char *address, + guint32 timestamp, + guint32 lifetime); + +void nm_fake_ndisc_add_dns_domain (NMFakeNDisc *self, + guint ra_id, + const char *domain, + guint32 timestamp, + guint32 lifetime); + +void nm_fake_ndisc_emit_new_ras (NMFakeNDisc *self); + +gboolean nm_fake_ndisc_done (NMFakeNDisc *self); + +#endif /* __NETWORKMANAGER_FAKE_NDISC_H__ */ diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c new file mode 100644 index 00000000..3bc1590e --- /dev/null +++ b/src/ndisc/nm-lndp-ndisc.c @@ -0,0 +1,629 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-lndp-ndisc.c - Router discovery implementation using libndp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-lndp-ndisc.h" + +#include +#include +#include +/* stdarg.h included because of a bug in ndp.h */ +#include +#include + +#include "nm-ndisc-private.h" +#include "NetworkManagerUtils.h" +#include "platform/nm-platform.h" +#include "platform/nmp-netns.h" + +#define _NMLOG_PREFIX_NAME "ndisc-lndp" + +/*****************************************************************************/ + +typedef struct { + struct ndp *ndp; + + GIOChannel *event_channel; + guint event_id; +} NMLndpNDiscPrivate; + +/*****************************************************************************/ + +struct _NMLndpNDisc { + NMNDisc parent; + NMLndpNDiscPrivate _priv; +}; + +struct _NMLndpNDiscClass { + NMNDiscClass parent; +}; + +/*****************************************************************************/ + +G_DEFINE_TYPE (NMLndpNDisc, nm_lndp_ndisc, NM_TYPE_NDISC) + +#define NM_LNDP_NDISC_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMLndpNDisc, NM_IS_LNDP_NDISC) + +/*****************************************************************************/ + +static gboolean +send_rs (NMNDisc *ndisc, GError **error) +{ + NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE ((NMLndpNDisc *) ndisc); + struct ndp_msg *msg; + int errsv; + + errsv = ndp_msg_new (&msg, NDP_MSG_RS); + if (errsv) { + errsv = errsv > 0 ? errsv : -errsv; + g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "cannot create router solicitation"); + return FALSE; + } + ndp_msg_ifindex_set (msg, nm_ndisc_get_ifindex (ndisc)); + + errsv = ndp_msg_send (priv->ndp, msg); + ndp_msg_destroy (msg); + if (errsv) { + errsv = errsv > 0 ? errsv : -errsv; + g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "%s (%d)", + g_strerror (errsv), errsv); + return FALSE; + } + + return TRUE; +} + +_NM_UTILS_LOOKUP_DEFINE (static, translate_preference, enum ndp_route_preference, NMNDiscPreference, + NM_UTILS_LOOKUP_DEFAULT (NM_NDISC_PREFERENCE_INVALID), + NM_UTILS_LOOKUP_ITEM (NDP_ROUTE_PREF_LOW, NM_NDISC_PREFERENCE_LOW), + NM_UTILS_LOOKUP_ITEM (NDP_ROUTE_PREF_MEDIUM, NM_NDISC_PREFERENCE_MEDIUM), + NM_UTILS_LOOKUP_ITEM (NDP_ROUTE_PREF_HIGH, NM_NDISC_PREFERENCE_HIGH), +); + +static int +receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data) +{ + NMNDisc *ndisc = (NMNDisc *) user_data; + NMNDiscDataInternal *rdata = ndisc->rdata; + NMNDiscConfigMap changed = 0; + struct ndp_msgra *msgra = ndp_msgra (msg); + struct in6_addr gateway_addr; + guint32 now = nm_utils_get_monotonic_timestamp_s (); + int offset; + int hop_limit; + + /* Router discovery is subject to the following RFC documents: + * + * http://tools.ietf.org/html/rfc4861 + * http://tools.ietf.org/html/rfc4862 + * + * The biggest difference from good old DHCP is that all configuration + * items have their own lifetimes and they are merged from various + * sources. Router discovery is *not* contract-based, so there is *no* + * single time when the configuration is finished and updates can + * come at any time. + */ + _LOGD ("received router advertisement at %u", now); + + /* DHCP level: + * + * The problem with DHCP level is what to do if subsequent + * router advertisements carry different flags. Currently we just + * rewrite the flag with every inbound RA. + */ + { + NMNDiscDHCPLevel dhcp_level; + + if (ndp_msgra_flag_managed (msgra)) + dhcp_level = NM_NDISC_DHCP_LEVEL_MANAGED; + else if (ndp_msgra_flag_other (msgra)) + dhcp_level = NM_NDISC_DHCP_LEVEL_OTHERCONF; + else + dhcp_level = NM_NDISC_DHCP_LEVEL_NONE; + + /* when receiving multiple RA (possibly from different routers), + * let's keep the "most managed" level. */ + G_STATIC_ASSERT_EXPR (NM_NDISC_DHCP_LEVEL_MANAGED > NM_NDISC_DHCP_LEVEL_OTHERCONF); + G_STATIC_ASSERT_EXPR (NM_NDISC_DHCP_LEVEL_OTHERCONF > NM_NDISC_DHCP_LEVEL_NONE); + dhcp_level = MAX (dhcp_level, rdata->public.dhcp_level); + + if (dhcp_level != rdata->public.dhcp_level) { + rdata->public.dhcp_level = dhcp_level; + changed |= NM_NDISC_CONFIG_DHCP_LEVEL; + } + } + + /* Default gateway: + * + * Subsequent router advertisements can represent new default gateways + * on the network. We should present all of them in router preference + * order. + */ + gateway_addr = *ndp_msg_addrto (msg); + { + NMNDiscGateway gateway = { + .address = gateway_addr, + .timestamp = now, + .lifetime = ndp_msgra_router_lifetime (msgra), + .preference = translate_preference (ndp_msgra_route_preference (msgra)), + }; + + if (nm_ndisc_add_gateway (ndisc, &gateway)) + changed |= NM_NDISC_CONFIG_GATEWAYS; + } + + /* Addresses & Routes */ + ndp_msg_opt_for_each_offset (offset, msg, NDP_MSG_OPT_PREFIX) { + guint8 r_plen; + struct in6_addr r_network; + + /* Device route */ + + r_plen = ndp_msg_opt_prefix_len (msg, offset); + if (r_plen == 0 || r_plen > 128) + continue; + nm_utils_ip6_address_clear_host_address (&r_network, ndp_msg_opt_prefix (msg, offset), r_plen); + + if (ndp_msg_opt_prefix_flag_on_link (msg, offset)) { + NMNDiscRoute route = { + .network = r_network, + .plen = r_plen, + .timestamp = now, + .lifetime = ndp_msg_opt_prefix_valid_time (msg, offset), + }; + + if (nm_ndisc_add_route (ndisc, &route)) + changed |= NM_NDISC_CONFIG_ROUTES; + } + + /* Address */ + if ( r_plen == 64 + && ndp_msg_opt_prefix_flag_auto_addr_conf (msg, offset)) { + NMNDiscAddress address = { + .address = r_network, + .timestamp = now, + .lifetime = ndp_msg_opt_prefix_valid_time (msg, offset), + .preferred = ndp_msg_opt_prefix_preferred_time (msg, offset), + }; + + if (address.preferred > address.lifetime) + address.preferred = address.lifetime; + if (nm_ndisc_complete_and_add_address (ndisc, &address)) + changed |= NM_NDISC_CONFIG_ADDRESSES; + } + } + ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_ROUTE) { + NMNDiscRoute route = { + .gateway = gateway_addr, + .plen = ndp_msg_opt_route_prefix_len (msg, offset), + .timestamp = now, + .lifetime = ndp_msg_opt_route_lifetime (msg, offset), + .preference = translate_preference (ndp_msg_opt_route_preference (msg, offset)), + }; + + if (route.plen == 0 || route.plen > 128) + continue; + + /* Routers through this particular gateway */ + nm_utils_ip6_address_clear_host_address (&route.network, ndp_msg_opt_route_prefix (msg, offset), route.plen); + if (nm_ndisc_add_route (ndisc, &route)) + changed |= NM_NDISC_CONFIG_ROUTES; + } + + /* DNS information */ + ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_RDNSS) { + static struct in6_addr *addr; + int addr_index; + + ndp_msg_opt_rdnss_for_each_addr (addr, addr_index, msg, offset) { + NMNDiscDNSServer dns_server = { + .address = *addr, + .timestamp = now, + .lifetime = ndp_msg_opt_rdnss_lifetime (msg, offset), + }; + + /* Pad the lifetime somewhat to give a bit of slack in cases + * where one RA gets lost or something (which can happen on unreliable + * links like WiFi where certain types of frames are not retransmitted). + * Note that 0 has special meaning and is therefore not adjusted. + */ + if (dns_server.lifetime && dns_server.lifetime < 7200) + dns_server.lifetime = 7200; + if (nm_ndisc_add_dns_server (ndisc, &dns_server)) + changed |= NM_NDISC_CONFIG_DNS_SERVERS; + } + } + ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_DNSSL) { + char *domain; + int domain_index; + + ndp_msg_opt_dnssl_for_each_domain (domain, domain_index, msg, offset) { + NMNDiscDNSDomain dns_domain = { + .domain = domain, + .timestamp = now, + .lifetime = ndp_msg_opt_rdnss_lifetime (msg, offset), + }; + + /* Pad the lifetime somewhat to give a bit of slack in cases + * where one RA gets lost or something (which can happen on unreliable + * links like WiFi where certain types of frames are not retransmitted). + * Note that 0 has special meaning and is therefore not adjusted. + */ + if (dns_domain.lifetime && dns_domain.lifetime < 7200) + dns_domain.lifetime = 7200; + if (nm_ndisc_add_dns_domain (ndisc, &dns_domain)) + changed |= NM_NDISC_CONFIG_DNS_DOMAINS; + } + } + + hop_limit = ndp_msgra_curhoplimit (msgra); + if (rdata->public.hop_limit != hop_limit) { + rdata->public.hop_limit = hop_limit; + changed |= NM_NDISC_CONFIG_HOP_LIMIT; + } + + /* MTU */ + ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_MTU) { + guint32 mtu = ndp_msg_opt_mtu(msg, offset); + if (mtu >= 1280) { + if (rdata->public.mtu != mtu) { + rdata->public.mtu = mtu; + changed |= NM_NDISC_CONFIG_MTU; + } + } else { + /* All sorts of bad things would happen if we accepted this. + * Kernel would set it, but would flush out all IPv6 addresses away + * from the link, even the link-local, and we wouldn't be able to + * listen for further RAs that could fix the MTU. */ + _LOGW ("MTU too small for IPv6 ignored: %d", mtu); + } + } + + nm_ndisc_ra_received (ndisc, now, changed); + return 0; +} + +static void * +_ndp_msg_add_option (struct ndp_msg *msg, int len) +{ + void *ret = (uint8_t *)msg + ndp_msg_payload_len (msg); + + len += ndp_msg_payload_len (msg); + if (len > ndp_msg_payload_maxlen (msg)) + return NULL; + + ndp_msg_payload_len_set (msg, len); + return ret; +} + +#define NM_ND_OPT_RDNSS 25 +typedef struct { + struct nd_opt_hdr header; + uint16_t reserved; + uint32_t lifetime;; + struct in6_addr addrs[0]; +} NMLndpRdnssOption; + +#define NM_ND_OPT_DNSSL 31 +typedef struct { + struct nd_opt_hdr header; + uint16_t reserved; + uint32_t lifetime; + char search_list[0]; +} NMLndpDnsslOption; + +static gboolean +send_ra (NMNDisc *ndisc, GError **error) +{ + NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE ((NMLndpNDisc *) ndisc); + NMNDiscDataInternal *rdata = ndisc->rdata; + guint32 now = nm_utils_get_monotonic_timestamp_s (); + int errsv; + struct in6_addr *addr; + struct ndp_msg *msg; + struct nd_opt_prefix_info *prefix; + int i; + + errsv = ndp_msg_new (&msg, NDP_MSG_RA); + if (errsv) { + errsv = errsv > 0 ? errsv : -errsv; + g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "cannot create a router advertisement"); + return FALSE; + } + + ndp_msg_ifindex_set (msg, nm_ndisc_get_ifindex (ndisc)); + + /* Multicast to all nodes. */ + addr = ndp_msg_addrto (msg); + addr->s6_addr32[0] = htonl(0xff020000); + addr->s6_addr32[1] = 0; + addr->s6_addr32[2] = 0; + addr->s6_addr32[3] = htonl(0x1); + + ndp_msgra_router_lifetime_set (ndp_msgra (msg), NM_NDISC_ROUTER_LIFETIME); + + /* The device let us know about all addresses that the device got + * whose prefixes are suitable for delegating. Let's announce them. */ + for (i = 0; i < rdata->addresses->len; i++) { + NMNDiscAddress *address = &g_array_index (rdata->addresses, NMNDiscAddress, i); + guint32 age = now - address->timestamp; + guint32 lifetime = address->lifetime; + guint32 preferred = address->preferred; + + /* Clamp the life times if they're not forever. */ + if (lifetime != 0xffffffff) + lifetime = lifetime > age ? lifetime - age : 0; + if (preferred != 0xffffffff) + preferred = preferred > age ? preferred - age : 0; + + prefix = _ndp_msg_add_option (msg, sizeof(*prefix)); + if (!prefix) { + /* Maybe we could sent separate RAs, but why bother... */ + _LOGW ("The RA is too big, had to omit some some prefixes."); + break; + } + + prefix->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION; + prefix->nd_opt_pi_len = 4; + prefix->nd_opt_pi_prefix_len = 64; + prefix->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_ONLINK; + prefix->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_AUTO; + prefix->nd_opt_pi_valid_time = htonl(lifetime); + prefix->nd_opt_pi_preferred_time = htonl(preferred); + prefix->nd_opt_pi_prefix.s6_addr32[0] = address->address.s6_addr32[0]; + prefix->nd_opt_pi_prefix.s6_addr32[1] = address->address.s6_addr32[1]; + prefix->nd_opt_pi_prefix.s6_addr32[2] = 0; + prefix->nd_opt_pi_prefix.s6_addr32[3] = 0; + } + + if (rdata->dns_servers->len) { + NMLndpRdnssOption *option; + int len = sizeof(*option) + sizeof(option->addrs[0]) * rdata->dns_servers->len; + + option = _ndp_msg_add_option (msg, len); + if (option) { + option->header.nd_opt_type = NM_ND_OPT_RDNSS; + option->header.nd_opt_len = len / 8; + option->lifetime = htonl (900); + + for (i = 0; i < rdata->dns_servers->len; i++) { + NMNDiscDNSServer *dns_server = &g_array_index (rdata->dns_servers, NMNDiscDNSServer, i); + option->addrs[i] = dns_server->address; + } + } else { + _LOGW ("The RA is too big, had to omit DNS information."); + } + + } + + if (rdata->dns_domains->len) { + NMLndpDnsslOption *option; + NMNDiscDNSDomain *dns_server; + int len = sizeof(*option); + char *search_list; + + for (i = 0; i < rdata->dns_domains->len; i++) { + dns_server = &g_array_index (rdata->dns_domains, NMNDiscDNSDomain, i); + len += strlen (dns_server->domain) + 2; + } + len = (len + 8) & ~0x7; + + option = _ndp_msg_add_option (msg, len); + if (option) { + option->header.nd_opt_type = NM_ND_OPT_DNSSL; + option->header.nd_opt_len = len / 8; + option->lifetime = htonl (900); + + search_list = option->search_list; + for (i = 0; i < rdata->dns_domains->len; i++) { + NMNDiscDNSDomain *dns_domain = &g_array_index (rdata->dns_domains, NMNDiscDNSDomain, i); + uint8_t domain_len = strlen (dns_domain->domain); + + *search_list++ = domain_len; + memcpy (search_list, dns_domain->domain, domain_len); + search_list += domain_len; + *search_list++ = '\0'; + } + } else { + _LOGW ("The RA is too big, had to omit DNS search list."); + } + } + + errsv = ndp_msg_send (priv->ndp, msg); + + ndp_msg_destroy (msg); + if (errsv) { + errsv = errsv > 0 ? errsv : -errsv; + g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "%s (%d)", + g_strerror (errsv), errsv); + return FALSE; + } + + return TRUE; +} + +static int +receive_rs (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data) +{ + NMNDisc *ndisc = user_data; + + nm_ndisc_rs_received (ndisc); + return 0; +} + +static gboolean +event_ready (GIOChannel *source, GIOCondition condition, NMNDisc *ndisc) +{ + nm_auto_pop_netns NMPNetns *netns = NULL; + NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE ((NMLndpNDisc *) ndisc); + + _LOGD ("processing libndp events"); + + if (!nm_ndisc_netns_push (ndisc, &netns)) + return G_SOURCE_CONTINUE; + + ndp_callall_eventfd_handler (priv->ndp); + return G_SOURCE_CONTINUE; +} + +static void +start (NMNDisc *ndisc) +{ + NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE ((NMLndpNDisc *) ndisc); + int fd = ndp_get_eventfd (priv->ndp); + + g_return_if_fail (!priv->event_channel); + g_return_if_fail (!priv->event_id); + + priv->event_channel = g_io_channel_unix_new (fd); + priv->event_id = g_io_add_watch (priv->event_channel, G_IO_IN, (GIOFunc) event_ready, ndisc); + + /* Flush any pending messages to avoid using obsolete information */ + event_ready (priv->event_channel, 0, ndisc); + + switch (nm_ndisc_get_node_type (ndisc)) { + case NM_NDISC_NODE_TYPE_HOST: + ndp_msgrcv_handler_register (priv->ndp, receive_ra, NDP_MSG_RA, nm_ndisc_get_ifindex (ndisc), ndisc); + break; + case NM_NDISC_NODE_TYPE_ROUTER: + ndp_msgrcv_handler_register (priv->ndp, receive_rs, NDP_MSG_RS, nm_ndisc_get_ifindex (ndisc), ndisc); + break; + default: + g_assert_not_reached (); + } +} + +/*****************************************************************************/ + +static inline int +ipv6_sysctl_get (NMPlatform *platform, const char *ifname, const char *property, int min, int max, int defval) +{ + return (int) nm_platform_sysctl_get_int_checked (platform, + NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (ifname, property)), + 10, + min, + max, + defval); +} + +static void +nm_lndp_ndisc_init (NMLndpNDisc *lndp_ndisc) +{ +} + +NMNDisc * +nm_lndp_ndisc_new (NMPlatform *platform, + int ifindex, + const char *ifname, + NMUtilsStableType stable_type, + const char *network_id, + NMSettingIP6ConfigAddrGenMode addr_gen_mode, + NMNDiscNodeType node_type, + GError **error) +{ + nm_auto_pop_netns NMPNetns *netns = NULL; + NMNDisc *ndisc; + NMLndpNDiscPrivate *priv; + int errsv; + + g_return_val_if_fail (NM_IS_PLATFORM (platform), NULL); + g_return_val_if_fail (!error || !*error, NULL); + g_return_val_if_fail (network_id, NULL); + + if (!nm_platform_netns_push (platform, &netns)) + return NULL; + + ndisc = g_object_new (NM_TYPE_LNDP_NDISC, + NM_NDISC_PLATFORM, platform, + NM_NDISC_STABLE_TYPE, (int) stable_type, + NM_NDISC_IFINDEX, ifindex, + NM_NDISC_IFNAME, ifname, + NM_NDISC_NETWORK_ID, network_id, + NM_NDISC_ADDR_GEN_MODE, (int) addr_gen_mode, + NM_NDISC_NODE_TYPE, (int) node_type, + NM_NDISC_MAX_ADDRESSES, ipv6_sysctl_get (platform, ifname, + "max_addresses", + 0, G_MAXINT32, NM_NDISC_MAX_ADDRESSES_DEFAULT), + NM_NDISC_ROUTER_SOLICITATIONS, ipv6_sysctl_get (platform, ifname, + "router_solicitations", + 1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT), + NM_NDISC_ROUTER_SOLICITATION_INTERVAL, ipv6_sysctl_get (platform, ifname, + "router_solicitation_interval", + 1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATION_INTERVAL_DEFAULT), + NULL); + + priv = NM_LNDP_NDISC_GET_PRIVATE ((NMLndpNDisc *) ndisc); + + errsv = ndp_open (&priv->ndp); + + if (errsv != 0) { + errsv = errsv > 0 ? errsv : -errsv; + g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "failure creating libndp socket: %s (%d)", + g_strerror (errsv), errsv); + g_object_unref (ndisc); + return NULL; + } + return ndisc; +} + +static void +dispose (GObject *object) +{ + NMNDisc *ndisc = (NMNDisc *) object; + NMLndpNDiscPrivate *priv = NM_LNDP_NDISC_GET_PRIVATE ((NMLndpNDisc *) ndisc); + + nm_clear_g_source (&priv->event_id); + g_clear_pointer (&priv->event_channel, g_io_channel_unref); + + if (priv->ndp) { + switch (nm_ndisc_get_node_type (ndisc)) { + case NM_NDISC_NODE_TYPE_HOST: + ndp_msgrcv_handler_unregister (priv->ndp, receive_ra, NDP_MSG_RA, nm_ndisc_get_ifindex (ndisc), ndisc); + break; + case NM_NDISC_NODE_TYPE_ROUTER: + ndp_msgrcv_handler_unregister (priv->ndp, receive_rs, NDP_MSG_RS, nm_ndisc_get_ifindex (ndisc), ndisc); + break; + default: + g_assert_not_reached (); + } + ndp_close (priv->ndp); + priv->ndp = NULL; + } + + G_OBJECT_CLASS (nm_lndp_ndisc_parent_class)->dispose (object); +} + +static void +nm_lndp_ndisc_class_init (NMLndpNDiscClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMNDiscClass *ndisc_class = NM_NDISC_CLASS (klass); + + object_class->dispose = dispose; + ndisc_class->start = start; + ndisc_class->send_rs = send_rs; + ndisc_class->send_ra = send_ra; +} diff --git a/src/ndisc/nm-lndp-ndisc.h b/src/ndisc/nm-lndp-ndisc.h new file mode 100644 index 00000000..f042fb74 --- /dev/null +++ b/src/ndisc/nm-lndp-ndisc.h @@ -0,0 +1,48 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-lndp-ndisc.h - Implementation of neighbor discovery using libndp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_LNDP_NDISC_H__ +#define __NETWORKMANAGER_LNDP_NDISC_H__ + +#include "nm-ndisc.h" +#include "nm-core-utils.h" + +#define NM_TYPE_LNDP_NDISC (nm_lndp_ndisc_get_type ()) +#define NM_LNDP_NDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_LNDP_NDISC, NMLndpNDisc)) +#define NM_LNDP_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_LNDP_NDISC, NMLndpNDiscClass)) +#define NM_IS_LNDP_NDISC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_LNDP_NDISC)) +#define NM_IS_LNDP_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_LNDP_NDISC)) +#define NM_LNDP_NDISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_LNDP_NDISC, NMLndpNDiscClass)) + +typedef struct _NMLndpNDisc NMLndpNDisc; +typedef struct _NMLndpNDiscClass NMLndpNDiscClass; + +GType nm_lndp_ndisc_get_type (void); + +NMNDisc *nm_lndp_ndisc_new (NMPlatform *platform, + int ifindex, + const char *ifname, + NMUtilsStableType stable_type, + const char *network_id, + NMSettingIP6ConfigAddrGenMode addr_gen_mode, + NMNDiscNodeType node_type, + GError **error); + +#endif /* __NETWORKMANAGER_LNDP_NDISC_H__ */ diff --git a/src/ndisc/nm-ndisc-private.h b/src/ndisc/nm-ndisc-private.h new file mode 100644 index 00000000..2308675a --- /dev/null +++ b/src/ndisc/nm-ndisc-private.h @@ -0,0 +1,78 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-ndisc.h - Perform IPv6 neighbor discovery + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2015 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_NDISC_PRIVATE_H__ +#define __NETWORKMANAGER_NDISC_PRIVATE_H__ + +#include "nm-ndisc.h" + +/* Functions only used by ndisc implementations */ + +struct _NMNDiscDataInternal { + NMNDiscData public; + GArray *gateways; + GArray *addresses; + GArray *routes; + GArray *dns_servers; + GArray *dns_domains; +}; + +typedef struct _NMNDiscDataInternal NMNDiscDataInternal; + +void nm_ndisc_ra_received (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap changed); +void nm_ndisc_rs_received (NMNDisc *ndisc); + +gboolean nm_ndisc_add_gateway (NMNDisc *ndisc, const NMNDiscGateway *new); +gboolean nm_ndisc_complete_and_add_address (NMNDisc *ndisc, NMNDiscAddress *new); +gboolean nm_ndisc_add_route (NMNDisc *ndisc, const NMNDiscRoute *new); +gboolean nm_ndisc_add_dns_server (NMNDisc *ndisc, const NMNDiscDNSServer *new); +gboolean nm_ndisc_add_dns_domain (NMNDisc *ndisc, const NMNDiscDNSDomain *new); + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_IP6 +#define _NMLOG(level, ...) _LOG(level, _NMLOG_DOMAIN, ndisc, __VA_ARGS__) + +#define _LOG(level, domain, self, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + const NMLogDomain __domain = (domain); \ + \ + if (nm_logging_enabled (__level, __domain)) { \ + NMNDisc *const __self = (self); \ + char __prefix[64]; \ + \ + _nm_log (__level, __domain, 0, \ + "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + (__self \ + ? ({ \ + const char *__ifname = nm_ndisc_get_ifname (__self); \ + nm_sprintf_buf (__prefix, "%s[%p,%s%s%s]", \ + _NMLOG_PREFIX_NAME, __self, \ + NM_PRINT_FMT_QUOTE_STRING (__ifname)); \ + }) \ + : _NMLOG_PREFIX_NAME) \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +/*****************************************************************************/ + +#endif /* __NETWORKMANAGER_NDISC_PRIVATE_H__ */ diff --git a/src/ndisc/nm-ndisc.c b/src/ndisc/nm-ndisc.c new file mode 100644 index 00000000..a50bbe43 --- /dev/null +++ b/src/ndisc/nm-ndisc.c @@ -0,0 +1,1235 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-ndisc.c - Perform IPv6 neighbor discovery + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-ndisc.h" + +#include +#include +#include + +#include "nm-setting-ip6-config.h" + +#include "nm-ndisc-private.h" +#include "nm-utils.h" +#include "platform/nm-platform.h" +#include "platform/nmp-netns.h" + +#define _NMLOG_PREFIX_NAME "ndisc" + +/*****************************************************************************/ + +struct _NMNDiscPrivate { + /* this *must* be the first field. */ + NMNDiscDataInternal rdata; + + union { + gint32 solicitations_left; + gint32 announcements_left; + }; + union { + guint send_rs_id; + guint send_ra_id; + }; + union { + gint32 last_rs; + gint32 last_ra; + }; + guint ra_timeout_id; /* first RA timeout */ + guint timeout_id; /* prefix/dns/etc lifetime timeout */ + char *last_error; + NMUtilsIPv6IfaceId iid; + + /* immutable values: */ + int ifindex; + char *ifname; + char *network_id; + NMSettingIP6ConfigAddrGenMode addr_gen_mode; + NMUtilsStableType stable_type; + gint32 max_addresses; + gint32 router_solicitations; + gint32 router_solicitation_interval; + NMNDiscNodeType node_type; + + NMPlatform *platform; + NMPNetns *netns; +}; + +typedef struct _NMNDiscPrivate NMNDiscPrivate; + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PLATFORM, + PROP_IFINDEX, + PROP_IFNAME, + PROP_STABLE_TYPE, + PROP_NETWORK_ID, + PROP_ADDR_GEN_MODE, + PROP_MAX_ADDRESSES, + PROP_ROUTER_SOLICITATIONS, + PROP_ROUTER_SOLICITATION_INTERVAL, + PROP_NODE_TYPE, +); + +enum { + CONFIG_CHANGED, + RA_TIMEOUT, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +G_DEFINE_TYPE (NMNDisc, nm_ndisc, G_TYPE_OBJECT) + +#define NM_NDISC_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMNDisc, NM_IS_NDISC) + +/*****************************************************************************/ + +static void _config_changed_log (NMNDisc *ndisc, NMNDiscConfigMap changed); + +/*****************************************************************************/ + +NMPNetns * +nm_ndisc_netns_get (NMNDisc *self) +{ + g_return_val_if_fail (NM_IS_NDISC (self), NULL); + + return NM_NDISC_GET_PRIVATE (self)->netns; +} + +gboolean +nm_ndisc_netns_push (NMNDisc *self, NMPNetns **netns) +{ + NMNDiscPrivate *priv; + + g_return_val_if_fail (NM_IS_NDISC (self), FALSE); + + priv = NM_NDISC_GET_PRIVATE (self); + if ( priv->netns + && !nmp_netns_push (priv->netns)) { + NM_SET_OUT (netns, NULL); + return FALSE; + } + + NM_SET_OUT (netns, priv->netns); + return TRUE; +} + +/*****************************************************************************/ + +int +nm_ndisc_get_ifindex (NMNDisc *self) +{ + g_return_val_if_fail (NM_IS_NDISC (self), 0); + + return NM_NDISC_GET_PRIVATE (self)->ifindex; +} + +const char * +nm_ndisc_get_ifname (NMNDisc *self) +{ + g_return_val_if_fail (NM_IS_NDISC (self), NULL); + + return NM_NDISC_GET_PRIVATE (self)->ifname; +} + +NMNDiscNodeType +nm_ndisc_get_node_type (NMNDisc *self) +{ + g_return_val_if_fail (NM_IS_NDISC (self), NM_NDISC_NODE_TYPE_INVALID); + + return NM_NDISC_GET_PRIVATE (self)->node_type; +} + +/*****************************************************************************/ + +static const NMNDiscData * +_data_complete (NMNDiscDataInternal *data) +{ +#define _SET(data, field) \ + G_STMT_START { \ + if ((data->public.field##_n = data->field->len) > 0) \ + data->public.field = (gpointer) data->field->data; \ + else \ + data->public.field = NULL; \ + } G_STMT_END + _SET (data, gateways); + _SET (data, addresses); + _SET (data, routes); + _SET (data, dns_servers); + _SET (data, dns_domains); +#undef _SET + return &data->public; +} + +static void +_emit_config_change (NMNDisc *self, NMNDiscConfigMap changed) +{ + _config_changed_log (self, changed); + g_signal_emit (self, signals[CONFIG_CHANGED], 0, + _data_complete (&NM_NDISC_GET_PRIVATE (self)->rdata), + (guint) changed); +} + +/*****************************************************************************/ + +gboolean +nm_ndisc_add_gateway (NMNDisc *ndisc, const NMNDiscGateway *new) +{ + NMNDiscDataInternal *rdata = &NM_NDISC_GET_PRIVATE(ndisc)->rdata; + int i, insert_idx = -1; + + for (i = 0; i < rdata->gateways->len; i++) { + NMNDiscGateway *item = &g_array_index (rdata->gateways, NMNDiscGateway, i); + + if (IN6_ARE_ADDR_EQUAL (&item->address, &new->address)) { + if (new->lifetime == 0) { + g_array_remove_index (rdata->gateways, i--); + return TRUE; + } + + if (item->preference != new->preference) { + g_array_remove_index (rdata->gateways, i--); + continue; + } + + memcpy (item, new, sizeof (*new)); + return FALSE; + } + + /* Put before less preferable gateways. */ + if (item->preference < new->preference && insert_idx < 0) + insert_idx = i; + } + + if (new->lifetime) + g_array_insert_val (rdata->gateways, MAX (insert_idx, 0), *new); + return !!new->lifetime; +} + +/** + * complete_address: + * @ndisc: the #NMNDisc + * @addr: the #NMNDiscAddress + * + * Adds the host part to the address that has network part set. + * If the address already has a host part, add a different host part + * if possible (this is useful in case DAD failed). + * + * Can fail if a different address can not be generated (DAD failure + * for an EUI-64 address or DAD counter overflow). + * + * Returns: %TRUE if the address could be completed, %FALSE otherwise. + **/ +static gboolean +complete_address (NMNDisc *ndisc, NMNDiscAddress *addr) +{ + NMNDiscPrivate *priv; + GError *error = NULL; + + g_return_val_if_fail (NM_IS_NDISC (ndisc), FALSE); + + priv = NM_NDISC_GET_PRIVATE (ndisc); + if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { + if (!nm_utils_ipv6_addr_set_stable_privacy (priv->stable_type, + &addr->address, + priv->ifname, + priv->network_id, + addr->dad_counter++, + &error)) { + _LOGW ("complete-address: failed to generate an stable-privacy address: %s", + error->message); + g_clear_error (&error); + return FALSE; + } + _LOGD ("complete-address: using an stable-privacy address"); + return TRUE; + } + + if (!priv->iid.id) { + _LOGW ("complete-address: can't generate an EUI-64 address: no interface identifier"); + return FALSE; + } + + if (addr->address.s6_addr32[2] == 0x0 && addr->address.s6_addr32[3] == 0x0) { + _LOGD ("complete-address: adding an EUI-64 address"); + nm_utils_ipv6_addr_set_interface_identifier (&addr->address, priv->iid); + return TRUE; + } + + _LOGW ("complete-address: can't generate a new EUI-64 address"); + return FALSE; +} + +static gboolean +nm_ndisc_add_address (NMNDisc *ndisc, const NMNDiscAddress *new) +{ + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + NMNDiscDataInternal *rdata = &priv->rdata; + int i; + + for (i = 0; i < rdata->addresses->len; i++) { + NMNDiscAddress *item = &g_array_index (rdata->addresses, NMNDiscAddress, i); + + if (IN6_ARE_ADDR_EQUAL (&item->address, &new->address)) { + gboolean changed; + + if (new->lifetime == 0) { + g_array_remove_index (rdata->addresses, i--); + return TRUE; + } + + changed = item->timestamp + item->lifetime != new->timestamp + new->lifetime || + item->timestamp + item->preferred != new->timestamp + new->preferred; + *item = *new; + return changed; + } + } + + /* we create at most max_addresses autoconf addresses. This is different from + * what the kernel does, because it considers *all* addresses (including + * static and other temporary addresses). + **/ + if (priv->max_addresses && rdata->addresses->len >= priv->max_addresses) + return FALSE; + + if (new->lifetime) + g_array_insert_val (rdata->addresses, i, *new); + return !!new->lifetime; +} + +gboolean +nm_ndisc_complete_and_add_address (NMNDisc *ndisc, NMNDiscAddress *new) +{ + if (!complete_address (ndisc, new)) + return FALSE; + + return nm_ndisc_add_address (ndisc, new); +} + +gboolean +nm_ndisc_add_route (NMNDisc *ndisc, const NMNDiscRoute *new) +{ + NMNDiscPrivate *priv; + NMNDiscDataInternal *rdata; + int i, insert_idx = -1; + + if (new->plen == 0 || new->plen > 128) { + /* Only expect non-default routes. The router has no idea what the + * local configuration or user preferences are, so sending routes + * with a prefix length of 0 must be ignored by NMNDisc. + * + * Also, upper layers also don't expect that NMNDisc exposes routes + * with a plen or zero or larger then 128. + */ + g_return_val_if_reached (FALSE); + } + + priv = NM_NDISC_GET_PRIVATE (ndisc); + rdata = &priv->rdata; + + for (i = 0; i < rdata->routes->len; i++) { + NMNDiscRoute *item = &g_array_index (rdata->routes, NMNDiscRoute, i); + + if (IN6_ARE_ADDR_EQUAL (&item->network, &new->network) && item->plen == new->plen) { + if (new->lifetime == 0) { + g_array_remove_index (rdata->routes, i--); + return TRUE; + } + + if (item->preference != new->preference) { + g_array_remove_index (rdata->routes, i--); + continue; + } + + memcpy (item, new, sizeof (*new)); + return FALSE; + } + + /* Put before less preferable routes. */ + if (item->preference < new->preference && insert_idx < 0) + insert_idx = i; + } + + if (new->lifetime) + g_array_insert_val (rdata->routes, CLAMP (insert_idx, 0, G_MAXINT), *new); + return !!new->lifetime; +} + +gboolean +nm_ndisc_add_dns_server (NMNDisc *ndisc, const NMNDiscDNSServer *new) +{ + NMNDiscPrivate *priv; + NMNDiscDataInternal *rdata; + int i; + + priv = NM_NDISC_GET_PRIVATE (ndisc); + rdata = &priv->rdata; + + for (i = 0; i < rdata->dns_servers->len; i++) { + NMNDiscDNSServer *item = &g_array_index (rdata->dns_servers, NMNDiscDNSServer, i); + + if (IN6_ARE_ADDR_EQUAL (&item->address, &new->address)) { + if (new->lifetime == 0) { + g_array_remove_index (rdata->dns_servers, i); + return TRUE; + } + if (item->timestamp != new->timestamp || item->lifetime != new->lifetime) { + *item = *new; + return TRUE; + } + return FALSE; + } + } + + if (new->lifetime) + g_array_insert_val (rdata->dns_servers, i, *new); + return !!new->lifetime; +} + +/* Copies new->domain if 'new' is added to the dns_domains list */ +gboolean +nm_ndisc_add_dns_domain (NMNDisc *ndisc, const NMNDiscDNSDomain *new) +{ + NMNDiscPrivate *priv; + NMNDiscDataInternal *rdata; + NMNDiscDNSDomain *item; + int i; + + priv = NM_NDISC_GET_PRIVATE (ndisc); + rdata = &priv->rdata; + + for (i = 0; i < rdata->dns_domains->len; i++) { + item = &g_array_index (rdata->dns_domains, NMNDiscDNSDomain, i); + + if (!g_strcmp0 (item->domain, new->domain)) { + gboolean changed; + + if (new->lifetime == 0) { + g_array_remove_index (rdata->dns_domains, i); + return TRUE; + } + + changed = (item->timestamp != new->timestamp || + item->lifetime != new->lifetime); + if (changed) { + item->timestamp = new->timestamp; + item->lifetime = new->lifetime; + } + return changed; + } + } + + if (new->lifetime) { + g_array_insert_val (rdata->dns_domains, i, *new); + item = &g_array_index (rdata->dns_domains, NMNDiscDNSDomain, i); + item->domain = g_strdup (new->domain); + } + return !!new->lifetime; +} + +/*****************************************************************************/ + +#define _MAYBE_WARN(...) G_STMT_START { \ + gboolean _different_message; \ + \ + _different_message = g_strcmp0 (priv->last_error, error->message) != 0; \ + _NMLOG (_different_message ? LOGL_WARN : LOGL_DEBUG, __VA_ARGS__); \ + if (_different_message) { \ + g_clear_pointer (&priv->last_error, g_free); \ + priv->last_error = g_strdup (error->message); \ + } \ + } G_STMT_END + +static gboolean +send_rs_timeout (NMNDisc *ndisc) +{ + nm_auto_pop_netns NMPNetns *netns = NULL; + NMNDiscClass *klass = NM_NDISC_GET_CLASS (ndisc); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + GError *error = NULL; + + priv->send_rs_id = 0; + + if (!nm_ndisc_netns_push (ndisc, &netns)) + return G_SOURCE_REMOVE; + + if (klass->send_rs (ndisc, &error)) { + _LOGD ("router solicitation sent"); + priv->solicitations_left--; + g_clear_pointer (&priv->last_error, g_free); + } else { + _MAYBE_WARN ("failure sending router solicitation: %s", error->message); + g_clear_error (&error); + } + + priv->last_rs = nm_utils_get_monotonic_timestamp_s (); + if (priv->solicitations_left > 0) { + _LOGD ("scheduling router solicitation retry in %d seconds.", + (int) priv->router_solicitation_interval); + priv->send_rs_id = g_timeout_add_seconds (priv->router_solicitation_interval, + (GSourceFunc) send_rs_timeout, ndisc); + } else { + _LOGD ("did not receive a router advertisement after %d solicitations.", + (int) priv->router_solicitations); + } + + return G_SOURCE_REMOVE; +} + +static void +solicit_routers (NMNDisc *ndisc) +{ + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + gint64 next, now; + + if (priv->send_rs_id) + return; + + now = nm_utils_get_monotonic_timestamp_s (); + priv->solicitations_left = priv->router_solicitations; + + next = (((gint64) priv->last_rs) + priv->router_solicitation_interval) - now; + next = CLAMP (next, 0, G_MAXINT32); + _LOGD ("scheduling explicit router solicitation request in %" G_GINT64_FORMAT " seconds.", + next); + priv->send_rs_id = g_timeout_add_seconds ((guint32) next, (GSourceFunc) send_rs_timeout, ndisc); +} + +static gboolean +announce_router (NMNDisc *ndisc) +{ + nm_auto_pop_netns NMPNetns *netns = NULL; + NMNDiscClass *klass = NM_NDISC_GET_CLASS (ndisc); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + GError *error = NULL; + + if (!nm_ndisc_netns_push (ndisc, &netns)) + return G_SOURCE_REMOVE; + + priv->last_ra = nm_utils_get_monotonic_timestamp_s (); + if (klass->send_ra (ndisc, &error)) { + _LOGD ("router advertisement sent"); + g_clear_pointer (&priv->last_error, g_free); + } else { + _MAYBE_WARN ("failure sending router advertisement: %s", error->message); + g_clear_error (&error); + } + + if (--priv->announcements_left) { + _LOGD ("will resend an initial router advertisement"); + + /* Schedule next initial announcement retransmit. */ + priv->send_ra_id = g_timeout_add_seconds (g_random_int_range (NM_NDISC_ROUTER_ADVERT_DELAY, + NM_NDISC_ROUTER_ADVERT_INITIAL_INTERVAL), + (GSourceFunc) announce_router, ndisc); + } else { + _LOGD ("will send an unsolicited router advertisement"); + + /* Schedule next unsolicited announcement. */ + priv->announcements_left = 1; + priv->send_ra_id = g_timeout_add_seconds (NM_NDISC_ROUTER_ADVERT_MAX_INTERVAL, + (GSourceFunc) announce_router, + ndisc); + } + + return G_SOURCE_REMOVE; +} + +static void +announce_router_initial (NMNDisc *ndisc) +{ + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + + _LOGD ("will send an initial router advertisement"); + + /* Retry three more times. */ + priv->announcements_left = NM_NDISC_ROUTER_ADVERTISEMENTS_DEFAULT; + + /* Unschedule an unsolicited resend if we are allowed to send now. */ + if (G_LIKELY (nm_utils_get_monotonic_timestamp_s () - priv->last_ra > NM_NDISC_ROUTER_ADVERT_DELAY)) + nm_clear_g_source (&priv->send_ra_id); + + /* Schedule the initial send rather early. Clamp the delay by minimal + * delay and not the initial advert internal so that we start fast. */ + if (G_LIKELY (!priv->send_ra_id)) { + priv->send_ra_id = g_timeout_add_seconds (g_random_int_range (0, NM_NDISC_ROUTER_ADVERT_DELAY), + (GSourceFunc) announce_router, ndisc); + } +} + +static void +announce_router_solicited (NMNDisc *ndisc) +{ + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + + _LOGD ("will send an solicited router advertisement"); + + /* Unschedule an unsolicited resend if we are allowed to send now. */ + if (nm_utils_get_monotonic_timestamp_s () - priv->last_ra > NM_NDISC_ROUTER_ADVERT_DELAY) + nm_clear_g_source (&priv->send_ra_id); + + if (!priv->send_ra_id) { + priv->send_ra_id = g_timeout_add (g_random_int_range (0, NM_NDISC_ROUTER_ADVERT_DELAY_MS), + (GSourceFunc) announce_router, ndisc); + } +} + +/*****************************************************************************/ + +void +nm_ndisc_set_config (NMNDisc *ndisc, + const GArray *addresses, + const GArray *dns_servers, + const GArray *dns_domains) +{ + int changed = FALSE; + guint i; + + for (i = 0; i < addresses->len; i++) { + if (nm_ndisc_add_address (ndisc, &g_array_index (addresses, NMNDiscAddress, i))) + changed = TRUE; + } + + for (i = 0; i < dns_servers->len; i++) { + if (nm_ndisc_add_dns_server (ndisc, &g_array_index (dns_servers, NMNDiscDNSServer, i))) + changed = TRUE; + } + + for (i = 0; i < dns_domains->len; i++) { + if (nm_ndisc_add_dns_domain (ndisc, &g_array_index (dns_domains, NMNDiscDNSDomain, i))) + changed = TRUE; + } + + if (changed) + announce_router_initial (ndisc); +} + +/** + * nm_ndisc_set_iid: + * @ndisc: the #NMNDisc + * @iid: the new interface ID + * + * Sets the "Modified EUI-64" interface ID to be used when generating + * IPv6 addresses using received prefixes. Identifiers are either generated + * from the hardware addresses or manually set by the operator with + * "ip token" command. + * + * Upon token change (or initial setting) all addresses generated using + * the old identifier are removed. The caller should ensure the addresses + * will be reset by soliciting router advertisements. + * + * In case the stable privacy addressing is used %FALSE is returned and + * addresses are left untouched. + * + * Returns: %TRUE if addresses need to be regenerated, %FALSE otherwise. + **/ +gboolean +nm_ndisc_set_iid (NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid) +{ + NMNDiscPrivate *priv; + NMNDiscDataInternal *rdata; + + g_return_val_if_fail (NM_IS_NDISC (ndisc), FALSE); + + priv = NM_NDISC_GET_PRIVATE (ndisc); + rdata = &priv->rdata; + + if (priv->iid.id != iid.id) { + priv->iid = iid; + + if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) + return FALSE; + + if (rdata->addresses->len) { + _LOGD ("IPv6 interface identifier changed, flushing addresses"); + g_array_remove_range (rdata->addresses, 0, rdata->addresses->len); + _emit_config_change (ndisc, NM_NDISC_CONFIG_ADDRESSES); + solicit_routers (ndisc); + } + return TRUE; + } + + return FALSE; +} + +static gboolean +ndisc_ra_timeout_cb (gpointer user_data) +{ + NMNDisc *ndisc = NM_NDISC (user_data); + + NM_NDISC_GET_PRIVATE (ndisc)->ra_timeout_id = 0; + g_signal_emit (ndisc, signals[RA_TIMEOUT], 0); + return G_SOURCE_REMOVE; +} + +void +nm_ndisc_start (NMNDisc *ndisc) +{ + nm_auto_pop_netns NMPNetns *netns = NULL; + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + NMNDiscClass *klass = NM_NDISC_GET_CLASS (ndisc); + gint64 ra_wait_secs; + + g_return_if_fail (klass->start); + g_return_if_fail (!priv->ra_timeout_id); + + _LOGD ("starting neighbor discovery: %d", priv->ifindex); + + if (!nm_ndisc_netns_push (ndisc, &netns)) + return; + + klass->start (ndisc); + + switch (priv->node_type) { + case NM_NDISC_NODE_TYPE_HOST: + ra_wait_secs = (((gint64) priv->router_solicitations) * priv->router_solicitation_interval) + 1; + ra_wait_secs = CLAMP (ra_wait_secs, 30, 120); + priv->ra_timeout_id = g_timeout_add_seconds (ra_wait_secs, ndisc_ra_timeout_cb, ndisc); + _LOGD ("scheduling RA timeout in %d seconds", (int) ra_wait_secs); + solicit_routers (ndisc); + break; + case NM_NDISC_NODE_TYPE_ROUTER: + announce_router_initial (ndisc); + break; + default: + g_assert_not_reached (); + } +} + +void +nm_ndisc_dad_failed (NMNDisc *ndisc, struct in6_addr *address) +{ + NMNDiscDataInternal *rdata; + int i; + gboolean changed = FALSE; + + rdata = &NM_NDISC_GET_PRIVATE (ndisc)->rdata; + + for (i = 0; i < rdata->addresses->len; i++) { + NMNDiscAddress *item = &g_array_index (rdata->addresses, NMNDiscAddress, i); + + if (!IN6_ARE_ADDR_EQUAL (&item->address, address)) + continue; + + _LOGD ("DAD failed for discovered address %s", nm_utils_inet6_ntop (address, NULL)); + if (!complete_address (ndisc, item)) + g_array_remove_index (rdata->addresses, i--); + changed = TRUE; + } + + if (changed) + _emit_config_change (ndisc, NM_NDISC_CONFIG_ADDRESSES); +} + +#define CONFIG_MAP_MAX_STR 7 + +static void +config_map_to_string (NMNDiscConfigMap map, char *p) +{ + if (map & NM_NDISC_CONFIG_DHCP_LEVEL) + *p++ = 'd'; + if (map & NM_NDISC_CONFIG_GATEWAYS) + *p++ = 'G'; + if (map & NM_NDISC_CONFIG_ADDRESSES) + *p++ = 'A'; + if (map & NM_NDISC_CONFIG_ROUTES) + *p++ = 'R'; + if (map & NM_NDISC_CONFIG_DNS_SERVERS) + *p++ = 'S'; + if (map & NM_NDISC_CONFIG_DNS_DOMAINS) + *p++ = 'D'; + *p = '\0'; +} + +static const char * +dhcp_level_to_string (NMNDiscDHCPLevel dhcp_level) +{ + switch (dhcp_level) { + case NM_NDISC_DHCP_LEVEL_NONE: + return "none"; + case NM_NDISC_DHCP_LEVEL_OTHERCONF: + return "otherconf"; + case NM_NDISC_DHCP_LEVEL_MANAGED: + return "managed"; + default: + return "INVALID"; + } +} + +#define expiry(item) (item->timestamp + item->lifetime) + +static void +_config_changed_log (NMNDisc *ndisc, NMNDiscConfigMap changed) +{ + NMNDiscPrivate *priv; + NMNDiscDataInternal *rdata; + int i; + char changedstr[CONFIG_MAP_MAX_STR]; + char addrstr[INET6_ADDRSTRLEN]; + + if (!_LOGD_ENABLED ()) + return; + + priv = NM_NDISC_GET_PRIVATE (ndisc); + rdata = &priv->rdata; + + config_map_to_string (changed, changedstr); + _LOGD ("neighbor discovery configuration changed [%s]:", changedstr); + _LOGD (" dhcp-level %s", dhcp_level_to_string (priv->rdata.public.dhcp_level)); + for (i = 0; i < rdata->gateways->len; i++) { + NMNDiscGateway *gateway = &g_array_index (rdata->gateways, NMNDiscGateway, i); + + inet_ntop (AF_INET6, &gateway->address, addrstr, sizeof (addrstr)); + _LOGD (" gateway %s pref %d exp %u", addrstr, gateway->preference, expiry (gateway)); + } + for (i = 0; i < rdata->addresses->len; i++) { + NMNDiscAddress *address = &g_array_index (rdata->addresses, NMNDiscAddress, i); + + inet_ntop (AF_INET6, &address->address, addrstr, sizeof (addrstr)); + _LOGD (" address %s exp %u", addrstr, expiry (address)); + } + for (i = 0; i < rdata->routes->len; i++) { + NMNDiscRoute *route = &g_array_index (rdata->routes, NMNDiscRoute, i); + + inet_ntop (AF_INET6, &route->network, addrstr, sizeof (addrstr)); + _LOGD (" route %s/%d via %s pref %d exp %u", addrstr, (int) route->plen, + nm_utils_inet6_ntop (&route->gateway, NULL), route->preference, + expiry (route)); + } + for (i = 0; i < rdata->dns_servers->len; i++) { + NMNDiscDNSServer *dns_server = &g_array_index (rdata->dns_servers, NMNDiscDNSServer, i); + + inet_ntop (AF_INET6, &dns_server->address, addrstr, sizeof (addrstr)); + _LOGD (" dns_server %s exp %u", addrstr, expiry (dns_server)); + } + for (i = 0; i < rdata->dns_domains->len; i++) { + NMNDiscDNSDomain *dns_domain = &g_array_index (rdata->dns_domains, NMNDiscDNSDomain, i); + + _LOGD (" dns_domain %s exp %u", dns_domain->domain, expiry (dns_domain)); + } +} + +static void +clean_gateways (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap *changed, guint32 *nextevent) +{ + NMNDiscDataInternal *rdata; + guint i; + + rdata = &NM_NDISC_GET_PRIVATE (ndisc)->rdata; + + for (i = 0; i < rdata->gateways->len; i++) { + NMNDiscGateway *item = &g_array_index (rdata->gateways, NMNDiscGateway, i); + guint64 expiry = (guint64) item->timestamp + item->lifetime; + + if (item->lifetime == G_MAXUINT32) + continue; + + if (now >= expiry) { + g_array_remove_index (rdata->gateways, i--); + *changed |= NM_NDISC_CONFIG_GATEWAYS; + } else if (*nextevent > expiry) + *nextevent = expiry; + } +} + +static void +clean_addresses (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap *changed, guint32 *nextevent) +{ + NMNDiscDataInternal *rdata; + guint i; + + rdata = &NM_NDISC_GET_PRIVATE (ndisc)->rdata; + + for (i = 0; i < rdata->addresses->len; i++) { + NMNDiscAddress *item = &g_array_index (rdata->addresses, NMNDiscAddress, i); + guint64 expiry = (guint64) item->timestamp + item->lifetime; + + if (item->lifetime == G_MAXUINT32) + continue; + + if (now >= expiry) { + g_array_remove_index (rdata->addresses, i--); + *changed |= NM_NDISC_CONFIG_ADDRESSES; + } else if (*nextevent > expiry) + *nextevent = expiry; + } +} + +static void +clean_routes (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap *changed, guint32 *nextevent) +{ + NMNDiscDataInternal *rdata; + guint i; + + rdata = &NM_NDISC_GET_PRIVATE (ndisc)->rdata; + + for (i = 0; i < rdata->routes->len; i++) { + NMNDiscRoute *item = &g_array_index (rdata->routes, NMNDiscRoute, i); + guint64 expiry = (guint64) item->timestamp + item->lifetime; + + if (item->lifetime == G_MAXUINT32) + continue; + + if (now >= expiry) { + g_array_remove_index (rdata->routes, i--); + *changed |= NM_NDISC_CONFIG_ROUTES; + } else if (*nextevent > expiry) + *nextevent = expiry; + } +} + +static void +clean_dns_servers (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap *changed, guint32 *nextevent) +{ + NMNDiscDataInternal *rdata; + guint i; + + rdata = &NM_NDISC_GET_PRIVATE (ndisc)->rdata; + + for (i = 0; i < rdata->dns_servers->len; i++) { + NMNDiscDNSServer *item = &g_array_index (rdata->dns_servers, NMNDiscDNSServer, i); + guint64 expiry = (guint64) item->timestamp + item->lifetime; + guint64 refresh = (guint64) item->timestamp + item->lifetime / 2; + + if (item->lifetime == G_MAXUINT32) + continue; + + if (now >= expiry) { + g_array_remove_index (rdata->dns_servers, i--); + *changed |= NM_NDISC_CONFIG_DNS_SERVERS; + } else if (now >= refresh) + solicit_routers (ndisc); + else if (*nextevent > refresh) + *nextevent = refresh; + } +} + +static void +clean_dns_domains (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap *changed, guint32 *nextevent) +{ + NMNDiscDataInternal *rdata; + guint i; + + rdata = &NM_NDISC_GET_PRIVATE (ndisc)->rdata; + + for (i = 0; i < rdata->dns_domains->len; i++) { + NMNDiscDNSDomain *item = &g_array_index (rdata->dns_domains, NMNDiscDNSDomain, i); + guint64 expiry = (guint64) item->timestamp + item->lifetime; + guint64 refresh = (guint64) item->timestamp + item->lifetime / 2; + + if (item->lifetime == G_MAXUINT32) + continue; + + if (now >= expiry) { + g_array_remove_index (rdata->dns_domains, i--); + *changed |= NM_NDISC_CONFIG_DNS_DOMAINS; + } else if (now >= refresh) + solicit_routers (ndisc); + else if (*nextevent > refresh) + *nextevent = refresh; + } +} + +static gboolean timeout_cb (gpointer user_data); + +static void +check_timestamps (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap changed) +{ + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + /* Use a magic date in the distant future (~68 years) */ + guint32 never = G_MAXINT32; + guint32 nextevent = never; + + nm_clear_g_source (&priv->timeout_id); + + clean_gateways (ndisc, now, &changed, &nextevent); + clean_addresses (ndisc, now, &changed, &nextevent); + clean_routes (ndisc, now, &changed, &nextevent); + clean_dns_servers (ndisc, now, &changed, &nextevent); + clean_dns_domains (ndisc, now, &changed, &nextevent); + + if (changed) + _emit_config_change (ndisc, changed); + + if (nextevent != never) { + g_return_if_fail (nextevent > now); + _LOGD ("scheduling next now/lifetime check: %u seconds", + nextevent - now); + priv->timeout_id = g_timeout_add_seconds (nextevent - now, timeout_cb, ndisc); + } +} + +static gboolean +timeout_cb (gpointer user_data) +{ + NMNDisc *self = user_data; + + NM_NDISC_GET_PRIVATE (self)->timeout_id = 0; + check_timestamps (self, nm_utils_get_monotonic_timestamp_s (), 0); + return G_SOURCE_REMOVE; +} + +void +nm_ndisc_ra_received (NMNDisc *ndisc, guint32 now, NMNDiscConfigMap changed) +{ + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + + nm_clear_g_source (&priv->ra_timeout_id); + nm_clear_g_source (&priv->send_rs_id); + g_clear_pointer (&priv->last_error, g_free); + check_timestamps (ndisc, now, changed); +} + +void +nm_ndisc_rs_received (NMNDisc *ndisc) +{ + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + + g_clear_pointer (&priv->last_error, g_free); + announce_router_solicited (ndisc); +} + +/*****************************************************************************/ + +static void +dns_domain_free (gpointer data) +{ + g_free (((NMNDiscDNSDomain *)(data))->domain); +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMNDisc *self = NM_NDISC (object); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_PLATFORM: + /* construct-only */ + priv->platform = g_value_get_object (value) ? : NM_PLATFORM_GET; + if (!priv->platform) + g_return_if_reached (); + + g_object_ref (priv->platform); + + priv->netns = nm_platform_netns_get (priv->platform); + if (priv->netns) + g_object_ref (priv->netns); + + g_return_if_fail (!priv->netns || priv->netns == nmp_netns_get_current ()); + break; + case PROP_IFINDEX: + /* construct-only */ + priv->ifindex = g_value_get_int (value); + g_return_if_fail (priv->ifindex > 0); + break; + case PROP_IFNAME: + /* construct-only */ + priv->ifname = g_value_dup_string (value); + g_return_if_fail (priv->ifname && priv->ifname[0]); + break; + case PROP_STABLE_TYPE: + /* construct-only */ + priv->stable_type = g_value_get_int (value); + break; + case PROP_NETWORK_ID: + /* construct-only */ + priv->network_id = g_value_dup_string (value); + g_return_if_fail (priv->network_id); + break; + case PROP_ADDR_GEN_MODE: + /* construct-only */ + priv->addr_gen_mode = g_value_get_int (value); + break; + case PROP_MAX_ADDRESSES: + /* construct-only */ + priv->max_addresses = g_value_get_int (value); + break; + case PROP_ROUTER_SOLICITATIONS: + /* construct-only */ + priv->router_solicitations = g_value_get_int (value); + break; + case PROP_ROUTER_SOLICITATION_INTERVAL: + /* construct-only */ + priv->router_solicitation_interval = g_value_get_int (value); + break; + case PROP_NODE_TYPE: + /* construct-only */ + priv->node_type = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_ndisc_init (NMNDisc *ndisc) +{ + NMNDiscPrivate *priv; + NMNDiscDataInternal *rdata; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (ndisc, NM_TYPE_NDISC, NMNDiscPrivate); + ndisc->_priv = priv; + + rdata = &priv->rdata; + + rdata->gateways = g_array_new (FALSE, FALSE, sizeof (NMNDiscGateway)); + rdata->addresses = g_array_new (FALSE, FALSE, sizeof (NMNDiscAddress)); + rdata->routes = g_array_new (FALSE, FALSE, sizeof (NMNDiscRoute)); + rdata->dns_servers = g_array_new (FALSE, FALSE, sizeof (NMNDiscDNSServer)); + rdata->dns_domains = g_array_new (FALSE, FALSE, sizeof (NMNDiscDNSDomain)); + g_array_set_clear_func (rdata->dns_domains, dns_domain_free); + priv->rdata.public.hop_limit = 64; + + /* Start at very low number so that last_rs - router_solicitation_interval + * is much lower than nm_utils_get_monotonic_timestamp_s() at startup. + */ + priv->last_rs = G_MININT32; +} + +static void +dispose (GObject *object) +{ + NMNDisc *ndisc = NM_NDISC (object); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + + nm_clear_g_source (&priv->ra_timeout_id); + nm_clear_g_source (&priv->send_rs_id); + nm_clear_g_source (&priv->send_ra_id); + g_clear_pointer (&priv->last_error, g_free); + + nm_clear_g_source (&priv->timeout_id); + + G_OBJECT_CLASS (nm_ndisc_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + NMNDisc *ndisc = NM_NDISC (object); + NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc); + NMNDiscDataInternal *rdata = &priv->rdata; + + g_free (priv->ifname); + g_free (priv->network_id); + + g_array_unref (rdata->gateways); + g_array_unref (rdata->addresses); + g_array_unref (rdata->routes); + g_array_unref (rdata->dns_servers); + g_array_unref (rdata->dns_domains); + + g_clear_object (&priv->netns); + g_clear_object (&priv->platform); + + G_OBJECT_CLASS (nm_ndisc_parent_class)->finalize (object); +} + +static void +nm_ndisc_class_init (NMNDiscClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (NMNDiscPrivate)); + + object_class->set_property = set_property; + object_class->dispose = dispose; + object_class->finalize = finalize; + + obj_properties[PROP_PLATFORM] = + g_param_spec_object (NM_NDISC_PLATFORM, "", "", + NM_TYPE_PLATFORM, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_IFINDEX] = + g_param_spec_int (NM_NDISC_IFINDEX, "", "", + 0, G_MAXINT, 0, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_IFNAME] = + g_param_spec_string (NM_NDISC_IFNAME, "", "", + NULL, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_STABLE_TYPE] = + g_param_spec_int (NM_NDISC_STABLE_TYPE, "", "", + NM_UTILS_STABLE_TYPE_UUID, NM_UTILS_STABLE_TYPE_RANDOM, NM_UTILS_STABLE_TYPE_UUID, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_NETWORK_ID] = + g_param_spec_string (NM_NDISC_NETWORK_ID, "", "", + NULL, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_ADDR_GEN_MODE] = + g_param_spec_int (NM_NDISC_ADDR_GEN_MODE, "", "", + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_MAX_ADDRESSES] = + g_param_spec_int (NM_NDISC_MAX_ADDRESSES, "", "", + 0, G_MAXINT32, NM_NDISC_MAX_ADDRESSES_DEFAULT, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_ROUTER_SOLICITATIONS] = + g_param_spec_int (NM_NDISC_ROUTER_SOLICITATIONS, "", "", + 1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_ROUTER_SOLICITATION_INTERVAL] = + g_param_spec_int (NM_NDISC_ROUTER_SOLICITATION_INTERVAL, "", "", + 1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATION_INTERVAL_DEFAULT, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_NODE_TYPE] = + g_param_spec_int (NM_NDISC_NODE_TYPE, "", "", + NM_NDISC_NODE_TYPE_INVALID, NM_NDISC_NODE_TYPE_ROUTER, NM_NDISC_NODE_TYPE_INVALID, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + signals[CONFIG_CHANGED] = + g_signal_new (NM_NDISC_CONFIG_RECEIVED, + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT); + signals[RA_TIMEOUT] = + g_signal_new (NM_NDISC_RA_TIMEOUT, + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 0); +} diff --git a/src/ndisc/nm-ndisc.h b/src/ndisc/nm-ndisc.h new file mode 100644 index 00000000..7c67289d --- /dev/null +++ b/src/ndisc/nm-ndisc.h @@ -0,0 +1,189 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-ndisc.h - Perform IPv6 neighbor discovery + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_NDISC_H__ +#define __NETWORKMANAGER_NDISC_H__ + +#include +#include + +#include "nm-setting-ip6-config.h" +#include "NetworkManagerUtils.h" + +#define NM_TYPE_NDISC (nm_ndisc_get_type ()) +#define NM_NDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_NDISC, NMNDisc)) +#define NM_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_NDISC, NMNDiscClass)) +#define NM_IS_NDISC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_NDISC)) +#define NM_IS_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_NDISC)) +#define NM_NDISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_NDISC, NMNDiscClass)) + +#define NM_NDISC_PLATFORM "platform" +#define NM_NDISC_IFINDEX "ifindex" +#define NM_NDISC_IFNAME "ifname" +#define NM_NDISC_NETWORK_ID "network-id" +#define NM_NDISC_ADDR_GEN_MODE "addr-gen-mode" +#define NM_NDISC_STABLE_TYPE "stable-type" +#define NM_NDISC_NODE_TYPE "node-type" +#define NM_NDISC_MAX_ADDRESSES "max-addresses" +#define NM_NDISC_ROUTER_SOLICITATIONS "router-solicitations" +#define NM_NDISC_ROUTER_SOLICITATION_INTERVAL "router-solicitation-interval" + +#define NM_NDISC_CONFIG_RECEIVED "config-received" +#define NM_NDISC_RA_TIMEOUT "ra-timeout" + +typedef enum { + NM_NDISC_DHCP_LEVEL_UNKNOWN, + NM_NDISC_DHCP_LEVEL_NONE, + NM_NDISC_DHCP_LEVEL_OTHERCONF, + NM_NDISC_DHCP_LEVEL_MANAGED +} NMNDiscDHCPLevel; + +typedef enum { + NM_NDISC_PREFERENCE_INVALID, + NM_NDISC_PREFERENCE_LOW, + NM_NDISC_PREFERENCE_MEDIUM, + NM_NDISC_PREFERENCE_HIGH +} NMNDiscPreference; + +typedef struct { + struct in6_addr address; + guint32 timestamp; + guint32 lifetime; + NMNDiscPreference preference; +} NMNDiscGateway; + +typedef struct { + struct in6_addr address; + guint8 dad_counter; + guint32 timestamp; + guint32 lifetime; + guint32 preferred; +} NMNDiscAddress; + +typedef struct { + struct in6_addr network; + guint8 plen; + struct in6_addr gateway; + guint32 timestamp; + guint32 lifetime; + NMNDiscPreference preference; +} NMNDiscRoute; + +typedef struct { + struct in6_addr address; + guint32 timestamp; + guint32 lifetime; +} NMNDiscDNSServer; + +typedef struct { + char *domain; + guint32 timestamp; + guint32 lifetime; +} NMNDiscDNSDomain; + +typedef enum { + NM_NDISC_CONFIG_DHCP_LEVEL = 1 << 0, + NM_NDISC_CONFIG_GATEWAYS = 1 << 1, + NM_NDISC_CONFIG_ADDRESSES = 1 << 2, + NM_NDISC_CONFIG_ROUTES = 1 << 3, + NM_NDISC_CONFIG_DNS_SERVERS = 1 << 4, + NM_NDISC_CONFIG_DNS_DOMAINS = 1 << 5, + NM_NDISC_CONFIG_HOP_LIMIT = 1 << 6, + NM_NDISC_CONFIG_MTU = 1 << 7, +} NMNDiscConfigMap; + +typedef enum { + NM_NDISC_NODE_TYPE_INVALID, + NM_NDISC_NODE_TYPE_HOST, + NM_NDISC_NODE_TYPE_ROUTER, +} NMNDiscNodeType; + +#define NM_NDISC_MAX_ADDRESSES_DEFAULT 16 +#define NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT 3 /* RFC4861 MAX_RTR_SOLICITATIONS */ +#define NM_NDISC_ROUTER_SOLICITATION_INTERVAL_DEFAULT 4 /* RFC4861 RTR_SOLICITATION_INTERVAL */ +#define NM_NDISC_ROUTER_ADVERTISEMENTS_DEFAULT 3 /* RFC4861 MAX_INITIAL_RTR_ADVERTISEMENTS */ +#define NM_NDISC_ROUTER_ADVERT_DELAY 3 /* RFC4861 MIN_DELAY_BETWEEN_RAS */ +#define NM_NDISC_ROUTER_ADVERT_INITIAL_INTERVAL 16 /* RFC4861 MAX_INITIAL_RTR_ADVERT_INTERVAL */ +#define NM_NDISC_ROUTER_ADVERT_DELAY_MS 500 /* RFC4861 MAX_RA_DELAY_TIME */ +#define NM_NDISC_ROUTER_ADVERT_MAX_INTERVAL 600 /* RFC4861 MaxRtrAdvInterval default */ +#define NM_NDISC_ROUTER_LIFETIME 900 /* 1.5 * NM_NDISC_ROUTER_ADVERT_MAX_INTERVAL */ + +struct _NMNDiscPrivate; +struct _NMNDiscDataInternal; + +typedef struct { + NMNDiscDHCPLevel dhcp_level; + guint32 mtu; + int hop_limit; + + guint gateways_n; + guint addresses_n; + guint routes_n; + guint dns_servers_n; + guint dns_domains_n; + + const NMNDiscGateway *gateways; + const NMNDiscAddress *addresses; + const NMNDiscRoute *routes; + const NMNDiscDNSServer *dns_servers; + const NMNDiscDNSDomain *dns_domains; +} NMNDiscData; + +/** + * NMNDisc: + * + * Interface-specific structure that handles incoming router advertisements, + * caches advertised items and removes them when they are obsolete. + */ +typedef struct { + GObject parent; + union { + struct _NMNDiscPrivate *_priv; + struct _NMNDiscDataInternal *rdata; + }; +} NMNDisc; + +typedef struct { + GObjectClass parent; + + void (*start) (NMNDisc *ndisc); + gboolean (*send_rs) (NMNDisc *ndisc, GError **error); + gboolean (*send_ra) (NMNDisc *ndisc, GError **error); +} NMNDiscClass; + +GType nm_ndisc_get_type (void); + +int nm_ndisc_get_ifindex (NMNDisc *self); +const char *nm_ndisc_get_ifname (NMNDisc *self); +NMNDiscNodeType nm_ndisc_get_node_type (NMNDisc *self); + +gboolean nm_ndisc_set_iid (NMNDisc *ndisc, const NMUtilsIPv6IfaceId iid); +void nm_ndisc_start (NMNDisc *ndisc); +void nm_ndisc_dad_failed (NMNDisc *ndisc, struct in6_addr *address); +void nm_ndisc_set_config (NMNDisc *ndisc, + const GArray *addresses, + const GArray *dns_servers, + const GArray *dns_domains); + +NMPlatform *nm_ndisc_get_platform (NMNDisc *self); +NMPNetns *nm_ndisc_netns_get (NMNDisc *self); +gboolean nm_ndisc_netns_push (NMNDisc *self, NMPNetns **netns); + +#endif /* __NETWORKMANAGER_NDISC_H__ */ diff --git a/src/ndisc/tests/test-ndisc-fake.c b/src/ndisc/tests/test-ndisc-fake.c new file mode 100644 index 00000000..006aea7f --- /dev/null +++ b/src/ndisc/tests/test-ndisc-fake.c @@ -0,0 +1,483 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* ndisc.c - test program + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2015 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include +#include + +#include "ndisc/nm-ndisc.h" +#include "ndisc/nm-fake-ndisc.h" + +#include "platform/nm-fake-platform.h" + +#include "nm-test-utils-core.h" + +static NMFakeNDisc * +ndisc_new (void) +{ + NMNDisc *ndisc; + const int ifindex = 1; + const char *ifname = nm_platform_link_get_name (NM_PLATFORM_GET, ifindex); + NMUtilsIPv6IfaceId iid = { }; + + ndisc = nm_fake_ndisc_new (ifindex, ifname); + iid.id_u8[7] = 1; + nm_ndisc_set_iid (ndisc, iid); + g_assert (ndisc); + return NM_FAKE_NDISC (ndisc); +} + +static void +match_gateway (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt, NMNDiscPreference pref) +{ + const NMNDiscGateway *gw; + char buf[INET6_ADDRSTRLEN]; + + g_assert (rdata); + g_assert_cmpint (idx, <, rdata->gateways_n); + g_assert (rdata->gateways); + + gw = &rdata->gateways[idx]; + + g_assert_cmpstr (inet_ntop (AF_INET6, &gw->address, buf, sizeof (buf)), ==, addr); + g_assert_cmpint (gw->timestamp, ==, ts); + g_assert_cmpint (gw->lifetime, ==, lt); + g_assert_cmpint (gw->preference, ==, pref); +} + +static void +match_address (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt, guint32 preferred) +{ + const NMNDiscAddress *a; + char buf[INET6_ADDRSTRLEN]; + + g_assert (rdata); + g_assert_cmpint (idx, <, rdata->addresses_n); + g_assert (rdata->addresses); + + a = &rdata->addresses[idx]; + + g_assert_cmpstr (inet_ntop (AF_INET6, &a->address, buf, sizeof (buf)), ==, addr); + g_assert_cmpint (a->timestamp, ==, ts); + g_assert_cmpint (a->lifetime, ==, lt); + g_assert_cmpint (a->preferred, ==, preferred); +} + +static void +match_route (const NMNDiscData *rdata, guint idx, const char *nw, int plen, const char *gw, guint32 ts, guint32 lt, NMNDiscPreference pref) +{ + const NMNDiscRoute *route; + char buf[INET6_ADDRSTRLEN]; + + g_assert (rdata); + g_assert_cmpint (idx, <, rdata->routes_n); + g_assert (rdata->routes); + g_assert (plen > 0 && plen <= 128); + + route = &rdata->routes[idx]; + + g_assert_cmpstr (inet_ntop (AF_INET6, &route->network, buf, sizeof (buf)), ==, nw); + g_assert_cmpint ((int) route->plen, ==, plen); + g_assert_cmpstr (inet_ntop (AF_INET6, &route->gateway, buf, sizeof (buf)), ==, gw); + g_assert_cmpint (route->timestamp, ==, ts); + g_assert_cmpint (route->lifetime, ==, lt); + g_assert_cmpint (route->preference, ==, pref); +} + +static void +match_dns_server (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt) +{ + const NMNDiscDNSServer *dns; + char buf[INET6_ADDRSTRLEN]; + + g_assert (rdata); + g_assert_cmpint (idx, <, rdata->dns_servers_n); + g_assert (rdata->dns_servers); + + dns = &rdata->dns_servers[idx]; + + g_assert_cmpstr (inet_ntop (AF_INET6, &dns->address, buf, sizeof (buf)), ==, addr); + g_assert_cmpint (dns->timestamp, ==, ts); + g_assert_cmpint (dns->lifetime, ==, lt); +} + +static void +match_dns_domain (const NMNDiscData *rdata, guint idx, const char *domain, guint32 ts, guint32 lt) +{ + const NMNDiscDNSDomain *dns; + + g_assert (rdata); + g_assert_cmpint (idx, <, rdata->dns_domains_n); + g_assert (rdata->dns_domains); + + dns = &rdata->dns_domains[idx]; + + g_assert_cmpstr (dns->domain, ==, domain); + g_assert_cmpint (dns->timestamp, ==, ts); + g_assert_cmpint (dns->lifetime, ==, lt); +} + +typedef struct { + GMainLoop *loop; + guint counter; + guint rs_counter; + guint32 timestamp1; + guint32 first_solicit; + guint32 timeout_id; +} TestData; + +static void +test_simple_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, TestData *data) +{ + NMNDiscConfigMap changed = changed_int; + + g_assert_cmpint (changed, ==, NM_NDISC_CONFIG_DHCP_LEVEL | + NM_NDISC_CONFIG_GATEWAYS | + NM_NDISC_CONFIG_ADDRESSES | + NM_NDISC_CONFIG_ROUTES | + NM_NDISC_CONFIG_DNS_SERVERS | + NM_NDISC_CONFIG_DNS_DOMAINS | + NM_NDISC_CONFIG_HOP_LIMIT | + NM_NDISC_CONFIG_MTU); + g_assert_cmpint (rdata->dhcp_level, ==, NM_NDISC_DHCP_LEVEL_OTHERCONF); + match_gateway (rdata, 0, "fe80::1", data->timestamp1, 10, NM_NDISC_PREFERENCE_MEDIUM); + match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1, 10, 10); + match_route (rdata, 0, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1, 10, 10); + match_dns_server (rdata, 0, "2001:db8:c:c::1", data->timestamp1, 10); + match_dns_domain (rdata, 0, "foobar.com", data->timestamp1, 10); + + g_assert (nm_fake_ndisc_done (NM_FAKE_NDISC (ndisc))); + data->counter++; + g_main_loop_quit (data->loop); +} + +static void +test_simple (void) +{ + NMFakeNDisc *ndisc = ndisc_new (); + guint32 now = nm_utils_get_monotonic_timestamp_s (); + TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now }; + guint id; + + id = nm_fake_ndisc_add_ra (ndisc, 1, NM_NDISC_DHCP_LEVEL_OTHERCONF, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::1", now, 10, NM_NDISC_PREFERENCE_MEDIUM); + nm_fake_ndisc_add_prefix (ndisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 10); + nm_fake_ndisc_add_dns_server (ndisc, id, "2001:db8:c:c::1", now, 10); + nm_fake_ndisc_add_dns_domain (ndisc, id, "foobar.com", now, 10); + + g_signal_connect (ndisc, + NM_NDISC_CONFIG_RECEIVED, + G_CALLBACK (test_simple_changed), + &data); + + nm_ndisc_start (NM_NDISC (ndisc)); + g_main_loop_run (data.loop); + g_assert_cmpint (data.counter, ==, 1); + + g_object_unref (ndisc); + g_main_loop_unref (data.loop); +} + +static void +test_everything_rs_sent (NMNDisc *ndisc, TestData *data) +{ + g_assert_cmpint (data->rs_counter, ==, 0); + data->rs_counter++; +} + +static void +test_everything_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, TestData *data) +{ + NMNDiscConfigMap changed = changed_int; + + if (data->counter == 0) { + g_assert_cmpint (data->rs_counter, ==, 1); + g_assert_cmpint (changed, ==, NM_NDISC_CONFIG_DHCP_LEVEL | + NM_NDISC_CONFIG_GATEWAYS | + NM_NDISC_CONFIG_ADDRESSES | + NM_NDISC_CONFIG_ROUTES | + NM_NDISC_CONFIG_DNS_SERVERS | + NM_NDISC_CONFIG_DNS_DOMAINS | + NM_NDISC_CONFIG_HOP_LIMIT | + NM_NDISC_CONFIG_MTU); + match_gateway (rdata, 0, "fe80::1", data->timestamp1, 10, NM_NDISC_PREFERENCE_MEDIUM); + match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1, 10, 10); + match_route (rdata, 0, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1, 10, 10); + match_dns_server (rdata, 0, "2001:db8:c:c::1", data->timestamp1, 10); + match_dns_domain (rdata, 0, "foobar.com", data->timestamp1, 10); + } else if (data->counter == 1) { + g_assert_cmpint (changed, ==, NM_NDISC_CONFIG_GATEWAYS | + NM_NDISC_CONFIG_ADDRESSES | + NM_NDISC_CONFIG_ROUTES | + NM_NDISC_CONFIG_DNS_SERVERS | + NM_NDISC_CONFIG_DNS_DOMAINS); + + g_assert_cmpint (rdata->gateways_n, ==, 1); + match_gateway (rdata, 0, "fe80::2", data->timestamp1, 10, NM_NDISC_PREFERENCE_MEDIUM); + g_assert_cmpint (rdata->addresses_n, ==, 1); + match_address (rdata, 0, "2001:db8:a:b::1", data->timestamp1, 10, 10); + g_assert_cmpint (rdata->routes_n, ==, 1); + match_route (rdata, 0, "2001:db8:a:b::", 64, "fe80::2", data->timestamp1, 10, 10); + g_assert_cmpint (rdata->dns_servers_n, ==, 1); + match_dns_server (rdata, 0, "2001:db8:c:c::2", data->timestamp1, 10); + g_assert_cmpint (rdata->dns_domains_n, ==, 1); + match_dns_domain (rdata, 0, "foobar2.com", data->timestamp1, 10); + + g_assert (nm_fake_ndisc_done (NM_FAKE_NDISC (ndisc))); + g_main_loop_quit (data->loop); + } else + g_assert_not_reached (); + + data->counter++; +} + +static void +test_everything (void) +{ + NMFakeNDisc *ndisc = ndisc_new (); + guint32 now = nm_utils_get_monotonic_timestamp_s (); + TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now }; + guint id; + + id = nm_fake_ndisc_add_ra (ndisc, 1, NM_NDISC_DHCP_LEVEL_NONE, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::1", now, 10, NM_NDISC_PREFERENCE_MEDIUM); + nm_fake_ndisc_add_prefix (ndisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 10); + nm_fake_ndisc_add_dns_server (ndisc, id, "2001:db8:c:c::1", now, 10); + nm_fake_ndisc_add_dns_domain (ndisc, id, "foobar.com", now, 10); + + /* expire everything from the first RA in the second */ + id = nm_fake_ndisc_add_ra (ndisc, 1, NM_NDISC_DHCP_LEVEL_NONE, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::1", now, 0, NM_NDISC_PREFERENCE_MEDIUM); + nm_fake_ndisc_add_prefix (ndisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 0, 0, 0); + nm_fake_ndisc_add_dns_server (ndisc, id, "2001:db8:c:c::1", now, 0); + nm_fake_ndisc_add_dns_domain (ndisc, id, "foobar.com", now, 0); + + /* and add some new stuff */ + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::2", now, 10, NM_NDISC_PREFERENCE_MEDIUM); + nm_fake_ndisc_add_prefix (ndisc, id, "2001:db8:a:b::", 64, "fe80::2", now, 10, 10, 10); + nm_fake_ndisc_add_dns_server (ndisc, id, "2001:db8:c:c::2", now, 10); + nm_fake_ndisc_add_dns_domain (ndisc, id, "foobar2.com", now, 10); + + g_signal_connect (ndisc, + NM_NDISC_CONFIG_RECEIVED, + G_CALLBACK (test_everything_changed), + &data); + g_signal_connect (ndisc, + NM_FAKE_NDISC_RS_SENT, + G_CALLBACK (test_everything_rs_sent), + &data); + + nm_ndisc_start (NM_NDISC (ndisc)); + g_main_loop_run (data.loop); + g_assert_cmpint (data.counter, ==, 2); + g_assert_cmpint (data.rs_counter, ==, 1); + + g_object_unref (ndisc); + g_main_loop_unref (data.loop); +} + +static void +test_preference_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, TestData *data) +{ + NMNDiscConfigMap changed = changed_int; + + if (data->counter == 1) { + g_assert_cmpint (changed, ==, NM_NDISC_CONFIG_GATEWAYS | + NM_NDISC_CONFIG_ADDRESSES | + NM_NDISC_CONFIG_ROUTES); + g_assert_cmpint (rdata->gateways_n, ==, 2); + match_gateway (rdata, 0, "fe80::2", data->timestamp1 + 1, 10, NM_NDISC_PREFERENCE_MEDIUM); + match_gateway (rdata, 1, "fe80::1", data->timestamp1, 10, NM_NDISC_PREFERENCE_LOW); + g_assert_cmpint (rdata->addresses_n, ==, 2); + match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1, 10, 10); + match_address (rdata, 1, "2001:db8:a:b::1", data->timestamp1 + 1, 10, 10); + g_assert_cmpint (rdata->routes_n, ==, 2); + match_route (rdata, 0, "2001:db8:a:b::", 64, "fe80::2", data->timestamp1 + 1, 10, 10); + match_route (rdata, 1, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1, 10, 5); + } else if (data->counter == 2) { + g_assert_cmpint (changed, ==, NM_NDISC_CONFIG_GATEWAYS | + NM_NDISC_CONFIG_ADDRESSES | + NM_NDISC_CONFIG_ROUTES); + + g_assert_cmpint (rdata->gateways_n, ==, 2); + match_gateway (rdata, 0, "fe80::1", data->timestamp1 + 2, 10, NM_NDISC_PREFERENCE_HIGH); + match_gateway (rdata, 1, "fe80::2", data->timestamp1 + 1, 10, NM_NDISC_PREFERENCE_MEDIUM); + g_assert_cmpint (rdata->addresses_n, ==, 2); + match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1 + 2, 10, 10); + match_address (rdata, 1, "2001:db8:a:b::1", data->timestamp1 + 1, 10, 10); + g_assert_cmpint (rdata->routes_n, ==, 2); + match_route (rdata, 0, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1 + 2, 10, 15); + match_route (rdata, 1, "2001:db8:a:b::", 64, "fe80::2", data->timestamp1 + 1, 10, 10); + + g_assert (nm_fake_ndisc_done (NM_FAKE_NDISC (ndisc))); + g_main_loop_quit (data->loop); + } + + data->counter++; +} + +static void +test_preference (void) +{ + NMFakeNDisc *ndisc = ndisc_new (); + guint32 now = nm_utils_get_monotonic_timestamp_s (); + TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now }; + guint id; + + /* Test that when a low-preference and medium gateway send advertisements, + * that if the low-preference gateway switches to high-preference, we do + * not get duplicates in the gateway list. + */ + + id = nm_fake_ndisc_add_ra (ndisc, 1, NM_NDISC_DHCP_LEVEL_NONE, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::1", now, 10, NM_NDISC_PREFERENCE_LOW); + nm_fake_ndisc_add_prefix (ndisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 5); + + id = nm_fake_ndisc_add_ra (ndisc, 1, NM_NDISC_DHCP_LEVEL_NONE, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::2", ++now, 10, NM_NDISC_PREFERENCE_MEDIUM); + nm_fake_ndisc_add_prefix (ndisc, id, "2001:db8:a:b::", 64, "fe80::2", now, 10, 10, 10); + + id = nm_fake_ndisc_add_ra (ndisc, 1, NM_NDISC_DHCP_LEVEL_NONE, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::1", ++now, 10, NM_NDISC_PREFERENCE_HIGH); + nm_fake_ndisc_add_prefix (ndisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 15); + + g_signal_connect (ndisc, + NM_NDISC_CONFIG_RECEIVED, + G_CALLBACK (test_preference_changed), + &data); + + nm_ndisc_start (NM_NDISC (ndisc)); + g_main_loop_run (data.loop); + g_assert_cmpint (data.counter, ==, 3); + + g_object_unref (ndisc); + g_main_loop_unref (data.loop); +} + +static void +test_dns_solicit_loop_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, TestData *data) +{ + data->counter++; +} + +static gboolean +success_timeout (TestData *data) +{ + data->timeout_id = 0; + g_main_loop_quit (data->loop); + return G_SOURCE_REMOVE; +} + +static void +test_dns_solicit_loop_rs_sent (NMFakeNDisc *ndisc, TestData *data) +{ + guint32 now = nm_utils_get_monotonic_timestamp_s (); + guint id; + + if (data->rs_counter > 0 && data->rs_counter < 6) { + if (data->rs_counter == 1) { + data->first_solicit = now; + /* Kill the test after 10 seconds if it hasn't failed yet */ + data->timeout_id = g_timeout_add_seconds (10, (GSourceFunc) success_timeout, data); + } + + /* On all but the first solicitation, which should be triggered by the + * DNS servers reaching 1/2 lifetime, emit a new RA without the DNS + * servers again. + */ + id = nm_fake_ndisc_add_ra (ndisc, 0, NM_NDISC_DHCP_LEVEL_NONE, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::1", now, 10, NM_NDISC_PREFERENCE_MEDIUM); + + nm_fake_ndisc_emit_new_ras (ndisc); + } else if (data->rs_counter >= 6) { + /* Fail if we've sent too many solicitations in the past 4 seconds */ + g_assert_cmpint (now - data->first_solicit, >, 4); + g_source_remove (data->timeout_id); + g_main_loop_quit (data->loop); + } + data->rs_counter++; +} + +static void +test_dns_solicit_loop (void) +{ + NMFakeNDisc *ndisc = ndisc_new (); + guint32 now = nm_utils_get_monotonic_timestamp_s (); + TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now, 0 }; + guint id; + + /* Ensure that no solicitation loop happens when DNS servers or domains + * stop being sent in advertisements. This can happen if two routers + * send RAs, but the one sending DNS info stops responding, or if one + * router removes the DNS info from the RA without zero-lifetiming them + * first. + */ + + id = nm_fake_ndisc_add_ra (ndisc, 1, NM_NDISC_DHCP_LEVEL_NONE, 4, 1500); + g_assert (id); + nm_fake_ndisc_add_gateway (ndisc, id, "fe80::1", now, 10, NM_NDISC_PREFERENCE_LOW); + nm_fake_ndisc_add_dns_server (ndisc, id, "2001:db8:c:c::1", now, 6); + + g_signal_connect (ndisc, + NM_NDISC_CONFIG_RECEIVED, + G_CALLBACK (test_dns_solicit_loop_changed), + &data); + g_signal_connect (ndisc, + NM_FAKE_NDISC_RS_SENT, + G_CALLBACK (test_dns_solicit_loop_rs_sent), + &data); + + nm_ndisc_start (NM_NDISC (ndisc)); + g_main_loop_run (data.loop); + g_assert_cmpint (data.counter, ==, 3); + + g_object_unref (ndisc); + g_main_loop_unref (data.loop); +} + +NMTST_DEFINE (); + +int +main (int argc, char **argv) +{ + nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT"); + + if (nmtst_test_quick ()) { + g_print ("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", g_get_prgname () ?: "test-ndisc-fake"); + return g_test_run (); + } + + nm_fake_platform_setup (); + + g_test_add_func ("/ndisc/simple", test_simple); + g_test_add_func ("/ndisc/everything-changed", test_everything); + g_test_add_func ("/ndisc/preference-changed", test_preference); + g_test_add_func ("/ndisc/dns-solicit-loop", test_dns_solicit_loop); + + return g_test_run (); +} diff --git a/src/ndisc/tests/test-ndisc-linux.c b/src/ndisc/tests/test-ndisc-linux.c new file mode 100644 index 00000000..2764b6c0 --- /dev/null +++ b/src/ndisc/tests/test-ndisc-linux.c @@ -0,0 +1,86 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* ndisc.c - test program + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2013 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include +#include + +#include "ndisc/nm-ndisc.h" +#include "ndisc/nm-lndp-ndisc.h" + +#include "platform/nm-linux-platform.h" + +#include "nm-test-utils-core.h" + +NMTST_DEFINE (); + +int +main (int argc, char **argv) +{ + GMainLoop *loop; + NMNDisc *ndisc; + int ifindex = 1; + const char *ifname; + NMUtilsIPv6IfaceId iid = { }; + GError *error = NULL; + + nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT"); + + if (getuid () != 0) { + g_print ("Missing permission: must run as root\n"); + return EXIT_FAILURE; + } + + loop = g_main_loop_new (NULL, FALSE); + + nm_linux_platform_setup (); + + if (argv[1]) { + ifname = argv[1]; + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname); + } else { + g_print ("Missing command line argument \"interface-name\"\n"); + return EXIT_FAILURE; + } + + ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET, + ifindex, + ifname, + NM_UTILS_STABLE_TYPE_UUID, + "8ce666e8-d34d-4fb1-b858-f15a7al28086", + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + NM_NDISC_NODE_TYPE_HOST, + &error); + if (!ndisc) { + g_print ("Failed to create NMNDisc instance: %s\n", error->message); + g_error_free (error); + return EXIT_FAILURE; + } + + iid.id_u8[7] = 1; + nm_ndisc_set_iid (ndisc, iid); + nm_ndisc_start (ndisc); + g_main_loop_run (loop); + + g_clear_object (&ndisc); + + return EXIT_SUCCESS; +} diff --git a/src/nm-act-request.c b/src/nm-act-request.c new file mode 100644 index 00000000..3a04667b --- /dev/null +++ b/src/nm-act-request.c @@ -0,0 +1,606 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2012 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#include "nm-default.h" + +#include "nm-act-request.h" + +#include +#include +#include +#include + +#include "nm-setting-wireless-security.h" +#include "nm-setting-8021x.h" +#include "devices/nm-device.h" +#include "nm-active-connection.h" +#include "settings/nm-settings-connection.h" +#include "nm-auth-subject.h" + +typedef struct { + char *table; + char *rule; +} ShareRule; + +typedef struct { + GSList *secrets_calls; + gboolean shared; + GSList *share_rules; +} NMActRequestPrivate; + +struct _NMActRequest { + NMActiveConnection parent; + NMActRequestPrivate _priv; +}; + +typedef struct { + NMActiveConnectionClass parent; +} NMActRequestClass; + +enum { + PROP_0, + PROP_IP4_CONFIG, + PROP_DHCP4_CONFIG, + PROP_IP6_CONFIG, + PROP_DHCP6_CONFIG, + + LAST_PROP +}; + +G_DEFINE_TYPE (NMActRequest, nm_act_request, NM_TYPE_ACTIVE_CONNECTION) + +#define NM_ACT_REQUEST_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMActRequest, NM_IS_ACT_REQUEST) + +/*****************************************************************************/ + +NMSettingsConnection * +nm_act_request_get_settings_connection (NMActRequest *req) +{ + g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NULL); + + return nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (req)); +} + +NMConnection * +nm_act_request_get_applied_connection (NMActRequest *req) +{ + g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NULL); + + return nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (req)); +} + +/*****************************************************************************/ + +struct _NMActRequestGetSecretsCallId { + NMActRequest *self; + NMActRequestSecretsFunc callback; + gpointer callback_data; + NMSettingsConnectionCallId call_id; + bool has_ref; +}; + +typedef struct _NMActRequestGetSecretsCallId GetSecretsInfo; + +static GetSecretsInfo * +_get_secrets_info_new (NMActRequest *self, gboolean ref_self, NMActRequestSecretsFunc callback, gpointer callback_data) +{ + GetSecretsInfo *info; + + info = g_slice_new0 (GetSecretsInfo); + info->has_ref = ref_self; + info->self = ref_self ? g_object_ref (self) : self; + info->callback = callback; + info->callback_data = callback_data; + + return info; +} + +static void +_get_secrets_info_free (GetSecretsInfo *info) +{ + if (info->has_ref) + g_object_unref (info->self); + g_slice_free (GetSecretsInfo, info); +} + +static void +get_secrets_cb (NMSettingsConnection *connection, + NMSettingsConnectionCallId call_id_s, + const char *agent_username, + const char *setting_name, + GError *error, + gpointer user_data) +{ + GetSecretsInfo *info = user_data; + NMActRequestPrivate *priv; + + g_return_if_fail (info && info->call_id == call_id_s); + g_return_if_fail (NM_IS_ACT_REQUEST (info->self)); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + priv = NM_ACT_REQUEST_GET_PRIVATE (info->self); + + g_return_if_fail (g_slist_find (priv->secrets_calls, info)); + + priv->secrets_calls = g_slist_remove (priv->secrets_calls, info); + + if (info->callback) + info->callback (info->self, info, connection, error, info->callback_data); + + _get_secrets_info_free (info); +} + +/** + * nm_act_request_get_secrets: + * @self: + * @ref_self: if %TRUE, the pending call take a reference on @self. + * It also allows you to omit the @self argument in nm_act_request_cancel_secrets(). + * @setting_name: + * @flags: + * @hint: + * @callback: + * @callback_data: + * + * Asnychronously starts the request for secrets. This function cannot + * fail. + * + * The return call-id can be used to cancel the request. You are + * only allowed to cancel a still pending operation (once). + * The callback will always be invoked once, even for canceling + * or disposing of NMActRequest. + * + * Returns: a call-id. + */ +NMActRequestGetSecretsCallId +nm_act_request_get_secrets (NMActRequest *self, + gboolean ref_self, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags, + const char *hint, + NMActRequestSecretsFunc callback, + gpointer callback_data) +{ + NMActRequestPrivate *priv; + GetSecretsInfo *info; + NMSettingsConnectionCallId call_id_s; + NMSettingsConnection *settings_connection; + NMConnection *applied_connection; + const char *hints[2] = { hint, NULL }; + + g_return_val_if_fail (NM_IS_ACT_REQUEST (self), NULL); + + priv = NM_ACT_REQUEST_GET_PRIVATE (self); + + settings_connection = nm_act_request_get_settings_connection (self); + applied_connection = nm_act_request_get_applied_connection (self); + + info = _get_secrets_info_new (self, ref_self, callback, callback_data); + + priv->secrets_calls = g_slist_append (priv->secrets_calls, info); + + if (nm_active_connection_get_user_requested (NM_ACTIVE_CONNECTION (self))) + flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED; + + call_id_s = nm_settings_connection_get_secrets (settings_connection, + applied_connection, + nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (self)), + setting_name, + flags, + hints, + get_secrets_cb, + info); + info->call_id = call_id_s; + g_return_val_if_fail (call_id_s, NULL); + return info; +} + +static void +_do_cancel_secrets (NMActRequest *self, GetSecretsInfo *info, gboolean is_disposing) +{ + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); + + nm_assert (info && info->self == self); + nm_assert (g_slist_find (priv->secrets_calls, info)); + + priv->secrets_calls = g_slist_remove (priv->secrets_calls, info); + + nm_settings_connection_cancel_secrets (nm_act_request_get_settings_connection (self), info->call_id); + + if (info->callback) { + gs_free_error GError *error = NULL; + + nm_utils_error_set_cancelled (&error, is_disposing, "NMActRequest"); + info->callback (self, info, NULL, error, info->callback_data); + } + + _get_secrets_info_free (info); +} + +/** + * nm_act_request_cancel_secrets: + * @self: The #NMActRequest. Note that this argument can be %NULL if, and only if + * the call_id was created with @take_ref. + * @call_id: + * + * You are only allowed to cancel the call once, and only before the callback + * is already invoked. Note that cancelling causes the callback to be invoked + * synchronously. + */ +void +nm_act_request_cancel_secrets (NMActRequest *self, NMActRequestGetSecretsCallId call_id) +{ + NMActRequestPrivate *priv; + + g_return_if_fail (call_id); + + if (self) { + g_return_if_fail (NM_IS_ACT_REQUEST (self)); + g_return_if_fail (self == call_id->self); + } else { + g_return_if_fail (call_id->has_ref); + g_return_if_fail (NM_IS_ACT_REQUEST (call_id->self)); + self = call_id->self; + } + + priv = NM_ACT_REQUEST_GET_PRIVATE (self); + + if (!g_slist_find (priv->secrets_calls, call_id)) + g_return_if_reached (); + + _do_cancel_secrets (self, call_id, FALSE); +} + +void +nm_act_request_clear_secrets (NMActRequest *self) +{ + g_return_if_fail (NM_IS_ACT_REQUEST (self)); + + nm_active_connection_clear_secrets ((NMActiveConnection *) self); +} + +/*****************************************************************************/ + +static void +clear_share_rules (NMActRequest *req) +{ + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req); + GSList *iter; + + for (iter = priv->share_rules; iter; iter = g_slist_next (iter)) { + ShareRule *rule = (ShareRule *) iter->data; + + g_free (rule->table); + g_free (rule->rule); + g_free (rule); + } + + g_slist_free (priv->share_rules); + priv->share_rules = NULL; +} + +void +nm_act_request_set_shared (NMActRequest *req, gboolean shared) +{ + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req); + GSList *list, *iter; + + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + NM_ACT_REQUEST_GET_PRIVATE (req)->shared = shared; + + /* Tear the rules down in reverse order when sharing is stopped */ + list = g_slist_copy (priv->share_rules); + if (!shared) + list = g_slist_reverse (list); + + /* Send the rules to iptables */ + for (iter = list; iter; iter = g_slist_next (iter)) { + ShareRule *rule = (ShareRule *) iter->data; + char *envp[1] = { NULL }; + gs_strfreev char **argv = NULL; + gs_free char *cmd = NULL; + + cmd = g_strdup_printf ("%s --table %s %s %s", + IPTABLES_PATH, + rule->table, + shared ? "--insert" : "--delete", + rule->rule); + if (!cmd) + continue; + + argv = g_strsplit (cmd, " ", 0); + if (argv && argv[0]) { + int status; + GError *error = NULL; + + nm_log_info (LOGD_SHARING, "Executing: %s", cmd); + if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, + NULL, NULL, NULL, NULL, &status, &error)) { + nm_log_warn (LOGD_SHARING, "Error executing command: %s", + error->message); + g_clear_error (&error); + } else if (WEXITSTATUS (status)) { + nm_log_warn (LOGD_SHARING, "** Command returned exit status %d.", + WEXITSTATUS (status)); + } + } + } + + g_slist_free (list); + + /* Clear the share rule list when sharing is stopped */ + if (!shared) + clear_share_rules (req); +} + +gboolean +nm_act_request_get_shared (NMActRequest *req) +{ + g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE); + + return NM_ACT_REQUEST_GET_PRIVATE (req)->shared; +} + +void +nm_act_request_add_share_rule (NMActRequest *req, + const char *table, + const char *table_rule) +{ + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req); + ShareRule *rule; + + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + g_return_if_fail (table != NULL); + g_return_if_fail (table_rule != NULL); + + rule = g_malloc0 (sizeof (ShareRule)); + rule->table = g_strdup (table); + rule->rule = g_strdup (table_rule); + priv->share_rules = g_slist_prepend (priv->share_rules, rule); +} + +/*****************************************************************************/ + +static void +device_notify (GObject *object, + GParamSpec *pspec, + gpointer self) +{ + g_object_notify (self, pspec->name); +} + +static void +device_state_changed (NMActiveConnection *active, + NMDevice *device, + NMDeviceState new_state, + NMDeviceState old_state) +{ + NMActiveConnectionState cur_ac_state = nm_active_connection_get_state (active); + NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; + + /* Decide which device state changes to handle when this active connection + * is not the device's current request. Two cases here: (a) the AC is + * pending and not yet active, and (b) the AC was active but the device is + * entering DISCONNECTED state (which clears the device's current AC before + * emitting the state change signal). + */ + if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != active) { + /* Some other request is activating; this one must be pending */ + if (new_state >= NM_DEVICE_STATE_PREPARE) + return; + else if (new_state == NM_DEVICE_STATE_DISCONNECTED) { + /* This request hasn't started activating yet; the device is + * disconnecting and cleaning up a previous activation request. + */ + if (cur_ac_state < NM_ACTIVE_CONNECTION_STATE_ACTIVATING) + return; + + /* Catch device disconnections after this request has been active */ + } + + /* All states < DISCONNECTED are fatal and handled */ + } + + /* Set NMActiveConnection state based on the device's state */ + switch (new_state) { + case NM_DEVICE_STATE_PREPARE: + case NM_DEVICE_STATE_CONFIG: + case NM_DEVICE_STATE_NEED_AUTH: + case NM_DEVICE_STATE_IP_CONFIG: + case NM_DEVICE_STATE_IP_CHECK: + case NM_DEVICE_STATE_SECONDARIES: + ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING; + break; + case NM_DEVICE_STATE_ACTIVATED: + ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED; + + g_signal_connect (device, "notify::" NM_DEVICE_IP4_CONFIG, + G_CALLBACK (device_notify), active); + g_signal_connect (device, "notify::" NM_DEVICE_DHCP4_CONFIG, + G_CALLBACK (device_notify), active); + g_signal_connect (device, "notify::" NM_DEVICE_IP6_CONFIG, + G_CALLBACK (device_notify), active); + g_signal_connect (device, "notify::" NM_DEVICE_DHCP6_CONFIG, + G_CALLBACK (device_notify), active); + break; + case NM_DEVICE_STATE_DEACTIVATING: + ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING; + break; + case NM_DEVICE_STATE_FAILED: + case NM_DEVICE_STATE_DISCONNECTED: + case NM_DEVICE_STATE_UNMANAGED: + case NM_DEVICE_STATE_UNAVAILABLE: + ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED; + + g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_notify), active); + break; + default: + break; + } + + if ( ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED + || ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) { + nm_active_connection_set_default (active, FALSE); + nm_active_connection_set_default6 (active, FALSE); + } + + nm_active_connection_set_state (active, ac_state); +} + +static void +master_failed (NMActiveConnection *self) +{ + NMDevice *device; + NMDeviceState device_state; + + /* If the connection has an active device, fail it */ + device = nm_active_connection_get_device (self); + if (device) { + device_state = nm_device_get_state (device); + if (nm_device_is_activating (device) || (device_state == NM_DEVICE_STATE_ACTIVATED)) { + nm_device_queue_state (device, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED); + return; + } + } + + /* If no device, or the device wasn't active, just move to deactivated state */ + nm_active_connection_set_state (self, NM_ACTIVE_CONNECTION_STATE_DEACTIVATED); +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMDevice *device; + + device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object)); + if (!device) { + g_value_set_string (value, "/"); + return; + } + + switch (prop_id) { + case PROP_IP4_CONFIG: + g_object_get_property (G_OBJECT (device), NM_DEVICE_IP4_CONFIG, value); + break; + case PROP_DHCP4_CONFIG: + g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP4_CONFIG, value); + break; + case PROP_IP6_CONFIG: + g_object_get_property (G_OBJECT (device), NM_DEVICE_IP6_CONFIG, value); + break; + case PROP_DHCP6_CONFIG: + g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP6_CONFIG, value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_act_request_init (NMActRequest *req) +{ +} + +/** + * nm_act_request_new: + * + * @settings_connection: (allow-none): the connection to activate @device with + * @applied_connection: (allow-none): the applied connection + * @specific_object: the object path of the specific object (ie, WiFi access point, + * etc) that will be used to activate @connection and @device + * @subject: the #NMAuthSubject representing the requestor of the activation + * @device: the device/interface to configure according to @connection + * + * Creates a new device-based activation request. If an applied connection is + * supplied, it shall not be modified by the caller afterwards. + * + * Returns: the new activation request on success, %NULL on error. + */ +NMActRequest * +nm_act_request_new (NMSettingsConnection *settings_connection, + NMConnection *applied_connection, + const char *specific_object, + NMAuthSubject *subject, + NMDevice *device) +{ + g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL); + g_return_val_if_fail (NM_IS_DEVICE (device), NULL); + g_return_val_if_fail (NM_IS_AUTH_SUBJECT (subject), NULL); + + return (NMActRequest *) g_object_new (NM_TYPE_ACT_REQUEST, + NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION, applied_connection, + NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, settings_connection, + NM_ACTIVE_CONNECTION_INT_DEVICE, device, + NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, + NM_ACTIVE_CONNECTION_INT_SUBJECT, subject, + NULL); +} + +static void +dispose (GObject *object) +{ + NMActRequest *self = NM_ACT_REQUEST (object); + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); + + /* Kill any in-progress secrets requests */ + while (priv->secrets_calls) + _do_cancel_secrets (self, priv->secrets_calls->data, TRUE); + + /* Clear any share rules */ + if (priv->share_rules) { + nm_act_request_set_shared (NM_ACT_REQUEST (object), FALSE); + clear_share_rules (NM_ACT_REQUEST (object)); + } + + G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object); +} + +static void +nm_act_request_class_init (NMActRequestClass *req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS (req_class); + + /* virtual methods */ + object_class->dispose = dispose; + object_class->get_property = get_property; + active_class->master_failed = master_failed; + active_class->device_state_changed = device_state_changed; + + /* properties */ + g_object_class_override_property (object_class, PROP_IP4_CONFIG, + NM_ACTIVE_CONNECTION_IP4_CONFIG); + g_object_class_override_property (object_class, PROP_DHCP4_CONFIG, + NM_ACTIVE_CONNECTION_DHCP4_CONFIG); + g_object_class_override_property (object_class, PROP_IP6_CONFIG, + NM_ACTIVE_CONNECTION_IP6_CONFIG); + g_object_class_override_property (object_class, PROP_DHCP6_CONFIG, + NM_ACTIVE_CONNECTION_DHCP6_CONFIG); +} + diff --git a/src/nm-act-request.h b/src/nm-act-request.h new file mode 100644 index 00000000..47247f89 --- /dev/null +++ b/src/nm-act-request.h @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2005 - 2012 Red Hat, Inc. + */ + +#ifndef __NM_ACT_REQUEST_H__ +#define __NM_ACT_REQUEST_H__ + +#include "nm-connection.h" +#include "nm-active-connection.h" + +#define NM_TYPE_ACT_REQUEST (nm_act_request_get_type ()) +#define NM_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACT_REQUEST, NMActRequest)) +#define NM_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACT_REQUEST, NMActRequestClass)) +#define NM_IS_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ACT_REQUEST)) +#define NM_IS_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_ACT_REQUEST)) +#define NM_ACT_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACT_REQUEST, NMActRequestClass)) + +struct _NMActRequestGetSecretsCallId; +typedef struct _NMActRequestGetSecretsCallId *NMActRequestGetSecretsCallId; + +GType nm_act_request_get_type (void); + +NMActRequest *nm_act_request_new (NMSettingsConnection *settings_connection, + NMConnection *applied_connection, + const char *specific_object, + NMAuthSubject *subject, + NMDevice *device); + +NMSettingsConnection *nm_act_request_get_settings_connection (NMActRequest *req); + +NMConnection *nm_act_request_get_applied_connection (NMActRequest *req); + +gboolean nm_act_request_get_shared (NMActRequest *req); + +void nm_act_request_set_shared (NMActRequest *req, gboolean shared); + +void nm_act_request_add_share_rule (NMActRequest *req, + const char *table, + const char *rule); + +/* Secrets handling */ + +typedef void (*NMActRequestSecretsFunc) (NMActRequest *req, + NMActRequestGetSecretsCallId call_id, + NMSettingsConnection *connection, + GError *error, + gpointer user_data); + +NMActRequestGetSecretsCallId nm_act_request_get_secrets (NMActRequest *req, + gboolean take_ref, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags, + const char *hint, + NMActRequestSecretsFunc callback, + gpointer callback_data); + +void nm_act_request_cancel_secrets (NMActRequest *req, NMActRequestGetSecretsCallId call_id); +void nm_act_request_clear_secrets (NMActRequest *self); + +#endif /* __NM_ACT_REQUEST_H__ */ + diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c deleted file mode 100644 index 22fa5b69..00000000 --- a/src/nm-activation-request.c +++ /dev/null @@ -1,571 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2012 Red Hat, Inc. - * Copyright (C) 2007 - 2008 Novell, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-activation-request.h" -#include "nm-setting-wireless-security.h" -#include "nm-setting-8021x.h" -#include "nm-device.h" -#include "nm-active-connection.h" -#include "nm-settings-connection.h" -#include "nm-auth-subject.h" - -G_DEFINE_TYPE (NMActRequest, nm_act_request, NM_TYPE_ACTIVE_CONNECTION) - -#define NM_ACT_REQUEST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_ACT_REQUEST, \ - NMActRequestPrivate)) - -typedef struct { - char *table; - char *rule; -} ShareRule; - -typedef struct { - GSList *secrets_calls; - gboolean shared; - GSList *share_rules; -} NMActRequestPrivate; - -enum { - PROP_0, - PROP_IP4_CONFIG, - PROP_DHCP4_CONFIG, - PROP_IP6_CONFIG, - PROP_DHCP6_CONFIG, - - LAST_PROP -}; - -/*******************************************************************/ - -NMSettingsConnection * -nm_act_request_get_settings_connection (NMActRequest *req) -{ - g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NULL); - - return nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (req)); -} - -NMConnection * -nm_act_request_get_applied_connection (NMActRequest *req) -{ - g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NULL); - - return nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (req)); -} - -/*******************************************************************/ - -struct _NMActRequestGetSecretsCallId { - NMActRequest *self; - NMActRequestSecretsFunc callback; - gpointer callback_data; - NMSettingsConnectionCallId call_id; -}; - -typedef struct _NMActRequestGetSecretsCallId GetSecretsInfo; - -static GetSecretsInfo * -_get_secrets_info_new (NMActRequest *self, NMActRequestSecretsFunc callback, gpointer callback_data) -{ - GetSecretsInfo *info; - - info = g_slice_new0 (GetSecretsInfo); - info->self = self; - info->callback = callback; - info->callback_data = callback_data; - - return info; -} - -static void -_get_secrets_info_free (GetSecretsInfo *info) -{ - g_slice_free (GetSecretsInfo, info); -} - -static void -get_secrets_cb (NMSettingsConnection *connection, - NMSettingsConnectionCallId call_id_s, - const char *agent_username, - const char *setting_name, - GError *error, - gpointer user_data) -{ - GetSecretsInfo *info = user_data; - NMActRequestPrivate *priv; - - g_return_if_fail (info && info->call_id == call_id_s); - g_return_if_fail (NM_IS_ACT_REQUEST (info->self)); - - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - priv = NM_ACT_REQUEST_GET_PRIVATE (info->self); - - g_return_if_fail (g_slist_find (priv->secrets_calls, info)); - - priv->secrets_calls = g_slist_remove (priv->secrets_calls, info); - - if (info->callback) - info->callback (info->self, info, connection, error, info->callback_data); - - _get_secrets_info_free (info); -} - -/** - * nm_act_request_get_secrets: - * @self: - * @setting_name: - * @flags: - * @hint: - * @callback: - * @callback_data: - * - * Asnychronously starts the request for secrets. This function cannot - * fail. - * - * The return call-id can be used to cancel the request. You are - * only allowed to cancel a still pending operation (once). - * The callback will always be invoked once, even for canceling - * or disposing of NMActRequest. - * - * Returns: a call-id. - */ -NMActRequestGetSecretsCallId -nm_act_request_get_secrets (NMActRequest *self, - const char *setting_name, - NMSecretAgentGetSecretsFlags flags, - const char *hint, - NMActRequestSecretsFunc callback, - gpointer callback_data) -{ - NMActRequestPrivate *priv; - GetSecretsInfo *info; - NMSettingsConnectionCallId call_id_s; - NMSettingsConnection *settings_connection; - NMConnection *applied_connection; - const char *hints[2] = { hint, NULL }; - - g_return_val_if_fail (NM_IS_ACT_REQUEST (self), 0); - - priv = NM_ACT_REQUEST_GET_PRIVATE (self); - - settings_connection = nm_act_request_get_settings_connection (self); - applied_connection = nm_act_request_get_applied_connection (self); - - info = _get_secrets_info_new (self, callback, callback_data); - - priv->secrets_calls = g_slist_append (priv->secrets_calls, info); - - if (nm_active_connection_get_user_requested (NM_ACTIVE_CONNECTION (self))) - flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED; - - call_id_s = nm_settings_connection_get_secrets (settings_connection, - applied_connection, - nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (self)), - setting_name, - flags, - hints, - get_secrets_cb, - info); - info->call_id = call_id_s; - g_return_val_if_fail (call_id_s, NULL); - return info; -} - -static void -_do_cancel_secrets (NMActRequest *self, GetSecretsInfo *info, gboolean is_disposing) -{ - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); - - nm_assert (info && info->self == self); - nm_assert (g_slist_find (priv->secrets_calls, info)); - - priv->secrets_calls = g_slist_remove (priv->secrets_calls, info); - - nm_settings_connection_cancel_secrets (nm_act_request_get_settings_connection (self), info->call_id); - - if (info->callback) { - gs_free_error GError *error = NULL; - - nm_utils_error_set_cancelled (&error, is_disposing, "NMActRequest"); - info->callback (self, info, NULL, error, info->callback_data); - } - - _get_secrets_info_free (info); -} - -void -nm_act_request_cancel_secrets (NMActRequest *self, NMActRequestGetSecretsCallId call_id) -{ - NMActRequestPrivate *priv; - - g_return_if_fail (NM_IS_ACT_REQUEST (self)); - g_return_if_fail (call_id); - - priv = NM_ACT_REQUEST_GET_PRIVATE (self); - - if (!g_slist_find (priv->secrets_calls, call_id)) - g_return_if_reached (); - - _do_cancel_secrets (self, call_id, FALSE); -} - -void -nm_act_request_clear_secrets (NMActRequest *self) -{ - g_return_if_fail (NM_IS_ACT_REQUEST (self)); - - nm_active_connection_clear_secrets ((NMActiveConnection *) self); -} - -/********************************************************************/ - -static void -clear_share_rules (NMActRequest *req) -{ - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req); - GSList *iter; - - for (iter = priv->share_rules; iter; iter = g_slist_next (iter)) { - ShareRule *rule = (ShareRule *) iter->data; - - g_free (rule->table); - g_free (rule->rule); - g_free (rule); - } - - g_slist_free (priv->share_rules); - priv->share_rules = NULL; -} - -void -nm_act_request_set_shared (NMActRequest *req, gboolean shared) -{ - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req); - GSList *list, *iter; - - g_return_if_fail (NM_IS_ACT_REQUEST (req)); - - NM_ACT_REQUEST_GET_PRIVATE (req)->shared = shared; - - /* Tear the rules down in reverse order when sharing is stopped */ - list = g_slist_copy (priv->share_rules); - if (!shared) - list = g_slist_reverse (list); - - /* Send the rules to iptables */ - for (iter = list; iter; iter = g_slist_next (iter)) { - ShareRule *rule = (ShareRule *) iter->data; - char *envp[1] = { NULL }; - gs_strfreev char **argv = NULL; - gs_free char *cmd = NULL; - - cmd = g_strdup_printf ("%s --table %s %s %s", - IPTABLES_PATH, - rule->table, - shared ? "--insert" : "--delete", - rule->rule); - if (!cmd) - continue; - - argv = g_strsplit (cmd, " ", 0); - if (argv && argv[0]) { - int status; - GError *error = NULL; - - nm_log_info (LOGD_SHARING, "Executing: %s", cmd); - if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, - NULL, NULL, NULL, NULL, &status, &error)) { - nm_log_warn (LOGD_SHARING, "Error executing command: %s", - error->message); - g_clear_error (&error); - } else if (WEXITSTATUS (status)) { - nm_log_warn (LOGD_SHARING, "** Command returned exit status %d.", - WEXITSTATUS (status)); - } - } - } - - g_slist_free (list); - - /* Clear the share rule list when sharing is stopped */ - if (!shared) - clear_share_rules (req); -} - -gboolean -nm_act_request_get_shared (NMActRequest *req) -{ - g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE); - - return NM_ACT_REQUEST_GET_PRIVATE (req)->shared; -} - -void -nm_act_request_add_share_rule (NMActRequest *req, - const char *table, - const char *table_rule) -{ - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req); - ShareRule *rule; - - g_return_if_fail (NM_IS_ACT_REQUEST (req)); - g_return_if_fail (table != NULL); - g_return_if_fail (table_rule != NULL); - - rule = g_malloc0 (sizeof (ShareRule)); - rule->table = g_strdup (table); - rule->rule = g_strdup (table_rule); - priv->share_rules = g_slist_prepend (priv->share_rules, rule); -} - -/********************************************************************/ - -static void -device_notify (GObject *object, - GParamSpec *pspec, - gpointer self) -{ - g_object_notify (self, pspec->name); -} - -static void -device_state_changed (NMActiveConnection *active, - NMDevice *device, - NMDeviceState new_state, - NMDeviceState old_state) -{ - NMActiveConnectionState cur_ac_state = nm_active_connection_get_state (active); - NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; - - /* Decide which device state changes to handle when this active connection - * is not the device's current request. Two cases here: (a) the AC is - * pending and not yet active, and (b) the AC was active but the device is - * entering DISCONNECTED state (which clears the device's current AC before - * emitting the state change signal). - */ - if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != active) { - /* Some other request is activating; this one must be pending */ - if (new_state >= NM_DEVICE_STATE_PREPARE) - return; - else if (new_state == NM_DEVICE_STATE_DISCONNECTED) { - /* This request hasn't started activating yet; the device is - * disconnecting and cleaning up a previous activation request. - */ - if (cur_ac_state < NM_ACTIVE_CONNECTION_STATE_ACTIVATING) - return; - - /* Catch device disconnections after this request has been active */ - } - - /* All states < DISCONNECTED are fatal and handled */ - } - - /* Set NMActiveConnection state based on the device's state */ - switch (new_state) { - case NM_DEVICE_STATE_PREPARE: - case NM_DEVICE_STATE_CONFIG: - case NM_DEVICE_STATE_NEED_AUTH: - case NM_DEVICE_STATE_IP_CONFIG: - case NM_DEVICE_STATE_IP_CHECK: - case NM_DEVICE_STATE_SECONDARIES: - ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING; - break; - case NM_DEVICE_STATE_ACTIVATED: - ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED; - - g_signal_connect (device, "notify::" NM_DEVICE_IP4_CONFIG, - G_CALLBACK (device_notify), active); - g_signal_connect (device, "notify::" NM_DEVICE_DHCP4_CONFIG, - G_CALLBACK (device_notify), active); - g_signal_connect (device, "notify::" NM_DEVICE_IP6_CONFIG, - G_CALLBACK (device_notify), active); - g_signal_connect (device, "notify::" NM_DEVICE_DHCP6_CONFIG, - G_CALLBACK (device_notify), active); - break; - case NM_DEVICE_STATE_DEACTIVATING: - ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING; - break; - case NM_DEVICE_STATE_FAILED: - case NM_DEVICE_STATE_DISCONNECTED: - case NM_DEVICE_STATE_UNMANAGED: - case NM_DEVICE_STATE_UNAVAILABLE: - ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED; - - g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_notify), active); - break; - default: - break; - } - - if ( ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED - || ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) { - nm_active_connection_set_default (active, FALSE); - nm_active_connection_set_default6 (active, FALSE); - } - - nm_active_connection_set_state (active, ac_state); -} - -static void -master_failed (NMActiveConnection *self) -{ - NMDevice *device; - NMDeviceState device_state; - - /* If the connection has an active device, fail it */ - device = nm_active_connection_get_device (self); - if (device) { - device_state = nm_device_get_state (device); - if (nm_device_is_activating (device) || (device_state == NM_DEVICE_STATE_ACTIVATED)) { - nm_device_queue_state (device, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED); - return; - } - } - - /* If no device, or the device wasn't active, just move to deactivated state */ - nm_active_connection_set_state (self, NM_ACTIVE_CONNECTION_STATE_DEACTIVATED); -} - -/********************************************************************/ - -/** - * nm_act_request_new: - * - * @settings_connection: (allow-none): the connection to activate @device with - * @specific_object: the object path of the specific object (ie, WiFi access point, - * etc) that will be used to activate @connection and @device - * @subject: the #NMAuthSubject representing the requestor of the activation - * @device: the device/interface to configure according to @connection - * - * Creates a new device-based activation request. - * - * Returns: the new activation request on success, %NULL on error. - */ -NMActRequest * -nm_act_request_new (NMSettingsConnection *settings_connection, - const char *specific_object, - NMAuthSubject *subject, - NMDevice *device) -{ - g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL); - g_return_val_if_fail (NM_IS_DEVICE (device), NULL); - g_return_val_if_fail (NM_IS_AUTH_SUBJECT (subject), NULL); - - return (NMActRequest *) g_object_new (NM_TYPE_ACT_REQUEST, - NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, settings_connection, - NM_ACTIVE_CONNECTION_INT_DEVICE, device, - NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, - NM_ACTIVE_CONNECTION_INT_SUBJECT, subject, - NULL); -} - -static void -nm_act_request_init (NMActRequest *req) -{ -} - -static void -dispose (GObject *object) -{ - NMActRequest *self = NM_ACT_REQUEST (object); - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); - - /* Kill any in-progress secrets requests */ - while (priv->secrets_calls) - _do_cancel_secrets (self, priv->secrets_calls->data, TRUE); - - /* Clear any share rules */ - if (priv->share_rules) { - nm_act_request_set_shared (NM_ACT_REQUEST (object), FALSE); - clear_share_rules (NM_ACT_REQUEST (object)); - } - - G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMDevice *device; - - device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object)); - if (!device) { - g_value_set_string (value, "/"); - return; - } - - switch (prop_id) { - case PROP_IP4_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_IP4_CONFIG, value); - break; - case PROP_DHCP4_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP4_CONFIG, value); - break; - case PROP_IP6_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_IP6_CONFIG, value); - break; - case PROP_DHCP6_CONFIG: - g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP6_CONFIG, value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -nm_act_request_class_init (NMActRequestClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (NMActRequestPrivate)); - - /* virtual methods */ - object_class->dispose = dispose; - object_class->get_property = get_property; - active_class->master_failed = master_failed; - active_class->device_state_changed = device_state_changed; - - /* properties */ - g_object_class_override_property (object_class, PROP_IP4_CONFIG, - NM_ACTIVE_CONNECTION_IP4_CONFIG); - g_object_class_override_property (object_class, PROP_DHCP4_CONFIG, - NM_ACTIVE_CONNECTION_DHCP4_CONFIG); - g_object_class_override_property (object_class, PROP_IP6_CONFIG, - NM_ACTIVE_CONNECTION_IP6_CONFIG); - g_object_class_override_property (object_class, PROP_DHCP6_CONFIG, - NM_ACTIVE_CONNECTION_DHCP6_CONFIG); -} - diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h deleted file mode 100644 index 1bd00499..00000000 --- a/src/nm-activation-request.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2005 - 2012 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_ACTIVATION_REQUEST_H__ -#define __NETWORKMANAGER_ACTIVATION_REQUEST_H__ - -#include "nm-connection.h" -#include "nm-active-connection.h" - -#define NM_TYPE_ACT_REQUEST (nm_act_request_get_type ()) -#define NM_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACT_REQUEST, NMActRequest)) -#define NM_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACT_REQUEST, NMActRequestClass)) -#define NM_IS_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ACT_REQUEST)) -#define NM_IS_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_ACT_REQUEST)) -#define NM_ACT_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACT_REQUEST, NMActRequestClass)) - -struct _NMActRequestGetSecretsCallId; -typedef struct _NMActRequestGetSecretsCallId *NMActRequestGetSecretsCallId; - -struct _NMActRequest { - NMActiveConnection parent; -}; - -typedef struct { - NMActiveConnectionClass parent; - -} NMActRequestClass; - -GType nm_act_request_get_type (void); - -NMActRequest *nm_act_request_new (NMSettingsConnection *settings_connection, - const char *specific_object, - NMAuthSubject *subject, - NMDevice *device); - -NMSettingsConnection *nm_act_request_get_settings_connection (NMActRequest *req); - -NMConnection *nm_act_request_get_applied_connection (NMActRequest *req); - -gboolean nm_act_request_get_shared (NMActRequest *req); - -void nm_act_request_set_shared (NMActRequest *req, gboolean shared); - -void nm_act_request_add_share_rule (NMActRequest *req, - const char *table, - const char *rule); - -/* Secrets handling */ - -typedef void (*NMActRequestSecretsFunc) (NMActRequest *req, - NMActRequestGetSecretsCallId call_id, - NMSettingsConnection *connection, - GError *error, - gpointer user_data); - -NMActRequestGetSecretsCallId nm_act_request_get_secrets (NMActRequest *req, - const char *setting_name, - NMSecretAgentGetSecretsFlags flags, - const char *hint, - NMActRequestSecretsFunc callback, - gpointer callback_data); - -void nm_act_request_cancel_secrets (NMActRequest *req, NMActRequestGetSecretsCallId call_id); -void nm_act_request_clear_secrets (NMActRequest *self); - -#endif /* __NETWORKMANAGER_ACTIVATION_REQUEST_H__ */ - diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 1844587c..17fb82e5 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -24,24 +24,17 @@ #include "nm-common-macros.h" #include "nm-dbus-interface.h" -#include "nm-device.h" -#include "nm-settings-connection.h" +#include "devices/nm-device.h" +#include "settings/nm-settings-connection.h" #include "nm-simple-connection.h" #include "nm-auth-utils.h" #include "nm-auth-subject.h" #include "NetworkManagerUtils.h" #include "nm-core-internal.h" -#include "nmdbus-active-connection.h" +#include "introspection/org.freedesktop.NetworkManager.Connection.Active.h" -/* Base class for anything implementing the Connection.Active D-Bus interface */ -G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORTED_OBJECT) - -#define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_ACTIVE_CONNECTION, \ - NMActiveConnectionPrivate)) - -typedef struct { +typedef struct _NMActiveConnectionPrivate { NMSettingsConnection *settings_connection; NMConnection *applied_connection; char *specific_object; @@ -90,6 +83,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection, PROP_MASTER, PROP_INT_SETTINGS_CONNECTION, + PROP_INT_APPLIED_CONNECTION, PROP_INT_DEVICE, PROP_INT_SUBJECT, PROP_INT_MASTER, @@ -104,10 +98,14 @@ enum { }; static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORTED_OBJECT) + +#define NM_ACTIVE_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMActiveConnection, NM_IS_ACTIVE_CONNECTION) + static void check_master_ready (NMActiveConnection *self); static void _device_cleanup (NMActiveConnection *self); -/****************************************************************/ +/*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_DEVICE #define _NMLOG_PREFIX_NAME "active-connection" @@ -122,7 +120,7 @@ static void _device_cleanup (NMActiveConnection *self); _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ } G_STMT_END -/****************************************************************/ +/*****************************************************************************/ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_state_to_string, NMActiveConnectionState, NM_UTILS_LOOKUP_DEFAULT (NULL), @@ -134,7 +132,7 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_state_to_string, NMActiveConnectionState, ); #define state_to_string(state) NM_UTILS_LOOKUP_STR (_state_to_string, state) -/****************************************************************/ +/*****************************************************************************/ static void _settings_connection_updated (NMSettingsConnection *connection, @@ -335,7 +333,7 @@ nm_active_connection_has_unmodified_applied_connection (NMActiveConnection *self compare_flags); } -/*******************************************************************/ +/*****************************************************************************/ void nm_active_connection_clear_secrets (NMActiveConnection *self) @@ -353,7 +351,7 @@ nm_active_connection_clear_secrets (NMActiveConnection *self) nm_connection_clear_secrets (priv->applied_connection); } -/*******************************************************************/ +/*****************************************************************************/ const char * nm_active_connection_get_specific_object (NMActiveConnection *self) @@ -717,7 +715,7 @@ nm_active_connection_get_assumed (NMActiveConnection *self) return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->assumed; } -/****************************************************************/ +/*****************************************************************************/ static void unwatch_parent (NMActiveConnection *self, gboolean unref); @@ -781,7 +779,7 @@ nm_active_connection_set_parent (NMActiveConnection *self, NMActiveConnection *p g_object_weak_ref ((GObject *) priv->parent, parent_destroyed, self); } -/****************************************************************/ +/*****************************************************************************/ static void auth_done (NMAuthChain *chain, @@ -900,7 +898,7 @@ nm_active_connection_authorize (NMActiveConnection *self, priv->user_data2 = user_data2; } -/****************************************************************/ +/*****************************************************************************/ static guint64 _version_id_new (void) @@ -931,88 +929,34 @@ nm_active_connection_version_id_bump (NMActiveConnection *self) return priv->version_id; } -/****************************************************************/ - -static void -nm_active_connection_init (NMActiveConnection *self) -{ - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); - - _LOGT ("creating"); - - priv->version_id = _version_id_new (); -} +/*****************************************************************************/ static void -constructed (GObject *object) +_device_cleanup (NMActiveConnection *self) { - NMActiveConnection *self = (NMActiveConnection *) object; NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); - G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); + if (priv->device) { + g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_state_changed), self); + g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_master_changed), self); + g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_metered_changed), self); + } - _LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (long long unsigned) priv->version_id); + if (priv->pending_activation_id) { + nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE); + g_clear_pointer (&priv->pending_activation_id, g_free); + } - g_return_if_fail (priv->subject); + g_clear_object (&priv->device); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMActiveConnection *self = (NMActiveConnection *) object; - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); - const char *tmp; - NMSettingsConnection *con; - - switch (prop_id) { - case PROP_INT_SETTINGS_CONNECTION: - /* construct-only */ - con = g_value_get_object (value); - if (con) { - _set_settings_connection (self, con); - priv->applied_connection = nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection); - nm_connection_clear_secrets (priv->applied_connection); - } - break; - case PROP_INT_DEVICE: - /* construct-only */ - nm_active_connection_set_device (self, g_value_get_object (value)); - break; - case PROP_INT_SUBJECT: - priv->subject = g_value_dup_object (value); - break; - case PROP_INT_MASTER: - nm_active_connection_set_master (self, g_value_get_object (value)); - break; - case PROP_SPECIFIC_OBJECT: - tmp = g_value_get_string (value); - /* NM uses "/" to mean NULL */ - if (g_strcmp0 (tmp, "/") != 0) - priv->specific_object = g_strdup (tmp); - break; - case PROP_DEFAULT: - priv->is_default = !!g_value_get_boolean (value); - break; - case PROP_DEFAULT6: - priv->is_default6 = !!g_value_get_boolean (value); - break; - case PROP_VPN: - priv->vpn = g_value_get_boolean (value); - break; - case PROP_MASTER: - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE ((NMActiveConnection *) object); GPtrArray *devices; NMDevice *master_device = NULL; @@ -1089,22 +1033,95 @@ get_property (GObject *object, guint prop_id, } static void -_device_cleanup (NMActiveConnection *self) +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { + NMActiveConnection *self = (NMActiveConnection *) object; NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); + const char *tmp; + NMSettingsConnection *con; + NMConnection *acon; - if (priv->device) { - g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_state_changed), self); - g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_master_changed), self); - g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_metered_changed), self); + switch (prop_id) { + case PROP_INT_SETTINGS_CONNECTION: + /* construct-only */ + con = g_value_get_object (value); + if (con) + _set_settings_connection (self, con); + break; + case PROP_INT_APPLIED_CONNECTION: + /* construct-only */ + acon = g_value_get_object (value); + if (acon) + priv->applied_connection = g_object_ref (acon); + break; + case PROP_INT_DEVICE: + /* construct-only */ + nm_active_connection_set_device (self, g_value_get_object (value)); + break; + case PROP_INT_SUBJECT: + priv->subject = g_value_dup_object (value); + break; + case PROP_INT_MASTER: + nm_active_connection_set_master (self, g_value_get_object (value)); + break; + case PROP_SPECIFIC_OBJECT: + tmp = g_value_get_string (value); + /* NM uses "/" to mean NULL */ + if (g_strcmp0 (tmp, "/") != 0) + priv->specific_object = g_strdup (tmp); + break; + case PROP_DEFAULT: + priv->is_default = !!g_value_get_boolean (value); + break; + case PROP_DEFAULT6: + priv->is_default6 = !!g_value_get_boolean (value); + break; + case PROP_VPN: + priv->vpn = g_value_get_boolean (value); + break; + case PROP_MASTER: + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } +} - if (priv->pending_activation_id) { - nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE); - g_clear_pointer (&priv->pending_activation_id, g_free); +/*****************************************************************************/ + +static void +nm_active_connection_init (NMActiveConnection *self) +{ + NMActiveConnectionPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate); + self->_priv = priv; + + _LOGT ("creating"); + + priv->version_id = _version_id_new (); +} + +static void +constructed (GObject *object) +{ + NMActiveConnection *self = (NMActiveConnection *) object; + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); + + G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); + + if (!priv->applied_connection && priv->settings_connection) { + priv->applied_connection = + nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection); } - g_clear_object (&priv->device); + if (priv->applied_connection) + nm_connection_clear_secrets (priv->applied_connection); + + _LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (long long unsigned) priv->version_id); + + g_return_if_fail (priv->subject); } static void @@ -1151,9 +1168,8 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class) g_type_class_add_private (ac_class, sizeof (NMActiveConnectionPrivate)); - exported_object_class->export_path = NM_DBUS_PATH "/ActiveConnection/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/ActiveConnection"); - /* virtual methods */ object_class->get_property = get_property; object_class->set_property = set_property; object_class->constructed = constructed; @@ -1259,6 +1275,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class) G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_INT_APPLIED_CONNECTION] = + g_param_spec_object (NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION, "", "", + NM_TYPE_CONNECTION, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_INT_DEVICE] = g_param_spec_object (NM_ACTIVE_CONNECTION_INT_DEVICE, "", "", NM_TYPE_DEVICE, diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h index a66f8e9f..d87a30b5 100644 --- a/src/nm-active-connection.h +++ b/src/nm-active-connection.h @@ -50,6 +50,7 @@ /* Internal non-exported properties */ #define NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION "int-settings-connection" +#define NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION "int-applied-connection" #define NM_ACTIVE_CONNECTION_INT_DEVICE "int-device" #define NM_ACTIVE_CONNECTION_INT_SUBJECT "int-subject" #define NM_ACTIVE_CONNECTION_INT_MASTER "int-master" @@ -60,8 +61,11 @@ #define NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED "device-metered-changed" #define NM_ACTIVE_CONNECTION_PARENT_ACTIVE "parent-active" +struct _NMActiveConnectionPrivate; + struct _NMActiveConnection { NMExportedObject parent; + struct _NMActiveConnectionPrivate *_priv; }; typedef struct { diff --git a/src/nm-audit-manager.c b/src/nm-audit-manager.c index 9e884096..eeb9d2ba 100644 --- a/src/nm-audit-manager.c +++ b/src/nm-audit-manager.c @@ -30,46 +30,65 @@ #include "nm-auth-subject.h" #include "nm-config.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings-connection.h" -#define AUDIT_LOG_LEVEL LOGL_INFO - -#define _NMLOG_PREFIX_NAME "audit" -#define _NMLOG(level, domain, ...) \ - G_STMT_START { \ - nm_log ((level), (domain), \ - "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } G_STMT_END +/*****************************************************************************/ typedef enum { - BACKEND_LOG = (1 << 0), - BACKEND_AUDITD = (1 << 1), - _BACKEND_LAST, - BACKEND_ALL = ((_BACKEND_LAST - 1) << 1) - 1, + BACKEND_LOG = (1 << 0), + BACKEND_AUDITD = (1 << 1), + _BACKEND_LAST, + BACKEND_ALL = ((_BACKEND_LAST - 1) << 1) - 1, } AuditBackend; typedef struct { - const char *name; - GValue value; - gboolean need_encoding; - AuditBackend backends; + const char *name; + GValue value; + gboolean need_encoding; + AuditBackend backends; } AuditField; -#if HAVE_LIBAUDIT +/*****************************************************************************/ + typedef struct { NMConfig *config; int auditd_fd; } NMAuditManagerPrivate; -#define NM_AUDIT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AUDIT_MANAGER, NMAuditManagerPrivate)) +struct _NMAuditManager { + GObject parent; +#if HAVE_LIBAUDIT + NMAuditManagerPrivate _priv; #endif +}; + +struct _NMAuditManagerClass { + GObjectClass parent; +}; G_DEFINE_TYPE (NMAuditManager, nm_audit_manager, G_TYPE_OBJECT) +#define NM_AUDIT_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMAuditManager, NM_IS_AUDIT_MANAGER) + +/*****************************************************************************/ + +#define AUDIT_LOG_LEVEL LOGL_INFO + +#define _NMLOG_PREFIX_NAME "audit" +#define _NMLOG(level, domain, ...) \ + G_STMT_START { \ + nm_log ((level), (domain), \ + "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG_PREFIX_NAME": " \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } G_STMT_END + +/*****************************************************************************/ + NM_DEFINE_SINGLETON_GETTER (NMAuditManager, nm_audit_manager_get, NM_TYPE_AUDIT_MANAGER); +/*****************************************************************************/ + static void _audit_field_init_string (AuditField *field, const char *name, const char *str, gboolean need_encoding, AuditBackend backends) @@ -317,7 +336,7 @@ init_auditd (NMAuditManager *self) if (nm_config_data_get_value_boolean (data, NM_CONFIG_KEYFILE_GROUP_LOGGING, NM_CONFIG_KEYFILE_KEY_AUDIT, - NM_CONFIG_DEFAULT_LOGGING_AUDIT)) { + NM_CONFIG_DEFAULT_LOGGING_AUDIT_BOOL)) { if (priv->auditd_fd < 0) { priv->auditd_fd = audit_open (); if (priv->auditd_fd < 0) @@ -346,6 +365,8 @@ config_changed_cb (NMConfig *config, } #endif +/*****************************************************************************/ + static void nm_audit_manager_init (NMAuditManager *self) { @@ -389,11 +410,5 @@ nm_audit_manager_class_init (NMAuditManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); -#if HAVE_LIBAUDIT - g_type_class_add_private (klass, sizeof (NMAuditManagerPrivate)); -#endif - - /* virtual methods */ object_class->dispose = dispose; } - diff --git a/src/nm-audit-manager.h b/src/nm-audit-manager.h index af8a2037..29bde1a5 100644 --- a/src/nm-audit-manager.h +++ b/src/nm-audit-manager.h @@ -22,7 +22,7 @@ #define __NM_AUDIT_MANAGER_H__ #include "nm-connection.h" -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-types.h" #define NM_TYPE_AUDIT_MANAGER (nm_audit_manager_get_type ()) @@ -32,13 +32,7 @@ #define NM_IS_AUDIT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AUDIT_MANAGER)) #define NM_AUDIT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AUDIT_MANAGER, NMAuditManagerClass)) -struct _NMAuditManager { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMAuditManagerClass; +typedef struct _NMAuditManagerClass NMAuditManagerClass; #define NM_AUDIT_OP_CONN_ADD "connection-add" #define NM_AUDIT_OP_CONN_DELETE "connection-delete" diff --git a/src/nm-auth-manager.c b/src/nm-auth-manager.c index 531e2c35..4359d8f1 100644 --- a/src/nm-auth-manager.c +++ b/src/nm-auth-manager.c @@ -30,32 +30,14 @@ #define POLKIT_OBJECT_PATH "/org/freedesktop/PolicyKit1/Authority" #define POLKIT_INTERFACE "org.freedesktop.PolicyKit1.Authority" +/*****************************************************************************/ -#define _NMLOG_PREFIX_NAME "auth" -#define _NMLOG_DOMAIN LOGD_CORE -#define _NMLOG(level, ...) \ - G_STMT_START { \ - if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \ - char __prefix[30] = _NMLOG_PREFIX_NAME; \ - \ - if ((self) != singleton_instance) \ - g_snprintf (__prefix, sizeof (__prefix), ""_NMLOG_PREFIX_NAME"[%p]", (self)); \ - _nm_log ((level), (_NMLOG_DOMAIN), 0, \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } \ - } G_STMT_END - -enum { - PROP_0, +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_POLKIT_ENABLED, - - LAST_PROP -}; +); enum { CHANGED_SIGNAL, - LAST_SIGNAL, }; @@ -71,11 +53,37 @@ typedef struct { #endif } NMAuthManagerPrivate; -NM_DEFINE_SINGLETON_REGISTER (NMAuthManager); +struct _NMAuthManager { + GObject parent; + NMAuthManagerPrivate _priv; +}; + +struct _NMAuthManagerClass { + GObjectClass parent; +}; G_DEFINE_TYPE (NMAuthManager, nm_auth_manager, G_TYPE_OBJECT) -#define NM_AUTH_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AUTH_MANAGER, NMAuthManagerPrivate)) +#define NM_AUTH_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMAuthManager, NM_IS_AUTH_MANAGER) + +NM_DEFINE_SINGLETON_REGISTER (NMAuthManager); + +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "auth" +#define _NMLOG_DOMAIN LOGD_CORE +#define _NMLOG(level, ...) \ + G_STMT_START { \ + if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \ + char __prefix[30] = _NMLOG_PREFIX_NAME; \ + \ + if ((self) != singleton_instance) \ + g_snprintf (__prefix, sizeof (__prefix), ""_NMLOG_PREFIX_NAME"[%p]", (self)); \ + _nm_log ((level), (_NMLOG_DOMAIN), 0, \ + "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } \ + } G_STMT_END /*****************************************************************************/ @@ -477,32 +485,12 @@ nm_auth_manager_get () return singleton_instance; } -NMAuthManager * -nm_auth_manager_setup (gboolean polkit_enabled) -{ - NMAuthManager *self; - - g_return_val_if_fail (!singleton_instance, singleton_instance); - - self = g_object_new (NM_TYPE_AUTH_MANAGER, - NM_AUTH_MANAGER_POLKIT_ENABLED, polkit_enabled, - NULL); - _LOGD ("set instance"); - - singleton_instance = self; - nm_singleton_instance_register (); - - nm_log_dbg (LOGD_CORE, "setup %s singleton (%p)", "NMAuthManager", singleton_instance); - - return self; -} - /*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE (object); + NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE ((NMAuthManager *) object); switch (prop_id) { case PROP_POLKIT_ENABLED: @@ -517,11 +505,11 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE (object); + NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE ((NMAuthManager *) object); switch (prop_id) { case PROP_POLKIT_ENABLED: - /* construct only */ + /* construct-only */ priv->polkit_enabled = !!g_value_get_boolean (value); break; default: @@ -530,6 +518,8 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *p } } +/*****************************************************************************/ + static void nm_auth_manager_init (NMAuthManager *self) { @@ -571,6 +561,25 @@ constructed (GObject *object) #endif } +NMAuthManager * +nm_auth_manager_setup (gboolean polkit_enabled) +{ + NMAuthManager *self; + + g_return_val_if_fail (!singleton_instance, singleton_instance); + + self = g_object_new (NM_TYPE_AUTH_MANAGER, + NM_AUTH_MANAGER_POLKIT_ENABLED, polkit_enabled, + NULL); + _LOGD ("set instance"); + + singleton_instance = self; + nm_singleton_instance_register (); + + nm_log_dbg (LOGD_CORE, "setup %s singleton (%p)", "NMAuthManager", singleton_instance); + + return self; +} static void dispose (GObject *object) @@ -605,20 +614,19 @@ nm_auth_manager_class_init (NMAuthManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMAuthManagerPrivate)); - object_class->get_property = get_property; object_class->set_property = set_property; object_class->constructed = constructed; object_class->dispose = dispose; - g_object_class_install_property - (object_class, PROP_POLKIT_ENABLED, + obj_properties[PROP_POLKIT_ENABLED] = g_param_spec_boolean (NM_AUTH_MANAGER_POLKIT_ENABLED, "", "", FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[CHANGED_SIGNAL] = g_signal_new (NM_AUTH_MANAGER_SIGNAL_CHANGED, NM_TYPE_AUTH_MANAGER, @@ -629,6 +637,5 @@ nm_auth_manager_class_init (NMAuthManagerClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - } diff --git a/src/nm-auth-manager.h b/src/nm-auth-manager.h index 9251b334..e66ef78c 100644 --- a/src/nm-auth-manager.h +++ b/src/nm-auth-manager.h @@ -30,18 +30,12 @@ #define NM_IS_AUTH_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AUTH_MANAGER)) #define NM_AUTH_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AUTH_MANAGER, NMAuthManagerClass)) - #define NM_AUTH_MANAGER_POLKIT_ENABLED "polkit-enabled" #define NM_AUTH_MANAGER_SIGNAL_CHANGED "changed" -typedef struct { - GObject parent; -} NMAuthManager; - -typedef struct { - GObjectClass parent; -} NMAuthManagerClass; +typedef struct _NMAuthManager NMAuthManager; +typedef struct _NMAuthManagerClass NMAuthManagerClass; GType nm_auth_manager_get_type (void); @@ -68,4 +62,3 @@ gboolean nm_auth_manager_polkit_authority_check_authorization_finish (NMAuthMana #endif #endif /* NM_AUTH_MANAGER_H */ - diff --git a/src/nm-auth-subject.c b/src/nm-auth-subject.c index 54d35959..9819ca70 100644 --- a/src/nm-auth-subject.c +++ b/src/nm-auth-subject.c @@ -34,7 +34,6 @@ #include #include "nm-bus-manager.h" -#include "nm-enum-types.h" #include "NetworkManagerUtils.h" enum { @@ -70,7 +69,7 @@ G_DEFINE_TYPE (NMAuthSubject, nm_auth_subject, G_TYPE_OBJECT) #define NM_AUTH_SUBJECT_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMAuthSubject, NM_IS_AUTH_SUBJECT) -/**************************************************************/ +/*****************************************************************************/ #define CHECK_SUBJECT(self, error_value) \ NMAuthSubjectPrivate *priv; \ @@ -172,7 +171,7 @@ nm_auth_subject_get_unix_process_dbus_sender (NMAuthSubject *subject) return priv->unix_process.dbus_sender; } -/**************************************************************/ +/*****************************************************************************/ static NMAuthSubject * _new_unix_process (GDBusMethodInvocation *context, @@ -213,7 +212,7 @@ _new_unix_process (GDBusMethodInvocation *context, g_return_val_if_fail (pid > 0 && pid <= MIN (G_MAXINT, G_MAXINT32), NULL); self = NM_AUTH_SUBJECT (g_object_new (NM_TYPE_AUTH_SUBJECT, - NM_AUTH_SUBJECT_SUBJECT_TYPE, NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS, + NM_AUTH_SUBJECT_SUBJECT_TYPE, (int) NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS, NM_AUTH_SUBJECT_UNIX_PROCESS_DBUS_SENDER, dbus_sender, NM_AUTH_SUBJECT_UNIX_PROCESS_PID, (gulong) pid, NM_AUTH_SUBJECT_UNIX_PROCESS_UID, (gulong) uid, @@ -252,11 +251,11 @@ NMAuthSubject * nm_auth_subject_new_internal (void) { return NM_AUTH_SUBJECT (g_object_new (NM_TYPE_AUTH_SUBJECT, - NM_AUTH_SUBJECT_SUBJECT_TYPE, NM_AUTH_SUBJECT_TYPE_INTERNAL, + NM_AUTH_SUBJECT_SUBJECT_TYPE, (int) NM_AUTH_SUBJECT_TYPE_INTERNAL, NULL)); } -/**************************************************************/ +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) @@ -265,7 +264,7 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_SUBJECT_TYPE: - g_value_set_enum (value, priv->subject_type); + g_value_set_int (value, priv->subject_type); break; case PROP_UNIX_PROCESS_DBUS_SENDER: g_value_set_string (value, priv->unix_process.dbus_sender); @@ -287,14 +286,16 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *p { NMAuthSubjectPrivate *priv = NM_AUTH_SUBJECT_GET_PRIVATE ((NMAuthSubject *) object); NMAuthSubjectType subject_type; + int i; const char *str; gulong id; /* all properties are construct-only */ switch (prop_id) { case PROP_SUBJECT_TYPE: - subject_type = g_value_get_enum (value); - g_return_if_fail (subject_type != NM_AUTH_SUBJECT_TYPE_INVALID); + i = g_value_get_int (value); + g_return_if_fail (NM_IN_SET (i, (int) NM_AUTH_SUBJECT_TYPE_INTERNAL, (int) NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS)); + subject_type = i; priv->subject_type |= subject_type; g_return_if_fail (priv->subject_type == subject_type); break; @@ -414,12 +415,13 @@ nm_auth_subject_class_init (NMAuthSubjectClass *config_class) g_object_class_install_property (object_class, PROP_SUBJECT_TYPE, - g_param_spec_enum (NM_AUTH_SUBJECT_SUBJECT_TYPE, "", "", - NM_TYPE_AUTH_SUBJECT_TYPE, - NM_AUTH_SUBJECT_TYPE_INVALID, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + g_param_spec_int (NM_AUTH_SUBJECT_SUBJECT_TYPE, "", "", + NM_AUTH_SUBJECT_TYPE_INVALID, + NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS, + NM_AUTH_SUBJECT_TYPE_INVALID, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_UNIX_PROCESS_DBUS_SENDER, diff --git a/src/nm-auth-utils.c b/src/nm-auth-utils.c index a6bc506c..930f6d0f 100644 --- a/src/nm-auth-utils.c +++ b/src/nm-auth-utils.c @@ -320,6 +320,7 @@ pk_call_cb (GObject *object, GAsyncResult *result, gpointer user_data) AuthCall *call = user_data; GError *error = NULL; gboolean is_authorized, is_challenge; + guint call_result = NM_AUTH_CALL_RESULT_UNKNOWN; nm_auth_manager_polkit_authority_check_authorization_finish (NM_AUTH_MANAGER (object), result, @@ -336,17 +337,11 @@ pk_call_cb (GObject *object, GAsyncResult *result, gpointer user_data) } if (error) { + /* Don't ruin the chain. Just leave the result unknown. */ nm_log_warn (LOGD_CORE, "error requesting auth for %s: %s", call->permission, error->message); - - if (!call->chain->error) { - call->chain->error = error; - error = NULL; - } else - g_clear_error (&error); + g_clear_error (&error); } else { - guint call_result = NM_AUTH_CALL_RESULT_UNKNOWN; - if (is_authorized) { /* Caller has the permission */ call_result = NM_AUTH_CALL_RESULT_YES; @@ -355,10 +350,10 @@ pk_call_cb (GObject *object, GAsyncResult *result, gpointer user_data) call_result = NM_AUTH_CALL_RESULT_AUTH; } else call_result = NM_AUTH_CALL_RESULT_NO; - - nm_auth_chain_set_data (call->chain, call->permission, GUINT_TO_POINTER (call_result), NULL); } + nm_auth_chain_set_data (call->chain, call->permission, GUINT_TO_POINTER (call_result), NULL); + auth_call_complete (call); } #endif diff --git a/src/nm-bus-manager.c b/src/nm-bus-manager.c index 270792ef..ca07e3d9 100644 --- a/src/nm-bus-manager.c +++ b/src/nm-bus-manager.c @@ -21,6 +21,8 @@ #include "nm-default.h" +#include "nm-bus-manager.h" + #include #include #include @@ -28,39 +30,29 @@ #include #include "nm-dbus-interface.h" -#include "nm-bus-manager.h" #include "nm-core-internal.h" #include "nm-dbus-compat.h" #include "nm-exported-object.h" #include "NetworkManagerUtils.h" -#define _NMLOG_DOMAIN LOGD_CORE -#define _NMLOG_PREFIX_NAME "bus-manager" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END +/* The base path for our GDBusObjectManagerServers. They do not contain + * "NetworkManager" because GDBusObjectManagerServer requires that all + * exported objects be *below* the base path, and eg the Manager object + * is the base path already. + */ +#define OBJECT_MANAGER_SERVER_BASE_PATH "/org/freedesktop" + +/*****************************************************************************/ enum { DBUS_CONNECTION_CHANGED = 0, PRIVATE_CONNECTION_NEW, PRIVATE_CONNECTION_DISCONNECTED, - NUMBER_OF_SIGNALS + NUMBER_OF_SIGNALS, }; static guint signals[NUMBER_OF_SIGNALS]; -G_DEFINE_TYPE(NMBusManager, nm_bus_manager, G_TYPE_OBJECT) - -#define NM_BUS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_BUS_MANAGER, \ - NMBusManagerPrivate)) - -typedef struct _PrivateServer PrivateServer; - typedef struct { GDBusConnection *connection; GDBusObjectManagerServer *obj_manager; @@ -74,16 +66,31 @@ typedef struct { guint reconnect_id; } NMBusManagerPrivate; +struct _NMBusManager { + GObject parent; + NMBusManagerPrivate _priv; +}; + +struct _NMBusManagerClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE(NMBusManager, nm_bus_manager, G_TYPE_OBJECT) + +#define NM_BUS_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMBusManager, NM_IS_BUS_MANAGER) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_CORE +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "bus-manager", __VA_ARGS__) + +/*****************************************************************************/ + static gboolean nm_bus_manager_init_bus (NMBusManager *self); static void nm_bus_manager_cleanup (NMBusManager *self); static void start_reconnection_timeout (NMBusManager *self); -/* The base path for our GDBusObjectManagerServers. They do not contain - * "NetworkManager" because GDBusObjectManagerServer requires that all - * exported objects be *below* the base path, and eg the Manager object - * is the base path already. - */ -#define OBJECT_MANAGER_SERVER_BASE_PATH "/org/freedesktop" +/*****************************************************************************/ NM_DEFINE_SINGLETON_REGISTER (NMBusManager); @@ -113,9 +120,9 @@ nm_bus_manager_setup (NMBusManager *instance) _LOGD ("setup %s singleton (%p)", "NMBusManager", singleton_instance); } -/**************************************************************/ +/*****************************************************************************/ -struct _PrivateServer { +typedef struct { const char *tag; GQuark detail; char *address; @@ -133,7 +140,7 @@ struct _PrivateServer { GHashTable *obj_managers; NMBusManager *manager; -}; +} PrivateServer; typedef struct { GDBusConnection *connection; @@ -382,7 +389,7 @@ private_server_get_connection_by_owner (PrivateServer *s, const char *owner) return NULL; } -/**************************************************************/ +/*****************************************************************************/ static gboolean _bus_get_unix_pid (NMBusManager *self, @@ -616,82 +623,7 @@ nm_bus_manager_get_unix_user (NMBusManager *self, return TRUE; } -/**************************************************************/ - -static void -nm_bus_manager_init (NMBusManager *self) -{ - NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self); - - priv->obj_manager = g_dbus_object_manager_server_new (OBJECT_MANAGER_SERVER_BASE_PATH); -} - -static void -nm_bus_manager_dispose (GObject *object) -{ - NMBusManager *self = NM_BUS_MANAGER (object); - NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self); - GList *exported, *iter; - - g_slist_free_full (priv->private_servers, private_server_free); - priv->private_servers = NULL; - - nm_bus_manager_cleanup (self); - - if (priv->obj_manager) { - /* The ObjectManager owns the last reference to many exported - * objects, and when that reference is dropped the objects unregister - * themselves via nm_bus_manager_unregister_object(). By that time - * priv->obj_manager is already NULL and that prints warnings. Unregister - * them before clearing the ObjectManager instead. - */ - exported = g_dbus_object_manager_get_objects ((GDBusObjectManager *) priv->obj_manager); - for (iter = exported; iter; iter = iter->next) { - nm_bus_manager_unregister_object (self, iter->data); - g_object_unref (iter->data); - } - g_list_free (exported); - g_clear_object (&priv->obj_manager); - } - - nm_clear_g_source (&priv->reconnect_id); - - G_OBJECT_CLASS (nm_bus_manager_parent_class)->dispose (object); -} - -static void -nm_bus_manager_class_init (NMBusManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (NMBusManagerPrivate)); - - object_class->dispose = nm_bus_manager_dispose; - - signals[DBUS_CONNECTION_CHANGED] = - g_signal_new (NM_BUS_MANAGER_DBUS_CONNECTION_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMBusManagerClass, dbus_connection_changed), - NULL, NULL, NULL, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - signals[PRIVATE_CONNECTION_NEW] = - g_signal_new (NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_DBUS_CONNECTION, G_TYPE_DBUS_OBJECT_MANAGER_SERVER); - - signals[PRIVATE_CONNECTION_DISCONNECTED] = - g_signal_new (NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - G_STRUCT_OFFSET (NMBusManagerClass, private_connection_disconnected), - NULL, NULL, NULL, - G_TYPE_NONE, 1, G_TYPE_POINTER); -} - +/*****************************************************************************/ /* Only cleanup a specific dbus connection, not all our private data */ static void @@ -1005,3 +937,78 @@ nm_bus_manager_new_proxy (NMBusManager *self, } return proxy; } + +/*****************************************************************************/ + +static void +nm_bus_manager_init (NMBusManager *self) +{ + NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self); + + priv->obj_manager = g_dbus_object_manager_server_new (OBJECT_MANAGER_SERVER_BASE_PATH); +} + +static void +dispose (GObject *object) +{ + NMBusManager *self = NM_BUS_MANAGER (object); + NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self); + GList *exported, *iter; + + g_slist_free_full (priv->private_servers, private_server_free); + priv->private_servers = NULL; + + nm_bus_manager_cleanup (self); + + if (priv->obj_manager) { + /* The ObjectManager owns the last reference to many exported + * objects, and when that reference is dropped the objects unregister + * themselves via nm_bus_manager_unregister_object(). By that time + * priv->obj_manager is already NULL and that prints warnings. Unregister + * them before clearing the ObjectManager instead. + */ + exported = g_dbus_object_manager_get_objects ((GDBusObjectManager *) priv->obj_manager); + for (iter = exported; iter; iter = iter->next) { + nm_bus_manager_unregister_object (self, iter->data); + g_object_unref (iter->data); + } + g_list_free (exported); + g_clear_object (&priv->obj_manager); + } + + nm_clear_g_source (&priv->reconnect_id); + + G_OBJECT_CLASS (nm_bus_manager_parent_class)->dispose (object); +} + +static void +nm_bus_manager_class_init (NMBusManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = dispose; + + signals[DBUS_CONNECTION_CHANGED] = + g_signal_new (NM_BUS_MANAGER_DBUS_CONNECTION_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_POINTER); + + signals[PRIVATE_CONNECTION_NEW] = + g_signal_new (NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_DBUS_CONNECTION, G_TYPE_DBUS_OBJECT_MANAGER_SERVER); + + signals[PRIVATE_CONNECTION_DISCONNECTED] = + g_signal_new (NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_POINTER); +} + + + diff --git a/src/nm-bus-manager.h b/src/nm-bus-manager.h index bc23d2ce..153f7cdc 100644 --- a/src/nm-bus-manager.h +++ b/src/nm-bus-manager.h @@ -33,23 +33,7 @@ #define NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW "private-connection-new" #define NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "private-connection-disconnected" -struct _NMBusManager { - GObject parent; -}; - -typedef struct { - GObjectClass parent; - - /* Signals */ - void (*dbus_connection_changed) (NMBusManager *mgr, - GDBusConnection *connection); - - void (*private_connection_new) (NMBusManager *mgr, - GDBusConnection *connection); - - void (*private_connection_disconnected) (NMBusManager *mgr, - GDBusConnection *connection); -} NMBusManagerClass; +typedef struct _NMBusManagerClass NMBusManagerClass; GType nm_bus_manager_get_type (void); diff --git a/src/nm-checkpoint-manager.c b/src/nm-checkpoint-manager.c index 254dc31e..7f9aa398 100644 --- a/src/nm-checkpoint-manager.c +++ b/src/nm-checkpoint-manager.c @@ -25,7 +25,7 @@ #include "nm-checkpoint.h" #include "nm-connection.h" #include "nm-core-utils.h" -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-exported-object.h" #include "nm-manager.h" #include "nm-utils.h" @@ -51,14 +51,8 @@ struct _NMCheckpointManager { /*****************************************************************************/ -#define _NMLOG_PREFIX_NAME "checkpoint" -#define _NMLOG_DOMAIN LOGD_CORE - -#define _NMLOG(level, ...) \ - nm_log (level, _NMLOG_DOMAIN, \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)) +#define _NMLOG_DOMAIN LOGD_CORE +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "checkpoint", __VA_ARGS__) /*****************************************************************************/ @@ -145,19 +139,31 @@ nm_checkpoint_manager_create (NMCheckpointManager *self, NMCheckpointCreateFlags flags, GError **error) { + NMManager *manager; NMCheckpoint *checkpoint; const char * const *path; gs_unref_ptrarray GPtrArray *devices = NULL; NMDevice *device; const char *checkpoint_path; + gs_free const char **device_paths_free = NULL; guint i; g_return_val_if_fail (self, FALSE); g_return_val_if_fail (!error || !*error, FALSE); + manager = GET_MANAGER (self); + + if (!device_paths || !device_paths[0]) { + device_paths_free = nm_manager_get_device_paths (manager); + device_paths = (const char *const *) device_paths_free; + } else if (NM_FLAGS_HAS (flags, NM_CHECKPOINT_CREATE_FLAG_DISCONNECT_NEW_DEVICES)) { + g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_ARGUMENTS, + "the DISCONNECT_NEW_DEVICES flag can only be used with an empty device list"); + return NULL; + } devices = g_ptr_array_new (); for (path = device_paths; *path; path++) { - device = nm_manager_get_device_by_path (GET_MANAGER (self), *path); + device = nm_manager_get_device_by_path (manager, *path); if (!device) { g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE, "device %s does not exist", *path); @@ -178,8 +184,7 @@ nm_checkpoint_manager_create (NMCheckpointManager *self, } } - checkpoint = nm_checkpoint_new (GET_MANAGER (self), devices, - rollback_timeout, error); + checkpoint = nm_checkpoint_new (manager, devices, rollback_timeout, flags, error); if (!checkpoint) return NULL; @@ -295,4 +300,3 @@ nm_checkpoint_manager_unref (NMCheckpointManager *self) g_slice_free (NMCheckpointManager, self); } - diff --git a/src/nm-checkpoint-manager.h b/src/nm-checkpoint-manager.h index 022b1a80..30e49041 100644 --- a/src/nm-checkpoint-manager.h +++ b/src/nm-checkpoint-manager.h @@ -22,6 +22,7 @@ #define __NM_CHECKPOINT_MANAGER_H__ #include "nm-dbus-interface.h" + #include "nm-checkpoint.h" typedef struct _NMCheckpointManager NMCheckpointManager; @@ -47,4 +48,3 @@ gboolean nm_checkpoint_manager_rollback (NMCheckpointManager *self, GError **error); #endif /* __NM_CHECKPOINT_MANAGER_H__ */ - diff --git a/src/nm-checkpoint.c b/src/nm-checkpoint.c index 605e0700..7d89e61e 100644 --- a/src/nm-checkpoint.c +++ b/src/nm-checkpoint.c @@ -19,6 +19,7 @@ */ #include "nm-default.h" + #include "nm-checkpoint.h" #include @@ -26,38 +27,32 @@ #include "nm-auth-subject.h" #include "nm-core-utils.h" #include "nm-dbus-interface.h" -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-manager.h" -#include "nm-settings.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings.h" +#include "settings/nm-settings-connection.h" #include "nm-simple-connection.h" #include "nm-utils.h" -#include "nmdbus-checkpoint.h" +#include "introspection/org.freedesktop.NetworkManager.Checkpoint.h" -#define _NMLOG_PREFIX_NAME "checkpoint" -#define _NMLOG_DOMAIN LOGD_CORE - -#define _NMLOG(level, ...) \ - G_STMT_START { \ - if (nm_logging_enabled (level, _NMLOG_DOMAIN)) { \ - char __prefix[32]; \ - \ - if (self) \ - g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \ - else \ - g_strlcpy (__prefix, _NMLOG_PREFIX_NAME, sizeof (__prefix)); \ - _nm_log ((level), (_NMLOG_DOMAIN), 0, \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } \ - } G_STMT_END +/*****************************************************************************/ typedef struct { char *original_dev_path; NMDevice *device; - NMConnection *connection; + NMConnection *applied_connection; + NMConnection *settings_connection; + NMDeviceState state; + bool realized:1; + bool unmanaged_explicit:1; } DeviceCheckpoint; +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_DEVICES, + PROP_CREATED, + PROP_ROLLBACK_TIMEOUT, +); + typedef struct { /* properties */ GHashTable *devices; @@ -66,6 +61,8 @@ typedef struct { /* private members */ NMManager *manager; gint64 rollback_ts; + NMCheckpointCreateFlags flags; + GHashTable *connection_uuids; } NMCheckpointPrivate; struct _NMCheckpoint { @@ -73,19 +70,35 @@ struct _NMCheckpoint { NMCheckpointPrivate _priv; }; -typedef struct { +struct _NMCheckpointClass { NMExportedObjectClass parent; -} NMCheckpointClass; +}; G_DEFINE_TYPE (NMCheckpoint, nm_checkpoint, NM_TYPE_EXPORTED_OBJECT) -#define NM_CHECKPOINT_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMCheckpoint, NM_IS_CHECKPOINT) +#define NM_CHECKPOINT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMCheckpoint, NM_IS_CHECKPOINT) -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_DEVICES, - PROP_CREATED, - PROP_ROLLBACK_TIMEOUT, -); +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "checkpoint" +#define _NMLOG_DOMAIN LOGD_CORE + +#define _NMLOG(level, ...) \ + G_STMT_START { \ + if (nm_logging_enabled (level, _NMLOG_DOMAIN)) { \ + char __prefix[32]; \ + \ + if (self) \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \ + else \ + g_strlcpy (__prefix, _NMLOG_PREFIX_NAME, sizeof (__prefix)); \ + _nm_log ((level), (_NMLOG_DOMAIN), 0, \ + "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } \ + } G_STMT_END + +/*****************************************************************************/ guint64 nm_checkpoint_get_rollback_ts (NMCheckpoint *self) @@ -122,47 +135,75 @@ nm_checkpoint_rollback (NMCheckpoint *self) while (g_hash_table_iter_next (&iter, (gpointer *) &device, (gpointer *) &dev_checkpoint)) { gs_unref_object NMAuthSubject *subject = NULL; guint32 result = NM_ROLLBACK_RESULT_OK; - const char *con_path; - - _LOGD ("rollback: restoring state of device %s", nm_device_get_iface (device)); - - if (!nm_device_is_real (device)) { - result = NM_ROLLBACK_RESULT_ERR_NO_DEVICE; - _LOGD ("rollback: device is not realized"); + const char *con_uuid; + + _LOGD ("rollback: restoring device %s (state %d, realized %d, explicitly unmanaged %d)", + nm_device_get_iface (device), + (int) dev_checkpoint->state, + dev_checkpoint->realized, + dev_checkpoint->unmanaged_explicit); + + if (nm_device_is_real (device)) { + if (!dev_checkpoint->realized) { + _LOGD ("rollback: device was not realized, unmanage it"); + nm_device_set_unmanaged_by_flags_queue (device, + NM_UNMANAGED_USER_EXPLICIT, + TRUE, + NM_DEVICE_STATE_REASON_NOW_UNMANAGED); + goto next_dev; + } + } else { + if (dev_checkpoint->realized) { + if (nm_device_is_software (device)) { + /* try to recreate software device */ + _LOGD ("rollback: software device not realized, will re-activate"); + goto activate; + } else { + _LOGD ("rollback: device is not realized"); + result = NM_ROLLBACK_RESULT_ERR_FAILED; + } + } goto next_dev; } - if (nm_device_get_state (device) <= NM_DEVICE_STATE_UNMANAGED) { - result = NM_ROLLBACK_RESULT_ERR_DEVICE_UNMANAGED; - _LOGD ("rollback: device is unmanaged"); +activate: + if (dev_checkpoint->state == NM_DEVICE_STATE_UNMANAGED) { + if ( nm_device_get_state (device) != NM_DEVICE_STATE_UNMANAGED + || dev_checkpoint->unmanaged_explicit) { + _LOGD ("rollback: explicitly unmanage device"); + nm_device_set_unmanaged_by_flags_queue (device, + NM_UNMANAGED_USER_EXPLICIT, + TRUE, + NM_DEVICE_STATE_REASON_NOW_UNMANAGED); + } goto next_dev; } - if (dev_checkpoint->connection) { + if (dev_checkpoint->applied_connection) { /* The device had an active connection, check if the * connection still exists * */ - con_path = nm_connection_get_path (dev_checkpoint->connection); - connection = nm_settings_get_connection_by_path (nm_settings_get(), con_path); + con_uuid = nm_connection_get_uuid (dev_checkpoint->settings_connection); + connection = nm_settings_get_connection_by_uuid (nm_settings_get (), con_uuid); if (connection) { /* If the connection is still there, restore its content * and save it * */ - _LOGD ("rollback: connection %s still exists", con_path); + _LOGD ("rollback: connection %s still exists", con_uuid); nm_connection_replace_settings_from_connection (NM_CONNECTION (connection), - dev_checkpoint->connection); + dev_checkpoint->settings_connection); nm_settings_connection_commit_changes (connection, NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL, NULL); } else { /* The connection was deleted, recreate it */ - _LOGD ("rollback: adding connection %s again", con_path); + _LOGD ("rollback: adding connection %s again", con_uuid); connection = nm_settings_add_connection (nm_settings_get (), - dev_checkpoint->connection, + dev_checkpoint->settings_connection, TRUE, &local_error); if (!connection) { @@ -177,6 +218,7 @@ nm_checkpoint_rollback (NMCheckpoint *self) subject = nm_auth_subject_new_internal (); if (!nm_manager_activate_connection (priv->manager, connection, + dev_checkpoint->applied_connection, NULL, device, subject, @@ -205,6 +247,47 @@ next_dev: g_variant_builder_add (&builder, "{su}", dev_checkpoint->original_dev_path, result); } + if (NM_FLAGS_HAS (priv->flags, NM_CHECKPOINT_CREATE_FLAG_DELETE_NEW_CONNECTIONS)) { + NMSettingsConnection *con; + gs_free_slist GSList *list = NULL; + GSList *item; + + g_return_val_if_fail (priv->connection_uuids, NULL); + list = nm_settings_get_connections_sorted (nm_settings_get ()); + + for (item = list; item; item = g_slist_next (item)) { + con = item->data; + if (!g_hash_table_contains (priv->connection_uuids, + nm_settings_connection_get_uuid (con))) { + _LOGD ("rollback: deleting new connection %s (%s)", + nm_settings_connection_get_uuid (con), + nm_settings_connection_get_id (con)); + nm_settings_connection_delete (con, NULL, NULL); + } + } + } + + if (NM_FLAGS_HAS (priv->flags, NM_CHECKPOINT_CREATE_FLAG_DISCONNECT_NEW_DEVICES)) { + const GSList *list = nm_manager_get_devices (priv->manager); + NMDeviceState state; + NMDevice *dev; + + for (list = nm_manager_get_devices (priv->manager); list ; list = g_slist_next (list)) { + dev = list->data; + if (!g_hash_table_contains (priv->devices, dev)) { + state = nm_device_get_state (dev); + if ( state > NM_DEVICE_STATE_DISCONNECTED + && state < NM_DEVICE_STATE_DEACTIVATING) { + _LOGD ("rollback: disconnecting new device %s", nm_device_get_iface (dev)); + nm_device_state_changed (dev, + NM_DEVICE_STATE_DEACTIVATING, + NM_DEVICE_STATE_REASON_USER_REQUESTED); + } + } + } + + } + return g_variant_new ("(a{su})", &builder); } @@ -213,36 +296,32 @@ device_checkpoint_create (NMDevice *device, GError **error) { DeviceCheckpoint *dev_checkpoint; - NMConnection *connection; + NMConnection *applied_connection; + NMSettingsConnection *settings_connection; const char *path; - - if (!nm_device_is_real (device)) { - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_INVALID_ARGUMENTS, - "device '%s' is not realized", - nm_device_get_iface (device)); - return NULL; - } - - if (nm_device_get_state (device) <= NM_DEVICE_STATE_UNMANAGED) { - g_set_error (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_INVALID_ARGUMENTS, - "device '%s' is unmanaged", - nm_device_get_iface (device)); - return NULL; - } + gboolean unmanaged_explicit; path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (device)); + unmanaged_explicit = !!nm_device_get_unmanaged_flags (device, + NM_UNMANAGED_USER_EXPLICIT); dev_checkpoint = g_slice_new0 (DeviceCheckpoint); dev_checkpoint->device = g_object_ref (device); dev_checkpoint->original_dev_path = g_strdup (path); - - connection = nm_device_get_applied_connection (device); - if (connection) - dev_checkpoint->connection = nm_simple_connection_new_clone (connection); + dev_checkpoint->state = nm_device_get_state (device); + dev_checkpoint->realized = nm_device_is_real (device); + dev_checkpoint->unmanaged_explicit = unmanaged_explicit; + + applied_connection = nm_device_get_applied_connection (device); + if (applied_connection) { + dev_checkpoint->applied_connection = + nm_simple_connection_new_clone (applied_connection); + + settings_connection = nm_device_get_settings_connection (device); + g_return_val_if_fail (settings_connection, NULL); + dev_checkpoint->settings_connection = + nm_simple_connection_new_clone (NM_CONNECTION (settings_connection)); + } return dev_checkpoint; } @@ -252,51 +331,63 @@ device_checkpoint_destroy (gpointer data) { DeviceCheckpoint *dev_checkpoint = data; - g_clear_object (&dev_checkpoint->connection); + g_clear_object (&dev_checkpoint->applied_connection); + g_clear_object (&dev_checkpoint->settings_connection); g_clear_object (&dev_checkpoint->device); g_free (dev_checkpoint->original_dev_path); g_slice_free (DeviceCheckpoint, dev_checkpoint); } +/*****************************************************************************/ + static void -nm_checkpoint_init (NMCheckpoint *self) +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { + NMCheckpoint *self = NM_CHECKPOINT (object); NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self); + gs_free_slist GSList *devices = NULL; + GHashTableIter iter; + NMDevice *device; - priv->devices = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, device_checkpoint_destroy); + switch (prop_id) { + case PROP_DEVICES: + g_hash_table_iter_init (&iter, priv->devices); + while (g_hash_table_iter_next (&iter, (gpointer *) &device, NULL)) + devices = g_slist_append (devices, device); + nm_utils_g_value_set_object_path_array (value, devices, NULL, NULL); + break; + case PROP_CREATED: + g_value_set_int64 (value, priv->created); + break; + case PROP_ROLLBACK_TIMEOUT: + g_value_set_uint (value, priv->rollback_timeout); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } +/*****************************************************************************/ + static void -get_all_devices (NMManager *manager, GPtrArray *devices) +nm_checkpoint_init (NMCheckpoint *self) { - const GSList *list, *iter; - NMDevice *dev; - - list = nm_manager_get_devices (manager); - - for (iter = list; iter; iter = g_slist_next (iter)) { - dev = iter->data; - - if (!nm_device_is_real (dev)) - continue; - if (nm_device_get_state (dev) <= NM_DEVICE_STATE_UNMANAGED) - continue; - /* We never touch assumed connections, unless told explicitly */ - if (nm_device_uses_assumed_connection (dev)) - continue; + NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self); - g_ptr_array_add (devices, dev); - } + priv->devices = g_hash_table_new_full (g_direct_hash, g_direct_equal, + NULL, device_checkpoint_destroy); } NMCheckpoint * nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_timeout, - GError **error) + NMCheckpointCreateFlags flags, GError **error) { NMCheckpoint *self; NMCheckpointPrivate *priv; + NMSettingsConnection *const *con; DeviceCheckpoint *dev_checkpoint; NMDevice *device; guint i; @@ -305,9 +396,6 @@ nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_time g_return_val_if_fail (devices, NULL); g_return_val_if_fail (!error || !*error, NULL); - if (!devices->len) - get_all_devices (manager, devices); - if (!devices->len) { g_set_error_literal (error, NM_MANAGER_ERROR, @@ -326,6 +414,15 @@ nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_time priv->rollback_ts = rollback_timeout ? (nm_utils_get_monotonic_timestamp_ms () + ((gint64) rollback_timeout * 1000)) : 0; + priv->flags = flags; + + if (NM_FLAGS_HAS (flags, NM_CHECKPOINT_CREATE_FLAG_DELETE_NEW_CONNECTIONS)) { + priv->connection_uuids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + for (con = nm_settings_get_connections (nm_settings_get (), NULL); *con; con++) { + g_hash_table_add (priv->connection_uuids, + g_strdup (nm_settings_connection_get_uuid (*con))); + } + } for (i = 0; i < devices->len; i++) { device = (NMDevice *) devices->pdata[i]; @@ -347,55 +444,23 @@ dispose (GObject *object) NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self); g_clear_pointer (&priv->devices, g_hash_table_unref); + g_clear_pointer (&priv->connection_uuids, g_hash_table_unref); G_OBJECT_CLASS (nm_checkpoint_parent_class)->dispose (object); } -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMCheckpoint *self = NM_CHECKPOINT (object); - NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self); - gs_free_slist GSList *devices = NULL; - GHashTableIter iter; - NMDevice *device; - - switch (prop_id) { - case PROP_DEVICES: - g_hash_table_iter_init (&iter, priv->devices); - while (g_hash_table_iter_next (&iter, (gpointer *) &device, NULL)) - devices = g_slist_append (devices, device); - nm_utils_g_value_set_object_path_array (value, devices, NULL, NULL); - break; - case PROP_CREATED: - g_value_set_int64 (value, priv->created); - break; - case PROP_ROLLBACK_TIMEOUT: - g_value_set_uint (value, priv->rollback_timeout); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void nm_checkpoint_class_init (NMCheckpointClass *checkpoint_class) { GObjectClass *object_class = G_OBJECT_CLASS (checkpoint_class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (checkpoint_class); - g_type_class_add_private (checkpoint_class, sizeof (NMCheckpointPrivate)); - - exported_object_class->export_path = NM_DBUS_PATH "/Checkpoint/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/Checkpoint"); exported_object_class->export_on_construction = FALSE; - /* virtual methods */ object_class->dispose = dispose; object_class->get_property = get_property; - /* properties */ obj_properties[PROP_DEVICES] = g_param_spec_boxed (NM_CHECKPOINT_DEVICES, "", "", G_TYPE_STRV, diff --git a/src/nm-checkpoint.h b/src/nm-checkpoint.h index c7d2d42f..fccf8af3 100644 --- a/src/nm-checkpoint.h +++ b/src/nm-checkpoint.h @@ -31,16 +31,17 @@ #define NM_IS_CHECKPOINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CHECKPOINT)) #define NM_CHECKPOINT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CHECKPOINT, NMCheckpointClass)) -typedef struct _NMCheckpoint NMCheckpoint; - #define NM_CHECKPOINT_DEVICES "devices" #define NM_CHECKPOINT_CREATED "created" #define NM_CHECKPOINT_ROLLBACK_TIMEOUT "rollback-timeout" +typedef struct _NMCheckpoint NMCheckpoint; +typedef struct _NMCheckpointClass NMCheckpointClass; + GType nm_checkpoint_get_type (void); NMCheckpoint *nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_timeout, - GError **error); + NMCheckpointCreateFlags flags, GError **error); guint64 nm_checkpoint_get_rollback_ts (NMCheckpoint *checkpoint); gboolean nm_checkpoint_includes_device (NMCheckpoint *checkpoint, NMDevice *device); diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 23c4cecd..0d554e55 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -26,10 +26,12 @@ #include #include "nm-config.h" -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-core-internal.h" #include "nm-keyfile-internal.h" +/*****************************************************************************/ + typedef struct { char *group_name; gboolean stop_match; @@ -42,6 +44,33 @@ typedef struct { } match_device; } MatchSectionInfo; +struct _NMGlobalDnsDomain { + char *name; + char **servers; + char **options; +}; + +struct _NMGlobalDnsConfig { + char **searches; + char **options; + GHashTable *domains; + char **domain_list; + gboolean internal; +}; + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_CONFIG_MAIN_FILE, + PROP_CONFIG_DESCRIPTION, + PROP_KEYFILE_USER, + PROP_KEYFILE_INTERN, + PROP_CONNECTIVITY_URI, + PROP_CONNECTIVITY_INTERVAL, + PROP_CONNECTIVITY_RESPONSE, + PROP_NO_AUTO_DEFAULT, +); + typedef struct { char *config_main_file; char *config_description; @@ -82,40 +111,20 @@ typedef struct { char *value_cached; } NMConfigDataPrivate; -struct _NMGlobalDnsDomain { - char *name; - char **servers; - char **options; +struct _NMConfigData { + GObject parent; + NMConfigDataPrivate _priv; }; -struct _NMGlobalDnsConfig { - char **searches; - char **options; - GHashTable *domains; - char **domain_list; - gboolean internal; -}; - -enum { - PROP_0, - PROP_CONFIG_MAIN_FILE, - PROP_CONFIG_DESCRIPTION, - PROP_KEYFILE_USER, - PROP_KEYFILE_INTERN, - PROP_CONNECTIVITY_URI, - PROP_CONNECTIVITY_INTERVAL, - PROP_CONNECTIVITY_RESPONSE, - PROP_NO_AUTO_DEFAULT, - - LAST_PROP +struct _NMConfigDataClass { + GObjectClass parent; }; - G_DEFINE_TYPE (NMConfigData, nm_config_data, G_TYPE_OBJECT) -#define NM_CONFIG_DATA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONFIG_DATA, NMConfigDataPrivate)) +#define NM_CONFIG_DATA_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMConfigData, NM_IS_CONFIG_DATA) -/************************************************************************/ +/*****************************************************************************/ #define _HAS_PREFIX(str, prefix) \ ({ \ @@ -123,7 +132,7 @@ G_DEFINE_TYPE (NMConfigData, nm_config_data, G_TYPE_OBJECT) g_str_has_prefix ( _str, ""prefix"") && _str[NM_STRLEN(prefix)] != '\0'; \ }) -/************************************************************************/ +/*****************************************************************************/ const char * nm_config_data_get_config_main_file (const NMConfigData *self) @@ -162,7 +171,7 @@ nm_config_data_get_value (const NMConfigData *self, const char *group, const cha const char *nm_config_data_get_value_cached (const NMConfigData *self, const char *group, const char *key, NMConfigGetValueFlags flags) { - NMConfigDataPrivate *priv; + const NMConfigDataPrivate *priv; g_return_val_if_fail (NM_IS_CONFIG_DATA (self), NULL); g_return_val_if_fail (group && *group, NULL); @@ -171,8 +180,8 @@ const char *nm_config_data_get_value_cached (const NMConfigData *self, const cha priv = NM_CONFIG_DATA_GET_PRIVATE (self); /* we modify @value_cached. In C++ jargon, the field is mutable. */ - g_free (priv->value_cached); - priv->value_cached = nm_config_keyfile_get_value (priv->keyfile, group, key, flags); + g_free (((NMConfigDataPrivate *) priv)->value_cached); + ((NMConfigDataPrivate *) priv)->value_cached = nm_config_keyfile_get_value (priv->keyfile, group, key, flags); return priv->value_cached; } @@ -208,6 +217,27 @@ nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, c return value; } +char ** +nm_config_data_get_plugins (const NMConfigData *self, gboolean allow_default) +{ + const NMConfigDataPrivate *priv; + char **list; + + g_return_val_if_fail (self, NULL); + + priv = NM_CONFIG_DATA_GET_PRIVATE (self); + + list = g_key_file_get_string_list (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL); + if (!list && allow_default) { + gs_unref_keyfile GKeyFile *kf = nm_config_create_keyfile (); + + /* let keyfile split the default string according to it's own escaping rules. */ + g_key_file_set_value (kf, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NM_CONFIG_DEFAULT_MAIN_PLUGINS); + list = g_key_file_get_string_list (kf, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL); + } + return _nm_utils_strv_cleanup (list, TRUE, TRUE, TRUE); +} + const char * nm_config_data_get_connectivity_uri (const NMConfigData *self) { @@ -243,7 +273,7 @@ nm_config_data_get_no_auto_default (const NMConfigData *self) gboolean nm_config_data_get_no_auto_default_for_device (const NMConfigData *self, NMDevice *device) { - NMConfigDataPrivate *priv; + const NMConfigDataPrivate *priv; g_return_val_if_fail (NM_IS_CONFIG_DATA (self), FALSE); g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); @@ -297,7 +327,7 @@ nm_config_data_get_assume_ipv6ll_only (const NMConfigData *self, NMDevice *devic GKeyFile * nm_config_data_clone_keyfile_intern (const NMConfigData *self) { - NMConfigDataPrivate *priv; + const NMConfigDataPrivate *priv; GKeyFile *keyfile; g_return_val_if_fail (NM_IS_CONFIG_DATA (self), FALSE); @@ -328,7 +358,7 @@ _nm_config_data_get_keyfile_user (const NMConfigData *self) return NM_CONFIG_DATA_GET_PRIVATE (self)->keyfile_user; } -/************************************************************************/ +/*****************************************************************************/ /** * nm_config_data_get_groups: @@ -373,7 +403,7 @@ nm_config_data_get_keys (const NMConfigData *self, const char *group) gboolean nm_config_data_is_intern_atomic_group (const NMConfigData *self, const char *group) { - NMConfigDataPrivate *priv; + const NMConfigDataPrivate *priv; g_return_val_if_fail (NM_IS_CONFIG_DATA (self), FALSE); g_return_val_if_fail (group && *group, FALSE); @@ -391,7 +421,7 @@ nm_config_data_is_intern_atomic_group (const NMConfigData *self, const char *gro return g_key_file_has_group (priv->keyfile, group); } -/************************************************************************/ +/*****************************************************************************/ static GKeyFile * _merge_keyfiles (GKeyFile *keyfile_user, GKeyFile *keyfile_intern) @@ -456,7 +486,7 @@ _merge_keyfiles (GKeyFile *keyfile_user, GKeyFile *keyfile_intern) return keyfile; } -/************************************************************************/ +/*****************************************************************************/ static int _nm_config_data_log_sort (const char **pa, const char **pb, gpointer dummy) @@ -464,6 +494,7 @@ _nm_config_data_log_sort (const char **pa, const char **pb, gpointer dummy) gboolean a_is_connection, b_is_connection; gboolean a_is_device, b_is_device; gboolean a_is_intern, b_is_intern; + gboolean a_is_main, b_is_main; const char *a = *pa; const char *b = *pb; @@ -522,9 +553,26 @@ _nm_config_data_log_sort (const char **pa, const char **pb, gpointer dummy) if (b_is_device && !a_is_device) return -1; - /* no reordering. */ - return 0; -} + a_is_main = nm_streq0 (a, "main"); + b_is_main = nm_streq0 (b, "main"); + if (a_is_main != b_is_main) + return a_is_main ? -1 : 1; + + return g_strcmp0 (a, b); +} + +static struct { + const char *group; + const char *key; + const char *value; +} default_values[] = { + { NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NM_CONFIG_DEFAULT_MAIN_PLUGINS }, + { NM_CONFIG_KEYFILE_GROUP_MAIN, "rc-manager", NM_CONFIG_DEFAULT_MAIN_RC_MANAGER }, + { NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT, NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT }, + { NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_DHCP, NM_CONFIG_DEFAULT_MAIN_DHCP }, + { NM_CONFIG_KEYFILE_GROUP_LOGGING, "backend", NM_CONFIG_DEFAULT_LOGGING_BACKEND }, + { NM_CONFIG_KEYFILE_GROUP_LOGGING, "audit", NM_CONFIG_DEFAULT_LOGGING_AUDIT }, +}; void nm_config_data_log (const NMConfigData *self, @@ -532,11 +580,13 @@ nm_config_data_log (const NMConfigData *self, const char *key_prefix, /* FILE* */ gpointer print_stream) { - NMConfigDataPrivate *priv; + const NMConfigDataPrivate *priv; gs_strfreev char **groups = NULL; gsize ngroups; - guint g, k; + guint g, k, i; FILE *stream = print_stream; + gs_unref_ptrarray GPtrArray *groups_full = NULL; + gboolean print_default = !!stream; g_return_if_fail (NM_IS_CONFIG_DATA (self)); @@ -562,18 +612,35 @@ nm_config_data_log (const NMConfigData *self, if (!groups) ngroups = 0; - if (groups && groups[0]) { - g_qsort_with_data (groups, ngroups, - sizeof (char *), - (GCompareDataFunc) _nm_config_data_log_sort, - NULL); + groups_full = g_ptr_array_sized_new (ngroups + 5); + + if (ngroups) { + g_ptr_array_set_size (groups_full, ngroups); + memcpy (groups_full->pdata, groups, sizeof (groups[0]) * ngroups); + g_ptr_array_sort_with_data (groups_full, (GCompareDataFunc) _nm_config_data_log_sort, NULL); + } + + if (print_default) { + for (g = 0; g < G_N_ELEMENTS (default_values); g++) { + const char *group = default_values[g].group; + gssize idx; + + idx = _nm_utils_array_find_binary_search ((gconstpointer *) groups_full->pdata, + sizeof (char *), + groups_full->len, + &group, + (GCompareDataFunc) _nm_config_data_log_sort, + NULL); + if (idx < 0) + g_ptr_array_insert (groups_full, (~idx), (gpointer) group); + } } if (!stream) - _LOG (stream, prefix, "config-data[%p]: %lu groups", self, (unsigned long) ngroups); + _LOG (stream, prefix, "config-data[%p]: %u groups", self, groups_full->len); - for (g = 0; g < ngroups; g++) { - const char *group = groups[g]; + for (g = 0; g < groups_full->len; g++) { + const char *group = groups_full->pdata[g]; gs_strfreev char **keys = NULL; gboolean is_atomic; @@ -582,6 +649,17 @@ nm_config_data_log (const NMConfigData *self, _LOG (stream, prefix, ""); _LOG (stream, prefix, "[%s]%s", group, is_atomic && !stream ? " # atomic section" : ""); + /* Print default values as comments */ + if (print_default) { + for (i = 0; i < G_N_ELEMENTS (default_values); i++) { + if ( nm_streq (default_values[i].group, group) + && !g_key_file_has_key (priv->keyfile, group, default_values[i].key, NULL)) { + _LOG (stream, prefix, "%s# %s=%s", key_prefix, default_values[i].key, + default_values[i].value); + } + } + } + keys = g_key_file_get_keys (priv->keyfile, group, NULL, NULL); for (k = 0; keys && keys[k]; k++) { const char *key = keys[k]; @@ -595,7 +673,7 @@ nm_config_data_log (const NMConfigData *self, #undef _LOG } -/************************************************************************/ +/*****************************************************************************/ const char *const * nm_global_dns_config_get_searches (const NMGlobalDnsConfig *dns) @@ -1081,7 +1159,7 @@ global_dns_equal (NMGlobalDnsConfig *old, NMGlobalDnsConfig *new) return TRUE; } -/************************************************************************/ +/*****************************************************************************/ static const MatchSectionInfo * _match_section_infos_lookup (const MatchSectionInfo *match_section_infos, @@ -1127,7 +1205,7 @@ nm_config_data_get_device_config (const NMConfigData *self, NMDevice *device, gboolean *has_match) { - NMConfigDataPrivate *priv; + const NMConfigDataPrivate *priv; const MatchSectionInfo *connection_info; char *value = NULL; @@ -1166,7 +1244,7 @@ nm_config_data_get_connection_default (const NMConfigData *self, const char *property, NMDevice *device) { - NMConfigDataPrivate *priv; + const NMConfigDataPrivate *priv; char *value = NULL; g_return_val_if_fail (self, NULL); @@ -1261,7 +1339,7 @@ _match_section_infos_construct (GKeyFile *keyfile, const char *prefix) return match_section_infos; } -/************************************************************************/ +/*****************************************************************************/ static gboolean _slist_str_equals (GSList *a, GSList *b) @@ -1318,7 +1396,7 @@ nm_config_data_diff (NMConfigData *old_data, NMConfigData *new_data) return changes; } -/************************************************************************/ +/*****************************************************************************/ static void get_property (GObject *object, @@ -1409,47 +1487,7 @@ set_property (GObject *object, } } -static void -dispose (GObject *object) -{ -} - -static void -finalize (GObject *gobject) -{ - NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE (gobject); - - g_free (priv->config_main_file); - g_free (priv->config_description); - - g_free (priv->connectivity.uri); - g_free (priv->connectivity.response); - - g_slist_free_full (priv->no_auto_default.specs, g_free); - g_slist_free_full (priv->no_auto_default.specs_config, g_free); - g_strfreev (priv->no_auto_default.arr); - - g_free (priv->dns_mode); - g_free (priv->rc_manager); - - g_slist_free_full (priv->ignore_carrier, g_free); - g_slist_free_full (priv->assume_ipv6ll_only, g_free); - - nm_global_dns_config_free (priv->global_dns); - - _match_section_infos_free (priv->connection_infos); - _match_section_infos_free (priv->device_infos); - - g_key_file_unref (priv->keyfile); - if (priv->keyfile_user) - g_key_file_unref (priv->keyfile_user); - if (priv->keyfile_intern) - g_key_file_unref (priv->keyfile_intern); - - G_OBJECT_CLASS (nm_config_data_parent_class)->finalize (gobject); - - g_free (priv->value_cached); -} +/*****************************************************************************/ static void nm_config_data_init (NMConfigData *self) @@ -1513,7 +1551,7 @@ nm_config_data_new (const char *config_main_file, NMConfigData * nm_config_data_new_update_keyfile_intern (const NMConfigData *base, GKeyFile *keyfile_intern) { - NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE (base); + const NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE (base); return g_object_new (NM_TYPE_CONFIG_DATA, NM_CONFIG_DATA_CONFIG_MAIN_FILE, priv->config_main_file, @@ -1528,7 +1566,7 @@ NMConfigData * nm_config_data_new_update_no_auto_default (const NMConfigData *base, const char *const*no_auto_default) { - NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE (base); + const NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE (base); return g_object_new (NM_TYPE_CONFIG_DATA, NM_CONFIG_DATA_CONFIG_MAIN_FILE, priv->config_main_file, @@ -1539,79 +1577,105 @@ nm_config_data_new_update_no_auto_default (const NMConfigData *base, NULL); } +static void +finalize (GObject *gobject) +{ + NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE ((NMConfigData *) gobject); + + g_free (priv->config_main_file); + g_free (priv->config_description); + + g_free (priv->connectivity.uri); + g_free (priv->connectivity.response); + + g_slist_free_full (priv->no_auto_default.specs, g_free); + g_slist_free_full (priv->no_auto_default.specs_config, g_free); + g_strfreev (priv->no_auto_default.arr); + + g_free (priv->dns_mode); + g_free (priv->rc_manager); + + g_slist_free_full (priv->ignore_carrier, g_free); + g_slist_free_full (priv->assume_ipv6ll_only, g_free); + + nm_global_dns_config_free (priv->global_dns); + + _match_section_infos_free (priv->connection_infos); + _match_section_infos_free (priv->device_infos); + + g_key_file_unref (priv->keyfile); + if (priv->keyfile_user) + g_key_file_unref (priv->keyfile_user); + if (priv->keyfile_intern) + g_key_file_unref (priv->keyfile_intern); + + G_OBJECT_CLASS (nm_config_data_parent_class)->finalize (gobject); + + g_free (priv->value_cached); +} + static void nm_config_data_class_init (NMConfigDataClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); - g_type_class_add_private (config_class, sizeof (NMConfigDataPrivate)); - object_class->constructed = constructed; - object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; object_class->set_property = set_property; - g_object_class_install_property - (object_class, PROP_CONFIG_MAIN_FILE, + obj_properties[PROP_CONFIG_MAIN_FILE] = g_param_spec_string (NM_CONFIG_DATA_CONFIG_MAIN_FILE, "", "", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_CONFIG_DESCRIPTION, + obj_properties[PROP_CONFIG_DESCRIPTION] = g_param_spec_string (NM_CONFIG_DATA_CONFIG_DESCRIPTION, "", "", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_KEYFILE_USER, - g_param_spec_boxed (NM_CONFIG_DATA_KEYFILE_USER, "", "", - G_TYPE_KEY_FILE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_KEYFILE_INTERN, - g_param_spec_boxed (NM_CONFIG_DATA_KEYFILE_INTERN, "", "", - G_TYPE_KEY_FILE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_CONNECTIVITY_URI, + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_KEYFILE_USER] = + g_param_spec_boxed (NM_CONFIG_DATA_KEYFILE_USER, "", "", + G_TYPE_KEY_FILE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_KEYFILE_INTERN] = + g_param_spec_boxed (NM_CONFIG_DATA_KEYFILE_INTERN, "", "", + G_TYPE_KEY_FILE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_CONNECTIVITY_URI] = g_param_spec_string (NM_CONFIG_DATA_CONNECTIVITY_URI, "", "", NULL, G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_CONNECTIVITY_INTERVAL, + obj_properties[PROP_CONNECTIVITY_INTERVAL] = g_param_spec_uint (NM_CONFIG_DATA_CONNECTIVITY_INTERVAL, "", "", 0, G_MAXUINT, 0, G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_CONNECTIVITY_RESPONSE, + obj_properties[PROP_CONNECTIVITY_RESPONSE] = g_param_spec_string (NM_CONFIG_DATA_CONNECTIVITY_RESPONSE, "", "", NULL, G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_NO_AUTO_DEFAULT, + obj_properties[PROP_NO_AUTO_DEFAULT] = g_param_spec_boxed (NM_CONFIG_DATA_NO_AUTO_DEFAULT, "", "", G_TYPE_STRV, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } - diff --git a/src/nm-config-data.h b/src/nm-config-data.h index e63b4590..b5e3c674 100644 --- a/src/nm-config-data.h +++ b/src/nm-config-data.h @@ -28,7 +28,6 @@ #define NM_IS_CONFIG_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CONFIG_DATA)) #define NM_CONFIG_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONFIG_DATA, NMConfigDataClass)) - #define NM_CONFIG_DATA_CONFIG_MAIN_FILE "config-main-file" #define NM_CONFIG_DATA_CONFIG_DESCRIPTION "config-description" #define NM_CONFIG_DATA_KEYFILE_USER "keyfile-user" @@ -128,13 +127,7 @@ typedef enum { /*< flags >*/ } NMConfigChangeFlags; -struct _NMConfigData { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMConfigDataClass; +typedef struct _NMConfigDataClass NMConfigDataClass; typedef struct _NMGlobalDnsConfig NMGlobalDnsConfig; typedef struct _NMGlobalDnsDomain NMGlobalDnsDomain; @@ -165,6 +158,7 @@ char *nm_config_data_get_value (const NMConfigData *config_data, const char *gro const char *nm_config_data_get_value_cached (const NMConfigData *config_data, const char *group, const char *key, NMConfigGetValueFlags flags); gint nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, const char *key, gint default_value); +char **nm_config_data_get_plugins (const NMConfigData *config_data, gboolean allow_default); const char *nm_config_data_get_connectivity_uri (const NMConfigData *config_data); const guint nm_config_data_get_connectivity_interval (const NMConfigData *config_data); const char *nm_config_data_get_connectivity_response (const NMConfigData *config_data); diff --git a/src/nm-config.c b/src/nm-config.c index f0f0c528..87d0c8a7 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -27,9 +27,8 @@ #include #include "nm-utils.h" -#include "nm-device.h" +#include "devices/nm-device.h" #include "NetworkManagerUtils.h" -#include "nm-enum-types.h" #include "nm-core-internal.h" #include "nm-keyfile-internal.h" @@ -37,23 +36,13 @@ #define DEFAULT_CONFIG_DIR NMCONFDIR "/conf.d" #define DEFAULT_CONFIG_MAIN_FILE_OLD NMCONFDIR "/nm-system-settings.conf" #define DEFAULT_SYSTEM_CONFIG_DIR NMLIBDIR "/conf.d" +#define RUN_CONFIG_DIR NMRUNDIR "/conf.d" #define DEFAULT_NO_AUTO_DEFAULT_FILE NMSTATEDIR "/no-auto-default.state" #define DEFAULT_INTERN_CONFIG_FILE NMSTATEDIR "/NetworkManager-intern.conf" #define DEFAULT_STATE_FILE NMSTATEDIR "/NetworkManager.state" /*****************************************************************************/ -#define _NMLOG_PREFIX_NAME "config" -#define _NMLOG_DOMAIN LOGD_CORE - -#define _NMLOG(level, ...) \ - nm_log (level, _NMLOG_DOMAIN, \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)) - -/*****************************************************************************/ - struct NMConfigCmdLineOptions { char *config_main_file; char *intern_config_file; @@ -77,6 +66,20 @@ typedef struct { NMConfigState p; } State; +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_CMD_LINE_OPTIONS, + PROP_ATOMIC_SECTION_PREFIXES, +); + +enum { + SIGNAL_CONFIG_CHANGED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + typedef struct { NMConfigCmdLineOptions cli; @@ -88,16 +91,11 @@ typedef struct { char *no_auto_default_file; char *intern_config_file; - char **plugins; gboolean monitor_connection_files; - gboolean auth_polkit; - char *dhcp_client; char *log_level; char *log_domains; - char *debug; - gboolean configure_and_quit; char **atomic_section_prefixes; @@ -116,35 +114,33 @@ typedef struct { State *state; } NMConfigPrivate; -enum { - PROP_0, - PROP_CMD_LINE_OPTIONS, - PROP_ATOMIC_SECTION_PREFIXES, - LAST_PROP, +struct _NMConfig { + GObject parent; + NMConfigPrivate _priv; }; -enum { - SIGNAL_CONFIG_CHANGED, - - LAST_SIGNAL +struct _NMConfigClass { + GObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; - static void nm_config_initable_iface_init (GInitableIface *iface); G_DEFINE_TYPE_WITH_CODE (NMConfig, nm_config, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_config_initable_iface_init); ) +#define NM_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMConfig, NM_IS_CONFIG) -#define NM_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONFIG, NMConfigPrivate)) +/*****************************************************************************/ -/************************************************************************/ +#define _NMLOG_DOMAIN LOGD_CORE +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "config", __VA_ARGS__) + +/*****************************************************************************/ static void _set_config_data (NMConfig *self, NMConfigData *new_data, NMConfigChangeFlags reload_flags); -/************************************************************************/ +/*****************************************************************************/ #define _HAS_PREFIX(str, prefix) \ ({ \ @@ -152,7 +148,7 @@ static void _set_config_data (NMConfig *self, NMConfigData *new_data, NMConfigCh g_str_has_prefix ( _str, ""prefix"") && _str[NM_STRLEN(prefix)] != '\0'; \ }) -/************************************************************************/ +/*****************************************************************************/ gint nm_config_parse_boolean (const char *str, @@ -162,7 +158,7 @@ nm_config_parse_boolean (const char *str, } gint -nm_config_keyfile_get_boolean (GKeyFile *keyfile, +nm_config_keyfile_get_boolean (const GKeyFile *keyfile, const char *section, const char *key, gint default_value) @@ -173,12 +169,12 @@ nm_config_keyfile_get_boolean (GKeyFile *keyfile, g_return_val_if_fail (section != NULL, default_value); g_return_val_if_fail (key != NULL, default_value); - str = g_key_file_get_value (keyfile, section, key, NULL); + str = g_key_file_get_value ((GKeyFile *) keyfile, section, key, NULL); return nm_config_parse_boolean (str, default_value); } char * -nm_config_keyfile_get_value (GKeyFile *keyfile, +nm_config_keyfile_get_value (const GKeyFile *keyfile, const char *section, const char *key, NMConfigGetValueFlags flags) @@ -186,9 +182,9 @@ nm_config_keyfile_get_value (GKeyFile *keyfile, char *value; if (NM_FLAGS_HAS (flags, NM_CONFIG_GET_VALUE_RAW)) - value = g_key_file_get_value (keyfile, section, key, NULL); + value = g_key_file_get_value ((GKeyFile *) keyfile, section, key, NULL); else - value = g_key_file_get_string (keyfile, section, key, NULL); + value = g_key_file_get_string ((GKeyFile *) keyfile, section, key, NULL); if (!value) return NULL; @@ -238,7 +234,7 @@ nm_config_keyfile_set_string_list (GKeyFile *keyfile, g_free (new_value); } -/************************************************************************/ +/*****************************************************************************/ NMConfigData * nm_config_get_data (NMConfig *config) @@ -259,14 +255,6 @@ nm_config_get_data_orig (NMConfig *config) return NM_CONFIG_GET_PRIVATE (config)->config_data_orig; } -const char ** -nm_config_get_plugins (NMConfig *config) -{ - g_return_val_if_fail (config != NULL, NULL); - - return (const char **) NM_CONFIG_GET_PRIVATE (config)->plugins; -} - gboolean nm_config_get_monitor_connection_files (NMConfig *config) { @@ -275,22 +263,6 @@ nm_config_get_monitor_connection_files (NMConfig *config) return NM_CONFIG_GET_PRIVATE (config)->monitor_connection_files; } -gboolean -nm_config_get_auth_polkit (NMConfig *config) -{ - g_return_val_if_fail (NM_IS_CONFIG (config), NM_CONFIG_DEFAULT_AUTH_POLKIT); - - return NM_CONFIG_GET_PRIVATE (config)->auth_polkit; -} - -const char * -nm_config_get_dhcp_client (NMConfig *config) -{ - g_return_val_if_fail (config != NULL, NULL); - - return NM_CONFIG_GET_PRIVATE (config)->dhcp_client; -} - const char * nm_config_get_log_level (NMConfig *config) { @@ -307,14 +279,6 @@ nm_config_get_log_domains (NMConfig *config) return NM_CONFIG_GET_PRIVATE (config)->log_domains; } -const char * -nm_config_get_debug (NMConfig *config) -{ - g_return_val_if_fail (config != NULL, NULL); - - return NM_CONFIG_GET_PRIVATE (config)->debug; -} - gboolean nm_config_get_configure_and_quit (NMConfig *config) { @@ -327,7 +291,7 @@ nm_config_get_is_debug (NMConfig *config) return NM_CONFIG_GET_PRIVATE (config)->cli.is_debug; } -/************************************************************************/ +/*****************************************************************************/ static char ** no_auto_default_from_file (const char *no_auto_default_file) @@ -418,8 +382,8 @@ nm_config_set_no_auto_default_for_device (NMConfig *self, NMDevice *device) g_ptr_array_add (no_auto_default_new, NULL); if (!no_auto_default_to_file (priv->no_auto_default_file, (const char *const*) no_auto_default_new->pdata, &error)) { - nm_log_warn (LOGD_SETTINGS, "Could not update no-auto-default.state file: %s", - error->message); + _LOGW ("Could not update no-auto-default.state file: %s", + error->message); g_error_free (error); } @@ -431,7 +395,7 @@ nm_config_set_no_auto_default_for_device (NMConfig *self, NMDevice *device) _set_config_data (self, new_data, NM_CONFIG_CHANGE_CAUSE_NO_AUTO_DEFAULT); } -/************************************************************************/ +/*****************************************************************************/ static void _nm_config_cmd_line_options_clear (NMConfigCmdLineOptions *cli) @@ -505,7 +469,7 @@ nm_config_cmd_line_options_add_to_entries (NMConfigCmdLineOptions *cli, { "intern-config", 0, 0, G_OPTION_ARG_FILENAME, &cli->intern_config_file, N_("Internal config file location"), N_(DEFAULT_INTERN_CONFIG_FILE) }, { "state-file", 0, 0, G_OPTION_ARG_FILENAME, &cli->state_file, N_("State file location"), N_(DEFAULT_STATE_FILE) }, { "no-auto-default", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &cli->no_auto_default_file, N_("State file for no-auto-default devices"), N_(DEFAULT_NO_AUTO_DEFAULT_FILE) }, - { "plugins", 0, 0, G_OPTION_ARG_STRING, &cli->plugins, N_("List of plugins separated by ','"), N_(CONFIG_PLUGINS_DEFAULT) }, + { "plugins", 0, 0, G_OPTION_ARG_STRING, &cli->plugins, N_("List of plugins separated by ','"), N_(NM_CONFIG_DEFAULT_MAIN_PLUGINS) }, { "configure-and-quit", 0, 0, G_OPTION_ARG_NONE, &cli->configure_and_quit, N_("Quit after initial configuration"), NULL }, { "debug", 'd', 0, G_OPTION_ARG_NONE, &cli->is_debug, N_("Don't become a daemon, and log to stderr"), NULL }, @@ -520,7 +484,7 @@ nm_config_cmd_line_options_add_to_entries (NMConfigCmdLineOptions *cli, } } -/************************************************************************/ +/*****************************************************************************/ GKeyFile * nm_config_create_keyfile () @@ -651,7 +615,7 @@ static gboolean _setting_is_string_list (const char *group, const char *key) { return _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins") - || _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, "debug") + || _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG) || _IS (NM_CONFIG_KEYFILE_GROUP_LOGGING, "domains") || g_str_has_prefix (group, NM_CONFIG_KEYFILE_GROUPPREFIX_TEST_APPEND_STRINGLIST); #undef _IS @@ -680,7 +644,7 @@ read_config (GKeyFile *keyfile, gboolean is_base_config, const char *dirname, co return FALSE; } - nm_log_dbg (LOGD_SETTINGS, "Reading config file '%s'", path); + _LOGD ("Reading config file '%s'", path); kf = nm_config_create_keyfile (); if (!g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, error)) { @@ -763,6 +727,13 @@ read_config (GKeyFile *keyfile, gboolean is_base_config, const char *dirname, co if (is_string_list) { old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, NULL); new_val = g_key_file_get_string_list (kf, group, key, NULL, NULL); + if (!old_val && !g_key_file_has_key (keyfile, group, base_key, NULL)) { + /* we must fill the unspecified value with the compile-time default. */ + if (nm_streq (group, NM_CONFIG_KEYFILE_GROUP_MAIN) && nm_streq (base_key, "plugins")) { + g_key_file_set_value (keyfile, group, base_key, NM_CONFIG_DEFAULT_MAIN_PLUGINS); + old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, NULL); + } + } } else { gs_free char *old_sval = nm_config_keyfile_get_value (keyfile, group, base_key, NM_CONFIG_GET_VALUE_TYPE_SPEC); gs_free char *new_sval = nm_config_keyfile_get_value (kf, group, key, NM_CONFIG_GET_VALUE_TYPE_SPEC); @@ -866,8 +837,8 @@ read_base_config (GKeyFile *keyfile, } if (!g_error_matches (my_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) { - nm_log_warn (LOGD_CORE, "Old default config file invalid: %s\n", - my_error->message); + _LOGW ("Old default config file invalid: %s\n", + my_error->message); } g_clear_error (&my_error); @@ -878,8 +849,8 @@ read_base_config (GKeyFile *keyfile, } if (!g_error_matches (my_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) { - nm_log_warn (LOGD_CORE, "Default config file invalid: %s\n", - my_error->message); + _LOGW ("Default config file invalid: %s\n", + my_error->message); g_propagate_error (error, my_error); return FALSE; } @@ -889,8 +860,8 @@ read_base_config (GKeyFile *keyfile, * config file path. */ *out_config_main_file = g_strdup (DEFAULT_CONFIG_MAIN_FILE); - nm_log_info (LOGD_CORE, "No config file found or given; using %s\n", - DEFAULT_CONFIG_MAIN_FILE); + _LOGI ("No config file found or given; using %s\n", + DEFAULT_CONFIG_MAIN_FILE); return TRUE; } @@ -926,6 +897,24 @@ _get_config_dir_files (const char *config_dir) return confs; } +static void +_confs_to_description (GString *str, const GPtrArray *confs, const char *name) +{ + guint i; + + if (!confs->len) + return; + + for (i = 0; i < confs->len; i++) { + if (i == 0) + g_string_append_printf (str, " (%s: ", name); + else + g_string_append (str, ", "); + g_string_append (str, confs->pdata[i]); + } + g_string_append (str, ")"); +} + static GKeyFile * read_entire_config (const NMConfigCmdLineOptions *cli, const char *config_dir, @@ -934,13 +923,13 @@ read_entire_config (const NMConfigCmdLineOptions *cli, char **out_config_description, GError **error) { - GKeyFile *keyfile; + gs_unref_keyfile GKeyFile *keyfile = NULL; gs_unref_ptrarray GPtrArray *system_confs = NULL; gs_unref_ptrarray GPtrArray *confs = NULL; + gs_unref_ptrarray GPtrArray *run_confs = NULL; guint i; gs_free char *o_config_main_file = NULL; - GString *str; - char **plugins_default; + const char *run_config_dir = ""; g_return_val_if_fail (config_dir, NULL); g_return_val_if_fail (system_config_dir, NULL); @@ -948,46 +937,56 @@ read_entire_config (const NMConfigCmdLineOptions *cli, g_return_val_if_fail (!out_config_description || !*out_config_description, NULL); g_return_val_if_fail (!error || !*error, FALSE); + if ( (""RUN_CONFIG_DIR)[0] == '/' + && !nm_streq (RUN_CONFIG_DIR, system_config_dir) + && !nm_streq (RUN_CONFIG_DIR, config_dir)) + run_config_dir = RUN_CONFIG_DIR; + /* create a default configuration file. */ keyfile = nm_config_create_keyfile (); - plugins_default = g_strsplit (CONFIG_PLUGINS_DEFAULT, ",", -1); - if (plugins_default && plugins_default[0]) - nm_config_keyfile_set_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", (const char *const*) plugins_default, -1); - g_strfreev (plugins_default); - system_confs = _get_config_dir_files (system_config_dir); confs = _get_config_dir_files (config_dir); + run_confs = _get_config_dir_files (run_config_dir); for (i = 0; i < system_confs->len; ) { const char *filename = system_confs->pdata[i]; - /* if a same named file exists in config_dir, skip it. */ - if (_nm_utils_strv_find_first ((char **) confs->pdata, confs->len, filename) >= 0) { + /* if a same named file exists in config_dir or run_config_dir, skip it. */ + if (_nm_utils_strv_find_first ((char **) confs->pdata, confs->len, filename) >= 0 || + _nm_utils_strv_find_first ((char **) run_confs->pdata, run_confs->len, filename) >= 0) { g_ptr_array_remove_index (system_confs, i); continue; } - if (!read_config (keyfile, FALSE, system_config_dir, filename, error)) { - g_key_file_free (keyfile); + if (!read_config (keyfile, FALSE, system_config_dir, filename, error)) return NULL; + i++; + } + + for (i = 0; i < run_confs->len; ) { + const char *filename = run_confs->pdata[i]; + + /* if a same named file exists in config_dir, skip it. */ + if (_nm_utils_strv_find_first ((char **) confs->pdata, confs->len, filename) >= 0) { + g_ptr_array_remove_index (run_confs, i); + continue; } + + if (!read_config (keyfile, FALSE, run_config_dir, filename, error)) + return NULL; i++; } /* First read the base config file */ - if (!read_base_config (keyfile, cli ? cli->config_main_file : NULL, &o_config_main_file, error)) { - g_key_file_free (keyfile); + if (!read_base_config (keyfile, cli ? cli->config_main_file : NULL, &o_config_main_file, error)) return NULL; - } g_assert (o_config_main_file); for (i = 0; i < confs->len; i++) { - if (!read_config (keyfile, FALSE, config_dir, confs->pdata[i], error)) { - g_key_file_free (keyfile); + if (!read_config (keyfile, FALSE, config_dir, confs->pdata[i], error)) return NULL; - } } /* Merge settings from command line. They overwrite everything read from @@ -1006,39 +1005,17 @@ read_entire_config (const NMConfigCmdLineOptions *cli, if (cli && cli->connectivity_response && cli->connectivity_response[0]) g_key_file_set_string (keyfile, NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, "response", cli->connectivity_response); - str = g_string_new (o_config_main_file); - if (system_confs->len > 0) { - for (i = 0; i < system_confs->len; i++) { - if (i == 0) - g_string_append (str, " (lib: "); - else - g_string_append (str, ", "); - g_string_append (str, system_confs->pdata[i]); - } - g_string_append (str, ")"); - } - if (confs->len > 0) { - for (i = 0; i < confs->len; i++) { - if (i == 0) - g_string_append (str, " (etc: "); - else - g_string_append (str, ", "); - g_string_append (str, confs->pdata[i]); - } - g_string_append (str, ")"); - } + if (out_config_description) { + GString *str; - if (out_config_main_file) - *out_config_main_file = o_config_main_file; - else - g_free (o_config_main_file); - if (out_config_description) + str = g_string_new (o_config_main_file); + _confs_to_description (str, system_confs, "lib"); + _confs_to_description (str, run_confs, "run"); + _confs_to_description (str, confs, "etc"); *out_config_description = g_string_free (str, FALSE); - else - g_string_free (str, TRUE); - - o_config_main_file = NULL; - return keyfile; + } + NM_SET_OUT (out_config_main_file, g_steal_pointer (&o_config_main_file)); + return g_steal_pointer (&keyfile); } static gboolean @@ -1303,7 +1280,7 @@ out: if (out_needs_rewrite) *out_needs_rewrite = needs_rewrite; - nm_log_dbg (LOGD_CORE, "intern config file \"%s\"", filename); + _LOGD ("intern config file \"%s\"", filename); if (!has_intern) { g_key_file_unref (keyfile_intern); @@ -1502,14 +1479,14 @@ intern_config_write (const char *filename, success = g_key_file_save_to_file (keyfile, filename, &local); - nm_log_dbg (LOGD_CORE, "write intern config file \"%s\"%s%s", filename, success ? "" : ": ", success ? "" : local->message); + _LOGD ("write intern config file \"%s\"%s%s", filename, success ? "" : ": ", success ? "" : local->message); g_key_file_unref (keyfile); if (!success) g_propagate_error (error, local); return success; } -/************************************************************************/ +/*****************************************************************************/ GSList * nm_config_get_match_spec (const GKeyFile *keyfile, const char *group, const char *key, gboolean *out_has_key) @@ -1525,7 +1502,7 @@ nm_config_get_match_spec (const GKeyFile *keyfile, const char *group, const char return nm_match_spec_split (value); } -/************************************************************************/ +/*****************************************************************************/ gboolean nm_config_set_global_dns (NMConfig *self, NMGlobalDnsConfig *global_dns, GError **error) @@ -1658,7 +1635,7 @@ nm_config_set_values (NMConfig *self, if (!_nm_keyfile_equals (keyfile_intern_current, keyfile_new, TRUE)) new_data = nm_config_data_new_update_keyfile_intern (priv->config_data, keyfile_new); - nm_log_dbg (LOGD_CORE, "set values(): %s", new_data ? "has changes" : "no changes"); + _LOGD ("set values(): %s", new_data ? "has changes" : "no changes"); if (allow_write && (new_data || force_rewrite)) { @@ -1673,11 +1650,11 @@ nm_config_set_values (NMConfig *self, keyfile_user = _nm_config_data_get_keyfile_user (priv->config_data); if (!intern_config_write (priv->intern_config_file, keyfile_new, keyfile_user, (const char *const*) priv->atomic_section_prefixes, &local)) { - nm_log_warn (LOGD_CORE, "error saving internal configuration \"%s\": %s", priv->intern_config_file, local->message); + _LOGW ("error saving internal configuration \"%s\": %s", priv->intern_config_file, local->message); g_clear_error (&local); } } else - nm_log_dbg (LOGD_CORE, "don't persistate internal configuration (no file set, use --intern-config?)"); + _LOGD ("don't persist internal configuration (no file set, use --intern-config?)"); } if (new_data) _set_config_data (self, new_data, NM_CONFIG_CHANGE_CAUSE_SET_VALUES); @@ -1870,6 +1847,219 @@ _nm_config_state_set (NMConfig *self, /*****************************************************************************/ +#define DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE "device" +#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED "managed" +#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_PERM_HW_ADDR_FAKE "perm-hw-addr-fake" +#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID "connection-uuid" + +static NMConfigDeviceStateData * +_config_device_state_data_new (int ifindex, GKeyFile *kf) +{ + NMConfigDeviceStateData *device_state; + NMConfigDeviceStateManagedType managed_type = NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN; + gs_free char *connection_uuid = NULL; + gs_free char *perm_hw_addr_fake = NULL; + gsize connection_uuid_len; + gsize perm_hw_addr_fake_len; + char *p; + + nm_assert (ifindex > 0); + + if (kf) { + gboolean managed; + + managed = nm_config_keyfile_get_boolean (kf, + DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE, + DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED, + FALSE); + managed_type = managed + ? NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED + : NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED; + + if (managed) { + connection_uuid = nm_config_keyfile_get_value (kf, + DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE, + DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID, + NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); + } + + perm_hw_addr_fake = nm_config_keyfile_get_value (kf, + DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE, + DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_PERM_HW_ADDR_FAKE, + NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); + if (perm_hw_addr_fake) { + char *normalized; + + normalized = nm_utils_hwaddr_canonical (perm_hw_addr_fake, -1); + g_free (perm_hw_addr_fake); + perm_hw_addr_fake = normalized; + } + } + + connection_uuid_len = connection_uuid ? strlen (connection_uuid) + 1 : 0; + perm_hw_addr_fake_len = perm_hw_addr_fake ? strlen (perm_hw_addr_fake) + 1 : 0; + + device_state = g_malloc (sizeof (NMConfigDeviceStateData) + + connection_uuid_len + + perm_hw_addr_fake_len); + + device_state->ifindex = ifindex; + device_state->managed = managed_type; + device_state->connection_uuid = NULL; + device_state->perm_hw_addr_fake = NULL; + + p = (char *) (&device_state[1]); + if (connection_uuid) { + memcpy (p, connection_uuid, connection_uuid_len); + device_state->connection_uuid = p; + p += connection_uuid_len; + } + if (perm_hw_addr_fake) { + memcpy (p, perm_hw_addr_fake, perm_hw_addr_fake_len); + device_state->perm_hw_addr_fake = p; + p += perm_hw_addr_fake_len; + } + + return device_state; +} + +/** + * nm_config_device_state_load: + * @self: the NMConfig instance + * @ifindex: the ifindex for which the state is to load + * + * Returns: (transfer full): a run state object. + * Must be freed with g_free(). + */ +NMConfigDeviceStateData * +nm_config_device_state_load (NMConfig *self, + int ifindex) +{ + NMConfigDeviceStateData *device_state; + char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60]; + gs_unref_keyfile GKeyFile *kf = NULL; + + g_return_val_if_fail (ifindex > 0, NULL); + + nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex); + + kf = nm_config_create_keyfile (); + if (!g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, NULL)) + g_clear_pointer (&kf, g_key_file_unref); + + device_state = _config_device_state_data_new (ifindex, kf); + + if (kf) { + _LOGT ("device-state: read #%d (%s); managed=%d%s%s%s%s%s%s", + ifindex, path, + device_state->managed, + NM_PRINT_FMT_QUOTED (device_state->connection_uuid, ", connection-uuid=", device_state->connection_uuid, "", ""), + NM_PRINT_FMT_QUOTED (device_state->perm_hw_addr_fake, ", perm-hw-addr-fake=", device_state->perm_hw_addr_fake, "", "")); + } else { + _LOGT ("device-state: read #%d (%s); no persistent state", + ifindex, path); + } + + return device_state; +} + +gboolean +nm_config_device_state_write (NMConfig *self, + int ifindex, + gboolean managed, + const char *perm_hw_addr_fake, + const char *connection_uuid) +{ + char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60]; + GError *local = NULL; + gs_unref_keyfile GKeyFile *kf = NULL; + + g_return_val_if_fail (NM_IS_CONFIG (self), FALSE); + g_return_val_if_fail (ifindex > 0, FALSE); + g_return_val_if_fail (!connection_uuid || *connection_uuid, FALSE); + g_return_val_if_fail (managed || !connection_uuid, FALSE); + + nm_assert (!perm_hw_addr_fake || nm_utils_hwaddr_valid (perm_hw_addr_fake, -1)); + + nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex); + + kf = nm_config_create_keyfile (); + g_key_file_set_boolean (kf, + DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE, + DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED, + !!managed); + if (perm_hw_addr_fake) { + g_key_file_set_string (kf, + DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE, + DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_PERM_HW_ADDR_FAKE, + perm_hw_addr_fake); + } + if (connection_uuid) { + g_key_file_set_string (kf, + DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE, + DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID, + connection_uuid); + } + + if (!g_key_file_save_to_file (kf, path, &local)) { + _LOGW ("device-state: write #%d (%s) failed: %s", ifindex, path, local->message); + g_error_free (local); + return FALSE; + } + _LOGT ("device-state: write #%d (%s); managed=%d%s%s%s%s%s%s", + ifindex, path, + (bool) managed, + NM_PRINT_FMT_QUOTED (connection_uuid, ", connection-uuid=", connection_uuid, "", ""), + NM_PRINT_FMT_QUOTED (perm_hw_addr_fake, ", perm-hw-addr-fake=", perm_hw_addr_fake, "", "")); + return TRUE; +} + +void +nm_config_device_state_prune_unseen (NMConfig *self, + GHashTable *seen_ifindexes) +{ + GDir *dir; + const char *fn; + int ifindex; + gsize fn_len; + gsize i; + char buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/") + 30 + 3] = NM_CONFIG_DEVICE_STATE_DIR"/"; + char *buf_p = &buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/")]; + + g_return_if_fail (seen_ifindexes); + + dir = g_dir_open (NM_CONFIG_DEVICE_STATE_DIR, 0, NULL); + if (!dir) + return; + + while ((fn = g_dir_read_name (dir))) { + fn_len = strlen (fn); + + /* skip over file names that are not plain integers. */ + for (i = 0; i < fn_len; i++) { + if (!g_ascii_isdigit (fn[i])) + break; + } + if (fn_len == 0 || i != fn_len) + continue; + + ifindex = _nm_utils_ascii_str_to_int64 (fn, 10, 1, G_MAXINT, 0); + if (!ifindex) + continue; + + if (g_hash_table_contains (seen_ifindexes, GINT_TO_POINTER (ifindex))) + continue; + + memcpy (buf_p, fn, fn_len + 1); + _LOGT ("device-state: prune #%d (%s)", ifindex, buf); + (void) unlink (buf); + } + + g_dir_close (dir); +} + +/*****************************************************************************/ + void nm_config_reload (NMConfig *self, NMConfigChangeFlags reload_flags) { @@ -1907,7 +2097,7 @@ nm_config_reload (NMConfig *self, NMConfigChangeFlags reload_flags) &config_description, &error); if (!keyfile) { - nm_log_err (LOGD_CORE, "Failed to reload the configuration: %s", error->message); + _LOGE ("Failed to reload the configuration: %s", error->message); g_clear_error (&error); _set_config_data (self, NULL, reload_flags); return; @@ -1989,15 +2179,15 @@ _set_config_data (NMConfig *self, NMConfigData *new_data, NMConfigChangeFlags re } if (new_data) { - nm_log_info (LOGD_CORE, "config: signal %s (%s)", - nm_config_change_flags_to_string (changes, NULL, 0), - nm_config_data_get_config_description (new_data)); + _LOGI ("config: signal %s (%s)", + nm_config_change_flags_to_string (changes, NULL, 0), + nm_config_data_get_config_description (new_data)); nm_config_data_log (new_data, "CONFIG: ", " ", NULL); priv->config_data = new_data; } else if (had_new_data) - nm_log_info (LOGD_CORE, "config: signal %s (no changes from disk)", nm_config_change_flags_to_string (changes, NULL, 0)); + _LOGI ("config: signal %s (no changes from disk)", nm_config_change_flags_to_string (changes, NULL, 0)); else - nm_log_info (LOGD_CORE, "config: signal %s", nm_config_change_flags_to_string (changes, NULL, 0)); + _LOGI ("config: signal %s", nm_config_change_flags_to_string (changes, NULL, 0)); g_signal_emit (self, signals[SIGNAL_CONFIG_CHANGED], 0, new_data ? new_data : old_data, changes, old_data); @@ -2030,6 +2220,37 @@ nm_config_setup (const NMConfigCmdLineOptions *cli, char **atomic_section_prefix return singleton_instance; } +/*****************************************************************************/ + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMConfig *self = NM_CONFIG (object); + NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (self); + NMConfigCmdLineOptions *cli; + + switch (prop_id) { + case PROP_CMD_LINE_OPTIONS: + /* construct-only */ + cli = g_value_get_pointer (value); + if (!cli) + _nm_config_cmd_line_options_clear (&priv->cli); + else + _nm_config_cmd_line_options_copy (cli, &priv->cli); + break; + case PROP_ATOMIC_SECTION_PREFIXES: + /* construct-only */ + priv->atomic_section_prefixes = g_strdupv (g_value_get_boxed (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + static gboolean init_sync (GInitable *initable, GCancellable *cancellable, GError **error) { @@ -2040,31 +2261,24 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) char *config_description = NULL; gs_strfreev char **no_auto_default = NULL; gboolean intern_config_needs_rewrite; + const char *s; if (priv->config_dir) { /* Object is already initialized. */ if (priv->config_data) return TRUE; g_set_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND, "unspecified error"); - return FALSE; + g_return_val_if_reached (FALSE); } - if (priv->cli.config_dir) - priv->config_dir = g_strdup (priv->cli.config_dir); - else - priv->config_dir = g_strdup (DEFAULT_CONFIG_DIR); - - if (priv->cli.system_config_dir) - priv->system_config_dir = g_strdup (priv->cli.system_config_dir); - else - priv->system_config_dir = g_strdup (DEFAULT_SYSTEM_CONFIG_DIR); + s = priv->cli.config_dir ?: ""DEFAULT_CONFIG_DIR; + priv->config_dir = g_strdup (s[0] == '/' ? s : ""); - if (strcmp (priv->config_dir, priv->system_config_dir) == 0) { - /* having the same directory twice makes no sense. In that case, clear - * @system_config_dir. */ - g_free (priv->system_config_dir); - priv->system_config_dir = g_strdup (""); - } + s = priv->cli.system_config_dir ?: ""DEFAULT_SYSTEM_CONFIG_DIR; + if ( s[0] != '/' + || nm_streq (s, priv->config_dir)) + s = ""; + priv->system_config_dir = g_strdup (s); if (priv->cli.intern_config_file) priv->intern_config_file = g_strdup (priv->cli.intern_config_file); @@ -2087,22 +2301,11 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) else priv->no_auto_default_file = g_strdup (DEFAULT_NO_AUTO_DEFAULT_FILE); - priv->plugins = _nm_utils_strv_cleanup (g_key_file_get_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL), - TRUE, TRUE, TRUE); - if (!priv->plugins) - priv->plugins = g_new0 (char *, 1); - priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE); - priv->auth_polkit = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT); - - priv->dhcp_client = nm_strstrip (g_key_file_get_string (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "dhcp", NULL)); - priv->log_level = nm_strstrip (g_key_file_get_string (keyfile, NM_CONFIG_KEYFILE_GROUP_LOGGING, "level", NULL)); priv->log_domains = nm_strstrip (g_key_file_get_string (keyfile, NM_CONFIG_KEYFILE_GROUP_LOGGING, "domains", NULL)); - priv->debug = g_key_file_get_string (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "debug", NULL); - priv->configure_and_quit = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "configure-and-quit", FALSE); no_auto_default = no_auto_default_from_file (priv->no_auto_default_file); @@ -2128,6 +2331,13 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) return TRUE; } +/*****************************************************************************/ + +static void +nm_config_init (NMConfig *config) +{ +} + NMConfig * nm_config_new (const NMConfigCmdLineOptions *cli, char **atomic_section_prefixes, GError **error) { @@ -2139,18 +2349,10 @@ nm_config_new (const NMConfigCmdLineOptions *cli, char **atomic_section_prefixes NULL)); } -static void -nm_config_init (NMConfig *config) -{ - NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (config); - - priv->auth_polkit = NM_CONFIG_DEFAULT_AUTH_POLKIT; -} - static void finalize (GObject *gobject) { - NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (gobject); + NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE ((NMConfig *) gobject); state_free (priv->state); @@ -2158,11 +2360,8 @@ finalize (GObject *gobject) g_free (priv->system_config_dir); g_free (priv->no_auto_default_file); g_free (priv->intern_config_file); - g_strfreev (priv->plugins); - g_free (priv->dhcp_client); g_free (priv->log_level); g_free (priv->log_domains); - g_free (priv->debug); g_strfreev (priv->atomic_section_prefixes); _nm_config_cmd_line_options_clear (&priv->cli); @@ -2173,56 +2372,28 @@ finalize (GObject *gobject) G_OBJECT_CLASS (nm_config_parent_class)->finalize (gobject); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMConfig *self = NM_CONFIG (object); - NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (self); - NMConfigCmdLineOptions *cli; - - switch (prop_id) { - case PROP_CMD_LINE_OPTIONS: - /* construct only */ - cli = g_value_get_pointer (value); - if (!cli) - _nm_config_cmd_line_options_clear (&priv->cli); - else - _nm_config_cmd_line_options_copy (cli, &priv->cli); - break; - case PROP_ATOMIC_SECTION_PREFIXES: - /* construct only */ - priv->atomic_section_prefixes = g_strdupv (g_value_get_boxed (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void nm_config_class_init (NMConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); - g_type_class_add_private (config_class, sizeof (NMConfigPrivate)); object_class->finalize = finalize; object_class->set_property = set_property; - g_object_class_install_property - (object_class, PROP_CMD_LINE_OPTIONS, + obj_properties[PROP_CMD_LINE_OPTIONS] = g_param_spec_pointer (NM_CONFIG_CMD_LINE_OPTIONS, "", "", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_ATOMIC_SECTION_PREFIXES, + obj_properties[PROP_ATOMIC_SECTION_PREFIXES] = g_param_spec_boxed (NM_CONFIG_ATOMIC_SECTION_PREFIXES, "", "", G_TYPE_STRV, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[SIGNAL_CONFIG_CHANGED] = g_signal_new (NM_CONFIG_SIGNAL_CONFIG_CHANGED, @@ -2248,4 +2419,3 @@ nm_config_initable_iface_init (GInitableIface *iface) { iface->init = init_sync; } - diff --git a/src/nm-config.h b/src/nm-config.h index a75e3935..9930df33 100644 --- a/src/nm-config.h +++ b/src/nm-config.h @@ -59,6 +59,9 @@ #define NM_CONFIG_KEYFILE_GROUP_IFUPDOWN "ifupdown" #define NM_CONFIG_KEYFILE_GROUP_IFNET "ifnet" +#define NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT "auth-polkit" +#define NM_CONFIG_KEYFILE_KEY_MAIN_DHCP "dhcp" +#define NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG "debug" #define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND "backend" #define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable" #define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was" @@ -100,13 +103,7 @@ typedef struct { bool dirty; } NMConfigState; -struct _NMConfig { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMConfigClass; +typedef struct _NMConfigClass NMConfigClass; GType nm_config_get_type (void); @@ -120,13 +117,9 @@ NMConfigData *nm_config_get_data_orig (NMConfig *config); #define NM_CONFIG_GET_DATA (nm_config_get_data (nm_config_get ())) #define NM_CONFIG_GET_DATA_ORIG (nm_config_get_data_orig (nm_config_get ())) -const char **nm_config_get_plugins (NMConfig *config); gboolean nm_config_get_monitor_connection_files (NMConfig *config); -gboolean nm_config_get_auth_polkit (NMConfig *config); -const char *nm_config_get_dhcp_client (NMConfig *config); const char *nm_config_get_log_level (NMConfig *config); const char *nm_config_get_log_domains (NMConfig *config); -const char *nm_config_get_debug (NMConfig *config); gboolean nm_config_get_configure_and_quit (NMConfig *config); gboolean nm_config_get_is_debug (NMConfig *config); @@ -160,11 +153,11 @@ void _nm_config_state_set (NMConfig *config, gint nm_config_parse_boolean (const char *str, gint default_value); GKeyFile *nm_config_create_keyfile (void); -gint nm_config_keyfile_get_boolean (GKeyFile *keyfile, +gint nm_config_keyfile_get_boolean (const GKeyFile *keyfile, const char *section, const char *key, gint default_value); -char *nm_config_keyfile_get_value (GKeyFile *keyfile, +char *nm_config_keyfile_get_value (const GKeyFile *keyfile, const char *section, const char *key, NMConfigGetValueFlags flags); @@ -185,5 +178,39 @@ gboolean nm_config_set_global_dns (NMConfig *self, NMGlobalDnsConfig *global_dns extern guint _nm_config_match_nm_version; extern char *_nm_config_match_env; -#endif /* __NETWORKMANAGER_CONFIG_H__ */ +/*****************************************************************************/ + +#define NM_CONFIG_DEVICE_STATE_DIR ""NMRUNDIR"/devices" + +#define NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL (nm_streq (""NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT, "true")) +#define NM_CONFIG_DEFAULT_LOGGING_AUDIT_BOOL (nm_streq (""NM_CONFIG_DEFAULT_LOGGING_AUDIT, "true")) + +typedef enum { + NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN = -1, + NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED = 0, + NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED = 1, +} NMConfigDeviceStateManagedType; +struct _NMConfigDeviceStateData { + int ifindex; + NMConfigDeviceStateManagedType managed; + + /* the UUID of the last settings-connection active + * on the device. */ + const char *connection_uuid; + + const char *perm_hw_addr_fake; +}; + +NMConfigDeviceStateData *nm_config_device_state_load (NMConfig *self, + int ifindex); +gboolean nm_config_device_state_write (NMConfig *self, + int ifindex, + gboolean managed, + const char *perm_hw_addr_fake, + const char *connection_uuid); +void nm_config_device_state_prune_unseen (NMConfig *self, GHashTable *seen_ifindexes); + +/*****************************************************************************/ + +#endif /* __NETWORKMANAGER_CONFIG_H__ */ diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index 7cf3e707..a33ec680 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -21,28 +21,25 @@ #include "nm-default.h" +#include "nm-connectivity.h" + #include #if WITH_CONCHECK #include #endif -#include "nm-connectivity.h" #include "nm-config.h" #include "nm-dispatcher.h" #include "NetworkManagerUtils.h" -G_DEFINE_TYPE (NMConnectivity, nm_connectivity, G_TYPE_OBJECT) +/*****************************************************************************/ -#define NM_CONNECTIVITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONNECTIVITY, NMConnectivityPrivate)) - -#define _NMLOG_DOMAIN LOGD_CONCHECK -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), (_NMLOG_DOMAIN), \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - "connectivity: " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END +NM_GOBJECT_PROPERTIES_DEFINE (NMConnectivity, + PROP_URI, + PROP_INTERVAL, + PROP_RESPONSE, + PROP_STATE, +); typedef struct { char *uri; @@ -59,15 +56,25 @@ typedef struct { NMConnectivityState state; } NMConnectivityPrivate; -enum { - PROP_0, - PROP_URI, - PROP_INTERVAL, - PROP_RESPONSE, - PROP_STATE, - LAST_PROP +struct _NMConnectivity { + GObject parent; + NMConnectivityPrivate _priv; +}; + +struct _NMConnectivityClass { + GObjectClass parent; }; +G_DEFINE_TYPE (NMConnectivity, nm_connectivity, G_TYPE_OBJECT) + +#define NM_CONNECTIVITY_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMConnectivity, NM_IS_CONNECTIVITY) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_CONCHECK +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "connectivity", __VA_ARGS__) + +/*****************************************************************************/ NMConnectivityState nm_connectivity_get_state (NMConnectivity *connectivity) @@ -96,7 +103,7 @@ update_state (NMConnectivity *self, NMConnectivityState state) nm_connectivity_state_to_string (priv->state), nm_connectivity_state_to_string (state)); priv->state = state; - g_object_notify (G_OBJECT (self), NM_CONNECTIVITY_STATE); + _notify (self, PROP_STATE); /* Notify dispatcher scripts of a connectivity state change */ nm_dispatcher_call_connectivity (DISPATCHER_ACTION_CONNECTIVITY_CHANGE, state); @@ -329,18 +336,35 @@ nm_connectivity_check_finish (NMConnectivity *self, return (NMConnectivityState) g_simple_async_result_get_op_res_gssize (simple); } -/**************************************************************************/ +/*****************************************************************************/ -NMConnectivity * -nm_connectivity_new (const char *uri, - guint interval, - const char *response) +static void +get_property (GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) { - return g_object_new (NM_TYPE_CONNECTIVITY, - NM_CONNECTIVITY_URI, uri, - NM_CONNECTIVITY_INTERVAL, interval, - NM_CONNECTIVITY_RESPONSE, response, - NULL); + NMConnectivity *self = NM_CONNECTIVITY (object); + NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE (self); + + switch (property_id) { + case PROP_URI: + g_value_set_string (value, priv->uri); + break; + case PROP_INTERVAL: + g_value_set_uint (value, priv->interval); + break; + case PROP_RESPONSE: + if (priv->response) + g_value_set_string (value, priv->response); + else + g_value_set_static_string (value, NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE); + break; + case PROP_STATE: + g_value_set_uint (value, priv->state); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } } static void @@ -403,35 +427,7 @@ set_property (GObject *object, guint property_id, } } -static void -get_property (GObject *object, guint property_id, - GValue *value, GParamSpec *pspec) -{ - NMConnectivity *self = NM_CONNECTIVITY (object); - NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE (self); - - switch (property_id) { - case PROP_URI: - g_value_set_string (value, priv->uri); - break; - case PROP_INTERVAL: - g_value_set_uint (value, priv->interval); - break; - case PROP_RESPONSE: - if (priv->response) - g_value_set_string (value, priv->response); - else - g_value_set_static_string (value, NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE); - break; - case PROP_STATE: - g_value_set_uint (value, priv->state); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - +/*****************************************************************************/ static void nm_connectivity_init (NMConnectivity *self) @@ -444,6 +440,17 @@ nm_connectivity_init (NMConnectivity *self) priv->state = NM_CONNECTIVITY_NONE; } +NMConnectivity * +nm_connectivity_new (const char *uri, + guint interval, + const char *response) +{ + return g_object_new (NM_TYPE_CONNECTIVITY, + NM_CONNECTIVITY_URI, uri, + NM_CONNECTIVITY_INTERVAL, interval, + NM_CONNECTIVITY_RESPONSE, response, + NULL); +} static void dispose (GObject *object) @@ -466,48 +473,42 @@ dispose (GObject *object) G_OBJECT_CLASS (nm_connectivity_parent_class)->dispose (object); } - static void nm_connectivity_class_init (NMConnectivityClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMConnectivityPrivate)); - /* virtual methods */ object_class->set_property = set_property; object_class->get_property = get_property; object_class->dispose = dispose; - /* properties */ - g_object_class_install_property - (object_class, PROP_URI, + obj_properties[PROP_URI] = g_param_spec_string (NM_CONNECTIVITY_URI, "", "", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_INTERVAL, + obj_properties[PROP_INTERVAL] = g_param_spec_uint (NM_CONNECTIVITY_INTERVAL, "", "", 0, G_MAXUINT, NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_RESPONSE, + obj_properties[PROP_RESPONSE] = g_param_spec_string (NM_CONNECTIVITY_RESPONSE, "", "", NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); - g_object_class_install_property - (object_class, PROP_STATE, + obj_properties[PROP_STATE] = g_param_spec_uint (NM_CONNECTIVITY_STATE, "", "", NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_UNKNOWN, G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/nm-connectivity.h b/src/nm-connectivity.h index 10fcef97..6900bd0f 100644 --- a/src/nm-connectivity.h +++ b/src/nm-connectivity.h @@ -30,19 +30,12 @@ #define NM_IS_CONNECTIVITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CONNECTIVITY)) #define NM_CONNECTIVITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTIVITY, NMConnectivityClass)) -/* Properties */ #define NM_CONNECTIVITY_URI "uri" #define NM_CONNECTIVITY_INTERVAL "interval" #define NM_CONNECTIVITY_RESPONSE "response" #define NM_CONNECTIVITY_STATE "state" -struct _NMConnectivity { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMConnectivityClass; +typedef struct _NMConnectivityClass NMConnectivityClass; GType nm_connectivity_get_type (void); diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index ed2a871e..219f309b 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -520,7 +520,7 @@ fail: return 0; } -/******************************************************************************************/ +/*****************************************************************************/ typedef struct { pid_t pid; @@ -1152,12 +1152,12 @@ nm_utils_kill_process_sync (pid_t pid, guint64 start_time, int sig, NMLogDomain const char *const NM_PATHS_DEFAULT[] = { PREFIX "/sbin/", PREFIX "/bin/", + "/usr/local/sbin/", "/sbin/", "/usr/sbin/", - "/usr/local/sbin/", + "/usr/local/bin/", "/bin/", "/usr/bin/", - "/usr/local/bin/", NULL, }; @@ -1167,7 +1167,7 @@ nm_utils_find_helper(const char *progname, const char *try_first, GError **error return nm_utils_file_search_in_paths (progname, try_first, NM_PATHS_DEFAULT, G_FILE_TEST_IS_EXECUTABLE, NULL, NULL, error); } -/******************************************************************************************/ +/*****************************************************************************/ /** * nm_utils_read_link_absolute: @@ -1201,7 +1201,7 @@ nm_utils_read_link_absolute (const char *link_file, GError **error) return ln_abs; } -/******************************************************************************************/ +/*****************************************************************************/ #define MAC_TAG "mac:" #define INTERFACE_NAME_TAG "interface-name:" @@ -1771,83 +1771,6 @@ nm_utils_to_string_buffer_init_null (gconstpointer obj, char **buf, gsize *len) return TRUE; } -void -nm_utils_strbuf_append_c (char **buf, gsize *len, char c) -{ - switch (*len) { - case 0: - return; - case 1: - (*buf)[0] = '\0'; - *len = 0; - (*buf)++; - return; - default: - (*buf)[0] = c; - (*buf)[1] = '\0'; - (*len)--; - (*buf)++; - return; - } -} - -void -nm_utils_strbuf_append_str (char **buf, gsize *len, const char *str) -{ - gsize src_len; - - switch (*len) { - case 0: - return; - case 1: - if (!str || !*str) { - (*buf)[0] = '\0'; - return; - } - (*buf)[0] = '\0'; - *len = 0; - (*buf)++; - return; - default: - if (!str || !*str) { - (*buf)[0] = '\0'; - return; - } - src_len = g_strlcpy (*buf, str, *len); - if (src_len >= *len) { - *buf = &(*buf)[*len]; - *len = 0; - } else { - *buf = &(*buf)[src_len]; - *len -= src_len; - } - return; - } -} - -void -nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...) -{ - char *p = *buf; - va_list args; - gint retval; - - if (*len == 0) - return; - - va_start (args, format); - retval = g_vsnprintf (p, *len, format, args); - va_end (args); - - if (retval >= *len) { - *buf = &p[*len]; - *len = 0; - } else { - *buf = &p[retval]; - *len -= retval; - } -} - const char * nm_utils_flags2str (const NMUtilsFlags2StrDesc *descs, gsize n_descs, @@ -2080,7 +2003,7 @@ nm_utils_cmp_connection_by_autoconnect_priority (NMConnection **a, NMConnection return 0; } -/**************************************************************************/ +/*****************************************************************************/ static gint64 monotonic_timestamp_offset_sec; static int monotonic_timestamp_clock_mode = 0; @@ -2649,7 +2572,7 @@ nm_utils_is_specific_hostname (const char *name) return FALSE; } -/******************************************************************/ +/*****************************************************************************/ gboolean nm_utils_machine_id_parse (const char *id_str, /*uuid_t*/ guchar *out_uuid) @@ -2802,6 +2725,246 @@ nm_utils_fd_read_loop_exact (int fd, void *buf, size_t nbytes, bool do_poll) return 0; } +_nm_printf (3, 4) +static int +_get_contents_error (GError **error, int errsv, const char *format, ...) +{ + if (errsv < 0) + errsv = -errsv; + else if (!errsv) + errsv = errno; + + if (error) { + char *msg; + va_list args; + + va_start (args, format); + msg = g_strdup_vprintf (format, args); + va_end (args); + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "%s: %s", + msg, g_strerror (errsv)); + g_free (msg); + } + return -errsv; +} + +/** + * nm_utils_fd_get_contents: + * @fd: open file descriptor to read. The fd will not be closed, + * but don't rely on it's state afterwards. + * @max_length: allocate at most @max_length bytes. If the + * file is larger, reading will fail. Set to zero to use + * a very large default. + * + * WARNING: @max_length is here to avoid a crash for huge/unlimited files. + * For example, stat(/sys/class/net/enp0s25/ifindex) gives a filesize of + * 4K, although the actual real is small. @max_length is the memory + * allocated in the process of reading the file, thus it must be at least + * the size reported by fstat. + * If you set it to 1K, read will fail because fstat() claims the + * file is larger. + * + * @contents: the output buffer with the file read. It is always + * NUL terminated. The buffer is at most @max_length long, including + * the NUL byte. That is, it reads only files up to a length of + * @max_length - 1 bytes. + * @length: optional output argument of the read file size. + * + * A reimplementation of g_file_get_contents() with a few differences: + * - accepts an open fd, instead of a path name. This allows you to + * use openat(). + * - limits the maxium filesize to max_length. + * + * Returns: a negative error code on failure. + */ +int +nm_utils_fd_get_contents (int fd, + gsize max_length, + char **contents, + gsize *length, + GError **error) +{ + struct stat stat_buf; + gs_free char *str = NULL; + + g_return_val_if_fail (fd >= 0, -EINVAL); + g_return_val_if_fail (contents, -EINVAL); + g_return_val_if_fail (!error || !*error, -EINVAL); + + if (fstat (fd, &stat_buf) < 0) + return _get_contents_error (error, 0, "failure during fstat"); + + if (!max_length) { + /* default to a very large size, but not extreme */ + max_length = 2 * 1024 * 1024; + } + + if ( stat_buf.st_size > 0 + && S_ISREG (stat_buf.st_mode)) { + const gsize n_stat = stat_buf.st_size; + ssize_t n_read; + + if (n_stat > max_length - 1) + return _get_contents_error (error, EMSGSIZE, "file too large (%zu+1 bytes with maximum %zu bytes)", n_stat, max_length); + + str = g_try_malloc (n_stat + 1); + if (!str) + return _get_contents_error (error, ENOMEM, "failure to allocate buffer of %zu+1 bytes", n_stat); + + n_read = nm_utils_fd_read_loop (fd, str, n_stat, TRUE); + if (n_read < 0) + return _get_contents_error (error, n_read, "error reading %zu bytes from file descriptor", n_stat); + str[n_read] = '\0'; + + if (n_read < n_stat) { + char *tmp; + + tmp = g_try_realloc (str, n_read + 1); + if (!tmp) + return _get_contents_error (error, ENOMEM, "failure to reallocate buffer with %zu bytes", n_read + 1); + str = tmp; + } + NM_SET_OUT (length, n_read); + } else { + nm_auto_fclose FILE *f = NULL; + char buf[4096]; + gsize n_have, n_alloc; + + if (!(f = fdopen (fd, "r"))) + return _get_contents_error (error, 0, "failure during fdopen"); + + n_have = 0; + n_alloc = 0; + + while (!feof (f)) { + int errsv; + gsize n_read; + + n_read = fread (buf, 1, sizeof (buf), f); + errsv = errno; + if (ferror (f)) + return _get_contents_error (error, errsv, "error during fread"); + + if ( n_have > G_MAXSIZE - 1 - n_read + || n_have + n_read + 1 > max_length) { + return _get_contents_error (error, EMSGSIZE, "file stream too large (%zu+1 bytes with maximum %zu bytes)", + (n_have > G_MAXSIZE - 1 - n_read) ? G_MAXSIZE : n_have + n_read, + max_length); + } + + if (n_have + n_read + 1 >= n_alloc) { + char *tmp; + + if (str) { + if (n_alloc >= max_length / 2) + n_alloc = max_length; + else + n_alloc *= 2; + } else + n_alloc = NM_MIN (n_read + 1, sizeof (buf)); + + tmp = g_try_realloc (str, n_alloc); + if (!tmp) + return _get_contents_error (error, ENOMEM, "failure to allocate buffer of %zu bytes", n_alloc); + str = tmp; + } + + memcpy (str + n_have, buf, n_read); + n_have += n_read; + } + + if (n_alloc == 0) + str = g_new0 (gchar, 1); + else { + str[n_have] = '\0'; + if (n_have + 1 < n_alloc) { + char *tmp; + + tmp = g_try_realloc (str, n_have + 1); + if (!tmp) + return _get_contents_error (error, ENOMEM, "failure to truncate buffer to %zu bytes", n_have + 1); + str = tmp; + } + } + + NM_SET_OUT (length, n_have); + } + + *contents = g_steal_pointer (&str); + return 0; +} + +/** + * nm_utils_file_get_contents: + * @dirfd: optional file descriptor to use openat(). If negative, use plain open(). + * @filename: the filename to open. Possibly relative to @dirfd. + * @max_length: allocate at most @max_length bytes. + * WARNING: see nm_utils_fd_get_contents() hint about @max_length. + * @contents: the output buffer with the file read. It is always + * NUL terminated. The buffer is at most @max_length long, including + * the NUL byte. That is, it reads only files up to a length of + * @max_length - 1 bytes. + * @length: optional output argument of the read file size. + * + * A reimplementation of g_file_get_contents() with a few differences: + * - accepts an @dirfd to open @filename relative to that path via openat(). + * - limits the maxium filesize to max_length. + * - uses O_CLOEXEC on internal file descriptor + * + * Returns: a negative error code on failure. + */ +int +nm_utils_file_get_contents (int dirfd, + const char *filename, + gsize max_length, + char **contents, + gsize *length, + GError **error) +{ + nm_auto_close int fd = -1; + int errsv; + + g_return_val_if_fail (filename && filename[0], -EINVAL); + + if (dirfd >= 0) { + fd = openat (dirfd, filename, O_RDONLY | O_CLOEXEC); + if (fd < 0) { + errsv = errno; + + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "Failed to open file \"%s\" with openat: %s", + filename, + g_strerror (errsv)); + return -errsv; + } + } else { + fd = open (filename, O_RDONLY | O_CLOEXEC); + if (fd < 0) { + errsv = errno; + + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "Failed to open file \"%s\": %s", + filename, + g_strerror (errsv)); + return -errsv; + } + } + return nm_utils_fd_get_contents (fd, + max_length, + contents, + length, + error); +} + +/*****************************************************************************/ + /* taken from systemd's dev_urandom(). */ int nm_utils_read_urandom (void *p, size_t nbytes) @@ -2877,6 +3040,39 @@ out: return NULL; } +/*****************************************************************************/ + +const char * +nm_utils_get_boot_id (void) +{ + static const char *boot_id; + + if (G_UNLIKELY (!boot_id)) { + gs_free char *contents = NULL; + + nm_utils_file_get_contents (-1, "/proc/sys/kernel/random/boot_id", 0, + &contents, NULL, NULL); + if (contents) { + g_strstrip (contents); + if (contents[0]) { + /* clone @contents because we keep @boot_id until the program + * ends. + * nm_utils_file_get_contents() likely allocated a larger + * buffer chunk initially and (although using realloc to shrink + * the buffer) it might not be best to keep this memory + * around. */ + boot_id = g_strdup (contents); + } + } + if (!boot_id) + boot_id = nm_utils_uuid_generate (); + } + + return boot_id; +} + +/*****************************************************************************/ + /* Returns the "u" (universal/local) bit value for a Modified EUI-64 */ static gboolean get_gre_eui64_u_bit (guint32 addr) @@ -3071,8 +3267,188 @@ nm_utils_inet6_interface_identifier_to_token (NMUtilsIPv6IfaceId iid, char *buf) /*****************************************************************************/ +char * +nm_utils_stable_id_random (void) +{ + char buf[15]; + + if (nm_utils_read_urandom (buf, sizeof (buf)) < 0) + g_return_val_if_reached (nm_utils_uuid_generate ()); + return g_base64_encode ((guchar *) buf, sizeof (buf)); +} + +char * +nm_utils_stable_id_generated_complete (const char *stable_id_generated) +{ + guint8 buf[20]; + GChecksum *sum; + gsize buf_size; + char *base64; + + /* for NM_UTILS_STABLE_TYPE_GENERATED we genererate a possibly long string + * by doing text-substitutions in nm_utils_stable_id_parse(). + * + * Let's shorten the (possibly) long stable_id to something more compact. */ + + g_return_val_if_fail (stable_id_generated, NULL); + + sum = g_checksum_new (G_CHECKSUM_SHA1); + nm_assert (sum); + + g_checksum_update (sum, (guchar *) stable_id_generated, strlen (stable_id_generated)); + + buf_size = sizeof (buf); + g_checksum_get_digest (sum, buf, &buf_size); + nm_assert (buf_size == sizeof (buf)); + + g_checksum_free (sum); + + /* we don't care to use the sha1 sum in common hex representation. + * Use instead base64, it's 27 chars (stripping the padding) vs. + * 40. */ + + base64 = g_base64_encode ((guchar *) buf, sizeof (buf)); + nm_assert (strlen (base64) == 28); + nm_assert (base64[27] == '='); + + base64[27] = '\0'; + return base64; +} + +static void +_stable_id_append (GString *str, + const char *substitution) +{ + if (!substitution) + substitution = ""; + g_string_append_printf (str, "=%zu{%s}", strlen (substitution), substitution); +} + +NMUtilsStableType +nm_utils_stable_id_parse (const char *stable_id, + const char *uuid, + const char *bootid, + char **out_generated) +{ + gsize i, idx_start; + GString *str = NULL; + + g_return_val_if_fail (out_generated, NM_UTILS_STABLE_TYPE_RANDOM); + + if (!stable_id) { + out_generated = NULL; + return NM_UTILS_STABLE_TYPE_UUID; + } + + /* the stable-id allows for some dynamic by performing text-substitutions + * of ${...} patterns. + * + * At first, it looks a bit like bash parameter substitution. + * In contrast however, the process is unambigious so that the resulting + * effective id differs if: + * - the original, untranslated stable-id differs + * - or any of the subsitutions differs. + * + * The reason for that is, for example if you specify "${CONNECTION}" in the + * stable-id, then the resulting ID should be always(!) unique for this connection. + * There should be no way another connection could specify any stable-id that results + * in the same addresses to be generated (aside hash collisions). + * + * + * For example: say you have a connection with UUID + * "123e4567-e89b-12d3-a456-426655440000" which happens also to be + * the current boot-id. + * Then: + * (1) connection.stable-id = + * (2) connection.stable-id = "123e4567-e89b-12d3-a456-426655440000" + * (3) connection.stable-id = "${CONNECTION}" + * (3) connection.stable-id = "${BOOT}" + * will all generate different addresses, although in one way or the + * other, they all mangle the uuid "123e4567-e89b-12d3-a456-426655440000". + * + * For example, with stable-id="${FOO}${BAR}" the substitutions + * - FOO="ab", BAR="c" + * - FOO="a", BAR="bc" + * should give a different effective id. + * + * For example, with FOO="x" and BAR="x", the stable-ids + * - "${FOO}${BAR}" + * - "${BAR}${FOO}" + * should give a different effective id. + */ + + idx_start = 0; + for (i = 0; stable_id[i]; ) { + if (stable_id[i] != '$') { + i++; + continue; + } + +#define CHECK_PREFIX(prefix) \ + ({ \ + gboolean _match = FALSE; \ + \ + if (g_str_has_prefix (&stable_id[i], ""prefix"")) { \ + _match = TRUE; \ + if (!str) \ + str = g_string_sized_new (256); \ + i += NM_STRLEN (prefix); \ + g_string_append_len (str, &(stable_id)[idx_start], i - idx_start); \ + idx_start = i; \ + } \ + _match; \ + }) + if (CHECK_PREFIX ("${CONNECTION}")) + _stable_id_append (str, uuid); + else if (CHECK_PREFIX ("${BOOT}")) + _stable_id_append (str, bootid ?: nm_utils_get_boot_id ()); + else if (g_str_has_prefix (&stable_id[i], "${RANDOM}")) { + /* RANDOM makes not so much sense for cloned-mac-address + * as the result is simmilar to specifing "cloned-mac-address=random". + * It makes however sense for RFC 7217 Stable Privacy IPv6 addresses + * where this is effectively the only way to generate a different + * (random) host identifier for each connect. + * + * With RANDOM, the user can switch the lifetime of the + * generated cloned-mac-address and IPv6 host identifier + * by toggeling only the stable-id property of the connection. + * With RANDOM being the most short-lived, ~non-stable~ variant. + */ + if (str) + g_string_free (str, TRUE); + *out_generated = NULL; + return NM_UTILS_STABLE_TYPE_RANDOM; + } else { + /* The text following the '$' is not recognized as valid + * substitution pattern. Treat it verbatim. */ + i++; + + /* Note that using unrecognized substitution patterns might + * yield different results with future versions. Avoid that, + * by not using '$' (except for actual substitutions) or escape + * it as "$$" (which is guaranteed to be treated verbatim + * in future). */ + if (stable_id[i] == '$') + i++; + } + } +#undef CHECK_PREFIX + + if (!str) { + *out_generated = NULL; + return NM_UTILS_STABLE_TYPE_STABLE_ID; + } + + if (idx_start < i) + g_string_append_len (str, &stable_id[idx_start], i - idx_start); + *out_generated = g_string_free (str, FALSE); + return NM_UTILS_STABLE_TYPE_GENERATED; +} + +/*****************************************************************************/ + static gboolean -_set_stable_privacy (guint8 stable_type, +_set_stable_privacy (NMUtilsStableType stable_type, struct in6_addr *addr, const char *ifname, const char *network_id, @@ -3086,7 +3462,8 @@ _set_stable_privacy (guint8 stable_type, guint32 tmp[2]; gsize len = sizeof (digest); - g_return_val_if_fail (key_len, FALSE); + nm_assert (key_len); + nm_assert (network_id); /* Documentation suggests that this can fail. * Maybe in case of a missing algorithm in crypto library? */ @@ -3100,6 +3477,11 @@ _set_stable_privacy (guint8 stable_type, key_len = MIN (key_len, G_MAXUINT32); if (stable_type != NM_UTILS_STABLE_TYPE_UUID) { + guint8 stable_type_uint8; + + nm_assert (stable_type < (NMUtilsStableType) 255); + stable_type_uint8 = (guint8) stable_type; + /* Preferably, we would always like to include the stable-type, * but for backward compatibility reasons, we cannot for UUID. * @@ -3109,13 +3491,11 @@ _set_stable_privacy (guint8 stable_type, * and the terminating '\0' of @network_id, it is unambigiously * possible to revert the process and deduce the @stable_type. */ - g_checksum_update (sum, &stable_type, sizeof (stable_type)); + g_checksum_update (sum, &stable_type_uint8, sizeof (stable_type_uint8)); } g_checksum_update (sum, addr->s6_addr, 8); g_checksum_update (sum, (const guchar *) ifname, strlen (ifname) + 1); - if (!network_id) - network_id = ""; g_checksum_update (sum, (const guchar *) network_id, strlen (network_id) + 1); tmp[0] = htonl (dad_counter); tmp[1] = htonl (key_len); @@ -3132,6 +3512,19 @@ _set_stable_privacy (guint8 stable_type, return TRUE; } +gboolean +nm_utils_ipv6_addr_set_stable_privacy_impl (NMUtilsStableType stable_type, + struct in6_addr *addr, + const char *ifname, + const char *network_id, + guint dad_counter, + guint8 *secret_key, + gsize key_len, + GError **error) +{ + return _set_stable_privacy (stable_type, addr, ifname, network_id, dad_counter, secret_key, key_len, error); +} + #define RFC7217_IDGEN_RETRIES 3 /** * nm_utils_ipv6_addr_set_stable_privacy: @@ -3152,9 +3545,7 @@ nm_utils_ipv6_addr_set_stable_privacy (NMUtilsStableType stable_type, gs_free guint8 *secret_key = NULL; gsize key_len = 0; - nm_assert (NM_IN_SET (stable_type, - NM_UTILS_STABLE_TYPE_UUID, - NM_UTILS_STABLE_TYPE_STABLE_ID)); + g_return_val_if_fail (network_id, FALSE); if (dad_counter >= RFC7217_IDGEN_RETRIES) { g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, @@ -3254,9 +3645,6 @@ _hw_addr_gen_stable_eth (NMUtilsStableType stable_type, guint8 stable_type_uint8; nm_assert (stable_id); - nm_assert (NM_IN_SET (stable_type, - NM_UTILS_STABLE_TYPE_UUID, - NM_UTILS_STABLE_TYPE_STABLE_ID)); nm_assert (secret_key); sum = g_checksum_new (G_CHECKSUM_SHA256); @@ -3265,6 +3653,7 @@ _hw_addr_gen_stable_eth (NMUtilsStableType stable_type, key_len = MIN (key_len, G_MAXUINT32); + nm_assert (stable_type < (NMUtilsStableType) 255); stable_type_uint8 = stable_type; g_checksum_update (sum, (const guchar *) &stable_type_uint8, sizeof (stable_type_uint8)); @@ -3284,6 +3673,18 @@ _hw_addr_gen_stable_eth (NMUtilsStableType stable_type, return nm_utils_hwaddr_ntoa (&bin_addr, ETH_ALEN); } +char * +nm_utils_hw_addr_gen_stable_eth_impl (NMUtilsStableType stable_type, + const char *stable_id, + const guint8 *secret_key, + gsize key_len, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask) +{ + return _hw_addr_gen_stable_eth (stable_type, stable_id, secret_key, key_len, ifname, current_mac_address, generate_mac_address_mask); +} + char * nm_utils_hw_addr_gen_stable_eth (NMUtilsStableType stable_type, const char *stable_id, @@ -3418,7 +3819,7 @@ nm_utils_ifname_cpy (char *dst, const char *name) g_return_if_fail (dst); g_return_if_fail (name && name[0]); - nm_assert (nm_utils_iface_valid_name (name)); + nm_assert (nm_utils_is_valid_iface_name (name, NULL)); if (g_strlcpy (dst, name, IFNAMSIZ) >= IFNAMSIZ) g_return_if_reached (); @@ -3486,14 +3887,15 @@ nm_utils_lifetime_get (guint32 timestamp, nm_assert (now >= 0); - if (lifetime == 0) { + if (timestamp == 0 && lifetime == 0) { + /* We treat lifetime==0 && timestamp == 0 addresses as permanent addresses to allow easy + * creation of such addresses (without requiring to set the lifetime fields to + * NM_PLATFORM_LIFETIME_PERMANENT). The real lifetime==0 addresses (E.g. DHCP6 telling us + * to drop an address will have timestamp set. + */ *out_lifetime = NM_PLATFORM_LIFETIME_PERMANENT; *out_preferred = NM_PLATFORM_LIFETIME_PERMANENT; - - /* We treat lifetime==0 as permanent addresses to allow easy creation of such addresses - * (without requiring to set the lifetime fields to NM_PLATFORM_LIFETIME_PERMANENT). - * In that case we also expect that the other fields (timestamp and preferred) are left unset. */ - g_return_val_if_fail (timestamp == 0 && preferred == 0, TRUE); + g_return_val_if_fail (preferred == 0, TRUE); } else { if (now <= 0) now = nm_utils_get_monotonic_timestamp_s (); @@ -3654,3 +4056,228 @@ nm_utils_get_reverse_dns_domains_ip6 (const struct in6_addr *ip, guint8 plen, GP #undef N_SHIFT } + +/** + * Copied from GLib's g_file_set_contents() et al., but allows + * specifying a mode for the new file. + */ +gboolean +nm_utils_file_set_contents (const gchar *filename, + const gchar *contents, + gssize length, + mode_t mode, + GError **error) +{ + gs_free char *tmp_name = NULL; + struct stat statbuf; + int errsv; + gssize s; + int fd; + + g_return_val_if_fail (filename, FALSE); + g_return_val_if_fail (contents || !length, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + g_return_val_if_fail (length >= -1, FALSE); + + tmp_name = g_strdup_printf ("%s.XXXXXX", filename); + fd = g_mkstemp_full (tmp_name, O_RDWR, mode); + if (fd < 0) { + errsv = errno; + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "failed to create file %s: %s", + tmp_name, + g_strerror (errsv)); + return FALSE; + } + + while (length > 0) { + s = write (fd, contents, length); + if (s < 0) { + errsv = errno; + if (errsv == EINTR) + continue; + + close (fd); + unlink (tmp_name); + + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "failed to write to file %s: %s", + tmp_name, + g_strerror (errsv)); + return FALSE; + } + + g_assert (s <= length); + + contents += s; + length -= s; + } + + /* If the final destination exists and is > 0 bytes, we want to sync the + * newly written file to ensure the data is on disk when we rename over + * the destination. Otherwise if we get a system crash we can lose both + * the new and the old file on some filesystems. (I.E. those that don't + * guarantee the data is written to the disk before the metadata.) + */ + if ( lstat (filename, &statbuf) == 0 + && statbuf.st_size > 0 + && fsync (fd) != 0) { + errsv = errno; + + close (fd); + unlink (tmp_name); + + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "failed to fsync %s: %s", + tmp_name, + g_strerror (errsv)); + return FALSE; + } + + close (fd); + + if (rename (tmp_name, filename)) { + errsv = errno; + unlink (tmp_name); + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (errsv), + "failed to rename %s to %s: %s", + tmp_name, + filename, + g_strerror (errsv)); + return FALSE; + } + + return TRUE; +} + +struct plugin_info { + char *path; + struct stat st; +}; + +static gint +read_device_factory_paths_sort_fcn (gconstpointer a, gconstpointer b) +{ + const struct plugin_info *da = a; + const struct plugin_info *db = b; + time_t ta, tb; + + ta = MAX (da->st.st_mtime, da->st.st_ctime); + tb = MAX (db->st.st_mtime, db->st.st_ctime); + + if (ta < tb) + return 1; + if (ta > tb) + return -1; + return 0; +} + +gboolean +nm_utils_validate_plugin (const char *path, struct stat *st, GError **error) +{ + g_return_val_if_fail (path, FALSE); + g_return_val_if_fail (st, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + if (!S_ISREG (st->st_mode)) { + g_set_error_literal (error, + NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "not a regular file"); + return FALSE; + } + + if (st->st_uid != 0) { + g_set_error_literal (error, + NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "file has invalid owner (should be root)"); + return FALSE; + } + + if (st->st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) { + g_set_error_literal (error, + NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, + "file has invalid permissions"); + return FALSE; + } + + return TRUE; +} + +char ** +nm_utils_read_plugin_paths (const char *dirname, const char *prefix) +{ + GDir *dir; + GError *error = NULL; + const char *item; + GArray *paths; + char **result; + guint i; + + g_return_val_if_fail (dirname, NULL); + g_return_val_if_fail (prefix, NULL); + + dir = g_dir_open (dirname, 0, &error); + if (!dir) { + nm_log_warn (LOGD_CORE, "device plugin: failed to open directory %s: %s", + dirname, + error->message); + g_clear_error (&error); + return NULL; + } + + paths = g_array_new (FALSE, FALSE, sizeof (struct plugin_info)); + + while ((item = g_dir_read_name (dir))) { + int errsv; + struct plugin_info data; + + if (!g_str_has_prefix (item, prefix)) + continue; + if (g_str_has_suffix (item, ".la")) + continue; + + data.path = g_build_filename (dirname, item, NULL); + + if (stat (data.path, &data.st) != 0) { + errsv = errno; + nm_log_warn (LOGD_CORE, + "plugin: skip invalid file %s (error during stat: %s)", + data.path, strerror (errsv)); + goto skip; + } + + if (!nm_utils_validate_plugin (data.path, &data.st, &error)) { + nm_log_warn (LOGD_CORE, + "plugin: skip invalid file %s: %s", + data.path, error->message); + g_clear_error (&error); + goto skip; + } + + g_array_append_val (paths, data); + continue; +skip: + g_free (data.path); + } + g_dir_close (dir); + + /* sort filenames by modification time. */ + g_array_sort (paths, read_device_factory_paths_sort_fcn); + + result = g_new (char *, paths->len + 1); + for (i = 0; i < paths->len; i++) + result[i] = g_array_index (paths, struct plugin_info, i).path; + result[i] = NULL; + + g_array_free (paths, TRUE); + return result; +} + diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h index 3ef960bb..e3aa257f 100644 --- a/src/nm-core-utils.h +++ b/src/nm-core-utils.h @@ -262,23 +262,6 @@ fcn_name (lookup_type val) \ /*****************************************************************************/ -static inline void -_nm_utils_strbuf_init (char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len) -{ - NM_SET_OUT (p_buf_len, len); - NM_SET_OUT (p_buf_ptr, buf); - buf[0] = '\0'; -} - -#define nm_utils_strbuf_init(buf, p_buf_ptr, p_buf_len) \ - G_STMT_START { \ - G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) > sizeof (char *)); \ - _nm_utils_strbuf_init ((buf), sizeof (buf), (p_buf_ptr), (p_buf_len)); \ - } G_STMT_END -void nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...) _nm_printf (3, 4); -void nm_utils_strbuf_append_c (char **buf, gsize *len, char c); -void nm_utils_strbuf_append_str (char **buf, gsize *len, const char *str); - const char *nm_utils_get_ip_config_method (NMConnection *connection, GType ip_setting_type); @@ -313,6 +296,25 @@ int nm_utils_fd_wait_for_event (int fd, int event, gint64 timeout_ns); ssize_t nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll); int nm_utils_fd_read_loop_exact (int fd, void *buf, size_t nbytes, bool do_poll); +int nm_utils_fd_get_contents (int fd, + gsize max_length, + char **contents, + gsize *length, + GError **error); + +int nm_utils_file_get_contents (int dirfd, + const char *filename, + gsize max_length, + char **contents, + gsize *length, + GError **error); + +gboolean nm_utils_file_set_contents (const gchar *filename, + const gchar *contents, + gssize length, + mode_t mode, + GError **error); + int nm_utils_read_urandom (void *p, size_t n); char *nm_utils_machine_id_read (void); @@ -320,6 +322,8 @@ gboolean nm_utils_machine_id_parse (const char *id_str, /*uuid_t*/ guchar *out_u guint8 *nm_utils_secret_key_read (gsize *out_key_len, GError **error); +const char *nm_utils_get_boot_id (void); + /* IPv6 Interface Identifer helpers */ /** @@ -358,11 +362,36 @@ gboolean nm_utils_get_ipv6_interface_identifier (NMLinkType link_type, guint dev_id, NMUtilsIPv6IfaceId *out_iid); -typedef enum { /*< skip >*/ - NM_UTILS_STABLE_TYPE_UUID = 0, +typedef enum { + /* The stable type. Note that this value is encoded in the + * generated addresses, thus the numbers MUST not change. + * + * Also note, if we ever allocate ID 255, we must take care + * that nm_utils_ipv6_addr_set_stable_privacy() extends the + * uint8 encoding of this value. */ + NM_UTILS_STABLE_TYPE_UUID = 0, NM_UTILS_STABLE_TYPE_STABLE_ID = 1, + NM_UTILS_STABLE_TYPE_GENERATED = 2, + NM_UTILS_STABLE_TYPE_RANDOM = 3, } NMUtilsStableType; +NMUtilsStableType nm_utils_stable_id_parse (const char *stable_id, + const char *uuid, + const char *bootid, + char **out_generated); + +char *nm_utils_stable_id_random (void); +char *nm_utils_stable_id_generated_complete (const char *msg); + +gboolean nm_utils_ipv6_addr_set_stable_privacy_impl (NMUtilsStableType stable_type, + struct in6_addr *addr, + const char *ifname, + const char *network_id, + guint dad_counter, + guint8 *secret_key, + gsize key_len, + GError **error); + gboolean nm_utils_ipv6_addr_set_stable_privacy (NMUtilsStableType id_type, struct in6_addr *addr, const char *ifname, @@ -372,6 +401,13 @@ gboolean nm_utils_ipv6_addr_set_stable_privacy (NMUtilsStableType id_type, char *nm_utils_hw_addr_gen_random_eth (const char *current_mac_address, const char *generate_mac_address_mask); +char *nm_utils_hw_addr_gen_stable_eth_impl (NMUtilsStableType stable_type, + const char *stable_id, + const guint8 *secret_key, + gsize key_len, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask); char *nm_utils_hw_addr_gen_stable_eth (NMUtilsStableType stable_type, const char *stable_id, const char *ifname, @@ -428,4 +464,9 @@ const char *nm_utils_dnsmasq_status_to_string (int status, char *dest, gsize siz void nm_utils_get_reverse_dns_domains_ip4 (guint32 ip, guint8 plen, GPtrArray *domains); void nm_utils_get_reverse_dns_domains_ip6 (const struct in6_addr *ip, guint8 plen, GPtrArray *domains); +struct stat; + +gboolean nm_utils_validate_plugin (const char *path, struct stat *stat, GError **error); +char **nm_utils_read_plugin_paths (const char *dirname, const char *prefix); + #endif /* __NM_CORE_UTILS_H__ */ diff --git a/src/nm-dcb.c b/src/nm-dcb.c index d8f3d3e7..140e7c36 100644 --- a/src/nm-dcb.c +++ b/src/nm-dcb.c @@ -24,7 +24,7 @@ #include #include "nm-dcb.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "NetworkManagerUtils.h" static const char *helper_names[] = { "dcbtool", "fcoeadm" }; diff --git a/src/nm-default-route-manager.c b/src/nm-default-route-manager.c index 2fd2c7db..5944654c 100644 --- a/src/nm-default-route-manager.c +++ b/src/nm-default-route-manager.c @@ -21,16 +21,23 @@ #include "nm-default.h" +#include "nm-default-route-manager.h" + #include -#include "nm-default-route-manager.h" -#include "nm-device.h" -#include "nm-vpn-connection.h" -#include "nm-platform.h" +#include "devices/nm-device.h" +#include "vpn/nm-vpn-connection.h" +#include "platform/nm-platform.h" #include "nm-manager.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" -#include "nm-activation-request.h" +#include "nm-act-request.h" + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PLATFORM, +); typedef struct { GPtrArray *entries_ip4; @@ -54,16 +61,23 @@ typedef struct { NMPlatform *platform; } NMDefaultRouteManagerPrivate; -#define NM_DEFAULT_ROUTE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEFAULT_ROUTE_MANAGER, NMDefaultRouteManagerPrivate)) +struct _NMDefaultRouteManager { + GObject parent; + NMDefaultRouteManagerPrivate _priv; +}; + +struct _NMDefaultRouteManagerClass { + GObjectClass parent; +}; G_DEFINE_TYPE (NMDefaultRouteManager, nm_default_route_manager, G_TYPE_OBJECT) -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PLATFORM, -); +#define NM_DEFAULT_ROUTE_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDefaultRouteManager, NM_IS_DEFAULT_ROUTE_MANAGER) NM_DEFINE_SINGLETON_GETTER (NMDefaultRouteManager, nm_default_route_manager_get, NM_TYPE_DEFAULT_ROUTE_MANAGER); +/*****************************************************************************/ + #define _NMLOG_PREFIX_NAME "default-route" #undef _NMLOG_ENABLED #define _NMLOG_ENABLED(level, addr_family) \ @@ -127,11 +141,11 @@ NM_DEFINE_SINGLETON_GETTER (NMDefaultRouteManager, nm_default_route_manager_get, } \ } G_STMT_END -/***********************************************************************************/ +/*****************************************************************************/ static void _resync_idle_cancel (NMDefaultRouteManager *self); -/***********************************************************************************/ +/*****************************************************************************/ typedef struct { union { @@ -695,7 +709,7 @@ _entry_at_idx_remove (const VTableIP *vtable, NMDefaultRouteManager *self, guint _entry_free (entry); } -/***********************************************************************************/ +/*****************************************************************************/ static void _ipx_update_default_route (const VTableIP *vtable, NMDefaultRouteManager *self, gpointer source) @@ -888,7 +902,7 @@ nm_default_route_manager_ip6_update_default_route (NMDefaultRouteManager *self, _ipx_update_default_route (&vtable_ip6, self, source); } -/***********************************************************************************/ +/*****************************************************************************/ static gboolean _ipx_connection_has_default_route (const VTableIP *vtable, NMDefaultRouteManager *self, NMConnection *connection, gboolean *out_is_never_default) @@ -947,7 +961,7 @@ nm_default_route_manager_ip6_connection_has_default_route (NMDefaultRouteManager return _ipx_connection_has_default_route (&vtable_ip6, self, connection, out_is_never_default); } -/***********************************************************************************/ +/*****************************************************************************/ static NMDevice * _ipx_get_best_device (const VTableIP *vtable, NMDefaultRouteManager *self, const GSList *devices) @@ -1085,7 +1099,7 @@ nm_default_route_manager_ip6_get_best_device (NMDefaultRouteManager *self, const return _ipx_get_best_activating_device (&vtable_ip6, self, devices, preferred_device); } -/***********************************************************************************/ +/*****************************************************************************/ static gpointer _ipx_get_best_config (const VTableIP *vtable, @@ -1218,7 +1232,7 @@ nm_default_route_manager_ip6_get_best_config (NMDefaultRouteManager *self, out_vpn); } -/***********************************************************************************/ +/*****************************************************************************/ static GPtrArray * _v4_get_entries (NMDefaultRouteManagerPrivate *priv) @@ -1242,7 +1256,7 @@ static const VTableIP vtable_ip6 = { .get_entries = _v6_get_entries, }; -/***********************************************************************************/ +/*****************************************************************************/ static gboolean _resync_idle_now (NMDefaultRouteManager *self) @@ -1350,12 +1364,14 @@ _platform_ipx_route_changed_cb (const VTableIP *vtable, static void _platform_changed_cb (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, gpointer platform_object, - NMPlatformSignalChangeType change_type, + int change_type_i, NMDefaultRouteManager *self) { + const NMPObjectType obj_type = obj_type_i; + switch (obj_type) { case NMP_OBJECT_TYPE_IP4_ADDRESS: _platform_ipx_route_changed_cb (&vtable_ip4, self, NULL); @@ -1374,7 +1390,7 @@ _platform_changed_cb (NMPlatform *platform, } } -/***********************************************************************************/ +/*****************************************************************************/ static void set_property (GObject *object, guint prop_id, @@ -1397,6 +1413,8 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + static void nm_default_route_manager_init (NMDefaultRouteManager *self) { @@ -1464,9 +1482,6 @@ nm_default_route_manager_class_init (NMDefaultRouteManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDefaultRouteManagerPrivate)); - - /* virtual methods */ object_class->constructed = constructed; object_class->dispose = dispose; object_class->set_property = set_property; @@ -1477,7 +1492,6 @@ nm_default_route_manager_class_init (NMDefaultRouteManagerClass *klass) G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } - diff --git a/src/nm-default-route-manager.h b/src/nm-default-route-manager.h index 30f130a4..bd5e8732 100644 --- a/src/nm-default-route-manager.h +++ b/src/nm-default-route-manager.h @@ -32,13 +32,7 @@ #define NM_DEFAULT_ROUTE_MANAGER_PLATFORM "platform" -struct _NMDefaultRouteManager { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMDefaultRouteManagerClass; +typedef struct _NMDefaultRouteManagerClass NMDefaultRouteManagerClass; GType nm_default_route_manager_get_type (void); @@ -68,4 +62,3 @@ NMIP6Config *nm_default_route_manager_ip6_get_best_config (NMDefaultRouteManager NMVpnConnection **out_vpn); #endif /* NM_DEFAULT_ROUTE_MANAGER_H */ - diff --git a/src/nm-dhcp4-config.c b/src/nm-dhcp4-config.c index 26c6ab0b..10f58bc6 100644 --- a/src/nm-dhcp4-config.c +++ b/src/nm-dhcp4-config.c @@ -20,36 +20,40 @@ #include "nm-default.h" +#include "nm-dhcp4-config.h" + #include #include "nm-dbus-interface.h" -#include "nm-dhcp4-config.h" #include "nm-utils.h" +#include "nm-exported-object.h" -#include "nmdbus-dhcp4-config.h" +#include "introspection/org.freedesktop.NetworkManager.DHCP4Config.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)) +NM_GOBJECT_PROPERTIES_DEFINE (NMDhcp4Config, + PROP_OPTIONS, +); typedef struct { GVariant *options; } NMDhcp4ConfigPrivate; +struct _NMDhcp4Config { + NMExportedObject parent; + NMDhcp4ConfigPrivate _priv; +}; -enum { - PROP_0, - PROP_OPTIONS, - - LAST_PROP +struct _NMDhcp4ConfigClass { + NMExportedObjectClass parent; }; +G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_EXPORTED_OBJECT) -NMDhcp4Config * -nm_dhcp4_config_new (void) -{ - return NM_DHCP4_CONFIG (g_object_new (NM_TYPE_DHCP4_CONFIG, NULL)); -} +#define NM_DHCP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp4Config, NM_IS_DHCP4_CONFIG) + +/*****************************************************************************/ void nm_dhcp4_config_set_options (NMDhcp4Config *self, @@ -72,7 +76,7 @@ nm_dhcp4_config_set_options (NMDhcp4Config *self, priv->options = g_variant_builder_end (&builder); g_variant_ref_sink (priv->options); - g_object_notify (G_OBJECT (self), NM_DHCP4_CONFIG_OPTIONS); + _notify (self, PROP_OPTIONS); } const char * @@ -98,6 +102,26 @@ nm_dhcp4_config_get_options (NMDhcp4Config *self) return g_variant_ref (NM_DHCP4_CONFIG_GET_PRIVATE (self)->options); } +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE ((NMDhcp4Config *) object); + + switch (prop_id) { + case PROP_OPTIONS: + g_value_set_variant (value, priv->options); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + static void nm_dhcp4_config_init (NMDhcp4Config *self) { @@ -107,55 +131,42 @@ nm_dhcp4_config_init (NMDhcp4Config *self) g_variant_ref_sink (priv->options); } +NMDhcp4Config * +nm_dhcp4_config_new (void) +{ + return NM_DHCP4_CONFIG (g_object_new (NM_TYPE_DHCP4_CONFIG, NULL)); +} + static void finalize (GObject *object) { - NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); + NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE ((NMDhcp4Config *) object); g_variant_unref (priv->options); G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->finalize (object); } -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_OPTIONS: - g_value_set_variant (value, priv->options); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); - g_type_class_add_private (config_class, sizeof (NMDhcp4ConfigPrivate)); + object_class->get_property = get_property; + object_class->finalize = finalize; - exported_object_class->export_path = NM_DBUS_PATH "/DHCP4Config/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP4Config"); exported_object_class->export_on_construction = TRUE; - /* virtual methods */ - object_class->get_property = get_property; - object_class->finalize = finalize; + obj_properties[PROP_OPTIONS] = + g_param_spec_variant (NM_DHCP4_CONFIG_OPTIONS, "", "", + G_VARIANT_TYPE ("a{sv}"), + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); - /* properties */ - g_object_class_install_property - (object_class, PROP_OPTIONS, - g_param_spec_variant (NM_DHCP4_CONFIG_OPTIONS, "", "", - G_VARIANT_TYPE ("a{sv}"), - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class), NMDBUS_TYPE_DHCP4_CONFIG_SKELETON, diff --git a/src/nm-dhcp4-config.h b/src/nm-dhcp4-config.h index 080e28de..7fdf0653 100644 --- a/src/nm-dhcp4-config.h +++ b/src/nm-dhcp4-config.h @@ -21,8 +21,6 @@ #ifndef __NETWORKMANAGER_DHCP4_CONFIG_H__ #define __NETWORKMANAGER_DHCP4_CONFIG_H__ -#include "nm-exported-object.h" - #define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ()) #define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4Config)) #define NM_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass)) @@ -30,17 +28,10 @@ #define NM_IS_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP4_CONFIG)) #define NM_DHCP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass)) -struct _NMDhcp4Config { - NMExportedObject parent; -}; - -typedef struct { - NMExportedObjectClass parent; - -} NMDhcp4ConfigClass; - #define NM_DHCP4_CONFIG_OPTIONS "options" +typedef struct _NMDhcp4ConfigClass NMDhcp4ConfigClass; + GType nm_dhcp4_config_get_type (void); NMDhcp4Config *nm_dhcp4_config_new (void); diff --git a/src/nm-dhcp6-config.c b/src/nm-dhcp6-config.c index 4311ee98..d51d77ef 100644 --- a/src/nm-dhcp6-config.c +++ b/src/nm-dhcp6-config.c @@ -20,36 +20,40 @@ #include "nm-default.h" +#include "nm-dhcp6-config.h" + #include #include "nm-dbus-interface.h" -#include "nm-dhcp6-config.h" #include "nm-utils.h" +#include "nm-exported-object.h" -#include "nmdbus-dhcp6-config.h" +#include "introspection/org.freedesktop.NetworkManager.DHCP6Config.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)) +NM_GOBJECT_PROPERTIES_DEFINE (NMDhcp6Config, + PROP_OPTIONS, +); typedef struct { GVariant *options; } NMDhcp6ConfigPrivate; +struct _NMDhcp6Config { + NMExportedObject parent; + NMDhcp6ConfigPrivate _priv; +}; -enum { - PROP_0, - PROP_OPTIONS, - - LAST_PROP +struct _NMDhcp6ConfigClass { + NMExportedObjectClass parent; }; +G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_EXPORTED_OBJECT) -NMDhcp6Config * -nm_dhcp6_config_new (void) -{ - return NM_DHCP6_CONFIG (g_object_new (NM_TYPE_DHCP6_CONFIG, NULL)); -} +#define NM_DHCP6_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp6Config, NM_IS_DHCP6_CONFIG) + +/*****************************************************************************/ void nm_dhcp6_config_set_options (NMDhcp6Config *self, @@ -72,7 +76,7 @@ nm_dhcp6_config_set_options (NMDhcp6Config *self, priv->options = g_variant_builder_end (&builder); g_variant_ref_sink (priv->options); - g_object_notify (G_OBJECT (self), NM_DHCP6_CONFIG_OPTIONS); + _notify (self, PROP_OPTIONS); } const char * @@ -98,6 +102,24 @@ nm_dhcp6_config_get_options (NMDhcp6Config *self) return g_variant_ref (NM_DHCP6_CONFIG_GET_PRIVATE (self)->options); } +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE ((NMDhcp6Config *) object); + + switch (prop_id) { + case PROP_OPTIONS: + g_value_set_variant (value, priv->options); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void nm_dhcp6_config_init (NMDhcp6Config *self) { @@ -107,55 +129,42 @@ nm_dhcp6_config_init (NMDhcp6Config *self) g_variant_ref_sink (priv->options); } +NMDhcp6Config * +nm_dhcp6_config_new (void) +{ + return NM_DHCP6_CONFIG (g_object_new (NM_TYPE_DHCP6_CONFIG, NULL)); +} + static void finalize (GObject *object) { - NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); + NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE ((NMDhcp6Config *) object); g_variant_unref (priv->options); G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->finalize (object); } -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_OPTIONS: - g_value_set_variant (value, priv->options); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); - g_type_class_add_private (config_class, sizeof (NMDhcp6ConfigPrivate)); + object_class->get_property = get_property; + object_class->finalize = finalize; - exported_object_class->export_path = NM_DBUS_PATH "/DHCP6Config/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP6Config"); exported_object_class->export_on_construction = TRUE; - /* virtual methods */ - object_class->get_property = get_property; - object_class->finalize = finalize; + obj_properties[PROP_OPTIONS] = + g_param_spec_variant (NM_DHCP6_CONFIG_OPTIONS, "", "", + G_VARIANT_TYPE ("a{sv}"), + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); - /* properties */ - g_object_class_install_property - (object_class, PROP_OPTIONS, - g_param_spec_variant (NM_DHCP6_CONFIG_OPTIONS, "", "", - G_VARIANT_TYPE ("a{sv}"), - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class), NMDBUS_TYPE_DHCP6_CONFIG_SKELETON, diff --git a/src/nm-dhcp6-config.h b/src/nm-dhcp6-config.h index c018d97f..6241845a 100644 --- a/src/nm-dhcp6-config.h +++ b/src/nm-dhcp6-config.h @@ -21,8 +21,6 @@ #ifndef __NETWORKMANAGER_DHCP6_CONFIG_H__ #define __NETWORKMANAGER_DHCP6_CONFIG_H__ -#include "nm-exported-object.h" - #define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ()) #define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6Config)) #define NM_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass)) @@ -30,17 +28,10 @@ #define NM_IS_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP6_CONFIG)) #define NM_DHCP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass)) -struct _NMDhcp6Config { - NMExportedObject parent; -}; - -typedef struct { - NMExportedObjectClass parent; - -} NMDhcp6ConfigClass; - #define NM_DHCP6_CONFIG_OPTIONS "options" +typedef struct _NMDhcp6ConfigClass NMDhcp6ConfigClass; + GType nm_dhcp6_config_get_type (void); NMDhcp6Config *nm_dhcp6_config_new (void); diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c index df9be2e7..6c0c4bb4 100644 --- a/src/nm-dispatcher.c +++ b/src/nm-dispatcher.c @@ -29,27 +29,21 @@ #include "NetworkManagerUtils.h" #include "nm-utils.h" #include "nm-connectivity.h" -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" +#include "nm-proxy-config.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" #include "nm-manager.h" -#include "nm-settings-connection.h" -#include "nm-platform.h" +#include "settings/nm-settings-connection.h" +#include "platform/nm-platform.h" #include "nm-core-internal.h" #define CALL_TIMEOUT (1000 * 60 * 10) /* 10 minutes for all scripts */ -#define _NMLOG_DOMAIN LOGD_DISPATCH -#define _NMLOG_PREFIX_NAME "dispatcher" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END +#define _NMLOG_DOMAIN LOGD_DISPATCH +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "dispatcher", __VA_ARGS__) static GDBusProxy *dispatcher_proxy; static GHashTable *requests = NULL; @@ -90,6 +84,29 @@ _get_monitor_by_action (DispatcherAction action) } } +static void +dump_proxy_to_props (NMProxyConfig *proxy, GVariantBuilder *builder) +{ + const char *pac_url = NULL, *pac_script = NULL; + + if (nm_proxy_config_get_method (proxy) == NM_PROXY_CONFIG_METHOD_NONE) + return; + + pac_url = nm_proxy_config_get_pac_url (proxy); + if (pac_url) { + g_variant_builder_add (builder, "{sv}", + "pac-url", + g_variant_new_string (pac_url)); + } + + pac_script = nm_proxy_config_get_pac_script (proxy); + if (pac_script) { + g_variant_builder_add (builder, "{sv}", + "pac-script", + g_variant_new_string (pac_script)); + } +} + static void dump_ip4_to_props (NMIP4Config *ip4, GVariantBuilder *builder) { @@ -231,11 +248,13 @@ dump_ip6_to_props (NMIP6Config *ip6, GVariantBuilder *builder) static void fill_device_props (NMDevice *device, GVariantBuilder *dev_builder, + GVariantBuilder *proxy_builder, GVariantBuilder *ip4_builder, GVariantBuilder *ip6_builder, GVariant **dhcp4_props, GVariant **dhcp6_props) { + NMProxyConfig *proxy_config; NMIP4Config *ip4_config; NMIP6Config *ip6_config; NMDhcp4Config *dhcp4_config; @@ -254,6 +273,10 @@ fill_device_props (NMDevice *device, g_variant_builder_add (dev_builder, "{sv}", NMD_DEVICE_PROPS_PATH, g_variant_new_object_path (nm_exported_object_get_path (NM_EXPORTED_OBJECT (device)))); + proxy_config = nm_device_get_proxy_config (device); + if (proxy_config) + dump_proxy_to_props (proxy_config, proxy_builder); + ip4_config = nm_device_get_ip4_config (device); if (ip4_config) dump_ip4_to_props (ip4_config, ip4_builder); @@ -272,11 +295,15 @@ fill_device_props (NMDevice *device, } static void -fill_vpn_props (NMIP4Config *ip4_config, +fill_vpn_props (NMProxyConfig *proxy_config, + NMIP4Config *ip4_config, NMIP6Config *ip6_config, + GVariantBuilder *proxy_builder, GVariantBuilder *ip4_builder, GVariantBuilder *ip6_builder) { + if (proxy_config) + dump_proxy_to_props (proxy_config, proxy_builder); if (ip4_config) dump_ip4_to_props (ip4_config, ip4_builder); if (ip6_config) @@ -454,6 +481,7 @@ _dispatcher_call (DispatcherAction action, NMDevice *device, NMConnectivityState connectivity_state, const char *vpn_iface, + NMProxyConfig *vpn_proxy_config, NMIP4Config *vpn_ip4_config, NMIP6Config *vpn_ip6_config, DispatcherFunc callback, @@ -463,10 +491,12 @@ _dispatcher_call (DispatcherAction action, GVariant *connection_dict; GVariantBuilder connection_props; GVariantBuilder device_props; + GVariantBuilder device_proxy_props; GVariantBuilder device_ip4_props; GVariantBuilder device_ip6_props; GVariant *device_dhcp4_props = NULL; GVariant *device_dhcp6_props = NULL; + GVariantBuilder vpn_proxy_props; GVariantBuilder vpn_ip4_props; GVariantBuilder vpn_ip6_props; DispatchInfo *info = NULL; @@ -551,8 +581,10 @@ _dispatcher_call (DispatcherAction action, } g_variant_builder_init (&device_props, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&device_proxy_props, G_VARIANT_TYPE_VARDICT); g_variant_builder_init (&device_ip4_props, G_VARIANT_TYPE_VARDICT); g_variant_builder_init (&device_ip6_props, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&vpn_proxy_props, G_VARIANT_TYPE_VARDICT); g_variant_builder_init (&vpn_ip4_props, G_VARIANT_TYPE_VARDICT); g_variant_builder_init (&vpn_ip6_props, G_VARIANT_TYPE_VARDICT); @@ -561,13 +593,16 @@ _dispatcher_call (DispatcherAction action, && action != DISPATCHER_ACTION_CONNECTIVITY_CHANGE) { fill_device_props (device, &device_props, + &device_proxy_props, &device_ip4_props, &device_ip6_props, &device_dhcp4_props, &device_dhcp6_props); if (vpn_ip4_config || vpn_ip6_config) { - fill_vpn_props (vpn_ip4_config, + fill_vpn_props (vpn_proxy_config, + vpn_ip4_config, vpn_ip6_config, + &vpn_proxy_props, &vpn_ip4_props, &vpn_ip6_props); } @@ -584,17 +619,19 @@ _dispatcher_call (DispatcherAction action, GVariantIter *results; ret = _nm_dbus_proxy_call_sync (dispatcher_proxy, "Action", - g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}b)", + g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}a{sv}b)", action_to_string (action), connection_dict, &connection_props, &device_props, + &device_proxy_props, &device_ip4_props, &device_ip6_props, device_dhcp4_props, device_dhcp6_props, nm_connectivity_state_to_string (connectivity_state), vpn_iface ? vpn_iface : "", + &vpn_proxy_props, &vpn_ip4_props, &vpn_ip6_props, nm_logging_enabled (LOGL_DEBUG, LOGD_DISPATCH)), @@ -620,17 +657,19 @@ _dispatcher_call (DispatcherAction action, info->callback = callback; info->user_data = user_data; g_dbus_proxy_call (dispatcher_proxy, "Action", - g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}b)", + g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}a{sv}b)", action_to_string (action), connection_dict, &connection_props, &device_props, + &device_proxy_props, &device_ip4_props, &device_ip6_props, device_dhcp4_props, device_dhcp6_props, nm_connectivity_state_to_string (connectivity_state), vpn_iface ? vpn_iface : "", + &vpn_proxy_props, &vpn_ip4_props, &vpn_ip6_props, nm_logging_enabled (LOGL_DEBUG, LOGD_DISPATCH)), @@ -680,7 +719,7 @@ nm_dispatcher_call (DispatcherAction action, guint *out_call_id) { return _dispatcher_call (action, FALSE, settings_connection, applied_connection, device, - NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, + NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, NULL, callback, user_data, out_call_id); } @@ -703,7 +742,7 @@ nm_dispatcher_call_sync (DispatcherAction action, NMDevice *device) { return _dispatcher_call (action, TRUE, settings_connection, applied_connection, device, - NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, NULL, NULL, NULL); + NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } /** @@ -713,6 +752,7 @@ nm_dispatcher_call_sync (DispatcherAction action, * @applied_connection: the currently applied connection * @parent_device: the parent #NMDevice of the VPN connection * @vpn_iface: the IP interface of the VPN tunnel, if any + * @vpn_proxy_config: the #NMProxyConfig of the VPN connection * @vpn_ip4_config: the #NMIP4Config of the VPN connection * @vpn_ip6_config: the #NMIP6Config of the VPN connection * @callback: a caller-supplied callback to execute when done @@ -731,6 +771,7 @@ nm_dispatcher_call_vpn (DispatcherAction action, NMConnection *applied_connection, NMDevice *parent_device, const char *vpn_iface, + NMProxyConfig *vpn_proxy_config, NMIP4Config *vpn_ip4_config, NMIP6Config *vpn_ip6_config, DispatcherFunc callback, @@ -738,8 +779,8 @@ nm_dispatcher_call_vpn (DispatcherAction action, guint *out_call_id) { return _dispatcher_call (action, FALSE, settings_connection, applied_connection, - parent_device, NM_CONNECTIVITY_UNKNOWN, vpn_iface, vpn_ip4_config, - vpn_ip6_config, callback, user_data, out_call_id); + parent_device, NM_CONNECTIVITY_UNKNOWN, vpn_iface, vpn_proxy_config, + vpn_ip4_config, vpn_ip6_config, callback, user_data, out_call_id); } /** @@ -749,6 +790,7 @@ nm_dispatcher_call_vpn (DispatcherAction action, * @applied_connection: the currently applied connection * @parent_device: the parent #NMDevice of the VPN connection * @vpn_iface: the IP interface of the VPN tunnel, if any + * @vpn_proxy_config: the #NMProxyConfig of the VPN connection * @vpn_ip4_config: the #NMIP4Config of the VPN connection * @vpn_ip6_config: the #NMIP6Config of the VPN connection * @@ -763,11 +805,12 @@ nm_dispatcher_call_vpn_sync (DispatcherAction action, NMConnection *applied_connection, NMDevice *parent_device, const char *vpn_iface, + NMProxyConfig *vpn_proxy_config, NMIP4Config *vpn_ip4_config, NMIP6Config *vpn_ip6_config) { return _dispatcher_call (action, TRUE, settings_connection, applied_connection, - parent_device, NM_CONNECTIVITY_UNKNOWN, vpn_iface, + parent_device, NM_CONNECTIVITY_UNKNOWN, vpn_iface, vpn_proxy_config, vpn_ip4_config, vpn_ip6_config, NULL, NULL, NULL); } @@ -785,7 +828,7 @@ nm_dispatcher_call_connectivity (DispatcherAction action, NMConnectivityState connectivity_state) { return _dispatcher_call (action, FALSE, NULL, NULL, NULL, connectivity_state, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL, NULL); } void diff --git a/src/nm-dispatcher.h b/src/nm-dispatcher.h index 62818c45..7ea1a6b8 100644 --- a/src/nm-dispatcher.h +++ b/src/nm-dispatcher.h @@ -61,6 +61,7 @@ gboolean nm_dispatcher_call_vpn (DispatcherAction action, NMConnection *applied_connection, NMDevice *parent_device, const char *vpn_iface, + NMProxyConfig *vpn_proxy_config, NMIP4Config *vpn_ip4_config, NMIP6Config *vpn_ip6_config, DispatcherFunc callback, @@ -72,6 +73,7 @@ gboolean nm_dispatcher_call_vpn_sync (DispatcherAction action, NMConnection *applied_connection, NMDevice *parent_device, const char *vpn_iface, + NMProxyConfig *vpn_proxy_config, NMIP4Config *vpn_ip4_config, NMIP6Config *vpn_ip6_config); diff --git a/src/nm-enum-types.c b/src/nm-enum-types.c deleted file mode 100644 index 50a0cfd5..00000000 --- a/src/nm-enum-types.c +++ /dev/null @@ -1,729 +0,0 @@ - - - -/* Generated by glib-mkenums. Do not edit */ - -#include "config.h" - -#include "nm-enum-types.h" -#include "nm-default.h" - -#include "nm-dhcp-dhclient-utils.h" -#include "nm-checkpoint-manager.h" -#include "nm-checkpoint.h" -#include "nm-device.h" -#include "nm-lldp-listener.h" -#include "nm-arping-manager.h" -#include "nm-device-ethernet-utils.h" -#include "nm-device-factory.h" -#include "nm-device-generic.h" -#include "nm-dhcp-client.h" -#include "nm-dhcp-helper-api.h" -#include "nm-dhcp-utils.h" -#include "nm-dhcp-listener.h" -#include "nm-dhcp-manager.h" -#include "nm-dns-dnsmasq.h" -#include "nm-dns-unbound.h" -#include "nm-dns-manager.h" -#include "nm-dns-plugin.h" -#include "nm-dnsmasq-manager.h" -#include "nm-dnsmasq-utils.h" -#include "nmp-netns.h" -#include "nmp-object.h" -#include "nm-platform-utils.h" -#include "nm-platform.h" -#include "nm-linux-platform.h" -#include "wifi-utils-nl80211.h" -#include "wifi-utils.h" -#include "nm-lndp-rdisc.h" -#include "nm-rdisc.h" -#include "nm-ppp-manager.h" -#include "nm-ppp-status.h" -#include "nm-agent-manager.h" -#include "nm-inotify-helper.h" -#include "nm-secret-agent.h" -#include "nm-settings-connection.h" -#include "nm-settings-plugin.h" -#include "nm-settings.h" -#include "nm-keyfile-connection.h" -#include "plugin.h" -#include "reader.h" -#include "utils.h" -#include "writer.h" -#include "nm-supplicant-config.h" -#include "nm-supplicant-interface.h" -#include "nm-supplicant-manager.h" -#include "nm-supplicant-settings-verify.h" -#include "nm-supplicant-types.h" -#include "nm-vpn-connection.h" -#include "nm-vpn-manager.h" -#include "nm-activation-request.h" -#include "nm-active-connection.h" -#include "nm-audit-manager.h" -#include "nm-bus-manager.h" -#include "nm-config.h" -#include "nm-config-data.h" -#include "nm-connectivity.h" -#include "nm-dcb.h" -#include "nm-route-manager.h" -#include "nm-default-route-manager.h" -#include "nm-dhcp4-config.h" -#include "nm-dhcp6-config.h" -#include "nm-dispatcher.h" -#include "nm-exported-object.h" -#include "nm-firewall-manager.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" -#include "nm-auth-manager.h" -#include "nm-auth-subject.h" -#include "nm-auth-utils.h" -#include "nm-manager.h" -#include "nm-multi-index.h" -#include "nm-policy.h" -#include "nm-rfkill-manager.h" -#include "nm-session-monitor.h" -#include "nm-sleep-monitor.h" -#include "nm-types.h" -#include "NetworkManagerUtils.h" -#include "wifi-utils-wext.h" - -GType -nm_unman_flag_op_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_UNMAN_FLAG_OP_SET_MANAGED, "NM_UNMAN_FLAG_OP_SET_MANAGED", "set-managed" }, - { NM_UNMAN_FLAG_OP_SET_UNMANAGED, "NM_UNMAN_FLAG_OP_SET_UNMANAGED", "set-unmanaged" }, - { NM_UNMAN_FLAG_OP_FORGET, "NM_UNMAN_FLAG_OP_FORGET", "forget" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMUnmanFlagOp"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_dhcp_state_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_DHCP_STATE_UNKNOWN, "NM_DHCP_STATE_UNKNOWN", "nm-dhcp-state-unknown" }, - { NM_DHCP_STATE_BOUND, "NM_DHCP_STATE_BOUND", "nm-dhcp-state-bound" }, - { NM_DHCP_STATE_TIMEOUT, "NM_DHCP_STATE_TIMEOUT", "nm-dhcp-state-timeout" }, - { NM_DHCP_STATE_DONE, "NM_DHCP_STATE_DONE", "nm-dhcp-state-done" }, - { NM_DHCP_STATE_EXPIRE, "NM_DHCP_STATE_EXPIRE", "nm-dhcp-state-expire" }, - { NM_DHCP_STATE_FAIL, "NM_DHCP_STATE_FAIL", "nm-dhcp-state-fail" }, - { __NM_DHCP_STATE_MAX, "__NM_DHCP_STATE_MAX", "--nm-dhcp-state-max" }, - { NM_DHCP_STATE_MAX, "NM_DHCP_STATE_MAX", "nm-dhcp-state-max" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMDhcpState"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_dns_ip_config_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_DNS_IP_CONFIG_TYPE_DEFAULT, "NM_DNS_IP_CONFIG_TYPE_DEFAULT", "default" }, - { NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE, "NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE", "best-device" }, - { NM_DNS_IP_CONFIG_TYPE_VPN, "NM_DNS_IP_CONFIG_TYPE_VPN", "vpn" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMDnsIPConfigType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_dns_manager_resolv_conf_manager_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN, "NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN", "unknown" }, - { NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED, "NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED", "unmanaged" }, - { NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE, "NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE", "immutable" }, - { NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK, "NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK", "symlink" }, - { NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE, "NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE", "file" }, - { NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF, "NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF", "resolvconf" }, - { NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG, "NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG", "netconfig" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMDnsManagerResolvConfManager"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_dns_masq_status_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_DNSMASQ_STATUS_UNKNOWN, "NM_DNSMASQ_STATUS_UNKNOWN", "unknown" }, - { NM_DNSMASQ_STATUS_DEAD, "NM_DNSMASQ_STATUS_DEAD", "dead" }, - { NM_DNSMASQ_STATUS_RUNNING, "NM_DNSMASQ_STATUS_RUNNING", "running" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMDnsMasqStatus"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_platform_signal_change_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_PLATFORM_SIGNAL_NONE, "NM_PLATFORM_SIGNAL_NONE", "none" }, - { NM_PLATFORM_SIGNAL_ADDED, "NM_PLATFORM_SIGNAL_ADDED", "added" }, - { NM_PLATFORM_SIGNAL_CHANGED, "NM_PLATFORM_SIGNAL_CHANGED", "changed" }, - { NM_PLATFORM_SIGNAL_REMOVED, "NM_PLATFORM_SIGNAL_REMOVED", "removed" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMPlatformSignalChangeType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_rdisc_dhcp_level_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_RDISC_DHCP_LEVEL_UNKNOWN, "NM_RDISC_DHCP_LEVEL_UNKNOWN", "unknown" }, - { NM_RDISC_DHCP_LEVEL_NONE, "NM_RDISC_DHCP_LEVEL_NONE", "none" }, - { NM_RDISC_DHCP_LEVEL_OTHERCONF, "NM_RDISC_DHCP_LEVEL_OTHERCONF", "otherconf" }, - { NM_RDISC_DHCP_LEVEL_MANAGED, "NM_RDISC_DHCP_LEVEL_MANAGED", "managed" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMRDiscDHCPLevel"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_rdisc_preference_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_RDISC_PREFERENCE_INVALID, "NM_RDISC_PREFERENCE_INVALID", "invalid" }, - { NM_RDISC_PREFERENCE_LOW, "NM_RDISC_PREFERENCE_LOW", "low" }, - { NM_RDISC_PREFERENCE_MEDIUM, "NM_RDISC_PREFERENCE_MEDIUM", "medium" }, - { NM_RDISC_PREFERENCE_HIGH, "NM_RDISC_PREFERENCE_HIGH", "high" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMRDiscPreference"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_rdisc_config_map_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GFlagsValue values[] = { - { NM_RDISC_CONFIG_DHCP_LEVEL, "NM_RDISC_CONFIG_DHCP_LEVEL", "dhcp-level" }, - { NM_RDISC_CONFIG_GATEWAYS, "NM_RDISC_CONFIG_GATEWAYS", "gateways" }, - { NM_RDISC_CONFIG_ADDRESSES, "NM_RDISC_CONFIG_ADDRESSES", "addresses" }, - { NM_RDISC_CONFIG_ROUTES, "NM_RDISC_CONFIG_ROUTES", "routes" }, - { NM_RDISC_CONFIG_DNS_SERVERS, "NM_RDISC_CONFIG_DNS_SERVERS", "dns-servers" }, - { NM_RDISC_CONFIG_DNS_DOMAINS, "NM_RDISC_CONFIG_DNS_DOMAINS", "dns-domains" }, - { NM_RDISC_CONFIG_HOP_LIMIT, "NM_RDISC_CONFIG_HOP_LIMIT", "hop-limit" }, - { NM_RDISC_CONFIG_MTU, "NM_RDISC_CONFIG_MTU", "mtu" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_flags_register_static (g_intern_static_string ("NMRDiscConfigMap"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_ppp_status_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_PPP_STATUS_UNKNOWN, "NM_PPP_STATUS_UNKNOWN", "unknown" }, - { NM_PPP_STATUS_DEAD, "NM_PPP_STATUS_DEAD", "dead" }, - { NM_PPP_STATUS_INITIALIZE, "NM_PPP_STATUS_INITIALIZE", "initialize" }, - { NM_PPP_STATUS_SERIALCONN, "NM_PPP_STATUS_SERIALCONN", "serialconn" }, - { NM_PPP_STATUS_DORMANT, "NM_PPP_STATUS_DORMANT", "dormant" }, - { NM_PPP_STATUS_ESTABLISH, "NM_PPP_STATUS_ESTABLISH", "establish" }, - { NM_PPP_STATUS_AUTHENTICATE, "NM_PPP_STATUS_AUTHENTICATE", "authenticate" }, - { NM_PPP_STATUS_CALLBACK, "NM_PPP_STATUS_CALLBACK", "callback" }, - { NM_PPP_STATUS_NETWORK, "NM_PPP_STATUS_NETWORK", "network" }, - { NM_PPP_STATUS_RUNNING, "NM_PPP_STATUS_RUNNING", "running" }, - { NM_PPP_STATUS_TERMINATE, "NM_PPP_STATUS_TERMINATE", "terminate" }, - { NM_PPP_STATUS_DISCONNECT, "NM_PPP_STATUS_DISCONNECT", "disconnect" }, - { NM_PPP_STATUS_HOLDOFF, "NM_PPP_STATUS_HOLDOFF", "holdoff" }, - { NM_PPP_STATUS_MASTER, "NM_PPP_STATUS_MASTER", "master" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMPPPStatus"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_settings_connection_flags_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GFlagsValue values[] = { - { NM_SETTINGS_CONNECTION_FLAGS_NONE, "NM_SETTINGS_CONNECTION_FLAGS_NONE", "nm-settings-connection-flags-none" }, - { NM_SETTINGS_CONNECTION_FLAGS_UNSAVED, "NM_SETTINGS_CONNECTION_FLAGS_UNSAVED", "nm-settings-connection-flags-unsaved" }, - { NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, "NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED", "nm-settings-connection-flags-nm-generated" }, - { NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED, "NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED", "nm-settings-connection-flags-nm-generated-assumed" }, - { __NM_SETTINGS_CONNECTION_FLAGS_LAST, "__NM_SETTINGS_CONNECTION_FLAGS_LAST", "--nm-settings-connection-flags-last" }, - { NM_SETTINGS_CONNECTION_FLAGS_ALL, "NM_SETTINGS_CONNECTION_FLAGS_ALL", "nm-settings-connection-flags-all" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_flags_register_static (g_intern_static_string ("NMSettingsConnectionFlags"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_settings_plugin_capabilities_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_SETTINGS_PLUGIN_CAP_NONE, "NM_SETTINGS_PLUGIN_CAP_NONE", "none" }, - { NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS, "NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS", "modify-connections" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMSettingsPluginCapabilities"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_settings_plugin_prop_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_SETTINGS_PLUGIN_PROP_FIRST, "NM_SETTINGS_PLUGIN_PROP_FIRST", "first" }, - { NM_SETTINGS_PLUGIN_PROP_NAME, "NM_SETTINGS_PLUGIN_PROP_NAME", "name" }, - { NM_SETTINGS_PLUGIN_PROP_INFO, "NM_SETTINGS_PLUGIN_PROP_INFO", "info" }, - { NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, "NM_SETTINGS_PLUGIN_PROP_CAPABILITIES", "capabilities" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMSettingsPluginProp"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_opt_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { TYPE_INVALID, "TYPE_INVALID", "invalid" }, - { TYPE_INT, "TYPE_INT", "int" }, - { TYPE_BYTES, "TYPE_BYTES", "bytes" }, - { TYPE_UTF8, "TYPE_UTF8", "utf8" }, - { TYPE_KEYWORD, "TYPE_KEYWORD", "keyword" }, - { TYPE_STRING, "TYPE_STRING", "string" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("OptType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_supplicant_feature_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_SUPPLICANT_FEATURE_UNKNOWN, "NM_SUPPLICANT_FEATURE_UNKNOWN", "unknown" }, - { NM_SUPPLICANT_FEATURE_NO, "NM_SUPPLICANT_FEATURE_NO", "no" }, - { NM_SUPPLICANT_FEATURE_YES, "NM_SUPPLICANT_FEATURE_YES", "yes" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMSupplicantFeature"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_supplicant_error_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_SUPPLICANT_ERROR_UNKNOWN, "NM_SUPPLICANT_ERROR_UNKNOWN", "Unknown" }, - { NM_SUPPLICANT_ERROR_CONFIG, "NM_SUPPLICANT_ERROR_CONFIG", "Config" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMSupplicantError"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_config_run_state_property_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_CONFIG_STATE_PROPERTY_NONE, "NM_CONFIG_STATE_PROPERTY_NONE", "none" }, - { NM_CONFIG_STATE_PROPERTY_NETWORKING_ENABLED, "NM_CONFIG_STATE_PROPERTY_NETWORKING_ENABLED", "networking-enabled" }, - { NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED, "NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED", "wifi-enabled" }, - { NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED, "NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED", "wwan-enabled" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMConfigRunStatePropertyType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_config_get_value_flags_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GFlagsValue values[] = { - { NM_CONFIG_GET_VALUE_NONE, "NM_CONFIG_GET_VALUE_NONE", "none" }, - { NM_CONFIG_GET_VALUE_RAW, "NM_CONFIG_GET_VALUE_RAW", "raw" }, - { NM_CONFIG_GET_VALUE_STRIP, "NM_CONFIG_GET_VALUE_STRIP", "strip" }, - { NM_CONFIG_GET_VALUE_NO_EMPTY, "NM_CONFIG_GET_VALUE_NO_EMPTY", "no-empty" }, - { NM_CONFIG_GET_VALUE_TYPE_SPEC, "NM_CONFIG_GET_VALUE_TYPE_SPEC", "type-spec" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_flags_register_static (g_intern_static_string ("NMConfigGetValueFlags"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_config_change_flags_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GFlagsValue values[] = { - { NM_CONFIG_CHANGE_NONE, "NM_CONFIG_CHANGE_NONE", "none" }, - { NM_CONFIG_CHANGE_CAUSE_SIGHUP, "NM_CONFIG_CHANGE_CAUSE_SIGHUP", "cause-sighup" }, - { NM_CONFIG_CHANGE_CAUSE_SIGUSR1, "NM_CONFIG_CHANGE_CAUSE_SIGUSR1", "cause-sigusr1" }, - { NM_CONFIG_CHANGE_CAUSE_SIGUSR2, "NM_CONFIG_CHANGE_CAUSE_SIGUSR2", "cause-sigusr2" }, - { NM_CONFIG_CHANGE_CAUSE_NO_AUTO_DEFAULT, "NM_CONFIG_CHANGE_CAUSE_NO_AUTO_DEFAULT", "cause-no-auto-default" }, - { NM_CONFIG_CHANGE_CAUSE_SET_VALUES, "NM_CONFIG_CHANGE_CAUSE_SET_VALUES", "cause-set-values" }, - { NM_CONFIG_CHANGE_CAUSE_CONF, "NM_CONFIG_CHANGE_CAUSE_CONF", "cause-conf" }, - { NM_CONFIG_CHANGE_CAUSE_DNS_RC, "NM_CONFIG_CHANGE_CAUSE_DNS_RC", "cause-dns-rc" }, - { NM_CONFIG_CHANGE_CAUSE_DNS_FULL, "NM_CONFIG_CHANGE_CAUSE_DNS_FULL", "cause-dns-full" }, - { NM_CONFIG_CHANGE_CAUSES, "NM_CONFIG_CHANGE_CAUSES", "causes" }, - { NM_CONFIG_CHANGE_CONFIG_FILES, "NM_CONFIG_CHANGE_CONFIG_FILES", "config-files" }, - { NM_CONFIG_CHANGE_VALUES, "NM_CONFIG_CHANGE_VALUES", "values" }, - { NM_CONFIG_CHANGE_VALUES_USER, "NM_CONFIG_CHANGE_VALUES_USER", "values-user" }, - { NM_CONFIG_CHANGE_VALUES_INTERN, "NM_CONFIG_CHANGE_VALUES_INTERN", "values-intern" }, - { NM_CONFIG_CHANGE_CONNECTIVITY, "NM_CONFIG_CHANGE_CONNECTIVITY", "connectivity" }, - { NM_CONFIG_CHANGE_NO_AUTO_DEFAULT, "NM_CONFIG_CHANGE_NO_AUTO_DEFAULT", "no-auto-default" }, - { NM_CONFIG_CHANGE_DNS_MODE, "NM_CONFIG_CHANGE_DNS_MODE", "dns-mode" }, - { NM_CONFIG_CHANGE_RC_MANAGER, "NM_CONFIG_CHANGE_RC_MANAGER", "rc-manager" }, - { NM_CONFIG_CHANGE_GLOBAL_DNS_CONFIG, "NM_CONFIG_CHANGE_GLOBAL_DNS_CONFIG", "global-dns-config" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_flags_register_static (g_intern_static_string ("NMConfigChangeFlags"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_dispatcher_action_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { DISPATCHER_ACTION_HOSTNAME, "DISPATCHER_ACTION_HOSTNAME", "hostname" }, - { DISPATCHER_ACTION_PRE_UP, "DISPATCHER_ACTION_PRE_UP", "pre-up" }, - { DISPATCHER_ACTION_UP, "DISPATCHER_ACTION_UP", "up" }, - { DISPATCHER_ACTION_PRE_DOWN, "DISPATCHER_ACTION_PRE_DOWN", "pre-down" }, - { DISPATCHER_ACTION_DOWN, "DISPATCHER_ACTION_DOWN", "down" }, - { DISPATCHER_ACTION_VPN_PRE_UP, "DISPATCHER_ACTION_VPN_PRE_UP", "vpn-pre-up" }, - { DISPATCHER_ACTION_VPN_UP, "DISPATCHER_ACTION_VPN_UP", "vpn-up" }, - { DISPATCHER_ACTION_VPN_PRE_DOWN, "DISPATCHER_ACTION_VPN_PRE_DOWN", "vpn-pre-down" }, - { DISPATCHER_ACTION_VPN_DOWN, "DISPATCHER_ACTION_VPN_DOWN", "vpn-down" }, - { DISPATCHER_ACTION_DHCP4_CHANGE, "DISPATCHER_ACTION_DHCP4_CHANGE", "dhcp4-change" }, - { DISPATCHER_ACTION_DHCP6_CHANGE, "DISPATCHER_ACTION_DHCP6_CHANGE", "dhcp6-change" }, - { DISPATCHER_ACTION_CONNECTIVITY_CHANGE, "DISPATCHER_ACTION_CONNECTIVITY_CHANGE", "connectivity-change" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("DispatcherAction"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_auth_subject_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_AUTH_SUBJECT_TYPE_INVALID, "NM_AUTH_SUBJECT_TYPE_INVALID", "invalid" }, - { NM_AUTH_SUBJECT_TYPE_INTERNAL, "NM_AUTH_SUBJECT_TYPE_INTERNAL", "internal" }, - { NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS, "NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS", "unix-process" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMAuthSubjectType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_auth_call_result_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_AUTH_CALL_RESULT_UNKNOWN, "NM_AUTH_CALL_RESULT_UNKNOWN", "unknown" }, - { NM_AUTH_CALL_RESULT_YES, "NM_AUTH_CALL_RESULT_YES", "yes" }, - { NM_AUTH_CALL_RESULT_AUTH, "NM_AUTH_CALL_RESULT_AUTH", "auth" }, - { NM_AUTH_CALL_RESULT_NO, "NM_AUTH_CALL_RESULT_NO", "no" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMAuthCallResult"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_ip_config_source_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_IP_CONFIG_SOURCE_UNKNOWN, "NM_IP_CONFIG_SOURCE_UNKNOWN", "nm-ip-config-source-unknown" }, - { NM_IP_CONFIG_SOURCE_RTPROT_UNSPEC, "NM_IP_CONFIG_SOURCE_RTPROT_UNSPEC", "nm-ip-config-source-rtprot-unspec" }, - { NM_IP_CONFIG_SOURCE_RTPROT_REDIRECT, "NM_IP_CONFIG_SOURCE_RTPROT_REDIRECT", "nm-ip-config-source-rtprot-redirect" }, - { NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, "NM_IP_CONFIG_SOURCE_RTPROT_KERNEL", "nm-ip-config-source-rtprot-kernel" }, - { NM_IP_CONFIG_SOURCE_RTPROT_BOOT, "NM_IP_CONFIG_SOURCE_RTPROT_BOOT", "nm-ip-config-source-rtprot-boot" }, - { NM_IP_CONFIG_SOURCE_RTPROT_STATIC, "NM_IP_CONFIG_SOURCE_RTPROT_STATIC", "nm-ip-config-source-rtprot-static" }, - { NM_IP_CONFIG_SOURCE_RTPROT_RA, "NM_IP_CONFIG_SOURCE_RTPROT_RA", "nm-ip-config-source-rtprot-ra" }, - { NM_IP_CONFIG_SOURCE_RTPROT_DHCP, "NM_IP_CONFIG_SOURCE_RTPROT_DHCP", "nm-ip-config-source-rtprot-dhcp" }, - { _NM_IP_CONFIG_SOURCE_RTPROT_LAST, "_NM_IP_CONFIG_SOURCE_RTPROT_LAST", "-nm-ip-config-source-rtprot-last" }, - { NM_IP_CONFIG_SOURCE_KERNEL, "NM_IP_CONFIG_SOURCE_KERNEL", "nm-ip-config-source-kernel" }, - { NM_IP_CONFIG_SOURCE_SHARED, "NM_IP_CONFIG_SOURCE_SHARED", "nm-ip-config-source-shared" }, - { NM_IP_CONFIG_SOURCE_IP4LL, "NM_IP_CONFIG_SOURCE_IP4LL", "nm-ip-config-source-ip4ll" }, - { NM_IP_CONFIG_SOURCE_PPP, "NM_IP_CONFIG_SOURCE_PPP", "nm-ip-config-source-ppp" }, - { NM_IP_CONFIG_SOURCE_WWAN, "NM_IP_CONFIG_SOURCE_WWAN", "nm-ip-config-source-wwan" }, - { NM_IP_CONFIG_SOURCE_VPN, "NM_IP_CONFIG_SOURCE_VPN", "nm-ip-config-source-vpn" }, - { NM_IP_CONFIG_SOURCE_DHCP, "NM_IP_CONFIG_SOURCE_DHCP", "nm-ip-config-source-dhcp" }, - { NM_IP_CONFIG_SOURCE_RDISC, "NM_IP_CONFIG_SOURCE_RDISC", "nm-ip-config-source-rdisc" }, - { NM_IP_CONFIG_SOURCE_USER, "NM_IP_CONFIG_SOURCE_USER", "nm-ip-config-source-user" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMIPConfigSource"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_link_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NM_LINK_TYPE_NONE, "NM_LINK_TYPE_NONE", "none" }, - { NM_LINK_TYPE_UNKNOWN, "NM_LINK_TYPE_UNKNOWN", "unknown" }, - { NM_LINK_TYPE_ETHERNET, "NM_LINK_TYPE_ETHERNET", "ethernet" }, - { NM_LINK_TYPE_INFINIBAND, "NM_LINK_TYPE_INFINIBAND", "infiniband" }, - { NM_LINK_TYPE_OLPC_MESH, "NM_LINK_TYPE_OLPC_MESH", "olpc-mesh" }, - { NM_LINK_TYPE_WIFI, "NM_LINK_TYPE_WIFI", "wifi" }, - { NM_LINK_TYPE_WWAN_NET, "NM_LINK_TYPE_WWAN_NET", "wwan-net" }, - { NM_LINK_TYPE_WIMAX, "NM_LINK_TYPE_WIMAX", "wimax" }, - { NM_LINK_TYPE_DUMMY, "NM_LINK_TYPE_DUMMY", "dummy" }, - { NM_LINK_TYPE_GRE, "NM_LINK_TYPE_GRE", "gre" }, - { NM_LINK_TYPE_GRETAP, "NM_LINK_TYPE_GRETAP", "gretap" }, - { NM_LINK_TYPE_IFB, "NM_LINK_TYPE_IFB", "ifb" }, - { NM_LINK_TYPE_IP6TNL, "NM_LINK_TYPE_IP6TNL", "ip6tnl" }, - { NM_LINK_TYPE_IPIP, "NM_LINK_TYPE_IPIP", "ipip" }, - { NM_LINK_TYPE_LOOPBACK, "NM_LINK_TYPE_LOOPBACK", "loopback" }, - { NM_LINK_TYPE_MACVLAN, "NM_LINK_TYPE_MACVLAN", "macvlan" }, - { NM_LINK_TYPE_MACVTAP, "NM_LINK_TYPE_MACVTAP", "macvtap" }, - { NM_LINK_TYPE_OPENVSWITCH, "NM_LINK_TYPE_OPENVSWITCH", "openvswitch" }, - { NM_LINK_TYPE_SIT, "NM_LINK_TYPE_SIT", "sit" }, - { NM_LINK_TYPE_TAP, "NM_LINK_TYPE_TAP", "tap" }, - { NM_LINK_TYPE_TUN, "NM_LINK_TYPE_TUN", "tun" }, - { NM_LINK_TYPE_VETH, "NM_LINK_TYPE_VETH", "veth" }, - { NM_LINK_TYPE_VLAN, "NM_LINK_TYPE_VLAN", "vlan" }, - { NM_LINK_TYPE_VXLAN, "NM_LINK_TYPE_VXLAN", "vxlan" }, - { NM_LINK_TYPE_BNEP, "NM_LINK_TYPE_BNEP", "bnep" }, - { NM_LINK_TYPE_BRIDGE, "NM_LINK_TYPE_BRIDGE", "bridge" }, - { NM_LINK_TYPE_BOND, "NM_LINK_TYPE_BOND", "bond" }, - { NM_LINK_TYPE_TEAM, "NM_LINK_TYPE_TEAM", "team" }, - { NM_LINK_TYPE_ANY, "NM_LINK_TYPE_ANY", "any" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMLinkType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_pobject_type_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GEnumValue values[] = { - { NMP_OBJECT_TYPE_UNKNOWN, "NMP_OBJECT_TYPE_UNKNOWN", "nmp-object-type-unknown" }, - { NMP_OBJECT_TYPE_LINK, "NMP_OBJECT_TYPE_LINK", "nmp-object-type-link" }, - { NMP_OBJECT_TYPE_IP4_ADDRESS, "NMP_OBJECT_TYPE_IP4_ADDRESS", "nmp-object-type-ip4-address" }, - { NMP_OBJECT_TYPE_IP6_ADDRESS, "NMP_OBJECT_TYPE_IP6_ADDRESS", "nmp-object-type-ip6-address" }, - { NMP_OBJECT_TYPE_IP4_ROUTE, "NMP_OBJECT_TYPE_IP4_ROUTE", "nmp-object-type-ip4-route" }, - { NMP_OBJECT_TYPE_IP6_ROUTE, "NMP_OBJECT_TYPE_IP6_ROUTE", "nmp-object-type-ip6-route" }, - { NMP_OBJECT_TYPE_LNK_GRE, "NMP_OBJECT_TYPE_LNK_GRE", "nmp-object-type-lnk-gre" }, - { NMP_OBJECT_TYPE_LNK_INFINIBAND, "NMP_OBJECT_TYPE_LNK_INFINIBAND", "nmp-object-type-lnk-infiniband" }, - { NMP_OBJECT_TYPE_LNK_IP6TNL, "NMP_OBJECT_TYPE_LNK_IP6TNL", "nmp-object-type-lnk-ip6tnl" }, - { NMP_OBJECT_TYPE_LNK_IPIP, "NMP_OBJECT_TYPE_LNK_IPIP", "nmp-object-type-lnk-ipip" }, - { NMP_OBJECT_TYPE_LNK_MACVLAN, "NMP_OBJECT_TYPE_LNK_MACVLAN", "nmp-object-type-lnk-macvlan" }, - { NMP_OBJECT_TYPE_LNK_MACVTAP, "NMP_OBJECT_TYPE_LNK_MACVTAP", "nmp-object-type-lnk-macvtap" }, - { NMP_OBJECT_TYPE_LNK_SIT, "NMP_OBJECT_TYPE_LNK_SIT", "nmp-object-type-lnk-sit" }, - { NMP_OBJECT_TYPE_LNK_VLAN, "NMP_OBJECT_TYPE_LNK_VLAN", "nmp-object-type-lnk-vlan" }, - { NMP_OBJECT_TYPE_LNK_VXLAN, "NMP_OBJECT_TYPE_LNK_VXLAN", "nmp-object-type-lnk-vxlan" }, - { __NMP_OBJECT_TYPE_LAST, "__NMP_OBJECT_TYPE_LAST", "--nmp-object-type-last" }, - { NMP_OBJECT_TYPE_MAX, "NMP_OBJECT_TYPE_MAX", "nmp-object-type-max" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_enum_register_static (g_intern_static_string ("NMPObjectType"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} -GType -nm_ip_config_merge_flags_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - static const GFlagsValue values[] = { - { NM_IP_CONFIG_MERGE_DEFAULT, "NM_IP_CONFIG_MERGE_DEFAULT", "default" }, - { NM_IP_CONFIG_MERGE_NO_ROUTES, "NM_IP_CONFIG_MERGE_NO_ROUTES", "no-routes" }, - { NM_IP_CONFIG_MERGE_NO_DNS, "NM_IP_CONFIG_MERGE_NO_DNS", "no-dns" }, - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_flags_register_static (g_intern_static_string ("NMIPConfigMergeFlags"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} - - - diff --git a/src/nm-enum-types.h b/src/nm-enum-types.h deleted file mode 100644 index 09ffca60..00000000 --- a/src/nm-enum-types.h +++ /dev/null @@ -1,70 +0,0 @@ - - - -/* Generated by glib-mkenums. Do not edit */ - -#ifndef __NM_ENUM_TYPES_H__ -#define __NM_ENUM_TYPES_H__ - -#include -#include - -G_BEGIN_DECLS -GType nm_unman_flag_op_get_type (void) G_GNUC_CONST; -#define NM_TYPE_UNMAN_FLAG_OP (nm_unman_flag_op_get_type ()) -GType nm_dhcp_state_get_type (void) G_GNUC_CONST; -#define NM_TYPE_DHCP_STATE (nm_dhcp_state_get_type ()) -GType nm_dns_ip_config_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_DNS_IP_CONFIG_TYPE (nm_dns_ip_config_type_get_type ()) -GType nm_dns_manager_resolv_conf_manager_get_type (void) G_GNUC_CONST; -#define NM_TYPE_DNS_MANAGER_RESOLV_CONF_MANAGER (nm_dns_manager_resolv_conf_manager_get_type ()) -GType nm_dns_masq_status_get_type (void) G_GNUC_CONST; -#define NM_TYPE_DNS_MASQ_STATUS (nm_dns_masq_status_get_type ()) -GType nm_platform_signal_change_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_PLATFORM_SIGNAL_CHANGE_TYPE (nm_platform_signal_change_type_get_type ()) -GType nm_rdisc_dhcp_level_get_type (void) G_GNUC_CONST; -#define NM_TYPE_RDISC_DHCP_LEVEL (nm_rdisc_dhcp_level_get_type ()) -GType nm_rdisc_preference_get_type (void) G_GNUC_CONST; -#define NM_TYPE_RDISC_PREFERENCE (nm_rdisc_preference_get_type ()) -GType nm_rdisc_config_map_get_type (void) G_GNUC_CONST; -#define NM_TYPE_RDISC_CONFIG_MAP (nm_rdisc_config_map_get_type ()) -GType nm_ppp_status_get_type (void) G_GNUC_CONST; -#define NM_TYPE_PPP_STATUS (nm_ppp_status_get_type ()) -GType nm_settings_connection_flags_get_type (void) G_GNUC_CONST; -#define NM_TYPE_SETTINGS_CONNECTION_FLAGS (nm_settings_connection_flags_get_type ()) -GType nm_settings_plugin_capabilities_get_type (void) G_GNUC_CONST; -#define NM_TYPE_SETTINGS_PLUGIN_CAPABILITIES (nm_settings_plugin_capabilities_get_type ()) -GType nm_settings_plugin_prop_get_type (void) G_GNUC_CONST; -#define NM_TYPE_SETTINGS_PLUGIN_PROP (nm_settings_plugin_prop_get_type ()) -GType nm_opt_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_OPT_TYPE (nm_opt_type_get_type ()) -GType nm_supplicant_feature_get_type (void) G_GNUC_CONST; -#define NM_TYPE_SUPPLICANT_FEATURE (nm_supplicant_feature_get_type ()) -GType nm_supplicant_error_get_type (void) G_GNUC_CONST; -#define NM_TYPE_SUPPLICANT_ERROR (nm_supplicant_error_get_type ()) -GType nm_config_run_state_property_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_CONFIG_RUN_STATE_PROPERTY_TYPE (nm_config_run_state_property_type_get_type ()) -GType nm_config_get_value_flags_get_type (void) G_GNUC_CONST; -#define NM_TYPE_CONFIG_GET_VALUE_FLAGS (nm_config_get_value_flags_get_type ()) -GType nm_config_change_flags_get_type (void) G_GNUC_CONST; -#define NM_TYPE_CONFIG_CHANGE_FLAGS (nm_config_change_flags_get_type ()) -GType nm_dispatcher_action_get_type (void) G_GNUC_CONST; -#define NM_TYPE_DISPATCHER_ACTION (nm_dispatcher_action_get_type ()) -GType nm_auth_subject_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_AUTH_SUBJECT_TYPE (nm_auth_subject_type_get_type ()) -GType nm_auth_call_result_get_type (void) G_GNUC_CONST; -#define NM_TYPE_AUTH_CALL_RESULT (nm_auth_call_result_get_type ()) -GType nm_ip_config_source_get_type (void) G_GNUC_CONST; -#define NM_TYPE_IP_CONFIG_SOURCE (nm_ip_config_source_get_type ()) -GType nm_link_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_LINK_TYPE (nm_link_type_get_type ()) -GType nm_pobject_type_get_type (void) G_GNUC_CONST; -#define NM_TYPE_POBJECT_TYPE (nm_pobject_type_get_type ()) -GType nm_ip_config_merge_flags_get_type (void) G_GNUC_CONST; -#define NM_TYPE_IP_CONFIG_MERGE_FLAGS (nm_ip_config_merge_flags_get_type ()) -G_END_DECLS - -#endif /* __NM_ENUM_TYPES_H__ */ - - - diff --git a/src/nm-exported-object.c b/src/nm-exported-object.c index 32b5ec05..a53a3123 100644 --- a/src/nm-exported-object.c +++ b/src/nm-exported-object.c @@ -27,9 +27,9 @@ #include "nm-bus-manager.h" -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-active-connection.h" -#include "nmdbus-device-statistics.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Statistics.h" #if NM_MORE_ASSERTS >= 2 #define _ASSERT_NO_EARLY_EXPORT @@ -37,15 +37,13 @@ static gboolean quitting = FALSE; -G_DEFINE_ABSTRACT_TYPE (NMExportedObject, nm_exported_object, G_TYPE_DBUS_OBJECT_SKELETON); - typedef struct { GDBusInterfaceSkeleton *interface; guint property_changed_signal_id; GHashTable *pending_notifies; } InterfaceData; -typedef struct { +typedef struct _NMExportedObjectPrivate { NMBusManager *bus_mgr; char *path; @@ -59,7 +57,11 @@ typedef struct { #endif } NMExportedObjectPrivate; -#define NM_EXPORTED_OBJECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectPrivate)) +G_DEFINE_ABSTRACT_TYPE (NMExportedObject, nm_exported_object, G_TYPE_DBUS_OBJECT_SKELETON); + +#define NM_EXPORTED_OBJECT_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMExportedObject, NM_IS_EXPORTED_OBJECT) + +/*****************************************************************************/ typedef struct { GHashTable *properties; @@ -72,23 +74,11 @@ G_DEFINE_QUARK (NMExportedObjectClassInfo, nm_exported_object_class_info) /*****************************************************************************/ -#define _NMLOG_PREFIX_NAME "exported-object" -#define _NMLOG_DOMAIN LOGD_CORE - -#define _NMLOG(level, ...) \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s[%p]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, (self) \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)) +#define _NMLOG_DOMAIN LOGD_CORE +#define _NMLOG(level, ...) __NMLOG_DEFAULT_WITH_ADDR (level, _NMLOG_DOMAIN, "exported-object", __VA_ARGS__) -#define _NMLOG2_PREFIX_NAME "properties-changed" -#define _NMLOG2_DOMAIN LOGD_DBUS_PROPS - -#define _NMLOG2(level, ...) \ - nm_log ((level), _NMLOG2_DOMAIN, \ - "%s[%p]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG2_PREFIX_NAME, (self) \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)) +#define _NMLOG2_DOMAIN LOGD_DBUS_PROPS +#define _NMLOG2(level, ...) __NMLOG_DEFAULT_WITH_ADDR (level, _NMLOG2_DOMAIN, "properties-changed", __VA_ARGS__) /*****************************************************************************/ @@ -574,7 +564,7 @@ _create_export_path (NMExportedObjectClass *klass) { const char *class_export_path, *p; static GHashTable *prefix_counters; - guint *counter; + guint64 *counter; class_export_path = klass->export_path; @@ -585,17 +575,19 @@ _create_export_path (NMExportedObjectClass *klass) if (G_UNLIKELY (!prefix_counters)) prefix_counters = g_hash_table_new (g_str_hash, g_str_equal); - g_assert (p[1] == 'u'); - g_assert (strchr (p + 1, '%') == NULL); + nm_assert (p[1] == 'l'); + nm_assert (p[2] == 'l'); + nm_assert (p[3] == 'u'); + nm_assert (p[4] == '\0'); counter = g_hash_table_lookup (prefix_counters, class_export_path); if (!counter) { - counter = g_slice_new0 (guint); - g_hash_table_insert (prefix_counters, g_strdup (class_export_path), counter); + counter = g_slice_new0 (guint64); + g_hash_table_insert (prefix_counters, (char *) class_export_path, counter); } NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral") - return g_strdup_printf (class_export_path, (*counter)++); + return g_strdup_printf (class_export_path, (long long unsigned) (++(*counter))); NM_PRAGMA_WARNING_REENABLE } @@ -800,7 +792,7 @@ _sort_pending_notifies (gconstpointer a, gconstpointer b, gpointer user_da static gboolean idle_emit_properties_changed (gpointer self) { - NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self); + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (NM_EXPORTED_OBJECT (self)); guint k; priv->notify_idle_id = 0; @@ -958,7 +950,7 @@ vtype_found: (gpointer) dbus_property_name, value_variant); } else - nm_assert_not_reached (); + g_variant_unref (value_variant); if (!priv->notify_idle_id) priv->notify_idle_id = g_idle_add (idle_emit_properties_changed, self); @@ -969,6 +961,10 @@ vtype_found: static void nm_exported_object_init (NMExportedObject *self) { + NMExportedObjectPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_EXPORTED_OBJECT, NMExportedObjectPrivate); + self->_priv = priv; } static void @@ -979,7 +975,7 @@ constructed (GObject *object) G_OBJECT_CLASS (nm_exported_object_parent_class)->constructed (object); #ifdef _ASSERT_NO_EARLY_EXPORT - NM_EXPORTED_OBJECT_GET_PRIVATE (object)->_constructed = TRUE; + NM_EXPORTED_OBJECT_GET_PRIVATE (NM_EXPORTED_OBJECT (object))->_constructed = TRUE; #endif klass = NM_EXPORTED_OBJECT_GET_CLASS (object); @@ -989,9 +985,9 @@ constructed (GObject *object) } static void -nm_exported_object_dispose (GObject *object) +dispose (GObject *object) { - NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (object); + NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (NM_EXPORTED_OBJECT (object)); /* Objects should have already been unexported by their owner, unless * we are quitting, where many objects stick around until exit. @@ -1018,7 +1014,5 @@ nm_exported_object_class_init (NMExportedObjectClass *klass) object_class->constructed = constructed; object_class->notify = nm_exported_object_notify; - object_class->dispose = nm_exported_object_dispose; + object_class->dispose = dispose; } - - diff --git a/src/nm-exported-object.h b/src/nm-exported-object.h index 7036e0d0..7d348129 100644 --- a/src/nm-exported-object.h +++ b/src/nm-exported-object.h @@ -23,6 +23,8 @@ /*****************************************************************************/ +#define NM_EXPORT_PATH_NUMBERED(basepath) ""basepath"/%llu" + char *nm_exported_object_skeletonify_method_name (const char *dbus_method_name); typedef struct { @@ -47,8 +49,11 @@ void nm_exported_object_skeleton_release (GDBusInterfaceSkeleton *interface); #define NM_IS_EXPORTED_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_EXPORTED_OBJECT)) #define NM_EXPORTED_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectClass)) +struct _NMExportedObjectPrivate; + struct _NMExportedObject { GDBusObjectSkeleton parent; + struct _NMExportedObjectPrivate *_priv; }; typedef struct { diff --git a/src/nm-firewall-manager.c b/src/nm-firewall-manager.c index f1d0170b..5ba3d23e 100644 --- a/src/nm-firewall-manager.c +++ b/src/nm-firewall-manager.c @@ -26,19 +26,19 @@ #include "NetworkManagerUtils.h" -#define NM_FIREWALL_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_FIREWALL_MANAGER, \ - NMFirewallManagerPrivate)) +/*****************************************************************************/ -G_DEFINE_TYPE (NMFirewallManager, nm_firewall_manager, G_TYPE_OBJECT) +NM_GOBJECT_PROPERTIES_DEFINE (NMFirewallManager, + PROP_AVAILABLE, +); -/* Properties */ enum { - PROP_0 = 0, - PROP_AVAILABLE, - LAST_PROP + STARTED, + LAST_SIGNAL }; +static guint signals[LAST_SIGNAL] = { 0 }; + typedef struct { GDBusProxy * proxy; gboolean running; @@ -46,17 +46,24 @@ typedef struct { GHashTable *pending_calls; } NMFirewallManagerPrivate; -enum { - STARTED, +struct _NMFirewallManager { + GObject parent; + NMFirewallManagerPrivate _priv; +}; - LAST_SIGNAL +struct _NMFirewallManagerClass { + GObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_TYPE (NMFirewallManager, nm_firewall_manager, G_TYPE_OBJECT) + +#define NM_FIREWALL_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMFirewallManager, NM_IS_FIREWALL_MANAGER) + +/*****************************************************************************/ NM_DEFINE_SINGLETON_GETTER (NMFirewallManager, nm_firewall_manager_get, NM_TYPE_FIREWALL_MANAGER); -/********************************************************************/ +/*****************************************************************************/ typedef enum { CB_INFO_OPS_ADD = 1, @@ -89,7 +96,7 @@ struct _NMFirewallManagerCallId { }; typedef struct _NMFirewallManagerCallId CBInfo; -/********************************************************************/ +/*****************************************************************************/ static const char * _ops_type_to_string (CBInfoOpsType ops_type) @@ -131,7 +138,7 @@ _ops_type_to_string (CBInfoOpsType ops_type) } \ } G_STMT_END -/********************************************************************/ +/*****************************************************************************/ static gboolean _cb_info_is_idle (CBInfo *info) @@ -396,7 +403,7 @@ nm_firewall_manager_cancel_call (NMFirewallManagerCallId call) } } -/*******************************************************************/ +/*****************************************************************************/ static void set_running (NMFirewallManager *self, gboolean now_running) @@ -406,7 +413,7 @@ set_running (NMFirewallManager *self, gboolean now_running) priv->running = now_running; if (old_running != priv->running) - g_object_notify (G_OBJECT (self), NM_FIREWALL_MANAGER_AVAILABLE); + _notify (self, PROP_AVAILABLE); } static void @@ -428,7 +435,22 @@ name_owner_changed (GObject *object, } } -/*******************************************************************/ +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case PROP_AVAILABLE: + g_value_set_boolean (value, NM_FIREWALL_MANAGER_GET_PRIVATE ((NMFirewallManager *) object)->running); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ static void nm_firewall_manager_init (NMFirewallManager * self) @@ -456,31 +478,17 @@ constructed (GObject *object) FIREWALL_DBUS_PATH, FIREWALL_DBUS_INTERFACE_ZONE, NULL, &error); - if (priv->proxy) { + if (priv->proxy) { g_signal_connect (priv->proxy, "notify::g-name-owner", - G_CALLBACK (name_owner_changed), self); + G_CALLBACK (name_owner_changed), self); owner = g_dbus_proxy_get_name_owner (priv->proxy); priv->running = (owner != NULL); - } else { - _LOGW (NULL, "could not connect to system D-Bus (%s)", error->message); - } + } else + _LOGW (NULL, "could not connect to system D-Bus (%s)", error->message); _LOGD (NULL, "firewall constructed (%srunning)", priv->running ? "" : "not"); } -static void -get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_AVAILABLE: - g_value_set_boolean (value, NM_FIREWALL_MANAGER_GET_PRIVATE (object)->running); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void dispose (GObject *object) { @@ -497,7 +505,6 @@ dispose (GObject *object) g_clear_object (&priv->proxy); - /* Chain up to the parent class */ G_OBJECT_CLASS (nm_firewall_manager_parent_class)->dispose (object); } @@ -506,27 +513,24 @@ nm_firewall_manager_class_init (NMFirewallManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMFirewallManagerPrivate)); - object_class->constructed = constructed; object_class->get_property = get_property; object_class->dispose = dispose; - g_object_class_install_property - (object_class, PROP_AVAILABLE, + obj_properties[PROP_AVAILABLE] = g_param_spec_boolean (NM_FIREWALL_MANAGER_AVAILABLE, "", "", FALSE, G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[STARTED] = g_signal_new (NM_FIREWALL_MANAGER_STARTED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMFirewallManagerClass, started), + 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - } - diff --git a/src/nm-firewall-manager.h b/src/nm-firewall-manager.h index 92fac8e2..a00ee451 100644 --- a/src/nm-firewall-manager.h +++ b/src/nm-firewall-manager.h @@ -26,30 +26,21 @@ #define FIREWALL_DBUS_INTERFACE "org.fedoraproject.FirewallD1" #define FIREWALL_DBUS_INTERFACE_ZONE "org.fedoraproject.FirewallD1.zone" -#define NM_TYPE_FIREWALL_MANAGER (nm_firewall_manager_get_type ()) -#define NM_FIREWALL_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_FIREWALL_MANAGER, NMFirewallManager)) -#define NM_FIREWALL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_FIREWALL_MANAGER, NMFirewallManagerClass)) -#define NM_IS_FIREWALL_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_FIREWALL_MANAGER)) -#define NM_IS_FIREWALL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_FIREWALL_MANAGER)) -#define NM_FIREWALL_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_FIREWALL_MANAGER, NMFirewallManagerClass)) +#define NM_TYPE_FIREWALL_MANAGER (nm_firewall_manager_get_type ()) +#define NM_FIREWALL_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_FIREWALL_MANAGER, NMFirewallManager)) +#define NM_FIREWALL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_FIREWALL_MANAGER, NMFirewallManagerClass)) +#define NM_IS_FIREWALL_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_FIREWALL_MANAGER)) +#define NM_IS_FIREWALL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_FIREWALL_MANAGER)) +#define NM_FIREWALL_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_FIREWALL_MANAGER, NMFirewallManagerClass)) #define NM_FIREWALL_MANAGER_AVAILABLE "available" #define NM_FIREWALL_MANAGER_STARTED "started" -struct _NMFirewallManagerCallId; typedef struct _NMFirewallManagerCallId *NMFirewallManagerCallId; -typedef struct { - GObject parent; -} NMFirewallManager; - -typedef struct { - GObjectClass parent; - - /* Signals */ - void (*started) (NMFirewallManager *manager); -} NMFirewallManagerClass; +typedef struct _NMFirewallManager NMFirewallManager; +typedef struct _NMFirewallManagerClass NMFirewallManagerClass; GType nm_firewall_manager_get_type (void); diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index de035f1a..4405c325 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -32,19 +32,16 @@ #include #include -/* Cannot include due to conflict with . - * Forward declare if_nametoindex. */ -extern unsigned int if_nametoindex (const char *__ifname); - #include "main-utils.h" #include "NetworkManagerUtils.h" -#include "nm-linux-platform.h" -#include "nm-dhcp-manager.h" -#include "nm-rdisc.h" -#include "nm-lndp-rdisc.h" +#include "platform/nm-linux-platform.h" +#include "platform/nm-platform-utils.h" +#include "dhcp/nm-dhcp-manager.h" +#include "ndisc/nm-ndisc.h" +#include "ndisc/nm-lndp-ndisc.h" #include "nm-utils.h" #include "nm-setting-ip6-config.h" -#include "nm-sd.h" +#include "systemd/nm-sd.h" #if !defined(NM_DIST_VERSION) # define NM_DIST_VERSION VERSION @@ -52,8 +49,14 @@ extern unsigned int if_nametoindex (const char *__ifname); #define NMIH_PID_FILE_FMT NMRUNDIR "/nm-iface-helper-%d.pid" -static GMainLoop *main_loop = NULL; -static int ifindex = -1; +/*****************************************************************************/ + +static struct { + GMainLoop *main_loop; + int ifindex; +} gl/*obal*/ = { + .ifindex = -1, +}; static struct { gboolean slaac; @@ -84,6 +87,16 @@ static struct { .priority_v6 = NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, }; +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "nm-iface-helper" +#define _NMLOG(level, domain, ...) \ + nm_log ((level), (domain), \ + "iface-helper: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__) \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)) + +/*****************************************************************************/ + static void dhcp4_state_changed (NMDhcpClient *client, NMDhcpState state, @@ -97,18 +110,18 @@ dhcp4_state_changed (NMDhcpClient *client, g_return_if_fail (!ip4_config || NM_IS_IP4_CONFIG (ip4_config)); - nm_log_dbg (LOGD_DHCP4, "(%s): new DHCPv4 client state %d", global_opt.ifname, state); + _LOGD (LOGD_DHCP4, "new DHCPv4 client state %d", state); switch (state) { case NM_DHCP_STATE_BOUND: g_assert (ip4_config); - existing = nm_ip4_config_capture (ifindex, FALSE); + existing = nm_ip4_config_capture (gl.ifindex, FALSE); if (last_config) nm_ip4_config_subtract (existing, last_config); nm_ip4_config_merge (existing, ip4_config, NM_IP_CONFIG_MERGE_DEFAULT); - if (!nm_ip4_config_commit (existing, ifindex, TRUE, global_opt.priority_v4)) - nm_log_warn (LOGD_DHCP4, "(%s): failed to apply DHCPv4 config", global_opt.ifname); + if (!nm_ip4_config_commit (existing, gl.ifindex, TRUE, global_opt.priority_v4)) + _LOGW (LOGD_DHCP4, "failed to apply DHCPv4 config"); if (last_config) g_object_unref (last_config); @@ -119,10 +132,10 @@ dhcp4_state_changed (NMDhcpClient *client, case NM_DHCP_STATE_DONE: case NM_DHCP_STATE_FAIL: if (global_opt.dhcp4_required) { - nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 timed out or failed, quitting...", global_opt.ifname); - g_main_loop_quit (main_loop); + _LOGW (LOGD_DHCP4, "DHCPv4 timed out or failed, quitting..."); + g_main_loop_quit (gl.main_loop); } else - nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 timed out or failed", global_opt.ifname); + _LOGW (LOGD_DHCP4, "DHCPv4 timed out or failed"); break; default: break; @@ -130,25 +143,23 @@ dhcp4_state_changed (NMDhcpClient *client, } static void -rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_int, gpointer user_data) +ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, gpointer user_data) { - NMRDiscConfigMap changed = changed_int; - static NMIP6Config *rdisc_config = NULL; + NMNDiscConfigMap changed = changed_int; + static NMIP6Config *ndisc_config = NULL; NMIP6Config *existing; - static int system_support = -1; + int system_support; guint32 ifa_flags = 0x00; int i; - if (system_support == -1) { - /* - * Check, whether kernel is recent enough, to help user space handling RA. - * If it's not supported, we have no ipv6-privacy and must add autoconf - * addresses as /128. - * The reason for the /128 is to prevent the kernel - * from adding a prefix route for this address. - **/ - system_support = nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET); - } + /* + * Check, whether kernel is recent enough, to help user space handling RA. + * If it's not supported, we have no ipv6-privacy and must add autoconf + * addresses as /128. + * The reason for the /128 is to prevent the kernel + * from adding a prefix route for this address. + **/ + system_support = nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET); if (system_support) ifa_flags = IFA_F_NOPREFIXROUTE; @@ -159,31 +170,31 @@ rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_in ifa_flags |= IFA_F_MANAGETEMPADDR; } - existing = nm_ip6_config_capture (ifindex, FALSE, global_opt.tempaddr); - if (rdisc_config) - nm_ip6_config_subtract (existing, rdisc_config); + existing = nm_ip6_config_capture (gl.ifindex, FALSE, global_opt.tempaddr); + if (ndisc_config) + nm_ip6_config_subtract (existing, ndisc_config); else - rdisc_config = nm_ip6_config_new (ifindex); + ndisc_config = nm_ip6_config_new (gl.ifindex); - if (changed & NM_RDISC_CONFIG_GATEWAYS) { - /* Use the first gateway as ordered in router discovery cache. */ + if (changed & NM_NDISC_CONFIG_GATEWAYS) { + /* Use the first gateway as ordered in neighbor discovery cache. */ if (rdata->gateways_n) - nm_ip6_config_set_gateway (rdisc_config, &rdata->gateways[0].address); + nm_ip6_config_set_gateway (ndisc_config, &rdata->gateways[0].address); else - nm_ip6_config_set_gateway (rdisc_config, NULL); + nm_ip6_config_set_gateway (ndisc_config, NULL); } - if (changed & NM_RDISC_CONFIG_ADDRESSES) { - /* Rebuild address list from router discovery cache. */ - nm_ip6_config_reset_addresses (rdisc_config); + if (changed & NM_NDISC_CONFIG_ADDRESSES) { + /* Rebuild address list from neighbor discovery cache. */ + nm_ip6_config_reset_addresses (ndisc_config); - /* rdisc->addresses contains at most max_addresses entries. + /* ndisc->addresses contains at most max_addresses entries. * This is different from what the kernel does, which * also counts static and temporary addresses when checking * max_addresses. **/ for (i = 0; i < rdata->addresses_n; i++) { - const NMRDiscAddress *discovered_address = &rdata->addresses[i]; + const NMNDiscAddress *discovered_address = &rdata->addresses[i]; NMPlatformIP6Address address; memset (&address, 0, sizeof (address)); @@ -194,64 +205,64 @@ rdisc_config_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_in address.preferred = discovered_address->preferred; if (address.preferred > address.lifetime) address.preferred = address.lifetime; - address.addr_source = NM_IP_CONFIG_SOURCE_RDISC; + address.addr_source = NM_IP_CONFIG_SOURCE_NDISC; address.n_ifa_flags = ifa_flags; - nm_ip6_config_add_address (rdisc_config, &address); + nm_ip6_config_add_address (ndisc_config, &address); } } - if (changed & NM_RDISC_CONFIG_ROUTES) { - /* Rebuild route list from router discovery cache. */ - nm_ip6_config_reset_routes (rdisc_config); + if (changed & NM_NDISC_CONFIG_ROUTES) { + /* Rebuild route list from neighbor discovery cache. */ + nm_ip6_config_reset_routes (ndisc_config); for (i = 0; i < rdata->routes_n; i++) { - const NMRDiscRoute *discovered_route = &rdata->routes[i]; + const NMNDiscRoute *discovered_route = &rdata->routes[i]; const NMPlatformIP6Route route = { .network = discovered_route->network, .plen = discovered_route->plen, .gateway = discovered_route->gateway, - .rt_source = NM_IP_CONFIG_SOURCE_RDISC, + .rt_source = NM_IP_CONFIG_SOURCE_NDISC, .metric = global_opt.priority_v6, }; - nm_ip6_config_add_route (rdisc_config, &route); + nm_ip6_config_add_route (ndisc_config, &route); } } - if (changed & NM_RDISC_CONFIG_DHCP_LEVEL) { + if (changed & NM_NDISC_CONFIG_DHCP_LEVEL) { /* Unsupported until systemd DHCPv6 is ready */ } - if (changed & NM_RDISC_CONFIG_HOP_LIMIT) + if (changed & NM_NDISC_CONFIG_HOP_LIMIT) nm_platform_sysctl_set_ip6_hop_limit_safe (NM_PLATFORM_GET, global_opt.ifname, rdata->hop_limit); - if (changed & NM_RDISC_CONFIG_MTU) { + if (changed & NM_NDISC_CONFIG_MTU) { char val[16]; g_snprintf (val, sizeof (val), "%d", rdata->mtu); - nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val); + nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (global_opt.ifname, "mtu")), val); } - nm_ip6_config_merge (existing, rdisc_config, NM_IP_CONFIG_MERGE_DEFAULT); - if (!nm_ip6_config_commit (existing, ifindex, TRUE)) - nm_log_warn (LOGD_IP6, "(%s): failed to apply IPv6 config", global_opt.ifname); + nm_ip6_config_merge (existing, ndisc_config, NM_IP_CONFIG_MERGE_DEFAULT); + if (!nm_ip6_config_commit (existing, gl.ifindex, TRUE)) + _LOGW (LOGD_IP6, "failed to apply IPv6 config"); } static void -rdisc_ra_timeout (NMRDisc *rdisc, gpointer user_data) +ndisc_ra_timeout (NMNDisc *ndisc, gpointer user_data) { if (global_opt.slaac_required) { - nm_log_warn (LOGD_IP6, "(%s): IPv6 timed out or failed, quitting...", global_opt.ifname); - g_main_loop_quit (main_loop); + _LOGW (LOGD_IP6, "IPv6 timed out or failed, quitting..."); + g_main_loop_quit (gl.main_loop); } else - nm_log_warn (LOGD_IP6, "(%s): IPv6 timed out or failed", global_opt.ifname); + _LOGW (LOGD_IP6, "IPv6 timed out or failed"); } static gboolean quit_handler (gpointer user_data) { - g_main_loop_quit (main_loop); + g_main_loop_quit (gl.main_loop); return G_SOURCE_REMOVE; } @@ -263,7 +274,7 @@ setup_signals (void) g_unix_signal_add (SIGTERM, quit_handler, NULL); } -static void +static gboolean do_early_setup (int *argc, char **argv[]) { gint64 priority64_v4 = -1; @@ -306,25 +317,28 @@ do_early_setup (int *argc, char **argv[]) NULL, NULL, _("nm-iface-helper is a small, standalone process that manages a single network interface."))) - exit (1); + return FALSE; if (priority64_v4 >= 0 && priority64_v4 <= G_MAXUINT32) global_opt.priority_v4 = (guint32) priority64_v4; if (priority64_v6 >= 0 && priority64_v6 <= G_MAXUINT32) global_opt.priority_v6 = (guint32) priority64_v6; + return TRUE; } static void ip6_address_changed (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int iface, NMPlatformIP6Address *addr, - NMPlatformSignalChangeType change_type, - NMRDisc *rdisc) + int change_type_i, + NMNDisc *ndisc) { + const NMPlatformSignalChangeType change_type = change_type_i; + if ( (change_type == NM_PLATFORM_SIGNAL_CHANGED && addr->n_ifa_flags & IFA_F_DADFAILED) || (change_type == NM_PLATFORM_SIGNAL_REMOVED && addr->n_ifa_flags & IFA_F_TENTATIVE)) - nm_rdisc_dad_failed (rdisc, &addr->address); + nm_ndisc_dad_failed (ndisc, &addr->address); } int @@ -335,7 +349,7 @@ main (int argc, char *argv[]) gboolean wrote_pidfile = FALSE; gs_free char *pidfile = NULL; gs_unref_object NMDhcpClient *dhcp4_client = NULL; - gs_unref_object NMRDisc *rdisc = NULL; + gs_unref_object NMNDisc *ndisc = NULL; GByteArray *hwaddr = NULL; size_t hwaddr_len = 0; gconstpointer tmp; @@ -346,7 +360,14 @@ main (int argc, char *argv[]) setpgid (getpid (), getpid ()); - do_early_setup (&argc, &argv); + if (!do_early_setup (&argc, &argv)) + return 1; + + nm_logging_set_syslog_identifier ("nm-iface-helper"); + nm_logging_set_prefix ("%s[%ld] (%s): ", + _NMLOG_PREFIX_NAME, + (long) getpid (), + global_opt.ifname ?: "???"); if (global_opt.g_fatal_warnings) { GLogLevelFlags fatal_mask; @@ -358,22 +379,22 @@ main (int argc, char *argv[]) if (global_opt.show_version) { fprintf (stdout, NM_DIST_VERSION "\n"); - exit (0); + return 0; } nm_main_utils_ensure_root (); if (!global_opt.ifname || !global_opt.uuid) { fprintf (stderr, _("An interface name and UUID are required\n")); - exit (1); + return 1; } - ifindex = if_nametoindex (global_opt.ifname); - if (ifindex <= 0) { + gl.ifindex = nmp_utils_if_nametoindex (global_opt.ifname); + if (gl.ifindex <= 0) { fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno)); - exit (1); + return 1; } - pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex); + pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, gl.ifindex); nm_main_utils_ensure_not_running_pidfile (pidfile); nm_main_utils_ensure_rundir (); @@ -385,7 +406,7 @@ main (int argc, char *argv[]) fprintf (stderr, _("%s. Please use --help to see a list of valid options.\n"), error->message); - exit (1); + return 1; } else if (bad_domains) { fprintf (stderr, _("Ignoring unrecognized log domain(s) '%s' passed on command line.\n"), @@ -401,26 +422,26 @@ main (int argc, char *argv[]) fprintf (stderr, _("Could not daemonize: %s [error %u]\n"), g_strerror (saved_errno), saved_errno); - exit (1); + return 1; } if (nm_main_utils_write_pidfile (pidfile)) wrote_pidfile = TRUE; } /* Set up unix signal handling - before creating threads, but after daemonizing! */ - main_loop = g_main_loop_new (NULL, FALSE); + gl.main_loop = g_main_loop_new (NULL, FALSE); setup_signals (); nm_logging_syslog_openlog (global_opt.logging_backend ? global_opt.logging_backend : (global_opt.debug ? "debug" : NULL)); - nm_log_info (LOGD_CORE, "nm-iface-helper (version " NM_DIST_VERSION ") is starting..."); + _LOGI (LOGD_CORE, "nm-iface-helper (version " NM_DIST_VERSION ") is starting..."); /* Set up platform interaction layer */ nm_linux_platform_setup (); - tmp = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len); + tmp = nm_platform_link_get_address (NM_PLATFORM_GET, gl.ifindex, &hwaddr_len); if (tmp) { hwaddr = g_byte_array_sized_new (hwaddr_len); g_byte_array_append (hwaddr, tmp, hwaddr_len); @@ -433,17 +454,17 @@ main (int argc, char *argv[]) bytes = nm_utils_hexstr2bin (global_opt.iid_str); if (!bytes || g_bytes_get_size (bytes) != sizeof (*iid)) { fprintf (stderr, _("(%s): Invalid IID %s\n"), global_opt.ifname, global_opt.iid_str); - exit (1); + return 1; } iid = g_bytes_unref_to_data (bytes, &ignored); } if (global_opt.dhcp4_address) { - nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1"); + nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries")), "1"); dhcp4_client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (), global_opt.ifname, - ifindex, + gl.ifindex, hwaddr, global_opt.uuid, global_opt.priority_v4, @@ -465,7 +486,7 @@ main (int argc, char *argv[]) NMUtilsStableType stable_type = NM_UTILS_STABLE_TYPE_UUID; const char *stable_id = global_opt.uuid; - nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, TRUE); + nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, gl.ifindex, TRUE); if ( global_opt.stable_id && (global_opt.stable_id[0] >= '0' && global_opt.stable_id[0] <= '9') @@ -476,98 +497,111 @@ main (int argc, char *argv[]) stable_type = (global_opt.stable_id[0] - '0'); stable_id = &global_opt.stable_id[2]; } - rdisc = nm_lndp_rdisc_new (NM_PLATFORM_GET, ifindex, global_opt.ifname, + ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET, gl.ifindex, global_opt.ifname, stable_type, stable_id, - global_opt.addr_gen_mode, NULL); - g_assert (rdisc); + global_opt.addr_gen_mode, + NM_NDISC_NODE_TYPE_HOST, + NULL); + g_assert (ndisc); if (iid) - nm_rdisc_set_iid (rdisc, *iid); + nm_ndisc_set_iid (ndisc, *iid); - nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1"); - nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0"); - nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0"); - nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0"); + nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra")), "1"); + nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr")), "0"); + nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo")), "0"); + nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref")), "0"); g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, G_CALLBACK (ip6_address_changed), - rdisc); - g_signal_connect (rdisc, - NM_RDISC_CONFIG_CHANGED, - G_CALLBACK (rdisc_config_changed), + ndisc); + g_signal_connect (ndisc, + NM_NDISC_CONFIG_RECEIVED, + G_CALLBACK (ndisc_config_changed), NULL); - g_signal_connect (rdisc, - NM_RDISC_RA_TIMEOUT, - G_CALLBACK (rdisc_ra_timeout), + g_signal_connect (ndisc, + NM_NDISC_RA_TIMEOUT, + G_CALLBACK (ndisc_ra_timeout), NULL); - nm_rdisc_start (rdisc); + nm_ndisc_start (ndisc); } sd_id = nm_sd_event_attach_default (); - g_main_loop_run (main_loop); + g_main_loop_run (gl.main_loop); g_clear_pointer (&hwaddr, g_byte_array_unref); if (pidfile && wrote_pidfile) unlink (pidfile); - nm_log_info (LOGD_CORE, "exiting"); + _LOGI (LOGD_CORE, "exiting"); nm_clear_g_source (&sd_id); - exit (0); + g_clear_pointer (&gl.main_loop, g_main_loop_unref); + return 0; } -/*******************************************************/ +/*****************************************************************************/ + +const NMDhcpClientFactory *const _nm_dhcp_manager_factories[3] = { + &_nm_dhcp_client_factory_internal, +}; + +/*****************************************************************************/ /* Stub functions */ +#include "nm-config.h" +#include "devices/nm-device.h" +#include "nm-active-connection.h" +#include "nm-bus-manager.h" + void nm_main_config_reload (int signal) { - nm_log_info (LOGD_CORE, "reloading configuration not supported"); + _LOGI (LOGD_CORE, "reloading configuration not supported"); } -gconstpointer nm_config_get (void); -const char *nm_config_get_dhcp_client (gpointer unused); -gboolean nm_config_get_configure_and_quit (gpointer unused); -gconstpointer nm_bus_manager_get (void); -void nm_bus_manager_register_object (gpointer unused, gpointer object); -void nm_bus_manager_unregister_object (gpointer unused, gpointer object); -GType nm_device_get_type (void); -GType nm_active_connection_get_type (void); - -gconstpointer +NMConfig * nm_config_get (void) { return GUINT_TO_POINTER (1); } -const char * -nm_config_get_dhcp_client (gpointer unused) +NMConfigData * +nm_config_get_data_orig (NMConfig *config) +{ + return GUINT_TO_POINTER (1); +} + +char * +nm_config_data_get_value (const NMConfigData *config_data, const char *group, const char *key, NMConfigGetValueFlags flags) { - return "internal"; + return NULL; } gboolean -nm_config_get_configure_and_quit (gpointer unused) +nm_config_get_configure_and_quit (NMConfig *config) { return TRUE; } -gconstpointer +NMBusManager * nm_bus_manager_get (void) { return GUINT_TO_POINTER (1); } void -nm_bus_manager_register_object (gpointer unused, gpointer object) +nm_bus_manager_register_object (NMBusManager *bus_manager, + GDBusObjectSkeleton *object) { } void -nm_bus_manager_unregister_object (gpointer unused, gpointer object) +nm_bus_manager_unregister_object (NMBusManager *bus_manager, + GDBusObjectSkeleton *object) { } diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 7b422359..1486edcc 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -27,34 +27,57 @@ #include #include "nm-utils.h" -#include "nm-platform.h" -#include "nm-platform-utils.h" +#include "platform/nm-platform.h" +#include "platform/nm-platform-utils.h" #include "NetworkManagerUtils.h" #include "nm-route-manager.h" #include "nm-core-internal.h" -#include "nmdbus-ip4-config.h" +#include "introspection/org.freedesktop.NetworkManager.IP4Config.h" + +/*****************************************************************************/ + +/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */ +G_STATIC_ASSERT (sizeof (uint) >= sizeof (guint32)); +G_STATIC_ASSERT (G_MAXUINT >= 0xFFFFFFFF); + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE (NMIP4Config, + PROP_IFINDEX, + PROP_ADDRESS_DATA, + PROP_ADDRESSES, + PROP_ROUTE_DATA, + PROP_ROUTES, + PROP_GATEWAY, + PROP_NAMESERVERS, + PROP_DOMAINS, + PROP_SEARCHES, + PROP_DNS_OPTIONS, + PROP_WINS_SERVERS, + PROP_DNS_PRIORITY, +); typedef struct { - gboolean never_default; + bool never_default:1; + bool metered:1; + bool has_gateway:1; guint32 gateway; - gboolean has_gateway; + guint32 mss; + guint32 mtu; + int ifindex; + NMIPConfigSource mtu_source; + gint dns_priority; + gint64 route_metric; GArray *addresses; GArray *routes; GArray *nameservers; GPtrArray *domains; GPtrArray *searches; GPtrArray *dns_options; - guint32 mss; GArray *nis; char *nis_domain; GArray *wins; - guint32 mtu; - NMIPConfigSource mtu_source; - int ifindex; - gint64 route_metric; - gboolean metered; - gint dns_priority; GVariant *address_data_variant; GVariant *addresses_variant; } NMIP4ConfigPrivate; @@ -72,33 +95,7 @@ G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT) #define NM_IP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP4Config, NM_IS_IP4_CONFIG) -/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */ -G_STATIC_ASSERT (sizeof (uint) >= sizeof (guint32)); -G_STATIC_ASSERT (G_MAXUINT >= 0xFFFFFFFF); - -NM_GOBJECT_PROPERTIES_DEFINE (NMIP4Config, - PROP_IFINDEX, - PROP_ADDRESS_DATA, - PROP_ADDRESSES, - PROP_ROUTE_DATA, - PROP_ROUTES, - PROP_GATEWAY, - PROP_NAMESERVERS, - PROP_DOMAINS, - PROP_SEARCHES, - PROP_DNS_OPTIONS, - PROP_WINS_SERVERS, - PROP_DNS_PRIORITY, -); - -NMIP4Config * -nm_ip4_config_new (int ifindex) -{ - g_return_val_if_fail (ifindex >= -1, NULL); - return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG, - NM_IP4_CONFIG_IFINDEX, ifindex, - NULL); -} +/*****************************************************************************/ int nm_ip4_config_get_ifindex (const NMIP4Config *config) @@ -106,7 +103,7 @@ nm_ip4_config_get_ifindex (const NMIP4Config *config) return NM_IP4_CONFIG_GET_PRIVATE (config)->ifindex; } -/******************************************************************/ +/*****************************************************************************/ static gboolean _ipv4_is_zeronet (in_addr_t network) @@ -115,7 +112,7 @@ _ipv4_is_zeronet (in_addr_t network) return (network & htonl(0xff000000)) == htonl(0x00000000); } -/******************************************************************/ +/*****************************************************************************/ /** * nm_ip4_config_capture_resolv_conf(): @@ -640,7 +637,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config) return NM_SETTING (s_ip4); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFlags merge_flags) @@ -705,9 +702,11 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl nm_ip4_config_set_mss (dst, nm_ip4_config_get_mss (src)); /* MTU */ - if (nm_ip4_config_get_mtu (src)) - nm_ip4_config_set_mtu (dst, nm_ip4_config_get_mtu (src), - nm_ip4_config_get_mtu_source (src)); + if ( src_priv->mtu_source > dst_priv->mtu_source + || ( src_priv->mtu_source == dst_priv->mtu_source + && ( (!dst_priv->mtu && src_priv->mtu) + || (dst_priv->mtu && src_priv->mtu < dst_priv->mtu)))) + nm_ip4_config_set_mtu (dst, src_priv->mtu, src_priv->mtu_source); /* NIS */ if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { @@ -735,7 +734,7 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl g_object_thaw_notify (G_OBJECT (dst)); } -/*******************************************************************************/ +/*****************************************************************************/ static int _addresses_get_index (const NMIP4Config *self, const NMPlatformIP4Address *addr) @@ -858,7 +857,7 @@ _wins_get_index (const NMIP4Config *self, guint32 wins_server) return -1; } -/*******************************************************************************/ +/*****************************************************************************/ /** * nm_ip4_config_subtract: @@ -935,7 +934,8 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src) nm_ip4_config_set_mss (dst, 0); /* MTU */ - if (nm_ip4_config_get_mtu (src) == nm_ip4_config_get_mtu (dst)) + if ( nm_ip4_config_get_mtu (src) == nm_ip4_config_get_mtu (dst) + && nm_ip4_config_get_mtu_source (src) == nm_ip4_config_get_mtu_source (dst)) nm_ip4_config_set_mtu (dst, 0, NM_IP_CONFIG_SOURCE_UNKNOWN); /* NIS */ @@ -1255,7 +1255,8 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev } /* mtu */ - if (src_priv->mtu != dst_priv->mtu) { + if ( src_priv->mtu != dst_priv->mtu + || src_priv->mtu_source != dst_priv->mtu_source) { nm_ip4_config_set_mtu (dst, src_priv->mtu, src_priv->mtu_source); has_minor_changes = TRUE; } @@ -1332,7 +1333,7 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail) g_message (" dnspri: %d", nm_ip4_config_get_dns_priority (config)); g_message (" mss: %"G_GUINT32_FORMAT, nm_ip4_config_get_mss (config)); - g_message (" mtu: %"G_GUINT32_FORMAT, nm_ip4_config_get_mtu (config)); + g_message (" mtu: %"G_GUINT32_FORMAT" (source: %d)", nm_ip4_config_get_mtu (config), (int) nm_ip4_config_get_mtu_source (config)); /* NIS */ for (i = 0; i < nm_ip4_config_get_num_nis_servers (config); i++) { @@ -1378,14 +1379,14 @@ nm_ip4_config_destination_is_direct (const NMIP4Config *config, guint32 network, return FALSE; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); - priv->never_default = !!never_default; + priv->never_default = never_default; } gboolean @@ -1454,7 +1455,7 @@ nm_ip4_config_get_route_metric (const NMIP4Config *config) return priv->route_metric; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_addresses (NMIP4Config *config) @@ -1558,7 +1559,7 @@ nm_ip4_config_address_exists (const NMIP4Config *config, return _addresses_get_index (config, needle) >= 0; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_routes (NMIP4Config *config) @@ -1673,7 +1674,7 @@ nm_ip4_config_get_direct_route_for_host (const NMIP4Config *config, guint32 host return best_route; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_nameservers (NMIP4Config *config) @@ -1729,7 +1730,7 @@ nm_ip4_config_get_nameserver (const NMIP4Config *config, guint i) return g_array_index (priv->nameservers, guint32, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_domains (NMIP4Config *config) @@ -1786,7 +1787,7 @@ nm_ip4_config_get_domain (const NMIP4Config *config, guint i) return g_ptr_array_index (priv->domains, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_searches (NMIP4Config *config) @@ -1858,7 +1859,7 @@ nm_ip4_config_get_search (const NMIP4Config *config, guint i) return g_ptr_array_index (priv->searches, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_dns_options (NMIP4Config *config) @@ -1915,7 +1916,7 @@ nm_ip4_config_get_dns_option (const NMIP4Config *config, guint i) return g_ptr_array_index (priv->dns_options, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_set_dns_priority (NMIP4Config *config, gint priority) @@ -1936,7 +1937,7 @@ nm_ip4_config_get_dns_priority (const NMIP4Config *config) return priv->dns_priority; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss) @@ -1954,7 +1955,7 @@ nm_ip4_config_get_mss (const NMIP4Config *config) return priv->mss; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_nis_servers (NMIP4Config *config) @@ -2020,7 +2021,7 @@ nm_ip4_config_get_nis_domain (const NMIP4Config *config) return priv->nis_domain; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_reset_wins (NMIP4Config *config) @@ -2076,18 +2077,18 @@ nm_ip4_config_get_wins (const NMIP4Config *config, guint i) return g_array_index (priv->wins, guint32, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu, NMIPConfigSource source) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (source > priv->mtu_source) { - priv->mtu = mtu; - priv->mtu_source = source; - } else if (source == priv->mtu_source && (!priv->mtu || priv->mtu > mtu)) - priv->mtu = mtu; + if (!mtu) + source = NM_IP_CONFIG_SOURCE_UNKNOWN; + + priv->mtu = mtu; + priv->mtu_source = source; } guint32 @@ -2106,14 +2107,14 @@ nm_ip4_config_get_mtu_source (const NMIP4Config *config) return priv->mtu_source; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip4_config_set_metered (NMIP4Config *config, gboolean metered) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); - priv->metered = !!metered; + priv->metered = metered; } gboolean @@ -2124,7 +2125,7 @@ nm_ip4_config_get_metered (const NMIP4Config *config) return priv->metered; } -/******************************************************************/ +/*****************************************************************************/ static inline void hash_u32 (GChecksum *sum, guint32 n) @@ -2231,44 +2232,7 @@ nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b) return equal; } -/******************************************************************/ - -static void -nm_ip4_config_init (NMIP4Config *config) -{ - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); - - priv->addresses = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Address)); - priv->routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route)); - priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32)); - priv->domains = g_ptr_array_new_with_free_func (g_free); - priv->searches = g_ptr_array_new_with_free_func (g_free); - priv->dns_options = g_ptr_array_new_with_free_func (g_free); - priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32)); - priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32)); - priv->route_metric = -1; -} - -static void -finalize (GObject *object) -{ - NMIP4Config *self = NM_IP4_CONFIG (object); - NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self); - - nm_clear_g_variant (&priv->address_data_variant); - nm_clear_g_variant (&priv->addresses_variant); - g_array_unref (priv->addresses); - g_array_unref (priv->routes); - g_array_unref (priv->nameservers); - g_ptr_array_unref (priv->domains); - g_ptr_array_unref (priv->searches); - g_ptr_array_unref (priv->dns_options); - g_array_unref (priv->nis); - g_free (priv->nis_domain); - g_array_unref (priv->wins); - - G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object); -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, @@ -2459,6 +2423,7 @@ set_property (GObject *object, switch (prop_id) { case PROP_IFINDEX: + /* construct-only */ priv->ifindex = g_value_get_int (value); break; default: @@ -2467,13 +2432,61 @@ set_property (GObject *object, } } +/*****************************************************************************/ + +static void +nm_ip4_config_init (NMIP4Config *config) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + + priv->addresses = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Address)); + priv->routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route)); + priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32)); + priv->domains = g_ptr_array_new_with_free_func (g_free); + priv->searches = g_ptr_array_new_with_free_func (g_free); + priv->dns_options = g_ptr_array_new_with_free_func (g_free); + priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32)); + priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32)); + priv->route_metric = -1; +} + +NMIP4Config * +nm_ip4_config_new (int ifindex) +{ + g_return_val_if_fail (ifindex >= -1, NULL); + return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG, + NM_IP4_CONFIG_IFINDEX, ifindex, + NULL); +} + +static void +finalize (GObject *object) +{ + NMIP4Config *self = NM_IP4_CONFIG (object); + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self); + + nm_clear_g_variant (&priv->address_data_variant); + nm_clear_g_variant (&priv->addresses_variant); + g_array_unref (priv->addresses); + g_array_unref (priv->routes); + g_array_unref (priv->nameservers); + g_ptr_array_unref (priv->domains); + g_ptr_array_unref (priv->searches); + g_ptr_array_unref (priv->dns_options); + g_array_unref (priv->nis); + g_free (priv->nis_domain); + g_array_unref (priv->wins); + + G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object); +} + static void nm_ip4_config_class_init (NMIP4ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); - exported_object_class->export_path = NM_DBUS_PATH "/IP4Config/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP4Config"); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h index 6fc45dc2..58ee4a7d 100644 --- a/src/nm-ip4-config.h +++ b/src/nm-ip4-config.h @@ -150,7 +150,7 @@ gboolean nm_ip4_config_get_metered (const NMIP4Config *config); void nm_ip4_config_hash (const NMIP4Config *config, GChecksum *sum, gboolean dns_only); gboolean nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b); -/******************************************************/ +/*****************************************************************************/ /* Testing-only functions */ gboolean nm_ip4_config_capture_resolv_conf (GArray *nameservers, GPtrArray *dns_options, diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index a0211246..c90d04aa 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -27,16 +27,23 @@ #include #include "nm-utils.h" -#include "nm-platform.h" -#include "nm-platform-utils.h" +#include "platform/nm-platform.h" +#include "platform/nm-platform-utils.h" #include "nm-route-manager.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" -#include "nmdbus-ip6-config.h" +#include "introspection/org.freedesktop.NetworkManager.IP6Config.h" + +/*****************************************************************************/ typedef struct { - gboolean never_default; + bool never_default:1; + guint32 mss; + int ifindex; + int dns_priority; + NMSettingIP6ConfigPrivacy privacy; + gint64 route_metric; struct in6_addr gateway; GArray *addresses; GArray *routes; @@ -44,13 +51,8 @@ typedef struct { GPtrArray *domains; GPtrArray *searches; GPtrArray *dns_options; - guint32 mss; - int ifindex; - gint64 route_metric; - gint dns_priority; GVariant *address_data_variant; GVariant *addresses_variant; - NMSettingIP6ConfigPrivacy privacy; } NMIP6ConfigPrivate; struct _NMIP6Config { @@ -80,26 +82,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMIP6Config, PROP_DNS_PRIORITY, ); -NMIP6Config * -nm_ip6_config_new (int ifindex) -{ - g_return_val_if_fail (ifindex >= -1, NULL); - return (NMIP6Config *) g_object_new (NM_TYPE_IP6_CONFIG, - NM_IP6_CONFIG_IFINDEX, ifindex, - NULL); -} - -NMIP6Config * -nm_ip6_config_new_cloned (const NMIP6Config *src) -{ - NMIP6Config *new; - - g_return_val_if_fail (NM_IS_IP6_CONFIG (src), NULL); - - new = nm_ip6_config_new (nm_ip6_config_get_ifindex (src)); - nm_ip6_config_replace (new, src, NULL); - return new; -} +/*****************************************************************************/ int nm_ip6_config_get_ifindex (const NMIP6Config *config) @@ -661,7 +644,7 @@ nm_ip6_config_create_setting (const NMIP6Config *config) return NM_SETTING (s_ip6); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFlags merge_flags) @@ -752,7 +735,7 @@ nm_ip6_config_destination_is_direct (const NMIP6Config *config, const struct in6 return FALSE; } -/*******************************************************************************/ +/*****************************************************************************/ static int _addresses_get_index (const NMIP6Config *self, const NMPlatformIP6Address *addr) @@ -844,7 +827,7 @@ _dns_options_get_index (const NMIP6Config *self, const char *option) return -1; } -/*******************************************************************************/ +/*****************************************************************************/ /** * nm_ip6_config_subtract: @@ -1249,14 +1232,14 @@ nm_ip6_config_dump (const NMIP6Config *config, const char *detail) g_message (" n-dflt: %d", nm_ip6_config_get_never_default (config)); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_default) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); - priv->never_default = !!never_default; + priv->never_default = never_default; } gboolean @@ -1300,7 +1283,7 @@ nm_ip6_config_get_route_metric (const NMIP6Config *config) return priv->route_metric; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_reset_addresses (NMIP6Config *config) @@ -1468,7 +1451,7 @@ nm_ip6_config_has_any_dad_pending (const NMIP6Config *self, return FALSE; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_reset_routes (NMIP6Config *config) @@ -1611,7 +1594,7 @@ nm_ip6_config_get_subnet_for_host (const NMIP6Config *config, const struct in6_a } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_reset_nameservers (NMIP6Config *config) @@ -1667,7 +1650,7 @@ nm_ip6_config_get_nameserver (const NMIP6Config *config, guint i) return &g_array_index (priv->nameservers, struct in6_addr, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_reset_domains (NMIP6Config *config) @@ -1724,7 +1707,7 @@ nm_ip6_config_get_domain (const NMIP6Config *config, guint i) return g_ptr_array_index (priv->domains, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_reset_searches (NMIP6Config *config) @@ -1796,7 +1779,7 @@ nm_ip6_config_get_search (const NMIP6Config *config, guint i) return g_ptr_array_index (priv->searches, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_reset_dns_options (NMIP6Config *config) @@ -1853,7 +1836,7 @@ nm_ip6_config_get_dns_option (const NMIP6Config *config, guint i) return g_ptr_array_index (priv->dns_options, i); } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_set_dns_priority (NMIP6Config *config, gint priority) @@ -1874,7 +1857,7 @@ nm_ip6_config_get_dns_priority (const NMIP6Config *config) return priv->dns_priority; } -/******************************************************************/ +/*****************************************************************************/ void nm_ip6_config_set_mss (NMIP6Config *config, guint32 mss) @@ -1892,7 +1875,7 @@ nm_ip6_config_get_mss (const NMIP6Config *config) return priv->mss; } -/******************************************************************/ +/*****************************************************************************/ static inline void hash_u32 (GChecksum *sum, guint32 n) @@ -1997,39 +1980,7 @@ nm_ip6_config_equal (const NMIP6Config *a, const NMIP6Config *b) return equal; } -/******************************************************************/ - -static void -nm_ip6_config_init (NMIP6Config *config) -{ - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); - - priv->addresses = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Address)); - priv->routes = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Route)); - priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr)); - priv->domains = g_ptr_array_new_with_free_func (g_free); - priv->searches = g_ptr_array_new_with_free_func (g_free); - priv->dns_options = g_ptr_array_new_with_free_func (g_free); - priv->route_metric = -1; -} - -static void -finalize (GObject *object) -{ - NMIP6Config *self = NM_IP6_CONFIG (object); - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self); - - g_array_unref (priv->addresses); - g_array_unref (priv->routes); - g_array_unref (priv->nameservers); - g_ptr_array_unref (priv->domains); - g_ptr_array_unref (priv->searches); - g_ptr_array_unref (priv->dns_options); - nm_clear_g_variant (&priv->address_data_variant); - nm_clear_g_variant (&priv->addresses_variant); - - G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object); -} +/*****************************************************************************/ static void nameservers_to_gvalue (GArray *array, GValue *value) @@ -2223,6 +2174,7 @@ set_property (GObject *object, switch (prop_id) { case PROP_IFINDEX: + /* construct-only */ priv->ifindex = g_value_get_int (value); break; default: @@ -2231,20 +2183,73 @@ set_property (GObject *object, } } +/*****************************************************************************/ + +static void +nm_ip6_config_init (NMIP6Config *config) +{ + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); + + priv->addresses = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Address)); + priv->routes = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Route)); + priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr)); + priv->domains = g_ptr_array_new_with_free_func (g_free); + priv->searches = g_ptr_array_new_with_free_func (g_free); + priv->dns_options = g_ptr_array_new_with_free_func (g_free); + priv->route_metric = -1; +} + +NMIP6Config * +nm_ip6_config_new (int ifindex) +{ + g_return_val_if_fail (ifindex >= -1, NULL); + return (NMIP6Config *) g_object_new (NM_TYPE_IP6_CONFIG, + NM_IP6_CONFIG_IFINDEX, ifindex, + NULL); +} + +NMIP6Config * +nm_ip6_config_new_cloned (const NMIP6Config *src) +{ + NMIP6Config *new; + + g_return_val_if_fail (NM_IS_IP6_CONFIG (src), NULL); + + new = nm_ip6_config_new (nm_ip6_config_get_ifindex (src)); + nm_ip6_config_replace (new, src, NULL); + return new; +} + +static void +finalize (GObject *object) +{ + NMIP6Config *self = NM_IP6_CONFIG (object); + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self); + + g_array_unref (priv->addresses); + g_array_unref (priv->routes); + g_array_unref (priv->nameservers); + g_ptr_array_unref (priv->domains); + g_ptr_array_unref (priv->searches); + g_ptr_array_unref (priv->dns_options); + nm_clear_g_variant (&priv->address_data_variant); + nm_clear_g_variant (&priv->addresses_variant); + + G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object); +} + static void nm_ip6_config_class_init (NMIP6ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (config_class); - exported_object_class->export_path = NM_DBUS_PATH "/IP6Config/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP6Config"); - /* virtual methods */ object_class->get_property = get_property; object_class->set_property = set_property; object_class->finalize = finalize; - /* properties */ obj_properties[PROP_IFINDEX] = g_param_spec_int (NM_IP6_CONFIG_IFINDEX, "", "", -1, G_MAXINT, -1, diff --git a/src/nm-ip6-config.h b/src/nm-ip6-config.h index 9454c0f7..c196421b 100644 --- a/src/nm-ip6-config.h +++ b/src/nm-ip6-config.h @@ -136,6 +136,7 @@ gboolean nm_ip6_config_equal (const NMIP6Config *a, const NMIP6Config *b); void nm_ip6_config_set_privacy (NMIP6Config *config, NMSettingIP6ConfigPrivacy privacy); +/*****************************************************************************/ /* Testing-only functions */ gboolean nm_ip6_config_capture_resolv_conf (GArray *nameservers, diff --git a/src/nm-logging.c b/src/nm-logging.c index 6ecc1606..c242d903 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -40,6 +40,17 @@ #include "nm-errors.h" #include "nm-core-utils.h" +/* often we have some static string where we need to know the maximum length. + * _MAX_LEN() returns @max but adds a debugging assertion that @str is indeed + * shorter then @mac. */ +#define _MAX_LEN(max, str) \ + ({ \ + const char *const _str = (str); \ + \ + nm_assert (_str && strlen (str) < (max)); \ + (max); \ + }) + void (*_nm_logging_clear_platform_logging_cache) (void); static void @@ -79,9 +90,12 @@ NMLogDomain _nm_logging_enabled_state[_LOGL_N_REAL] = { [LOGL_ERR] = LOGD_DEFAULT, }; -static struct { +static struct Global { NMLogLevel log_level; bool uses_syslog:1; + bool syslog_identifier_initialized:1; + const char *prefix; + const char *syslog_identifier; enum { LOG_BACKEND_GLIB, LOG_BACKEND_SYSLOG, @@ -90,7 +104,7 @@ static struct { char *logging_domains_to_string; const LogLevelDesc level_desc[_LOGL_N]; -#define _DOMAIN_DESC_LEN 38 +#define _DOMAIN_DESC_LEN 39 /* Would be nice to use C99 flexible array member here, * but that feature doesn't seem well supported. */ const LogDesc domain_desc[_DOMAIN_DESC_LEN]; @@ -98,6 +112,8 @@ static struct { /* nm_logging_setup ("INFO", LOGD_DEFAULT_STRING, NULL, NULL); */ .log_level = LOGL_INFO, .log_backend = LOG_BACKEND_GLIB, + .syslog_identifier = "SYSLOG_IDENTIFIER="G_LOG_DOMAIN, + .prefix = "", .level_desc = { [LOGL_TRACE] = { "TRACE", "", LOG_DEBUG, G_LOG_LEVEL_DEBUG, }, [LOGL_DEBUG] = { "DEBUG", "", LOG_DEBUG, G_LOG_LEVEL_DEBUG, }, @@ -145,6 +161,7 @@ static struct { { LOGD_AUDIT, "AUDIT" }, { LOGD_SYSTEMD, "SYSTEMD" }, { LOGD_VPN_PLUGIN,"VPN_PLUGIN" }, + { LOGD_PROXY, "PROXY" }, { 0, NULL } /* keep _DOMAIN_DESC_LEN in sync */ }, @@ -159,11 +176,77 @@ G_STATIC_ASSERT (sizeof (NMLogDomain) >= sizeof (guint64)); #define LOGD_DHCP_STRING "DHCP" #define LOGD_IP_STRING "IP" -/************************************************************************/ +/*****************************************************************************/ static char *_domains_to_string (gboolean include_level_override); -/************************************************************************/ +/*****************************************************************************/ + +static gboolean +_syslog_identifier_valid_domain (const char *domain) +{ + char c; + + if (!domain || !domain[0]) + return FALSE; + + /* we pass the syslog identifier as format string. No funny stuff. */ + + for (; (c = domain[0]); domain++) { + if ( (c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') + || NM_IN_SET (c, '-', '_')) + continue; + return FALSE; + } + return TRUE; +} + +static gboolean +_syslog_identifier_assert (const struct Global *gl) +{ + g_assert (gl); + g_assert (gl->syslog_identifier); + g_assert (g_str_has_prefix (gl->syslog_identifier, "SYSLOG_IDENTIFIER=")); + g_assert (_syslog_identifier_valid_domain (&gl->syslog_identifier[NM_STRLEN ("SYSLOG_IDENTIFIER=")])); + return TRUE; +} + +static const char * +syslog_identifier_domain (const struct Global *gl) +{ + nm_assert (_syslog_identifier_assert (gl)); + return &gl->syslog_identifier[NM_STRLEN ("SYSLOG_IDENTIFIER=")]; +} + +#if SYSTEMD_JOURNAL +static const char * +syslog_identifier_full (const struct Global *gl) +{ + nm_assert (_syslog_identifier_assert (gl)); + return &gl->syslog_identifier[0]; +} +#endif + +void +nm_logging_set_syslog_identifier (const char *domain) +{ + if (global.log_backend != LOG_BACKEND_GLIB) + g_return_if_reached (); + + if (!_syslog_identifier_valid_domain (domain)) + g_return_if_reached (); + + if (global.syslog_identifier_initialized) + g_return_if_reached (); + + global.syslog_identifier_initialized = TRUE; + global.syslog_identifier = g_strdup_printf ("SYSLOG_IDENTIFIER=%s", domain); + nm_assert (_syslog_identifier_assert (&global)); +} + +/*****************************************************************************/ static gboolean match_log_level (const char *level, @@ -246,6 +329,13 @@ nm_logging_setup (const char *level, bits = 0; + if (domains_free) { + /* The caller didn't provide any domains to set (`nmcli general logging level DEBUG`). + * We reset all domains that were previously set, but we still want to protect + * VPN_PLUGIN domain. */ + protect = LOGD_VPN_PLUGIN; + } + /* Check for combined domains */ if (!g_ascii_strcasecmp (*iter, LOGD_ALL_STRING)) { bits = LOGD_ALL; @@ -297,7 +387,7 @@ nm_logging_setup (const char *level, new_logging[i] &= ~bits; else { new_logging[i] |= bits; - if ( protect + if ( (protect & bits) && i < LOGL_INFO) new_logging[i] &= ~protect; } @@ -452,9 +542,22 @@ nm_logging_get_level (NMLogDomain domain) } #if SYSTEMD_JOURNAL -_nm_printf (4, 5) static void -_iovec_set_format (struct iovec *iov, gboolean *iov_free, int i, const char *format, ...) +_iovec_set (struct iovec *iov, const void *str, gsize len) +{ + iov->iov_base = (void *) str; + iov->iov_len = len; +} + +static void +_iovec_set_string (struct iovec *iov, const char *str) +{ + _iovec_set (iov, str, strlen (str)); +} + +_nm_printf (3, 4) +static void +_iovec_set_format (struct iovec *iov, gpointer *iov_free, const char *format, ...) { va_list ap; char *str; @@ -463,19 +566,24 @@ _iovec_set_format (struct iovec *iov, gboolean *iov_free, int i, const char *for str = g_strdup_vprintf (format, ap); va_end (ap); - iov[i].iov_base = str; - iov[i].iov_len = strlen (str); - iov_free[i] = TRUE; + _iovec_set_string (iov, str); + *iov_free = str; } -static void -_iovec_set_string (struct iovec *iov, gboolean *iov_free, int i, const char *str, gsize len) -{ - iov[i].iov_base = (char *) str; - iov[i].iov_len = len; - iov_free[i] = FALSE; -} -#define _iovec_set_literal_string(iov, iov_free, i, str) _iovec_set_string ((iov), (iov_free), (i), (""str""), NM_STRLEN (str)) +#define _iovec_set_format_a(iov, reserve_extra, format, ...) \ + G_STMT_START { \ + const gsize _size = (reserve_extra) + (NM_STRLEN (format) + 3); \ + char *const _buf = g_alloca (_size); \ + int _len; \ + \ + _len = g_snprintf (_buf, _size, ""format"", ##__VA_ARGS__);\ + \ + nm_assert (_len >= 0); \ + nm_assert (_len <= _size); \ + nm_assert (_len == strlen (_buf)); \ + \ + _iovec_set ((iov), _buf, _len); \ + } G_STMT_END #endif void @@ -490,9 +598,8 @@ _nm_log_impl (const char *file, { va_list args; char *msg; - char *fullmsg; - char s_buf_timestamp[64]; GTimeVal tv; + int errno_saved; if ((guint) level >= G_N_ELEMENTS (_nm_logging_enabled_state)) g_return_if_reached (); @@ -500,6 +607,8 @@ _nm_log_impl (const char *file, if (!(_nm_logging_enabled_state[level] & domain)) return; + errno_saved = errno; + /* Make sure that %m maps to the specified error */ if (error != 0) { if (error < 0) @@ -511,8 +620,15 @@ _nm_log_impl (const char *file, msg = g_strdup_vprintf (fmt, args); va_end (args); +#define MESSAGE_FMT "%s%-7s [%ld.%04ld] %s" +#define MESSAGE_ARG(global, tv, msg) \ + (global).prefix, \ + (global).level_desc[level].level_str, \ + (tv).tv_sec, \ + ((tv).tv_usec / 100), \ + (msg) + g_get_current_time (&tv); - nm_sprintf_buf (s_buf_timestamp, " [%ld.%04ld]", tv.tv_sec, tv.tv_usec / 100); switch (global.log_backend) { #if SYSTEMD_JOURNAL @@ -520,27 +636,23 @@ _nm_log_impl (const char *file, { gint64 now, boottime; #define _NUM_MAX_FIELDS_SYSLOG_FACILITY 10 -#define _NUM_FIELDS (10 + _NUM_MAX_FIELDS_SYSLOG_FACILITY) - int i_field = 0; - struct iovec iov[_NUM_FIELDS]; - gboolean iov_free[_NUM_FIELDS]; + struct iovec iov_data[12 + _NUM_MAX_FIELDS_SYSLOG_FACILITY]; + struct iovec *iov = iov_data; + gpointer iov_free_data[3]; + gpointer *iov_free = iov_free_data; + nm_auto_free_gstring GString *s_domain_all = NULL; now = nm_utils_get_monotonic_timestamp_ns (); boottime = nm_utils_monotonic_timestamp_as_boottime (now, 1); - _iovec_set_format (iov, iov_free, i_field++, "PRIORITY=%d", global.level_desc[level].syslog_level); - _iovec_set_format (iov, iov_free, i_field++, "MESSAGE=" - "%-7s%s %s", - global.level_desc[level].level_str, - s_buf_timestamp, - msg); - _iovec_set_literal_string (iov, iov_free, i_field++, "SYSLOG_IDENTIFIER=" G_LOG_DOMAIN); - _iovec_set_format (iov, iov_free, i_field++, "SYSLOG_PID=%ld", (long) getpid ()); + _iovec_set_format_a (iov++, 30, "PRIORITY=%d", global.level_desc[level].syslog_level); + _iovec_set_format (iov++, iov_free++, "MESSAGE="MESSAGE_FMT, MESSAGE_ARG (global, tv, msg)); + _iovec_set_string (iov++, syslog_identifier_full (&global)); + _iovec_set_format_a (iov++, 30, "SYSLOG_PID=%ld", (long) getpid ()); { const LogDesc *diter; int i_domain = _NUM_MAX_FIELDS_SYSLOG_FACILITY; const char *s_domain_1 = NULL; - GString *s_domain_all = NULL; NMLogDomain dom_all = domain; NMLogDomain dom = dom_all & _nm_logging_enabled_state[level]; @@ -555,8 +667,10 @@ _nm_log_impl (const char *file, if (!s_domain_1) s_domain_1 = diter->name; else { - if (!s_domain_all) - s_domain_all = g_string_new (s_domain_1); + if (!s_domain_all) { + s_domain_all = g_string_new ("NM_LOG_DOMAINS="); + g_string_append (s_domain_all, s_domain_1); + } g_string_append_c (s_domain_all, ','); g_string_append (s_domain_all, diter->name); } @@ -564,7 +678,7 @@ _nm_log_impl (const char *file, if (NM_FLAGS_HAS (dom, diter->num)) { if (i_domain > 0) { /* SYSLOG_FACILITY is specified multiple times for each domain that is actually enabled. */ - _iovec_set_format (iov, iov_free, i_field++, "SYSLOG_FACILITY=%s", diter->name); + _iovec_set_format_a (iov++, _MAX_LEN (30, diter->name), "SYSLOG_FACILITY=%s", diter->name); i_domain--; } dom &= ~diter->num; @@ -572,52 +686,47 @@ _nm_log_impl (const char *file, if (!dom && !dom_all) break; } - if (s_domain_all) { - _iovec_set_format (iov, iov_free, i_field++, "NM_LOG_DOMAINS=%s", s_domain_all->str); - g_string_free (s_domain_all, TRUE); - } else - _iovec_set_format (iov, iov_free, i_field++, "NM_LOG_DOMAINS=%s", s_domain_1); + if (s_domain_all) + _iovec_set (iov++, s_domain_all->str, s_domain_all->len); + else + _iovec_set_format_a (iov++, _MAX_LEN (30, s_domain_1), "NM_LOG_DOMAINS=%s", s_domain_1); } - _iovec_set_format (iov, iov_free, i_field++, "NM_LOG_LEVEL=%s", global.level_desc[level].name); + _iovec_set_format_a (iov++, _MAX_LEN (15, global.level_desc[level].name), "NM_LOG_LEVEL=%s", global.level_desc[level].name); if (func) - _iovec_set_format (iov, iov_free, i_field++, "CODE_FUNC=%s", func); - _iovec_set_format (iov, iov_free, i_field++, "CODE_FILE=%s", file ?: ""); - _iovec_set_format (iov, iov_free, i_field++, "CODE_LINE=%u", line); - _iovec_set_format (iov, iov_free, i_field++, "TIMESTAMP_MONOTONIC=%lld.%06lld", (long long) (now / NM_UTILS_NS_PER_SECOND), (long long) ((now % NM_UTILS_NS_PER_SECOND) / 1000)); - _iovec_set_format (iov, iov_free, i_field++, "TIMESTAMP_BOOTTIME=%lld.%06lld", (long long) (boottime / NM_UTILS_NS_PER_SECOND), (long long) ((boottime % NM_UTILS_NS_PER_SECOND) / 1000)); + _iovec_set_format (iov++, iov_free++, "CODE_FUNC=%s", func); + _iovec_set_format (iov++, iov_free++, "CODE_FILE=%s", file ?: ""); + _iovec_set_format_a (iov++, 20, "CODE_LINE=%u", line); + _iovec_set_format_a (iov++, 60, "TIMESTAMP_MONOTONIC=%lld.%06lld", (long long) (now / NM_UTILS_NS_PER_SECOND), (long long) ((now % NM_UTILS_NS_PER_SECOND) / 1000)); + _iovec_set_format_a (iov++, 60, "TIMESTAMP_BOOTTIME=%lld.%06lld", (long long) (boottime / NM_UTILS_NS_PER_SECOND), (long long) ((boottime % NM_UTILS_NS_PER_SECOND) / 1000)); if (error != 0) - _iovec_set_format (iov, iov_free, i_field++, "ERRNO=%d", error); + _iovec_set_format_a (iov++, 30, "ERRNO=%d", error); - nm_assert (i_field <= G_N_ELEMENTS (iov)); + nm_assert (iov <= &iov_data[G_N_ELEMENTS (iov_data)]); + nm_assert (iov_free <= &iov_free_data[G_N_ELEMENTS (iov_free_data)]); - sd_journal_sendv (iov, i_field); + sd_journal_sendv (iov_data, iov - iov_data); - for (; i_field > 0; ) { - i_field--; - if (iov_free[i_field]) - g_free (iov[i_field].iov_base); - } + for (; --iov_free >= iov_free_data; ) + g_free (*iov_free); } break; #endif + case LOG_BACKEND_SYSLOG: + syslog (global.level_desc[level].syslog_level, + MESSAGE_FMT, MESSAGE_ARG (global, tv, msg)); + break; default: - fullmsg = g_strdup_printf ("%-7s%s %s", - global.level_desc[level].level_str, - s_buf_timestamp, - msg); - - if (global.log_backend == LOG_BACKEND_SYSLOG) - syslog (global.level_desc[level].syslog_level, "%s", fullmsg); - else - g_log (G_LOG_DOMAIN, global.level_desc[level].g_log_level, "%s", fullmsg); - g_free (fullmsg); + g_log (syslog_identifier_domain (&global), global.level_desc[level].g_log_level, + MESSAGE_FMT, MESSAGE_ARG (global, tv, msg)); break; } g_free (msg); + + errno = errno_saved; } -/************************************************************************/ +/*****************************************************************************/ static void nm_log_handler (const gchar *log_domain, @@ -659,8 +768,8 @@ nm_log_handler (const gchar *log_domain, boottime = nm_utils_monotonic_timestamp_as_boottime (now, 1); sd_journal_send ("PRIORITY=%d", syslog_priority, - "MESSAGE=%s", message ?: "", - "SYSLOG_IDENTIFIER=%s", G_LOG_DOMAIN, + "MESSAGE=%s%s", global.prefix, message ?: "", + syslog_identifier_full (&global), "SYSLOG_PID=%ld", (long) getpid (), "SYSLOG_FACILITY=GLIB", "GLIB_DOMAIN=%s", log_domain ?: "", @@ -672,7 +781,7 @@ nm_log_handler (const gchar *log_domain, break; #endif default: - syslog (syslog_priority, "%s", message ?: ""); + syslog (syslog_priority, "%s%s", global.prefix, message ?: ""); break; } } @@ -683,6 +792,30 @@ nm_logging_syslog_enabled (void) return global.uses_syslog; } +void +nm_logging_set_prefix (const char *format, ...) +{ + char *prefix; + va_list ap; + + /* prefix can only be set once, to a non-empty string. Also, after + * nm_logging_syslog_openlog() the prefix cannot be set either. */ + if (global.log_backend != LOG_BACKEND_GLIB) + g_return_if_reached (); + if (global.prefix[0]) + g_return_if_reached (); + + va_start (ap, format); + prefix = g_strdup_vprintf (format, ap); + va_end (ap); + + if (!prefix || !prefix[0]) + g_return_if_reached (); + + /* we pass the allocated string on and never free it. */ + global.prefix = prefix; +} + void nm_logging_syslog_openlog (const char *logging_backend) { @@ -690,11 +823,11 @@ nm_logging_syslog_openlog (const char *logging_backend) g_return_if_reached (); if (!logging_backend) - logging_backend = ""NM_CONFIG_LOGGING_BACKEND_DEFAULT; + logging_backend = ""NM_CONFIG_DEFAULT_LOGGING_BACKEND; if (strcmp (logging_backend, "debug") == 0) { global.log_backend = LOG_BACKEND_SYSLOG; - openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); + openlog (syslog_identifier_domain (&global), LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); #if SYSTEMD_JOURNAL } else if (strcmp (logging_backend, "syslog") != 0) { global.log_backend = LOG_BACKEND_JOURNAL; @@ -707,10 +840,10 @@ nm_logging_syslog_openlog (const char *logging_backend) } else { global.log_backend = LOG_BACKEND_SYSLOG; global.uses_syslog = TRUE; - openlog (G_LOG_DOMAIN, LOG_PID, LOG_DAEMON); + openlog (syslog_identifier_domain (&global), LOG_PID, LOG_DAEMON); } - g_log_set_handler (G_LOG_DOMAIN, + g_log_set_handler (syslog_identifier_domain (&global), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, nm_log_handler, NULL); diff --git a/src/nm-logging.h b/src/nm-logging.h index 72eb3db4..2c1a1059 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -66,6 +66,7 @@ typedef enum { /*< skip >*/ LOGD_AUDIT = (1LL << 34), LOGD_SYSTEMD = (1LL << 35), LOGD_VPN_PLUGIN = (1LL << 36), + LOGD_PROXY = (1LL << 37), __LOGD_MAX, LOGD_ALL = (((__LOGD_MAX - 1LL) << 1) - 1LL), @@ -186,6 +187,10 @@ gboolean nm_logging_setup (const char *level, const char *domains, char **bad_domains, GError **error); + +void nm_logging_set_syslog_identifier (const char *domain); +void nm_logging_set_prefix (const char *format, ...) _nm_printf (1, 2); + void nm_logging_syslog_openlog (const char *logging_backend); gboolean nm_logging_syslog_enabled (void); @@ -270,4 +275,21 @@ extern void (*_nm_logging_clear_platform_logging_cache) (void); /*****************************************************************************/ +#define __NMLOG_DEFAULT(level, domain, prefix, ...) \ + G_STMT_START { \ + nm_log ((level), (domain), \ + "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + (prefix) \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + +#define __NMLOG_DEFAULT_WITH_ADDR(level, domain, prefix, ...) \ + G_STMT_START { \ + nm_log ((level), (domain), \ + "%s[%p]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + (prefix), \ + (self) \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + #endif /* __NETWORKMANAGER_LOGGING_H__ */ diff --git a/src/nm-manager.c b/src/nm-manager.c index c3d65cd1..867e0db6 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -31,24 +31,23 @@ #include "nm-common-macros.h" #include "nm-bus-manager.h" -#include "nm-vpn-manager.h" -#include "nm-device.h" -#include "nm-device-generic.h" -#include "nm-platform.h" +#include "vpn/nm-vpn-manager.h" +#include "devices/nm-device.h" +#include "devices/nm-device-generic.h" +#include "platform/nm-platform.h" #include "nm-rfkill-manager.h" -#include "nm-dhcp-manager.h" -#include "nm-settings.h" -#include "nm-settings-connection.h" +#include "dhcp/nm-dhcp-manager.h" +#include "settings/nm-settings.h" +#include "settings/nm-settings-connection.h" #include "nm-auth-utils.h" #include "nm-auth-manager.h" #include "NetworkManagerUtils.h" -#include "nm-device-factory.h" -#include "nm-enum-types.h" +#include "devices/nm-device-factory.h" #include "nm-sleep-monitor.h" #include "nm-connectivity.h" #include "nm-policy.h" #include "nm-session-monitor.h" -#include "nm-activation-request.h" +#include "nm-act-request.h" #include "nm-core-internal.h" #include "nm-config.h" #include "nm-audit-manager.h" @@ -57,13 +56,14 @@ #include "nm-checkpoint-manager.h" #include "NetworkManagerUtils.h" -#include "nmdbus-manager.h" -#include "nmdbus-device.h" +#include "introspection/org.freedesktop.NetworkManager.h" +#include "introspection/org.freedesktop.NetworkManager.Device.h" static gboolean add_device (NMManager *self, NMDevice *device, GError **error); static NMActiveConnection *_new_active_connection (NMManager *self, NMConnection *connection, + NMConnection *applied, const char *specific_object, NMDevice *device, NMAuthSubject *subject, @@ -100,6 +100,8 @@ typedef struct { } RadioState; typedef struct { + GArray *capabilities; + GSList *active_connections; GSList *authorizing_connections; guint ac_cleanup_id; @@ -180,6 +182,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; NM_GOBJECT_PROPERTIES_DEFINE (NMManager, PROP_VERSION, + PROP_CAPABILITIES, PROP_STATE, PROP_STARTUP, PROP_NETWORKING_ENABLED, @@ -206,7 +209,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMManager, NM_DEFINE_SINGLETON_INSTANCE (NMManager); -/************************************************************************/ +/*****************************************************************************/ #define _NMLOG_PREFIX_NAME "manager" #define _NMLOG(level, domain, ...) \ @@ -228,7 +231,10 @@ NM_DEFINE_SINGLETON_INSTANCE (NMManager); } \ } G_STMT_END -/************************************************************************/ +/*****************************************************************************/ + +GQuark autoconnect_root_quark (void); +G_DEFINE_QUARK (autoconnect-root, autoconnect_root); static void active_connection_state_changed (NMActiveConnection *active, GParamSpec *pspec, @@ -312,6 +318,7 @@ active_connection_state_changed (NMActiveConnection *active, { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); NMActiveConnectionState state; + NMSettingsConnection *con; state = nm_active_connection_get_state (active); if (state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { @@ -322,6 +329,10 @@ active_connection_state_changed (NMActiveConnection *active, */ if (!priv->ac_cleanup_id) priv->ac_cleanup_id = g_idle_add (_active_connection_cleanup, self); + + con = nm_active_connection_get_settings_connection (active); + if (con) + g_object_set_qdata (G_OBJECT (con), autoconnect_root_quark (), NULL); } nm_manager_update_state (self); @@ -456,7 +467,7 @@ active_connection_get_by_path (NMManager *manager, const char *path) return NULL; } -/************************************************************************/ +/*****************************************************************************/ static void _config_changed_cb (NMConfig *config, NMConfigData *config_data, NMConfigChangeFlags changes, NMConfigData *old_data, NMManager *self) @@ -569,7 +580,7 @@ impl_manager_reload (NMManager *self, nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_RELOAD, TRUE); } -/************************************************************************/ +/*****************************************************************************/ NMDevice * nm_manager_get_device_by_path (NMManager *manager, const char *path) @@ -938,6 +949,26 @@ settings_startup_complete_changed (NMSettings *settings, check_if_startup_complete (self); } +static void +_parent_notify_changed (NMManager *self, + NMDevice *device, + gboolean device_removed) +{ + GSList *iter; + + nm_assert (NM_IS_DEVICE (device)); + nm_assert (NM_IS_MANAGER (self)); + + for (iter = NM_MANAGER_GET_PRIVATE (self)->devices; iter; ) { + if (nm_device_parent_notify_changed (iter->data, device, device_removed)) { + /* in the unlikely event that this changes anything, we start iterating + * again, to be sure that the device list is up-to-date. */ + iter = NM_MANAGER_GET_PRIVATE (self)->devices; + } else + iter = iter->next; + } +} + static void remove_device (NMManager *self, NMDevice *device, @@ -974,6 +1005,8 @@ remove_device (NMManager *self, nm_settings_device_removed (priv->settings, device, quitting); priv->devices = g_slist_remove (priv->devices, device); + _parent_notify_changed (self, device, TRUE); + if (nm_device_is_real (device)) { gboolean unconfigure_ip_config = !quitting || unmanage; @@ -1013,7 +1046,7 @@ nm_manager_get_state (NMManager *manager) return NM_MANAGER_GET_PRIVATE (manager)->state; } -/***************************/ +/*****************************************************************************/ static NMDevice * find_parent_device_for_connection (NMManager *self, NMConnection *connection, NMDeviceFactory *cached_factory) @@ -1108,7 +1141,7 @@ nm_manager_get_connection_iface (NMManager *self, } if ( !out_parent - && !NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_connection_iface) { + && !NM_DEVICE_FACTORY_GET_CLASS (factory)->get_connection_iface) { /* optimization. Shortcut lookup of the partent device. */ iface = g_strdup (nm_connection_get_interface_name (connection)); if (!iface) { @@ -1134,6 +1167,30 @@ nm_manager_get_connection_iface (NMManager *self, return iface; } +/** + * nm_manager_iface_for_uuid: + * @self: the #NMManager + * @uuid: the connection uuid + * + * Gets a link name for the given UUID. Useful for the settings plugins that + * wish to write configuration files compatible with tooling that can't + * interpret our UUIDs. + * + * Returns: An interface name; %NULL if none matches + */ +const char * +nm_manager_iface_for_uuid (NMManager *self, const char *uuid) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + NMSettingsConnection *connection; + + connection = nm_settings_get_connection_by_uuid (priv->settings, uuid); + if (!connection) + return NULL; + + return nm_connection_get_interface_name (NM_CONNECTION (connection)); +} + /** * system_create_virtual_device: * @self: the #NMManager @@ -1358,9 +1415,9 @@ system_hostname_changed_cb (NMSettings *settings, nm_dhcp_manager_set_default_hostname (nm_dhcp_manager_get (), priv->hostname); } -/*******************************************************************/ +/*****************************************************************************/ /* General NMManager stuff */ -/*******************************************************************/ +/*****************************************************************************/ static gboolean radio_enabled_for_rstate (RadioState *rstate, gboolean check_changeable) @@ -1741,7 +1798,7 @@ assume_connection (NMManager *self, NMDevice *device, NMSettingsConnection *conn g_return_val_if_fail (nm_device_get_state (device) >= NM_DEVICE_STATE_DISCONNECTED, FALSE); subject = nm_auth_subject_new_internal (); - active = _new_active_connection (self, NM_CONNECTION (connection), NULL, device, subject, &error); + active = _new_active_connection (self, NM_CONNECTION (connection), NULL, NULL, device, subject, &error); g_object_unref (subject); if (!active) { @@ -1825,6 +1882,14 @@ recheck_assume_connection_cb (NMDevice *device, gpointer user_data) recheck_assume_connection (user_data, device); } +static void +device_ifindex_changed (NMDevice *device, + GParamSpec *pspec, + NMManager *self) +{ + _parent_notify_changed (self, device, FALSE); +} + static void device_ip_iface_changed (NMDevice *device, GParamSpec *pspec, @@ -1963,6 +2028,10 @@ add_device (NMManager *self, NMDevice *device, GError **error) G_CALLBACK (device_ip_iface_changed), self); + g_signal_connect (device, "notify::" NM_DEVICE_IFINDEX, + G_CALLBACK (device_ifindex_changed), + self); + g_signal_connect (device, "notify::" NM_DEVICE_IFACE, G_CALLBACK (device_iface_changed), self); @@ -2005,12 +2074,7 @@ add_device (NMManager *self, NMDevice *device, GError **error) g_signal_emit (self, signals[INTERNAL_DEVICE_ADDED], 0, device); _notify (self, PROP_ALL_DEVICES); - for (iter = priv->devices; iter; iter = iter->next) { - NMDevice *d = iter->data; - - if (d != device) - nm_device_notify_new_device_added (d, device); - } + _parent_notify_changed (self, device, FALSE); /* Virtual connections may refer to the new device as * parent device, retry to activate them. @@ -2020,7 +2084,7 @@ add_device (NMManager *self, NMDevice *device, GError **error) return TRUE; } -/*******************************************************************/ +/*****************************************************************************/ static void factory_device_added_cb (NMDeviceFactory *factory, @@ -2074,16 +2138,16 @@ _register_device_factory (NMDeviceFactory *factory, gpointer user_data) self); } -/*******************************************************************/ +/*****************************************************************************/ static void platform_link_added (NMManager *self, int ifindex, - const NMPlatformLink *plink) + const NMPlatformLink *plink, + const NMConfigDeviceStateData *dev_state) { NMDeviceFactory *factory; NMDevice *device = NULL; - gboolean nm_plugin_missing = FALSE; GSList *iter; g_return_if_fail (ifindex > 0); @@ -2137,6 +2201,8 @@ platform_link_added (NMManager *self, } if (device == NULL) { + gboolean nm_plugin_missing = FALSE; + switch (plink->type) { case NM_LINK_TYPE_WWAN_NET: case NM_LINK_TYPE_BNEP: @@ -2148,7 +2214,7 @@ platform_link_added (NMManager *self, nm_plugin_missing = TRUE; /* fall through */ default: - device = nm_device_generic_new (plink); + device = nm_device_generic_new (plink, nm_plugin_missing); break; } } @@ -2156,8 +2222,6 @@ platform_link_added (NMManager *self, if (device) { gs_free_error GError *error = NULL; - if (nm_plugin_missing) - nm_device_set_nm_plugin_missing (device, TRUE); if (nm_device_realize_start (device, plink, NULL, &error)) { add_device (self, device, NULL); _device_realize_finish (self, device, plink); @@ -2190,7 +2254,7 @@ _platform_link_cb_idle (PlatformLinkCbData *data) NMPlatformLink pllink; pllink = *l; /* make a copy of the link instance */ - platform_link_added (self, data->ifindex, &pllink); + platform_link_added (self, data->ifindex, &pllink, NULL); } else { NMDevice *device; GError *error = NULL; @@ -2220,12 +2284,13 @@ out: static void platform_link_cb (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, NMPlatformLink *plink, - NMPlatformSignalChangeType change_type, + int change_type_i, gpointer user_data) { + const NMPlatformSignalChangeType change_type = change_type_i; PlatformLinkCbData *data; switch (change_type) { @@ -2245,14 +2310,24 @@ platform_link_cb (NMPlatform *platform, static void platform_query_devices (NMManager *self) { + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); GArray *links_array; NMPlatformLink *links; int i; links_array = nm_platform_link_get_all (NM_PLATFORM_GET); links = (NMPlatformLink *) links_array->data; - for (i = 0; i < links_array->len; i++) - platform_link_added (self, links[i].ifindex, &links[i]); + for (i = 0; i < links_array->len; i++) { + gs_free NMConfigDeviceStateData *dev_state = NULL; + + dev_state = nm_config_device_state_load (priv->config, + links[i].ifindex); + + platform_link_added (self, + links[i].ifindex, + &links[i], + dev_state); + } g_array_unref (links_array); } @@ -2274,6 +2349,28 @@ nm_manager_get_devices (NMManager *manager) return NM_MANAGER_GET_PRIVATE (manager)->devices; } +const char ** +nm_manager_get_device_paths (NMManager *self) +{ + const GSList *devices, *iter; + GPtrArray *paths; + const char *path; + + g_return_val_if_fail (NM_IS_MANAGER (self), NULL); + devices = NM_MANAGER_GET_PRIVATE (self)->devices; + paths = g_ptr_array_new (); + + for (iter = devices; iter; iter = g_slist_next (iter)) { + path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (iter->data)); + if (path) + g_ptr_array_add (paths, (gpointer) path); + } + + g_ptr_array_add (paths, NULL); + + return (const char **) g_ptr_array_free (paths, FALSE); +} + static NMDevice * nm_manager_get_connection_device (NMManager *self, NMConnection *connection) @@ -2598,6 +2695,7 @@ ensure_master_active_connection (NMManager *self, master_ac = nm_manager_activate_connection (self, candidate, NULL, + NULL, master_device, subject, error); @@ -2644,6 +2742,7 @@ ensure_master_active_connection (NMManager *self, master_ac = nm_manager_activate_connection (self, master_connection, NULL, + NULL, candidate, subject, error); @@ -2680,14 +2779,9 @@ find_slaves (NMManager *manager, GSList *all_connections, *iter; GSList *slaves = NULL; NMSettingConnection *s_con; - const char *master; s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); g_assert (s_con); - master = nm_setting_connection_get_master (s_con); - - if (master != NULL) - return NULL; /* connection is not master */ /* Search through all connections, not only inactive ones, because * even if a slave was already active, it might be deactivated during @@ -2756,8 +2850,34 @@ autoconnect_slaves (NMManager *self, while (iter) { NMSettingsConnection *slave_connection = iter->data; + const char *uuid; iter = iter->next; + + /* To avoid loops when autoconnecting slaves, we propagate + * the UUID of the initial connection down to slaves until + * the same connection is found. + */ + uuid = g_object_get_qdata (G_OBJECT (master_connection), + autoconnect_root_quark ()); + if (nm_streq0 (nm_settings_connection_get_uuid (slave_connection), uuid)) { + _LOGI (LOGD_CORE, + "will NOT activate slave connection '%s' (%s) as a dependency for master '%s' (%s): " + "circular dependency detected", + nm_settings_connection_get_id (slave_connection), + nm_settings_connection_get_uuid (slave_connection), + nm_settings_connection_get_id (master_connection), + nm_settings_connection_get_uuid (master_connection)); + continue; + } + + if (!uuid) + uuid = nm_settings_connection_get_uuid (master_connection); + g_object_set_qdata_full (G_OBJECT (slave_connection), + autoconnect_root_quark (), + g_strdup (uuid), + g_free); + _LOGD (LOGD_CORE, "will activate slave connection '%s' (%s) as a dependency for master '%s' (%s)", nm_settings_connection_get_id (slave_connection), nm_settings_connection_get_uuid (slave_connection), @@ -2768,6 +2888,7 @@ autoconnect_slaves (NMManager *self, nm_manager_activate_connection (self, slave_connection, NULL, + NULL, nm_manager_get_best_device_for_connection (self, NM_CONNECTION (slave_connection), FALSE), subject, &local_err); @@ -2927,7 +3048,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * return FALSE; } - parent_ac = nm_manager_activate_connection (self, parent_con, NULL, parent, subject, error); + parent_ac = nm_manager_activate_connection (self, parent_con, NULL, NULL, parent, subject, error); if (!parent_ac) { g_prefix_error (error, "%s failed to activate parent: ", nm_device_get_iface (device)); return FALSE; @@ -3109,6 +3230,7 @@ _new_vpn_active_connection (NMManager *self, static NMActiveConnection * _new_active_connection (NMManager *self, NMConnection *connection, + NMConnection *applied, const char *specific_object, NMDevice *device, NMAuthSubject *subject, @@ -3148,6 +3270,7 @@ _new_active_connection (NMManager *self, } return (NMActiveConnection *) nm_act_request_new (settings_connection, + applied, specific_object, subject, device); @@ -3198,6 +3321,7 @@ _internal_activation_auth_done (NMActiveConnection *active, * nm_manager_activate_connection(): * @self: the #NMManager * @connection: the #NMSettingsConnection to activate on @device + * @applied: (allow-none): the applied connection to activate on @device * @specific_object: the specific object path, if any, for the activation * @device: the #NMDevice to activate @connection on * @subject: the subject which requested activation @@ -3207,7 +3331,8 @@ _internal_activation_auth_done (NMActiveConnection *active, * @subject should be the subject of the activation that triggered this * one, or if this is an autoconnect request, a new internal subject. * The returned #NMActiveConnection is owned by the Manager and should be - * referenced by the caller if the caller continues to use it. + * referenced by the caller if the caller continues to use it. If @applied + * is supplied, it shall not be modified by the caller afterwards. * * Returns: (transfer none): the new #NMActiveConnection that tracks * activation of @connection on @device @@ -3215,6 +3340,7 @@ _internal_activation_auth_done (NMActiveConnection *active, NMActiveConnection * nm_manager_activate_connection (NMManager *self, NMSettingsConnection *connection, + NMConnection *applied, const char *specific_object, NMDevice *device, NMAuthSubject *subject, @@ -3260,6 +3386,7 @@ nm_manager_activate_connection (NMManager *self, active = _new_active_connection (self, NM_CONNECTION (connection), + applied, specific_object, device, subject, @@ -3328,18 +3455,6 @@ validate_activation_request (NMManager *self, goto error; } - /* Not implemented yet, we want to fail early */ - if ( nm_connection_get_setting_connection (connection) - && nm_connection_get_setting_ip6_config (connection) - && !strcmp (nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG), - NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { - g_set_error_literal (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, - "Sharing IPv6 connections is not supported yet."); - goto error; - } - /* Check whether it's a VPN or not */ if ( nm_connection_get_setting_vpn (connection) || nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)) @@ -3404,7 +3519,7 @@ error: return NULL; } -/***********************************************************************/ +/*****************************************************************************/ static void _activation_auth_done (NMActiveConnection *active, @@ -3514,6 +3629,7 @@ impl_manager_activate_connection (NMManager *self, active = _new_active_connection (self, NM_CONNECTION (connection), + NULL, specific_object_path, device, subject, @@ -3537,7 +3653,7 @@ error: g_dbus_method_invocation_take_error (context, error); } -/***********************************************************************/ +/*****************************************************************************/ typedef struct { NMManager *manager; @@ -3586,7 +3702,8 @@ activation_add_done (NMSettings *settings, g_assert (error); _internal_activation_failed (self, active, error->message); - nm_settings_connection_delete (new_connection, NULL, NULL); + if (new_connection) + nm_settings_connection_delete (new_connection, NULL, NULL); g_dbus_method_invocation_return_gerror (context, error); nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD_ACTIVATE, NULL, @@ -3721,6 +3838,7 @@ impl_manager_add_and_activate_connection (NMManager *self, active = _new_active_connection (self, connection, + NULL, specific_object_path, device, subject, @@ -3748,7 +3866,7 @@ error: g_dbus_method_invocation_take_error (context, error); } -/***********************************************************************/ +/*****************************************************************************/ gboolean nm_manager_deactivate_connection (NMManager *manager, @@ -4592,6 +4710,58 @@ start_factory (NMDeviceFactory *factory, gpointer user_data) nm_device_factory_start (factory); } +void +nm_manager_write_device_state (NMManager *self) +{ + const GSList *devices; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + gs_unref_hashtable GHashTable *seen_ifindexes = NULL; + + seen_ifindexes = g_hash_table_new (NULL, NULL); + + for (devices = priv->devices; devices; devices = devices->next) { + NMDevice *device = NM_DEVICE (devices->data); + int ifindex; + gboolean managed; + NMConnection *settings_connection; + const char *uuid = NULL; + const char *perm_hw_addr_fake = NULL; + gboolean perm_hw_addr_is_fake; + + ifindex = nm_device_get_ip_ifindex (device); + if (ifindex <= 0) + continue; + if (ifindex == 1) { + /* ignore loopback */ + continue; + } + + if (!nm_platform_link_get (NM_PLATFORM_GET, ifindex)) + continue; + + managed = nm_device_get_managed (device, FALSE); + if (managed) { + settings_connection = NM_CONNECTION (nm_device_get_settings_connection (device)); + if (settings_connection) + uuid = nm_connection_get_uuid (settings_connection); + } + + perm_hw_addr_fake = nm_device_get_permanent_hw_address_full (device, FALSE, &perm_hw_addr_is_fake); + if (perm_hw_addr_fake && !perm_hw_addr_is_fake) + perm_hw_addr_fake = NULL; + + if (nm_config_device_state_write (priv->config, + ifindex, + managed, + perm_hw_addr_fake, + uuid)) + g_hash_table_add (seen_ifindexes, GINT_TO_POINTER (ifindex)); + } + + nm_config_device_state_prune_unseen (priv->config, + seen_ifindexes); +} + gboolean nm_manager_start (NMManager *self, GError **error) { @@ -5088,7 +5258,7 @@ prop_filter (GDBusConnection *connection, return NULL; } -/******************************************************************************/ +/*****************************************************************************/ static int _set_prop_filter_free2 (gpointer user_data) @@ -5135,7 +5305,7 @@ _set_prop_filter (NMManager *self, GDBusConnection *connection) } } -/******************************************************************************/ +/*****************************************************************************/ static NMCheckpointManager * _checkpoint_mgr_get (NMManager *self, gboolean create_as_needed) @@ -5303,7 +5473,7 @@ impl_manager_checkpoint_rollback (NMManager *self, nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_CHECKPOINT_ROLLBACK, TRUE); } -/******************************************************************************/ +/*****************************************************************************/ static void auth_mgr_changed (NMAuthManager *auth_manager, gpointer user_data) @@ -5320,7 +5490,7 @@ struct rfkill_event { __u8 type; __u8 op; __u8 soft, hard; -} __attribute__((packed)); +} _nm_packed; static void rfkill_change (NMManager *self, const char *desc, RfKillType rtype, gboolean enabled) @@ -5446,7 +5616,40 @@ dbus_connection_changed_cb (NMBusManager *dbus_mgr, _set_prop_filter (NM_MANAGER (user_data), connection); } -/**********************************************************************/ +/*****************************************************************************/ + +void +nm_manager_set_capability (NMManager *self, + NMCapability cap) +{ + NMManagerPrivate *priv; + guint32 cap_i; + gssize idx; + + g_return_if_fail (NM_IS_MANAGER (self)); + if (cap < 1 || cap > NM_CAPABILITY_TEAM) + g_return_if_reached (); + + cap_i = (guint32) cap; + + priv = NM_MANAGER_GET_PRIVATE (self); + + idx = _nm_utils_array_find_binary_search (&g_array_index (priv->capabilities, guint32, 0), + sizeof (guint32), + priv->capabilities->len, + &cap_i, + nm_cmp_uint32_p_with_data, + NULL); + if (idx >= 0) + return; + + nm_assert ((~idx) <= (gssize) priv->capabilities->len); + + g_array_insert_val (priv->capabilities, ~idx, cap_i); + _notify (self, PROP_CAPABILITIES); +} + +/*****************************************************************************/ NM_DEFINE_SINGLETON_REGISTER (NMManager); @@ -5497,6 +5700,9 @@ constructed (GObject *object) _set_prop_filter (self, nm_bus_manager_get_connection (priv->dbus_mgr)); priv->settings = nm_settings_new (); + + nm_exported_object_export (NM_EXPORTED_OBJECT (priv->settings)); + g_signal_connect (priv->settings, "notify::" NM_SETTINGS_STARTUP_COMPLETE, G_CALLBACK (settings_startup_complete_changed), self); g_signal_connect (priv->settings, "notify::" NM_SETTINGS_UNMANAGED_SPECS, @@ -5565,6 +5771,8 @@ nm_manager_init (NMManager *self) guint i; GFile *file; + priv->capabilities = g_array_new (FALSE, FALSE, sizeof (guint32)); + /* Initialize rfkill structures and states */ memset (priv->radio_states, 0, sizeof (priv->radio_states)); @@ -5652,6 +5860,12 @@ get_property (GObject *object, guint prop_id, case PROP_VERSION: g_value_set_string (value, VERSION); break; + case PROP_CAPABILITIES: + g_value_set_variant (value, g_variant_new_fixed_array (G_VARIANT_TYPE ("u"), + priv->capabilities->data, + priv->capabilities->len, + sizeof (guint32))); + break; case PROP_STATE: g_value_set_uint (value, priv->state); break; @@ -5870,6 +6084,16 @@ dispose (GObject *object) G_OBJECT_CLASS (nm_manager_parent_class)->dispose (object); } +static void +finalize (GObject *object) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE ((NMManager *) object); + + g_array_free (priv->capabilities, TRUE); + + G_OBJECT_CLASS (nm_manager_parent_class)->finalize (object); +} + static void nm_manager_class_init (NMManagerClass *manager_class) { @@ -5883,6 +6107,7 @@ nm_manager_class_init (NMManagerClass *manager_class) object_class->set_property = set_property; object_class->get_property = get_property; object_class->dispose = dispose; + object_class->finalize = finalize; /* properties */ obj_properties[PROP_VERSION] = @@ -5891,6 +6116,13 @@ nm_manager_class_init (NMManagerClass *manager_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_CAPABILITIES] = + g_param_spec_variant (NM_MANAGER_CAPABILITIES, "", "", + G_VARIANT_TYPE ("au"), + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_STATE] = g_param_spec_uint (NM_MANAGER_STATE, "", "", 0, NM_STATE_DISCONNECTED, 0, @@ -6128,4 +6360,3 @@ nm_manager_class_init (NMManagerClass *manager_class) "CheckpointRollback", impl_manager_checkpoint_rollback, NULL); } - diff --git a/src/nm-manager.h b/src/nm-manager.h index d7aabff1..13cae375 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -23,7 +23,7 @@ #define __NETWORKMANAGER_MANAGER_H__ #include "nm-exported-object.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings-connection.h" #define NM_TYPE_MANAGER (nm_manager_get_type ()) #define NM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MANAGER, NMManager)) @@ -33,6 +33,7 @@ #define NM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MANAGER, NMManagerClass)) #define NM_MANAGER_VERSION "version" +#define NM_MANAGER_CAPABILITIES "capabilities" #define NM_MANAGER_STATE "state" #define NM_MANAGER_STARTUP "startup" #define NM_MANAGER_NETWORKING_ENABLED "networking-enabled" @@ -85,9 +86,12 @@ NMState nm_manager_get_state (NMManager *manager); const GSList *nm_manager_get_active_connections (NMManager *manager); GSList * nm_manager_get_activatable_connections (NMManager *manager); +void nm_manager_write_device_state (NMManager *manager); + /* Device handling */ const GSList * nm_manager_get_devices (NMManager *manager); +const char ** nm_manager_get_device_paths (NMManager *self); NMDevice * nm_manager_get_device_by_ifindex (NMManager *manager, int ifindex); @@ -99,8 +103,12 @@ char * nm_manager_get_connection_iface (NMManager *self, NMDevice **out_parent, GError **error); +const char * nm_manager_iface_for_uuid (NMManager *self, + const char *uuid); + NMActiveConnection *nm_manager_activate_connection (NMManager *manager, NMSettingsConnection *connection, + NMConnection *applied_connection, const char *specific_object, NMDevice *device, NMAuthSubject *subject, @@ -111,5 +119,6 @@ gboolean nm_manager_deactivate_connection (NMManager *manager, NMDeviceStateReason reason, GError **error); +void nm_manager_set_capability (NMManager *self, NMCapability cap); #endif /* __NETWORKMANAGER_MANAGER_H__ */ diff --git a/src/nm-multi-index.c b/src/nm-multi-index.c index 6ae54a98..6ae4c21f 100644 --- a/src/nm-multi-index.c +++ b/src/nm-multi-index.c @@ -42,7 +42,7 @@ typedef struct { GHashTable *index; } ValuesData; -/******************************************************************************************/ +/*****************************************************************************/ static void _values_data_destroy (ValuesData *values_data) @@ -99,7 +99,7 @@ _values_data_get_data (ValuesData *values_data, NM_SET_OUT (out_data, values_data->values); } -/******************************************************************************************/ +/*****************************************************************************/ /** * nm_multi_index_lookup(): @@ -237,7 +237,7 @@ nm_multi_index_iter_next (NMMultiIndexIter *iter, return FALSE; } -/******************************************************************************************/ +/*****************************************************************************/ void nm_multi_index_id_iter_init (NMMultiIndexIdIter *iter, @@ -283,7 +283,7 @@ nm_multi_index_id_iter_next (NMMultiIndexIdIter *iter, } } -/******************************************************************************************/ +/*****************************************************************************/ static gboolean _do_add (NMMultiIndex *index, @@ -430,7 +430,7 @@ nm_multi_index_move (NMMultiIndex *index, } } -/******************************************************************************************/ +/*****************************************************************************/ guint nm_multi_index_get_num_groups (const NMMultiIndex *index) diff --git a/src/nm-pacrunner-manager.c b/src/nm-pacrunner-manager.c new file mode 100644 index 00000000..450cf0e3 --- /dev/null +++ b/src/nm-pacrunner-manager.c @@ -0,0 +1,468 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2016 Atul Anand . + */ + +#include "nm-default.h" + +#include "nm-pacrunner-manager.h" + +#include "nm-utils.h" +#include "platform/nm-platform.h" +#include "nm-proxy-config.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" + +#define PACRUNNER_DBUS_SERVICE "org.pacrunner" +#define PACRUNNER_DBUS_INTERFACE "org.pacrunner.Manager" +#define PACRUNNER_DBUS_PATH "/org/pacrunner/manager" + +/*****************************************************************************/ + +struct remove_data { + char *iface; + char *path; +}; + +typedef struct { + char *iface; + GPtrArray *domains; + GDBusProxy *pacrunner; + GCancellable *pacrunner_cancellable; + GList *args; + GList *remove; +} NMPacrunnerManagerPrivate; + +struct _NMPacrunnerManager { + GObject parent; + NMPacrunnerManagerPrivate _priv; +}; + +struct _NMPacrunnerManagerClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMPacrunnerManager, nm_pacrunner_manager, G_TYPE_OBJECT) + +#define NM_PACRUNNER_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPacrunnerManager, NM_IS_PACRUNNER_MANAGER) + +/*****************************************************************************/ + +NM_DEFINE_SINGLETON_GETTER (NMPacrunnerManager, nm_pacrunner_manager_get, NM_TYPE_PACRUNNER_MANAGER); + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_PROXY +#define _NMLOG(level, ...) __NMLOG_DEFAULT_WITH_ADDR (level, _NMLOG_DOMAIN, "pacrunner", __VA_ARGS__) + +/*****************************************************************************/ + +static void +remove_data_destroy (struct remove_data *data) +{ + g_return_if_fail (data != NULL); + + g_free (data->iface); + g_free (data->path); + memset (data, 0, sizeof (struct remove_data)); + g_free (data); +} + +static void +add_proxy_config (NMPacrunnerManager *self, GVariantBuilder *proxy_data, const NMProxyConfig *proxy_config) +{ + const char *pac_url, *pac_script; + NMProxyConfigMethod method; + + method = nm_proxy_config_get_method (proxy_config); + + if (method == NM_PROXY_CONFIG_METHOD_AUTO) { + pac_url = nm_proxy_config_get_pac_url (proxy_config); + if (pac_url) { + g_variant_builder_add (proxy_data, "{sv}", + "URL", + g_variant_new_string (pac_url)); + } + + pac_script = nm_proxy_config_get_pac_script (proxy_config); + if (pac_script) { + g_variant_builder_add (proxy_data, "{sv}", + "Script", + g_variant_new_string (pac_script)); + } + } + + g_variant_builder_add (proxy_data, "{sv}", + "BrowserOnly", + g_variant_new_boolean (nm_proxy_config_get_browser_only (proxy_config))); +} + +static void +add_ip4_config (NMPacrunnerManager *self, GVariantBuilder *proxy_data, NMIP4Config *ip4) +{ + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + int i; + char *cidr = NULL; + + /* Extract searches */ + for (i = 0; i < nm_ip4_config_get_num_searches (ip4); i++) + g_ptr_array_add (priv->domains, g_strdup (nm_ip4_config_get_search (ip4, i))); + + /* Extract domains */ + for (i = 0; i < nm_ip4_config_get_num_domains (ip4); i++) + g_ptr_array_add (priv->domains, g_strdup (nm_ip4_config_get_domain (ip4, i))); + + /* Add addresses and routes in CIDR form */ + for (i = 0; i < nm_ip4_config_get_num_addresses (ip4); i++) { + const NMPlatformIP4Address *address = nm_ip4_config_get_address (ip4, i); + + cidr = g_strdup_printf ("%s/%u", + nm_utils_inet4_ntop (address->address, NULL), + address->plen); + g_ptr_array_add (priv->domains, g_strdup (cidr)); + g_free (cidr); + } + + for (i = 0; i < nm_ip4_config_get_num_routes (ip4); i++) { + const NMPlatformIP4Route *routes = nm_ip4_config_get_route (ip4, i); + + cidr = g_strdup_printf ("%s/%u", + nm_utils_inet4_ntop (routes->network, NULL), + routes->plen); + g_ptr_array_add (priv->domains, g_strdup (cidr)); + g_free (cidr); + } +} + +static void +add_ip6_config (NMPacrunnerManager *self, GVariantBuilder *proxy_data, NMIP6Config *ip6) +{ + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + int i; + char *cidr = NULL; + + /* Extract searches */ + for (i = 0; i < nm_ip6_config_get_num_searches (ip6); i++) + g_ptr_array_add (priv->domains, g_strdup (nm_ip6_config_get_search (ip6, i))); + + /* Extract domains */ + for (i = 0; i < nm_ip6_config_get_num_domains (ip6); i++) + g_ptr_array_add (priv->domains, g_strdup (nm_ip6_config_get_domain (ip6, i))); + + /* Add addresses and routes in CIDR form */ + for (i = 0; i < nm_ip6_config_get_num_addresses (ip6); i++) { + const NMPlatformIP6Address *address = nm_ip6_config_get_address (ip6, i); + + cidr = g_strdup_printf ("%s/%u", + nm_utils_inet6_ntop (&address->address, NULL), + address->plen); + g_ptr_array_add (priv->domains, g_strdup (cidr)); + g_free (cidr); + } + + for (i = 0; i < nm_ip6_config_get_num_routes (ip6); i++) { + const NMPlatformIP6Route *routes = nm_ip6_config_get_route (ip6, i); + + cidr = g_strdup_printf ("%s/%u", + nm_utils_inet6_ntop (&routes->network, NULL), + routes->plen); + g_ptr_array_add (priv->domains, g_strdup (cidr)); + g_free (cidr); + } +} + +static void +pacrunner_send_done (GObject *source, GAsyncResult *res, gpointer user_data) +{ + NMPacrunnerManager *self = NM_PACRUNNER_MANAGER (user_data); + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *variant = NULL; + const char *path = NULL; + GList *iter = NULL; + gboolean found = FALSE; + + variant = g_dbus_proxy_call_finish (priv->pacrunner, res, &error); + if (!variant) { + _LOGD ("sending proxy config to pacrunner failed: %s", error->message); + } else { + struct remove_data *data; + g_variant_get (variant, "(&o)", &path); + + /* Replace the old path (if any) of proxy config with the new one returned + * from CreateProxyConfiguration() DBus method on pacrunner. + */ + for (iter = g_list_first (priv->remove); iter; iter = g_list_next (iter)) { + struct remove_data *r = iter->data; + if (g_strcmp0 (priv->iface, r->iface) == 0) { + g_free (r->path); + r->path = g_strdup (path); + found = TRUE; + break; + } + } + + if (!found) { + data = g_malloc0 (sizeof (struct remove_data)); + data->iface = g_strdup (priv->iface); + data->path = g_strdup (path); + priv->remove = g_list_append (priv->remove, data); + _LOGD ("proxy config sent to pacrunner"); + } + } +} + +static void +send_pacrunner_proxy_data (NMPacrunnerManager *self, GVariant *pacrunner_manager_args) +{ + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + + if (!pacrunner_manager_args) + return; + + if (priv->pacrunner) + g_dbus_proxy_call (priv->pacrunner, + "CreateProxyConfiguration", + pacrunner_manager_args, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + (GAsyncReadyCallback) pacrunner_send_done, + self); +} + +static void +name_owner_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + NMPacrunnerManager *self = NM_PACRUNNER_MANAGER (user_data); + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + gs_free char *owner = NULL; + GList *iter = NULL; + + owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object)); + if (owner) { + _LOGD ("pacrunner appeared as %s", owner); + for (iter = g_list_first(priv->args); iter; iter = g_list_next(iter)) { + send_pacrunner_proxy_data (self, iter->data); + } + } else { + _LOGD ("pacrunner disappeared"); + } +} + +static void +pacrunner_proxy_cb (GObject *source, GAsyncResult *res, gpointer user_data) +{ + NMPacrunnerManager *self = user_data; + NMPacrunnerManagerPrivate *priv; + GError *error = NULL; + GDBusProxy *proxy; + + proxy = g_dbus_proxy_new_for_bus_finish (res, &error); + if (!proxy) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + _LOGW ("failed to connect to pacrunner via DBus: %s", error->message); + g_error_free (error); + return; + } + + priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + + priv->pacrunner = proxy; + nm_clear_g_cancellable (&priv->pacrunner_cancellable); + + g_signal_connect (priv->pacrunner, "notify::g-name-owner", + G_CALLBACK (name_owner_changed), self); +} + +/** + * nm_pacrunner_manager_send: + * @self: the #NMPacrunnerManager + * @iface: the iface for the connection or %NULL + * @proxy_config: proxy config of the connection + * @ip4_config: IP4 config of the connection + * @ip6_config: IP6 config of the connection + */ +void +nm_pacrunner_manager_send (NMPacrunnerManager *self, + const char *iface, + NMProxyConfig *proxy_config, + NMIP4Config *ip4_config, + NMIP6Config *ip6_config) +{ + char **strv = NULL; + NMProxyConfigMethod method; + NMPacrunnerManagerPrivate *priv; + GVariantBuilder proxy_data; + GVariant *pacrunner_manager_args; + + g_return_if_fail (NM_IS_PACRUNNER_MANAGER (self)); + g_return_if_fail (proxy_config); + + priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + + g_free (priv->iface); + priv->iface = g_strdup (iface); + + g_variant_builder_init (&proxy_data, G_VARIANT_TYPE_VARDICT); + + if (iface) { + g_variant_builder_add (&proxy_data, "{sv}", + "Interface", + g_variant_new_string (iface)); + } + + method = nm_proxy_config_get_method (proxy_config); + switch (method) { + case NM_PROXY_CONFIG_METHOD_AUTO: + g_variant_builder_add (&proxy_data, "{sv}", + "Method", + g_variant_new_string ("auto")); + + break; + case NM_PROXY_CONFIG_METHOD_NONE: + g_variant_builder_add (&proxy_data, "{sv}", + "Method", + g_variant_new_string ("direct")); + } + + priv->domains = g_ptr_array_new_with_free_func (g_free); + + /* Extract stuff from configs */ + add_proxy_config (self, &proxy_data, proxy_config); + + if (ip4_config) + add_ip4_config (self, &proxy_data, ip4_config); + if (ip6_config) + add_ip6_config (self, &proxy_data, ip6_config); + + g_ptr_array_add (priv->domains, NULL); + strv = (char **) g_ptr_array_free (priv->domains, (priv->domains->len == 1)); + + if (strv) { + g_variant_builder_add (&proxy_data, "{sv}", + "Domains", + g_variant_new_strv ((const char *const *) strv, -1)); + g_strfreev (strv); + } + + pacrunner_manager_args = g_variant_ref_sink (g_variant_new ("(a{sv})", &proxy_data)); + priv->args = g_list_append (priv->args, pacrunner_manager_args); + + /* Send if pacrunner is available on Bus, otherwise + * argument has already been appended above to be + * sent when pacrunner appears. + */ + send_pacrunner_proxy_data (self, pacrunner_manager_args); +} + +static void +pacrunner_remove_done (GObject *source, GAsyncResult *res, gpointer user_data) +{ + /* @self may be a dangling pointer. However, we don't use it as the + * logging macro below does not dereference @self. */ + NMPacrunnerManager *self = user_data; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; + + ret = g_dbus_proxy_call_finish ((GDBusProxy *) source, res, &error); + + if (!ret) + _LOGD ("Couldn't remove proxy config from pacrunner: %s", error->message); + else + _LOGD ("Successfully removed proxy config from pacrunner"); +} + +/** + * nm_pacrunner_manager_remove: + * @self: the #NMPacrunnerManager + * @iface: the iface for the connection to be removed + * from pacrunner + */ +void +nm_pacrunner_manager_remove (NMPacrunnerManager *self, const char *iface) +{ + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + GList *list; + + for (list = g_list_first(priv->remove); list; list = g_list_next(list)) { + struct remove_data *data = list->data; + if (g_strcmp0 (data->iface, iface) == 0) { + if (priv->pacrunner && data->path) + g_dbus_proxy_call (priv->pacrunner, + "DestroyProxyConfiguration", + g_variant_new ("(o)", data->path), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + (GAsyncReadyCallback) pacrunner_remove_done, + self); + break; + } + } +} + +/*****************************************************************************/ + +static void +nm_pacrunner_manager_init (NMPacrunnerManager *self) +{ + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE (self); + + priv->pacrunner_cancellable = g_cancellable_new (); + + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + PACRUNNER_DBUS_SERVICE, + PACRUNNER_DBUS_PATH, + PACRUNNER_DBUS_INTERFACE, + priv->pacrunner_cancellable, + (GAsyncReadyCallback) pacrunner_proxy_cb, + self); +} + +static void +dispose (GObject *object) +{ + NMPacrunnerManagerPrivate *priv = NM_PACRUNNER_MANAGER_GET_PRIVATE ((NMPacrunnerManager *) object); + + g_clear_pointer (&priv->iface, g_free); + + nm_clear_g_cancellable (&priv->pacrunner_cancellable); + + g_clear_object (&priv->pacrunner); + + g_list_free_full (priv->args, (GDestroyNotify) g_variant_unref); + priv->args = NULL; + + g_list_free_full (priv->remove, (GDestroyNotify) remove_data_destroy); + priv->remove = NULL; + + G_OBJECT_CLASS (nm_pacrunner_manager_parent_class)->dispose (object); +} + +static void +nm_pacrunner_manager_class_init (NMPacrunnerManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = dispose; +} diff --git a/src/nm-pacrunner-manager.h b/src/nm-pacrunner-manager.h new file mode 100644 index 00000000..99e85115 --- /dev/null +++ b/src/nm-pacrunner-manager.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2016 Atul Anand . + */ + +#ifndef __NETWORKMANAGER_PACRUNNER_MANAGER_H__ +#define __NETWORKMANAGER_PACRUNNER_MANAGER_H__ + +#define NM_TYPE_PACRUNNER_MANAGER (nm_pacrunner_manager_get_type ()) +#define NM_PACRUNNER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PACRUNNER_MANAGER, NMPacrunnerManager)) +#define NM_PACRUNNER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PACRUNNER_MANAGER, NMPacrunnerManagerClass)) +#define NM_IS_PACRUNNER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PACRUNNER_MANAGER)) +#define NM_IS_PACRUNNER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PACRUNNER_MANAGER)) +#define NM_PACRUNNER_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PACRUNNER_MANAGER, NMPacrunnerManagerClass)) + +typedef struct _NMPacrunnerManagerClass NMPacrunnerManagerClass; + +GType nm_pacrunner_manager_get_type (void); + +NMPacrunnerManager *nm_pacrunner_manager_get (void); + +void nm_pacrunner_manager_send (NMPacrunnerManager *self, + const char *iface, + NMProxyConfig *proxy_config, + NMIP4Config *ip4_config, + NMIP6Config *ip6_config); + +void nm_pacrunner_manager_remove (NMPacrunnerManager *self, const char *iface); + +#endif /* __NETWORKMANAGER_PACRUNNER_MANAGER_H__ */ diff --git a/src/nm-policy.c b/src/nm-policy.c index 5fa46259..266bc5b1 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -21,45 +21,45 @@ #include "nm-default.h" +#include "nm-policy.h" + #include #include #include #include -#include "nm-policy.h" #include "NetworkManagerUtils.h" -#include "nm-activation-request.h" -#include "nm-device.h" +#include "nm-act-request.h" +#include "devices/nm-device.h" #include "nm-default-route-manager.h" #include "nm-setting-ip4-config.h" #include "nm-setting-connection.h" -#include "nm-platform.h" -#include "nm-dns-manager.h" -#include "nm-vpn-manager.h" +#include "platform/nm-platform.h" +#include "dns/nm-dns-manager.h" +#include "vpn/nm-vpn-manager.h" #include "nm-auth-utils.h" #include "nm-firewall-manager.h" #include "nm-dispatcher.h" #include "nm-utils.h" #include "nm-core-internal.h" #include "nm-manager.h" -#include "nm-settings.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings.h" +#include "settings/nm-settings-connection.h" #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" -#define _NMLOG_PREFIX_NAME "policy" -#define _NMLOG(level, domain, ...) \ - G_STMT_START { \ - nm_log ((level), (domain), \ - "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } G_STMT_END +/*****************************************************************************/ -typedef struct _NMPolicyPrivate NMPolicyPrivate; +NM_GOBJECT_PROPERTIES_DEFINE (NMPolicy, + PROP_MANAGER, + PROP_SETTINGS, + PROP_DEFAULT_IP4_DEVICE, + PROP_DEFAULT_IP6_DEVICE, + PROP_ACTIVATING_IP4_DEVICE, + PROP_ACTIVATING_IP6_DEVICE, +); -struct _NMPolicyPrivate { - NMPolicy *self; +typedef struct { NMManager *manager; NMFirewallManager *firewall_manager; GSList *pending_activation_checks; @@ -88,28 +88,281 @@ struct _NMPolicyPrivate { char *orig_hostname; /* hostname at NM start time */ char *cur_hostname; /* hostname we want to assign */ gboolean hostname_changed; /* TRUE if NM ever set the hostname */ + + GArray *ip6_prefix_delegations; /* pool of ip6 prefixes delegated to all devices */ +} NMPolicyPrivate; + +struct _NMPolicy { + GObject parent; + NMPolicyPrivate _priv; +}; + +struct _NMPolicyClass { + GObjectClass parent; }; -static NMPolicyPrivate * -NM_POLICY_GET_PRIVATE(NMPolicy *self) +G_DEFINE_TYPE (NMPolicy, nm_policy, G_TYPE_OBJECT) + +#define NM_POLICY_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPolicy, NM_IS_POLICY) + +static NMPolicy * +_PRIV_TO_SELF (NMPolicyPrivate *priv) { + NMPolicy *self; + + nm_assert (priv); + + self = (NMPolicy *) (((char *) priv) - G_STRUCT_OFFSET (NMPolicy, _priv)); + nm_assert (NM_IS_POLICY (self)); - return self->priv; + return self; } -G_DEFINE_TYPE (NMPolicy, nm_policy, G_TYPE_OBJECT) +/*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE (NMPolicy, - PROP_MANAGER, - PROP_SETTINGS, - PROP_DEFAULT_IP4_DEVICE, - PROP_DEFAULT_IP6_DEVICE, - PROP_ACTIVATING_IP4_DEVICE, - PROP_ACTIVATING_IP6_DEVICE, -); +#define _NMLOG_PREFIX_NAME "policy" +#define _NMLOG(level, domain, ...) \ + G_STMT_START { \ + nm_log ((level), (domain), \ + "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG_PREFIX_NAME": " \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } G_STMT_END + +/*****************************************************************************/ static void schedule_activate_all (NMPolicy *self); +/*****************************************************************************/ + +typedef struct { + NMPlatformIP6Address prefix; + NMDevice *device; /* The requesting ("uplink") device */ + guint64 next_subnet; /* Cache of the next subnet number to be + * assigned from this prefix */ + GHashTable *subnets; /* ifindex -> NMPlatformIP6Address */ +} IP6PrefixDelegation; + +static void +_clear_ip6_subnet (gpointer key, gpointer value, gpointer user_data) +{ + NMPlatformIP6Address *subnet = value; + NMDevice *device = nm_manager_get_device_by_ifindex (nm_manager_get (), + GPOINTER_TO_INT (key)); + + if (device) { + /* We can not remove a subnet we already started announcing. + * Just un-prefer it. */ + subnet->preferred = 0; + nm_device_use_ip6_subnet (device, subnet); + } + g_slice_free (NMPlatformIP6Address, subnet); +} + +static void +clear_ip6_prefix_delegation (gpointer data) +{ + IP6PrefixDelegation *delegation = data; + + _LOGD (LOGD_IP6, "ipv6-pd: undelegating prefix %s/%d", + nm_utils_inet6_ntop (&delegation->prefix.address, NULL), + delegation->prefix.plen); + + g_hash_table_foreach (delegation->subnets, _clear_ip6_subnet, NULL); + g_hash_table_destroy (delegation->subnets); +} + +static void +expire_ip6_delegations (NMPolicy *self) +{ + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); + guint32 now = nm_utils_get_monotonic_timestamp_s (); + IP6PrefixDelegation *delegation = NULL; + guint i; + + for (i = 0; i < priv->ip6_prefix_delegations->len; i++) { + delegation = &g_array_index (priv->ip6_prefix_delegations, + IP6PrefixDelegation, i); + if (delegation->prefix.timestamp + delegation->prefix.lifetime < now) + g_array_remove_index_fast (priv->ip6_prefix_delegations, i); + } +} + +/* + * Try to obtain a new subnet for a particular active connection from given + * delegated prefix, possibly reusing the existing subnet. + * Return value of FALSE indicates no more subnets are available from + * this prefix (and other prefix should be used -- and requested if necessary). + */ +static gboolean +ip6_subnet_from_delegation (IP6PrefixDelegation *delegation, NMDevice *device) +{ + NMPlatformIP6Address *subnet; + int ifindex = nm_device_get_ifindex (device); + + subnet = g_hash_table_lookup (delegation->subnets, GINT_TO_POINTER (ifindex)); + if (!subnet) { + /* Check for out-of-prefixes condition. */ + if (delegation->next_subnet >= (1 << (64 - delegation->prefix.plen))) { + _LOGD (LOGD_IP6, "ipv6-pd: no more prefixes in %s/%d", + nm_utils_inet6_ntop (&delegation->prefix.address, NULL), + delegation->prefix.plen); + return FALSE; + } + + /* Allocate a new subnet. */ + subnet = g_slice_new0 (NMPlatformIP6Address); + g_hash_table_insert (delegation->subnets, GINT_TO_POINTER (ifindex), subnet); + + subnet->plen = 64; + subnet->address.s6_addr32[0] = delegation->prefix.address.s6_addr32[0] + | htonl (delegation->next_subnet >> 32); + subnet->address.s6_addr32[1] = delegation->prefix.address.s6_addr32[1] + | htonl (delegation->next_subnet); + + /* Out subnet pool management is pretty unsophisticated. We only add + * the subnets and index them by ifindex. That keeps the implementation + * simple and the dead entries make it easy to reuse the same subnet on + * subsequent activations. On the other hand they may waste the subnet + * space. */ + delegation->next_subnet++; + } + + subnet->timestamp = delegation->prefix.timestamp; + subnet->lifetime = delegation->prefix.lifetime; + subnet->preferred = delegation->prefix.preferred; + + _LOGD (LOGD_IP6, "ipv6-pd: %s allocated from a /%d prefix on %s", + nm_utils_inet6_ntop (&subnet->address, NULL), + delegation->prefix.plen, + nm_device_get_iface (device)); + + nm_device_use_ip6_subnet (device, subnet); + + return TRUE; +} + +/* + * Try to obtain a subnet from each prefix delegated to given requesting + * ("uplink") device and assign it to the downlink device. + * Requests a new prefix if no subnet could be found. + */ +static void +ip6_subnet_from_device (NMPolicy *self, NMDevice *from_device, NMDevice *device) +{ + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); + IP6PrefixDelegation *delegation = NULL; + gboolean got_subnet = FALSE; + guint have_prefixes = 0; + guint i; + + expire_ip6_delegations (self); + + for (i = 0; i < priv->ip6_prefix_delegations->len; i++) { + delegation = &g_array_index (priv->ip6_prefix_delegations, + IP6PrefixDelegation, i); + + if (delegation->device != from_device) + continue; + + if (ip6_subnet_from_delegation (delegation, device)) + got_subnet = TRUE; + have_prefixes++; + } + + if (!got_subnet) { + _LOGI (LOGD_IP6, "ipv6-pd: none of %u prefixes of %s can be shared on %s", + have_prefixes, nm_device_get_iface (from_device), + nm_device_get_iface (device)); + nm_device_request_ip6_prefixes (from_device, have_prefixes + 1); + } +} + +static void +ip6_remove_device_prefix_delegations (NMPolicy *self, NMDevice *device) +{ + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); + IP6PrefixDelegation *delegation = NULL; + guint i; + + for (i = 0; i < priv->ip6_prefix_delegations->len; i++) { + delegation = &g_array_index (priv->ip6_prefix_delegations, + IP6PrefixDelegation, i); + if (delegation->device == device) + g_array_remove_index_fast (priv->ip6_prefix_delegations, i); + } +} + +static void +device_ip6_prefix_delegated (NMDevice *device, + NMPlatformIP6Address *prefix, + gpointer user_data) +{ + NMPolicyPrivate *priv = user_data; + NMPolicy *self = _PRIV_TO_SELF (priv); + IP6PrefixDelegation *delegation = NULL; + const GSList *connections, *iter; + guint i; + + _LOGI (LOGD_IP6, "ipv6-pd: received a prefix %s/%d from %s", + nm_utils_inet6_ntop (&prefix->address, NULL), + prefix->plen, + nm_device_get_iface (device)); + + expire_ip6_delegations (self); + + for (i = 0; i < priv->ip6_prefix_delegations->len; i++) { + /* Look for an already known prefix to update. */ + delegation = &g_array_index (priv->ip6_prefix_delegations, IP6PrefixDelegation, i); + if (IN6_ARE_ADDR_EQUAL (&delegation->prefix.address, &prefix->address)) + break; + } + + if (i == priv->ip6_prefix_delegations->len) { + /* Allocate a delegation delegation for new prefix. */ + g_array_set_size (priv->ip6_prefix_delegations, i + 1); + delegation = &g_array_index (priv->ip6_prefix_delegations, IP6PrefixDelegation, i); + delegation->subnets = g_hash_table_new (NULL, NULL); + delegation->next_subnet = 0; + } + + delegation->device = device; + delegation->prefix = *prefix; + + /* The newly activated connections are added to the list beginning, + * so traversing it from the beginning makes it likely for newly + * activated connections that have no subnet assigned to be served + * first. That is a simple yet fair policy, which is good. */ + connections = nm_manager_get_active_connections (priv->manager); + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMDevice *to_device = nm_active_connection_get_device (iter->data); + + if (nm_device_needs_ip6_subnet (to_device)) + ip6_subnet_from_delegation (delegation, to_device); + } +} + +static void +device_ip6_subnet_needed (NMDevice *device, + gpointer user_data) +{ + NMPolicyPrivate *priv = user_data; + NMPolicy *self = _PRIV_TO_SELF (priv); + + _LOGD (LOGD_IP6, "ipv6-pd: %s needs a subnet", + nm_device_get_iface (device)); + + if (!priv->default_device6) { + /* We request the prefixes when the default IPv6 device is set. */ + _LOGI (LOGD_IP6, "ipv6-pd: no device to obtain a subnet to share on %s from", + nm_device_get_iface (device)); + return; + } + ip6_subnet_from_device (self, priv->default_device6, device); + nm_device_copy_ip6_dns_config (device, priv->default_device6); +} + +/*****************************************************************************/ static NMDevice * get_best_ip4_device (NMPolicy *self, gboolean fully_activated) @@ -522,6 +775,21 @@ get_best_ip6_config (NMPolicy *self, out_vpn); } +static void +update_ip6_dns_delegation (NMPolicy *self) +{ + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); + const GSList *connections, *iter; + + connections = nm_manager_get_active_connections (priv->manager); + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMDevice *device = nm_active_connection_get_device (iter->data); + + if (device && nm_device_needs_ip6_subnet (device)) + nm_device_copy_ip6_dns_config (device, priv->default_device6); + } +} + static void update_ip6_dns (NMPolicy *self, NMDnsManager *dns_mgr) { @@ -540,6 +808,24 @@ update_ip6_dns (NMPolicy *self, NMDnsManager *dns_mgr) */ nm_dns_manager_add_ip6_config (dns_mgr, ip_iface, ip6_config, dns_type); } + + update_ip6_dns_delegation (self); +} + +static void +update_ip6_prefix_delegation (NMPolicy *self) +{ + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); + const GSList *connections, *iter; + + /* There's new default IPv6 connection, try to get a prefix for everyone. */ + connections = nm_manager_get_active_connections (priv->manager); + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMDevice *device = nm_active_connection_get_device (iter->data); + + if (device && nm_device_needs_ip6_subnet (device)) + ip6_subnet_from_device (self, priv->default_device6, device); + } } static void @@ -593,8 +879,10 @@ update_ip6_routing (NMPolicy *self, gboolean force_update) if (default_device6 == priv->default_device6) return; - priv->default_device6 = default_device6; + + update_ip6_prefix_delegation (self); + connection = nm_active_connection_get_applied_connection (best_ac); _LOGI (LOGD_CORE, "set '%s' (%s) as default for IPv6 routing and DNS", nm_connection_get_id (connection), ip_iface); @@ -665,34 +953,32 @@ activate_data_free (ActivateData *data) g_slice_free (ActivateData, data); } -static gboolean -auto_activate_device (gpointer user_data) +static void +auto_activate_device (NMPolicy *self, + NMDevice *device) { - ActivateData *data = (ActivateData *) user_data; - NMPolicy *self; NMPolicyPrivate *priv; NMSettingsConnection *best_connection; - char *specific_object = NULL; + gs_free char *specific_object = NULL; GPtrArray *connections; GSList *connection_list; guint i; - g_assert (data); - self = data->policy; - priv = NM_POLICY_GET_PRIVATE (self); + nm_assert (NM_IS_POLICY (self)); + nm_assert (NM_IS_DEVICE (device)); - data->autoactivate_id = 0; + priv = NM_POLICY_GET_PRIVATE (self); // FIXME: if a device is already activating (or activated) with a connection // but another connection now overrides the current one for that device, // deactivate the device and activate the new connection instead of just // bailing if the device is already active - if (nm_device_get_act_request (data->device)) - goto out; + if (nm_device_get_act_request (device)) + return; connection_list = nm_manager_get_activatable_connections (priv->manager); if (!connection_list) - goto out; + return; connections = _nm_utils_copy_slist_to_array (connection_list, NULL, NULL); g_slist_free (connection_list); @@ -708,7 +994,7 @@ auto_activate_device (gpointer user_data) if (!nm_settings_connection_can_autoconnect (candidate)) continue; - if (nm_device_can_auto_connect (data->device, (NMConnection *) candidate, &specific_object)) { + if (nm_device_can_auto_connect (device, (NMConnection *) candidate, &specific_object)) { best_connection = candidate; break; } @@ -724,8 +1010,9 @@ auto_activate_device (gpointer user_data) subject = nm_auth_subject_new_internal (); if (!nm_manager_activate_connection (priv->manager, best_connection, + NULL, specific_object, - data->device, + device, subject, &error)) { _LOGI (LOGD_DEVICE, "connection '%s' auto-activation failed: (%d) %s", @@ -736,8 +1023,19 @@ auto_activate_device (gpointer user_data) } g_object_unref (subject); } +} - out: +static gboolean +auto_activate_device_cb (gpointer user_data) +{ + ActivateData *data = user_data; + + g_assert (data); + g_assert (NM_IS_POLICY (data->policy)); + g_assert (NM_IS_DEVICE (data->device)); + + data->autoactivate_id = 0; + auto_activate_device (data->policy, data->device); activate_data_free (data); return G_SOURCE_REMOVE; } @@ -842,7 +1140,7 @@ static void hostname_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); update_system_hostname (self, NULL, NULL); } @@ -919,7 +1217,7 @@ static void sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); gboolean sleeping = FALSE, enabled = FALSE; g_object_get (G_OBJECT (manager), NM_MANAGER_SLEEPING, &sleeping, NULL); @@ -960,7 +1258,7 @@ schedule_activate_check (NMPolicy *self, NMDevice *device) data = g_slice_new0 (ActivateData); data->policy = self; data->device = g_object_ref (device); - data->autoactivate_id = g_idle_add (auto_activate_device, data); + data->autoactivate_id = g_idle_add (auto_activate_device_cb, data); priv->pending_activation_checks = g_slist_append (priv->pending_activation_checks, data); } @@ -1117,6 +1415,7 @@ activate_secondary_connections (NMPolicy *self, nm_connection_get_id (connection), nm_connection_get_uuid (connection)); ac = nm_manager_activate_connection (priv->manager, settings_con, + NULL, nm_exported_object_get_path (NM_EXPORTED_OBJECT (req)), device, nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (req)), @@ -1151,7 +1450,7 @@ device_state_changed (NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); NMSettingsConnection *connection = nm_device_get_settings_connection (device); @@ -1168,17 +1467,18 @@ device_state_changed (NMDevice *device, if ( connection && old_state >= NM_DEVICE_STATE_PREPARE && old_state <= NM_DEVICE_STATE_ACTIVATED) { - guint32 tries = nm_settings_connection_get_autoconnect_retries (connection); + int tries = nm_settings_connection_get_autoconnect_retries (connection); if (reason == NM_DEVICE_STATE_REASON_NO_SECRETS) { _LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets", nm_settings_connection_get_id (connection)); nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NO_SECRETS); - } else if (tries > 0) { + } else if (tries != 0) { _LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left", nm_settings_connection_get_id (connection), tries); - nm_settings_connection_set_autoconnect_retries (connection, tries - 1); + if (tries > 0) + nm_settings_connection_set_autoconnect_retries (connection, tries - 1); } if (nm_settings_connection_get_autoconnect_retries (connection) == 0) { @@ -1242,6 +1542,7 @@ device_state_changed (NMDevice *device, } } } + ip6_remove_device_prefix_delegations (self, device); break; case NM_DEVICE_STATE_DISCONNECTED: /* Reset retry counts for a device's connections when carrier on; if cable @@ -1297,7 +1598,7 @@ device_ip4_config_changed (NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); const char *ip_iface = nm_device_get_ip_iface (device); nm_dns_manager_begin_updates (priv->dns_manager, __func__); @@ -1306,7 +1607,7 @@ device_ip4_config_changed (NMDevice *device, * catch all the changes when the device moves to ACTIVATED state. * Prevents unecessary changes to DNS information. */ - if (!nm_device_is_activating (device)) { + if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) { if (old_config != new_config) { if (old_config) nm_dns_manager_remove_ip4_config (priv->dns_manager, old_config); @@ -1332,7 +1633,7 @@ device_ip6_config_changed (NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); const char *ip_iface = nm_device_get_ip_iface (device); nm_dns_manager_begin_updates (priv->dns_manager, __func__); @@ -1360,13 +1661,15 @@ device_ip6_config_changed (NMDevice *device, nm_dns_manager_end_updates (priv->dns_manager, __func__); } +/*****************************************************************************/ + static void device_autoconnect_changed (NMDevice *device, GParamSpec *pspec, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); if (nm_device_autoconnect_allowed (device)) schedule_activate_check (self, device); @@ -1376,7 +1679,7 @@ static void device_recheck_auto_activate (NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); schedule_activate_check (self, device); } @@ -1398,6 +1701,8 @@ devices_list_register (NMPolicy *self, NMDevice *device) g_signal_connect_after (device, NM_DEVICE_STATE_CHANGED, (GCallback) device_state_changed, priv); g_signal_connect (device, NM_DEVICE_IP4_CONFIG_CHANGED, (GCallback) device_ip4_config_changed, priv); g_signal_connect (device, NM_DEVICE_IP6_CONFIG_CHANGED, (GCallback) device_ip6_config_changed, priv); + g_signal_connect (device, NM_DEVICE_IP6_PREFIX_DELEGATED, (GCallback) device_ip6_prefix_delegated, priv); + g_signal_connect (device, NM_DEVICE_IP6_SUBNET_NEEDED, (GCallback) device_ip6_subnet_needed, priv); g_signal_connect (device, "notify::" NM_DEVICE_AUTOCONNECT, (GCallback) device_autoconnect_changed, priv); g_signal_connect (device, NM_DEVICE_RECHECK_AUTO_ACTIVATE, (GCallback) device_recheck_auto_activate, priv); } @@ -1406,7 +1711,7 @@ static void device_added (NMManager *manager, NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); g_return_if_fail (NM_IS_POLICY (self)); @@ -1422,7 +1727,11 @@ static void device_removed (NMManager *manager, NMDevice *device, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); + + /* XXX is this needed? The delegations are cleaned up + * on transition to deactivated too. */ + ip6_remove_device_prefix_delegations (self, device); /* Clear any idle callbacks for this device */ clear_pending_activate_check (self, device); @@ -1435,7 +1744,7 @@ device_removed (NMManager *manager, NMDevice *device, gpointer user_data) */ } -/**************************************************************************/ +/*****************************************************************************/ static void vpn_connection_activated (NMPolicy *self, NMVpnConnection *vpn) @@ -1520,6 +1829,7 @@ vpn_connection_retry_after_failure (NMVpnConnection *vpn, NMPolicy *self) connection, NULL, NULL, + NULL, nm_active_connection_get_subject (ac), &error)) { _LOGW (LOGD_DEVICE, "VPN '%s' reconnect failed: %s", @@ -1548,7 +1858,7 @@ active_connection_added (NMManager *manager, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); if (NM_IS_VPN_CONNECTION (active)) { g_signal_connect (active, NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED, @@ -1570,7 +1880,7 @@ active_connection_removed (NMManager *manager, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); g_signal_handlers_disconnect_by_func (active, vpn_connection_state_changed, @@ -1583,7 +1893,7 @@ active_connection_removed (NMManager *manager, self); } -/**************************************************************************/ +/*****************************************************************************/ static gboolean schedule_activate_all_cb (gpointer user_data) @@ -1617,7 +1927,7 @@ connection_added (NMSettings *settings, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); schedule_activate_all (self); } @@ -1675,7 +1985,7 @@ connection_updated (NMSettings *settings, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); const GSList *iter; NMDevice *device = NULL; @@ -1743,7 +2053,7 @@ connection_visibility_changed (NMSettings *settings, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); if (nm_settings_connection_is_visible (connection)) schedule_activate_all (self); @@ -1757,7 +2067,7 @@ secret_agent_registered (NMSettings *settings, gpointer user_data) { NMPolicyPrivate *priv = user_data; - NMPolicy *self = priv->self; + NMPolicy *self = _PRIV_TO_SELF (priv); /* The registered secret agent may provide some missing secrets. Thus we * reset retries count here and schedule activation, so that the @@ -1848,12 +2158,11 @@ set_property (GObject *object, guint prop_id, static void nm_policy_init (NMPolicy *self) { - NMPolicyPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_POLICY, NMPolicyPrivate); - - self->priv = priv; - priv->self = self; + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); priv->devices = g_hash_table_new (NULL, NULL); + priv->ip6_prefix_delegations = g_array_new (FALSE, FALSE, sizeof (IP6PrefixDelegation)); + g_array_set_clear_func (priv->ip6_prefix_delegations, clear_ip6_prefix_delegation); } static void @@ -1974,6 +2283,11 @@ dispose (GObject *object) g_signal_handlers_disconnect_by_data (priv->manager, priv); } + if (priv->ip6_prefix_delegations) { + g_array_free (priv->ip6_prefix_delegations, TRUE); + priv->ip6_prefix_delegations = NULL; + } + nm_assert (NM_IS_MANAGER (priv->manager)); G_OBJECT_CLASS (nm_policy_parent_class)->dispose (object); @@ -1988,8 +2302,6 @@ finalize (GObject *object) g_hash_table_unref (priv->devices); G_OBJECT_CLASS (nm_policy_parent_class)->finalize (object); - - priv->self = NULL; } static void @@ -1997,8 +2309,6 @@ nm_policy_class_init (NMPolicyClass *policy_class) { GObjectClass *object_class = G_OBJECT_CLASS (policy_class); - g_type_class_add_private (policy_class, sizeof (NMPolicyPrivate)); - object_class->get_property = get_property; object_class->set_property = set_property; object_class->constructed = constructed; @@ -2037,5 +2347,6 @@ nm_policy_class_init (NMPolicyClass *policy_class) NM_TYPE_DEVICE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/nm-policy.h b/src/nm-policy.h index ce900ba6..64cac4fe 100644 --- a/src/nm-policy.h +++ b/src/nm-policy.h @@ -36,17 +36,7 @@ #define NM_POLICY_ACTIVATING_IP4_DEVICE "activating-ip4-device" #define NM_POLICY_ACTIVATING_IP6_DEVICE "activating-ip6-device" -struct _NMPolicyPrivate; - -struct _NMPolicy { - GObject parent; - struct _NMPolicyPrivate *priv; -}; - -typedef struct { - GObjectClass parent; - -} NMPolicyClass; +typedef struct _NMPolicyClass NMPolicyClass; GType nm_policy_get_type (void); diff --git a/src/nm-proxy-config.c b/src/nm-proxy-config.c new file mode 100644 index 00000000..e051367a --- /dev/null +++ b/src/nm-proxy-config.c @@ -0,0 +1,187 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2016 Atul Anand . + */ + +#include "nm-default.h" + +#include "nm-proxy-config.h" + +#include + +#include "nm-core-internal.h" + +/*****************************************************************************/ + +typedef struct { + NMProxyConfigMethod method; + gboolean browser_only; + char *pac_url; + char *pac_script; +} NMProxyConfigPrivate; + +struct _NMProxyConfig { + GObject parent; + NMProxyConfigPrivate _priv; +}; + +struct _NMProxyConfigClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) + +#define NM_PROXY_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMProxyConfig, NM_IS_PROXY_CONFIG) + +/*****************************************************************************/ + +void +nm_proxy_config_set_method (NMProxyConfig *config, NMProxyConfigMethod method) +{ + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + priv->method = method; +} + +NMProxyConfigMethod +nm_proxy_config_get_method (const NMProxyConfig *config) +{ + const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + return priv->method; +} + +void +nm_proxy_config_merge_setting (NMProxyConfig *config, NMSettingProxy *setting) +{ + const char *tmp = NULL; + NMProxyConfigPrivate *priv; + NMSettingProxyMethod method; + + if (!setting) + return; + + g_return_if_fail (NM_IS_SETTING_PROXY (setting)); + + priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + g_clear_pointer (&priv->pac_script, g_free); + + method = nm_setting_proxy_get_method (setting); + switch (method) { + case NM_SETTING_PROXY_METHOD_AUTO: + priv->method = NM_PROXY_CONFIG_METHOD_AUTO; + + /* Free DHCP Obtained PAC Url (i.e Option 252) + * only when libnm overrides it. + */ + tmp = nm_setting_proxy_get_pac_url (setting); + if (tmp) { + g_free (priv->pac_url); + priv->pac_url = g_strdup (tmp); + } + + tmp = nm_setting_proxy_get_pac_script (setting); + priv->pac_script = g_strdup (tmp); + + break; + case NM_SETTING_PROXY_METHOD_NONE: + priv->method = NM_PROXY_CONFIG_METHOD_NONE; + break; + } + + priv->browser_only = nm_setting_proxy_get_browser_only (setting); +} + +gboolean +nm_proxy_config_get_browser_only (const NMProxyConfig *config) +{ + const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + return priv->browser_only; +} + +void +nm_proxy_config_set_pac_url (NMProxyConfig *config, const char *url) +{ + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + g_free (priv->pac_url); + priv->pac_url = g_strdup (url); +} + +const char * +nm_proxy_config_get_pac_url (const NMProxyConfig *config) +{ + const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + return priv->pac_url; +} + +void +nm_proxy_config_set_pac_script (NMProxyConfig *config, const char *script) +{ + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + g_free (priv->pac_script); + priv->pac_script = g_strdup (script); +} + +const char * +nm_proxy_config_get_pac_script (const NMProxyConfig *config) +{ + const NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + return priv->pac_script; +} + +/*****************************************************************************/ + +static void +nm_proxy_config_init (NMProxyConfig *config) +{ + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); + + priv->method = NM_PROXY_CONFIG_METHOD_NONE; +} + +NMProxyConfig * +nm_proxy_config_new (void) +{ + return NM_PROXY_CONFIG (g_object_new (NM_TYPE_PROXY_CONFIG, NULL)); +} + +static void +finalize (GObject *object) +{ + NMProxyConfig *self = NM_PROXY_CONFIG (object); + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (self); + + g_free (priv->pac_url); + g_free (priv->pac_script); + + G_OBJECT_CLASS (nm_proxy_config_parent_class)->finalize (object); +} + +static void +nm_proxy_config_class_init (NMProxyConfigClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = finalize; +} diff --git a/src/nm-proxy-config.h b/src/nm-proxy-config.h new file mode 100644 index 00000000..2712e43f --- /dev/null +++ b/src/nm-proxy-config.h @@ -0,0 +1,57 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2016 Atul Anand . + */ + +#ifndef __NETWORKMANAGER_PROXY_CONFIG_H__ +#define __NETWORKMANAGER_PROXY_CONFIG_H__ + +#include "nm-setting-proxy.h" + +typedef enum { + NM_PROXY_CONFIG_METHOD_AUTO = 0, + NM_PROXY_CONFIG_METHOD_NONE +} NMProxyConfigMethod; + +#define NM_TYPE_PROXY_CONFIG (nm_proxy_config_get_type ()) +#define NM_PROXY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PROXY_CONFIG, NMProxyConfig)) +#define NM_PROXY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PROXY_CONFIG, NMProxyConfigClass)) +#define NM_IS_PROXY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PROXY_CONFIG)) +#define NM_IS_PROXY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PROXY_CONFIG)) +#define NM_PROXY_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PROXY_CONFIG, NMProxyConfigClass)) + +typedef struct _NMProxyConfigClass NMProxyConfigClass; + +GType nm_proxy_config_get_type (void); + +NMProxyConfig * nm_proxy_config_new (void); + +void nm_proxy_config_set_method (NMProxyConfig *config, NMProxyConfigMethod method); +NMProxyConfigMethod nm_proxy_config_get_method (const NMProxyConfig *config); + +void nm_proxy_config_merge_setting (NMProxyConfig *config, NMSettingProxy *setting); + +gboolean nm_proxy_config_get_browser_only (const NMProxyConfig *config); + +void nm_proxy_config_set_pac_url (NMProxyConfig *config, const char *url); +const char * nm_proxy_config_get_pac_url (const NMProxyConfig *config); + +void nm_proxy_config_set_pac_script (NMProxyConfig *config, const char *script); +const char * nm_proxy_config_get_pac_script (const NMProxyConfig *config); + +#endif /* __NETWORKMANAGER_PROXY_CONFIG_H__ */ diff --git a/src/nm-rfkill-manager.c b/src/nm-rfkill-manager.c index e4e738c9..36afd35e 100644 --- a/src/nm-rfkill-manager.c +++ b/src/nm-rfkill-manager.c @@ -20,10 +20,19 @@ #include "nm-default.h" +#include "nm-rfkill-manager.h" + #include #include -#include "nm-rfkill-manager.h" +/*****************************************************************************/ + +enum { + RFKILL_CHANGED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { GUdevClient *client; @@ -31,21 +40,22 @@ typedef struct { /* Authoritative rfkill state (RFKILL_* enum) */ RfKillState rfkill_states[RFKILL_TYPE_MAX]; GSList *killswitches; - } NMRfkillManagerPrivate; -#define NM_RFKILL_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_RFKILL_MANAGER, NMRfkillManagerPrivate)) - -G_DEFINE_TYPE (NMRfkillManager, nm_rfkill_manager, G_TYPE_OBJECT) - -enum { - RFKILL_CHANGED, +struct _NMRfkillManager { + GObject parent; + NMRfkillManagerPrivate _priv; +}; - LAST_SIGNAL +struct _NMRfkillManagerClass { + GObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_TYPE (NMRfkillManager, nm_rfkill_manager, G_TYPE_OBJECT) + +#define NM_RFKILL_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMRfkillManager, NM_IS_RFKILL_MANAGER) +/*****************************************************************************/ typedef struct { char *name; @@ -149,12 +159,6 @@ killswitch_destroy (Killswitch *ks) g_free (ks); } -NMRfkillManager * -nm_rfkill_manager_new (void) -{ - return NM_RFKILL_MANAGER (g_object_new (NM_TYPE_RFKILL_MANAGER, NULL)); -} - static RfKillState sysfs_state_to_nm_state (gint sysfs_state) { @@ -358,6 +362,8 @@ handle_uevent (GUdevClient *client, recheck_killswitches (self); } +/*****************************************************************************/ + static void nm_rfkill_manager_init (NMRfkillManager *self) { @@ -382,6 +388,12 @@ nm_rfkill_manager_init (NMRfkillManager *self) recheck_killswitches (self); } +NMRfkillManager * +nm_rfkill_manager_new (void) +{ + return NM_RFKILL_MANAGER (g_object_new (NM_TYPE_RFKILL_MANAGER, NULL)); +} + static void dispose (GObject *object) { @@ -403,17 +415,13 @@ nm_rfkill_manager_class_init (NMRfkillManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMRfkillManagerPrivate)); - - /* virtual methods */ object_class->dispose = dispose; - /* Signals */ signals[RFKILL_CHANGED] = - g_signal_new (NM_RFKILL_MANAGER_SIGNAL_RFKILL_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMRfkillManagerClass, rfkill_changed), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); + g_signal_new (NM_RFKILL_MANAGER_SIGNAL_RFKILL_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); } diff --git a/src/nm-rfkill-manager.h b/src/nm-rfkill-manager.h index 3aca8f50..490c1ca2 100644 --- a/src/nm-rfkill-manager.h +++ b/src/nm-rfkill-manager.h @@ -19,10 +19,8 @@ * Copyright (C) 2007 - 2013 Red Hat, Inc. */ -#ifndef __NETWORKMANAGER_RFKILL_MANAGER_H__ -#define __NETWORKMANAGER_RFKILL_MANAGER_H__ - -#define NM_RFKILL_MANAGER_SIGNAL_RFKILL_CHANGED "rfkill-changed" +#ifndef __NM_RFKILL_MANAGER_H__ +#define __NM_RFKILL_MANAGER_H__ typedef enum { /*< skip >*/ RFKILL_UNBLOCKED = 0, @@ -42,7 +40,6 @@ typedef enum { /*< skip >*/ RFKILL_TYPE_MAX = RFKILL_TYPE_UNKNOWN } RfKillType; - #define NM_TYPE_RFKILL_MANAGER (nm_rfkill_manager_get_type ()) #define NM_RFKILL_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_RFKILL_MANAGER, NMRfkillManager)) #define NM_RFKILL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_RFKILL_MANAGER, NMRfkillManagerClass)) @@ -50,16 +47,9 @@ typedef enum { /*< skip >*/ #define NM_IS_RFKILL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_RFKILL_MANAGER)) #define NM_RFKILL_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_RFKILL_MANAGER, NMRfkillManagerClass)) -struct _NMRfkillManager { - GObject parent; -}; - -typedef struct { - GObjectClass parent; +#define NM_RFKILL_MANAGER_SIGNAL_RFKILL_CHANGED "rfkill-changed" - /* signals */ - void (*rfkill_changed) (NMRfkillManager *manager, RfKillType rtype, RfKillState state); -} NMRfkillManagerClass; +typedef struct _NMRfkillManagerClass NMRfkillManagerClass; GType nm_rfkill_manager_get_type (void); @@ -67,5 +57,4 @@ NMRfkillManager *nm_rfkill_manager_new (void); RfKillState nm_rfkill_manager_get_rfkill_state (NMRfkillManager *manager, RfKillType rtype); -#endif /* NM_RFKILL_MANAGER_H */ - +#endif /* __NM_RFKILL_MANAGER_H__ */ diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c index 2d4c7d95..344ebc46 100644 --- a/src/nm-route-manager.c +++ b/src/nm-route-manager.c @@ -20,11 +20,12 @@ #include "nm-default.h" +#include "nm-route-manager.h" + #include -#include "nm-route-manager.h" -#include "nm-platform.h" -#include "nmp-object.h" +#include "platform/nm-platform.h" +#include "platform/nmp-object.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" @@ -34,6 +35,8 @@ #define IP4_DEVICE_ROUTES_GC_INTERVAL_SEC (IP4_DEVICE_ROUTES_WAIT_TIME_NS * 2) +/*****************************************************************************/ + typedef struct { guint len; NMPlatformIPXRoute *entries[1]; @@ -58,6 +61,12 @@ typedef struct { NMPObject *obj; } IP4DeviceRoutePurgeEntry; +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PLATFORM, +); + typedef struct { NMPlatform *platform; @@ -69,17 +78,24 @@ typedef struct { } ip4_device_routes; } NMRouteManagerPrivate; -#define NM_ROUTE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ROUTE_MANAGER, NMRouteManagerPrivate)) +struct _NMRouteManager { + GObject parent; + NMRouteManagerPrivate _priv; +}; + +struct _NMRouteManagerClass { + GObjectClass parent; +}; G_DEFINE_TYPE (NMRouteManager, nm_route_manager, G_TYPE_OBJECT); -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PLATFORM, -); +#define NM_ROUTE_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMRouteManager, NM_IS_ROUTE_MANAGER) + +/*****************************************************************************/ NM_DEFINE_SINGLETON_GETTER (NMRouteManager, nm_route_manager_get, NM_TYPE_ROUTE_MANAGER); -/*********************************************************************************************/ +/*****************************************************************************/ typedef struct { const NMPlatformVTableRoute *vt; @@ -112,7 +128,7 @@ static const VTableIP vtable_v4, vtable_v6; return 1; \ } G_STMT_END -/*********************************************************************************************/ +/*****************************************************************************/ #define _NMLOG_PREFIX_NAME "route-mgr" #undef _NMLOG_ENABLED @@ -144,11 +160,11 @@ static const VTableIP vtable_v4, vtable_v6; } \ } G_STMT_END -/*********************************************************************************************/ +/*****************************************************************************/ static gboolean _ip4_device_routes_cancel (NMRouteManager *self); -/*********************************************************************************************/ +/*****************************************************************************/ #if NM_MORE_ASSERTS && !defined (G_DISABLE_ASSERT) inline static void @@ -202,7 +218,7 @@ ASSERT_route_index_valid (const VTableIP *vtable, const GArray *entries, const R #define ASSERT_route_index_valid(vtable, entries, index, unique_ifindexes) G_STMT_START { (void) 0; } G_STMT_END #endif -/*********************************************************************************************/ +/*****************************************************************************/ static int _v4_route_dest_cmp (const NMPlatformIP4Route *r1, const NMPlatformIP4Route *r2) @@ -254,7 +270,7 @@ _v6_route_id_cmp (const NMPlatformIP6Route *r1, const NMPlatformIP6Route *r2) return 0; } -/*********************************************************************************************/ +/*****************************************************************************/ static int _route_index_create_sort (const NMPlatformIPXRoute **p1, const NMPlatformIPXRoute ** p2, const VTableIP *vtable) @@ -296,7 +312,7 @@ _route_index_find (const VTableIP *vtable, const RouteIndex *index, const NMPlat { gssize idx, idx2; - idx = _nm_utils_ptrarray_find_binary_search ((gpointer *) index->entries, index->len, (gpointer) needle, (GCompareDataFunc) _vx_route_id_cmp_full, (gpointer) vtable); + idx = _nm_utils_ptrarray_find_binary_search ((gconstpointer *) index->entries, index->len, needle, (GCompareDataFunc) _vx_route_id_cmp_full, (gpointer) vtable); if (idx < 0) return idx; @@ -340,7 +356,7 @@ _route_index_reverse_idx (const VTableIP *vtable, const RouteIndex *index, guint return offset; } -/*********************************************************************************************/ +/*****************************************************************************/ static gboolean _route_equals_ignoring_ifindex (const VTableIP *vtable, const NMPlatformIPXRoute *r1, const NMPlatformIPXRoute *r2, gint64 r2_metric) @@ -431,7 +447,7 @@ _sort_indexes_cmp (guint *a, guint *b) g_return_val_if_reached (0); } -/*********************************************************************************************/ +/*****************************************************************************/ static gboolean _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes, gboolean full_sync) @@ -951,7 +967,7 @@ nm_route_manager_route_flush (NMRouteManager *self, int ifindex) return success; } -/*********************************************************************************************/ +/*****************************************************************************/ static gboolean _ip4_device_routes_entry_expired (const IP4DeviceRoutePurgeEntry *entry, gint64 now) @@ -1011,12 +1027,13 @@ _ip4_device_routes_idle_cb (IP4DeviceRoutePurgeEntry *entry) static void _ip4_device_routes_ip4_route_changed (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, const NMPlatformIP4Route *route, - NMPlatformSignalChangeType change_type, + int change_type_i, NMRouteManager *self) { + const NMPlatformSignalChangeType change_type = change_type_i; NMRouteManagerPrivate *priv; NMPObject obj_needle; IP4DeviceRoutePurgeEntry *entry; @@ -1126,7 +1143,7 @@ nm_route_manager_ip4_route_register_device_route_purge_list (NMRouteManager *sel } } -/*********************************************************************************************/ +/*****************************************************************************/ static const VTableIP vtable_v4 = { .vt = &nm_platform_vtable_route_v4, @@ -1140,7 +1157,7 @@ static const VTableIP vtable_v6 = { .route_id_cmp = (int (*) (const NMPlatformIPXRoute *, const NMPlatformIPXRoute *)) _v6_route_id_cmp, }; -/*********************************************************************************************/ +/*****************************************************************************/ static void set_property (GObject *object, guint prop_id, @@ -1163,6 +1180,8 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + static void nm_route_manager_init (NMRouteManager *self) { @@ -1194,7 +1213,7 @@ static void dispose (GObject *object) { NMRouteManager *self = NM_ROUTE_MANAGER (object); - NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (object); + NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (self); g_hash_table_remove_all (priv->ip4_device_routes.entries); _ip4_device_routes_cancel (self); @@ -1205,7 +1224,7 @@ dispose (GObject *object) static void finalize (GObject *object) { - NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (object); + NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE ((NMRouteManager *) object); g_array_free (priv->ip4_routes.entries, TRUE); g_array_free (priv->ip6_routes.entries, TRUE); @@ -1228,9 +1247,6 @@ nm_route_manager_class_init (NMRouteManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMRouteManagerPrivate)); - - /* virtual methods */ object_class->set_property = set_property; object_class->dispose = dispose; object_class->finalize = finalize; diff --git a/src/nm-route-manager.h b/src/nm-route-manager.h index 8e2746d9..d12f0256 100644 --- a/src/nm-route-manager.h +++ b/src/nm-route-manager.h @@ -18,8 +18,8 @@ * Copyright (C) 2015 Red Hat, Inc. */ -#ifndef __NETWORKMANAGER_ROUTE_MANAGER_H__ -#define __NETWORKMANAGER_ROUTE_MANAGER_H__ +#ifndef __NM_ROUTE_MANAGER_H__ +#define __NM_ROUTE_MANAGER_H__ #define NM_TYPE_ROUTE_MANAGER (nm_route_manager_get_type ()) #define NM_ROUTE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ROUTE_MANAGER, NMRouteManager)) @@ -30,13 +30,7 @@ #define NM_ROUTE_MANAGER_PLATFORM "platform" -struct _NMRouteManager { - GObject parent; -}; - -typedef struct { - GObjectClass parent; -} NMRouteManagerClass; +typedef struct _NMRouteManagerClass NMRouteManagerClass; GType nm_route_manager_get_type (void); @@ -49,4 +43,4 @@ void nm_route_manager_ip4_route_register_device_route_purge_list (NMRouteManager NMRouteManager *nm_route_manager_get (void); NMRouteManager *nm_route_manager_new (NMPlatform *platform); -#endif /* NM_ROUTE_MANAGER_H */ +#endif /* __NM_ROUTE_MANAGER_H__ */ diff --git a/src/nm-session-monitor.c b/src/nm-session-monitor.c index fb656c6b..b37db362 100644 --- a/src/nm-session-monitor.c +++ b/src/nm-session-monitor.c @@ -21,29 +21,30 @@ */ #include "nm-default.h" +#include "nm-session-monitor.h" + #include #include #include #include -#include "nm-session-monitor.h" -#include "NetworkManagerUtils.h" - #ifdef SESSION_TRACKING_SYSTEMD #include #endif -/********************************************************************/ +#include "NetworkManagerUtils.h" + +/*****************************************************************************/ + +enum { + CHANGED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; -/* - * SECTION:nm-session-monitor - * @title: NMSessionMonitor - * @short_description: Monitor sessions - * - * The #NMSessionMonitor class is a utility class to track and monitor sessions. - */ struct _NMSessionMonitor { - GObject parent_instance; + GObject parent; #ifdef SESSION_TRACKING_SYSTEMD struct { @@ -62,32 +63,13 @@ struct _NMSessionMonitor { }; struct _NMSessionMonitorClass { - GObjectClass parent_class; - - void (*changed) (NMSessionMonitor *monitor); + GObjectClass parent; }; G_DEFINE_TYPE (NMSessionMonitor, nm_session_monitor, G_TYPE_OBJECT); -enum { - CHANGED, - LAST_SIGNAL, -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/********************************************************************/ - -#define _NMLOG_PREFIX_NAME "session-monitor" -#define _NMLOG_DOMAIN LOGD_CORE - -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log (level, _NMLOG_DOMAIN, \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END +#define _NMLOG_DOMAIN LOGD_CORE +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "session-monitor", __VA_ARGS__) /*****************************************************************************/ @@ -148,7 +130,7 @@ st_sd_finalize (NMSessionMonitor *monitor) } #endif /* SESSION_TRACKING_SYSTEMD */ -/********************************************************************/ +/*****************************************************************************/ #ifdef SESSION_TRACKING_CONSOLEKIT typedef struct { @@ -286,7 +268,7 @@ ck_finalize (NMSessionMonitor *monitor) } #endif /* SESSION_TRACKING_CONSOLEKIT */ -/********************************************************************/ +/*****************************************************************************/ NM_DEFINE_SINGLETON_GETTER (NMSessionMonitor, nm_session_monitor_get, NM_TYPE_SESSION_MONITOR); @@ -368,7 +350,7 @@ nm_session_monitor_session_exists (NMSessionMonitor *self, return FALSE; } -/********************************************************************/ +/*****************************************************************************/ static void nm_session_monitor_init (NMSessionMonitor *monitor) @@ -385,7 +367,7 @@ nm_session_monitor_init (NMSessionMonitor *monitor) } static void -nm_session_monitor_finalize (GObject *object) +finalize (GObject *object) { #ifdef SESSION_TRACKING_SYSTEMD st_sd_finalize (NM_SESSION_MONITOR (object)); @@ -395,8 +377,7 @@ nm_session_monitor_finalize (GObject *object) ck_finalize (NM_SESSION_MONITOR (object)); #endif - if (G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize != NULL) - G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize (object); + G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize (object); } static void @@ -404,7 +385,7 @@ nm_session_monitor_class_init (NMSessionMonitorClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = nm_session_monitor_finalize; + gobject_class->finalize = finalize; /** * NMSessionMonitor::changed: @@ -413,12 +394,10 @@ nm_session_monitor_class_init (NMSessionMonitorClass *klass) * Emitted when something changes. */ signals[CHANGED] = g_signal_new (NM_SESSION_MONITOR_CHANGED, - NM_TYPE_SESSION_MONITOR, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSessionMonitorClass, changed), - NULL, /* accumulator */ - NULL, /* accumulator data */ - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + NM_TYPE_SESSION_MONITOR, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); } diff --git a/src/nm-session-monitor.h b/src/nm-session-monitor.h index 3751d7db..d3d10e98 100644 --- a/src/nm-session-monitor.h +++ b/src/nm-session-monitor.h @@ -30,19 +30,16 @@ #define NM_SESSION_MONITOR_CHANGED "changed" -typedef struct _NMSessionMonitorClass NMSessionMonitorClass; +typedef struct _NMSessionMonitorClass NMSessionMonitorClass; -typedef void (*NMSessionCallback) (NMSessionMonitor *monitor, gpointer user_data); - -GType nm_session_monitor_get_type (void) G_GNUC_CONST; +GType nm_session_monitor_get_type (void) G_GNUC_CONST; NMSessionMonitor *nm_session_monitor_get (void); -gboolean nm_session_monitor_uid_to_user (uid_t uid, const char **out_user); -gboolean nm_session_monitor_user_to_uid (const char *user, uid_t *out_uid); -gboolean nm_session_monitor_session_exists (NMSessionMonitor *self, - uid_t uid, - gboolean active); +gboolean nm_session_monitor_uid_to_user (uid_t uid, const char **out_user); +gboolean nm_session_monitor_user_to_uid (const char *user, uid_t *out_uid); +gboolean nm_session_monitor_session_exists (NMSessionMonitor *self, + uid_t uid, + gboolean active); #endif /* __NETWORKMANAGER_SESSION_MONITOR_H__ */ - diff --git a/src/nm-sleep-monitor.c b/src/nm-sleep-monitor.c index 13ce1be0..3be542c7 100644 --- a/src/nm-sleep-monitor.c +++ b/src/nm-sleep-monitor.c @@ -64,8 +64,17 @@ #endif +/*****************************************************************************/ + +enum { + SLEEPING, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = {0}; + struct _NMSleepMonitor { - GObject parent_instance; + GObject parent; GDBusProxy *proxy; @@ -81,29 +90,19 @@ struct _NMSleepMonitor { }; struct _NMSleepMonitorClass { - GObjectClass parent_class; + GObjectClass parent; }; -enum { - SLEEPING, - LAST_SIGNAL, -}; -static guint signals[LAST_SIGNAL] = {0}; - G_DEFINE_TYPE (NMSleepMonitor, nm_sleep_monitor, G_TYPE_OBJECT); -static void sleep_signal (NMSleepMonitor *self, gboolean is_about_to_suspend); +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SUSPEND +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, _NMLOG_PREFIX_NAME, __VA_ARGS__) /*****************************************************************************/ -#define _NMLOG_DOMAIN LOGD_SUSPEND -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - _NMLOG_PREFIX_NAME \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } G_STMT_END +static void sleep_signal (NMSleepMonitor *self, gboolean is_about_to_suspend); /*****************************************************************************/ @@ -337,6 +336,8 @@ on_proxy_acquired (GObject *object, #endif } +/*****************************************************************************/ + static void nm_sleep_monitor_init (NMSleepMonitor *self) { diff --git a/src/nm-sleep-monitor.h b/src/nm-sleep-monitor.h index d54aebbc..350f1eec 100644 --- a/src/nm-sleep-monitor.h +++ b/src/nm-sleep-monitor.h @@ -29,10 +29,11 @@ #define NM_SLEEP_MONITOR_SLEEPING "sleeping" -typedef struct _NMSleepMonitorClass NMSleepMonitorClass; +typedef struct _NMSleepMonitorClass NMSleepMonitorClass; -GType nm_sleep_monitor_get_type (void) G_GNUC_CONST; -NMSleepMonitor *nm_sleep_monitor_new (void); +GType nm_sleep_monitor_get_type (void) G_GNUC_CONST; + +NMSleepMonitor *nm_sleep_monitor_new (void); typedef struct _NMSleepMonitorInhibitorHandle NMSleepMonitorInhibitorHandle; diff --git a/src/nm-types.h b/src/nm-types.h index 1fbf043e..c323c9a7 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -42,15 +42,18 @@ typedef struct _NMDefaultRouteManager NMDefaultRouteManager; typedef struct _NMDevice NMDevice; typedef struct _NMDhcp4Config NMDhcp4Config; typedef struct _NMDhcp6Config NMDhcp6Config; +typedef struct _NMProxyConfig NMProxyConfig; typedef struct _NMIP4Config NMIP4Config; typedef struct _NMIP6Config NMIP6Config; typedef struct _NMManager NMManager; typedef struct _NMPolicy NMPolicy; typedef struct _NMRfkillManager NMRfkillManager; +typedef struct _NMPacrunnerManager NMPacrunnerManager; typedef struct _NMRouteManager NMRouteManager; typedef struct _NMSessionMonitor NMSessionMonitor; typedef struct _NMSleepMonitor NMSleepMonitor; typedef struct _NMLldpListener NMLldpListener; +typedef struct _NMConfigDeviceStateData NMConfigDeviceStateData; typedef enum { /* In priority order; higher number == higher priority */ @@ -76,7 +79,7 @@ typedef enum { NM_IP_CONFIG_SOURCE_WWAN, NM_IP_CONFIG_SOURCE_VPN, NM_IP_CONFIG_SOURCE_DHCP, - NM_IP_CONFIG_SOURCE_RDISC, + NM_IP_CONFIG_SOURCE_NDISC, NM_IP_CONFIG_SOURCE_USER, } NMIPConfigSource; @@ -126,6 +129,7 @@ typedef enum { NM_LINK_TYPE_IP6TNL, NM_LINK_TYPE_IPIP, NM_LINK_TYPE_LOOPBACK, + NM_LINK_TYPE_MACSEC, NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP, NM_LINK_TYPE_OPENVSWITCH, @@ -157,6 +161,7 @@ typedef enum { NMP_OBJECT_TYPE_LNK_INFINIBAND, NMP_OBJECT_TYPE_LNK_IP6TNL, NMP_OBJECT_TYPE_LNK_IPIP, + NMP_OBJECT_TYPE_LNK_MACSEC, NMP_OBJECT_TYPE_LNK_MACVLAN, NMP_OBJECT_TYPE_LNK_MACVTAP, NMP_OBJECT_TYPE_LNK_SIT, diff --git a/src/platform/Makefile.am b/src/platform/Makefile.am deleted file mode 100644 index 3c6155b9..00000000 --- a/src/platform/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = tests diff --git a/src/platform/Makefile.in b/src/platform/Makefile.in deleted file mode 100644 index be78d19f..00000000 --- a/src/platform/Makefile.in +++ /dev/null @@ -1,781 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/platform -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = tests -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/platform/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/platform/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index 8a4f69b6..b92f56ce 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -36,7 +36,39 @@ #include "nm-test-utils-core.h" -/*********************************************************************************************/ +/*****************************************************************************/ + +typedef struct { + NMPlatformLink link; + + char *udi; + NMPObject *lnk; + struct in6_addr ip6_lladdr; +} NMFakePlatformLink; + +typedef struct { + GHashTable *options; + GArray *links; + GArray *ip4_addresses; + GArray *ip6_addresses; + GArray *ip4_routes; + GArray *ip6_routes; +} NMFakePlatformPrivate; + +struct _NMFakePlatform { + NMPlatform parent; + NMFakePlatformPrivate _priv; +}; + +struct _NMFakePlatformClass { + NMPlatformClass parent; +}; + +G_DEFINE_TYPE (NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM) + +#define NM_FAKE_PLATFORM_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMFakePlatform, NM_IS_FAKE_PLATFORM) + +/*****************************************************************************/ #define _NMLOG_PREFIX_NAME "platform-fake" #define _NMLOG_DOMAIN LOGD_PLATFORM @@ -62,30 +94,7 @@ } \ } G_STMT_END -/*********************************************************************************************/ - -typedef struct { - GHashTable *options; - GArray *links; - GArray *ip4_addresses; - GArray *ip6_addresses; - GArray *ip4_routes; - GArray *ip6_routes; -} NMFakePlatformPrivate; - -typedef struct { - NMPlatformLink link; - - char *udi; - NMPObject *lnk; - struct in6_addr ip6_lladdr; -} NMFakePlatformLink; - -#define NM_FAKE_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_FAKE_PLATFORM, NMFakePlatformPrivate)) - -G_DEFINE_TYPE (NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM) - -/******************************************************************/ +/*****************************************************************************/ static void link_changed (NMPlatform *platform, NMFakePlatformLink *device, gboolean raise_signal); @@ -99,7 +108,7 @@ static gboolean ip6_address_add (NMPlatform *platform, guint flags); static gboolean ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen); -/******************************************************************/ +/*****************************************************************************/ static gboolean _ip4_address_equal_peer_net (in_addr_t peer1, in_addr_t peer2, guint8 plen) @@ -107,12 +116,32 @@ _ip4_address_equal_peer_net (in_addr_t peer1, in_addr_t peer2, guint8 plen) return ((peer1 ^ peer2) & nm_utils_ip4_prefix_to_netmask (plen)) == 0; } -/******************************************************************/ +/*****************************************************************************/ + +#define ASSERT_SYSCTL_ARGS(pathid, dirfd, path) \ + G_STMT_START { \ + const char *const _pathid = (pathid); \ + const int _dirfd = (dirfd); \ + const char *const _path = (path); \ + \ + g_assert (_path && _path[0]); \ + g_assert (!strstr (_path, "/../")); \ + if (_dirfd < 0) { \ + g_assert (!_pathid); \ + g_assert (_path[0] == '/'); \ + g_assert ( g_str_has_prefix (_path, "/proc/sys/") \ + || g_str_has_prefix (_path, "/sys/")); \ + } else { \ + g_assert_not_reached (); \ + } \ + } G_STMT_END static gboolean -sysctl_set (NMPlatform *platform, const char *path, const char *value) +sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *path, const char *value) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); + + ASSERT_SYSCTL_ARGS (pathid, dirfd, path); g_hash_table_insert (priv->options, g_strdup (path), g_strdup (value)); @@ -120,9 +149,11 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value) } static char * -sysctl_get (NMPlatform *platform, const char *path) +sysctl_get (NMPlatform *platform, const char *pathid, int dirfd, const char *path) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); + + ASSERT_SYSCTL_ARGS (pathid, dirfd, path); return g_strdup (g_hash_table_lookup (priv->options, path)); } @@ -186,7 +217,7 @@ link_init (NMFakePlatformLink *device, int ifindex, int type, const char *name) static NMFakePlatformLink * link_get (NMPlatform *platform, int ifindex) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMFakePlatformLink *device; if (ifindex >= priv->links->len) @@ -204,7 +235,7 @@ not_found: static GArray * link_get_all (NMPlatform *platform) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); GArray *links = g_array_sized_new (TRUE, TRUE, sizeof (NMPlatformLink), priv->links->len); int i; @@ -226,7 +257,7 @@ _nm_platform_link_get (NMPlatform *platform, int ifindex) static const NMPlatformLink * _nm_platform_link_get_by_ifname (NMPlatform *platform, const char *ifname) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); guint i; for (i = 0; i < priv->links->len; i++) { @@ -243,7 +274,7 @@ _nm_platform_link_get_by_address (NMPlatform *platform, gconstpointer address, size_t length) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); guint i; if ( length == 0 @@ -296,7 +327,7 @@ link_add (NMPlatform *platform, size_t address_len, const NMPlatformLink **out_link) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMFakePlatformLink device; NMFakePlatformLink *new_device; @@ -312,7 +343,7 @@ link_add (NMPlatform *platform, new_device = &g_array_index (priv->links, NMFakePlatformLink, priv->links->len - 1); if (device.link.ifindex) { - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, device.link.ifindex, &device, NM_PLATFORM_SIGNAL_ADDED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, (int) NMP_OBJECT_TYPE_LINK, device.link.ifindex, &device, (int) NM_PLATFORM_SIGNAL_ADDED); link_changed (platform, &g_array_index (priv->links, NMFakePlatformLink, priv->links->len - 1), FALSE); } @@ -325,7 +356,7 @@ link_add (NMPlatform *platform, static gboolean link_delete (NMPlatform *platform, int ifindex) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMFakePlatformLink *device = link_get (platform, ifindex); NMPlatformLink deleted_device; int i; @@ -364,7 +395,7 @@ link_delete (NMPlatform *platform, int ifindex) memset (route, 0, sizeof (*route)); } - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, ifindex, &deleted_device, NM_PLATFORM_SIGNAL_REMOVED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, (int) NMP_OBJECT_TYPE_LINK, ifindex, &deleted_device, (int) NM_PLATFORM_SIGNAL_REMOVED); return TRUE; } @@ -378,11 +409,11 @@ link_get_type_name (NMPlatform *platform, int ifindex) static void link_changed (NMPlatform *platform, NMFakePlatformLink *device, gboolean raise_signal) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; if (raise_signal) - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, device->link.ifindex, &device->link, NM_PLATFORM_SIGNAL_CHANGED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, (int) NMP_OBJECT_TYPE_LINK, device->link.ifindex, &device->link, (int) NM_PLATFORM_SIGNAL_CHANGED); if (device->link.ifindex && !IN6_IS_ADDR_UNSPECIFIED (&device->ip6_lladdr)) { if (device->link.connected) @@ -839,12 +870,12 @@ mesh_set_ssid (NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len) return FALSE; } -/******************************************************************/ +/*****************************************************************************/ static GArray * ip4_address_get_all (NMPlatform *platform, int ifindex) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); GArray *addresses; NMPlatformIP4Address *address; int count = 0, i; @@ -871,7 +902,7 @@ ip4_address_get_all (NMPlatform *platform, int ifindex) static GArray * ip6_address_get_all (NMPlatform *platform, int ifindex) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); GArray *addresses; NMPlatformIP6Address *address; int count = 0, i; @@ -907,7 +938,7 @@ ip4_address_add (NMPlatform *platform, guint32 flags, const char *label) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMPlatformIP4Address address; int i; @@ -938,12 +969,12 @@ ip4_address_add (NMPlatform *platform, memcpy (item, &address, sizeof (address)); if (changed) - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_CHANGED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_CHANGED); return TRUE; } g_array_append_val (priv->ip4_addresses, address); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_ADDED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_ADDED); return TRUE; } @@ -958,7 +989,7 @@ ip6_address_add (NMPlatform *platform, guint32 preferred, guint32 flags) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMPlatformIP6Address address; int i; @@ -985,12 +1016,12 @@ ip6_address_add (NMPlatform *platform, memcpy (item, &address, sizeof (address)); if (changed) - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_CHANGED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_CHANGED); return TRUE; } g_array_append_val (priv->ip6_addresses, address); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_ADDED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_ADDED); return TRUE; } @@ -998,7 +1029,7 @@ ip6_address_add (NMPlatform *platform, static gboolean ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen, in_addr_t peer_address) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; for (i = 0; i < priv->ip4_addresses->len; i++) { @@ -1012,7 +1043,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 pl memcpy (&deleted_address, address, sizeof (deleted_address)); memset (address, 0, sizeof (*address)); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &deleted_address, NM_PLATFORM_SIGNAL_REMOVED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &deleted_address, (int) NM_PLATFORM_SIGNAL_REMOVED); return TRUE; } } @@ -1023,7 +1054,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 pl static gboolean ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; for (i = 0; i < priv->ip6_addresses->len; i++) { @@ -1036,7 +1067,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, gui memcpy (&deleted_address, address, sizeof (deleted_address)); memset (address, 0, sizeof (*address)); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &deleted_address, NM_PLATFORM_SIGNAL_REMOVED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &deleted_address, (int) NM_PLATFORM_SIGNAL_REMOVED); return TRUE; } } @@ -1047,7 +1078,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, gui static const NMPlatformIP4Address * ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen, in_addr_t peer_address) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; for (i = 0; i < priv->ip4_addresses->len; i++) { @@ -1066,7 +1097,7 @@ ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen, static const NMPlatformIP6Address * ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; for (i = 0; i < priv->ip6_addresses->len; i++) { @@ -1081,12 +1112,12 @@ ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 return NULL; } -/******************************************************************/ +/*****************************************************************************/ static GArray * ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags flags) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); GArray *routes; NMPlatformIP4Route *route; guint i; @@ -1116,7 +1147,7 @@ ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags fl static GArray * ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags flags) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); GArray *routes; NMPlatformIP6Route *route; guint i; @@ -1146,7 +1177,7 @@ ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags fl static gboolean ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, guint8 plen, guint32 metric) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; for (i = 0; i < priv->ip4_routes->len; i++) { @@ -1161,7 +1192,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, guint8 p memcpy (&deleted_route, route, sizeof (deleted_route)); g_array_remove_index (priv->ip4_routes, i); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &deleted_route, (int) NM_PLATFORM_SIGNAL_REMOVED); } return TRUE; @@ -1170,7 +1201,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, guint8 p static gboolean ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, guint8 plen, guint32 metric) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; metric = nm_utils_ip6_route_metric_normalize (metric); @@ -1187,7 +1218,7 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, gu memcpy (&deleted_route, route, sizeof (deleted_route)); g_array_remove_index (priv->ip6_routes, i); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &deleted_route, (int) NM_PLATFORM_SIGNAL_REMOVED); } return TRUE; @@ -1198,7 +1229,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, in_addr_t network, guint8 plen, in_addr_t gateway, in_addr_t pref_src, guint32 metric, guint32 mss) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMPlatformIP4Route route; guint i; guint8 scope; @@ -1251,12 +1282,12 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, } memcpy (item, &route, sizeof (route)); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_CHANGED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_CHANGED); return TRUE; } g_array_append_val (priv->ip4_routes, route); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_ADDED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_ADDED); return TRUE; } @@ -1266,7 +1297,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, struct in6_addr network, guint8 plen, struct in6_addr gateway, guint32 metric, guint32 mss) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMPlatformIP6Route route; guint i; @@ -1317,12 +1348,12 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, } memcpy (item, &route, sizeof (route)); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_CHANGED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_CHANGED); return TRUE; } g_array_append_val (priv->ip6_routes, route); - g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_ADDED); + g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_ADDED); return TRUE; } @@ -1330,7 +1361,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, static const NMPlatformIP4Route * ip4_route_get (NMPlatform *platform, int ifindex, in_addr_t network, guint8 plen, guint32 metric) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; for (i = 0; i < priv->ip4_routes->len; i++) { @@ -1349,7 +1380,7 @@ ip4_route_get (NMPlatform *platform, int ifindex, in_addr_t network, guint8 plen static const NMPlatformIP6Route * ip6_route_get (NMPlatform *platform, int ifindex, struct in6_addr network, guint8 plen, guint32 metric) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); int i; metric = nm_utils_ip6_route_metric_normalize (metric); @@ -1367,7 +1398,7 @@ ip6_route_get (NMPlatform *platform, int ifindex, struct in6_addr network, guint return NULL; } -/******************************************************************/ +/*****************************************************************************/ static void nm_fake_platform_init (NMFakePlatform *fake_platform) @@ -1404,9 +1435,9 @@ nm_fake_platform_setup (void) } static void -nm_fake_platform_finalize (GObject *object) +finalize (GObject *object) { - NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (object); + NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) object); int i; g_hash_table_unref (priv->options); @@ -1431,10 +1462,7 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMPlatformClass *platform_class = NM_PLATFORM_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMFakePlatformPrivate)); - - /* virtual methods */ - object_class->finalize = nm_fake_platform_finalize; + object_class->finalize = finalize; platform_class->sysctl_set = sysctl_set; platform_class->sysctl_get = sysctl_get; diff --git a/src/platform/nm-fake-platform.h b/src/platform/nm-fake-platform.h index 53a2ff1a..8f42d11a 100644 --- a/src/platform/nm-fake-platform.h +++ b/src/platform/nm-fake-platform.h @@ -30,17 +30,8 @@ #define NM_IS_FAKE_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_FAKE_PLATFORM)) #define NM_FAKE_PLATFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_FAKE_PLATFORM, NMFakePlatformClass)) -/******************************************************************/ - -typedef struct { - NMPlatform parent; -} NMFakePlatform; - -typedef struct { - NMPlatformClass parent; -} NMFakePlatformClass; - -/******************************************************************/ +typedef struct _NMFakePlatform NMFakePlatform; +typedef struct _NMFakePlatformClass NMFakePlatformClass; GType nm_fake_platform_get_type (void); diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index f9f4b088..2c5f0897 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -21,6 +21,7 @@ #include "nm-linux-platform.h" +#include #include #include #include @@ -51,19 +52,17 @@ #include "wifi/wifi-utils-wext.h" #include "nm-utils/unaligned.h" -#define offset_plus_sizeof(t,m) (offsetof (t,m) + sizeof (((t *) NULL)->m)) - #define VLAN_FLAG_MVRP 0x8 /* nm-internal error codes for libnl. Make sure they don't overlap. */ #define _NLE_NM_NOBUFS 500 #define _NLE_MSG_TRUNC 501 -/*********************************************************************************************/ +/*****************************************************************************/ #define IFQDISCSIZ 32 -/*********************************************************************************************/ +/*****************************************************************************/ #ifndef IFLA_PROMISCUITY #define IFLA_PROMISCUITY 30 @@ -111,7 +110,26 @@ #define IP6_FLOWINFO_TCLASS_SHIFT 20 #define IP6_FLOWINFO_FLOWLABEL_MASK 0x000FFFFF -/*********************************************************************************************/ +/*****************************************************************************/ + +#define IFLA_MACSEC_UNSPEC 0 +#define IFLA_MACSEC_SCI 1 +#define IFLA_MACSEC_PORT 2 +#define IFLA_MACSEC_ICV_LEN 3 +#define IFLA_MACSEC_CIPHER_SUITE 4 +#define IFLA_MACSEC_WINDOW 5 +#define IFLA_MACSEC_ENCODING_SA 6 +#define IFLA_MACSEC_ENCRYPT 7 +#define IFLA_MACSEC_PROTECT 8 +#define IFLA_MACSEC_INC_SCI 9 +#define IFLA_MACSEC_ES 10 +#define IFLA_MACSEC_SCB 11 +#define IFLA_MACSEC_REPLAY_PROTECT 12 +#define IFLA_MACSEC_VALIDATION 13 +#define IFLA_MACSEC_PAD 14 +#define __IFLA_MACSEC_MAX 15 + +/*****************************************************************************/ #define _NMLOG_PREFIX_NAME "platform-linux" #define _NMLOG_DOMAIN LOGD_PLATFORM @@ -239,7 +257,7 @@ static void do_request_all_no_delayed_actions (NMPlatform *platform, DelayedActi static void cache_pre_hook (NMPCache *cache, const NMPObject *old, const NMPObject *new, NMPCacheOpsType ops_type, gpointer user_data); static void cache_prune_candidates_prune (NMPlatform *platform); static gboolean event_handler_read_netlink (NMPlatform *platform, gboolean wait_for_acks); -static void _assert_netns_current (NMPlatform *platform); +static void ASSERT_NETNS_CURRENT (NMPlatform *platform); /*****************************************************************************/ @@ -367,6 +385,7 @@ static const LinkDesc linktypes[] = { { NM_LINK_TYPE_IP6TNL, "ip6tnl", "ip6tnl", NULL }, { NM_LINK_TYPE_IPIP, "ipip", "ipip", NULL }, { NM_LINK_TYPE_LOOPBACK, "loopback", NULL, NULL }, + { NM_LINK_TYPE_MACSEC, "macsec", "macsec", NULL }, { NM_LINK_TYPE_MACVLAN, "macvlan", "macvlan", NULL }, { NM_LINK_TYPE_MACVTAP, "macvtap", "macvtap", NULL }, { NM_LINK_TYPE_OPENVSWITCH, "openvswitch", "openvswitch", NULL }, @@ -547,7 +566,7 @@ _addrtime_get_lifetimes (guint32 timestamp, *out_preferred = preferred; } -/******************************************************************/ +/*****************************************************************************/ static const NMPObject * _lookup_cached_link (const NMPCache *cache, int ifindex, gboolean *completed_from_cache, const NMPObject **link_cached) @@ -568,23 +587,19 @@ _lookup_cached_link (const NMPCache *cache, int ifindex, gboolean *completed_fro return *link_cached; } -/******************************************************************/ +/*****************************************************************************/ #define DEVTYPE_PREFIX "DEVTYPE=" static char * -_linktype_read_devtype (const char *ifname) +_linktype_read_devtype (int dirfd) { - char uevent[NM_STRLEN ("/sys/class/net/123456789012345/uevent\0") + 100 /*safety*/]; char *contents = NULL; char *cont, *end; - nm_sprintf_buf (uevent, - "/sys/class/net/%s/uevent", - NM_ASSERT_VALID_PATH_COMPONENT (ifname)); - nm_assert (strlen (uevent) < sizeof (uevent) - 1); + nm_assert (dirfd >= 0); - if (!g_file_get_contents (uevent, &contents, NULL, NULL)) + if (nm_utils_file_get_contents (dirfd, "uevent", 1*1024*1024, &contents, NULL, NULL) < 0) return NULL; for (cont = contents; cont; cont = end) { end = strpbrk (cont, "\r\n"); @@ -614,7 +629,8 @@ _linktype_get_type (NMPlatform *platform, { guint i; - _assert_netns_current (platform); + ASSERT_NETNS_CURRENT (platform); + nm_assert (ifname); if (completed_from_cache) { const NMPObject *obj; @@ -635,7 +651,7 @@ _linktype_get_type (NMPlatform *platform, * of messing stuff up. */ if ( obj && !NM_IN_SET (obj->link.type, NM_LINK_TYPE_UNKNOWN, NM_LINK_TYPE_NONE) - && !g_strcmp0 (ifname, obj->link.name) + && nm_streq (ifname, obj->link.name) && ( !kind || !g_strcmp0 (kind, obj->link.kind))) { nm_assert (obj->link.kind == g_intern_string (obj->link.kind)); @@ -656,7 +672,7 @@ _linktype_get_type (NMPlatform *platform, NMPlatformTunProperties props; if ( platform - && nm_platform_link_tun_get_properties_ifname (platform, ifname, &props)) { + && nm_platform_link_tun_get_properties (platform, ifindex, &props)) { if (!g_strcmp0 (props.mode, "tap")) return NM_LINK_TYPE_TAP; if (!g_strcmp0 (props.mode, "tun")) @@ -679,50 +695,52 @@ _linktype_get_type (NMPlatform *platform, else if (arptype == ARPHRD_TUNNEL6) return NM_LINK_TYPE_IP6TNL; - if (ifname) { - char anycast_mask[NM_STRLEN ("/sys/class/net/123456789012345/anycast_mask\0") + 100 /*safety*/]; - gs_free char *driver = NULL; - gs_free char *devtype = NULL; + { + NMPUtilsEthtoolDriverInfo driver_info; /* Fallback OVS detection for kernel <= 3.16 */ - if (nmp_utils_ethtool_get_driver_info (ifname, &driver, NULL, NULL)) { - if (!g_strcmp0 (driver, "openvswitch")) + if (nmp_utils_ethtool_get_driver_info (ifindex, &driver_info)) { + if (nm_streq (driver_info.driver, "openvswitch")) return NM_LINK_TYPE_OPENVSWITCH; if (arptype == 256) { /* Some s390 CTC-type devices report 256 for the encapsulation type * for some reason, but we need to call them Ethernet. */ - if (!g_strcmp0 (driver, "ctcm")) + if (nm_streq (driver_info.driver, "ctcm")) return NM_LINK_TYPE_ETHERNET; } } + } - nm_sprintf_buf (anycast_mask, - "/sys/class/net/%s/anycast_mask", - NM_ASSERT_VALID_PATH_COMPONENT (ifname)); - nm_assert (strlen (anycast_mask) < sizeof (anycast_mask) - 1); - - if (g_file_test (anycast_mask, G_FILE_TEST_EXISTS)) - return NM_LINK_TYPE_OLPC_MESH; - - devtype = _linktype_read_devtype (ifname); - for (i = 0; devtype && i < G_N_ELEMENTS (linktypes); i++) { - if (g_strcmp0 (devtype, linktypes[i].devtype) == 0) { - if (linktypes[i].nm_type == NM_LINK_TYPE_BNEP) { - /* Both BNEP and 6lowpan use DEVTYPE=bluetooth, so we must - * use arptype to distinguish between them. - */ - if (arptype != ARPHRD_ETHER) - continue; + { + nm_auto_close int dirfd = -1; + gs_free char *devtype = NULL; + char ifname_verified[IFNAMSIZ]; + + dirfd = nmp_utils_sysctl_open_netdir (ifindex, ifname, ifname_verified); + if (dirfd >= 0) { + if (faccessat (dirfd, "anycast_mask", F_OK, 0) == 0) + return NM_LINK_TYPE_OLPC_MESH; + + devtype = _linktype_read_devtype (dirfd); + for (i = 0; devtype && i < G_N_ELEMENTS (linktypes); i++) { + if (g_strcmp0 (devtype, linktypes[i].devtype) == 0) { + if (linktypes[i].nm_type == NM_LINK_TYPE_BNEP) { + /* Both BNEP and 6lowpan use DEVTYPE=bluetooth, so we must + * use arptype to distinguish between them. + */ + if (arptype != ARPHRD_ETHER) + continue; + } + return linktypes[i].nm_type; } - return linktypes[i].nm_type; } - } - /* Fallback for drivers that don't call SET_NETDEV_DEVTYPE() */ - if (wifi_utils_is_wifi (ifindex, ifname)) - return NM_LINK_TYPE_WIFI; + /* Fallback for drivers that don't call SET_NETDEV_DEVTYPE() */ + if (wifi_utils_is_wifi (dirfd, ifname_verified)) + return NM_LINK_TYPE_WIFI; + } if (arptype == ARPHRD_ETHER) { /* Misc non-upstream WWAN drivers. rmnet is Qualcomm's proprietary @@ -811,7 +829,7 @@ _parse_af_inet6 (NMPlatform *platform, { static struct nla_policy policy[IFLA_INET6_MAX+1] = { [IFLA_INET6_FLAGS] = { .type = NLA_U32 }, - [IFLA_INET6_CACHEINFO] = { .minlen = offset_plus_sizeof(struct ifla_cacheinfo, retrans_time) }, + [IFLA_INET6_CACHEINFO] = { .minlen = nm_offsetofend (struct ifla_cacheinfo, retrans_time) }, [IFLA_INET6_CONF] = { .minlen = 4 }, [IFLA_INET6_STATS] = { .minlen = 8 }, [IFLA_INET6_ICMP6STATS] = { .minlen = 8 }, @@ -1112,6 +1130,56 @@ _parse_lnk_macvlan (const char *kind, struct nlattr *info_data) /*****************************************************************************/ +static NMPObject * +_parse_lnk_macsec (const char *kind, struct nlattr *info_data) +{ + static struct nla_policy policy[__IFLA_MACSEC_MAX] = { + [IFLA_MACSEC_SCI] = { .type = NLA_U64 }, + [IFLA_MACSEC_ICV_LEN] = { .type = NLA_U8 }, + [IFLA_MACSEC_CIPHER_SUITE] = { .type = NLA_U64 }, + [IFLA_MACSEC_WINDOW] = { .type = NLA_U32 }, + [IFLA_MACSEC_ENCODING_SA] = { .type = NLA_U8 }, + [IFLA_MACSEC_ENCRYPT] = { .type = NLA_U8 }, + [IFLA_MACSEC_PROTECT] = { .type = NLA_U8 }, + [IFLA_MACSEC_INC_SCI] = { .type = NLA_U8 }, + [IFLA_MACSEC_ES] = { .type = NLA_U8 }, + [IFLA_MACSEC_SCB] = { .type = NLA_U8 }, + [IFLA_MACSEC_REPLAY_PROTECT] = { .type = NLA_U8 }, + [IFLA_MACSEC_VALIDATION] = { .type = NLA_U8 }, + }; + struct nlattr *tb[__IFLA_MACSEC_MAX]; + int err; + NMPObject *obj; + NMPlatformLnkMacsec *props; + + if (!info_data || !nm_streq0 (kind, "macsec")) + return NULL; + + err = nla_parse_nested (tb, __IFLA_MACSEC_MAX - 1, info_data, policy); + if (err < 0) + return NULL; + + obj = nmp_object_new (NMP_OBJECT_TYPE_LNK_MACSEC, NULL); + props = &obj->lnk_macsec; + + props->sci = tb[IFLA_MACSEC_SCI] ? be64toh (nla_get_u64 (tb[IFLA_MACSEC_SCI])) : 0; + props->icv_length = tb[IFLA_MACSEC_ICV_LEN] ? nla_get_u8 (tb[IFLA_MACSEC_ICV_LEN]) : 0; + props->cipher_suite = tb [IFLA_MACSEC_CIPHER_SUITE] ? nla_get_u64 (tb[IFLA_MACSEC_CIPHER_SUITE]) : 0; + props->window = tb [IFLA_MACSEC_WINDOW] ? nla_get_u32 (tb[IFLA_MACSEC_WINDOW]) : 0; + props->encoding_sa = tb[IFLA_MACSEC_ENCODING_SA] ? !!nla_get_u8 (tb[IFLA_MACSEC_ENCODING_SA]) : 0; + props->encrypt = tb[IFLA_MACSEC_ENCRYPT] ? !!nla_get_u8 (tb[IFLA_MACSEC_ENCRYPT]) : 0; + props->protect = tb[IFLA_MACSEC_PROTECT] ? !!nla_get_u8 (tb[IFLA_MACSEC_PROTECT]) : 0; + props->include_sci = tb[IFLA_MACSEC_INC_SCI] ? !!nla_get_u8 (tb[IFLA_MACSEC_INC_SCI]) : 0; + props->es = tb[IFLA_MACSEC_ES] ? !!nla_get_u8 (tb[IFLA_MACSEC_ES]) : 0; + props->scb = tb[IFLA_MACSEC_SCB] ? !!nla_get_u8 (tb[IFLA_MACSEC_SCB]) : 0; + props->replay_protect = tb[IFLA_MACSEC_REPLAY_PROTECT] ? !!nla_get_u8 (tb[IFLA_MACSEC_REPLAY_PROTECT]) : 0; + props->validation = tb[IFLA_MACSEC_VALIDATION] ? nla_get_u8 (tb[IFLA_MACSEC_VALIDATION]) : 0; + + return obj; +} + +/*****************************************************************************/ + static NMPObject * _parse_lnk_sit (const char *kind, struct nlattr *info_data) { @@ -1219,7 +1287,7 @@ _parse_lnk_vlan (const char *kind, struct nlattr *info_data) { static struct nla_policy policy[IFLA_VLAN_MAX+1] = { [IFLA_VLAN_ID] = { .type = NLA_U16 }, - [IFLA_VLAN_FLAGS] = { .minlen = offset_plus_sizeof(struct ifla_vlan_flags, flags) }, + [IFLA_VLAN_FLAGS] = { .minlen = nm_offsetofend (struct ifla_vlan_flags, flags) }, [IFLA_VLAN_INGRESS_QOS] = { .type = NLA_NESTED }, [IFLA_VLAN_EGRESS_QOS] = { .type = NLA_NESTED }, [IFLA_VLAN_PROTOCOL] = { .type = NLA_U16 }, @@ -1406,9 +1474,9 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr [IFLA_LINKINFO] = { .type = NLA_NESTED }, [IFLA_QDISC] = { .type = NLA_STRING, .maxlen = IFQDISCSIZ }, - [IFLA_STATS] = { .minlen = offset_plus_sizeof(struct rtnl_link_stats, tx_compressed) }, - [IFLA_STATS64] = { .minlen = offset_plus_sizeof(struct rtnl_link_stats64, tx_compressed)}, - [IFLA_MAP] = { .minlen = offset_plus_sizeof(struct rtnl_link_ifmap, port) }, + [IFLA_STATS] = { .minlen = nm_offsetofend (struct rtnl_link_stats, tx_compressed) }, + [IFLA_STATS64] = { .minlen = nm_offsetofend (struct rtnl_link_stats64, tx_compressed)}, + [IFLA_MAP] = { .minlen = nm_offsetofend (struct rtnl_link_ifmap, port) }, [IFLA_IFALIAS] = { .type = NLA_STRING, .maxlen = IFALIASZ }, [IFLA_NUM_VF] = { .type = NLA_U32 }, [IFLA_AF_SPEC] = { .type = NLA_NESTED }, @@ -1558,6 +1626,9 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr case NM_LINK_TYPE_IPIP: lnk_data = _parse_lnk_ipip (nl_info_kind, nl_info_data); break; + case NM_LINK_TYPE_MACSEC: + lnk_data = _parse_lnk_macsec (nl_info_kind, nl_info_data); + break; case NM_LINK_TYPE_MACVLAN: case NM_LINK_TYPE_MACVTAP: lnk_data = _parse_lnk_macvlan (nl_info_kind, nl_info_data); @@ -1630,7 +1701,7 @@ _new_from_nl_addr (struct nlmsghdr *nlh, gboolean id_only) static struct nla_policy policy[IFA_MAX+1] = { [IFA_LABEL] = { .type = NLA_STRING, .maxlen = IFNAMSIZ }, - [IFA_CACHEINFO] = { .minlen = offset_plus_sizeof(struct ifa_cacheinfo, tstamp) }, + [IFA_CACHEINFO] = { .minlen = nm_offsetofend (struct ifa_cacheinfo, tstamp) }, }; const struct ifaddrmsg *ifa; struct nlattr *tb[IFA_MAX+1]; @@ -1747,7 +1818,7 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only) [RTA_OIF] = { .type = NLA_U32 }, [RTA_PRIORITY] = { .type = NLA_U32 }, [RTA_FLOW] = { .type = NLA_U32 }, - [RTA_CACHEINFO] = { .minlen = offset_plus_sizeof(struct rta_cacheinfo, rta_tsage) }, + [RTA_CACHEINFO] = { .minlen = nm_offsetofend (struct rta_cacheinfo, rta_tsage) }, [RTA_METRICS] = { .type = NLA_NESTED }, [RTA_MULTIPATH] = { .type = NLA_NESTED }, }; @@ -1978,7 +2049,7 @@ nmp_object_new_from_nl (NMPlatform *platform, const NMPCache *cache, struct nl_m } } -/******************************************************************/ +/*****************************************************************************/ static gboolean _nl_msg_new_link_set_afspec (struct nl_msg *msg, @@ -2355,7 +2426,7 @@ nla_put_failure: g_return_val_if_reached (NULL); } -/******************************************************************/ +/*****************************************************************************/ static int _support_kernel_extended_ifa_flags = -1; @@ -2407,9 +2478,7 @@ typedef struct { gint *out_refresh_all_in_progess; } DelayedActionWaitForNlResponseData; -typedef struct _NMLinuxPlatformPrivate NMLinuxPlatformPrivate; - -struct _NMLinuxPlatformPrivate { +typedef struct { struct nl_sock *nlh; guint32 nlh_seq_next; #ifdef NM_MORE_LOGGING @@ -2444,18 +2513,27 @@ struct _NMLinuxPlatformPrivate { GHashTable *prune_candidates; GHashTable *wifi_data; +} NMLinuxPlatformPrivate; + +struct _NMLinuxPlatform { + NMPlatform parent; + NMLinuxPlatformPrivate _priv; +}; + +struct _NMLinuxPlatformClass { + NMPlatformClass parent; }; +G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM) + static inline NMLinuxPlatformPrivate * NM_LINUX_PLATFORM_GET_PRIVATE (const void *self) { nm_assert (NM_IS_LINUX_PLATFORM (self)); - return ((NMLinuxPlatform *) self)->priv; + return &(((NMLinuxPlatform *) self)->_priv); } -G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM) - NMPlatform * nm_linux_platform_new (gboolean netns_support) { @@ -2474,50 +2552,66 @@ nm_linux_platform_setup (void) NULL); } -/******************************************************************/ - static void -_assert_netns_current (NMPlatform *platform) +ASSERT_NETNS_CURRENT (NMPlatform *platform) { -#if NM_MORE_ASSERTS nm_assert (NM_IS_LINUX_PLATFORM (platform)); - nm_assert (NM_IN_SET (nm_platform_netns_get (platform), NULL, nmp_netns_get_current ())); -#endif } +/*****************************************************************************/ + +#define ASSERT_SYSCTL_ARGS(pathid, dirfd, path) \ + G_STMT_START { \ + const char *const _pathid = (pathid); \ + const int _dirfd = (dirfd); \ + const char *const _path = (path); \ + \ + nm_assert (_path && _path[0]); \ + g_assert (!strstr (_path, "/../")); \ + if (_dirfd < 0) { \ + nm_assert (!_pathid); \ + nm_assert (_path[0] == '/'); \ + nm_assert ( g_str_has_prefix (_path, "/proc/sys/") \ + || g_str_has_prefix (_path, "/sys/")); \ + } else { \ + nm_assert (_pathid && _pathid[0] && _pathid[0] != '/'); \ + nm_assert (_path[0] != '/'); \ + } \ + } G_STMT_END + static void -_log_dbg_sysctl_set_impl (NMPlatform *platform, const char *path, const char *value) +_log_dbg_sysctl_set_impl (NMPlatform *platform, const char *pathid, int dirfd, const char *path, const char *value) { GError *error = NULL; char *contents, *contents_escaped; char *value_escaped = g_strescape (value, NULL); - if (!g_file_get_contents (path, &contents, NULL, &error)) { - _LOGD ("sysctl: setting '%s' to '%s' (current value cannot be read: %s)", path, value_escaped, error->message); + if (nm_utils_file_get_contents (dirfd, path, 1*1024*1024, &contents, NULL, &error) < 0) { + _LOGD ("sysctl: setting '%s' to '%s' (current value cannot be read: %s)", pathid, value_escaped, error->message); g_clear_error (&error); } else { g_strstrip (contents); contents_escaped = g_strescape (contents, NULL); if (strcmp (contents, value) == 0) - _LOGD ("sysctl: setting '%s' to '%s' (current value is identical)", path, value_escaped); + _LOGD ("sysctl: setting '%s' to '%s' (current value is identical)", pathid, value_escaped); else - _LOGD ("sysctl: setting '%s' to '%s' (current value is '%s')", path, value_escaped, contents_escaped); + _LOGD ("sysctl: setting '%s' to '%s' (current value is '%s')", pathid, value_escaped, contents_escaped); g_free (contents); g_free (contents_escaped); } g_free (value_escaped); } -#define _log_dbg_sysctl_set(platform, path, value) \ +#define _log_dbg_sysctl_set(platform, pathid, dirfd, path, value) \ G_STMT_START { \ if (_LOGD_ENABLED ()) { \ - _log_dbg_sysctl_set_impl (platform, path, value); \ + _log_dbg_sysctl_set_impl (platform, pathid, dirfd, path, value); \ } \ } G_STMT_END static gboolean -sysctl_set (NMPlatform *platform, const char *path, const char *value) +sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *path, const char *value) { nm_auto_pop_netns NMPNetns *netns = NULL; int fd, tries; @@ -2530,32 +2624,46 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value) g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); - /* Don't write outside known locations */ - g_assert (g_str_has_prefix (path, "/proc/sys/") - || g_str_has_prefix (path, "/sys/")); - /* Don't write to suspicious locations */ - g_assert (!strstr (path, "/../")); + ASSERT_SYSCTL_ARGS (pathid, dirfd, path); - if (!nm_platform_netns_push (platform, &netns)) { - errno = ENETDOWN; - return FALSE; - } + if (dirfd < 0) { + if (!nm_platform_netns_push (platform, &netns)) { + errno = ENETDOWN; + return FALSE; + } - fd = open (path, O_WRONLY | O_TRUNC); - if (fd == -1) { - errsv = errno; - if (errsv == ENOENT) { - _LOGD ("sysctl: failed to open '%s': (%d) %s", - path, errsv, strerror (errsv)); - } else { - _LOGE ("sysctl: failed to open '%s': (%d) %s", - path, errsv, strerror (errsv)); + pathid = path; + + fd = open (path, O_WRONLY | O_TRUNC | O_CLOEXEC); + if (fd == -1) { + errsv = errno; + if (errsv == ENOENT) { + _LOGD ("sysctl: failed to open '%s': (%d) %s", + pathid, errsv, strerror (errsv)); + } else { + _LOGE ("sysctl: failed to open '%s': (%d) %s", + pathid, errsv, strerror (errsv)); + } + errno = errsv; + return FALSE; + } + } else { + fd = openat (dirfd, path, O_WRONLY | O_TRUNC | O_CLOEXEC); + if (fd == -1) { + errsv = errno; + if (errsv == ENOENT) { + _LOGD ("sysctl: failed to openat '%s': (%d) %s", + pathid, errsv, strerror (errsv)); + } else { + _LOGE ("sysctl: failed to openat '%s': (%d) %s", + pathid, errsv, strerror (errsv)); + } + errno = errsv; + return FALSE; } - errno = errsv; - return FALSE; } - _log_dbg_sysctl_set (platform, path, value); + _log_dbg_sysctl_set (platform, pathid, dirfd, path, value); /* Most sysfs and sysctl options don't care about a trailing LF, while some * (like infiniband) do. So always add the LF. Also, neither sysfs nor @@ -2573,7 +2681,7 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value) /* Try to write the entire value three times if a partial write occurs */ errsv = 0; - for (tries = 0, nwrote = 0; tries < 3 && nwrote != len; tries++) { + for (tries = 0, nwrote = 0; tries < 3 && nwrote < len - 1; tries++) { nwrote = write (fd, actual, len); if (nwrote == -1) { errsv = errno; @@ -2587,12 +2695,12 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value) if (nwrote == -1 && errsv != EEXIST) { _LOGE ("sysctl: failed to set '%s' to '%s': (%d) %s", path, value, errsv, strerror (errsv)); - } else if (nwrote < len) { + } else if (nwrote < len - 1) { _LOGE ("sysctl: failed to set '%s' to '%s' after three attempts", path, value); } - if (nwrote != len) { + if (nwrote < len - 1) { if (close (fd) != 0) { if (errsv != 0) errno = errsv; @@ -2628,7 +2736,7 @@ _nm_logging_clear_platform_logging_cache_impl (void) } static void -_log_dbg_sysctl_get_impl (NMPlatform *platform, const char *path, const char *contents) +_log_dbg_sysctl_get_impl (NMPlatform *platform, const char *pathid, const char *contents) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); const char *prev_value = NULL; @@ -2638,24 +2746,24 @@ _log_dbg_sysctl_get_impl (NMPlatform *platform, const char *path, const char *co sysctl_clear_cache_list = g_slist_prepend (sysctl_clear_cache_list, platform); priv->sysctl_get_prev_values = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); } else - prev_value = g_hash_table_lookup (priv->sysctl_get_prev_values, path); + prev_value = g_hash_table_lookup (priv->sysctl_get_prev_values, pathid); if (prev_value) { if (strcmp (prev_value, contents) != 0) { char *contents_escaped = g_strescape (contents, NULL); char *prev_value_escaped = g_strescape (prev_value, NULL); - _LOGD ("sysctl: reading '%s': '%s' (changed from '%s' on last read)", path, contents_escaped, prev_value_escaped); + _LOGD ("sysctl: reading '%s': '%s' (changed from '%s' on last read)", pathid, contents_escaped, prev_value_escaped); g_free (contents_escaped); g_free (prev_value_escaped); - g_hash_table_insert (priv->sysctl_get_prev_values, g_strdup (path), g_strdup (contents)); + g_hash_table_insert (priv->sysctl_get_prev_values, g_strdup (pathid), g_strdup (contents)); } } else { char *contents_escaped = g_strescape (contents, NULL); - _LOGD ("sysctl: reading '%s': '%s'", path, contents_escaped); + _LOGD ("sysctl: reading '%s': '%s'", pathid, contents_escaped); g_free (contents_escaped); - g_hash_table_insert (priv->sysctl_get_prev_values, g_strdup (path), g_strdup (contents)); + g_hash_table_insert (priv->sysctl_get_prev_values, g_strdup (pathid), g_strdup (contents)); } if ( !priv->sysctl_get_warned @@ -2665,47 +2773,47 @@ _log_dbg_sysctl_get_impl (NMPlatform *platform, const char *path, const char *co } } -#define _log_dbg_sysctl_get(platform, path, contents) \ +#define _log_dbg_sysctl_get(platform, pathid, contents) \ G_STMT_START { \ if (_LOGD_ENABLED ()) \ - _log_dbg_sysctl_get_impl (platform, path, contents); \ + _log_dbg_sysctl_get_impl (platform, pathid, contents); \ } G_STMT_END static char * -sysctl_get (NMPlatform *platform, const char *path) +sysctl_get (NMPlatform *platform, const char *pathid, int dirfd, const char *path) { nm_auto_pop_netns NMPNetns *netns = NULL; GError *error = NULL; char *contents; - /* Don't write outside known locations */ - g_assert (g_str_has_prefix (path, "/proc/sys/") - || g_str_has_prefix (path, "/sys/")); - /* Don't write to suspicious locations */ - g_assert (!strstr (path, "/../")); + ASSERT_SYSCTL_ARGS (pathid, dirfd, path); - if (!nm_platform_netns_push (platform, &netns)) - return NULL; + if (dirfd < 0) { + if (!nm_platform_netns_push (platform, &netns)) + return NULL; + pathid = path; + } - if (!g_file_get_contents (path, &contents, NULL, &error)) { + if (nm_utils_file_get_contents (dirfd, path, 1*1024*1024, &contents, NULL, &error) < 0) { /* We assume FAILED means EOPNOTSUP */ if ( g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) + || g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NODEV) || g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_FAILED)) - _LOGD ("error reading %s: %s", path, error->message); + _LOGD ("error reading %s: %s", pathid, error->message); else - _LOGE ("error reading %s: %s", path, error->message); + _LOGE ("error reading %s: %s", pathid, error->message); g_clear_error (&error); return NULL; } g_strstrip (contents); - _log_dbg_sysctl_get (platform, path, contents); + _log_dbg_sysctl_get (platform, pathid, contents); return contents; } -/******************************************************************/ +/*****************************************************************************/ static gboolean check_support_kernel_extended_ifa_flags (NMPlatform *platform) @@ -2729,14 +2837,18 @@ process_events (NMPlatform *platform) delayed_action_handle_all (platform, TRUE); } -/******************************************************************/ +/*****************************************************************************/ #define cache_lookup_all_objects(type, platform, obj_type, visible_only) \ - ((const type *const*) nmp_cache_lookup_multi (NM_LINUX_PLATFORM_GET_PRIVATE ((platform))->cache, \ - nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, (obj_type), (visible_only)), \ - NULL)) + ({ \ + NMPCacheId _cache_id; \ + \ + ((const type *const*) nmp_cache_lookup_multi (NM_LINUX_PLATFORM_GET_PRIVATE ((platform))->cache, \ + nmp_cache_id_init_object_type (&_cache_id, (obj_type), (visible_only)), \ + NULL)); \ + }) -/******************************************************************/ +/*****************************************************************************/ static void do_emit_signal (NMPlatform *platform, const NMPObject *obj, NMPCacheOpsType cache_op, gboolean was_visible) @@ -2751,8 +2863,7 @@ do_emit_signal (NMPlatform *platform, const NMPObject *obj, NMPCacheOpsType cach nm_assert (!obj || cache_op == NMP_CACHE_OPS_REMOVED || obj == nmp_cache_lookup_obj (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, obj)); nm_assert (!obj || cache_op != NMP_CACHE_OPS_REMOVED || obj != nmp_cache_lookup_obj (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, obj)); - /* we raise the signals inside the namespace of the NMPlatform instance. */ - _assert_netns_current (platform); + ASSERT_NETNS_CURRENT (platform); switch (cache_op) { case NMP_CACHE_OPS_ADDED: @@ -2800,13 +2911,13 @@ do_emit_signal (NMPlatform *platform, const NMPObject *obj, NMPCacheOpsType cach g_signal_emit (platform, _nm_platform_signal_id_get (klass->signal_type_id), 0, - klass->obj_type, + (int) klass->obj_type, obj_clone.object.ifindex, &obj_clone.object, - (NMPlatformSignalChangeType) cache_op); + (int) cache_op); } -/******************************************************************/ +/*****************************************************************************/ _NM_UTILS_LOOKUP_DEFINE (static, delayed_action_refresh_from_object_type, NMPObjectType, DelayedActionType, NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT (DELAYED_ACTION_TYPE_NONE), @@ -3030,7 +3141,7 @@ delayed_action_handle_one (NMPlatform *platform) g_ptr_array_remove_index_fast (priv->delayed_action.list_master_connected, 0); if (priv->delayed_action.list_master_connected->len == 0) priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_MASTER_CONNECTED; - nm_assert (_nm_utils_ptrarray_find_first (priv->delayed_action.list_master_connected->pdata, priv->delayed_action.list_master_connected->len, user_data) < 0); + nm_assert (_nm_utils_ptrarray_find_first ((gconstpointer *) priv->delayed_action.list_master_connected->pdata, priv->delayed_action.list_master_connected->len, user_data) < 0); _LOGt_delayed_action (DELAYED_ACTION_TYPE_MASTER_CONNECTED, user_data, "handle"); delayed_action_handle_MASTER_CONNECTED (platform, GPOINTER_TO_INT (user_data)); @@ -3071,7 +3182,7 @@ delayed_action_handle_one (NMPlatform *platform) g_ptr_array_remove_index_fast (priv->delayed_action.list_refresh_link, 0); if (priv->delayed_action.list_refresh_link->len == 0) priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_LINK; - nm_assert (_nm_utils_ptrarray_find_first (priv->delayed_action.list_refresh_link->pdata, priv->delayed_action.list_refresh_link->len, user_data) < 0); + nm_assert (_nm_utils_ptrarray_find_first ((gconstpointer *) priv->delayed_action.list_refresh_link->pdata, priv->delayed_action.list_refresh_link->len, user_data) < 0); _LOGt_delayed_action (DELAYED_ACTION_TYPE_REFRESH_LINK, user_data, "handle"); @@ -3120,11 +3231,11 @@ delayed_action_schedule (NMPlatform *platform, DelayedActionType action_type, gp switch (action_type) { case DELAYED_ACTION_TYPE_REFRESH_LINK: - if (_nm_utils_ptrarray_find_first (priv->delayed_action.list_refresh_link->pdata, priv->delayed_action.list_refresh_link->len, user_data) < 0) + if (_nm_utils_ptrarray_find_first ((gconstpointer *) priv->delayed_action.list_refresh_link->pdata, priv->delayed_action.list_refresh_link->len, user_data) < 0) g_ptr_array_add (priv->delayed_action.list_refresh_link, user_data); break; case DELAYED_ACTION_TYPE_MASTER_CONNECTED: - if (_nm_utils_ptrarray_find_first (priv->delayed_action.list_master_connected->pdata, priv->delayed_action.list_master_connected->len, user_data) < 0) + if (_nm_utils_ptrarray_find_first ((gconstpointer *) priv->delayed_action.list_master_connected->pdata, priv->delayed_action.list_master_connected->len, user_data) < 0) g_ptr_array_add (priv->delayed_action.list_master_connected, user_data); break; case DELAYED_ACTION_TYPE_WAIT_FOR_NL_RESPONSE: @@ -3165,15 +3276,16 @@ delayed_action_schedule_WAIT_FOR_NL_RESPONSE (NMPlatform *platform, &data); } -/******************************************************************/ +/*****************************************************************************/ static void cache_prune_candidates_record_all (NMPlatform *platform, NMPObjectType obj_type) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); + NMPCacheId cache_id; priv->prune_candidates = nmp_cache_lookup_all_to_hash (priv->cache, - nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, obj_type, FALSE), + nmp_cache_id_init_object_type (&cache_id, obj_type, FALSE), priv->prune_candidates); _LOGt ("cache-prune: record %s (now %u candidates)", nmp_class_from_type (obj_type)->obj_type_name, priv->prune_candidates ? g_hash_table_size (priv->prune_candidates) : 0); @@ -3511,7 +3623,7 @@ cache_post (NMPlatform *platform, } } -/******************************************************************/ +/*****************************************************************************/ static int _nl_send_auto_with_seq (NMPlatform *platform, @@ -3773,7 +3885,7 @@ event_valid_msg (NMPlatform *platform, struct nl_msg *msg, gboolean handle_event cache_prune_candidates_drop (platform, obj_cache); } -/******************************************************************/ +/*****************************************************************************/ static const NMPObject * cache_lookup_link (NMPlatform *platform, int ifindex) @@ -3801,10 +3913,11 @@ static GArray * link_get_all (NMPlatform *platform) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); + NMPCacheId cache_id; return nmp_cache_lookup_multi_to_array (priv->cache, NMP_OBJECT_TYPE_LINK, - nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, NMP_OBJECT_TYPE_LINK, TRUE)); + nmp_cache_id_init_object_type (&cache_id, NMP_OBJECT_TYPE_LINK, TRUE)); } static const NMPlatformLink * @@ -4414,10 +4527,6 @@ static gboolean link_supports_carrier_detect (NMPlatform *platform, int ifindex) { nm_auto_pop_netns NMPNetns *netns = NULL; - const char *name = nm_platform_link_get_name (platform, ifindex); - - if (!name) - return FALSE; if (!nm_platform_netns_push (platform, &netns)) return FALSE; @@ -4426,7 +4535,7 @@ link_supports_carrier_detect (NMPlatform *platform, int ifindex) * us whether the device actually supports carrier detection in the first * place. We assume any device that does implements one of these two APIs. */ - return nmp_utils_ethtool_supports_carrier_detect (name) || nmp_utils_mii_supports_carrier_detect (name); + return nmp_utils_ethtool_supports_carrier_detect (ifindex) || nmp_utils_mii_supports_carrier_detect (ifindex); } static gboolean @@ -4444,7 +4553,7 @@ link_supports_vlans (NMPlatform *platform, int ifindex) if (!nm_platform_netns_push (platform, &netns)) return FALSE; - return nmp_utils_ethtool_supports_vlans (obj->link.name); + return nmp_utils_ethtool_supports_vlans (ifindex); } static NMPlatformError @@ -4512,7 +4621,7 @@ link_get_permanent_address (NMPlatform *platform, if (!nm_platform_netns_push (platform, &netns)) return FALSE; - return nmp_utils_ethtool_get_permanent_address (nm_platform_link_get_name (platform, ifindex), buf, length); + return nmp_utils_ethtool_get_permanent_address (ifindex, buf, length); } static gboolean @@ -4541,44 +4650,27 @@ nla_put_failure: static char * link_get_physical_port_id (NMPlatform *platform, int ifindex) { - const char *ifname; - char *path, *id; + nm_auto_close int dirfd = -1; + char ifname_verified[IFNAMSIZ]; - ifname = nm_platform_link_get_name (platform, ifindex); - if (!ifname) + dirfd = nm_platform_sysctl_open_netdir (platform, ifindex, ifname_verified); + if (dirfd < 0) return NULL; - - ifname = NM_ASSERT_VALID_PATH_COMPONENT (ifname); - - path = g_strdup_printf ("/sys/class/net/%s/phys_port_id", ifname); - id = sysctl_get (platform, path); - g_free (path); - - return id; + return sysctl_get (platform, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_verified, "phys_port_id")); } static guint link_get_dev_id (NMPlatform *platform, int ifindex) { - const char *ifname; - gs_free char *path = NULL, *id = NULL; - gint64 int_val; + nm_auto_close int dirfd = -1; + char ifname_verified[IFNAMSIZ]; - ifname = nm_platform_link_get_name (platform, ifindex); - if (!ifname) + dirfd = nm_platform_sysctl_open_netdir (platform, ifindex, ifname_verified); + if (dirfd < 0) return 0; - - ifname = NM_ASSERT_VALID_PATH_COMPONENT (ifname); - - path = g_strdup_printf ("/sys/class/net/%s/dev_id", ifname); - id = sysctl_get (platform, path); - if (!id || !*id) - return 0; - - /* Value is reported as hex */ - int_val = _nm_utils_ascii_str_to_int64 (id, 16, 0, G_MAXUINT16, 0); - - return errno ? 0 : (int) int_val; + return nm_platform_sysctl_get_int_checked (platform, + NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_verified, "dev_id"), + 16, 0, G_MAXUINT16, 0); } static int @@ -4794,6 +4886,68 @@ nla_put_failure: g_return_val_if_reached (FALSE); } +static int +link_macsec_add (NMPlatform *platform, + const char *name, + int parent, + const NMPlatformLnkMacsec *props, + const NMPlatformLink **out_link) +{ + nm_auto_nlmsg struct nl_msg *nlmsg = NULL; + struct nlattr *info; + struct nlattr *data; + + _LOGD ("adding macsec '%s' parent %u sci %llx", + name, + parent, + (unsigned long long) props->sci); + + nlmsg = _nl_msg_new_link (RTM_NEWLINK, + NLM_F_CREATE | NLM_F_EXCL, + 0, + name, + 0, + 0); + if (!nlmsg) + return FALSE; + + NLA_PUT_U32 (nlmsg, IFLA_LINK, parent); + + if (!(info = nla_nest_start (nlmsg, IFLA_LINKINFO))) + goto nla_put_failure; + + NLA_PUT_STRING (nlmsg, IFLA_INFO_KIND, "macsec"); + + if (!(data = nla_nest_start (nlmsg, IFLA_INFO_DATA))) + goto nla_put_failure; + + if (props->icv_length) + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_ICV_LEN, 16); + if (props->cipher_suite) + NLA_PUT_U64 (nlmsg, IFLA_MACSEC_CIPHER_SUITE, props->cipher_suite); + if (props->replay_protect) + NLA_PUT_U32 (nlmsg, IFLA_MACSEC_WINDOW, props->window); + + NLA_PUT_U64 (nlmsg, IFLA_MACSEC_SCI, htobe64 (props->sci)); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_ENCODING_SA, props->encoding_sa); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_ENCRYPT, props->encrypt); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_PROTECT, props->protect); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_INC_SCI, props->include_sci); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_ES, props->es); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_SCB, props->scb); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_REPLAY_PROTECT, props->replay_protect); + NLA_PUT_U8 (nlmsg, IFLA_MACSEC_VALIDATION, props->validation); + + nla_nest_end (nlmsg, data); + nla_nest_end (nlmsg, info); + + return do_add_link_with_lookup (platform, + NM_LINK_TYPE_MACSEC, + name, nlmsg, out_link); +nla_put_failure: + g_return_val_if_reached (FALSE); +} + static int link_macvlan_add (NMPlatform *platform, const char *name, @@ -5226,7 +5380,7 @@ link_release (NMPlatform *platform, int master, int slave) return link_enslave (platform, 0, slave); } -/******************************************************************/ +/*****************************************************************************/ static gboolean _infiniband_partition_action (NMPlatform *platform, @@ -5236,9 +5390,9 @@ _infiniband_partition_action (NMPlatform *platform, const NMPlatformLink **out_link) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); - const NMPObject *obj_parent; + nm_auto_close int dirfd = -1; + char ifname_parent[IFNAMSIZ]; const NMPObject *obj; - char path[NM_STRLEN ("/sys/class/net/%s/%s") + IFNAMSIZ + 100]; char id[20]; char name[IFNAMSIZ]; gboolean success; @@ -5246,20 +5400,18 @@ _infiniband_partition_action (NMPlatform *platform, nm_assert (NM_IN_SET (action, INFINIBAND_ACTION_CREATE_CHILD, INFINIBAND_ACTION_DELETE_CHILD)); nm_assert (p_key > 0 && p_key <= 0xffff && p_key != 0x8000); - obj_parent = nmp_cache_lookup_link (priv->cache, parent); - if (!obj_parent || !obj_parent->link.name[0]) { + dirfd = nm_platform_sysctl_open_netdir (platform, parent, ifname_parent); + if (dirfd < 0) { errno = ENOENT; return FALSE; } - nm_sprintf_buf (path, - "/sys/class/net/%s/%s", - NM_ASSERT_VALID_PATH_COMPONENT (obj_parent->link.name), - (action == INFINIBAND_ACTION_CREATE_CHILD - ? "create_child" - : "delete_child")); nm_sprintf_buf (id, "0x%04x", p_key); - success = nm_platform_sysctl_set (platform, path, id); + if (action == INFINIBAND_ACTION_CREATE_CHILD) + success = nm_platform_sysctl_set (platform, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_parent, "create_child"), id); + else + success = nm_platform_sysctl_set (platform, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_parent, "delete_child"), id); + if (!success) { if ( action == INFINIBAND_ACTION_DELETE_CHILD && errno == ENODEV) @@ -5267,7 +5419,7 @@ _infiniband_partition_action (NMPlatform *platform, return FALSE; } - nm_utils_new_infiniband_name (name, obj_parent->link.name, p_key); + nm_utils_new_infiniband_name (name, ifname_parent, p_key); do_request_link (platform, 0, name); if (action == INFINIBAND_ACTION_DELETE_CHILD) @@ -5292,7 +5444,7 @@ infiniband_partition_delete (NMPlatform *platform, int parent, int p_key) return _infiniband_partition_action (platform, INFINIBAND_ACTION_DELETE_CHILD, parent, p_key, NULL); } -/******************************************************************/ +/*****************************************************************************/ static WifiData * wifi_get_wifi_data (NMPlatform *platform, int ifindex) @@ -5423,7 +5575,7 @@ wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean ru wifi_utils_indicate_addressing_running (wifi_data, running); } -/******************************************************************/ +/*****************************************************************************/ static gboolean link_can_assume (NMPlatform *platform, int ifindex) @@ -5466,7 +5618,7 @@ link_can_assume (NMPlatform *platform, int ifindex) return FALSE; } -/******************************************************************/ +/*****************************************************************************/ static guint32 mesh_get_channel (NMPlatform *platform, int ifindex) @@ -5489,7 +5641,7 @@ mesh_set_ssid (NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len) return wifi_utils_set_mesh_ssid (wifi_data, ssid, len); } -/******************************************************************/ +/*****************************************************************************/ static gboolean link_get_wake_on_lan (NMPlatform *platform, int ifindex) @@ -5501,7 +5653,7 @@ link_get_wake_on_lan (NMPlatform *platform, int ifindex) return FALSE; if (type == NM_LINK_TYPE_ETHERNET) - return nmp_utils_ethtool_get_wake_on_lan (nm_platform_link_get_name (platform, ifindex)); + return nmp_utils_ethtool_get_wake_on_lan (ifindex); else if (type == NM_LINK_TYPE_WIFI) { WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex); @@ -5521,28 +5673,32 @@ link_get_driver_info (NMPlatform *platform, char **out_fw_version) { nm_auto_pop_netns NMPNetns *netns = NULL; + NMPUtilsEthtoolDriverInfo driver_info; if (!nm_platform_netns_push (platform, &netns)) return FALSE; - return nmp_utils_ethtool_get_driver_info (nm_platform_link_get_name (platform, ifindex), - out_driver_name, - out_driver_version, - out_fw_version); + if (!nmp_utils_ethtool_get_driver_info (ifindex, &driver_info)) + return FALSE; + NM_SET_OUT (out_driver_name, g_strdup (driver_info.driver)); + NM_SET_OUT (out_driver_version, g_strdup (driver_info.version)); + NM_SET_OUT (out_fw_version, g_strdup (driver_info.fw_version)); + return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static GArray * ipx_address_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); + NMPCacheId cache_id; nm_assert (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS)); return nmp_cache_lookup_multi_to_array (priv->cache, obj_type, - nmp_cache_id_init_addrroute_visible_by_ifindex (NMP_CACHE_ID_STATIC, + nmp_cache_id_init_addrroute_visible_by_ifindex (&cache_id, obj_type, ifindex)); } @@ -5696,7 +5852,7 @@ ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 return NULL; } -/******************************************************************/ +/*****************************************************************************/ static GArray * ipx_route_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type, NMPlatformGetRouteFlags flags) @@ -5911,7 +6067,7 @@ ip6_route_get (NMPlatform *platform, int ifindex, struct in6_addr network, guint return NULL; } -/******************************************************************/ +/*****************************************************************************/ #define EVENT_CONDITIONS ((GIOCondition) (G_IO_IN | G_IO_PRI)) #define ERROR_CONDITIONS ((GIOCondition) (G_IO_ERR | G_IO_NVAL)) @@ -6264,7 +6420,7 @@ after_read: } } -/******************************************************************/ +/*****************************************************************************/ static void cache_update_link_udev (NMPlatform *platform, int ifindex, GUdevDevice *udev_device) @@ -6380,19 +6536,17 @@ handle_udev_event (GUdevClient *client, udev_device_removed (platform, udev_device); } -/******************************************************************/ +/*****************************************************************************/ static void nm_linux_platform_init (NMLinuxPlatform *self) { - NMLinuxPlatformPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_LINUX_PLATFORM, NMLinuxPlatformPrivate); + NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (self); gboolean use_udev; use_udev = nmp_netns_is_initial () && access ("/sys", W_OK) == 0; - self->priv = priv; - priv->nlh_seq_next = 1; priv->cache = nmp_cache_new (use_udev); priv->delayed_action.list_master_connected = g_ptr_array_new (); @@ -6530,7 +6684,7 @@ dispose (GObject *object) } static void -nm_linux_platform_finalize (GObject *object) +finalize (GObject *object) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (object); @@ -6540,7 +6694,6 @@ nm_linux_platform_finalize (GObject *object) g_ptr_array_unref (priv->delayed_action.list_refresh_link); g_array_unref (priv->delayed_action.list_wait_for_nl_response); - /* Free netlink resources */ g_source_remove (priv->event_id); g_io_channel_unref (priv->event_channel); nl_socket_free (priv->nlh); @@ -6555,20 +6708,15 @@ nm_linux_platform_finalize (GObject *object) G_OBJECT_CLASS (nm_linux_platform_parent_class)->finalize (object); } -#define OVERRIDE(function) platform_class->function = function - static void nm_linux_platform_class_init (NMLinuxPlatformClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMPlatformClass *platform_class = NM_PLATFORM_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMLinuxPlatformPrivate)); - - /* virtual methods */ object_class->constructed = constructed; object_class->dispose = dispose; - object_class->finalize = nm_linux_platform_finalize; + object_class->finalize = finalize; platform_class->sysctl_set = sysctl_set; platform_class->sysctl_get = sysctl_get; @@ -6642,6 +6790,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass) platform_class->link_gre_add = link_gre_add; platform_class->link_ip6tnl_add = link_ip6tnl_add; + platform_class->link_macsec_add = link_macsec_add; platform_class->link_macvlan_add = link_macvlan_add; platform_class->link_ipip_add = link_ipip_add; platform_class->link_sit_add = link_sit_add; diff --git a/src/platform/nm-linux-platform.h b/src/platform/nm-linux-platform.h index 3b2a440e..b3272aae 100644 --- a/src/platform/nm-linux-platform.h +++ b/src/platform/nm-linux-platform.h @@ -30,21 +30,8 @@ #define NM_IS_LINUX_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_LINUX_PLATFORM)) #define NM_LINUX_PLATFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_LINUX_PLATFORM, NMLinuxPlatformClass)) -/******************************************************************/ - -struct _NMLinuxPlatformPrivate; - -typedef struct { - NMPlatform parent; - - struct _NMLinuxPlatformPrivate *priv; -} NMLinuxPlatform; - -typedef struct { - NMPlatformClass parent; -} NMLinuxPlatformClass; - -/******************************************************************/ +typedef struct _NMLinuxPlatform NMLinuxPlatform; +typedef struct _NMLinuxPlatformClass NMLinuxPlatformClass; GType nm_linux_platform_get_type (void); diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index b939e783..65fb01bc 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -38,60 +38,139 @@ #include "nm-core-utils.h" +/****************************************************************** + * utils + ******************************************************************/ + extern char *if_indextoname (unsigned int __ifindex, char *__ifname); +unsigned int if_nametoindex (const char *__ifname); + +const char * +nmp_utils_if_indextoname (int ifindex, char *out_ifname/*IFNAMSIZ*/) +{ + g_return_val_if_fail (ifindex > 0, NULL); + g_return_val_if_fail (out_ifname, NULL); + + return if_indextoname (ifindex, out_ifname); +} + +int +nmp_utils_if_nametoindex (const char *ifname) +{ + g_return_val_if_fail (ifname, 0); + + return if_nametoindex (ifname); +} /****************************************************************** * ethtool ******************************************************************/ -static gboolean -ethtool_get (const char *name, gpointer edata) +NM_UTILS_ENUM2STR_DEFINE_STATIC (_ethtool_cmd_to_string, guint32, + NM_UTILS_ENUM2STR (ETHTOOL_GDRVINFO, "ETHTOOL_GDRVINFO"), + NM_UTILS_ENUM2STR (ETHTOOL_GFEATURES, "ETHTOOL_GFEATURES"), + NM_UTILS_ENUM2STR (ETHTOOL_GLINK, "ETHTOOL_GLINK"), + NM_UTILS_ENUM2STR (ETHTOOL_GPERMADDR, "ETHTOOL_GPERMADDR"), + NM_UTILS_ENUM2STR (ETHTOOL_GSET, "ETHTOOL_GSET"), + NM_UTILS_ENUM2STR (ETHTOOL_GSSET_INFO, "ETHTOOL_GSSET_INFO"), + NM_UTILS_ENUM2STR (ETHTOOL_GSTATS, "ETHTOOL_GSTATS"), + NM_UTILS_ENUM2STR (ETHTOOL_GSTRINGS, "ETHTOOL_GSTRINGS"), + NM_UTILS_ENUM2STR (ETHTOOL_GWOL, "ETHTOOL_GWOL"), + NM_UTILS_ENUM2STR (ETHTOOL_SSET, "ETHTOOL_SSET"), + NM_UTILS_ENUM2STR (ETHTOOL_SWOL, "ETHTOOL_SWOL"), +); + +static const char * +_ethtool_data_to_string (gconstpointer edata, char *buf, gsize len) { - struct ifreq ifr; - int fd; + return _ethtool_cmd_to_string (*((guint32 *) edata), buf, len); +} - if (!name || !*name) - return FALSE; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) +#define ethtool_cmd_speed(pedata) ((pedata)->speed) - if (!nmp_utils_device_exists (name)) - return FALSE; +#define ethtool_cmd_speed_set(pedata, speed) \ + G_STMT_START { (pedata)->speed = (guint16) (speed); } G_STMT_END +#endif - /* nmp_utils_device_exists() already errors out if @name is invalid. */ - nm_assert (strlen (name) < IFNAMSIZ); +static gboolean +ethtool_get (int ifindex, gpointer edata) +{ + char ifname[IFNAMSIZ]; + char sbuf[50]; - memset (&ifr, 0, sizeof (ifr)); - nm_utils_ifname_cpy (ifr.ifr_name, name); - ifr.ifr_data = edata; + nm_assert (ifindex > 0); - fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); - if (fd < 0) { - nm_log_err (LOGD_PLATFORM, "ethtool: Could not open socket."); + /* ethtool ioctl API uses the ifname to refer to an interface. That is racy + * as interfaces can be renamed *sigh*. + * + * Note that we anyway have to verify whether the interface exists, before + * calling ioctl for a non-existing ifname. This is to prevent autoloading + * of kernel modules *sigh*. + * Thus, as we anyway verify the existence of ifname before doing the call, + * go one step further and lookup the ifname everytime anew. + * + * This does not solve the renaming race, but it minimizes the time for + * the race to happen as much as possible. */ + + if (!nmp_utils_if_indextoname (ifindex, ifname)) { + nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: request fails resolving ifindex: %s", + ifindex, + _ethtool_data_to_string (edata, sbuf, sizeof (sbuf)), + g_strerror (errno)); return FALSE; } - if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) { - nm_log_dbg (LOGD_PLATFORM, "ethtool: Request failed: %s", strerror (errno)); - close (fd); - return FALSE; - } + { + nm_auto_close int fd = -1; + struct ifreq ifr = { + .ifr_data = edata, + }; + + memcpy (ifr.ifr_name, ifname, sizeof (ifname)); + + fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + if (fd < 0) { + nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s, %s: failed creating socket for ioctl: %s", + ifindex, + _ethtool_data_to_string (edata, sbuf, sizeof (sbuf)), + ifname, + g_strerror (errno)); + return FALSE; + } - close (fd); - return TRUE; + if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) { + nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s, %s: failed: %s", + ifindex, + _ethtool_data_to_string (edata, sbuf, sizeof (sbuf)), + ifname, + strerror (errno)); + return FALSE; + } + + nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s, %s: success", + ifindex, + _ethtool_data_to_string (edata, sbuf, sizeof (sbuf)), + ifname); + return TRUE; + } } static int -ethtool_get_stringset_index (const char *ifname, int stringset_id, const char *string) +ethtool_get_stringset_index (int ifindex, int stringset_id, const char *string) { gs_free struct ethtool_sset_info *info = NULL; gs_free struct ethtool_gstrings *strings = NULL; guint32 len, i; + g_return_val_if_fail (ifindex > 0, -1); + info = g_malloc0 (sizeof (*info) + sizeof (guint32)); info->cmd = ETHTOOL_GSSET_INFO; info->reserved = 0; info->sset_mask = 1ULL << stringset_id; - if (!ethtool_get (ifname, info)) + if (!ethtool_get (ifindex, info)) return -1; if (!info->sset_mask) return -1; @@ -102,7 +181,7 @@ ethtool_get_stringset_index (const char *ifname, int stringset_id, const char *s strings->cmd = ETHTOOL_GSTRINGS; strings->string_set = stringset_id; strings->len = len; - if (!ethtool_get (ifname, strings)) + if (!ethtool_get (ifindex, strings)) return -1; for (i = 0; i < len; i++) { @@ -114,32 +193,30 @@ ethtool_get_stringset_index (const char *ifname, int stringset_id, const char *s } gboolean -nmp_utils_ethtool_get_driver_info (const char *ifname, - char **out_driver_name, - char **out_driver_version, - char **out_fw_version) +nmp_utils_ethtool_get_driver_info (int ifindex, + NMPUtilsEthtoolDriverInfo *data) { - struct ethtool_drvinfo drvinfo = { 0 }; - - if (!ifname) - return FALSE; - - drvinfo.cmd = ETHTOOL_GDRVINFO; - if (!ethtool_get (ifname, &drvinfo)) - return FALSE; - - if (out_driver_name) - *out_driver_name = g_strdup (drvinfo.driver); - if (out_driver_version) - *out_driver_version = g_strdup (drvinfo.version); - if (out_fw_version) - *out_fw_version = g_strdup (drvinfo.fw_version); - - return TRUE; + struct ethtool_drvinfo *drvinfo; + G_STATIC_ASSERT (sizeof (*data) == sizeof (*drvinfo)); + G_STATIC_ASSERT (offsetof (NMPUtilsEthtoolDriverInfo, driver) == offsetof (struct ethtool_drvinfo, driver)); + G_STATIC_ASSERT (offsetof (NMPUtilsEthtoolDriverInfo, version) == offsetof (struct ethtool_drvinfo, version)); + G_STATIC_ASSERT (offsetof (NMPUtilsEthtoolDriverInfo, fw_version) == offsetof (struct ethtool_drvinfo, fw_version)); + G_STATIC_ASSERT (sizeof (data->driver) == sizeof (drvinfo->driver)); + G_STATIC_ASSERT (sizeof (data->version) == sizeof (drvinfo->version)); + G_STATIC_ASSERT (sizeof (data->fw_version) == sizeof (drvinfo->fw_version)); + + g_return_val_if_fail (ifindex > 0, FALSE); + g_return_val_if_fail (data, FALSE); + + drvinfo = (struct ethtool_drvinfo *) data; + + memset (drvinfo, 0, sizeof (*drvinfo)); + drvinfo->cmd = ETHTOOL_GDRVINFO; + return ethtool_get (ifindex, drvinfo); } gboolean -nmp_utils_ethtool_get_permanent_address (const char *ifname, +nmp_utils_ethtool_get_permanent_address (int ifindex, guint8 *buf, size_t *length) { @@ -149,14 +226,13 @@ nmp_utils_ethtool_get_permanent_address (const char *ifname, } edata; guint i; - if (!ifname) - return FALSE; + g_return_val_if_fail (ifindex > 0, FALSE); memset (&edata, 0, sizeof (edata)); edata.e.cmd = ETHTOOL_GPERMADDR; edata.e.size = NM_UTILS_HWADDR_LEN_MAX; - if (!ethtool_get (ifname, &edata.e)) + if (!ethtool_get (ifindex, &edata.e)) return FALSE; if (edata.e.size > NM_UTILS_HWADDR_LEN_MAX) @@ -183,29 +259,30 @@ not_all_0or1: } gboolean -nmp_utils_ethtool_supports_carrier_detect (const char *ifname) +nmp_utils_ethtool_supports_carrier_detect (int ifindex) { struct ethtool_cmd edata = { .cmd = ETHTOOL_GLINK }; + g_return_val_if_fail (ifindex > 0, FALSE); + /* We ignore the result. If the ETHTOOL_GLINK call succeeded, then we * assume the device supports carrier-detect, otherwise we assume it * doesn't. */ - return ethtool_get (ifname, &edata); + return ethtool_get (ifindex, &edata); } gboolean -nmp_utils_ethtool_supports_vlans (const char *ifname) +nmp_utils_ethtool_supports_vlans (int ifindex) { gs_free struct ethtool_gfeatures *features = NULL; int idx, block, bit, size; - if (!ifname) - return FALSE; + g_return_val_if_fail (ifindex > 0, FALSE); - idx = ethtool_get_stringset_index (ifname, ETH_SS_FEATURES, "vlan-challenged"); + idx = ethtool_get_stringset_index (ifindex, ETH_SS_FEATURES, "vlan-challenged"); if (idx == -1) { - nm_log_dbg (LOGD_PLATFORM, "ethtool: vlan-challenged ethtool feature does not exist for %s?", ifname); + nm_log_dbg (LOGD_PLATFORM, "ethtool: vlan-challenged ethtool feature does not exist for %d?", ifindex); return FALSE; } @@ -217,83 +294,148 @@ nmp_utils_ethtool_supports_vlans (const char *ifname) features->cmd = ETHTOOL_GFEATURES; features->size = size; - if (!ethtool_get (ifname, features)) + if (!ethtool_get (ifindex, features)) return FALSE; return !(features->features[block].active & (1 << bit)); } int -nmp_utils_ethtool_get_peer_ifindex (const char *ifname) +nmp_utils_ethtool_get_peer_ifindex (int ifindex) { gs_free struct ethtool_stats *stats = NULL; int peer_ifindex_stat; - if (!ifname) - return 0; + g_return_val_if_fail (ifindex > 0, 0); - peer_ifindex_stat = ethtool_get_stringset_index (ifname, ETH_SS_STATS, "peer_ifindex"); + peer_ifindex_stat = ethtool_get_stringset_index (ifindex, ETH_SS_STATS, "peer_ifindex"); if (peer_ifindex_stat == -1) { - nm_log_dbg (LOGD_PLATFORM, "ethtool: peer_ifindex stat for %s does not exist?", ifname); + nm_log_dbg (LOGD_PLATFORM, "ethtool: peer_ifindex stat for %d does not exist?", ifindex); return FALSE; } stats = g_malloc0 (sizeof (*stats) + (peer_ifindex_stat + 1) * sizeof (guint64)); stats->cmd = ETHTOOL_GSTATS; stats->n_stats = peer_ifindex_stat + 1; - if (!ethtool_get (ifname, stats)) + if (!ethtool_get (ifindex, stats)) return 0; return stats->data[peer_ifindex_stat]; } gboolean -nmp_utils_ethtool_get_wake_on_lan (const char *ifname) +nmp_utils_ethtool_get_wake_on_lan (int ifindex) { struct ethtool_wolinfo wol; - if (!ifname) - return FALSE; + g_return_val_if_fail (ifindex > 0, FALSE); memset (&wol, 0, sizeof (wol)); wol.cmd = ETHTOOL_GWOL; - if (!ethtool_get (ifname, &wol)) + if (!ethtool_get (ifindex, &wol)) return FALSE; return wol.wolopts != 0; } gboolean -nmp_utils_ethtool_get_link_speed (const char *ifname, guint32 *out_speed) +nmp_utils_ethtool_get_link_settings (int ifindex, + gboolean *out_autoneg, + guint32 *out_speed, + NMPlatformLinkDuplexType *out_duplex) { struct ethtool_cmd edata = { .cmd = ETHTOOL_GSET, }; - guint32 speed; - if (!ethtool_get (ifname, &edata)) + g_return_val_if_fail (ifindex > 0, FALSE); + + if (!ethtool_get (ifindex, &edata)) return FALSE; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - speed = edata.speed; -#else - speed = ethtool_cmd_speed (&edata); -#endif - if (speed == G_MAXUINT16 || speed == G_MAXUINT32) - speed = 0; + if (out_autoneg) + *out_autoneg = (edata.autoneg == AUTONEG_ENABLE); + + if (out_speed) { + guint32 speed; + + speed = ethtool_cmd_speed (&edata); + if (speed == G_MAXUINT16 || speed == G_MAXUINT32) + speed = 0; - if (out_speed) *out_speed = speed; + } + + if (out_duplex) { + switch (edata.duplex) { + case DUPLEX_HALF: + *out_duplex = NM_PLATFORM_LINK_DUPLEX_HALF; + break; + case DUPLEX_FULL: + *out_duplex = NM_PLATFORM_LINK_DUPLEX_FULL; + break; + default: /* DUPLEX_UNKNOWN */ + *out_duplex = NM_PLATFORM_LINK_DUPLEX_UNKNOWN; + break; + } + } + return TRUE; } gboolean -nmp_utils_ethtool_set_wake_on_lan (const char *ifname, +nmp_utils_ethtool_set_link_settings (int ifindex, + gboolean autoneg, + guint32 speed, + NMPlatformLinkDuplexType duplex) +{ + struct ethtool_cmd edata = { + .cmd = ETHTOOL_GSET, + }; + + g_return_val_if_fail (ifindex > 0, FALSE); + + /* retrieve first current settings */ + if (!ethtool_get (ifindex, &edata)) + return FALSE; + + /* then change the needed ones */ + edata.cmd = ETHTOOL_SSET; + if (autoneg) { + edata.autoneg = AUTONEG_ENABLE; + edata.advertising = edata.supported; + } else { + edata.autoneg = AUTONEG_DISABLE; + + if (speed) + ethtool_cmd_speed_set (&edata, speed); + + switch (duplex) { + case NM_PLATFORM_LINK_DUPLEX_HALF: + edata.duplex = DUPLEX_HALF; + break; + case NM_PLATFORM_LINK_DUPLEX_FULL: + edata.duplex = DUPLEX_FULL; + break; + case NM_PLATFORM_LINK_DUPLEX_UNKNOWN: + break; + default: + g_return_val_if_reached (FALSE); + } + } + + return ethtool_get (ifindex, &edata); +} + +gboolean +nmp_utils_ethtool_set_wake_on_lan (int ifindex, NMSettingWiredWakeOnLan wol, const char *wol_password) { struct ethtool_wolinfo wol_info = { }; + g_return_val_if_fail (ifindex > 0, FALSE); + if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE) return TRUE; @@ -324,7 +466,7 @@ nmp_utils_ethtool_set_wake_on_lan (const char *ifname, wol_info.wolopts |= WAKE_MAGICSECURE; } - return ethtool_get (ifname, &wol_info); + return ethtool_get (ifindex, &wol_info); } /****************************************************************** @@ -332,51 +474,45 @@ nmp_utils_ethtool_set_wake_on_lan (const char *ifname, ******************************************************************/ gboolean -nmp_utils_mii_supports_carrier_detect (const char *ifname) +nmp_utils_mii_supports_carrier_detect (int ifindex) { - int fd, errsv; + char ifname[IFNAMSIZ]; + nm_auto_close int fd = -1; struct ifreq ifr; struct mii_ioctl_data *mii; - gboolean supports_mii = FALSE; - if (!ifname) - return FALSE; + g_return_val_if_fail (ifindex > 0, FALSE); - if (!nmp_utils_device_exists (ifname)) + if (!nmp_utils_if_indextoname (ifindex, ifname)) { + nm_log_trace (LOGD_PLATFORM, "mii[%d]: carrier-detect no: request fails resolving ifindex: %s", ifindex, g_strerror (errno)); return FALSE; + } fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (fd < 0) { - nm_log_err (LOGD_PLATFORM, "mii: couldn't open control socket (%s)", ifname); + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: couldn't open control socket: %s", ifindex, ifname, g_strerror (errno)); return FALSE; } memset (&ifr, 0, sizeof (struct ifreq)); - nm_utils_ifname_cpy (ifr.ifr_name, ifname); + memcpy (ifr.ifr_name, ifname, IFNAMSIZ); - errno = 0; if (ioctl (fd, SIOCGMIIPHY, &ifr) < 0) { - errsv = errno; - nm_log_dbg (LOGD_PLATFORM, "mii: SIOCGMIIPHY failed: %s (%d) (%s)", strerror (errsv), errsv, ifname); - goto out; + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIPHY failed: %s", ifindex, ifname, strerror (errno)); + return FALSE; } /* If we can read the BMSR register, we assume that the card supports MII link detection */ mii = (struct mii_ioctl_data *) &ifr.ifr_ifru; mii->reg_num = MII_BMSR; - if (ioctl (fd, SIOCGMIIREG, &ifr) == 0) { - nm_log_dbg (LOGD_PLATFORM, "mii: SIOCGMIIREG result 0x%X (%s)", mii->val_out, ifname); - supports_mii = TRUE; - } else { - errsv = errno; - nm_log_dbg (LOGD_PLATFORM, "mii: SIOCGMIIREG failed: %s (%d) (%s)", strerror (errsv), errsv, ifname); + if (ioctl (fd, SIOCGMIIREG, &ifr) != 0) { + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect no: SIOCGMIIREG failed: %s", ifindex, ifname, strerror (errno)); + return FALSE; } -out: - close (fd); - nm_log_dbg (LOGD_PLATFORM, "mii: MII %s supported (%s)", supports_mii ? "is" : "not", ifname); - return supports_mii; + nm_log_trace (LOGD_PLATFORM, "mii[%d,%s]: carrier-detect yes: SIOCGMIIREG result 0x%X", ifindex, ifname, mii->val_out); + return TRUE; } /****************************************************************** @@ -424,22 +560,6 @@ out: * utils *****************************************************************************/ -gboolean -nmp_utils_device_exists (const char *name) -{ -#define SYS_CLASS_NET "/sys/class/net/" - char sysdir[NM_STRLEN (SYS_CLASS_NET) + IFNAMSIZ]; - - if ( !name - || strlen (name) >= IFNAMSIZ - || !nm_utils_is_valid_path_component (name)) - g_return_val_if_reached (FALSE); - - memcpy (sysdir, SYS_CLASS_NET, NM_STRLEN (SYS_CLASS_NET)); - nm_utils_ifname_cpy (&sysdir[NM_STRLEN (SYS_CLASS_NET)], name); - return g_file_test (sysdir, G_FILE_TEST_EXISTS); -} - NMIPConfigSource nmp_utils_ip_config_source_from_rtprot (guint8 rtprot) { @@ -472,7 +592,7 @@ nmp_utils_ip_config_source_coerce_to_rtprot (NMIPConfigSource source) return RTPROT_KERNEL; case NM_IP_CONFIG_SOURCE_DHCP: return RTPROT_DHCP; - case NM_IP_CONFIG_SOURCE_RDISC: + case NM_IP_CONFIG_SOURCE_NDISC: return RTPROT_RA; default: @@ -504,7 +624,7 @@ nmp_utils_ip_config_source_coerce_from_rtprot (NMIPConfigSource source) return NM_IP_CONFIG_SOURCE_KERNEL; case NM_IP_CONFIG_SOURCE_RTPROT_RA: - return NM_IP_CONFIG_SOURCE_RDISC; + return NM_IP_CONFIG_SOURCE_NDISC; case NM_IP_CONFIG_SOURCE_RTPROT_DHCP: return NM_IP_CONFIG_SOURCE_DHCP; @@ -541,7 +661,7 @@ nmp_utils_ip_config_source_to_string (NMIPConfigSource source, char *buf, gsize case NM_IP_CONFIG_SOURCE_WWAN: s = "wwan"; break; case NM_IP_CONFIG_SOURCE_VPN: s = "vpn"; break; case NM_IP_CONFIG_SOURCE_DHCP: s = "dhcp"; break; - case NM_IP_CONFIG_SOURCE_RDISC: s = "rdisc"; break; + case NM_IP_CONFIG_SOURCE_NDISC: s = "ndisc"; break; case NM_IP_CONFIG_SOURCE_USER: s = "user"; break; default: break; @@ -598,12 +718,12 @@ nmp_utils_sysctl_open_netdir (int ifindex, int fd; if (!ifname) { - ifname = if_indextoname (ifindex, ifname_buf); + ifname = nmp_utils_if_indextoname (ifindex, ifname_buf); if (!ifname) return -1; } - nm_assert (nm_utils_iface_valid_name (ifname)); + nm_assert (nm_utils_is_valid_iface_name (ifname, NULL)); if (g_strlcpy (&sysdir[NM_STRLEN (SYS_CLASS_NET)], ifname, IFNAMSIZ) >= IFNAMSIZ) g_return_val_if_reached (-1); diff --git a/src/platform/nm-platform-utils.h b/src/platform/nm-platform-utils.h index 92a06fdf..699e80c6 100644 --- a/src/platform/nm-platform-utils.h +++ b/src/platform/nm-platform-utils.h @@ -27,39 +27,56 @@ #include "nm-setting-wired.h" -const char *nmp_utils_ethtool_get_driver (const char *ifname); -gboolean nmp_utils_ethtool_supports_carrier_detect (const char *ifname); -gboolean nmp_utils_ethtool_supports_vlans (const char *ifname); -int nmp_utils_ethtool_get_peer_ifindex (const char *ifname); -gboolean nmp_utils_ethtool_get_wake_on_lan (const char *ifname); -gboolean nmp_utils_ethtool_set_wake_on_lan (const char *ifname, NMSettingWiredWakeOnLan wol, +const char *nmp_utils_ethtool_get_driver (int ifindex); +gboolean nmp_utils_ethtool_supports_carrier_detect (int ifindex); +gboolean nmp_utils_ethtool_supports_vlans (int ifindex); +int nmp_utils_ethtool_get_peer_ifindex (int ifindex); +gboolean nmp_utils_ethtool_get_wake_on_lan (int ifindex); +gboolean nmp_utils_ethtool_set_wake_on_lan (int ifindex, NMSettingWiredWakeOnLan wol, const char *wol_password); -gboolean nmp_utils_ethtool_get_link_speed (const char *ifname, guint32 *out_speed); - -gboolean nmp_utils_ethtool_get_driver_info (const char *ifname, - char **out_driver_name, - char **out_driver_version, - char **out_fw_version); - -gboolean nmp_utils_ethtool_get_permanent_address (const char *ifname, +gboolean nmp_utils_ethtool_get_link_settings (int ifindex, gboolean *out_autoneg, guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex); +gboolean nmp_utils_ethtool_set_link_settings (int ifindex, gboolean autoneg, guint32 speed, NMPlatformLinkDuplexType duplex); + +typedef struct { + /* We don't want to include in header files, + * thus create a ABI compatible version of struct ethtool_drvinfo.*/ + guint32 _private_cmd; + char driver[32]; + char version[32]; + char fw_version[32]; + char _private_bus_info[32]; + char _private_erom_version[32]; + char _private_reserved2[12]; + guint32 _private_n_priv_flags; + guint32 _private_n_stats; + guint32 _private_testinfo_len; + guint32 _private_eedump_len; + guint32 _private_regdump_len; +} NMPUtilsEthtoolDriverInfo; + +gboolean nmp_utils_ethtool_get_driver_info (int ifindex, + NMPUtilsEthtoolDriverInfo *data); + +gboolean nmp_utils_ethtool_get_permanent_address (int ifindex, guint8 *buf, size_t *length); -gboolean nmp_utils_mii_supports_carrier_detect (const char *ifname); +gboolean nmp_utils_mii_supports_carrier_detect (int ifindex); const char *nmp_utils_udev_get_driver (GUdevDevice *device); -gboolean nmp_utils_device_exists (const char *name); - NMIPConfigSource nmp_utils_ip_config_source_from_rtprot (guint8 rtprot) _nm_const; guint8 nmp_utils_ip_config_source_coerce_to_rtprot (NMIPConfigSource source) _nm_const; NMIPConfigSource nmp_utils_ip_config_source_coerce_from_rtprot (NMIPConfigSource source) _nm_const; NMIPConfigSource nmp_utils_ip_config_source_round_trip_rtprot (NMIPConfigSource source) _nm_const; const char * nmp_utils_ip_config_source_to_string (NMIPConfigSource source, char *buf, gsize len); +const char *nmp_utils_if_indextoname (int ifindex, char *out_ifname/*IFNAMSIZ*/); +int nmp_utils_if_nametoindex (const char *ifname); + int nmp_utils_sysctl_open_netdir (int ifindex, const char *ifname_guess, char *out_ifname); diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 9274a31d..8b22ced2 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -37,7 +37,6 @@ #include "nm-core-internal.h" #include "nm-core-utils.h" -#include "nm-enum-types.h" #include "nm-platform-utils.h" #include "nmp-object.h" #include "nmp-netns.h" @@ -79,10 +78,6 @@ G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPRoute, network_ptr) == G_STRUCT_OF /*****************************************************************************/ -#define NM_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PLATFORM, NMPlatformPrivate)) - -G_DEFINE_TYPE (NMPlatform, nm_platform, G_TYPE_OBJECT) - static guint signals[_NM_PLATFORM_SIGNAL_ID_LAST] = { 0 }; enum { @@ -92,11 +87,15 @@ enum { LAST_PROP, }; -typedef struct { - gboolean register_singleton; +typedef struct _NMPlatformPrivate { + bool register_singleton:1; } NMPlatformPrivate; -/******************************************************************/ +G_DEFINE_TYPE (NMPlatform, nm_platform, G_TYPE_OBJECT) + +#define NM_PLATFORM_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMPlatform, NM_IS_PLATFORM) + +/*****************************************************************************/ guint _nm_platform_signal_id_get (NMPlatformSignalIdType signal_type) @@ -108,7 +107,7 @@ _nm_platform_signal_id_get (NMPlatformSignalIdType signal_type) return signals[signal_type]; } -/******************************************************************/ +/*****************************************************************************/ /* Singleton NMPlatform subclass instance and cached class object */ NM_DEFINE_SINGLETON_INSTANCE (NMPlatform); @@ -135,6 +134,17 @@ NM_DEFINE_SINGLETON_REGISTER (NMPlatform); (void) klass; \ } while (0) +#define _CHECK_SELF_NETNS(self, klass, netns, err_val) \ + nm_auto_pop_netns NMPNetns *netns = NULL; \ + NMPlatformClass *klass; \ + do { \ + g_return_val_if_fail (NM_IS_PLATFORM (self), err_val); \ + klass = NM_PLATFORM_GET_CLASS (self); \ + (void) klass; \ + if (!nm_platform_netns_push (self, &netns)) \ + return (err_val); \ + } while (0) + /** * nm_platform_setup: * @instance: the #NMPlatform instance @@ -183,7 +193,7 @@ nm_platform_try_get (void) return singleton_instance; } -/******************************************************************/ +/*****************************************************************************/ /** * _nm_platform_error_to_string: @@ -208,7 +218,7 @@ NM_UTILS_LOOKUP_STR_DEFINE (_nm_platform_error_to_string, NMPlatformError, NM_UTILS_LOOKUP_ITEM_IGNORE (_NM_PLATFORM_ERROR_MININT), ); -/******************************************************************/ +/*****************************************************************************/ gboolean nm_platform_check_support_kernel_extended_ifa_flags (NMPlatform *self) @@ -253,11 +263,42 @@ nm_platform_process_events (NMPlatform *self) klass->process_events (self); } -/******************************************************************/ +/*****************************************************************************/ + +/** + * nm_platform_sysctl_open_netdir: + * @self: platform instance + * @ifindex: the ifindex for which to open /sys/class/net/%s + * @out_ifname: optional output argument of the found ifname. + * + * Wraps nmp_utils_sysctl_open_netdir() by first changing into the right + * network-namespace. + * + * Returns: on success, the open file descriptor to the /sys/class/net/%s + * directory. + */ +int +nm_platform_sysctl_open_netdir (NMPlatform *self, int ifindex, char *out_ifname) +{ + const char*ifname_guess; + _CHECK_SELF_NETNS (self, klass, netns, -1); + + g_return_val_if_fail (ifindex > 0, -1); + + /* we don't have an @ifname_guess argument to make the API nicer. + * But still do a cache-lookup first. Chances are good that we have + * the right ifname cached and save if_indextoname() */ + ifname_guess = nm_platform_link_get_name (self, ifindex); + + return nmp_utils_sysctl_open_netdir (ifindex, ifname_guess, out_ifname); +} /** * nm_platform_sysctl_set: * @self: platform instance + * @pathid: if @dirfd is present, this must be the full path that is looked up. + * It is required for logging. + * @dirfd: optional file descriptor for parent directory for openat() * @path: Absolute option path * @value: Value to write * @@ -268,14 +309,14 @@ nm_platform_process_events (NMPlatform *self) * Returns: %TRUE on success. */ gboolean -nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value) +nm_platform_sysctl_set (NMPlatform *self, const char *pathid, int dirfd, const char *path, const char *value) { _CHECK_SELF (self, klass, FALSE); g_return_val_if_fail (path, FALSE); g_return_val_if_fail (value, FALSE); - return klass->sysctl_set (self, path, value); + return klass->sysctl_set (self, pathid, dirfd, path, value); } gboolean @@ -295,7 +336,7 @@ nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, return FALSE; path = nm_utils_ip6_property_path (iface, "hop_limit"); - cur = nm_platform_sysctl_get_int_checked (self, path, 10, 1, G_MAXINT32, -1); + cur = nm_platform_sysctl_get_int_checked (self, NMP_SYSCTL_PATHID_ABSOLUTE (path), 10, 1, G_MAXINT32, -1); /* only allow increasing the hop-limit to avoid DOS by an attacker * setting a low hop-limit (CVE-2015-2924, rh#1209902) */ @@ -306,7 +347,7 @@ nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, char svalue[20]; sprintf (svalue, "%d", value); - nm_platform_sysctl_set (self, path, svalue); + nm_platform_sysctl_set (self, NMP_SYSCTL_PATHID_ABSOLUTE (path), svalue); } return TRUE; @@ -315,23 +356,29 @@ nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, /** * nm_platform_sysctl_get: * @self: platform instance + * @dirfd: if non-negative, used to lookup the path via openat(). + * @pathid: if @dirfd is present, this must be the full path that is looked up. + * It is required for logging. * @path: Absolute path to sysctl * * Returns: (transfer full): Contents of the virtual sysctl file. */ char * -nm_platform_sysctl_get (NMPlatform *self, const char *path) +nm_platform_sysctl_get (NMPlatform *self, const char *pathid, int dirfd, const char *path) { _CHECK_SELF (self, klass, NULL); g_return_val_if_fail (path, NULL); - return klass->sysctl_get (self, path); + return klass->sysctl_get (self, pathid, dirfd, path); } /** * nm_platform_sysctl_get_int32: * @self: platform instance + * @pathid: if @dirfd is present, this must be the full path that is looked up. + * It is required for logging. + * @dirfd: if non-negative, used to lookup the path via openat(). * @path: Absolute path to sysctl * @fallback: default value, if the content of path could not be read * as decimal integer. @@ -341,14 +388,17 @@ nm_platform_sysctl_get (NMPlatform *self, const char *path) * value, on success %errno will be set to zero. */ gint32 -nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback) +nm_platform_sysctl_get_int32 (NMPlatform *self, const char *pathid, int dirfd, const char *path, gint32 fallback) { - return nm_platform_sysctl_get_int_checked (self, path, 10, G_MININT32, G_MAXINT32, fallback); + return nm_platform_sysctl_get_int_checked (self, pathid, dirfd, path, 10, G_MININT32, G_MAXINT32, fallback); } /** * nm_platform_sysctl_get_int_checked: * @self: platform instance + * @pathid: if @dirfd is present, this must be the full path that is looked up. + * It is required for logging. + * @dirfd: if non-negative, used to lookup the path via openat(). * @path: Absolute path to sysctl * @base: base of numeric conversion * @min: minimal value that is still valid @@ -363,7 +413,7 @@ nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallbac * (inclusive) or @fallback. */ gint64 -nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint base, gint64 min, gint64 max, gint64 fallback) +nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *pathid, int dirfd, const char *path, guint base, gint64 min, gint64 max, gint64 fallback) { char *value = NULL; gint32 ret; @@ -373,7 +423,7 @@ nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint ba g_return_val_if_fail (path, fallback); if (path) - value = nm_platform_sysctl_get (self, path); + value = nm_platform_sysctl_get (self, pathid, dirfd, path); if (!value) { errno = EINVAL; @@ -385,7 +435,7 @@ nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint ba return ret; } -/******************************************************************/ +/*****************************************************************************/ static int _link_get_all_presort (gconstpointer p_a, @@ -720,6 +770,22 @@ nm_platform_link_get_ifindex (NMPlatform *self, const char *name) return pllink ? pllink->ifindex : 0; } +const char * +nm_platform_if_indextoname (NMPlatform *self, int ifindex, char *out_ifname/* of size IFNAMSIZ */) +{ + _CHECK_SELF_NETNS (self, klass, netns, FALSE); + + return nmp_utils_if_indextoname (ifindex, out_ifname); +} + +int +nm_platform_if_nametoindex (NMPlatform *self, const char *ifname) +{ + _CHECK_SELF_NETNS (self, klass, netns, FALSE); + + return nmp_utils_if_nametoindex (ifname); +} + /** * nm_platform_link_get_name: * @self: platform instance @@ -1461,6 +1527,12 @@ nm_platform_link_get_lnk_ipip (NMPlatform *self, int ifindex, const NMPlatformLi return _link_get_lnk (self, ifindex, NM_LINK_TYPE_IPIP, out_link); } +const NMPlatformLnkMacsec * +nm_platform_link_get_lnk_macsec (NMPlatform *self, int ifindex, const NMPlatformLink **out_link) +{ + return _link_get_lnk (self, ifindex, NM_LINK_TYPE_MACSEC, out_link); +} + const NMPlatformLnkMacvlan * nm_platform_link_get_lnk_macvlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link) { @@ -1658,34 +1730,44 @@ nm_platform_link_tun_add (NMPlatform *self, /*****************************************************************************/ -static char * -link_option_path (NMPlatform *self, int master, const char *category, const char *option) +static gboolean +link_set_option (NMPlatform *self, int ifindex, const char *category, const char *option, const char *value) { - const char *name = nm_platform_link_get_name (self, master); - - if (!name || !category || !option) - return NULL; + nm_auto_close int dirfd = -1; + char ifname_verified[IFNAMSIZ]; + const char *path; - return g_strdup_printf ("/sys/class/net/%s/%s/%s", - NM_ASSERT_VALID_PATH_COMPONENT (name), - NM_ASSERT_VALID_PATH_COMPONENT (category), - NM_ASSERT_VALID_PATH_COMPONENT (option)); -} + if (!category || !option) + return FALSE; -static gboolean -link_set_option (NMPlatform *self, int master, const char *category, const char *option, const char *value) -{ - gs_free char *path = link_option_path (self, master, category, option); + dirfd = nm_platform_sysctl_open_netdir (self, ifindex, ifname_verified); + if (dirfd < 0) + return FALSE; - return path && nm_platform_sysctl_set (self, path, value); + path = nm_sprintf_bufa (strlen (category) + strlen (option) + 2, + "%s/%s", + category, option); + return nm_platform_sysctl_set (self, NMP_SYSCTL_PATHID_NETDIR_unsafe (dirfd, ifname_verified, path), value); } static char * -link_get_option (NMPlatform *self, int master, const char *category, const char *option) +link_get_option (NMPlatform *self, int ifindex, const char *category, const char *option) { - gs_free char *path = link_option_path (self, master, category, option); + nm_auto_close int dirfd = -1; + char ifname_verified[IFNAMSIZ]; + const char *path; - return path ? nm_platform_sysctl_get (self, path) : NULL; + if (!category || !option) + return NULL; + + dirfd = nm_platform_sysctl_open_netdir (self, ifindex, ifname_verified); + if (dirfd < 0) + return NULL; + + path = nm_sprintf_bufa (strlen (category) + strlen (option) + 2, + "%s/%s", + category, option); + return nm_platform_sysctl_get (self, NMP_SYSCTL_PATHID_NETDIR_unsafe (dirfd, ifname_verified, path)); } static const char * @@ -1763,7 +1845,7 @@ nm_platform_sysctl_slave_get_option (NMPlatform *self, int ifindex, const char * return link_get_option (self, ifindex, slave_category (self, ifindex), option); } -/******************************************************************************/ +/*****************************************************************************/ gboolean nm_platform_link_vlan_change (NMPlatform *self, @@ -1963,10 +2045,11 @@ nm_platform_link_infiniband_get_properties (NMPlatform *self, int *out_p_key, const char **out_mode) { + nm_auto_close int dirfd = -1; + char ifname_verified[IFNAMSIZ]; const NMPlatformLnkInfiniband *plnk; const NMPlatformLink *plink; - const char *iface; - char *path, *contents; + char *contents; const char *mode; int p_key = 0; @@ -1990,15 +2073,13 @@ nm_platform_link_infiniband_get_properties (NMPlatform *self, /* Could not get the link information via netlink. To support older kernels, * fallback to reading sysfs. */ - iface = NM_ASSERT_VALID_PATH_COMPONENT (plink->name); + dirfd = nm_platform_sysctl_open_netdir (self, ifindex, ifname_verified); + if (dirfd < 0) + return FALSE; - /* Fall back to reading sysfs */ - path = g_strdup_printf ("/sys/class/net/%s/mode", iface); - contents = nm_platform_sysctl_get (self, path); - g_free (path); + contents = nm_platform_sysctl_get (self, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_verified, "mode")); if (!contents) return FALSE; - if (strstr (contents, "datagram")) mode = "datagram"; else if (strstr (contents, "connected")) @@ -2007,13 +2088,7 @@ nm_platform_link_infiniband_get_properties (NMPlatform *self, mode = NULL; g_free (contents); - path = g_strdup_printf ("/sys/class/net/%s/pkey", iface); - contents = nm_platform_sysctl_get (self, path); - g_free (path); - if (!contents) - return FALSE; - p_key = (int) _nm_utils_ascii_str_to_int64 (contents, 16, 0, 0xFFFF, -1); - g_free (contents); + p_key = nm_platform_sysctl_get_int_checked (self, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_verified, "pkey"), 16, 0, 0xFFFF, -1); if (p_key < 0) return FALSE; @@ -2101,6 +2176,43 @@ nm_platform_link_ipip_add (NMPlatform *self, return NM_PLATFORM_ERROR_SUCCESS; } +/** + * nm_platform_macsec_add: + * @self: platform instance + * @name: name of the new interface + * @props: interface properties + * @out_link: on success, the link object + * + * Create a MACsec interface. + */ +NMPlatformError +nm_platform_link_macsec_add (NMPlatform *self, + const char *name, + int parent, + const NMPlatformLnkMacsec *props, + const NMPlatformLink **out_link) +{ + NMPlatformError plerr; + + _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG); + + g_return_val_if_fail (props, NM_PLATFORM_ERROR_BUG); + g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG); + + plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_MACSEC, out_link); + if (plerr != NM_PLATFORM_ERROR_SUCCESS) + return plerr; + + _LOGD ("adding macsec '%s' parent %u sci %llx", + name, + parent, + (unsigned long long) props->sci); + + if (!klass->link_macsec_add (self, name, parent, props, out_link)) + return NM_PLATFORM_ERROR_UNSPECIFIED; + return NM_PLATFORM_ERROR_SUCCESS; +} + /** * nm_platform_macvlan_add: * @self: platform instance @@ -2206,7 +2318,7 @@ nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_pe if (!nm_platform_netns_push (self, &netns)) return FALSE; - peer_ifindex = nmp_utils_ethtool_get_peer_ifindex (plink->name); + peer_ifindex = nmp_utils_ethtool_get_peer_ifindex (plink->ifindex); if (peer_ifindex <= 0) return FALSE; @@ -2216,74 +2328,45 @@ nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_pe } gboolean -nm_platform_link_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMPlatformTunProperties *props) +nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props) { - char path[256]; - char *val; + nm_auto_close int dirfd = -1; + char ifname[IFNAMSIZ]; + gint64 flags; gboolean success = TRUE; - _CHECK_SELF (self, klass, FALSE); + g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (props, FALSE); memset (props, 0, sizeof (*props)); props->owner = -1; props->group = -1; - if (!ifname || !nm_utils_iface_valid_name (ifname)) + dirfd = nm_platform_sysctl_open_netdir (self, ifindex, ifname); + if (dirfd < 0) return FALSE; - nm_sprintf_buf (path, "/sys/class/net/%s/owner", ifname); - val = nm_platform_sysctl_get (self, path); - if (val) { - props->owner = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1); - if (errno) - success = FALSE; - g_free (val); - } else + props->owner = nm_platform_sysctl_get_int_checked (self, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "owner"), 10, -1, G_MAXINT64, -1); + if (errno) success = FALSE; - nm_sprintf_buf (path, "/sys/class/net/%s/group", ifname); - val = nm_platform_sysctl_get (self, path); - if (val) { - props->group = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1); - if (errno) - success = FALSE; - g_free (val); - } else + props->group = nm_platform_sysctl_get_int_checked (self, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "group"), 10, -1, G_MAXINT64, -1); + if (errno) success = FALSE; - nm_sprintf_buf (path, "/sys/class/net/%s/tun_flags", ifname); - val = nm_platform_sysctl_get (self, path); - if (val) { - gint64 flags; - - flags = _nm_utils_ascii_str_to_int64 (val, 16, 0, G_MAXINT64, 0); - if (!errno) { - props->mode = ((flags & (IFF_TUN | IFF_TAP)) == IFF_TUN) ? "tun" : "tap"; - props->no_pi = !!(flags & IFF_NO_PI); - props->vnet_hdr = !!(flags & IFF_VNET_HDR); - props->multi_queue = !!(flags & NM_IFF_MULTI_QUEUE); - } else - success = FALSE; - g_free (val); + flags = nm_platform_sysctl_get_int_checked (self, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "tun_flags"), 16, 0, G_MAXINT64, -1); + if (flags >= 0) { + props->mode = ((flags & (IFF_TUN | IFF_TAP)) == IFF_TUN) ? "tun" : "tap"; + props->no_pi = !!(flags & IFF_NO_PI); + props->vnet_hdr = !!(flags & IFF_VNET_HDR); + props->multi_queue = !!(flags & NM_IFF_MULTI_QUEUE); } else success = FALSE; return success; } -gboolean -nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props) -{ - _CHECK_SELF (self, klass, FALSE); - - g_return_val_if_fail (ifindex > 0, FALSE); - g_return_val_if_fail (props != NULL, FALSE); - - return nm_platform_link_tun_get_properties_ifname (self, nm_platform_link_get_name (self, ifindex), props); -} - gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps) { @@ -2466,33 +2549,39 @@ _to_string_ifa_flags (guint32 ifa_flags, char *buf, gsize size) return buf; } -/******************************************************************/ +/*****************************************************************************/ gboolean -nm_platform_ethtool_set_wake_on_lan (NMPlatform *self, const char *ifname, NMSettingWiredWakeOnLan wol, const char *wol_password) +nm_platform_ethtool_set_wake_on_lan (NMPlatform *self, int ifindex, NMSettingWiredWakeOnLan wol, const char *wol_password) { - nm_auto_pop_netns NMPNetns *netns = NULL; - _CHECK_SELF (self, klass, FALSE); + _CHECK_SELF_NETNS (self, klass, netns, FALSE); - if (!nm_platform_netns_push (self, &netns)) - return FALSE; + g_return_val_if_fail (ifindex > 0, FALSE); - return nmp_utils_ethtool_set_wake_on_lan (ifname, wol, wol_password); + return nmp_utils_ethtool_set_wake_on_lan (ifindex, wol, wol_password); } gboolean -nm_platform_ethtool_get_link_speed (NMPlatform *self, const char *ifname, guint32 *out_speed) +nm_platform_ethtool_set_link_settings (NMPlatform *self, int ifindex, gboolean autoneg, guint32 speed, NMPlatformLinkDuplexType duplex) { - nm_auto_pop_netns NMPNetns *netns = NULL; - _CHECK_SELF (self, klass, FALSE); + _CHECK_SELF_NETNS (self, klass, netns, FALSE); - if (!nm_platform_netns_push (self, &netns)) - return FALSE; + g_return_val_if_fail (ifindex > 0, FALSE); - return nmp_utils_ethtool_get_link_speed (ifname, out_speed); + return nmp_utils_ethtool_set_link_settings (ifindex, autoneg, speed, duplex); } -/******************************************************************/ +gboolean +nm_platform_ethtool_get_link_settings (NMPlatform *self, int ifindex, gboolean *out_autoneg, guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex) +{ + _CHECK_SELF_NETNS (self, klass, netns, FALSE); + + g_return_val_if_fail (ifindex > 0, FALSE); + + return nmp_utils_ethtool_get_link_settings (ifindex, out_autoneg, out_speed, out_duplex); +} + +/*****************************************************************************/ void nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, guint8 plen) @@ -2662,14 +2751,14 @@ nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr addr return klass->ip6_address_get (self, ifindex, address, plen); } -static gboolean +static const NMPlatformIP4Address * array_contains_ip4_address (const GArray *addresses, const NMPlatformIP4Address *address, gint32 now) { guint len = addresses ? addresses->len : 0; guint i; for (i = 0; i < len; i++) { - NMPlatformIP4Address *candidate = &g_array_index (addresses, NMPlatformIP4Address, i); + const NMPlatformIP4Address *candidate = &g_array_index (addresses, NMPlatformIP4Address, i); if ( candidate->address == address->address && candidate->plen == address->plen @@ -2678,11 +2767,11 @@ array_contains_ip4_address (const GArray *addresses, const NMPlatformIP4Address if (nm_utils_lifetime_get (candidate->timestamp, candidate->lifetime, candidate->preferred, now, &lifetime, &preferred)) - return TRUE; + return candidate; } } - return FALSE; + return NULL; } static gboolean @@ -2706,6 +2795,97 @@ array_contains_ip6_address (const GArray *addresses, const NMPlatformIP6Address return FALSE; } +static gboolean +_ptr_inside_ip4_addr_array (const GArray *array, gconstpointer needle) +{ + return needle >= (gconstpointer) &g_array_index (array, const NMPlatformIP4Address, 0) + && needle < (gconstpointer) &g_array_index (array, const NMPlatformIP4Address, array->len); +} + +static void +ip4_addr_subnets_destroy_index (GHashTable *ht, const GArray *addresses) +{ + GHashTableIter iter; + gpointer p; + + g_hash_table_iter_init (&iter, ht); + + while (g_hash_table_iter_next (&iter, NULL, &p)) { + if (!_ptr_inside_ip4_addr_array (addresses, p)) { + g_ptr_array_free ((GPtrArray *) p, TRUE); + } + } + + g_hash_table_unref (ht); +} + +static GHashTable * +ip4_addr_subnets_build_index (const GArray *addresses, gboolean consider_flags) +{ + const NMPlatformIP4Address *address; + gpointer p; + GHashTable *subnets; + GPtrArray *ptr; + guint32 net; + guint i; + gint position; + + if (!addresses) + return NULL; + + subnets = g_hash_table_new_full (g_direct_hash, + g_direct_equal, + NULL, + NULL); + + /* Build a hash table of all addresses per subnet */ + for (i = 0; i < addresses->len; i++) { + address = &g_array_index (addresses, const NMPlatformIP4Address, i); + net = address->address & nm_utils_ip4_prefix_to_netmask (address->plen); + if (!g_hash_table_lookup_extended (subnets, GUINT_TO_POINTER (net), NULL, &p)) { + g_hash_table_insert (subnets, GUINT_TO_POINTER (net), (gpointer) address); + continue; + } + if (_ptr_inside_ip4_addr_array (addresses, p)) { + ptr = g_ptr_array_new (); + g_hash_table_insert (subnets, GUINT_TO_POINTER (net), ptr); + g_ptr_array_add (ptr, p); + } else + ptr = p; + + if (!consider_flags || NM_FLAGS_HAS (address->n_ifa_flags, IFA_F_SECONDARY)) + position = -1; /* append */ + else + position = 0; /* prepend */ + + g_ptr_array_insert (ptr, position, (gpointer) address); + } + + return subnets; +} + +static gboolean +ip4_addr_subnets_is_secondary (const NMPlatformIP4Address *address, GHashTable *subnets, const GArray *addresses, GPtrArray **out_addr_list) +{ + GPtrArray *addr_list; + gpointer p; + guint32 net; + + net = address->address & nm_utils_ip4_prefix_to_netmask (address->plen); + p = g_hash_table_lookup (subnets, GUINT_TO_POINTER (net)); + nm_assert (p); + if (!_ptr_inside_ip4_addr_array (addresses, p)) { + addr_list = p; + if (addr_list->pdata[0] != address) { + NM_SET_OUT (out_addr_list, addr_list); + return TRUE; + } + } else + nm_assert ((gconstpointer) address == p); + NM_SET_OUT (out_addr_list, NULL); + return FALSE; +} + /** * nm_platform_ip4_address_sync: * @self: platform instance @@ -2727,19 +2907,64 @@ nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known { GArray *addresses; NMPlatformIP4Address *address; + const NMPlatformIP4Address *known_address; gint32 now = nm_utils_get_monotonic_timestamp_s (); - int i; + GHashTable *plat_subnets; + GHashTable *known_subnets; + GPtrArray *ptr; + int i, j; _CHECK_SELF (self, klass, FALSE); - /* Delete unknown addresses */ addresses = nm_platform_ip4_address_get_all (self, ifindex); + plat_subnets = ip4_addr_subnets_build_index (addresses, TRUE); + known_subnets = ip4_addr_subnets_build_index (known_addresses, FALSE); + + /* Delete unknown addresses */ for (i = 0; i < addresses->len; i++) { address = &g_array_index (addresses, NMPlatformIP4Address, i); - if (!array_contains_ip4_address (known_addresses, address, now)) - nm_platform_ip4_address_delete (self, ifindex, address->address, address->plen, address->peer_address); + if (!address->ifindex) { + /* Already deleted */ + continue; + } + + known_address = array_contains_ip4_address (known_addresses, address, now); + if (known_address) { + gboolean secondary; + + secondary = ip4_addr_subnets_is_secondary (known_address, known_subnets, known_addresses, NULL); + /* Ignore the matching address if it has a different primary/slave + * role. */ + if (secondary != NM_FLAGS_HAS (address->n_ifa_flags, IFA_F_SECONDARY)) + known_address = NULL; + } + + if (!known_address) { + nm_platform_ip4_address_delete (self, ifindex, + address->address, + address->plen, + address->peer_address); + if ( !ip4_addr_subnets_is_secondary (address, plat_subnets, addresses, &ptr) + && ptr) { + /* If we just deleted a primary addresses and there were + * secondary ones the kernel can do two things, depending on + * version and sysctl setting: delete also secondary addresses + * or promote a secondary to primary. Ensure that secondary + * addresses are deleted, so that we can start with a clean + * slate and add addresses in the right order. */ + for (j = 1; j < ptr->len; j++) { + address = ptr->pdata[j]; + nm_platform_ip4_address_delete (self, ifindex, + address->address, + address->plen, + address->peer_address); + address->ifindex = 0; + } + } + } } + ip4_addr_subnets_destroy_index (plat_subnets, addresses); g_array_free (addresses, TRUE); if (out_added_addresses) @@ -2750,17 +2975,20 @@ nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known /* Add missing addresses */ for (i = 0; i < known_addresses->len; i++) { - const NMPlatformIP4Address *known_address = &g_array_index (known_addresses, NMPlatformIP4Address, i); guint32 lifetime, preferred; + known_address = &g_array_index (known_addresses, NMPlatformIP4Address, i); + if (!nm_utils_lifetime_get (known_address->timestamp, known_address->lifetime, known_address->preferred, now, &lifetime, &preferred)) continue; if (!nm_platform_ip4_address_add (self, ifindex, known_address->address, known_address->plen, known_address->peer_address, lifetime, preferred, - 0, known_address->label)) + 0, known_address->label)) { + ip4_addr_subnets_destroy_index (known_subnets, known_addresses); return FALSE; + } if (out_added_addresses) { if (!*out_added_addresses) @@ -2769,6 +2997,8 @@ nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known } } + ip4_addr_subnets_destroy_index (known_subnets, known_addresses); + return TRUE; } @@ -2815,6 +3045,11 @@ nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known const NMPlatformIP6Address *known_address = &g_array_index (known_addresses, NMPlatformIP6Address, i); guint32 lifetime, preferred; + if (NM_FLAGS_HAS (known_address->n_ifa_flags, IFA_F_TEMPORARY)) { + /* Kernel manages these */ + continue; + } + if (!nm_utils_lifetime_get (known_address->timestamp, known_address->lifetime, known_address->preferred, now, &lifetime, &preferred)) continue; @@ -2837,7 +3072,7 @@ nm_platform_address_flush (NMPlatform *self, int ifindex) && nm_platform_ip6_address_sync (self, ifindex, NULL, FALSE); } -/******************************************************************/ +/*****************************************************************************/ GArray * nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags) @@ -2985,7 +3220,7 @@ nm_platform_ip6_route_get (NMPlatform *self, int ifindex, struct in6_addr networ return klass->ip6_route_get (self, ifindex, network, plen, metric); } -/******************************************************************/ +/*****************************************************************************/ const char * nm_platform_vlan_qos_mapping_to_string (const char *name, @@ -3277,6 +3512,39 @@ nm_platform_lnk_ipip_to_string (const NMPlatformLnkIpIp *lnk, char *buf, gsize l return buf; } +const char * +nm_platform_lnk_macsec_to_string (const NMPlatformLnkMacsec *lnk, char *buf, gsize len) +{ + if (!nm_utils_to_string_buffer_init_null (lnk, &buf, &len)) + return buf; + + g_snprintf (buf, len, + "macsec " + "sci %016llx " + "protect %s " + "cipher %016llx " + "icvlen %u " + "encodingsa %u " + "validate %u " + "encrypt %s " + "send_sci %s " + "end_station %s " + "scb %s " + "replay %s", + (unsigned long long) lnk->sci, + lnk->protect ? "on" : "off", + (unsigned long long) lnk->cipher_suite, + lnk->icv_length, + lnk->encoding_sa, + lnk->validation, + lnk->encrypt ? "on" : "off", + lnk->include_sci ? "on" : "off", + lnk->es ? "on" : "off", + lnk->scb ? "on" : "off", + lnk->replay_protect ? "on" : "off"); + return buf; +} + const char * nm_platform_lnk_macvlan_to_string (const NMPlatformLnkMacvlan *lnk, char *buf, gsize len) { @@ -3858,6 +4126,25 @@ nm_platform_lnk_ipip_cmp (const NMPlatformLnkIpIp *a, const NMPlatformLnkIpIp *b return 0; } +int +nm_platform_lnk_macsec_cmp (const NMPlatformLnkMacsec *a, const NMPlatformLnkMacsec *b) +{ + _CMP_SELF (a, b); + _CMP_FIELD (a, b, sci); + _CMP_FIELD (a, b, icv_length); + _CMP_FIELD (a, b, cipher_suite); + _CMP_FIELD (a, b, window); + _CMP_FIELD (a, b, encoding_sa); + _CMP_FIELD (a, b, validation); + _CMP_FIELD (a, b, encrypt); + _CMP_FIELD (a, b, protect); + _CMP_FIELD (a, b, include_sci); + _CMP_FIELD (a, b, es); + _CMP_FIELD (a, b, scb); + _CMP_FIELD (a, b, replay_protect); + return 0; +} + int nm_platform_lnk_macvlan_cmp (const NMPlatformLnkMacvlan *a, const NMPlatformLnkMacvlan *b) { @@ -4082,7 +4369,7 @@ log_ip6_route (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatform _LOGD ("signal: route 6 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip6_route_to_string (route, NULL, 0)); } -/******************************************************************/ +/*****************************************************************************/ NMPNetns * nm_platform_netns_get (NMPlatform *self) @@ -4107,7 +4394,7 @@ nm_platform_netns_push (NMPlatform *platform, NMPNetns **netns) return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static gboolean _vtr_v4_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, gint64 metric) @@ -4174,7 +4461,7 @@ _vtr_v6_route_delete_default (NMPlatform *self, int ifindex, guint32 metric) return nm_platform_ip6_route_delete (self, ifindex, in6addr_any, 0, metric); } -/******************************************************************/ +/*****************************************************************************/ const NMPlatformVTableRoute nm_platform_vtable_route_v4 = { .is_ip4 = TRUE, @@ -4202,7 +4489,7 @@ const NMPlatformVTableRoute nm_platform_vtable_route_v6 = { .metric_normalize = nm_utils_ip6_route_metric_normalize, }; -/******************************************************************/ +/*****************************************************************************/ static void set_property (GObject *object, guint prop_id, @@ -4245,8 +4532,9 @@ constructed (GObject *object) } static void -nm_platform_init (NMPlatform *object) +nm_platform_init (NMPlatform *self) { + self->_priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_PLATFORM, NMPlatformPrivate); } static void @@ -4294,7 +4582,12 @@ nm_platform_class_init (NMPlatformClass *platform_class) G_SIGNAL_RUN_FIRST, \ G_CALLBACK (method), \ NULL, NULL, NULL, \ - G_TYPE_NONE, 4, NM_TYPE_POBJECT_TYPE, G_TYPE_INT, G_TYPE_POINTER, NM_TYPE_PLATFORM_SIGNAL_CHANGE_TYPE); \ + G_TYPE_NONE, 4, \ + G_TYPE_INT, /* (int) NMPObjectType */ \ + G_TYPE_INT, /* ifindex */ \ + G_TYPE_POINTER /* const NMPObject * */, \ + G_TYPE_INT /* (int) NMPlatformSignalChangeType */ \ + ); \ } G_STMT_END /* Signals */ diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index fc6965e9..63dbe5a0 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -42,12 +42,12 @@ #define NM_PLATFORM_NETNS_SUPPORT_DEFAULT FALSE -/******************************************************************/ +/*****************************************************************************/ #define NM_PLATFORM_NETNS_SUPPORT "netns-support" #define NM_PLATFORM_REGISTER_SINGLETON "register-singleton" -/******************************************************************/ +/*****************************************************************************/ /* workaround for older libnl version, that does not define these flags. */ #ifndef IFA_F_MANAGETEMPADDR @@ -426,6 +426,22 @@ typedef struct { bool path_mtu_discovery:1; } NMPlatformLnkIpIp; +typedef struct { + int parent_ifindex; + guint64 sci; /* host byte order */ + guint64 cipher_suite; + guint32 window; + guint8 icv_length; + guint8 encoding_sa; + guint8 validation; + bool encrypt:1; + bool protect:1; + bool include_sci:1; + bool es:1; + bool scb:1; + bool replay_protect:1; +} NMPlatformLnkMacsec; + typedef struct { guint mode; bool no_promisc:1; @@ -481,19 +497,27 @@ typedef struct { bool multi_queue:1; } NMPlatformTunProperties; -/******************************************************************/ +typedef enum { + NM_PLATFORM_LINK_DUPLEX_UNKNOWN, + NM_PLATFORM_LINK_DUPLEX_HALF, + NM_PLATFORM_LINK_DUPLEX_FULL, +} NMPlatformLinkDuplexType; + +/*****************************************************************************/ + +struct _NMPlatformPrivate; struct _NMPlatform { GObject parent; - NMPNetns *_netns; + struct _NMPlatformPrivate *_priv; }; typedef struct { GObjectClass parent; - gboolean (*sysctl_set) (NMPlatform *, const char *path, const char *value); - char * (*sysctl_get) (NMPlatform *, const char *path); + gboolean (*sysctl_set) (NMPlatform *, const char *pathid, int dirfd, const char *path, const char *value); + char * (*sysctl_get) (NMPlatform *, const char *pathid, int dirfd, const char *path); const NMPlatformLink *(*link_get) (NMPlatform *platform, int ifindex); const NMPlatformLink *(*link_get_by_ifname) (NMPlatform *platform, const char *ifname); @@ -580,6 +604,11 @@ typedef struct { const char *name, const NMPlatformLnkIpIp *props, const NMPlatformLink **out_link); + gboolean (*link_macsec_add) (NMPlatform *, + const char *name, + int parent, + const NMPlatformLnkMacsec *props, + const NMPlatformLink **out_link); gboolean (*link_macvlan_add) (NMPlatform *, const char *name, int parent, @@ -672,7 +701,7 @@ typedef struct { const char *nm_platform_signal_change_type_to_string (NMPlatformSignalChangeType change_type); -/******************************************************************/ +/*****************************************************************************/ GType nm_platform_get_type (void); @@ -682,7 +711,7 @@ NMPlatform *nm_platform_try_get (void); #define NM_PLATFORM_GET (nm_platform_get ()) -/******************************************************************/ +/*****************************************************************************/ /** * nm_platform_route_scope_inv: @@ -709,13 +738,30 @@ const char *nm_link_type_to_string (NMLinkType link_type); const char *_nm_platform_error_to_string (NMPlatformError error); #define nm_platform_error_to_string(error) NM_UTILS_LOOKUP_STR (_nm_platform_error_to_string, error) -gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value); -char *nm_platform_sysctl_get (NMPlatform *self, const char *path); -gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback); -gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint base, gint64 min, gint64 max, gint64 fallback); +#define NMP_SYSCTL_PATHID_ABSOLUTE(path) \ + ((const char *) NULL), -1, (path) + +#define NMP_SYSCTL_PATHID_NETDIR_unsafe(dirfd, ifname, path) \ + nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + IFNAMSIZ + strlen (path), \ + "net:/sys/class/net/%s/%s", (ifname), (path)), \ + (dirfd), (path) + +#define NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, path) \ + nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + IFNAMSIZ, \ + "net:/sys/class/net/%s/%s", (ifname), path), \ + (dirfd), (""path"") + +int nm_platform_sysctl_open_netdir (NMPlatform *self, int ifindex, char *out_ifname); +gboolean nm_platform_sysctl_set (NMPlatform *self, const char *pathid, int dirfd, const char *path, const char *value); +char *nm_platform_sysctl_get (NMPlatform *self, const char *pathid, int dirfd, const char *path); +gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *pathid, int dirfd, const char *path, gint32 fallback); +gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *pathid, int dirfd, const char *path, guint base, gint64 min, gint64 max, gint64 fallback); gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, int value); +const char *nm_platform_if_indextoname (NMPlatform *self, int ifindex, char *out_ifname/* of size IFNAMSIZ */); +int nm_platform_if_nametoindex (NMPlatform *self, const char *ifname); + const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex); const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname); const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length); @@ -793,6 +839,7 @@ const NMPlatformLnkIp6Tnl *nm_platform_link_get_lnk_ip6tnl (NMPlatform *self, in const NMPlatformLnkIpIp *nm_platform_link_get_lnk_ipip (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkInfiniband *nm_platform_link_get_lnk_infiniband (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkIpIp *nm_platform_link_get_lnk_ipip (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); +const NMPlatformLnkMacsec *nm_platform_link_get_lnk_macsec (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkMacvlan *nm_platform_link_get_lnk_macvlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkMacvtap *nm_platform_link_get_lnk_macvtap (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkSit *nm_platform_link_get_lnk_sit (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); @@ -845,8 +892,6 @@ gboolean nm_platform_link_infiniband_get_properties (NMPlatform *self, int ifind gboolean nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex); gboolean nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties); -gboolean nm_platform_link_tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props); - gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps); gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid); guint32 nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex); @@ -879,6 +924,11 @@ NMPlatformError nm_platform_link_ipip_add (NMPlatform *self, const char *name, const NMPlatformLnkIpIp *props, const NMPlatformLink **out_link); +NMPlatformError nm_platform_link_macsec_add (NMPlatform *self, + const char *name, + int parent, + const NMPlatformLnkMacsec *props, + const NMPlatformLink **out_link); NMPlatformError nm_platform_link_macvlan_add (NMPlatform *self, const char *name, int parent, @@ -933,6 +983,7 @@ const char *nm_platform_lnk_gre_to_string (const NMPlatformLnkGre *lnk, char *bu const char *nm_platform_lnk_infiniband_to_string (const NMPlatformLnkInfiniband *lnk, char *buf, gsize len); const char *nm_platform_lnk_ip6tnl_to_string (const NMPlatformLnkIp6Tnl *lnk, char *buf, gsize len); const char *nm_platform_lnk_ipip_to_string (const NMPlatformLnkIpIp *lnk, char *buf, gsize len); +const char *nm_platform_lnk_macsec_to_string (const NMPlatformLnkMacsec *lnk, char *buf, gsize len); const char *nm_platform_lnk_macvlan_to_string (const NMPlatformLnkMacvlan *lnk, char *buf, gsize len); const char *nm_platform_lnk_sit_to_string (const NMPlatformLnkSit *lnk, char *buf, gsize len); const char *nm_platform_lnk_vlan_to_string (const NMPlatformLnkVlan *lnk, char *buf, gsize len); @@ -953,6 +1004,7 @@ int nm_platform_lnk_gre_cmp (const NMPlatformLnkGre *a, const NMPlatformLnkGre * int nm_platform_lnk_infiniband_cmp (const NMPlatformLnkInfiniband *a, const NMPlatformLnkInfiniband *b); int nm_platform_lnk_ip6tnl_cmp (const NMPlatformLnkIp6Tnl *a, const NMPlatformLnkIp6Tnl *b); int nm_platform_lnk_ipip_cmp (const NMPlatformLnkIpIp *a, const NMPlatformLnkIpIp *b); +int nm_platform_lnk_macsec_cmp (const NMPlatformLnkMacsec *a, const NMPlatformLnkMacsec *b); int nm_platform_lnk_macvlan_cmp (const NMPlatformLnkMacvlan *a, const NMPlatformLnkMacvlan *b); int nm_platform_lnk_sit_cmp (const NMPlatformLnkSit *a, const NMPlatformLnkSit *b); int nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b); @@ -972,7 +1024,8 @@ const char *nm_platform_route_scope2str (int scope, char *buf, gsize len); int nm_platform_ip_address_cmp_expiry (const NMPlatformIPAddress *a, const NMPlatformIPAddress *b); -gboolean nm_platform_ethtool_set_wake_on_lan (NMPlatform *self, const char *ifname, NMSettingWiredWakeOnLan wol, const char *wol_password); -gboolean nm_platform_ethtool_get_link_speed (NMPlatform *self, const char *ifname, guint32 *out_speed); +gboolean nm_platform_ethtool_set_wake_on_lan (NMPlatform *self, int ifindex, NMSettingWiredWakeOnLan wol, const char *wol_password); +gboolean nm_platform_ethtool_set_link_settings (NMPlatform *self, int ifindex, gboolean autoneg, guint32 speed, NMPlatformLinkDuplexType duplex); +gboolean nm_platform_ethtool_get_link_settings (NMPlatform *self, int ifindex, gboolean *out_autoneg, guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex); #endif /* __NETWORKMANAGER_PLATFORM_H__ */ diff --git a/src/platform/nmp-netns.c b/src/platform/nmp-netns.c index 07e134c1..c9c6850d 100644 --- a/src/platform/nmp-netns.c +++ b/src/platform/nmp-netns.c @@ -63,7 +63,7 @@ __ns_types_to_str (int ns_types, int ns_types_already_set, char *buf, gsize len) #define _ns_types_to_str(ns_types, ns_types_already_set, buf) \ __ns_types_to_str (ns_types, ns_types_already_set, buf, sizeof (buf)) -/*********************************************************************************************/ +/*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_PLATFORM #define _NMLOG_PREFIX_NAME "netns" @@ -83,20 +83,33 @@ __ns_types_to_str (int ns_types, int ns_types_already_set, char *buf, gsize len) } \ } G_STMT_END -/*********************************************************************************************/ +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_FD_NET, PROP_FD_MNT, ); -typedef struct _NMPNetnsPrivate NMPNetnsPrivate; - -struct _NMPNetnsPrivate { +typedef struct { int fd_net; int fd_mnt; +} NMPNetnsPrivate; + +struct _NMPNetns { + GObject parent; + NMPNetnsPrivate _priv; }; +struct _NMPNetnsClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMPNetns, nmp_netns, G_TYPE_OBJECT); + +#define NMP_NETNS_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPNetns, NMP_IS_NETNS) + +/*****************************************************************************/ + typedef struct { NMPNetns *netns; int count; @@ -106,7 +119,7 @@ typedef struct { static void _stack_push (NMPNetns *netns, int ns_types); static NMPNetns *_netns_new (GError **error); -/*********************************************************************************************/ +/*****************************************************************************/ static GArray *netns_stack = NULL; @@ -262,13 +275,7 @@ _stack_size (void) return netns_stack->len; } -/*********************************************************************************************/ - -G_DEFINE_TYPE (NMPNetns, nmp_netns, G_TYPE_OBJECT); - -#define NMP_NETNS_GET_PRIVATE(o) ((o)->priv) - -/*********************************************************************************************/ +/*****************************************************************************/ static NMPNetns * _netns_new (GError **error) @@ -311,10 +318,11 @@ _setns (NMPNetns *self, int type) { char buf[100]; int fd; + NMPNetnsPrivate *priv = NMP_NETNS_GET_PRIVATE (self); nm_assert (NM_IN_SET (type, _CLONE_NS_ALL_V)); - fd = (type == CLONE_NEWNET) ? self->priv->fd_net : self->priv->fd_mnt; + fd = (type == CLONE_NEWNET) ? priv->fd_net : priv->fd_mnt; _LOGt (self, "set netns(%s, %d)", _ns_types_to_str (type, 0, buf), fd); @@ -390,14 +398,14 @@ _netns_switch_pop (NMPNetns *self, int ns_types) return success; } -/*********************************************************************************************/ +/*****************************************************************************/ int nmp_netns_get_fd_net (NMPNetns *self) { g_return_val_if_fail (NMP_IS_NETNS (self), 0); - return self->priv->fd_net; + return NMP_NETNS_GET_PRIVATE (self)->fd_net; } int @@ -405,10 +413,10 @@ nmp_netns_get_fd_mnt (NMPNetns *self) { g_return_val_if_fail (NMP_IS_NETNS (self), 0); - return self->priv->fd_mnt; + return NMP_NETNS_GET_PRIVATE (self)->fd_mnt; } -/*********************************************************************************************/ +/*****************************************************************************/ static gboolean _nmp_netns_push_type (NMPNetns *self, int ns_types) @@ -579,7 +587,7 @@ nmp_netns_is_initial (void) return nmp_netns_get_current () == nmp_netns_get_initial (); } -/*********************************************************************************************/ +/*****************************************************************************/ gboolean nmp_netns_bind_to_path (NMPNetns *self, const char *filename, int *out_fd) @@ -657,24 +665,25 @@ nmp_netns_bind_to_path_destroy (NMPNetns *self, const char *filename) return TRUE; } -/******************************************************************************/ +/*****************************************************************************/ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMPNetns *self = NMP_NETNS (object); + NMPNetnsPrivate *priv = NMP_NETNS_GET_PRIVATE (self); switch (prop_id) { case PROP_FD_NET: - /* construct only */ - self->priv->fd_net = g_value_get_int (value); - g_return_if_fail (self->priv->fd_net > 0); + /* construct-only */ + priv->fd_net = g_value_get_int (value); + g_return_if_fail (priv->fd_net > 0); break; case PROP_FD_MNT: - /* construct only */ - self->priv->fd_mnt = g_value_get_int (value); - g_return_if_fail (self->priv->fd_mnt > 0); + /* construct-only */ + priv->fd_mnt = g_value_get_int (value); + g_return_if_fail (priv->fd_mnt > 0); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -685,22 +694,22 @@ set_property (GObject *object, guint prop_id, static void nmp_netns_init (NMPNetns *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NMP_TYPE_NETNS, NMPNetnsPrivate); } static void dispose (GObject *object) { NMPNetns *self = NMP_NETNS (object); + NMPNetnsPrivate *priv = NMP_NETNS_GET_PRIVATE (self); - if (self->priv->fd_net > 0) { - close (self->priv->fd_net); - self->priv->fd_net = 0; + if (priv->fd_net > 0) { + close (priv->fd_net); + priv->fd_net = 0; } - if (self->priv->fd_mnt > 0) { - close (self->priv->fd_mnt); - self->priv->fd_mnt = 0; + if (priv->fd_mnt > 0) { + close (priv->fd_mnt); + priv->fd_mnt = 0; } G_OBJECT_CLASS (nmp_netns_parent_class)->dispose (object); @@ -711,8 +720,6 @@ nmp_netns_class_init (NMPNetnsClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMPNetnsPrivate)); - object_class->set_property = set_property; object_class->dispose = dispose; diff --git a/src/platform/nmp-netns.h b/src/platform/nmp-netns.h index 4eac07ac..56c1e7e8 100644 --- a/src/platform/nmp-netns.h +++ b/src/platform/nmp-netns.h @@ -33,16 +33,7 @@ #define NMP_NETNS_FD_NET "fd-net" #define NMP_NETNS_FD_MNT "fd-mnt" -struct _NMPNetnsPrivate; - -struct _NMPNetns { - GObject parent; - struct _NMPNetnsPrivate *priv; -}; - -typedef struct { - GObjectClass parent; -} NMPNetnsClass; +typedef struct _NMPNetnsClass NMPNetnsClass; GType nmp_netns_get_type (void); @@ -62,8 +53,12 @@ int nmp_netns_get_fd_mnt (NMPNetns *self); static inline void _nm_auto_pop_netns (NMPNetns **p) { - if (*p) + if (*p) { + int errsv = errno; + nmp_netns_pop (*p); + errno = errsv; + } } #define nm_auto_pop_netns __attribute__((cleanup(_nm_auto_pop_netns))) diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index 993c23d6..1503ca9a 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -30,7 +30,7 @@ #include "nm-core-utils.h" #include "nm-platform-utils.h" -/*********************************************************************************************/ +/*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_PLATFORM #define _NMLOG(level, obj, ...) \ @@ -52,7 +52,7 @@ * Disabled by default. */ #define _LOGr(...) G_STMT_START { if (FALSE) { _LOGt (__VA_ARGS__); } } G_STMT_END -/*********************************************************************************************/ +/*****************************************************************************/ struct _NMPCache { /* the cache contains only one hash table for all object types, and similarly @@ -75,7 +75,7 @@ struct _NMPCache { gboolean use_udev; }; -/******************************************************************/ +/*****************************************************************************/ static inline guint _id_hash_ip6_addr (const struct in6_addr *addr) @@ -122,10 +122,10 @@ _vlan_xgress_qos_mappings_cpy (guint *dst_n_map, } } -/******************************************************************/ +/*****************************************************************************/ static const char * -_link_get_driver (GUdevDevice *udev_device, const char *kind, const char *ifname) +_link_get_driver (GUdevDevice *udev_device, const char *kind, int ifindex) { const char *driver = NULL; @@ -140,14 +140,12 @@ _link_get_driver (GUdevDevice *udev_device, const char *kind, const char *ifname if (kind) return kind; - if (ifname) { - char *d; + if (ifindex > 0) { + NMPUtilsEthtoolDriverInfo driver_info; - if (nmp_utils_ethtool_get_driver_info (ifname, &d, NULL, NULL)) { - driver = d && d[0] ? g_intern_string (d) : NULL; - g_free (d); - if (driver) - return driver; + if (nmp_utils_ethtool_get_driver_info (ifindex, &driver_info)) { + if (driver_info.driver[0]) + return g_intern_string (driver_info.driver); } } @@ -169,7 +167,7 @@ _nmp_object_fixup_link_udev_fields (NMPObject *obj, gboolean use_udev) if (obj->_link.netlink.is_in_netlink) { driver = _link_get_driver (obj->_link.udev.device, obj->link.kind, - obj->link.name); + obj->link.ifindex); if (obj->_link.udev.device) initialized = TRUE; else if (!use_udev) { @@ -197,7 +195,7 @@ _nmp_object_fixup_link_master_connected (NMPObject *obj, const NMPCache *cache) obj->link.connected = !obj->link.connected; } -/******************************************************************/ +/*****************************************************************************/ const NMPClass * nmp_class_from_type (NMPObjectType obj_type) @@ -207,7 +205,7 @@ nmp_class_from_type (NMPObjectType obj_type) return &_nmp_classes[obj_type - 1]; } -/******************************************************************/ +/*****************************************************************************/ NMPObject * nmp_object_ref (NMPObject *obj) @@ -293,7 +291,7 @@ nmp_object_new_link (int ifindex) return obj; } -/******************************************************************/ +/*****************************************************************************/ static const NMPObject * _nmp_object_stackinit_from_class (NMPObject *obj, const NMPClass *klass) @@ -416,7 +414,7 @@ _vt_cmd_obj_stackinit_id_ip6_route (NMPObject *obj, const NMPObject *src) nmp_object_stackinit_id_ip6_route (obj, src->ip_route.ifindex, &src->ip6_route.network, src->ip_route.plen, src->ip_route.metric); } -/******************************************************************/ +/*****************************************************************************/ const char * nmp_object_to_string (const NMPObject *obj, NMPObjectToStringMode to_string_mode, char *buf, gsize buf_size) @@ -955,23 +953,20 @@ _vt_cmd_obj_is_visible_link (const NMPObject *obj) && obj->link.name[0]; } -/******************************************************************/ - -#define _STRUCT_SIZE(struct_type, field) \ - (G_STRUCT_OFFSET (struct_type, field) + sizeof (((struct_type *) NULL)->field)) +/*****************************************************************************/ _NM_UTILS_LOOKUP_DEFINE (static, _nmp_cache_id_size_by_type, NMPCacheIdType, guint, - NM_UTILS_LOOKUP_DEFAULT (({ nm_assert_not_reached (); sizeof (NMPCacheId); })), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_OBJECT_TYPE, _STRUCT_SIZE (NMPCacheId, object_type)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY, _STRUCT_SIZE (NMPCacheId, object_type)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT, _STRUCT_SIZE (NMPCacheId, object_type)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT, _STRUCT_SIZE (NMPCacheId, object_type)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX, _STRUCT_SIZE (NMPCacheId, object_type_by_ifindex)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT, _STRUCT_SIZE (NMPCacheId, object_type_by_ifindex)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT, _STRUCT_SIZE (NMPCacheId, object_type_by_ifindex)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_LINK_BY_IFNAME, _STRUCT_SIZE (NMPCacheId, link_by_ifname)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP4, _STRUCT_SIZE (NMPCacheId, routes_by_destination_ip4)), - NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP6, _STRUCT_SIZE (NMPCacheId, routes_by_destination_ip6)), + NM_UTILS_LOOKUP_DEFAULT (({ nm_assert_not_reached (); (guint) 0; })), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_OBJECT_TYPE, nm_offsetofend (NMPCacheId, object_type)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY, nm_offsetofend (NMPCacheId, object_type)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT, nm_offsetofend (NMPCacheId, object_type)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT, nm_offsetofend (NMPCacheId, object_type)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX, nm_offsetofend (NMPCacheId, object_type_by_ifindex)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT, nm_offsetofend (NMPCacheId, object_type_by_ifindex)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT, nm_offsetofend (NMPCacheId, object_type_by_ifindex)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_LINK_BY_IFNAME, nm_offsetofend (NMPCacheId, link_by_ifname)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP4, nm_offsetofend (NMPCacheId, routes_by_destination_ip4)), + NM_UTILS_LOOKUP_ITEM (NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP6, nm_offsetofend (NMPCacheId, routes_by_destination_ip6)), NM_UTILS_LOOKUP_ITEM_IGNORE (NMP_CACHE_ID_TYPE_NONE), NM_UTILS_LOOKUP_ITEM_IGNORE (__NMP_CACHE_ID_TYPE_MAX), ); @@ -1022,28 +1017,25 @@ nmp_cache_id_destroy (NMPCacheId *id) g_slice_free1 (n, id); } -/******************************************************************/ - -NMPCacheId _nmp_cache_id_static; +/*****************************************************************************/ static void _nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type) { - memset (id, 0, sizeof (NMPCacheId)); + /* there is no need to set the entire @id to zero when + * initializing the ID. + * + * First, depending on the @id_type only part of the + * @id is actually used (_nmp_cache_id_size_by_type). + * + * Second, the nmp_cache_id_init_*() *MUST* anyway make sure + * that all relevant fields are set. Since it happens that + * all structs have the packed attribute, there are no holes + * due to alignment, and it becomes simple for nmp_cache_id_init_*() + * to ensure that all fields are set. */ id->_id_type = id_type; } -NMPCacheId * -nmp_cache_id_copy (NMPCacheId *id, const NMPCacheId *src) -{ - guint n; - - memset (id, 0, sizeof (NMPCacheId)); - n = _nmp_cache_id_size_by_type (src->_id_type); - memcpy (id, src, n); - return id; -} - NMPCacheId * nmp_cache_id_init_object_type (NMPCacheId *id, NMPObjectType obj_type, gboolean visible_only) { @@ -1081,15 +1073,14 @@ nmp_cache_id_init_routes_visible (NMPCacheId *id, { g_return_val_if_fail (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE), NULL); - if (with_default && with_non_default) { - if (ifindex <= 0) - return nmp_cache_id_init_object_type (id, obj_type, TRUE); - return nmp_cache_id_init_addrroute_visible_by_ifindex (id, obj_type, ifindex); - } - - if (with_default) + if (with_default) { + if (with_non_default) { + if (ifindex <= 0) + return nmp_cache_id_init_object_type (id, obj_type, TRUE); + return nmp_cache_id_init_addrroute_visible_by_ifindex (id, obj_type, ifindex); + } _nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT); - else if (with_non_default) + } else if (with_non_default) _nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT); else g_return_val_if_reached (NULL); @@ -1105,12 +1096,13 @@ nmp_cache_id_init_link_by_ifname (NMPCacheId *id, { gsize l; - _nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_LINK_BY_IFNAME); - if ( !ifname || (l = strlen (ifname)) > sizeof (id->link_by_ifname.ifname_short)) g_return_val_if_reached (id); + _nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_LINK_BY_IFNAME); + + memset (id->link_by_ifname.ifname_short, 0, sizeof (id->link_by_ifname.ifname_short)); /* the trailing NUL is dropped!! */ memcpy (id->link_by_ifname.ifname_short, ifname, l); @@ -1139,12 +1131,11 @@ nmp_cache_id_init_routes_by_destination_ip6 (NMPCacheId *id, _nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP6); id->routes_by_destination_ip4.plen = plen; memcpy (&id->routes_by_destination_ip6._misaligned_metric, &metric, sizeof (guint32)); - if (network) - memcpy (&id->routes_by_destination_ip6._misaligned_network, network, sizeof (struct in6_addr)); + memcpy (&id->routes_by_destination_ip6._misaligned_network, network ?: &nm_ip_addr_zero.addr6, sizeof (struct in6_addr)); return id; } -/******************************************************************/ +/*****************************************************************************/ static gboolean _nmp_object_init_cache_id (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id) @@ -1302,7 +1293,7 @@ _vt_cmd_obj_init_cache_id_ipx_route (const NMPObject *obj, NMPCacheIdType id_typ return TRUE; } -/******************************************************************/ +/*****************************************************************************/ gboolean nmp_cache_use_udev_get (const NMPCache *cache) @@ -1312,7 +1303,7 @@ nmp_cache_use_udev_get (const NMPCache *cache) return cache->use_udev; } -/******************************************************************/ +/*****************************************************************************/ /** * nmp_cache_link_connected_needs_toggle: @@ -1364,7 +1355,9 @@ nmp_cache_link_connected_needs_toggle (const NMPCache *cache, const NMPObject *m && potential_slave->link.connected) { is_lower_up = TRUE; } else { - links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, NMP_OBJECT_TYPE_LINK, FALSE), &len); + NMPCacheId cache_id; + + links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (&cache_id, NMP_OBJECT_TYPE_LINK, FALSE), &len); for (i = 0; i < len; i++) { const NMPlatformLink *link = links[i]; const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link); @@ -1417,7 +1410,7 @@ nmp_cache_link_connected_needs_toggle_by_ifindex (const NMPCache *cache, int mas return NULL; } -/******************************************************************/ +/*****************************************************************************/ const NMPlatformObject *const * nmp_cache_lookup_multi (const NMPCache *cache, const NMPCacheId *cache_id, guint *out_len) @@ -1582,7 +1575,7 @@ nmp_cache_lookup_all_to_hash (const NMPCache *cache, return hash; } -/******************************************************************/ +/*****************************************************************************/ static void _nmp_cache_update_cache (NMPCache *cache, NMPObject *obj, gboolean remove) @@ -1994,7 +1987,7 @@ nmp_cache_update_link_master_connected (NMPCache *cache, int ifindex, NMPObject return NMP_CACHE_OPS_UPDATED; } -/******************************************************************/ +/*****************************************************************************/ NMPCache * nmp_cache_new (gboolean use_udev) @@ -2035,7 +2028,7 @@ nmp_cache_free (NMPCache *cache) g_free (cache); } -/******************************************************************/ +/*****************************************************************************/ void ASSERT_nmp_cache_is_consistent (const NMPCache *cache) @@ -2093,7 +2086,7 @@ ASSERT_nmp_cache_is_consistent (const NMPCache *cache) } #endif } -/******************************************************************/ +/*****************************************************************************/ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = { [NMP_OBJECT_TYPE_LINK - 1] = { @@ -2237,6 +2230,15 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = { .cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_lnk_ipip_to_string, .cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_lnk_ipip_cmp, }, + [NMP_OBJECT_TYPE_LNK_MACSEC - 1] = { + .obj_type = NMP_OBJECT_TYPE_LNK_MACSEC, + .sizeof_data = sizeof (NMPObjectLnkMacsec), + .sizeof_public = sizeof (NMPlatformLnkMacsec), + .obj_type_name = "macsec", + .lnk_link_type = NM_LINK_TYPE_MACSEC, + .cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_lnk_macsec_to_string, + .cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_lnk_macsec_cmp, + }, [NMP_OBJECT_TYPE_LNK_MACVLAN - 1] = { .obj_type = NMP_OBJECT_TYPE_LNK_MACVLAN, .sizeof_data = sizeof (NMPObjectLnkMacvlan), diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h index b6d6709c..dd11b985 100644 --- a/src/platform/nmp-object.h +++ b/src/platform/nmp-object.h @@ -121,14 +121,14 @@ struct _NMPCacheId { char ifname_short[IFNAMSIZ - 1]; /* don't include the trailing NUL so the struct fits in 4 bytes. */ } link_by_ifname; struct _nm_packed { - /* NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP6 */ + /* NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP4 */ guint8 _id_type; guint8 plen; guint32 _misaligned_metric; guint32 _misaligned_network; } routes_by_destination_ip4; struct _nm_packed { - /* NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP4 */ + /* NMP_CACHE_ID_TYPE_ROUTES_BY_DESTINATION_IP6 */ guint8 _id_type; guint8 plen; guint32 _misaligned_metric; @@ -137,9 +137,6 @@ struct _NMPCacheId { }; }; -extern NMPCacheId _nmp_cache_id_static; -#define NMP_CACHE_ID_STATIC (&_nmp_cache_id_static) - typedef struct { NMPObjectType obj_type; int addr_family; @@ -209,6 +206,10 @@ typedef struct { NMPlatformLnkIpIp _public; } NMPObjectLnkIpIp; +typedef struct { + NMPlatformLnkMacsec _public; +} NMPObjectLnkMacsec; + typedef struct { NMPlatformLnkMacvlan _public; } NMPObjectLnkMacvlan; @@ -270,6 +271,9 @@ struct _NMPObject { NMPlatformLnkIp6Tnl lnk_ip6tnl; NMPObjectLnkIp6Tnl _lnk_ip6tnl; + NMPlatformLnkMacsec lnk_macsec; + NMPObjectLnkMacsec _lnk_macsec; + NMPlatformLnkMacvlan lnk_macvlan; NMPObjectLnkMacvlan _lnk_macvlan; @@ -403,7 +407,6 @@ guint nmp_cache_id_hash (const NMPCacheId *id); NMPCacheId *nmp_cache_id_clone (const NMPCacheId *id); void nmp_cache_id_destroy (NMPCacheId *id); -NMPCacheId *nmp_cache_id_copy (NMPCacheId *id, const NMPCacheId *src); NMPCacheId *nmp_cache_id_init_object_type (NMPCacheId *id, NMPObjectType obj_type, gboolean visible_only); NMPCacheId *nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id, NMPObjectType obj_type, int ifindex); NMPCacheId *nmp_cache_id_init_routes_visible (NMPCacheId *id, NMPObjectType obj_type, gboolean with_default, gboolean with_non_default, int ifindex); diff --git a/src/platform/tests/Makefile.am b/src/platform/tests/Makefile.am deleted file mode 100644 index 0633dd28..00000000 --- a/src/platform/tests/Makefile.am +++ /dev/null @@ -1,132 +0,0 @@ -AM_CPPFLAGS = \ - -I${top_srcdir} \ - -I${top_srcdir}/shared \ - -I${top_builddir}/shared \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I${srcdir}/.. \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(GUDEV_CFLAGS) \ - $(LIBNL_CFLAGS) - -if REQUIRE_ROOT_TESTS -AM_CPPFLAGS += -DREQUIRE_ROOT_TESTS=1 -endif - -PLATFORM_SOURCES = \ - ../nm-platform.c \ - ../nm-fake-platform.c \ - ../nm-linux-platform.c -TEST_SOURCES = \ - test-common.c \ - test-common.h \ - $(PLATFORM_SOURCES) -AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -AM_LDFLAGS = $(GLIB_LIBS) $(GUDEV_LIBS) $(LIBNL_LIBS) $(CODE_COVERAGE_LDFLAGS) -PLATFORM_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -@GNOME_CODE_COVERAGE_RULES@ - -noinst_PROGRAMS = \ - monitor \ - test-link-fake \ - test-link-linux \ - test-address-fake \ - test-address-linux \ - test-general \ - test-nmp-object \ - test-route-fake \ - test-route-linux \ - test-cleanup-fake \ - test-cleanup-linux - -EXTRA_DIST = test-common.h - -monitor_SOURCES = monitor.c $(PLATFORM_SOURCES) -monitor_LDADD = $(PLATFORM_LDADD) - -test_link_fake_SOURCES = $(TEST_SOURCES) test-link.c -test_link_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_link_fake_LDADD = $(PLATFORM_LDADD) - -test_link_linux_SOURCES = $(TEST_SOURCES) test-link.c -test_link_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_link_linux_LDADD = $(PLATFORM_LDADD) - -test_address_fake_SOURCES = $(TEST_SOURCES) test-address.c -test_address_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_address_fake_LDADD = $(PLATFORM_LDADD) - -test_address_linux_SOURCES = $(TEST_SOURCES) test-address.c -test_address_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_address_linux_LDADD = $(PLATFORM_LDADD) - -test_route_fake_SOURCES = $(TEST_SOURCES) test-route.c -test_route_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_route_fake_LDADD = $(PLATFORM_LDADD) - -test_route_linux_SOURCES = $(TEST_SOURCES) test-route.c -test_route_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_route_linux_LDADD = $(PLATFORM_LDADD) - -test_cleanup_fake_SOURCES = $(TEST_SOURCES) test-cleanup.c -test_cleanup_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_cleanup_fake_LDADD = $(PLATFORM_LDADD) - -test_cleanup_linux_SOURCES = $(TEST_SOURCES) test-cleanup.c -test_cleanup_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_cleanup_linux_LDADD = $(PLATFORM_LDADD) - -test_nmp_object_SOURCES = \ - test-nmp-object.c -test_nmp_object_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -test_general_SOURCES = \ - test-general.c -test_general_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - - -@VALGRIND_RULES@ -TESTS = \ - test-address-fake \ - test-address-linux \ - test-cleanup-fake \ - test-cleanup-linux \ - test-general \ - test-link-fake \ - test-link-linux \ - test-nmp-object \ - test-route-fake \ - test-route-linux - diff --git a/src/platform/tests/Makefile.in b/src/platform/tests/Makefile.in deleted file mode 100644 index 3f452b0f..00000000 --- a/src/platform/tests/Makefile.in +++ /dev/null @@ -1,2068 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@REQUIRE_ROOT_TESTS_TRUE@am__append_1 = -DREQUIRE_ROOT_TESTS=1 -noinst_PROGRAMS = monitor$(EXEEXT) test-link-fake$(EXEEXT) \ - test-link-linux$(EXEEXT) test-address-fake$(EXEEXT) \ - test-address-linux$(EXEEXT) test-general$(EXEEXT) \ - test-nmp-object$(EXEEXT) test-route-fake$(EXEEXT) \ - test-route-linux$(EXEEXT) test-cleanup-fake$(EXEEXT) \ - test-cleanup-linux$(EXEEXT) -TESTS = test-address-fake$(EXEEXT) test-address-linux$(EXEEXT) \ - test-cleanup-fake$(EXEEXT) test-cleanup-linux$(EXEEXT) \ - test-general$(EXEEXT) test-link-fake$(EXEEXT) \ - test-link-linux$(EXEEXT) test-nmp-object$(EXEEXT) \ - test-route-fake$(EXEEXT) test-route-linux$(EXEEXT) -subdir = src/platform/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am__objects_1 = nm-platform.$(OBJEXT) nm-fake-platform.$(OBJEXT) \ - nm-linux-platform.$(OBJEXT) -am_monitor_OBJECTS = monitor.$(OBJEXT) $(am__objects_1) -monitor_OBJECTS = $(am_monitor_OBJECTS) -monitor_DEPENDENCIES = $(PLATFORM_LDADD) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -am__objects_2 = test_address_fake-nm-platform.$(OBJEXT) \ - test_address_fake-nm-fake-platform.$(OBJEXT) \ - test_address_fake-nm-linux-platform.$(OBJEXT) -am__objects_3 = test_address_fake-test-common.$(OBJEXT) \ - $(am__objects_2) -am_test_address_fake_OBJECTS = $(am__objects_3) \ - test_address_fake-test-address.$(OBJEXT) -test_address_fake_OBJECTS = $(am_test_address_fake_OBJECTS) -test_address_fake_DEPENDENCIES = $(PLATFORM_LDADD) -am__objects_4 = test_address_linux-nm-platform.$(OBJEXT) \ - test_address_linux-nm-fake-platform.$(OBJEXT) \ - test_address_linux-nm-linux-platform.$(OBJEXT) -am__objects_5 = test_address_linux-test-common.$(OBJEXT) \ - $(am__objects_4) -am_test_address_linux_OBJECTS = $(am__objects_5) \ - test_address_linux-test-address.$(OBJEXT) -test_address_linux_OBJECTS = $(am_test_address_linux_OBJECTS) -test_address_linux_DEPENDENCIES = $(PLATFORM_LDADD) -am__objects_6 = test_cleanup_fake-nm-platform.$(OBJEXT) \ - test_cleanup_fake-nm-fake-platform.$(OBJEXT) \ - test_cleanup_fake-nm-linux-platform.$(OBJEXT) -am__objects_7 = test_cleanup_fake-test-common.$(OBJEXT) \ - $(am__objects_6) -am_test_cleanup_fake_OBJECTS = $(am__objects_7) \ - test_cleanup_fake-test-cleanup.$(OBJEXT) -test_cleanup_fake_OBJECTS = $(am_test_cleanup_fake_OBJECTS) -test_cleanup_fake_DEPENDENCIES = $(PLATFORM_LDADD) -am__objects_8 = test_cleanup_linux-nm-platform.$(OBJEXT) \ - test_cleanup_linux-nm-fake-platform.$(OBJEXT) \ - test_cleanup_linux-nm-linux-platform.$(OBJEXT) -am__objects_9 = test_cleanup_linux-test-common.$(OBJEXT) \ - $(am__objects_8) -am_test_cleanup_linux_OBJECTS = $(am__objects_9) \ - test_cleanup_linux-test-cleanup.$(OBJEXT) -test_cleanup_linux_OBJECTS = $(am_test_cleanup_linux_OBJECTS) -test_cleanup_linux_DEPENDENCIES = $(PLATFORM_LDADD) -am_test_general_OBJECTS = test-general.$(OBJEXT) -test_general_OBJECTS = $(am_test_general_OBJECTS) -test_general_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManagerTest.la -am__objects_10 = test_link_fake-nm-platform.$(OBJEXT) \ - test_link_fake-nm-fake-platform.$(OBJEXT) \ - test_link_fake-nm-linux-platform.$(OBJEXT) -am__objects_11 = test_link_fake-test-common.$(OBJEXT) \ - $(am__objects_10) -am_test_link_fake_OBJECTS = $(am__objects_11) \ - test_link_fake-test-link.$(OBJEXT) -test_link_fake_OBJECTS = $(am_test_link_fake_OBJECTS) -test_link_fake_DEPENDENCIES = $(PLATFORM_LDADD) -am__objects_12 = test_link_linux-nm-platform.$(OBJEXT) \ - test_link_linux-nm-fake-platform.$(OBJEXT) \ - test_link_linux-nm-linux-platform.$(OBJEXT) -am__objects_13 = test_link_linux-test-common.$(OBJEXT) \ - $(am__objects_12) -am_test_link_linux_OBJECTS = $(am__objects_13) \ - test_link_linux-test-link.$(OBJEXT) -test_link_linux_OBJECTS = $(am_test_link_linux_OBJECTS) -test_link_linux_DEPENDENCIES = $(PLATFORM_LDADD) -am_test_nmp_object_OBJECTS = test-nmp-object.$(OBJEXT) -test_nmp_object_OBJECTS = $(am_test_nmp_object_OBJECTS) -test_nmp_object_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManagerTest.la -am__objects_14 = test_route_fake-nm-platform.$(OBJEXT) \ - test_route_fake-nm-fake-platform.$(OBJEXT) \ - test_route_fake-nm-linux-platform.$(OBJEXT) -am__objects_15 = test_route_fake-test-common.$(OBJEXT) \ - $(am__objects_14) -am_test_route_fake_OBJECTS = $(am__objects_15) \ - test_route_fake-test-route.$(OBJEXT) -test_route_fake_OBJECTS = $(am_test_route_fake_OBJECTS) -test_route_fake_DEPENDENCIES = $(PLATFORM_LDADD) -am__objects_16 = test_route_linux-nm-platform.$(OBJEXT) \ - test_route_linux-nm-fake-platform.$(OBJEXT) \ - test_route_linux-nm-linux-platform.$(OBJEXT) -am__objects_17 = test_route_linux-test-common.$(OBJEXT) \ - $(am__objects_16) -am_test_route_linux_OBJECTS = $(am__objects_17) \ - test_route_linux-test-route.$(OBJEXT) -test_route_linux_OBJECTS = $(am_test_route_linux_OBJECTS) -test_route_linux_DEPENDENCIES = $(PLATFORM_LDADD) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(monitor_SOURCES) $(test_address_fake_SOURCES) \ - $(test_address_linux_SOURCES) $(test_cleanup_fake_SOURCES) \ - $(test_cleanup_linux_SOURCES) $(test_general_SOURCES) \ - $(test_link_fake_SOURCES) $(test_link_linux_SOURCES) \ - $(test_nmp_object_SOURCES) $(test_route_fake_SOURCES) \ - $(test_route_linux_SOURCES) -DIST_SOURCES = $(monitor_SOURCES) $(test_address_fake_SOURCES) \ - $(test_address_linux_SOURCES) $(test_cleanup_fake_SOURCES) \ - $(test_cleanup_linux_SOURCES) $(test_general_SOURCES) \ - $(test_link_fake_SOURCES) $(test_link_linux_SOURCES) \ - $(test_nmp_object_SOURCES) $(test_route_fake_SOURCES) \ - $(test_route_linux_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/shared \ - -I${top_builddir}/shared -I${top_srcdir}/src \ - -I${top_builddir}/src -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core -I${srcdir}/.. \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) $(GUDEV_CFLAGS) $(LIBNL_CFLAGS) $(am__append_1) -PLATFORM_SOURCES = \ - ../nm-platform.c \ - ../nm-fake-platform.c \ - ../nm-linux-platform.c - -TEST_SOURCES = \ - test-common.c \ - test-common.h \ - $(PLATFORM_SOURCES) - -AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -AM_LDFLAGS = $(GLIB_LIBS) $(GUDEV_LIBS) $(LIBNL_LIBS) $(CODE_COVERAGE_LDFLAGS) -PLATFORM_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -EXTRA_DIST = test-common.h -monitor_SOURCES = monitor.c $(PLATFORM_SOURCES) -monitor_LDADD = $(PLATFORM_LDADD) -test_link_fake_SOURCES = $(TEST_SOURCES) test-link.c -test_link_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 - -test_link_fake_LDADD = $(PLATFORM_LDADD) -test_link_linux_SOURCES = $(TEST_SOURCES) test-link.c -test_link_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 - -test_link_linux_LDADD = $(PLATFORM_LDADD) -test_address_fake_SOURCES = $(TEST_SOURCES) test-address.c -test_address_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 - -test_address_fake_LDADD = $(PLATFORM_LDADD) -test_address_linux_SOURCES = $(TEST_SOURCES) test-address.c -test_address_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 - -test_address_linux_LDADD = $(PLATFORM_LDADD) -test_route_fake_SOURCES = $(TEST_SOURCES) test-route.c -test_route_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 - -test_route_fake_LDADD = $(PLATFORM_LDADD) -test_route_linux_SOURCES = $(TEST_SOURCES) test-route.c -test_route_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 - -test_route_linux_LDADD = $(PLATFORM_LDADD) -test_cleanup_fake_SOURCES = $(TEST_SOURCES) test-cleanup.c -test_cleanup_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 - -test_cleanup_fake_LDADD = $(PLATFORM_LDADD) -test_cleanup_linux_SOURCES = $(TEST_SOURCES) test-cleanup.c -test_cleanup_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 - -test_cleanup_linux_LDADD = $(PLATFORM_LDADD) -test_nmp_object_SOURCES = \ - test-nmp-object.c - -test_nmp_object_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -test_general_SOURCES = \ - test-general.c - -test_general_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/platform/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/platform/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -monitor$(EXEEXT): $(monitor_OBJECTS) $(monitor_DEPENDENCIES) $(EXTRA_monitor_DEPENDENCIES) - @rm -f monitor$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(monitor_OBJECTS) $(monitor_LDADD) $(LIBS) - -test-address-fake$(EXEEXT): $(test_address_fake_OBJECTS) $(test_address_fake_DEPENDENCIES) $(EXTRA_test_address_fake_DEPENDENCIES) - @rm -f test-address-fake$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_address_fake_OBJECTS) $(test_address_fake_LDADD) $(LIBS) - -test-address-linux$(EXEEXT): $(test_address_linux_OBJECTS) $(test_address_linux_DEPENDENCIES) $(EXTRA_test_address_linux_DEPENDENCIES) - @rm -f test-address-linux$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_address_linux_OBJECTS) $(test_address_linux_LDADD) $(LIBS) - -test-cleanup-fake$(EXEEXT): $(test_cleanup_fake_OBJECTS) $(test_cleanup_fake_DEPENDENCIES) $(EXTRA_test_cleanup_fake_DEPENDENCIES) - @rm -f test-cleanup-fake$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_cleanup_fake_OBJECTS) $(test_cleanup_fake_LDADD) $(LIBS) - -test-cleanup-linux$(EXEEXT): $(test_cleanup_linux_OBJECTS) $(test_cleanup_linux_DEPENDENCIES) $(EXTRA_test_cleanup_linux_DEPENDENCIES) - @rm -f test-cleanup-linux$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_cleanup_linux_OBJECTS) $(test_cleanup_linux_LDADD) $(LIBS) - -test-general$(EXEEXT): $(test_general_OBJECTS) $(test_general_DEPENDENCIES) $(EXTRA_test_general_DEPENDENCIES) - @rm -f test-general$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_general_OBJECTS) $(test_general_LDADD) $(LIBS) - -test-link-fake$(EXEEXT): $(test_link_fake_OBJECTS) $(test_link_fake_DEPENDENCIES) $(EXTRA_test_link_fake_DEPENDENCIES) - @rm -f test-link-fake$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_link_fake_OBJECTS) $(test_link_fake_LDADD) $(LIBS) - -test-link-linux$(EXEEXT): $(test_link_linux_OBJECTS) $(test_link_linux_DEPENDENCIES) $(EXTRA_test_link_linux_DEPENDENCIES) - @rm -f test-link-linux$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_link_linux_OBJECTS) $(test_link_linux_LDADD) $(LIBS) - -test-nmp-object$(EXEEXT): $(test_nmp_object_OBJECTS) $(test_nmp_object_DEPENDENCIES) $(EXTRA_test_nmp_object_DEPENDENCIES) - @rm -f test-nmp-object$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_nmp_object_OBJECTS) $(test_nmp_object_LDADD) $(LIBS) - -test-route-fake$(EXEEXT): $(test_route_fake_OBJECTS) $(test_route_fake_DEPENDENCIES) $(EXTRA_test_route_fake_DEPENDENCIES) - @rm -f test-route-fake$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_route_fake_OBJECTS) $(test_route_fake_LDADD) $(LIBS) - -test-route-linux$(EXEEXT): $(test_route_linux_OBJECTS) $(test_route_linux_DEPENDENCIES) $(EXTRA_test_route_linux_DEPENDENCIES) - @rm -f test-route-linux$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_route_linux_OBJECTS) $(test_route_linux_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-general.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nmp-object.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_fake-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_fake-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_fake-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_fake-test-address.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_fake-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_linux-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_linux-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_linux-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_linux-test-address.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_address_linux-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_fake-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_fake-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_fake-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_fake-test-cleanup.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_fake-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_linux-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_linux-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_linux-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_linux-test-cleanup.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cleanup_linux-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_fake-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_fake-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_fake-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_fake-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_fake-test-link.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_linux-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_linux-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_linux-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_linux-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_link_linux-test-link.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_fake-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_fake-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_fake-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_fake-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_fake-test-route.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_linux-nm-fake-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_linux-nm-linux-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_linux-nm-platform.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_linux-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_linux-test-route.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-platform.o -MD -MP -MF $(DEPDIR)/nm-platform.Tpo -c -o nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-platform.Tpo $(DEPDIR)/nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-platform.obj -MD -MP -MF $(DEPDIR)/nm-platform.Tpo -c -o nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-platform.Tpo $(DEPDIR)/nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-fake-platform.o -MD -MP -MF $(DEPDIR)/nm-fake-platform.Tpo -c -o nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-fake-platform.Tpo $(DEPDIR)/nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/nm-fake-platform.Tpo -c -o nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-fake-platform.Tpo $(DEPDIR)/nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-linux-platform.o -MD -MP -MF $(DEPDIR)/nm-linux-platform.Tpo -c -o nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-linux-platform.Tpo $(DEPDIR)/nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/nm-linux-platform.Tpo -c -o nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nm-linux-platform.Tpo $(DEPDIR)/nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_address_fake-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-test-common.o -MD -MP -MF $(DEPDIR)/test_address_fake-test-common.Tpo -c -o test_address_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-test-common.Tpo $(DEPDIR)/test_address_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_address_fake-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_address_fake-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-test-common.obj -MD -MP -MF $(DEPDIR)/test_address_fake-test-common.Tpo -c -o test_address_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-test-common.Tpo $(DEPDIR)/test_address_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_address_fake-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_address_fake-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-nm-platform.o -MD -MP -MF $(DEPDIR)/test_address_fake-nm-platform.Tpo -c -o test_address_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-nm-platform.Tpo $(DEPDIR)/test_address_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_address_fake-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_address_fake-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_address_fake-nm-platform.Tpo -c -o test_address_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-nm-platform.Tpo $(DEPDIR)/test_address_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_address_fake-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_address_fake-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_address_fake-nm-fake-platform.Tpo -c -o test_address_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-nm-fake-platform.Tpo $(DEPDIR)/test_address_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_address_fake-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_address_fake-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_address_fake-nm-fake-platform.Tpo -c -o test_address_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-nm-fake-platform.Tpo $(DEPDIR)/test_address_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_address_fake-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_address_fake-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_address_fake-nm-linux-platform.Tpo -c -o test_address_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-nm-linux-platform.Tpo $(DEPDIR)/test_address_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_address_fake-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_address_fake-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_address_fake-nm-linux-platform.Tpo -c -o test_address_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-nm-linux-platform.Tpo $(DEPDIR)/test_address_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_address_fake-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_address_fake-test-address.o: test-address.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-test-address.o -MD -MP -MF $(DEPDIR)/test_address_fake-test-address.Tpo -c -o test_address_fake-test-address.o `test -f 'test-address.c' || echo '$(srcdir)/'`test-address.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-test-address.Tpo $(DEPDIR)/test_address_fake-test-address.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-address.c' object='test_address_fake-test-address.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-test-address.o `test -f 'test-address.c' || echo '$(srcdir)/'`test-address.c - -test_address_fake-test-address.obj: test-address.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_fake-test-address.obj -MD -MP -MF $(DEPDIR)/test_address_fake-test-address.Tpo -c -o test_address_fake-test-address.obj `if test -f 'test-address.c'; then $(CYGPATH_W) 'test-address.c'; else $(CYGPATH_W) '$(srcdir)/test-address.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_fake-test-address.Tpo $(DEPDIR)/test_address_fake-test-address.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-address.c' object='test_address_fake-test-address.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_fake-test-address.obj `if test -f 'test-address.c'; then $(CYGPATH_W) 'test-address.c'; else $(CYGPATH_W) '$(srcdir)/test-address.c'; fi` - -test_address_linux-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-test-common.o -MD -MP -MF $(DEPDIR)/test_address_linux-test-common.Tpo -c -o test_address_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-test-common.Tpo $(DEPDIR)/test_address_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_address_linux-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_address_linux-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-test-common.obj -MD -MP -MF $(DEPDIR)/test_address_linux-test-common.Tpo -c -o test_address_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-test-common.Tpo $(DEPDIR)/test_address_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_address_linux-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_address_linux-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-nm-platform.o -MD -MP -MF $(DEPDIR)/test_address_linux-nm-platform.Tpo -c -o test_address_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-nm-platform.Tpo $(DEPDIR)/test_address_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_address_linux-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_address_linux-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_address_linux-nm-platform.Tpo -c -o test_address_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-nm-platform.Tpo $(DEPDIR)/test_address_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_address_linux-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_address_linux-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_address_linux-nm-fake-platform.Tpo -c -o test_address_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-nm-fake-platform.Tpo $(DEPDIR)/test_address_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_address_linux-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_address_linux-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_address_linux-nm-fake-platform.Tpo -c -o test_address_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-nm-fake-platform.Tpo $(DEPDIR)/test_address_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_address_linux-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_address_linux-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_address_linux-nm-linux-platform.Tpo -c -o test_address_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-nm-linux-platform.Tpo $(DEPDIR)/test_address_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_address_linux-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_address_linux-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_address_linux-nm-linux-platform.Tpo -c -o test_address_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-nm-linux-platform.Tpo $(DEPDIR)/test_address_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_address_linux-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_address_linux-test-address.o: test-address.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-test-address.o -MD -MP -MF $(DEPDIR)/test_address_linux-test-address.Tpo -c -o test_address_linux-test-address.o `test -f 'test-address.c' || echo '$(srcdir)/'`test-address.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-test-address.Tpo $(DEPDIR)/test_address_linux-test-address.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-address.c' object='test_address_linux-test-address.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-test-address.o `test -f 'test-address.c' || echo '$(srcdir)/'`test-address.c - -test_address_linux-test-address.obj: test-address.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_address_linux-test-address.obj -MD -MP -MF $(DEPDIR)/test_address_linux-test-address.Tpo -c -o test_address_linux-test-address.obj `if test -f 'test-address.c'; then $(CYGPATH_W) 'test-address.c'; else $(CYGPATH_W) '$(srcdir)/test-address.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_address_linux-test-address.Tpo $(DEPDIR)/test_address_linux-test-address.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-address.c' object='test_address_linux-test-address.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_address_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_address_linux-test-address.obj `if test -f 'test-address.c'; then $(CYGPATH_W) 'test-address.c'; else $(CYGPATH_W) '$(srcdir)/test-address.c'; fi` - -test_cleanup_fake-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-test-common.o -MD -MP -MF $(DEPDIR)/test_cleanup_fake-test-common.Tpo -c -o test_cleanup_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-test-common.Tpo $(DEPDIR)/test_cleanup_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_cleanup_fake-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_cleanup_fake-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-test-common.obj -MD -MP -MF $(DEPDIR)/test_cleanup_fake-test-common.Tpo -c -o test_cleanup_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-test-common.Tpo $(DEPDIR)/test_cleanup_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_cleanup_fake-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_cleanup_fake-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-nm-platform.o -MD -MP -MF $(DEPDIR)/test_cleanup_fake-nm-platform.Tpo -c -o test_cleanup_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-nm-platform.Tpo $(DEPDIR)/test_cleanup_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_cleanup_fake-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_cleanup_fake-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_cleanup_fake-nm-platform.Tpo -c -o test_cleanup_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-nm-platform.Tpo $(DEPDIR)/test_cleanup_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_cleanup_fake-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_cleanup_fake-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_cleanup_fake-nm-fake-platform.Tpo -c -o test_cleanup_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-nm-fake-platform.Tpo $(DEPDIR)/test_cleanup_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_cleanup_fake-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_cleanup_fake-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_cleanup_fake-nm-fake-platform.Tpo -c -o test_cleanup_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-nm-fake-platform.Tpo $(DEPDIR)/test_cleanup_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_cleanup_fake-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_cleanup_fake-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_cleanup_fake-nm-linux-platform.Tpo -c -o test_cleanup_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-nm-linux-platform.Tpo $(DEPDIR)/test_cleanup_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_cleanup_fake-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_cleanup_fake-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_cleanup_fake-nm-linux-platform.Tpo -c -o test_cleanup_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-nm-linux-platform.Tpo $(DEPDIR)/test_cleanup_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_cleanup_fake-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_cleanup_fake-test-cleanup.o: test-cleanup.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-test-cleanup.o -MD -MP -MF $(DEPDIR)/test_cleanup_fake-test-cleanup.Tpo -c -o test_cleanup_fake-test-cleanup.o `test -f 'test-cleanup.c' || echo '$(srcdir)/'`test-cleanup.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-test-cleanup.Tpo $(DEPDIR)/test_cleanup_fake-test-cleanup.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-cleanup.c' object='test_cleanup_fake-test-cleanup.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-test-cleanup.o `test -f 'test-cleanup.c' || echo '$(srcdir)/'`test-cleanup.c - -test_cleanup_fake-test-cleanup.obj: test-cleanup.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_fake-test-cleanup.obj -MD -MP -MF $(DEPDIR)/test_cleanup_fake-test-cleanup.Tpo -c -o test_cleanup_fake-test-cleanup.obj `if test -f 'test-cleanup.c'; then $(CYGPATH_W) 'test-cleanup.c'; else $(CYGPATH_W) '$(srcdir)/test-cleanup.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_fake-test-cleanup.Tpo $(DEPDIR)/test_cleanup_fake-test-cleanup.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-cleanup.c' object='test_cleanup_fake-test-cleanup.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_fake-test-cleanup.obj `if test -f 'test-cleanup.c'; then $(CYGPATH_W) 'test-cleanup.c'; else $(CYGPATH_W) '$(srcdir)/test-cleanup.c'; fi` - -test_cleanup_linux-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-test-common.o -MD -MP -MF $(DEPDIR)/test_cleanup_linux-test-common.Tpo -c -o test_cleanup_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-test-common.Tpo $(DEPDIR)/test_cleanup_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_cleanup_linux-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_cleanup_linux-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-test-common.obj -MD -MP -MF $(DEPDIR)/test_cleanup_linux-test-common.Tpo -c -o test_cleanup_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-test-common.Tpo $(DEPDIR)/test_cleanup_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_cleanup_linux-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_cleanup_linux-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-nm-platform.o -MD -MP -MF $(DEPDIR)/test_cleanup_linux-nm-platform.Tpo -c -o test_cleanup_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-nm-platform.Tpo $(DEPDIR)/test_cleanup_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_cleanup_linux-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_cleanup_linux-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_cleanup_linux-nm-platform.Tpo -c -o test_cleanup_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-nm-platform.Tpo $(DEPDIR)/test_cleanup_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_cleanup_linux-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_cleanup_linux-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_cleanup_linux-nm-fake-platform.Tpo -c -o test_cleanup_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-nm-fake-platform.Tpo $(DEPDIR)/test_cleanup_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_cleanup_linux-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_cleanup_linux-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_cleanup_linux-nm-fake-platform.Tpo -c -o test_cleanup_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-nm-fake-platform.Tpo $(DEPDIR)/test_cleanup_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_cleanup_linux-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_cleanup_linux-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_cleanup_linux-nm-linux-platform.Tpo -c -o test_cleanup_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-nm-linux-platform.Tpo $(DEPDIR)/test_cleanup_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_cleanup_linux-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_cleanup_linux-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_cleanup_linux-nm-linux-platform.Tpo -c -o test_cleanup_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-nm-linux-platform.Tpo $(DEPDIR)/test_cleanup_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_cleanup_linux-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_cleanup_linux-test-cleanup.o: test-cleanup.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-test-cleanup.o -MD -MP -MF $(DEPDIR)/test_cleanup_linux-test-cleanup.Tpo -c -o test_cleanup_linux-test-cleanup.o `test -f 'test-cleanup.c' || echo '$(srcdir)/'`test-cleanup.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-test-cleanup.Tpo $(DEPDIR)/test_cleanup_linux-test-cleanup.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-cleanup.c' object='test_cleanup_linux-test-cleanup.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-test-cleanup.o `test -f 'test-cleanup.c' || echo '$(srcdir)/'`test-cleanup.c - -test_cleanup_linux-test-cleanup.obj: test-cleanup.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_cleanup_linux-test-cleanup.obj -MD -MP -MF $(DEPDIR)/test_cleanup_linux-test-cleanup.Tpo -c -o test_cleanup_linux-test-cleanup.obj `if test -f 'test-cleanup.c'; then $(CYGPATH_W) 'test-cleanup.c'; else $(CYGPATH_W) '$(srcdir)/test-cleanup.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_cleanup_linux-test-cleanup.Tpo $(DEPDIR)/test_cleanup_linux-test-cleanup.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-cleanup.c' object='test_cleanup_linux-test-cleanup.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_cleanup_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_cleanup_linux-test-cleanup.obj `if test -f 'test-cleanup.c'; then $(CYGPATH_W) 'test-cleanup.c'; else $(CYGPATH_W) '$(srcdir)/test-cleanup.c'; fi` - -test_link_fake-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-test-common.o -MD -MP -MF $(DEPDIR)/test_link_fake-test-common.Tpo -c -o test_link_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-test-common.Tpo $(DEPDIR)/test_link_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_link_fake-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_link_fake-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-test-common.obj -MD -MP -MF $(DEPDIR)/test_link_fake-test-common.Tpo -c -o test_link_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-test-common.Tpo $(DEPDIR)/test_link_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_link_fake-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_link_fake-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-nm-platform.o -MD -MP -MF $(DEPDIR)/test_link_fake-nm-platform.Tpo -c -o test_link_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-nm-platform.Tpo $(DEPDIR)/test_link_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_link_fake-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_link_fake-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_link_fake-nm-platform.Tpo -c -o test_link_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-nm-platform.Tpo $(DEPDIR)/test_link_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_link_fake-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_link_fake-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_link_fake-nm-fake-platform.Tpo -c -o test_link_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-nm-fake-platform.Tpo $(DEPDIR)/test_link_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_link_fake-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_link_fake-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_link_fake-nm-fake-platform.Tpo -c -o test_link_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-nm-fake-platform.Tpo $(DEPDIR)/test_link_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_link_fake-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_link_fake-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_link_fake-nm-linux-platform.Tpo -c -o test_link_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-nm-linux-platform.Tpo $(DEPDIR)/test_link_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_link_fake-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_link_fake-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_link_fake-nm-linux-platform.Tpo -c -o test_link_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-nm-linux-platform.Tpo $(DEPDIR)/test_link_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_link_fake-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_link_fake-test-link.o: test-link.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-test-link.o -MD -MP -MF $(DEPDIR)/test_link_fake-test-link.Tpo -c -o test_link_fake-test-link.o `test -f 'test-link.c' || echo '$(srcdir)/'`test-link.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-test-link.Tpo $(DEPDIR)/test_link_fake-test-link.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-link.c' object='test_link_fake-test-link.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-test-link.o `test -f 'test-link.c' || echo '$(srcdir)/'`test-link.c - -test_link_fake-test-link.obj: test-link.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_fake-test-link.obj -MD -MP -MF $(DEPDIR)/test_link_fake-test-link.Tpo -c -o test_link_fake-test-link.obj `if test -f 'test-link.c'; then $(CYGPATH_W) 'test-link.c'; else $(CYGPATH_W) '$(srcdir)/test-link.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_fake-test-link.Tpo $(DEPDIR)/test_link_fake-test-link.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-link.c' object='test_link_fake-test-link.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_fake-test-link.obj `if test -f 'test-link.c'; then $(CYGPATH_W) 'test-link.c'; else $(CYGPATH_W) '$(srcdir)/test-link.c'; fi` - -test_link_linux-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-test-common.o -MD -MP -MF $(DEPDIR)/test_link_linux-test-common.Tpo -c -o test_link_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-test-common.Tpo $(DEPDIR)/test_link_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_link_linux-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_link_linux-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-test-common.obj -MD -MP -MF $(DEPDIR)/test_link_linux-test-common.Tpo -c -o test_link_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-test-common.Tpo $(DEPDIR)/test_link_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_link_linux-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_link_linux-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-nm-platform.o -MD -MP -MF $(DEPDIR)/test_link_linux-nm-platform.Tpo -c -o test_link_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-nm-platform.Tpo $(DEPDIR)/test_link_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_link_linux-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_link_linux-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_link_linux-nm-platform.Tpo -c -o test_link_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-nm-platform.Tpo $(DEPDIR)/test_link_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_link_linux-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_link_linux-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_link_linux-nm-fake-platform.Tpo -c -o test_link_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-nm-fake-platform.Tpo $(DEPDIR)/test_link_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_link_linux-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_link_linux-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_link_linux-nm-fake-platform.Tpo -c -o test_link_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-nm-fake-platform.Tpo $(DEPDIR)/test_link_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_link_linux-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_link_linux-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_link_linux-nm-linux-platform.Tpo -c -o test_link_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-nm-linux-platform.Tpo $(DEPDIR)/test_link_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_link_linux-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_link_linux-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_link_linux-nm-linux-platform.Tpo -c -o test_link_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-nm-linux-platform.Tpo $(DEPDIR)/test_link_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_link_linux-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_link_linux-test-link.o: test-link.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-test-link.o -MD -MP -MF $(DEPDIR)/test_link_linux-test-link.Tpo -c -o test_link_linux-test-link.o `test -f 'test-link.c' || echo '$(srcdir)/'`test-link.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-test-link.Tpo $(DEPDIR)/test_link_linux-test-link.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-link.c' object='test_link_linux-test-link.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-test-link.o `test -f 'test-link.c' || echo '$(srcdir)/'`test-link.c - -test_link_linux-test-link.obj: test-link.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_link_linux-test-link.obj -MD -MP -MF $(DEPDIR)/test_link_linux-test-link.Tpo -c -o test_link_linux-test-link.obj `if test -f 'test-link.c'; then $(CYGPATH_W) 'test-link.c'; else $(CYGPATH_W) '$(srcdir)/test-link.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_link_linux-test-link.Tpo $(DEPDIR)/test_link_linux-test-link.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-link.c' object='test_link_linux-test-link.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_link_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_link_linux-test-link.obj `if test -f 'test-link.c'; then $(CYGPATH_W) 'test-link.c'; else $(CYGPATH_W) '$(srcdir)/test-link.c'; fi` - -test_route_fake-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-test-common.o -MD -MP -MF $(DEPDIR)/test_route_fake-test-common.Tpo -c -o test_route_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-test-common.Tpo $(DEPDIR)/test_route_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_route_fake-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_route_fake-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-test-common.obj -MD -MP -MF $(DEPDIR)/test_route_fake-test-common.Tpo -c -o test_route_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-test-common.Tpo $(DEPDIR)/test_route_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_route_fake-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_route_fake-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-nm-platform.o -MD -MP -MF $(DEPDIR)/test_route_fake-nm-platform.Tpo -c -o test_route_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-nm-platform.Tpo $(DEPDIR)/test_route_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_route_fake-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_route_fake-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_route_fake-nm-platform.Tpo -c -o test_route_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-nm-platform.Tpo $(DEPDIR)/test_route_fake-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_route_fake-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_route_fake-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_route_fake-nm-fake-platform.Tpo -c -o test_route_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-nm-fake-platform.Tpo $(DEPDIR)/test_route_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_route_fake-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_route_fake-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_route_fake-nm-fake-platform.Tpo -c -o test_route_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-nm-fake-platform.Tpo $(DEPDIR)/test_route_fake-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_route_fake-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_route_fake-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_route_fake-nm-linux-platform.Tpo -c -o test_route_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-nm-linux-platform.Tpo $(DEPDIR)/test_route_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_route_fake-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_route_fake-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_route_fake-nm-linux-platform.Tpo -c -o test_route_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-nm-linux-platform.Tpo $(DEPDIR)/test_route_fake-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_route_fake-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_route_fake-test-route.o: test-route.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-test-route.o -MD -MP -MF $(DEPDIR)/test_route_fake-test-route.Tpo -c -o test_route_fake-test-route.o `test -f 'test-route.c' || echo '$(srcdir)/'`test-route.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-test-route.Tpo $(DEPDIR)/test_route_fake-test-route.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route.c' object='test_route_fake-test-route.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-test-route.o `test -f 'test-route.c' || echo '$(srcdir)/'`test-route.c - -test_route_fake-test-route.obj: test-route.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_fake-test-route.obj -MD -MP -MF $(DEPDIR)/test_route_fake-test-route.Tpo -c -o test_route_fake-test-route.obj `if test -f 'test-route.c'; then $(CYGPATH_W) 'test-route.c'; else $(CYGPATH_W) '$(srcdir)/test-route.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_fake-test-route.Tpo $(DEPDIR)/test_route_fake-test-route.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route.c' object='test_route_fake-test-route.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_fake-test-route.obj `if test -f 'test-route.c'; then $(CYGPATH_W) 'test-route.c'; else $(CYGPATH_W) '$(srcdir)/test-route.c'; fi` - -test_route_linux-test-common.o: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-test-common.o -MD -MP -MF $(DEPDIR)/test_route_linux-test-common.Tpo -c -o test_route_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-test-common.Tpo $(DEPDIR)/test_route_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_route_linux-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-test-common.o `test -f 'test-common.c' || echo '$(srcdir)/'`test-common.c - -test_route_linux-test-common.obj: test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-test-common.obj -MD -MP -MF $(DEPDIR)/test_route_linux-test-common.Tpo -c -o test_route_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-test-common.Tpo $(DEPDIR)/test_route_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-common.c' object='test_route_linux-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-test-common.obj `if test -f 'test-common.c'; then $(CYGPATH_W) 'test-common.c'; else $(CYGPATH_W) '$(srcdir)/test-common.c'; fi` - -test_route_linux-nm-platform.o: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-nm-platform.o -MD -MP -MF $(DEPDIR)/test_route_linux-nm-platform.Tpo -c -o test_route_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-nm-platform.Tpo $(DEPDIR)/test_route_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_route_linux-nm-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-nm-platform.o `test -f '../nm-platform.c' || echo '$(srcdir)/'`../nm-platform.c - -test_route_linux-nm-platform.obj: ../nm-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-nm-platform.obj -MD -MP -MF $(DEPDIR)/test_route_linux-nm-platform.Tpo -c -o test_route_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-nm-platform.Tpo $(DEPDIR)/test_route_linux-nm-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-platform.c' object='test_route_linux-nm-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-nm-platform.obj `if test -f '../nm-platform.c'; then $(CYGPATH_W) '../nm-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-platform.c'; fi` - -test_route_linux-nm-fake-platform.o: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-nm-fake-platform.o -MD -MP -MF $(DEPDIR)/test_route_linux-nm-fake-platform.Tpo -c -o test_route_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-nm-fake-platform.Tpo $(DEPDIR)/test_route_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_route_linux-nm-fake-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-nm-fake-platform.o `test -f '../nm-fake-platform.c' || echo '$(srcdir)/'`../nm-fake-platform.c - -test_route_linux-nm-fake-platform.obj: ../nm-fake-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-nm-fake-platform.obj -MD -MP -MF $(DEPDIR)/test_route_linux-nm-fake-platform.Tpo -c -o test_route_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-nm-fake-platform.Tpo $(DEPDIR)/test_route_linux-nm-fake-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-fake-platform.c' object='test_route_linux-nm-fake-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-nm-fake-platform.obj `if test -f '../nm-fake-platform.c'; then $(CYGPATH_W) '../nm-fake-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-fake-platform.c'; fi` - -test_route_linux-nm-linux-platform.o: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-nm-linux-platform.o -MD -MP -MF $(DEPDIR)/test_route_linux-nm-linux-platform.Tpo -c -o test_route_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-nm-linux-platform.Tpo $(DEPDIR)/test_route_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_route_linux-nm-linux-platform.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-nm-linux-platform.o `test -f '../nm-linux-platform.c' || echo '$(srcdir)/'`../nm-linux-platform.c - -test_route_linux-nm-linux-platform.obj: ../nm-linux-platform.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-nm-linux-platform.obj -MD -MP -MF $(DEPDIR)/test_route_linux-nm-linux-platform.Tpo -c -o test_route_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-nm-linux-platform.Tpo $(DEPDIR)/test_route_linux-nm-linux-platform.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../nm-linux-platform.c' object='test_route_linux-nm-linux-platform.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-nm-linux-platform.obj `if test -f '../nm-linux-platform.c'; then $(CYGPATH_W) '../nm-linux-platform.c'; else $(CYGPATH_W) '$(srcdir)/../nm-linux-platform.c'; fi` - -test_route_linux-test-route.o: test-route.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-test-route.o -MD -MP -MF $(DEPDIR)/test_route_linux-test-route.Tpo -c -o test_route_linux-test-route.o `test -f 'test-route.c' || echo '$(srcdir)/'`test-route.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-test-route.Tpo $(DEPDIR)/test_route_linux-test-route.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route.c' object='test_route_linux-test-route.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-test-route.o `test -f 'test-route.c' || echo '$(srcdir)/'`test-route.c - -test_route_linux-test-route.obj: test-route.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_linux-test-route.obj -MD -MP -MF $(DEPDIR)/test_route_linux-test-route.Tpo -c -o test_route_linux-test-route.obj `if test -f 'test-route.c'; then $(CYGPATH_W) 'test-route.c'; else $(CYGPATH_W) '$(srcdir)/test-route.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_linux-test-route.Tpo $(DEPDIR)/test_route_linux-test-route.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route.c' object='test_route_linux-test-route.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_linux-test-route.obj `if test -f 'test-route.c'; then $(CYGPATH_W) 'test-route.c'; else $(CYGPATH_W) '$(srcdir)/test-route.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-address-fake.log: test-address-fake$(EXEEXT) - @p='test-address-fake$(EXEEXT)'; \ - b='test-address-fake'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-address-linux.log: test-address-linux$(EXEEXT) - @p='test-address-linux$(EXEEXT)'; \ - b='test-address-linux'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-cleanup-fake.log: test-cleanup-fake$(EXEEXT) - @p='test-cleanup-fake$(EXEEXT)'; \ - b='test-cleanup-fake'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-cleanup-linux.log: test-cleanup-linux$(EXEEXT) - @p='test-cleanup-linux$(EXEEXT)'; \ - b='test-cleanup-linux'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-general.log: test-general$(EXEEXT) - @p='test-general$(EXEEXT)'; \ - b='test-general'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-link-fake.log: test-link-fake$(EXEEXT) - @p='test-link-fake$(EXEEXT)'; \ - b='test-link-fake'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-link-linux.log: test-link-linux$(EXEEXT) - @p='test-link-linux$(EXEEXT)'; \ - b='test-link-linux'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-nmp-object.log: test-nmp-object$(EXEEXT) - @p='test-nmp-object$(EXEEXT)'; \ - b='test-nmp-object'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-route-fake.log: test-route-fake$(EXEEXT) - @p='test-route-fake$(EXEEXT)'; \ - b='test-route-fake'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-route-linux.log: test-route-linux$(EXEEXT) - @p='test-route-linux$(EXEEXT)'; \ - b='test-route-linux'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/platform/tests/monitor.c b/src/platform/tests/monitor.c index 937eea11..d0c58aeb 100644 --- a/src/platform/tests/monitor.c +++ b/src/platform/tests/monitor.c @@ -23,7 +23,7 @@ #include #include -#include "nm-linux-platform.h" +#include "platform/nm-linux-platform.h" #include "nm-test-utils-core.h" diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index 05a14448..4c139ef0 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -354,6 +354,8 @@ test_ip4_address_peer_zero (void) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index 3b52487a..4ac49298 100644 --- a/src/platform/tests/test-cleanup.c +++ b/src/platform/tests/test-cleanup.c @@ -106,6 +106,8 @@ test_cleanup_internal (void) g_array_unref (routes6); } +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index d636ebeb..0e42a727 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -32,12 +32,18 @@ /*****************************************************************************/ +void +nmtstp_setup_platform (void) +{ + g_assert (_nmtstp_setup_platform_func); + _nmtstp_setup_platform_func (); +} + gboolean nmtstp_is_root_test (void) { - NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare") - return (SETUP == nm_linux_platform_setup); - NM_PRAGMA_WARNING_REENABLE + g_assert (_nmtstp_setup_platform_func); + return _nmtstp_setup_platform_func == nm_linux_platform_setup; } gboolean @@ -143,12 +149,15 @@ _free_signal (const char *file, int line, const char *func, SignalData *data) } void -link_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, NMPlatformLink *received, NMPlatformSignalChangeType change_type, SignalData *data) +link_callback (NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *received, int change_type_i, SignalData *data) { + const NMPObjectType obj_type = obj_type_i; + const NMPlatformSignalChangeType change_type = change_type_i; GArray *links; NMPlatformLink *cached; int i; + g_assert_cmpint (obj_type, ==, NMP_OBJECT_TYPE_LINK); g_assert (received); g_assert_cmpint (received->ifindex, ==, ifindex); g_assert (data && data->name); @@ -217,7 +226,7 @@ nmtstp_ip4_route_exists (const char *ifname, guint32 network, int plen, guint32 gs_free_error GError *error = NULL; gs_free char *metric_pattern = NULL; - g_assert (ifname && nm_utils_iface_valid_name (ifname)); + g_assert (ifname && nm_utils_is_valid_iface_name (ifname, NULL)); g_assert (!strstr (ifname, " metric ")); g_assert (plen >= 0 && plen <= 32); @@ -335,10 +344,10 @@ typedef struct { static void _wait_for_signal_cb (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, NMPlatformLink *plink, - NMPlatformSignalChangeType change_type, + int change_type_i, gpointer user_data) { WaitForSignalData *data = user_data; @@ -508,7 +517,7 @@ nmtstp_ip_address_check_lifetime (const NMPlatformIPAddress *addr, g_assert (expected_preferred <= expected_lifetime); if ( expected_lifetime == NM_PLATFORM_LIFETIME_PERMANENT - && expected_lifetime == NM_PLATFORM_LIFETIME_PERMANENT) { + && expected_preferred == NM_PLATFORM_LIFETIME_PERMANENT) { return addr->timestamp == 0 && addr->lifetime == NM_PLATFORM_LIFETIME_PERMANENT && addr->preferred == NM_PLATFORM_LIFETIME_PERMANENT; @@ -554,7 +563,7 @@ nmtstp_ip_address_assert_lifetime (const NMPlatformIPAddress *addr, g_assert (expected_preferred <= expected_lifetime); if ( expected_lifetime == NM_PLATFORM_LIFETIME_PERMANENT - && expected_lifetime == NM_PLATFORM_LIFETIME_PERMANENT) { + && expected_preferred == NM_PLATFORM_LIFETIME_PERMANENT) { g_assert_cmpint (addr->timestamp, ==, 0); g_assert_cmpint (addr->lifetime, ==, NM_PLATFORM_LIFETIME_PERMANENT); g_assert_cmpint (addr->preferred, ==, NM_PLATFORM_LIFETIME_PERMANENT); @@ -924,7 +933,7 @@ nmtstp_link_dummy_add (NMPlatform *platform, const NMPlatformLink *pllink = NULL; gboolean success; - g_assert (nm_utils_iface_valid_name (name)); + g_assert (nm_utils_is_valid_iface_name (name, NULL)); external_command = nmtstp_run_command_check_external (external_command); @@ -953,7 +962,7 @@ nmtstp_link_gre_add (NMPlatform *platform, gboolean success; char buffer[INET_ADDRSTRLEN]; - g_assert (nm_utils_iface_valid_name (name)); + g_assert (nm_utils_is_valid_iface_name (name, NULL)); external_command = nmtstp_run_command_check_external (external_command); @@ -993,7 +1002,7 @@ nmtstp_link_ip6tnl_add (NMPlatform *platform, gboolean success; char buffer[INET6_ADDRSTRLEN]; - g_assert (nm_utils_iface_valid_name (name)); + g_assert (nm_utils_is_valid_iface_name (name, NULL)); external_command = nmtstp_run_command_check_external (external_command); @@ -1047,7 +1056,7 @@ nmtstp_link_ipip_add (NMPlatform *platform, gboolean success; char buffer[INET_ADDRSTRLEN]; - g_assert (nm_utils_iface_valid_name (name)); + g_assert (nm_utils_is_valid_iface_name (name, NULL)); external_command = nmtstp_run_command_check_external (external_command); @@ -1088,7 +1097,7 @@ nmtstp_link_macvlan_add (NMPlatform *platform, gboolean success; NMLinkType link_type; - g_assert (nm_utils_iface_valid_name (name)); + g_assert (nm_utils_is_valid_iface_name (name, NULL)); external_command = nmtstp_run_command_check_external (external_command); @@ -1135,7 +1144,7 @@ nmtstp_link_sit_add (NMPlatform *platform, gboolean success; char buffer[INET_ADDRSTRLEN]; - g_assert (nm_utils_iface_valid_name (name)); + g_assert (nm_utils_is_valid_iface_name (name, NULL)); external_command = nmtstp_run_command_check_external (external_command); @@ -1180,7 +1189,7 @@ nmtstp_link_vxlan_add (NMPlatform *platform, NMPlatformError plerr; int err; - g_assert (nm_utils_iface_valid_name (name)); + g_assert (nm_utils_is_valid_iface_name (name, NULL)); external_command = nmtstp_run_command_check_external (external_command); @@ -1264,7 +1273,7 @@ nmtstp_link_get_typed (NMPlatform *platform, g_assert_cmpstr (name, ==, pllink->name); } - g_assert (!name || nm_utils_iface_valid_name (name)); + g_assert (!name || nm_utils_is_valid_iface_name (name, NULL)); if (pllink && link_type != NM_LINK_TYPE_NONE) g_assert_cmpint (pllink->type, ==, link_type); @@ -1545,6 +1554,25 @@ nmtstp_namespace_get_fd_for_process (pid_t pid, const char *ns_name) /*****************************************************************************/ +void +nmtstp_netns_select_random (NMPlatform **platforms, gsize n_platforms, NMPNetns **netns) +{ + int i; + + g_assert (platforms); + g_assert (n_platforms && n_platforms <= G_MAXINT32); + g_assert (netns && !*netns); + for (i = 0; i < n_platforms; i++) + g_assert (NM_IS_PLATFORM (platforms[i])); + + i = nmtst_get_rand_int () % (n_platforms + 1); + if (i == 0) + return; + g_assert (nm_platform_netns_push (platforms[i - 1], netns)); +} + +/*****************************************************************************/ + NMTST_DEFINE(); static gboolean @@ -1620,36 +1648,50 @@ main (int argc, char **argv) g_error ("unshare(CLONE_NEWNET|CLONE_NEWNS) failed with %s (%d)", strerror (errsv), errsv); } - /* Mount our /sys instance, so that gudev sees only our devices. - * Needs to be read-only, because we don't run udev. */ + /* Below we need a read-only /sys (to signal that we're in an environment + * we don't have udev and writable /sys/devices so that we still are able + * to test device classes that modify the device attributes (such as bridges). + * + * We use two sysfs instances to achieve this, binding the /device subtree + * of the writeable one to the read-only one. + * + * We abuse a /sys/kernel/debug for our temporary writable sysfs mount, + * just because it's guarranteed to exist and mounts are allowed there even + * after the sysfs mount point hardening [linux 0cbee99269]. It's just in + * our mount namespace, we release it quickly and don't need debugfs anyway... + * An alrernative would be to create a temporary directory, but that seems + * like an overkill. */ + + /* Make the mounts below /sys private to our namespace. Other mounts + * wouldn't be permitted for good reasons. */ mount (NULL, "/sys", "sysfs", MS_SLAVE, NULL); + + /* Mount the read-only sysfs. */ if (mount ("sys", "/sys", "sysfs", MS_RDONLY, NULL) != 0) { errsv = errno; g_error ("mount(\"/sys\") failed with %s (%d)", strerror (errsv), errsv); } - /* Create a writable /sys/devices tree. This makes it possible to run tests - * that modify values via sysfs (such as bridge forward delay). */ - if (mount ("sys", "/sys/devices", "sysfs", 0, NULL) != 0) { + /* Create the writable /sys/devices tree. */ + if (mount ("sys", "/sys/kernel/debug", "sysfs", 0, NULL) != 0) { errsv = errno; - g_error ("mount(\"/sys/devices\") failed with %s (%d)", strerror (errsv), errsv); + g_error ("mount(\"/sys/devices/k\") failed with %s (%d)", strerror (errsv), errsv); } - if (mount (NULL, "/sys/devices", "sysfs", MS_REMOUNT, NULL) != 0) { - /* Read-write remount failed. Never mind, we're probably just a root in - * our user NS. */ - if (umount ("/sys/devices") != 0) { - errsv = errno; - g_error ("umount(\"/sys/devices\") failed with %s (%d)", strerror (errsv), errsv); - } - } else { - if (mount ("/sys/devices/devices", "/sys/devices", "sysfs", MS_BIND, NULL) != 0) { - errsv = errno; - g_error ("mount(\"/sys\") failed with %s (%d)", strerror (errsv), errsv); - } + + /* Bind mound the writable device tree to the read-only sysfs. */ + if (mount ("/sys/kernel/debug/devices", "/sys/devices", "sysfs", MS_BIND, NULL) != 0) { + errsv = errno; + g_error ("mount(\"/sys\") failed with %s (%d)", strerror (errsv), errsv); + } + + /* Release the temporary mount now that we bound the /devices subtree. */ + if (umount ("/sys/kernel/debug") != 0) { + errsv = errno; + g_error ("umount(\"/sys/kernel/debug\") failed with %s (%d)", strerror (errsv), errsv); } } - SETUP (); + nmtstp_setup_platform (); _nmtstp_setup_tests (); diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h index 87fccee2..48a41de6 100644 --- a/src/platform/tests/test-common.h +++ b/src/platform/tests/test-common.h @@ -4,15 +4,15 @@ #include #include -#include "nm-platform.h" -#include "nm-fake-platform.h" -#include "nm-linux-platform.h" +#include "platform/nm-platform.h" +#include "platform/nm-fake-platform.h" +#include "platform/nm-linux-platform.h" #include "nm-test-utils-core.h" #define DEVICE_NAME "nm-test-device" -/*********************************************************************************************/ +/*****************************************************************************/ #define _NMLOG_PREFIX_NAME "platform-test" #define _NMLOG_DOMAIN LOGD_PLATFORM @@ -35,12 +35,12 @@ } \ } G_STMT_END -/*********************************************************************************************/ +/*****************************************************************************/ gboolean nmtstp_is_root_test (void); gboolean nmtstp_is_sysfs_writable (void); -/******************************************************************************/ +/*****************************************************************************/ typedef struct _NMTstpNamespaceHandle NMTstpNamespaceHandle; @@ -51,7 +51,11 @@ pid_t nmtstp_namespace_handle_get_pid (NMTstpNamespaceHandle *handle); int nmtstp_namespace_get_fd_for_process (pid_t pid, const char *ns_name); -/******************************************************************************/ +/*****************************************************************************/ + +void nmtstp_netns_select_random (NMPlatform **platforms, gsize n_platforms, NMPNetns **netns); + +/*****************************************************************************/ typedef struct { gulong handler_id; @@ -80,7 +84,7 @@ void _free_signal (const char *file, int line, const char *func, SignalData *dat #define ensure_no_signal(data) _ensure_no_signal(__FILE__, __LINE__, G_STRFUNC, data) #define free_signal(data) _free_signal(__FILE__, __LINE__, G_STRFUNC, data) -void link_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, NMPlatformLink *received, NMPlatformSignalChangeType change_type, SignalData *data); +void link_callback (NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *received, int change_type_i, SignalData *data); /*****************************************************************************/ @@ -207,8 +211,12 @@ void nmtstp_link_del (NMPlatform *platform, int ifindex, const char *name); +typedef void (*NMTstpSetupFunc) (void); +extern NMTstpSetupFunc const _nmtstp_setup_platform_func; + +void nmtstp_setup_platform (void); + /*****************************************************************************/ void _nmtstp_init_tests (int *argc, char ***argv); void _nmtstp_setup_tests (void); - diff --git a/src/platform/tests/test-general.c b/src/platform/tests/test-general.c index f67f0089..658aad26 100644 --- a/src/platform/tests/test-general.c +++ b/src/platform/tests/test-general.c @@ -22,13 +22,13 @@ #include -#include "nm-platform-utils.h" -#include "nm-linux-platform.h" +#include "platform/nm-platform-utils.h" +#include "platform/nm-linux-platform.h" #include "nm-test-utils-core.h" -/******************************************************************/ +/*****************************************************************************/ static void test_init_linux_platform (void) @@ -38,7 +38,7 @@ test_init_linux_platform (void) platform = nm_linux_platform_new (NM_PLATFORM_NETNS_SUPPORT_DEFAULT); } -/******************************************************************/ +/*****************************************************************************/ static void test_link_get_all (void) @@ -51,7 +51,7 @@ test_link_get_all (void) links = nm_platform_link_get_all (platform); } -/******************************************************************/ +/*****************************************************************************/ NMTST_DEFINE (); diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index e242a71f..c2b3de13 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -25,9 +25,9 @@ #include #include -#include "nmp-object.h" -#include "nmp-netns.h" -#include "nm-platform-utils.h" +#include "platform/nmp-object.h" +#include "platform/nmp-netns.h" +#include "platform/nm-platform-utils.h" #include "test-common.h" #include "nm-test-utils-core.h" @@ -143,7 +143,7 @@ software_add (NMLinkType link_type, const char *name) /* when NM is running in the background, it will mess with addrgenmode which might cause additional signals. */ accept_signals (parent_changed, 0, 1); } else - accept_signal (parent_changed); + accept_signals (parent_changed, 1, 2); free_signal (parent_changed); return nm_platform_link_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS; @@ -157,12 +157,15 @@ software_add (NMLinkType link_type, const char *name) static void test_link_changed_signal_cb (NMPlatform *platform, - NMPObjectType obj_type, + int obj_type_i, int ifindex, const NMPlatformIP4Route *route, - NMPlatformSignalChangeType change_type, + int change_type_i, gboolean *p_test_link_changed_signal_arg) { + const NMPObjectType obj_type = obj_type_i; + const NMPlatformSignalChangeType change_type = change_type_i; + /* test invocation of platform signals with multiple listeners * connected to the signal. Platform signals have enum-typed * arguments and there seem to be an issue with invoking such @@ -315,7 +318,7 @@ test_slave (int master, int type, SignalData *master_changed) g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); if (link_changed->received_count > 0) { accept_signals (link_added, 0, 1); - accept_signals (link_changed, 1, 3); + accept_signals (link_changed, 1, 5); accept_signals (link_removed, 0, 1); } else { /* Due to https://bugzilla.redhat.com/show_bug.cgi?id=1285719 , kernel might send a @@ -395,26 +398,28 @@ test_software (NMLinkType link_type, const char *link_typename) accept_signal (link_changed); /* Set master option */ - switch (link_type) { - case NM_LINK_TYPE_BRIDGE: - if (nmtstp_is_sysfs_writable ()) { - g_assert (nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "628")); - value = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay"); - g_assert_cmpstr (value, ==, "628"); - g_free (value); - } - break; - case NM_LINK_TYPE_BOND: - if (nmtstp_is_sysfs_writable ()) { - g_assert (nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup")); - value = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, "mode"); - /* When reading back, the output looks slightly different. */ - g_assert (g_str_has_prefix (value, "active-backup")); - g_free (value); + if (nmtstp_is_root_test ()) { + switch (link_type) { + case NM_LINK_TYPE_BRIDGE: + if (nmtstp_is_sysfs_writable ()) { + g_assert (nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "628")); + value = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay"); + g_assert_cmpstr (value, ==, "628"); + g_free (value); + } + break; + case NM_LINK_TYPE_BOND: + if (nmtstp_is_sysfs_writable ()) { + g_assert (nm_platform_sysctl_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup")); + value = nm_platform_sysctl_master_get_option (NM_PLATFORM_GET, ifindex, "mode"); + /* When reading back, the output looks slightly different. */ + g_assert (g_str_has_prefix (value, "active-backup")); + g_free (value); + } + break; + default: + break; } - break; - default: - break; } /* Enslave and release */ @@ -1870,7 +1875,7 @@ again: nmtstp_link_del (NULL, -1, ifindex_dummy0, IFACE_DUMMY0); } -/******************************************************************/ +/*****************************************************************************/ static void _test_netns_setup (gpointer fixture, gconstpointer test_data) @@ -1883,8 +1888,7 @@ _test_netns_setup (gpointer fixture, gconstpointer test_data) static void _test_netns_teardown (gpointer fixture, gconstpointer test_data) { - /* re-create platform instance */ - SETUP (); + nmtstp_setup_platform (); } static NMPlatform * @@ -1933,13 +1937,13 @@ _test_netns_check_skip (void) return FALSE; } -/******************************************************************/ +/*****************************************************************************/ #define _sysctl_assert_eq(plat, path, value) \ G_STMT_START { \ gs_free char *_val = NULL; \ \ - _val = nm_platform_sysctl_get (plat, path); \ + _val = nm_platform_sysctl_get (plat, NMP_SYSCTL_PATHID_ABSOLUTE (path)); \ g_assert_cmpstr (_val, ==, value); \ } G_STMT_END @@ -1952,6 +1956,7 @@ test_netns_general (gpointer fixture, gconstpointer test_data) char sbuf[100]; int i, j, k; gboolean ethtool_support; + NMPUtilsEthtoolDriverInfo driver_info; if (_test_netns_check_skip ()) return; @@ -2011,7 +2016,7 @@ test_netns_general (gpointer fixture, gconstpointer test_data) else path = "/proc/sys/net/ipv6/conf/dummy2b/disable_ipv6"; } - g_assert (nm_platform_sysctl_set (pl, path, nm_sprintf_buf (sbuf, "%d", j))); + g_assert (nm_platform_sysctl_set (pl, NMP_SYSCTL_PATHID_ABSOLUTE (path), nm_sprintf_buf (sbuf, "%d", j))); _sysctl_assert_eq (pl, path, nm_sprintf_buf (sbuf, "%d", j)); } @@ -2022,9 +2027,8 @@ test_netns_general (gpointer fixture, gconstpointer test_data) * skip asserts that are known to fail. */ ethtool_support = nmtstp_run_command ("ethtool -i dummy1_ > /dev/null") == 0; if (ethtool_support) { - g_assert ( nmp_utils_ethtool_get_driver_info ("dummy1_", NULL, NULL, NULL)); - g_assert ( nmp_utils_ethtool_get_driver_info ("dummy2a", NULL, NULL, NULL)); - g_assert (!nmp_utils_ethtool_get_driver_info ("dummy2b", NULL, NULL, NULL)); + g_assert (nmp_utils_ethtool_get_driver_info (nmtstp_link_get_typed (platform_1, 0, "dummy1_", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); + g_assert (nmp_utils_ethtool_get_driver_info (nmtstp_link_get_typed (platform_1, 0, "dummy2a", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); g_assert_cmpint (nmtstp_run_command ("ethtool -i dummy1_ > /dev/null"), ==, 0); g_assert_cmpint (nmtstp_run_command ("ethtool -i dummy2a > /dev/null"), ==, 0); g_assert_cmpint (nmtstp_run_command ("ethtool -i dummy2b 2> /dev/null"), !=, 0); @@ -2033,9 +2037,8 @@ test_netns_general (gpointer fixture, gconstpointer test_data) g_assert (nm_platform_netns_push (platform_2, &netns_tmp)); if (ethtool_support) { - g_assert ( nmp_utils_ethtool_get_driver_info ("dummy1_", NULL, NULL, NULL)); - g_assert (!nmp_utils_ethtool_get_driver_info ("dummy2a", NULL, NULL, NULL)); - g_assert ( nmp_utils_ethtool_get_driver_info ("dummy2b", NULL, NULL, NULL)); + g_assert (nmp_utils_ethtool_get_driver_info (nmtstp_link_get_typed (platform_2, 0, "dummy1_", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); + g_assert (nmp_utils_ethtool_get_driver_info (nmtstp_link_get_typed (platform_2, 0, "dummy2b", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); g_assert_cmpint (nmtstp_run_command ("ethtool -i dummy1_ > /dev/null"), ==, 0); g_assert_cmpint (nmtstp_run_command ("ethtool -i dummy2a 2> /dev/null"), !=, 0); g_assert_cmpint (nmtstp_run_command ("ethtool -i dummy2b > /dev/null"), ==, 0); @@ -2054,7 +2057,6 @@ test_netns_set_netns (gpointer fixture, gconstpointer test_data) gs_unref_object NMPlatform *platform_1 = NULL; gs_unref_object NMPlatform *platform_2 = NULL; nm_auto_pop_netns NMPNetns *netns_pop = NULL; - int i; if (_test_netns_check_skip ()) return; @@ -2063,9 +2065,7 @@ test_netns_set_netns (gpointer fixture, gconstpointer test_data) platforms[1] = platform_1 = _test_netns_create_platform (); platforms[2] = platform_2 = _test_netns_create_platform (); - i = nmtst_get_rand_int () % 4; - if (i != 3) - g_assert (nm_platform_netns_push (platforms[i], &netns_pop)); + nmtstp_netns_select_random (platforms, G_N_ELEMENTS (platforms), &netns_pop); #define LINK_MOVE_NAME "link-move" g_assert (!nm_platform_link_get_by_ifname (platform_1, LINK_MOVE_NAME)); @@ -2185,7 +2185,7 @@ test_netns_push (gpointer fixture, gconstpointer test_data) _ADD_DUMMY (pl[i].platform, pl[i].device_name); - g_assert (nm_platform_sysctl_set (pl[i].platform, pl[i].sysctl_path, pl[i].sysctl_value)); + g_assert (nm_platform_sysctl_set (pl[i].platform, NMP_SYSCTL_PATHID_ABSOLUTE (pl[i].sysctl_path), pl[i].sysctl_value)); tmp = _get_current_namespace_id (CLONE_NEWNET); g_ptr_array_add (device_names, tmp); @@ -2292,9 +2292,7 @@ test_netns_bind_to_path (gpointer fixture, gconstpointer test_data) platforms[1] = platform_1 = _test_netns_create_platform (); platforms[2] = platform_2 = _test_netns_create_platform (); - i = nmtst_get_rand_int () % 4; - if (i != 3) - g_assert (nm_platform_netns_push (platforms[i], &netns_pop)); + nmtstp_netns_select_random (platforms, G_N_ELEMENTS (platforms), &netns_pop); g_assert_cmpint (mount ("tmpfs", P_VAR_RUN, "tmpfs", MS_NOATIME | MS_NODEV | MS_NOSUID, "mode=0755,size=32K"), ==, 0); g_assert_cmpint (mkdir (P_VAR_RUN_NETNS, 755), ==, 0); @@ -2323,6 +2321,175 @@ test_netns_bind_to_path (gpointer fixture, gconstpointer test_data) /*****************************************************************************/ +static void +test_sysctl_rename (void) +{ + NMPlatform *const PL = NM_PLATFORM_GET; + const char *const IFNAME[3] = { + "nm-dummy-0", + "nm-dummy-1", + "nm-dummy-2", + }; + int ifindex[G_N_ELEMENTS (IFNAME)] = { 0 }; + nm_auto_close int dirfd = -1; + int i; + char ifname_buf[IFNAMSIZ]; + char *s; + const NMPlatformLink *pllink; + + ifindex[0] = nmtstp_link_dummy_add (PL, -1, IFNAME[0])->ifindex; + ifindex[1] = nmtstp_link_dummy_add (PL, -1, IFNAME[1])->ifindex; + + s = (nmtst_get_rand_int () % 2) ? NULL : ifname_buf; + + if (nmtst_get_rand_int () % 2) { + /* bring the platform cache out of sync */ + nmtstp_run_command_check ("ip link set %s name %s", IFNAME[0], IFNAME[2]); + nm_platform_process_events (PL); + nmtstp_run_command_check ("ip link set %s name %s", IFNAME[2], IFNAME[0]); + + pllink = nm_platform_link_get_by_ifname (PL, IFNAME[2]); + g_assert (pllink && pllink->ifindex == ifindex[0]); + pllink = nm_platform_link_get_by_ifname (PL, IFNAME[0]); + g_assert (!pllink); + } + + /* open dirfd for IFNAME[0] */ + i = nmtst_get_rand_int () % (2 + G_N_ELEMENTS (IFNAME)); + if (i == 0) { + dirfd = nm_platform_sysctl_open_netdir (PL, + ifindex[0], + s); + } else { + const char *ifname_guess; + + /* provide a wrong or no guess. */ + ifname_guess = i == 1 ? NULL : IFNAME[i - 2]; + dirfd = nmp_utils_sysctl_open_netdir (ifindex[0], + ifname_guess, + s); + } + g_assert (dirfd >= 0); + if (s) + g_assert_cmpstr (s, ==, IFNAME[0]); + + /* possibly rename the interfaces. */ + switch (nmtst_get_rand_int () % 4) { + case 0: + break; + case 1: + nmtstp_run_command_check ("ip link set %s name %s", IFNAME[0], IFNAME[2]); + break; + case 2: + nmtstp_run_command_check ("ip link set %s name %s", IFNAME[0], IFNAME[2]); + nmtstp_run_command_check ("ip link set %s name %s", IFNAME[1], IFNAME[0]); + break; + } + + /* possibly, resync platform cache (should make no difference). */ + if (nmtst_get_rand_int () % 2) + nm_platform_process_events (PL); + + /* check that we still read the same file. */ + switch (nmtst_get_rand_int () % 2) { + case 0: { + gs_free char *c = NULL; + + if (nm_utils_file_get_contents (dirfd, "ifindex", 1*1024*1024, &c, NULL, NULL) < 0) + g_assert_not_reached(); + g_assert_cmpint (ifindex[0], ==, (int) _nm_utils_ascii_str_to_int64 (c, 10, 0, G_MAXINT, -1)); + break; + } + case 1: { + g_assert_cmpint (ifindex[0], ==, (gint32) nm_platform_sysctl_get_int32 (PL, NMP_SYSCTL_PATHID_NETDIR (dirfd, s ?: "", "ifindex"), -1)); + break; + } + default: + g_assert_not_reached (); + } + + nm_platform_process_events (PL); + nmtstp_link_del (PL, -1, ifindex[0], NULL); + nmtstp_link_del (PL, -1, ifindex[1], NULL); +} + +/*****************************************************************************/ + +static void +test_sysctl_netns_switch (void) +{ + const char *const IFNAME = "nm-dummy-0"; + int ifindex, ifindex_tmp; + nm_auto_close int dirfd = -1; + char ifname_buf[IFNAMSIZ]; + char *s; + gs_unref_object NMPlatform *platform_0 = NULL; + gs_unref_object NMPlatform *platform_1 = NULL; + gs_unref_object NMPlatform *platform_2 = NULL; + nm_auto_pop_netns NMPNetns *netns_pop_1 = NULL; + nm_auto_pop_netns NMPNetns *netns_pop_2 = NULL; + nm_auto_pop_netns NMPNetns *netns_pop_3 = NULL; + NMPlatform *PL; + NMPlatform *platforms[3]; + + if (_test_netns_check_skip ()) + return; + + platforms[0] = platform_0 = nm_linux_platform_new (TRUE); + platforms[1] = platform_1 = _test_netns_create_platform (); + platforms[2] = platform_2 = _test_netns_create_platform (); + PL = platforms[nmtst_get_rand_int () % 3]; + + nmtstp_netns_select_random (platforms, G_N_ELEMENTS (platforms), &netns_pop_1); + + ifindex = nmtstp_link_dummy_add (PL, FALSE, IFNAME)->ifindex; + + nmtstp_netns_select_random (platforms, G_N_ELEMENTS (platforms), &netns_pop_2); + + s = (nmtst_get_rand_int () % 2) ? NULL : ifname_buf; + dirfd = nm_platform_sysctl_open_netdir (PL, + ifindex, + s); + g_assert (dirfd >= 0); + if (s) + g_assert_cmpstr (s, ==, IFNAME); + + nmtstp_netns_select_random (platforms, G_N_ELEMENTS (platforms), &netns_pop_3); + + /* even if we switch to other namespaces, we can still lookup the path correctly, + * either using dirfd or via the platform instance (which switches namespace as needed). */ + { + gs_free char *c = NULL; + + if (nm_utils_file_get_contents (dirfd, "ifindex", 0, &c, NULL, NULL) < 0) + g_assert_not_reached(); + g_assert_cmpint (ifindex, ==, (int) _nm_utils_ascii_str_to_int64 (c, 10, 0, G_MAXINT, -1)); + } + g_assert_cmpint (ifindex, ==, (gint32) nm_platform_sysctl_get_int32 (PL, NMP_SYSCTL_PATHID_NETDIR (dirfd, s ?: "", "ifindex"), -1)); + g_assert_cmpint (ifindex, ==, (gint32) nm_platform_sysctl_get_int32 (PL, NMP_SYSCTL_PATHID_ABSOLUTE (nm_sprintf_bufa (100, "/sys/class/net/%s/ifindex", IFNAME)), -1)); + + /* accessing the path directly, only succeeds iff the current namespace happens to be the namespace + * in which we created the link. */ + { + gs_free char *c = NULL; + + if (nm_utils_file_get_contents (-1, nm_sprintf_bufa (100, "/sys/class/net/%s/ifindex", IFNAME), 0, &c, NULL, NULL) < 0) + ifindex_tmp = -1; + else + ifindex_tmp = _nm_utils_ascii_str_to_int64 (c, 10, 0, G_MAXINT, -2); + } + if (nmp_netns_get_current () == nm_platform_netns_get (PL)) + g_assert_cmpint (ifindex_tmp, ==, ifindex); + else + g_assert_cmpint (ifindex_tmp, ==, -1); + + nmtstp_link_del (PL, FALSE, ifindex, NULL); +} + +/*****************************************************************************/ + +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { @@ -2374,5 +2541,8 @@ _nmtstp_setup_tests (void) g_test_add_vtable ("/general/netns/set-netns", 0, NULL, _test_netns_setup, test_netns_set_netns, _test_netns_teardown); g_test_add_vtable ("/general/netns/push", 0, NULL, _test_netns_setup, test_netns_push, _test_netns_teardown); g_test_add_vtable ("/general/netns/bind-to-path", 0, NULL, _test_netns_setup, test_netns_bind_to_path, _test_netns_teardown); + + g_test_add_func ("/general/sysctl/rename", test_sysctl_rename); + g_test_add_func ("/general/sysctl/netns-switch", test_sysctl_netns_switch); } } diff --git a/src/platform/tests/test-nmp-object.c b/src/platform/tests/test-nmp-object.c index 9d4f69de..f7b209de 100644 --- a/src/platform/tests/test-nmp-object.c +++ b/src/platform/tests/test-nmp-object.c @@ -20,7 +20,7 @@ #include "nm-default.h" -#include "nmp-object.h" +#include "platform/nmp-object.h" #include "nm-test-utils-core.h" @@ -28,7 +28,7 @@ struct { GList *udev_devices; } global; -/******************************************************************/ +/*****************************************************************************/ static gboolean _nmp_object_id_equal (const NMPObject *a, const NMPObject *b) @@ -50,7 +50,7 @@ _nmp_object_equal (const NMPObject *a, const NMPObject *b) } #define nmp_object_equal _nmp_object_equal -/******************************************************************/ +/*****************************************************************************/ static void _assert_cache_multi_lookup_contains (const NMPCache *cache, const NMPCacheId *cache_id, const NMPObject *obj, gboolean contains) @@ -85,7 +85,7 @@ _assert_cache_multi_lookup_contains (const NMPCache *cache, const NMPCacheId *ca g_assert (!!contains == found); } -/******************************************************************/ +/*****************************************************************************/ typedef struct { NMPCache *cache; @@ -382,7 +382,7 @@ test_cache_link (void) nmp_cache_free (cache); } -/******************************************************************/ +/*****************************************************************************/ NMTST_DEFINE (); diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 360404e9..59a05bd4 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -23,15 +23,19 @@ #include #include "nm-core-utils.h" -#include "nm-platform-utils.h" +#include "platform/nm-platform-utils.h" #include "test-common.h" #define DEVICE_NAME "nm-test-device" static void -ip4_route_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, const NMPlatformIP4Route *received, NMPlatformSignalChangeType change_type, SignalData *data) +ip4_route_callback (NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformIP4Route *received, int change_type_i, SignalData *data) { + const NMPObjectType obj_type = obj_type_i; + const NMPlatformSignalChangeType change_type = change_type_i; + + g_assert_cmpint (obj_type, ==, NMP_OBJECT_TYPE_IP4_ROUTE); g_assert (received); g_assert_cmpint (received->ifindex, ==, ifindex); g_assert (data && data->name); @@ -50,8 +54,12 @@ ip4_route_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, c } static void -ip6_route_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, const NMPlatformIP6Route *received, NMPlatformSignalChangeType change_type, SignalData *data) +ip6_route_callback (NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformIP6Route *received, int change_type_i, SignalData *data) { + const NMPObjectType obj_type = obj_type_i; + const NMPlatformSignalChangeType change_type = change_type_i; + + g_assert_cmpint (obj_type, ==, NMP_OBJECT_TYPE_IP6_ROUTE); g_assert (received); g_assert_cmpint (received->ifindex, ==, ifindex); g_assert (data && data->name); @@ -328,6 +336,8 @@ test_ip4_zero_gateway (void) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c index 2e222eb8..ac51678f 100644 --- a/src/platform/wifi/wifi-utils-nl80211.c +++ b/src/platform/wifi/wifi-utils-nl80211.c @@ -34,7 +34,7 @@ #include "wifi-utils-private.h" #include "wifi-utils-nl80211.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-utils.h" diff --git a/src/platform/wifi/wifi-utils-wext.c b/src/platform/wifi/wifi-utils-wext.c index d4ed86eb..af8cf2de 100644 --- a/src/platform/wifi/wifi-utils-wext.c +++ b/src/platform/wifi/wifi-utils-wext.c @@ -31,7 +31,7 @@ #include "wifi-utils-private.h" #include "wifi-utils-wext.h" #include "nm-utils.h" -#include "nm-platform-utils.h" +#include "platform/nm-platform-utils.h" /* Hacks necessary to #include wireless.h; yay for WEXT */ #ifndef __user @@ -369,7 +369,7 @@ wifi_wext_get_qual (WifiData *data) return wext_qual_to_percent (&stats.qual, &wext->max_qual); } -/*********************/ +/*****************************************************************************/ /* OLPC Mesh-only functions */ static guint32 @@ -441,7 +441,7 @@ wifi_wext_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len) return FALSE; } -/*********************/ +/*****************************************************************************/ static gboolean wext_can_scan (WifiDataWext *wext) @@ -662,8 +662,15 @@ wifi_wext_is_wifi (const char *iface) struct iwreq iwr; gboolean is_wifi = FALSE; - if (!nmp_utils_device_exists (iface)) - return FALSE; + /* performing an ioctl on a non-existing name may cause the automatic + * loading of kernel modules, which should be avoided. + * + * Usually, we should thus make sure that an inteface with this name + * exists. + * + * Note that wifi_wext_is_wifi() has only one caller which just verified + * that an interface with this name exists. + */ fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (fd >= 0) { diff --git a/src/platform/wifi/wifi-utils.c b/src/platform/wifi/wifi-utils.c index 2ce6eb77..b8da02c1 100644 --- a/src/platform/wifi/wifi-utils.c +++ b/src/platform/wifi/wifi-utils.c @@ -56,7 +56,7 @@ wifi_data_free (WifiData *data) g_free (data); } -/***************************************************************/ +/*****************************************************************************/ WifiData * wifi_utils_init (const char *iface, int ifindex, gboolean check_scan) @@ -183,39 +183,19 @@ wifi_utils_deinit (WifiData *data) } gboolean -wifi_utils_is_wifi (int ifindex, const char *ifname) +wifi_utils_is_wifi (int dirfd, const char *ifname) { - int fd_sysnet; - int fd_phy80211; - char ifname_verified[IFNAMSIZ]; + g_return_val_if_fail (dirfd >= 0, FALSE); - g_return_val_if_fail (ifindex > 0, FALSE); - - fd_sysnet = nmp_utils_sysctl_open_netdir (ifindex, ifname, ifname_verified); - if (fd_sysnet < 0) - return FALSE; - - /* there might have been a race and ifname might be wrong. Below for checking - * wext, use the possibly improved name that we just verified. */ - ifname = ifname_verified; - - fd_phy80211 = openat (fd_sysnet, "phy80211", O_CLOEXEC); - close (fd_sysnet); - - if (fd_phy80211 >= 0) { - close (fd_phy80211); + if (faccessat (dirfd, "phy80211", F_OK, 0) == 0) return TRUE; - } - #if HAVE_WEXT if (wifi_wext_is_wifi (ifname)) return TRUE; #endif - return FALSE; } - /* OLPC Mesh-only functions */ guint32 diff --git a/src/platform/wifi/wifi-utils.h b/src/platform/wifi/wifi-utils.h index 3dca2ac1..4fd5a80b 100644 --- a/src/platform/wifi/wifi-utils.h +++ b/src/platform/wifi/wifi-utils.h @@ -28,7 +28,7 @@ typedef struct WifiData WifiData; -gboolean wifi_utils_is_wifi (int ifindex, const char *ifname); +gboolean wifi_utils_is_wifi (int dirfd, const char *ifname); WifiData *wifi_utils_init (const char *iface, int ifindex, gboolean check_scan); diff --git a/src/ppp-manager/Makefile.am b/src/ppp-manager/Makefile.am deleted file mode 100644 index 3026dab4..00000000 --- a/src/ppp-manager/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -if WITH_PPP - -AM_CPPFLAGS = \ - -I${top_srcdir}/shared \ - -I${top_builddir}/shared \ - -I${top_srcdir}/libnm-core \ - -I${top_srcdir}/src \ - -I${top_builddir}/libnm-core \ - -DG_LOG_DOMAIN=\""nm-pppd-plugin"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) - -pppd_plugindir = $(PPPD_PLUGIN_DIR) -pppd_plugin_LTLIBRARIES = nm-pppd-plugin.la - -nm_pppd_plugin_la_SOURCES = \ - nm-pppd-plugin.c \ - nm-pppd-plugin.h \ - nm-ppp-status.h - -nm_pppd_plugin_la_LDFLAGS = -module -avoid-version - -nm_pppd_plugin_la_LIBADD = \ - $(GLIB_LIBS) \ - $(DL_LIBS) \ - $(NULL) - -endif diff --git a/src/ppp-manager/Makefile.in b/src/ppp-manager/Makefile.in deleted file mode 100644 index 656bdd6c..00000000 --- a/src/ppp-manager/Makefile.in +++ /dev/null @@ -1,835 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/ppp-manager -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pppd_plugindir)" -LTLIBRARIES = $(pppd_plugin_LTLIBRARIES) -am__DEPENDENCIES_1 = -@WITH_PPP_TRUE@nm_pppd_plugin_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ -@WITH_PPP_TRUE@ $(am__DEPENDENCIES_1) -am__nm_pppd_plugin_la_SOURCES_DIST = nm-pppd-plugin.c nm-pppd-plugin.h \ - nm-ppp-status.h -@WITH_PPP_TRUE@am_nm_pppd_plugin_la_OBJECTS = nm-pppd-plugin.lo -nm_pppd_plugin_la_OBJECTS = $(am_nm_pppd_plugin_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -nm_pppd_plugin_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(nm_pppd_plugin_la_LDFLAGS) $(LDFLAGS) \ - -o $@ -@WITH_PPP_TRUE@am_nm_pppd_plugin_la_rpath = -rpath $(pppd_plugindir) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(nm_pppd_plugin_la_SOURCES) -DIST_SOURCES = $(am__nm_pppd_plugin_la_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@WITH_PPP_TRUE@AM_CPPFLAGS = \ -@WITH_PPP_TRUE@ -I${top_srcdir}/shared \ -@WITH_PPP_TRUE@ -I${top_builddir}/shared \ -@WITH_PPP_TRUE@ -I${top_srcdir}/libnm-core \ -@WITH_PPP_TRUE@ -I${top_srcdir}/src \ -@WITH_PPP_TRUE@ -I${top_builddir}/libnm-core \ -@WITH_PPP_TRUE@ -DG_LOG_DOMAIN=\""nm-pppd-plugin"\" \ -@WITH_PPP_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -@WITH_PPP_TRUE@ $(GLIB_CFLAGS) - -@WITH_PPP_TRUE@pppd_plugindir = $(PPPD_PLUGIN_DIR) -@WITH_PPP_TRUE@pppd_plugin_LTLIBRARIES = nm-pppd-plugin.la -@WITH_PPP_TRUE@nm_pppd_plugin_la_SOURCES = \ -@WITH_PPP_TRUE@ nm-pppd-plugin.c \ -@WITH_PPP_TRUE@ nm-pppd-plugin.h \ -@WITH_PPP_TRUE@ nm-ppp-status.h - -@WITH_PPP_TRUE@nm_pppd_plugin_la_LDFLAGS = -module -avoid-version -@WITH_PPP_TRUE@nm_pppd_plugin_la_LIBADD = \ -@WITH_PPP_TRUE@ $(GLIB_LIBS) \ -@WITH_PPP_TRUE@ $(DL_LIBS) \ -@WITH_PPP_TRUE@ $(NULL) - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/ppp-manager/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/ppp-manager/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-pppd_pluginLTLIBRARIES: $(pppd_plugin_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pppd_plugin_LTLIBRARIES)'; test -n "$(pppd_plugindir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pppd_plugindir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pppd_plugindir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pppd_plugindir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pppd_plugindir)"; \ - } - -uninstall-pppd_pluginLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pppd_plugin_LTLIBRARIES)'; test -n "$(pppd_plugindir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pppd_plugindir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pppd_plugindir)/$$f"; \ - done - -clean-pppd_pluginLTLIBRARIES: - -test -z "$(pppd_plugin_LTLIBRARIES)" || rm -f $(pppd_plugin_LTLIBRARIES) - @list='$(pppd_plugin_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -nm-pppd-plugin.la: $(nm_pppd_plugin_la_OBJECTS) $(nm_pppd_plugin_la_DEPENDENCIES) $(EXTRA_nm_pppd_plugin_la_DEPENDENCIES) - $(AM_V_CCLD)$(nm_pppd_plugin_la_LINK) $(am_nm_pppd_plugin_la_rpath) $(nm_pppd_plugin_la_OBJECTS) $(nm_pppd_plugin_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-pppd-plugin.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: - for dir in "$(DESTDIR)$(pppd_plugindir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-pppd_pluginLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-pppd_pluginLTLIBRARIES - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-pppd_pluginLTLIBRARIES - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-pppd_pluginLTLIBRARIES cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-pppd_pluginLTLIBRARIES install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ - uninstall-pppd_pluginLTLIBRARIES - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c deleted file mode 100644 index 34c550fa..00000000 --- a/src/ppp-manager/nm-ppp-manager.c +++ /dev/null @@ -1,1245 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2012 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#ifndef aligned_u64 -#define aligned_u64 unsigned long long __attribute__((aligned(8))) -#endif -#include -#include - -#include "NetworkManagerUtils.h" -#include "nm-ppp-manager.h" -#include "nm-platform.h" -#include "nm-core-internal.h" - -#include "nmdbus-ppp-manager.h" - -#define _NMLOG_DOMAIN LOGD_PPP -#define _NMLOG_PREFIX_NAME "ppp-manager" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -static void _ppp_cleanup (NMPPPManager *manager); -static void _ppp_kill (NMPPPManager *manager); - -#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so" -#define PPP_MANAGER_SECRET_TRIES "ppp-manager-secret-tries" - -typedef struct { - GPid pid; - - char *parent_iface; - - NMActRequest *act_req; - GDBusMethodInvocation *pending_secrets_context; - NMActRequestGetSecretsCallId secrets_id; - const char *secrets_setting_name; - - guint ppp_watch_id; - guint ppp_timeout_handler; - - /* Monitoring */ - char *ip_iface; - int monitor_fd; - guint monitor_id; -} NMPPPManagerPrivate; - -#define NM_PPP_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PPP_MANAGER, NMPPPManagerPrivate)) - -G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_EXPORTED_OBJECT) - -enum { - STATE_CHANGED, - IP4_CONFIG, - IP6_CONFIG, - STATS, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { - PROP_0, - PROP_PARENT_IFACE, - LAST_PROP -}; - -static void -nm_ppp_manager_init (NMPPPManager *manager) -{ - NM_PPP_MANAGER_GET_PRIVATE (manager)->monitor_fd = -1; -} - -static void -dispose (GObject *object) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); - - _ppp_cleanup (NM_PPP_MANAGER (object)); - _ppp_kill (NM_PPP_MANAGER (object)); - - g_clear_object (&priv->act_req); - - G_OBJECT_CLASS (nm_ppp_manager_parent_class)->dispose (object); -} - -static void -finalize (GObject *object) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); - - g_free (priv->ip_iface); - g_free (priv->parent_iface); - - G_OBJECT_CLASS (nm_ppp_manager_parent_class)->finalize (object); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PARENT_IFACE: - g_free (priv->parent_iface); - priv->parent_iface = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PARENT_IFACE: - g_value_set_string (value, priv->parent_iface); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -NMPPPManager * -nm_ppp_manager_new (const char *iface) -{ - g_return_val_if_fail (iface != NULL, NULL); - - return (NMPPPManager *) g_object_new (NM_TYPE_PPP_MANAGER, - NM_PPP_MANAGER_PARENT_IFACE, iface, - NULL); -} - -/*******************************************/ - -static gboolean -monitor_cb (gpointer user_data) -{ - NMPPPManager *manager = NM_PPP_MANAGER (user_data); - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - struct ifreq req; - struct ppp_stats stats; - - memset (&req, 0, sizeof (req)); - memset (&stats, 0, sizeof (stats)); - req.ifr_data = (caddr_t) &stats; - - strncpy (req.ifr_name, priv->ip_iface, sizeof (req.ifr_name)); - if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) { - if (errno != ENODEV) - _LOGW ("could not read ppp stats: %s", strerror (errno)); - } else { - g_signal_emit (manager, signals[STATS], 0, - stats.p.ppp_ibytes, - stats.p.ppp_obytes); - } - - return TRUE; -} - -static void -monitor_stats (NMPPPManager *manager) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - - /* already monitoring */ - if (priv->monitor_fd >= 0) - return; - - priv->monitor_fd = socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); - if (priv->monitor_fd >= 0) { - g_warn_if_fail (priv->monitor_id == 0); - if (priv->monitor_id) - g_source_remove (priv->monitor_id); - priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, manager); - } else - _LOGW ("could not monitor PPP stats: %s", strerror (errno)); -} - -/*******************************************/ - -static void -remove_timeout_handler (NMPPPManager *manager) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - - nm_clear_g_source (&priv->ppp_timeout_handler); -} - -static void -cancel_get_secrets (NMPPPManager *self) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); - - if (priv->secrets_id) - nm_act_request_cancel_secrets (priv->act_req, priv->secrets_id); - - g_return_if_fail (!priv->secrets_id && !priv->secrets_setting_name); -} - -static gboolean -extract_details_from_connection (NMConnection *connection, - const char *secrets_setting_name, - const char **username, - const char **password, - GError **error) -{ - NMSettingConnection *s_con; - NMSetting *setting; - const char *setting_name; - - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (username != NULL, FALSE); - g_return_val_if_fail (password != NULL, FALSE); - - if (secrets_setting_name) - setting_name = secrets_setting_name; - else { - /* Get the setting matching the connection type */ - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - setting_name = nm_setting_connection_get_connection_type (s_con); - g_assert (setting_name); - - /* In case of bluetooth connection, use GSM or CDMA setting */ - if (strcmp (setting_name, NM_SETTING_BLUETOOTH_SETTING_NAME) == 0) { - if (nm_connection_get_setting_gsm (connection)) - setting_name = NM_SETTING_GSM_SETTING_NAME; - else - setting_name = NM_SETTING_CDMA_SETTING_NAME; - } - } - - setting = nm_connection_get_setting_by_name (connection, setting_name); - if (!setting) { - /* This shouldn't ever happen */ - g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, - "Missing type-specific setting; no secrets could be found."); - return FALSE; - } - - if (NM_IS_SETTING_PPPOE (setting)) { - *username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting)); - *password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting)); - } else if (NM_IS_SETTING_ADSL (setting)) { - *username = nm_setting_adsl_get_username (NM_SETTING_ADSL (setting)); - *password = nm_setting_adsl_get_password (NM_SETTING_ADSL (setting)); - } else if (NM_IS_SETTING_GSM (setting)) { - *username = nm_setting_gsm_get_username (NM_SETTING_GSM (setting)); - *password = nm_setting_gsm_get_password (NM_SETTING_GSM (setting)); - } else if (NM_IS_SETTING_CDMA (setting)) { - *username = nm_setting_cdma_get_username (NM_SETTING_CDMA (setting)); - *password = nm_setting_cdma_get_password (NM_SETTING_CDMA (setting)); - } - - return TRUE; -} - -static void -ppp_secrets_cb (NMActRequest *req, - NMActRequestGetSecretsCallId call_id, - NMSettingsConnection *settings_connection, /* unused (we pass NULL here) */ - GError *error, - gpointer user_data) -{ - NMPPPManager *self = NM_PPP_MANAGER (user_data); - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); - const char *username = NULL; - const char *password = NULL; - GError *local = NULL; - NMConnection *applied_connection; - - g_return_if_fail (priv->pending_secrets_context != NULL); - g_return_if_fail (req == priv->act_req); - g_return_if_fail (call_id == priv->secrets_id); - - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - goto out; - - if (error) { - _LOGW ("%s", error->message); - g_dbus_method_invocation_return_gerror (priv->pending_secrets_context, error); - goto out; - } - - applied_connection = nm_act_request_get_applied_connection (req); - - if (!extract_details_from_connection (applied_connection, priv->secrets_setting_name, &username, &password, &local)) { - _LOGW ("%s", local->message); - g_dbus_method_invocation_take_error (priv->pending_secrets_context, local); - goto out; - } - - /* This is sort of a hack but... - * pppd plugin only ever needs username and password. Passing the full - * connection there would mean some bloat: the plugin would need to link - * against libnm just to parse this. So instead, let's just send what - * it needs. - */ - g_dbus_method_invocation_return_value ( - priv->pending_secrets_context, - g_variant_new ("(ss)", username ? username : "", password ? password : "")); - - out: - priv->pending_secrets_context = NULL; - priv->secrets_id = NULL; - priv->secrets_setting_name = NULL; -} - -static void -impl_ppp_manager_need_secrets (NMPPPManager *manager, - GDBusMethodInvocation *context) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - NMConnection *applied_connection; - const char *username = NULL; - const char *password = NULL; - guint32 tries; - GPtrArray *hints = NULL; - GError *error = NULL; - NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; - - nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (priv->act_req)); - - applied_connection = nm_act_request_get_applied_connection (priv->act_req); - - priv->secrets_setting_name = nm_connection_need_secrets (applied_connection, &hints); - if (!priv->secrets_setting_name) { - /* Use existing secrets from the connection */ - if (extract_details_from_connection (applied_connection, NULL, &username, &password, &error)) { - /* Send existing secrets to the PPP plugin */ - priv->pending_secrets_context = context; - ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, manager); - } else { - _LOGW ("%s", error->message); - g_dbus_method_invocation_take_error (priv->pending_secrets_context, error); - } - return; - } - - /* Only ask for completely new secrets after retrying them once; some devices - * appear to ask a few times when they actually don't even care what you - * pass back. - */ - tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES)); - if (tries > 1) - flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; - - priv->secrets_id = nm_act_request_get_secrets (priv->act_req, - priv->secrets_setting_name, - flags, - hints ? g_ptr_array_index (hints, 0) : NULL, - ppp_secrets_cb, - manager); - g_object_set_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES, GUINT_TO_POINTER (++tries)); - priv->pending_secrets_context = context; - - if (hints) - g_ptr_array_free (hints, TRUE); -} - -static void -impl_ppp_manager_set_state (NMPPPManager *manager, - GDBusMethodInvocation *context, - guint32 state) -{ - g_signal_emit (manager, signals[STATE_CHANGED], 0, state); - - g_dbus_method_invocation_return_value (context, NULL); -} - -static gboolean -set_ip_config_common (NMPPPManager *self, - GVariant *config_dict, - const char *iface_prop, - guint32 *out_mtu) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); - NMConnection *applied_connection; - NMSettingPpp *s_ppp; - const char *iface; - - if (!g_variant_lookup (config_dict, iface_prop, "&s", &iface)) { - _LOGE ("no interface received!"); - return FALSE; - } - if (priv->ip_iface == NULL) - priv->ip_iface = g_strdup (iface); - - /* Got successful IP config; obviously the secrets worked */ - applied_connection = nm_act_request_get_applied_connection (priv->act_req); - g_object_set_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES, NULL); - - if (out_mtu) { - /* Get any custom MTU */ - s_ppp = nm_connection_get_setting_ppp (applied_connection); - *out_mtu = s_ppp ? nm_setting_ppp_get_mtu (s_ppp) : 0; - } - - monitor_stats (self); - return TRUE; -} - -static void -impl_ppp_manager_set_ip4_config (NMPPPManager *manager, - GDBusMethodInvocation *context, - GVariant *config_dict) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - NMIP4Config *config; - NMPlatformIP4Address address; - guint32 u32; - GVariantIter *iter; - - _LOGI ("(IPv4 Config Get) reply received."); - - remove_timeout_handler (manager); - - config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface)); - - memset (&address, 0, sizeof (address)); - address.plen = 32; - - if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_ADDRESS, "u", &u32)) - address.address = u32; - - if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_GATEWAY, "u", &u32)) { - nm_ip4_config_set_gateway (config, u32); - address.peer_address = u32; - } else - address.peer_address = address.address; - - if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_PREFIX, "u", &u32)) - address.plen = u32; - - if (address.address && address.plen && address.plen <= 32) { - address.addr_source = NM_IP_CONFIG_SOURCE_PPP; - nm_ip4_config_add_address (config, &address); - } else { - _LOGE ("invalid IPv4 address received!"); - goto out; - } - - 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); - } - - 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_dict, NM_PPP_IP4_CONFIG_INTERFACE, &u32)) - goto out; - - 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); - 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 (GVariant *dict, - const char *prop, - struct in6_addr *out_addr, - NMUtilsIPv6IfaceId *out_iid) -{ - guint64 iid; - - if (!g_variant_lookup (dict, prop, "t", &iid)) { - _LOGD ("pppd plugin property '%s' missing or not a uint64", prop); - return FALSE; - } - g_return_val_if_fail (iid != 0, FALSE); - - /* Construct an IPv6 LL address from the interface identifier. See - * http://tools.ietf.org/html/rfc4291#section-2.5.1 (IPv6) and - * http://tools.ietf.org/html/rfc5072#section-4.1 (IPv6 over PPP). - */ - memset (out_addr->s6_addr, 0, sizeof (out_addr->s6_addr)); - out_addr->s6_addr16[0] = htons (0xfe80); - memcpy (out_addr->s6_addr + 8, &iid, sizeof (iid)); - if (out_iid) - nm_utils_ipv6_interface_identifier_get_from_addr (out_iid, out_addr); - return TRUE; -} - -static void -impl_ppp_manager_set_ip6_config (NMPPPManager *manager, - GDBusMethodInvocation *context, - GVariant *config_dict) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - NMIP6Config *config; - NMPlatformIP6Address addr; - struct in6_addr a; - NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; - gboolean has_peer = FALSE; - - _LOGI ("(IPv6 Config Get) reply received."); - - remove_timeout_handler (manager); - - config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface)); - - memset (&addr, 0, sizeof (addr)); - addr.plen = 64; - - 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; - has_peer = TRUE; - } - - if (iid_value_to_ll6_addr (config_dict, NM_PPP_IP6_CONFIG_OUR_IID, &addr.address, &iid)) { - if (!has_peer) - addr.peer_address = addr.address; - nm_ip6_config_add_address (config, &addr); - - 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); - } - } else - _LOGE ("invalid IPv6 address received!"); - - g_object_unref (config); - g_dbus_method_invocation_return_value (context, NULL); -} - -static void -nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (manager_class); - NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (manager_class); - - g_type_class_add_private (manager_class, sizeof (NMPPPManagerPrivate)); - - exported_object_class->export_path = NM_DBUS_PATH "/PPP/%u"; - exported_object_class->export_on_construction = TRUE; - - object_class->dispose = dispose; - object_class->finalize = finalize; - object_class->get_property = get_property; - object_class->set_property = set_property; - - /* Properties */ - g_object_class_install_property - (object_class, PROP_PARENT_IFACE, - g_param_spec_string (NM_PPP_MANAGER_PARENT_IFACE, "", "", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /* signals */ - signals[STATE_CHANGED] = - g_signal_new (NM_PPP_MANAGER_STATE_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMPPPManagerClass, state_changed), - NULL, NULL, NULL, - G_TYPE_NONE, 1, - G_TYPE_UINT); - - signals[IP4_CONFIG] = - g_signal_new ("ip4-config", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMPPPManagerClass, ip4_config), - NULL, NULL, NULL, - G_TYPE_NONE, 2, - G_TYPE_STRING, - G_TYPE_OBJECT); - - signals[IP6_CONFIG] = - g_signal_new ("ip6-config", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMPPPManagerClass, ip6_config), - NULL, NULL, NULL, - G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_OBJECT); - - signals[STATS] = - g_signal_new ("stats", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMPPPManagerClass, stats), - NULL, NULL, NULL, - G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); - - nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class), - 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); -} - -/*******************************************/ - - - -typedef struct { - GPtrArray *array; - GStringChunk *chunk; -} NMCmdLine; - -static NMCmdLine * -nm_cmd_line_new (void) -{ - NMCmdLine *cmd; - - cmd = g_slice_new (NMCmdLine); - cmd->array = g_ptr_array_new (); - cmd->chunk = g_string_chunk_new (1024); - - return cmd; -} - -static void -nm_cmd_line_destroy (NMCmdLine *cmd) -{ - g_ptr_array_free (cmd->array, TRUE); - g_string_chunk_free (cmd->chunk); - g_slice_free (NMCmdLine, cmd); -} - -static char * -nm_cmd_line_to_str (NMCmdLine *cmd) -{ - char *str; - - g_ptr_array_add (cmd->array, NULL); - str = g_strjoinv (" ", (gchar **) cmd->array->pdata); - g_ptr_array_remove_index (cmd->array, cmd->array->len - 1); - - return str; -} - -static void -nm_cmd_line_add_string (NMCmdLine *cmd, const char *str) -{ - g_ptr_array_add (cmd->array, g_string_chunk_insert (cmd->chunk, str)); -} - -static void -nm_cmd_line_add_int (NMCmdLine *cmd, int i) -{ - char *str; - - str = g_strdup_printf ("%d", i); - nm_cmd_line_add_string (cmd, str); - g_free (str); -} - -/*******************************************/ - -static void -ppp_exit_code (guint pppd_exit_status, GPid pid) -{ - const char *msg; - - switch (pppd_exit_status) { - case 1: - msg = "Fatal pppd error"; - break; - case 2: - msg = "pppd options error"; - break; - case 3: - msg = "No root priv error"; - break; - case 4: - msg = "No ppp module error"; - break; - case 5: - msg = "pppd received a signal"; - break; - case 6: - msg = "Serial port lock failed"; - break; - case 7: - msg = "Serial port open failed"; - break; - case 8: - msg = "Connect script failed"; - break; - case 9: - msg = "Pty program error"; - break; - case 10: - msg = "PPP negotiation failed"; - break; - case 11: - msg = "Peer didn't authenticatie itself"; - break; - case 12: - msg = "Link idle: Idle Seconds reached."; - break; - case 13: - msg = "Connect time limit reached."; - break; - case 14: - msg = "Callback negotiated, call should come back."; - break; - case 15: - msg = "Lack of LCP echo responses"; - break; - case 16: - msg = "A modem hung up the phone"; - break; - case 17: - msg = "Loopback detected"; - break; - case 18: - msg = "The init script failed"; - break; - case 19: - msg = "Authentication error.\n" - "We failed to authenticate ourselves to the peer.\n" - "Maybe bad account or password?"; - break; - default: - msg = "Unknown error"; - } - - _LOGW ("pppd pid %d exited with error: %s", pid, msg); -} - -static void -ppp_watch_cb (GPid pid, gint status, gpointer user_data) -{ - NMPPPManager *manager = NM_PPP_MANAGER (user_data); - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - guint err; - - g_assert (pid == priv->pid); - - if (WIFEXITED (status)) { - err = WEXITSTATUS (status); - if (err != 0) - ppp_exit_code (err, priv->pid); - } else if (WIFSTOPPED (status)) { - _LOGI ("pppd pid %d stopped unexpectedly with signal %d", priv->pid, WSTOPSIG (status)); - } else if (WIFSIGNALED (status)) { - _LOGI ("pppd pid %d died with signal %d", priv->pid, WTERMSIG (status)); - } else - _LOGI ("pppd pid %d died from an unknown cause", priv->pid); - - _LOGD ("pppd pid %d cleaned up", priv->pid); - priv->pid = 0; - priv->ppp_watch_id = 0; - g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD); -} - -static gboolean -pppd_timed_out (gpointer data) -{ - NMPPPManager *manager = NM_PPP_MANAGER (data); - - _LOGW ("pppd timed out or didn't initialize our dbus module"); - _ppp_cleanup (manager); - _ppp_kill (manager); - - g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD); - - return FALSE; -} - -static NMCmdLine * -create_pppd_cmd_line (NMPPPManager *self, - NMSettingPpp *setting, - NMSettingPppoe *pppoe, - NMSettingAdsl *adsl, - const char *ppp_name, - guint baud_override, - GError **err) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); - const char *pppd_binary = NULL; - NMCmdLine *cmd; - gboolean ppp_debug; - - g_return_val_if_fail (setting != NULL, NULL); - - pppd_binary = nm_utils_find_helper ("pppd", NULL, err); - if (!pppd_binary) - return NULL; - - /* Create pppd command line */ - cmd = nm_cmd_line_new (); - nm_cmd_line_add_string (cmd, pppd_binary); - - nm_cmd_line_add_string (cmd, "nodetach"); - nm_cmd_line_add_string (cmd, "lock"); - - /* NM handles setting the default route */ - nm_cmd_line_add_string (cmd, "nodefaultroute"); - - /* Allow IPv6 to be configured by IPV6CP */ - nm_cmd_line_add_string (cmd, "ipv6"); - nm_cmd_line_add_string (cmd, ","); - - ppp_debug = !!getenv ("NM_PPP_DEBUG"); - if (nm_logging_enabled (LOGL_DEBUG, LOGD_PPP)) - ppp_debug = TRUE; - - if (ppp_debug) - nm_cmd_line_add_string (cmd, "debug"); - - if (ppp_name) { - nm_cmd_line_add_string (cmd, "user"); - nm_cmd_line_add_string (cmd, ppp_name); - } - - if (pppoe) { - char *dev_str; - const char *pppoe_service; - - nm_cmd_line_add_string (cmd, "plugin"); - nm_cmd_line_add_string (cmd, "rp-pppoe.so"); - - dev_str = g_strdup_printf ("nic-%s", priv->parent_iface); - nm_cmd_line_add_string (cmd, dev_str); - g_free (dev_str); - - pppoe_service = nm_setting_pppoe_get_service (pppoe); - if (pppoe_service) { - nm_cmd_line_add_string (cmd, "rp_pppoe_service"); - nm_cmd_line_add_string (cmd, pppoe_service); - } - } else if (adsl) { - const gchar *protocol = nm_setting_adsl_get_protocol (adsl); - - if (!strcmp (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA)) { - guint32 vpi = nm_setting_adsl_get_vpi (adsl); - guint32 vci = nm_setting_adsl_get_vci (adsl); - const char *encaps = nm_setting_adsl_get_encapsulation (adsl); - gchar *vpivci; - - nm_cmd_line_add_string (cmd, "plugin"); - nm_cmd_line_add_string (cmd, "pppoatm.so"); - - vpivci = g_strdup_printf("%d.%d", vpi, vci); - nm_cmd_line_add_string (cmd, vpivci); - g_free (vpivci); - - if (g_strcmp0 (encaps, NM_SETTING_ADSL_ENCAPSULATION_LLC) == 0) - nm_cmd_line_add_string (cmd, "llc-encaps"); - else /*if (g_strcmp0 (encaps, NM_SETTING_ADSL_ENCAPSULATION_VCMUX) == 0)*/ - nm_cmd_line_add_string (cmd, "vc-encaps"); - - } else if (!strcmp (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) { - nm_cmd_line_add_string (cmd, "plugin"); - nm_cmd_line_add_string (cmd, "rp-pppoe.so"); - nm_cmd_line_add_string (cmd, priv->parent_iface); - } - - nm_cmd_line_add_string (cmd, "noipdefault"); - } else { - nm_cmd_line_add_string (cmd, priv->parent_iface); - /* Don't send some random address as the local address */ - nm_cmd_line_add_string (cmd, "noipdefault"); - } - - if (nm_setting_ppp_get_baud (setting)) - nm_cmd_line_add_int (cmd, nm_setting_ppp_get_baud (setting)); - else if (baud_override) - nm_cmd_line_add_int (cmd, (int) baud_override); - - /* noauth by default, because we certainly don't have any information - * with which to verify anything the peer gives us if we ask it to - * authenticate itself, which is what 'auth' really means. - */ - nm_cmd_line_add_string (cmd, "noauth"); - - if (nm_setting_ppp_get_refuse_eap (setting)) - nm_cmd_line_add_string (cmd, "refuse-eap"); - if (nm_setting_ppp_get_refuse_pap (setting)) - nm_cmd_line_add_string (cmd, "refuse-pap"); - if (nm_setting_ppp_get_refuse_chap (setting)) - nm_cmd_line_add_string (cmd, "refuse-chap"); - if (nm_setting_ppp_get_refuse_mschap (setting)) - nm_cmd_line_add_string (cmd, "refuse-mschap"); - if (nm_setting_ppp_get_refuse_mschapv2 (setting)) - nm_cmd_line_add_string (cmd, "refuse-mschap-v2"); - if (nm_setting_ppp_get_nobsdcomp (setting)) - nm_cmd_line_add_string (cmd, "nobsdcomp"); - if (nm_setting_ppp_get_no_vj_comp (setting)) - nm_cmd_line_add_string (cmd, "novj"); - if (nm_setting_ppp_get_nodeflate (setting)) - nm_cmd_line_add_string (cmd, "nodeflate"); - if (nm_setting_ppp_get_require_mppe (setting)) - nm_cmd_line_add_string (cmd, "require-mppe"); - if (nm_setting_ppp_get_require_mppe_128 (setting)) - nm_cmd_line_add_string (cmd, "require-mppe-128"); - if (nm_setting_ppp_get_mppe_stateful (setting)) - nm_cmd_line_add_string (cmd, "mppe-stateful"); - if (nm_setting_ppp_get_crtscts (setting)) - nm_cmd_line_add_string (cmd, "crtscts"); - - /* Always ask for DNS, we don't have to use them if the connection - * overrides the returned servers. - */ - nm_cmd_line_add_string (cmd, "usepeerdns"); - - if (nm_setting_ppp_get_mru (setting)) { - nm_cmd_line_add_string (cmd, "mru"); - nm_cmd_line_add_int (cmd, nm_setting_ppp_get_mru (setting)); - } - - if (nm_setting_ppp_get_mtu (setting)) { - nm_cmd_line_add_string (cmd, "mtu"); - nm_cmd_line_add_int (cmd, nm_setting_ppp_get_mtu (setting)); - } - - nm_cmd_line_add_string (cmd, "lcp-echo-failure"); - nm_cmd_line_add_int (cmd, nm_setting_ppp_get_lcp_echo_failure (setting)); - - nm_cmd_line_add_string (cmd, "lcp-echo-interval"); - nm_cmd_line_add_int (cmd, nm_setting_ppp_get_lcp_echo_interval (setting)); - - /* Avoid pppd to exit if no traffic going through */ - nm_cmd_line_add_string (cmd, "idle"); - nm_cmd_line_add_int (cmd, 0); - - nm_cmd_line_add_string (cmd, "ipparam"); - nm_cmd_line_add_string (cmd, nm_exported_object_get_path (NM_EXPORTED_OBJECT (self))); - - nm_cmd_line_add_string (cmd, "plugin"); - nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN); - - return cmd; -} - -static void -pppoe_fill_defaults (NMSettingPpp *setting) -{ - if (!nm_setting_ppp_get_mtu (setting)) - g_object_set (setting, NM_SETTING_PPP_MTU, (guint32) 1492, NULL); - - if (!nm_setting_ppp_get_mru (setting)) - g_object_set (setting, NM_SETTING_PPP_MRU, (guint32) 1492, NULL); - - g_object_set (setting, - NM_SETTING_PPP_NOAUTH, TRUE, - NM_SETTING_PPP_NODEFLATE, TRUE, - NULL); - - /* FIXME: These commented settings should be set as well, update NMSettingPpp first. */ -#if 0 - setting->noipdefault = TRUE; - setting->default_asyncmap = TRUE; - setting->defaultroute = TRUE; - setting->hide_password = TRUE; - setting->noaccomp = TRUE; - setting->nopcomp = TRUE; - setting->novj = TRUE; - setting->novjccomp = TRUE; -#endif -} - -gboolean -nm_ppp_manager_start (NMPPPManager *manager, - NMActRequest *req, - const char *ppp_name, - guint32 timeout_secs, - guint baud_override, - GError **err) -{ - NMPPPManagerPrivate *priv; - NMConnection *connection; - NMSettingPpp *s_ppp; - gs_unref_object NMSettingPpp *s_ppp_free = NULL; - NMSettingPppoe *pppoe_setting; - NMSettingAdsl *adsl_setting; - NMCmdLine *ppp_cmd; - char *cmd_str; - struct stat st; - - g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE); - g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE); - - priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - -#if !WITH_PPP - /* PPP support disabled */ - g_set_error_literal (err, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "PPP support is not enabled."); - return FALSE; -#endif - - priv->pid = 0; - - /* Make sure /dev/ppp exists (bgo #533064) */ - if (stat ("/dev/ppp", &st) || !S_ISCHR (st.st_mode)) - nm_utils_modprobe (NULL, FALSE, "ppp_generic", NULL); - - connection = nm_act_request_get_applied_connection (req); - g_return_val_if_fail (connection, FALSE); - - s_ppp = nm_connection_get_setting_ppp (connection); - if (!s_ppp) { - /* If the PPP settings are all default we may not have a PPP setting yet, - * so just make a default one here. - */ - s_ppp = s_ppp_free = NM_SETTING_PPP (nm_setting_ppp_new ()); - } - - pppoe_setting = nm_connection_get_setting_pppoe (connection); - if (pppoe_setting) { - /* We can't modify the applied connection's setting, make a copy */ - if (!s_ppp_free) - s_ppp = s_ppp_free = NM_SETTING_PPP (nm_setting_duplicate ((NMSetting *) s_ppp)); - pppoe_fill_defaults (s_ppp); - } - - adsl_setting = (NMSettingAdsl *) nm_connection_get_setting (connection, NM_TYPE_SETTING_ADSL); - - ppp_cmd = create_pppd_cmd_line (manager, s_ppp, pppoe_setting, adsl_setting, ppp_name, baud_override, err); - if (!ppp_cmd) - goto out; - - g_ptr_array_add (ppp_cmd->array, NULL); - - _LOGI ("starting PPP connection"); - - cmd_str = nm_cmd_line_to_str (ppp_cmd); - _LOGD ("command line: %s", cmd_str); - g_free (cmd_str); - - priv->pid = 0; - if (!g_spawn_async (NULL, (char **) ppp_cmd->array->pdata, NULL, - G_SPAWN_DO_NOT_REAP_CHILD, - nm_utils_setpgid, NULL, - &priv->pid, err)) { - goto out; - } - - _LOGI ("pppd started with pid %d", priv->pid); - - priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, manager); - priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, manager); - priv->act_req = g_object_ref (req); - -out: - if (ppp_cmd) - nm_cmd_line_destroy (ppp_cmd); - - return priv->pid > 0; -} - -static void -_ppp_kill (NMPPPManager *manager) -{ - NMPPPManagerPrivate *priv; - - g_return_if_fail (NM_IS_PPP_MANAGER (manager)); - - priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - - if (priv->pid) { - nm_utils_kill_child_async (priv->pid, SIGTERM, LOGD_PPP, "pppd", 2000, NULL, NULL); - priv->pid = 0; - } -} - -static void -_ppp_cleanup (NMPPPManager *manager) -{ - NMPPPManagerPrivate *priv; - - g_return_if_fail (NM_IS_PPP_MANAGER (manager)); - - priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - - cancel_get_secrets (manager); - - nm_clear_g_source (&priv->monitor_id); - - if (priv->monitor_fd >= 0) { - /* Get the stats one last time */ - monitor_cb (manager); - close (priv->monitor_fd); - priv->monitor_fd = -1; - } - - nm_clear_g_source (&priv->ppp_timeout_handler); - nm_clear_g_source (&priv->ppp_watch_id); -} - -/***********************************************************/ - -typedef struct { - NMPPPManager *manager; - GSimpleAsyncResult *result; - GCancellable *cancellable; -} StopContext; - -static void -stop_context_complete (StopContext *ctx) -{ - if (ctx->cancellable) - g_object_unref (ctx->cancellable); - g_simple_async_result_complete_in_idle (ctx->result); - g_object_unref (ctx->result); - g_object_unref (ctx->manager); - g_slice_free (StopContext, ctx); -} - -static gboolean -stop_context_complete_if_cancelled (StopContext *ctx) -{ - GError *error = NULL; - - if (g_cancellable_set_error_if_cancelled (ctx->cancellable, &error)) { - g_simple_async_result_take_error (ctx->result, error); - stop_context_complete (ctx); - return TRUE; - } - return FALSE; -} - -gboolean -nm_ppp_manager_stop_finish (NMPPPManager *manager, - GAsyncResult *res, - GError **error) -{ - return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); -} - -static void -kill_child_ready (pid_t pid, - gboolean success, - int child_status, - StopContext *ctx) -{ - if (stop_context_complete_if_cancelled (ctx)) - return; - stop_context_complete (ctx); -} - -void -nm_ppp_manager_stop (NMPPPManager *manager, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); - StopContext *ctx; - - ctx = g_slice_new0 (StopContext); - ctx->manager = g_object_ref (manager); - ctx->result = g_simple_async_result_new (G_OBJECT (manager), - callback, - user_data, - nm_ppp_manager_stop); - - /* Setup cancellable */ - ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL; - if (stop_context_complete_if_cancelled (ctx)) - return; - - /* Cleanup internals */ - _ppp_cleanup (manager); - - /* If no pppd running, we're done */ - if (!priv->pid) { - stop_context_complete (ctx); - return; - } - - /* No cancellable operation, so just wait until it returns always */ - nm_utils_kill_child_async (priv->pid, - SIGTERM, - LOGD_PPP, - "pppd", - 2000, - (NMUtilsKillChildAsyncCb) kill_child_ready, - ctx); - priv->pid = 0; -} diff --git a/src/ppp-manager/nm-ppp-manager.h b/src/ppp-manager/nm-ppp-manager.h deleted file mode 100644 index 9a8b13dc..00000000 --- a/src/ppp-manager/nm-ppp-manager.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2010 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_PPP_MANAGER_H__ -#define __NETWORKMANAGER_PPP_MANAGER_H__ - - -#include "nm-exported-object.h" -#include "nm-ppp-status.h" -#include "nm-activation-request.h" -#include "nm-connection.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" -#include "nm-pppd-plugin.h" -#include "NetworkManagerUtils.h" - -#define NM_TYPE_PPP_MANAGER (nm_ppp_manager_get_type ()) -#define NM_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PPP_MANAGER, NMPPPManager)) -#define NM_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) -#define NM_IS_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PPP_MANAGER)) -#define NM_IS_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PPP_MANAGER)) -#define NM_PPP_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) - -#define NM_PPP_MANAGER_PARENT_IFACE "parent-iface" - -/* signals */ -#define NM_PPP_MANAGER_STATE_CHANGED "state-changed" - -typedef struct { - NMExportedObject parent; -} NMPPPManager; - -typedef struct { - NMExportedObjectClass parent; - - /* Signals */ - void (*state_changed) (NMPPPManager *manager, NMPPPStatus status); - void (*ip4_config) (NMPPPManager *manager, const char *iface, NMIP4Config *config); - void (*ip6_config) (NMPPPManager *manager, - const char *iface, - const NMUtilsIPv6IfaceId *iid, - NMIP6Config *config); - void (*stats) (NMPPPManager *manager, guint32 in_bytes, guint32 out_bytes); -} NMPPPManagerClass; - -GType nm_ppp_manager_get_type (void); - -NMPPPManager *nm_ppp_manager_new (const char *iface); - -gboolean nm_ppp_manager_start (NMPPPManager *manager, - NMActRequest *req, - const char *ppp_name, - guint32 timeout_secs, - guint baud_override, - GError **err); - -void nm_ppp_manager_stop (NMPPPManager *manager, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean nm_ppp_manager_stop_finish (NMPPPManager *manager, - GAsyncResult *res, - GError **error); - -#endif /* __NETWORKMANAGER_PPP_MANAGER_H__ */ diff --git a/src/ppp-manager/nm-ppp-status.h b/src/ppp-manager/nm-ppp-status.h deleted file mode 100644 index 391b5aa9..00000000 --- a/src/ppp-manager/nm-ppp-status.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_PPP_STATUS_H__ -#define __NETWORKMANAGER_PPP_STATUS_H__ - -typedef enum { - NM_PPP_STATUS_UNKNOWN, - - NM_PPP_STATUS_DEAD, - NM_PPP_STATUS_INITIALIZE, - NM_PPP_STATUS_SERIALCONN, - NM_PPP_STATUS_DORMANT, - NM_PPP_STATUS_ESTABLISH, - NM_PPP_STATUS_AUTHENTICATE, - NM_PPP_STATUS_CALLBACK, - NM_PPP_STATUS_NETWORK, - NM_PPP_STATUS_RUNNING, - NM_PPP_STATUS_TERMINATE, - NM_PPP_STATUS_DISCONNECT, - NM_PPP_STATUS_HOLDOFF, - NM_PPP_STATUS_MASTER -} NMPPPStatus; - -#endif /* __NETWORKMANAGER_PPP_STATUS_H__ */ diff --git a/src/ppp-manager/nm-pppd-plugin.c b/src/ppp-manager/nm-pppd-plugin.c deleted file mode 100644 index 9c47c339..00000000 --- a/src/ppp-manager/nm-pppd-plugin.c +++ /dev/null @@ -1,417 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 Red Hat, Inc. - */ - -#include -#define ___CONFIG_H__ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define INET6 -#include -#include - -#include "nm-default.h" -#include "nm-dbus-interface.h" -#include "nm-pppd-plugin.h" -#include "nm-ppp-status.h" - -int plugin_init (void); - -char pppd_version[] = VERSION; - -static GDBusProxy *proxy = NULL; - -static void -nm_phasechange (void *data, int arg) -{ - NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN; - char *ppp_phase; - - g_return_if_fail (G_IS_DBUS_PROXY (proxy)); - - switch (arg) { - case PHASE_DEAD: - ppp_status = NM_PPP_STATUS_DEAD; - ppp_phase = "dead"; - break; - case PHASE_INITIALIZE: - ppp_status = NM_PPP_STATUS_INITIALIZE; - ppp_phase = "initialize"; - break; - case PHASE_SERIALCONN: - ppp_status = NM_PPP_STATUS_SERIALCONN; - ppp_phase = "serial connection"; - break; - case PHASE_DORMANT: - ppp_status = NM_PPP_STATUS_DORMANT; - ppp_phase = "dormant"; - break; - case PHASE_ESTABLISH: - ppp_status = NM_PPP_STATUS_ESTABLISH; - ppp_phase = "establish"; - break; - case PHASE_AUTHENTICATE: - ppp_status = NM_PPP_STATUS_AUTHENTICATE; - ppp_phase = "authenticate"; - break; - case PHASE_CALLBACK: - ppp_status = NM_PPP_STATUS_CALLBACK; - ppp_phase = "callback"; - break; - case PHASE_NETWORK: - ppp_status = NM_PPP_STATUS_NETWORK; - ppp_phase = "network"; - break; - case PHASE_RUNNING: - ppp_status = NM_PPP_STATUS_RUNNING; - ppp_phase = "running"; - break; - case PHASE_TERMINATE: - ppp_status = NM_PPP_STATUS_TERMINATE; - ppp_phase = "terminate"; - break; - case PHASE_DISCONNECT: - ppp_status = NM_PPP_STATUS_DISCONNECT; - ppp_phase = "disconnect"; - break; - case PHASE_HOLDOFF: - ppp_status = NM_PPP_STATUS_HOLDOFF; - ppp_phase = "holdoff"; - break; - case PHASE_MASTER: - ppp_status = NM_PPP_STATUS_MASTER; - ppp_phase = "master"; - break; - - default: - ppp_phase = "unknown"; - break; - } - - g_message ("nm-ppp-plugin: (%s): status %d / phase '%s'", - __func__, - ppp_status, - ppp_phase); - - if (ppp_status != NM_PPP_STATUS_UNKNOWN) { - g_dbus_proxy_call (proxy, - "SetState", - g_variant_new ("(u)", ppp_status), - G_DBUS_CALL_FLAGS_NONE, -1, - NULL, - NULL, NULL); - } -} - -static void -nm_ip_up (void *data, int arg) -{ - ipcp_options opts = ipcp_gotoptions[0]; - ipcp_options peer_opts = ipcp_hisoptions[0]; - GVariantBuilder builder; - guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit); - - g_return_if_fail (G_IS_DBUS_PROXY (proxy)); - - g_message ("nm-ppp-plugin: (%s): ip-up event", __func__); - - if (!opts.ouraddr) { - g_warning ("nm-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__); - nm_phasechange (NULL, PHASE_DEAD); - return; - } - - g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); - - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_INTERFACE, - g_variant_new_string (ifname)); - - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_ADDRESS, - g_variant_new_uint32 (opts.ouraddr)); - - /* Prefer the peer options remote address first, _unless_ pppd made the - * address up, at which point prefer the local options remote address, - * and if that's not right, use the made-up address as a last resort. - */ - if (peer_opts.hisaddr && (peer_opts.hisaddr != pppd_made_up_address)) { - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_GATEWAY, - g_variant_new_uint32 (peer_opts.hisaddr)); - } else if (opts.hisaddr) { - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_GATEWAY, - g_variant_new_uint32 (opts.hisaddr)); - } else if (peer_opts.hisaddr == pppd_made_up_address) { - /* As a last resort, use the made-up address */ - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_GATEWAY, - g_variant_new_uint32 (peer_opts.ouraddr)); - } - - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_PREFIX, - g_variant_new_uint32 (32)); - - if (opts.dnsaddr[0] || opts.dnsaddr[1]) { - guint32 dns[2]; - int len = 0; - - if (opts.dnsaddr[0]) - dns[len++] = opts.dnsaddr[0]; - if (opts.dnsaddr[1]) - dns[len++] = opts.dnsaddr[1]; - - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_DNS, - g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, - dns, len, sizeof (guint32))); - } - - if (opts.winsaddr[0] || opts.winsaddr[1]) { - guint32 wins[2]; - int len = 0; - - if (opts.winsaddr[0]) - wins[len++] = opts.winsaddr[0]; - if (opts.winsaddr[1]) - wins[len++] = opts.winsaddr[1]; - - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP4_CONFIG_WINS, - g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, - wins, len, sizeof (guint32))); - } - - g_message ("nm-ppp-plugin: (%s): sending IPv4 config to NetworkManager...", __func__); - - g_dbus_proxy_call (proxy, - "SetIp4Config", - g_variant_new ("(a{sv})", &builder), - G_DBUS_CALL_FLAGS_NONE, -1, - NULL, - NULL, NULL); -} - -static GVariant * -eui64_to_variant (eui64_t eui) -{ - guint64 iid; - - G_STATIC_ASSERT (sizeof (iid) == sizeof (eui)); - - memcpy (&iid, &eui, sizeof (eui)); - return g_variant_new_uint64 (iid); -} - -static void -nm_ip6_up (void *data, int arg) -{ - ipv6cp_options *ho = &ipv6cp_hisoptions[0]; - ipv6cp_options *go = &ipv6cp_gotoptions[0]; - GVariantBuilder builder; - - g_return_if_fail (G_IS_DBUS_PROXY (proxy)); - - g_message ("nm-ppp-plugin: (%s): ip6-up event", __func__); - - g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP6_CONFIG_INTERFACE, - g_variant_new_string (ifname)); - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP6_CONFIG_OUR_IID, - eui64_to_variant (go->ourid)); - g_variant_builder_add (&builder, "{sv}", - NM_PPP_IP6_CONFIG_PEER_IID, - eui64_to_variant (ho->hisid)); - - /* DNS is done via DHCPv6 or router advertisements */ - - g_message ("nm-ppp-plugin: (%s): sending IPv6 config to NetworkManager...", __func__); - - g_dbus_proxy_call (proxy, - "SetIp6Config", - g_variant_new ("(a{sv})", &builder), - G_DBUS_CALL_FLAGS_NONE, -1, - NULL, - NULL, NULL); -} - -static int -get_chap_check (void) -{ - return 1; -} - -static int -get_pap_check (void) -{ - return 1; -} - -static int -get_credentials (char *username, char *password) -{ - const char *my_username = NULL; - const char *my_password = NULL; - size_t len; - GVariant *ret; - GError *err = NULL; - - if (!password) { - /* pppd is checking pap support; return 1 for supported */ - g_return_val_if_fail (username, -1); - return 1; - } - - g_return_val_if_fail (username, -1); - g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), -1); - - g_message ("nm-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__); - - ret = g_dbus_proxy_call_sync (proxy, - "NeedSecrets", - NULL, - G_DBUS_CALL_FLAGS_NONE, -1, - NULL, &err); - if (!ret) { - g_warning ("nm-ppp-plugin: (%s): could not get secrets: %s", - __func__, - err->message); - g_error_free (err); - return -1; - } - - g_message ("nm-ppp-plugin: (%s): got credentials from NetworkManager", __func__); - - g_variant_get (ret, "(&s&s)", &my_username, &my_password); - - if (my_username) { - len = strlen (my_username) + 1; - len = len < MAXNAMELEN ? len : MAXNAMELEN; - - strncpy (username, my_username, len); - username[len - 1] = '\0'; - } - - if (my_password) { - len = strlen (my_password) + 1; - len = len < MAXSECRETLEN ? len : MAXSECRETLEN; - - strncpy (password, my_password, len); - password[len - 1] = '\0'; - } - - g_variant_unref (ret); - - return 1; -} - -static void -nm_exit_notify (void *data, int arg) -{ - g_return_if_fail (G_IS_DBUS_PROXY (proxy)); - - g_message ("nm-ppp-plugin: (%s): cleaning up", __func__); - - g_object_unref (proxy); - proxy = NULL; -} - -static void -add_ip6_notifier (void) -{ - static struct notifier **notifier = NULL; - static gsize load_once = 0; - - if (g_once_init_enter (&load_once)) { - void *handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); - - if (handle) { - notifier = dlsym (handle, "ipv6_up_notifier"); - dlclose (handle); - } - g_once_init_leave (&load_once, 1); - } - if (notifier) - add_notifier (notifier, nm_ip6_up, NULL); - else - g_message ("nm-ppp-plugin: no IPV6CP notifier support; IPv6 not available"); -} - -int -plugin_init (void) -{ - GDBusConnection *bus; - GError *err = NULL; - - nm_g_type_init (); - - g_message ("nm-ppp-plugin: (%s): initializing", __func__); - - bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err); - if (!bus) { - g_warning ("nm-pppd-plugin: (%s): couldn't connect to system bus: %s", - __func__, err->message); - g_error_free (err); - return -1; - } - - /* NM passes in the object path of the corresponding PPPManager - * object as the 'ipparam' argument to pppd. - */ - proxy = g_dbus_proxy_new_sync (bus, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - NM_DBUS_SERVICE, - ipparam, - NM_DBUS_INTERFACE_PPP, - NULL, &err); - g_object_unref (bus); - - if (!proxy) { - g_warning ("nm-pppd-plugin: (%s): couldn't create D-Bus proxy: %s", - __func__, err->message); - g_error_free (err); - return -1; - } - - chap_passwd_hook = get_credentials; - chap_check_hook = get_chap_check; - pap_passwd_hook = get_credentials; - pap_check_hook = get_pap_check; - - add_notifier (&phasechange, nm_phasechange, NULL); - add_notifier (&ip_up_notifier, nm_ip_up, NULL); - add_notifier (&exitnotify, nm_exit_notify, proxy); - add_ip6_notifier (); - - return 0; -} diff --git a/src/ppp-manager/nm-pppd-plugin.h b/src/ppp-manager/nm-pppd-plugin.h deleted file mode 100644 index 1a2ea09e..00000000 --- a/src/ppp-manager/nm-pppd-plugin.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2014 Red Hat, Inc. - */ - -#define NM_DBUS_INTERFACE_PPP "org.freedesktop.NetworkManager.PPP" - -#define NM_PPP_IP4_CONFIG_INTERFACE "interface" -#define NM_PPP_IP4_CONFIG_ADDRESS "address" -#define NM_PPP_IP4_CONFIG_PREFIX "prefix" -#define NM_PPP_IP4_CONFIG_GATEWAY "gateway" -#define NM_PPP_IP4_CONFIG_DNS "dns" -#define NM_PPP_IP4_CONFIG_WINS "wins" - -#define NM_PPP_IP6_CONFIG_INTERFACE "interface" -#define NM_PPP_IP6_CONFIG_OUR_IID "our-iid" -#define NM_PPP_IP6_CONFIG_PEER_IID "peer-iid" - diff --git a/src/ppp/nm-ppp-manager-call.c b/src/ppp/nm-ppp-manager-call.c new file mode 100644 index 00000000..d67c0a99 --- /dev/null +++ b/src/ppp/nm-ppp-manager-call.c @@ -0,0 +1,142 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2016 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-ppp-manager-call.h" + +#include +#include +#include + +#include "nm-manager.h" +#include "nm-core-utils.h" +#include "nm-ppp-plugin-api.h" + +#define PPP_PLUGIN_PATH NMPLUGINDIR "/libnm-ppp-plugin.so" + +/*****************************************************************************/ + +static NMPPPOps *ppp_ops = NULL; + +NMPPPManager * +nm_ppp_manager_create (const char *iface, GError **error) +{ + NMPPPManager *ret; + GModule *plugin; + GError *error_local = NULL; + NMPPPOps *ops; + struct stat st; + int errsv; + + if (G_UNLIKELY (!ppp_ops)) { + if (stat (PPP_PLUGIN_PATH, &st) != 0) { + errsv = errno; + g_set_error_literal (error, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "the PPP plugin " PPP_PLUGIN_PATH " is not installed"); + return NULL; + } + + if (!nm_utils_validate_plugin (PPP_PLUGIN_PATH, &st, &error_local)) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s", + error_local->message); + g_clear_error (&error_local); + return NULL; + } + + plugin = g_module_open (PPP_PLUGIN_PATH, G_MODULE_BIND_LOCAL); + if (!plugin) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s", + g_module_error ()); + return NULL; + } + + if (!g_module_symbol (plugin, "ppp_ops", (gpointer) &ops)) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN, + "error loading the PPP plugin: %s", g_module_error ()); + return NULL; + } + + /* after loading glib types from the plugin, we cannot unload the library anymore. + * Make it resident. */ + g_module_make_resident (plugin); + + nm_assert (ops); + nm_assert (ops->create); + nm_assert (ops->start); + nm_assert (ops->stop_async); + nm_assert (ops->stop_finish); + nm_assert (ops->stop_sync); + + ppp_ops = ops; + + nm_log_info (LOGD_CORE | LOGD_PPP, "loaded PPP plugin " PPP_PLUGIN_PATH); + } + + ret = ppp_ops->create (iface); + g_return_val_if_fail (ret, NULL); + return ret; +} + +gboolean +nm_ppp_manager_start (NMPPPManager *self, + NMActRequest *req, + const char *ppp_name, + guint32 timeout_secs, + guint baud_override, + GError **err) +{ + g_return_val_if_fail (ppp_ops, FALSE); + + return ppp_ops->start (self, req, ppp_name, timeout_secs, baud_override, err); +} + +void +nm_ppp_manager_stop_async (NMPPPManager *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (ppp_ops); + + ppp_ops->stop_async (self, cancellable, callback, user_data); +} + +gboolean +nm_ppp_manager_stop_finish (NMPPPManager *self, + GAsyncResult *res, + GError **error) +{ + g_return_val_if_fail (ppp_ops, FALSE); + + return ppp_ops->stop_finish (self, res, error); +} + +void +nm_ppp_manager_stop_sync (NMPPPManager *self) +{ + g_return_if_fail (ppp_ops); + + ppp_ops->stop_sync (self); +} + diff --git a/src/ppp/nm-ppp-manager-call.h b/src/ppp/nm-ppp-manager-call.h new file mode 100644 index 00000000..f21005f0 --- /dev/null +++ b/src/ppp/nm-ppp-manager-call.h @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2016 Red Hat, Inc. + */ + +#ifndef __NM_PPP_MANAGER_CALL_H__ +#define __NM_PPP_MANAGER_CALL_H__ + +#include "nm-ppp-manager.h" + +NMPPPManager * nm_ppp_manager_create (const char *iface, + GError **error); +gboolean nm_ppp_manager_start (NMPPPManager *self, + NMActRequest *req, + const char *ppp_name, + guint32 timeout_secs, + guint baud_override, + GError **error); +void nm_ppp_manager_stop_async (NMPPPManager *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean nm_ppp_manager_stop_finish (NMPPPManager *self, + GAsyncResult *res, + GError **error); +void nm_ppp_manager_stop_sync (NMPPPManager *self); + +#endif /* __NM_PPP_MANAGER_CALL_H__ */ diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c new file mode 100644 index 00000000..1bbe29d4 --- /dev/null +++ b/src/ppp/nm-ppp-manager.c @@ -0,0 +1,1296 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2012 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-ppp-manager.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#ifndef aligned_u64 +#define aligned_u64 unsigned long long __attribute__((aligned(8))) +#endif +#include +#include + +#include "NetworkManagerUtils.h" +#include "platform/nm-platform.h" +#include "nm-core-internal.h" +#include "nm-act-request.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" + +#include "nm-pppd-plugin.h" +#include "nm-ppp-plugin-api.h" +#include "nm-ppp-status.h" + +#include "introspection/org.freedesktop.NetworkManager.PPP.h" + +#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so" +#define PPP_MANAGER_SECRET_TRIES "ppp-manager-secret-tries" + +/*****************************************************************************/ + +#define NM_TYPE_PPP_MANAGER (nm_ppp_manager_get_type ()) +#define NM_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PPP_MANAGER, NMPPPManager)) +#define NM_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) +#define NM_IS_PPP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PPP_MANAGER)) +#define NM_IS_PPP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PPP_MANAGER)) +#define NM_PPP_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PPP_MANAGER, NMPPPManagerClass)) + +GType nm_ppp_manager_get_type (void); + +/*****************************************************************************/ + +enum { + STATE_CHANGED, + IP4_CONFIG, + IP6_CONFIG, + STATS, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PARENT_IFACE, +); + +typedef struct { + GPid pid; + + char *parent_iface; + + NMActRequest *act_req; + GDBusMethodInvocation *pending_secrets_context; + NMActRequestGetSecretsCallId secrets_id; + const char *secrets_setting_name; + + guint ppp_watch_id; + guint ppp_timeout_handler; + + /* Monitoring */ + char *ip_iface; + int monitor_fd; + guint monitor_id; +} NMPPPManagerPrivate; + +struct _NMPPPManager { + NMExportedObject parent; + NMPPPManagerPrivate _priv; +}; + +typedef struct { + NMExportedObjectClass parent; +} NMPPPManagerClass; + +G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, NM_TYPE_EXPORTED_OBJECT) + +#define NM_PPP_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMPPPManager, NM_IS_PPP_MANAGER) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_PPP +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "ppp-manager", __VA_ARGS__) + +/*****************************************************************************/ + +static void _ppp_cleanup (NMPPPManager *manager); +static void _ppp_kill (NMPPPManager *manager); + +/*****************************************************************************/ + +static gboolean +monitor_cb (gpointer user_data) +{ + NMPPPManager *manager = NM_PPP_MANAGER (user_data); + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + struct ifreq req; + struct ppp_stats stats; + + memset (&req, 0, sizeof (req)); + memset (&stats, 0, sizeof (stats)); + req.ifr_data = (caddr_t) &stats; + + strncpy (req.ifr_name, priv->ip_iface, sizeof (req.ifr_name)); + if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) { + if (errno != ENODEV) + _LOGW ("could not read ppp stats: %s", strerror (errno)); + } else { + g_signal_emit (manager, signals[STATS], 0, + stats.p.ppp_ibytes, + stats.p.ppp_obytes); + } + + return TRUE; +} + +static void +monitor_stats (NMPPPManager *manager) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + + /* already monitoring */ + if (priv->monitor_fd >= 0) + return; + + priv->monitor_fd = socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + if (priv->monitor_fd >= 0) { + g_warn_if_fail (priv->monitor_id == 0); + if (priv->monitor_id) + g_source_remove (priv->monitor_id); + priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, manager); + } else + _LOGW ("could not monitor PPP stats: %s", strerror (errno)); +} + +/*****************************************************************************/ + +static void +remove_timeout_handler (NMPPPManager *manager) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + + nm_clear_g_source (&priv->ppp_timeout_handler); +} + +static void +cancel_get_secrets (NMPPPManager *self) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); + + if (priv->secrets_id) + nm_act_request_cancel_secrets (priv->act_req, priv->secrets_id); + + g_return_if_fail (!priv->secrets_id && !priv->secrets_setting_name); +} + +static gboolean +extract_details_from_connection (NMConnection *connection, + const char *secrets_setting_name, + const char **username, + const char **password, + GError **error) +{ + NMSettingConnection *s_con; + NMSetting *setting; + const char *setting_name; + + g_return_val_if_fail (connection != NULL, FALSE); + g_return_val_if_fail (username != NULL, FALSE); + g_return_val_if_fail (password != NULL, FALSE); + + if (secrets_setting_name) + setting_name = secrets_setting_name; + else { + /* Get the setting matching the connection type */ + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + setting_name = nm_setting_connection_get_connection_type (s_con); + g_assert (setting_name); + + /* In case of bluetooth connection, use GSM or CDMA setting */ + if (strcmp (setting_name, NM_SETTING_BLUETOOTH_SETTING_NAME) == 0) { + if (nm_connection_get_setting_gsm (connection)) + setting_name = NM_SETTING_GSM_SETTING_NAME; + else + setting_name = NM_SETTING_CDMA_SETTING_NAME; + } + } + + setting = nm_connection_get_setting_by_name (connection, setting_name); + if (!setting) { + /* This shouldn't ever happen */ + g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, + "Missing type-specific setting; no secrets could be found."); + return FALSE; + } + + if (NM_IS_SETTING_PPPOE (setting)) { + *username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting)); + *password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting)); + } else if (NM_IS_SETTING_ADSL (setting)) { + *username = nm_setting_adsl_get_username (NM_SETTING_ADSL (setting)); + *password = nm_setting_adsl_get_password (NM_SETTING_ADSL (setting)); + } else if (NM_IS_SETTING_GSM (setting)) { + *username = nm_setting_gsm_get_username (NM_SETTING_GSM (setting)); + *password = nm_setting_gsm_get_password (NM_SETTING_GSM (setting)); + } else if (NM_IS_SETTING_CDMA (setting)) { + *username = nm_setting_cdma_get_username (NM_SETTING_CDMA (setting)); + *password = nm_setting_cdma_get_password (NM_SETTING_CDMA (setting)); + } + + return TRUE; +} + +static void +ppp_secrets_cb (NMActRequest *req, + NMActRequestGetSecretsCallId call_id, + NMSettingsConnection *settings_connection, /* unused (we pass NULL here) */ + GError *error, + gpointer user_data) +{ + NMPPPManager *self = NM_PPP_MANAGER (user_data); + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); + const char *username = NULL; + const char *password = NULL; + GError *local = NULL; + NMConnection *applied_connection; + + g_return_if_fail (priv->pending_secrets_context != NULL); + g_return_if_fail (req == priv->act_req); + g_return_if_fail (call_id == priv->secrets_id); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + goto out; + + if (error) { + _LOGW ("%s", error->message); + g_dbus_method_invocation_return_gerror (priv->pending_secrets_context, error); + goto out; + } + + applied_connection = nm_act_request_get_applied_connection (req); + + if (!extract_details_from_connection (applied_connection, priv->secrets_setting_name, &username, &password, &local)) { + _LOGW ("%s", local->message); + g_dbus_method_invocation_take_error (priv->pending_secrets_context, local); + goto out; + } + + /* This is sort of a hack but... + * pppd plugin only ever needs username and password. Passing the full + * connection there would mean some bloat: the plugin would need to link + * against libnm just to parse this. So instead, let's just send what + * it needs. + */ + g_dbus_method_invocation_return_value ( + priv->pending_secrets_context, + g_variant_new ("(ss)", username ? username : "", password ? password : "")); + + out: + priv->pending_secrets_context = NULL; + priv->secrets_id = NULL; + priv->secrets_setting_name = NULL; +} + +static void +impl_ppp_manager_need_secrets (NMPPPManager *manager, + GDBusMethodInvocation *context) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + NMConnection *applied_connection; + const char *username = NULL; + const char *password = NULL; + guint32 tries; + GPtrArray *hints = NULL; + GError *error = NULL; + NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; + + nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (priv->act_req)); + + applied_connection = nm_act_request_get_applied_connection (priv->act_req); + + priv->secrets_setting_name = nm_connection_need_secrets (applied_connection, &hints); + if (!priv->secrets_setting_name) { + /* Use existing secrets from the connection */ + if (extract_details_from_connection (applied_connection, NULL, &username, &password, &error)) { + /* Send existing secrets to the PPP plugin */ + priv->pending_secrets_context = context; + ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, manager); + } else { + _LOGW ("%s", error->message); + g_dbus_method_invocation_take_error (priv->pending_secrets_context, error); + } + return; + } + + /* Only ask for completely new secrets after retrying them once; some devices + * appear to ask a few times when they actually don't even care what you + * pass back. + */ + tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES)); + if (tries > 1) + flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; + + priv->secrets_id = nm_act_request_get_secrets (priv->act_req, + FALSE, + priv->secrets_setting_name, + flags, + hints ? g_ptr_array_index (hints, 0) : NULL, + ppp_secrets_cb, + manager); + g_object_set_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES, GUINT_TO_POINTER (++tries)); + priv->pending_secrets_context = context; + + if (hints) + g_ptr_array_free (hints, TRUE); +} + +static void +impl_ppp_manager_set_state (NMPPPManager *manager, + GDBusMethodInvocation *context, + guint32 state) +{ + g_signal_emit (manager, signals[STATE_CHANGED], 0, state); + + g_dbus_method_invocation_return_value (context, NULL); +} + +static gboolean +set_ip_config_common (NMPPPManager *self, + GVariant *config_dict, + const char *iface_prop, + guint32 *out_mtu) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); + NMConnection *applied_connection; + NMSettingPpp *s_ppp; + const char *iface; + + if (!g_variant_lookup (config_dict, iface_prop, "&s", &iface)) { + _LOGE ("no interface received!"); + return FALSE; + } + if (priv->ip_iface == NULL) + priv->ip_iface = g_strdup (iface); + + /* Got successful IP config; obviously the secrets worked */ + applied_connection = nm_act_request_get_applied_connection (priv->act_req); + g_object_set_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES, NULL); + + if (out_mtu) { + /* Get any custom MTU */ + s_ppp = nm_connection_get_setting_ppp (applied_connection); + *out_mtu = s_ppp ? nm_setting_ppp_get_mtu (s_ppp) : 0; + } + + monitor_stats (self); + return TRUE; +} + +static void +impl_ppp_manager_set_ip4_config (NMPPPManager *manager, + GDBusMethodInvocation *context, + GVariant *config_dict) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + NMIP4Config *config; + NMPlatformIP4Address address; + guint32 u32; + GVariantIter *iter; + + _LOGI ("(IPv4 Config Get) reply received."); + + remove_timeout_handler (manager); + + config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface)); + + memset (&address, 0, sizeof (address)); + address.plen = 32; + + if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_ADDRESS, "u", &u32)) + address.address = u32; + + if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_GATEWAY, "u", &u32)) { + nm_ip4_config_set_gateway (config, u32); + address.peer_address = u32; + } else + address.peer_address = address.address; + + if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_PREFIX, "u", &u32)) + address.plen = u32; + + if (address.address && address.plen && address.plen <= 32) { + address.addr_source = NM_IP_CONFIG_SOURCE_PPP; + nm_ip4_config_add_address (config, &address); + } else { + _LOGE ("invalid IPv4 address received!"); + goto out; + } + + 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); + } + + 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_dict, NM_PPP_IP4_CONFIG_INTERFACE, &u32)) + goto out; + + 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); + 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 (GVariant *dict, + const char *prop, + struct in6_addr *out_addr, + NMUtilsIPv6IfaceId *out_iid) +{ + guint64 iid; + + if (!g_variant_lookup (dict, prop, "t", &iid)) { + _LOGD ("pppd plugin property '%s' missing or not a uint64", prop); + return FALSE; + } + g_return_val_if_fail (iid != 0, FALSE); + + /* Construct an IPv6 LL address from the interface identifier. See + * http://tools.ietf.org/html/rfc4291#section-2.5.1 (IPv6) and + * http://tools.ietf.org/html/rfc5072#section-4.1 (IPv6 over PPP). + */ + memset (out_addr->s6_addr, 0, sizeof (out_addr->s6_addr)); + out_addr->s6_addr16[0] = htons (0xfe80); + memcpy (out_addr->s6_addr + 8, &iid, sizeof (iid)); + if (out_iid) + nm_utils_ipv6_interface_identifier_get_from_addr (out_iid, out_addr); + return TRUE; +} + +static void +impl_ppp_manager_set_ip6_config (NMPPPManager *manager, + GDBusMethodInvocation *context, + GVariant *config_dict) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + NMIP6Config *config; + NMPlatformIP6Address addr; + struct in6_addr a; + NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT; + gboolean has_peer = FALSE; + + _LOGI ("(IPv6 Config Get) reply received."); + + remove_timeout_handler (manager); + + config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface)); + + memset (&addr, 0, sizeof (addr)); + addr.plen = 64; + + 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; + has_peer = TRUE; + } + + if (iid_value_to_ll6_addr (config_dict, NM_PPP_IP6_CONFIG_OUR_IID, &addr.address, &iid)) { + if (!has_peer) + addr.peer_address = addr.address; + nm_ip6_config_add_address (config, &addr); + + 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); + } + } else + _LOGE ("invalid IPv6 address received!"); + + g_object_unref (config); + g_dbus_method_invocation_return_value (context, NULL); +} + +/*****************************************************************************/ + +typedef struct { + GPtrArray *array; + GStringChunk *chunk; +} NMCmdLine; + +static NMCmdLine * +nm_cmd_line_new (void) +{ + NMCmdLine *cmd; + + cmd = g_slice_new (NMCmdLine); + cmd->array = g_ptr_array_new (); + cmd->chunk = g_string_chunk_new (1024); + + return cmd; +} + +static void +nm_cmd_line_destroy (NMCmdLine *cmd) +{ + g_ptr_array_free (cmd->array, TRUE); + g_string_chunk_free (cmd->chunk); + g_slice_free (NMCmdLine, cmd); +} + +static char * +nm_cmd_line_to_str (NMCmdLine *cmd) +{ + char *str; + + g_ptr_array_add (cmd->array, NULL); + str = g_strjoinv (" ", (gchar **) cmd->array->pdata); + g_ptr_array_remove_index (cmd->array, cmd->array->len - 1); + + return str; +} + +static void +nm_cmd_line_add_string (NMCmdLine *cmd, const char *str) +{ + g_ptr_array_add (cmd->array, g_string_chunk_insert (cmd->chunk, str)); +} + +static void +nm_cmd_line_add_int (NMCmdLine *cmd, int i) +{ + char *str; + + str = g_strdup_printf ("%d", i); + nm_cmd_line_add_string (cmd, str); + g_free (str); +} + +/*****************************************************************************/ + +static void +ppp_exit_code (guint pppd_exit_status, GPid pid) +{ + const char *msg; + + switch (pppd_exit_status) { + case 1: + msg = "Fatal pppd error"; + break; + case 2: + msg = "pppd options error"; + break; + case 3: + msg = "No root priv error"; + break; + case 4: + msg = "No ppp module error"; + break; + case 5: + msg = "pppd received a signal"; + break; + case 6: + msg = "Serial port lock failed"; + break; + case 7: + msg = "Serial port open failed"; + break; + case 8: + msg = "Connect script failed"; + break; + case 9: + msg = "Pty program error"; + break; + case 10: + msg = "PPP negotiation failed"; + break; + case 11: + msg = "Peer didn't authenticatie itself"; + break; + case 12: + msg = "Link idle: Idle Seconds reached."; + break; + case 13: + msg = "Connect time limit reached."; + break; + case 14: + msg = "Callback negotiated, call should come back."; + break; + case 15: + msg = "Lack of LCP echo responses"; + break; + case 16: + msg = "A modem hung up the phone"; + break; + case 17: + msg = "Loopback detected"; + break; + case 18: + msg = "The init script failed"; + break; + case 19: + msg = "Authentication error.\n" + "We failed to authenticate ourselves to the peer.\n" + "Maybe bad account or password?"; + break; + default: + msg = "Unknown error"; + } + + _LOGW ("pppd pid %d exited with error: %s", pid, msg); +} + +static void +ppp_watch_cb (GPid pid, gint status, gpointer user_data) +{ + NMPPPManager *manager = NM_PPP_MANAGER (user_data); + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + guint err; + + g_assert (pid == priv->pid); + + if (WIFEXITED (status)) { + err = WEXITSTATUS (status); + if (err != 0) + ppp_exit_code (err, priv->pid); + } else if (WIFSTOPPED (status)) { + _LOGI ("pppd pid %d stopped unexpectedly with signal %d", priv->pid, WSTOPSIG (status)); + } else if (WIFSIGNALED (status)) { + _LOGI ("pppd pid %d died with signal %d", priv->pid, WTERMSIG (status)); + } else + _LOGI ("pppd pid %d died from an unknown cause", priv->pid); + + _LOGD ("pppd pid %d cleaned up", priv->pid); + priv->pid = 0; + priv->ppp_watch_id = 0; + g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD); +} + +static gboolean +pppd_timed_out (gpointer data) +{ + NMPPPManager *manager = NM_PPP_MANAGER (data); + + _LOGW ("pppd timed out or didn't initialize our dbus module"); + _ppp_cleanup (manager); + _ppp_kill (manager); + + g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD); + + return FALSE; +} + +static NMCmdLine * +create_pppd_cmd_line (NMPPPManager *self, + NMSettingPpp *setting, + NMSettingPppoe *pppoe, + NMSettingAdsl *adsl, + const char *ppp_name, + guint baud_override, + GError **err) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); + const char *pppd_binary = NULL; + NMCmdLine *cmd; + gboolean ppp_debug; + + g_return_val_if_fail (setting != NULL, NULL); + + pppd_binary = nm_utils_find_helper ("pppd", NULL, err); + if (!pppd_binary) + return NULL; + + /* Create pppd command line */ + cmd = nm_cmd_line_new (); + nm_cmd_line_add_string (cmd, pppd_binary); + + nm_cmd_line_add_string (cmd, "nodetach"); + nm_cmd_line_add_string (cmd, "lock"); + + /* NM handles setting the default route */ + nm_cmd_line_add_string (cmd, "nodefaultroute"); + + /* Allow IPv6 to be configured by IPV6CP */ + nm_cmd_line_add_string (cmd, "ipv6"); + nm_cmd_line_add_string (cmd, ","); + + ppp_debug = !!getenv ("NM_PPP_DEBUG"); + if (nm_logging_enabled (LOGL_DEBUG, LOGD_PPP)) + ppp_debug = TRUE; + + if (ppp_debug) + nm_cmd_line_add_string (cmd, "debug"); + + if (ppp_name) { + nm_cmd_line_add_string (cmd, "user"); + nm_cmd_line_add_string (cmd, ppp_name); + } + + if (pppoe) { + char *dev_str; + const char *pppoe_service; + + nm_cmd_line_add_string (cmd, "plugin"); + nm_cmd_line_add_string (cmd, "rp-pppoe.so"); + + dev_str = g_strdup_printf ("nic-%s", priv->parent_iface); + nm_cmd_line_add_string (cmd, dev_str); + g_free (dev_str); + + pppoe_service = nm_setting_pppoe_get_service (pppoe); + if (pppoe_service) { + nm_cmd_line_add_string (cmd, "rp_pppoe_service"); + nm_cmd_line_add_string (cmd, pppoe_service); + } + } else if (adsl) { + const gchar *protocol = nm_setting_adsl_get_protocol (adsl); + + if (!strcmp (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA)) { + guint32 vpi = nm_setting_adsl_get_vpi (adsl); + guint32 vci = nm_setting_adsl_get_vci (adsl); + const char *encaps = nm_setting_adsl_get_encapsulation (adsl); + gchar *vpivci; + + nm_cmd_line_add_string (cmd, "plugin"); + nm_cmd_line_add_string (cmd, "pppoatm.so"); + + vpivci = g_strdup_printf("%d.%d", vpi, vci); + nm_cmd_line_add_string (cmd, vpivci); + g_free (vpivci); + + if (g_strcmp0 (encaps, NM_SETTING_ADSL_ENCAPSULATION_LLC) == 0) + nm_cmd_line_add_string (cmd, "llc-encaps"); + else /*if (g_strcmp0 (encaps, NM_SETTING_ADSL_ENCAPSULATION_VCMUX) == 0)*/ + nm_cmd_line_add_string (cmd, "vc-encaps"); + + } else if (!strcmp (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) { + nm_cmd_line_add_string (cmd, "plugin"); + nm_cmd_line_add_string (cmd, "rp-pppoe.so"); + nm_cmd_line_add_string (cmd, priv->parent_iface); + } + + nm_cmd_line_add_string (cmd, "noipdefault"); + } else { + nm_cmd_line_add_string (cmd, priv->parent_iface); + /* Don't send some random address as the local address */ + nm_cmd_line_add_string (cmd, "noipdefault"); + } + + if (nm_setting_ppp_get_baud (setting)) + nm_cmd_line_add_int (cmd, nm_setting_ppp_get_baud (setting)); + else if (baud_override) + nm_cmd_line_add_int (cmd, (int) baud_override); + + /* noauth by default, because we certainly don't have any information + * with which to verify anything the peer gives us if we ask it to + * authenticate itself, which is what 'auth' really means. + */ + nm_cmd_line_add_string (cmd, "noauth"); + + if (nm_setting_ppp_get_refuse_eap (setting)) + nm_cmd_line_add_string (cmd, "refuse-eap"); + if (nm_setting_ppp_get_refuse_pap (setting)) + nm_cmd_line_add_string (cmd, "refuse-pap"); + if (nm_setting_ppp_get_refuse_chap (setting)) + nm_cmd_line_add_string (cmd, "refuse-chap"); + if (nm_setting_ppp_get_refuse_mschap (setting)) + nm_cmd_line_add_string (cmd, "refuse-mschap"); + if (nm_setting_ppp_get_refuse_mschapv2 (setting)) + nm_cmd_line_add_string (cmd, "refuse-mschap-v2"); + if (nm_setting_ppp_get_nobsdcomp (setting)) + nm_cmd_line_add_string (cmd, "nobsdcomp"); + if (nm_setting_ppp_get_no_vj_comp (setting)) + nm_cmd_line_add_string (cmd, "novj"); + if (nm_setting_ppp_get_nodeflate (setting)) + nm_cmd_line_add_string (cmd, "nodeflate"); + if (nm_setting_ppp_get_require_mppe (setting)) + nm_cmd_line_add_string (cmd, "require-mppe"); + if (nm_setting_ppp_get_require_mppe_128 (setting)) + nm_cmd_line_add_string (cmd, "require-mppe-128"); + if (nm_setting_ppp_get_mppe_stateful (setting)) + nm_cmd_line_add_string (cmd, "mppe-stateful"); + if (nm_setting_ppp_get_crtscts (setting)) + nm_cmd_line_add_string (cmd, "crtscts"); + + /* Always ask for DNS, we don't have to use them if the connection + * overrides the returned servers. + */ + nm_cmd_line_add_string (cmd, "usepeerdns"); + + if (nm_setting_ppp_get_mru (setting)) { + nm_cmd_line_add_string (cmd, "mru"); + nm_cmd_line_add_int (cmd, nm_setting_ppp_get_mru (setting)); + } + + if (nm_setting_ppp_get_mtu (setting)) { + nm_cmd_line_add_string (cmd, "mtu"); + nm_cmd_line_add_int (cmd, nm_setting_ppp_get_mtu (setting)); + } + + nm_cmd_line_add_string (cmd, "lcp-echo-failure"); + nm_cmd_line_add_int (cmd, nm_setting_ppp_get_lcp_echo_failure (setting)); + + nm_cmd_line_add_string (cmd, "lcp-echo-interval"); + nm_cmd_line_add_int (cmd, nm_setting_ppp_get_lcp_echo_interval (setting)); + + /* Avoid pppd to exit if no traffic going through */ + nm_cmd_line_add_string (cmd, "idle"); + nm_cmd_line_add_int (cmd, 0); + + nm_cmd_line_add_string (cmd, "ipparam"); + nm_cmd_line_add_string (cmd, nm_exported_object_get_path (NM_EXPORTED_OBJECT (self))); + + nm_cmd_line_add_string (cmd, "plugin"); + nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN); + + return cmd; +} + +static void +pppoe_fill_defaults (NMSettingPpp *setting) +{ + if (!nm_setting_ppp_get_mtu (setting)) + g_object_set (setting, NM_SETTING_PPP_MTU, (guint32) 1492, NULL); + + if (!nm_setting_ppp_get_mru (setting)) + g_object_set (setting, NM_SETTING_PPP_MRU, (guint32) 1492, NULL); + + g_object_set (setting, + NM_SETTING_PPP_NOAUTH, TRUE, + NM_SETTING_PPP_NODEFLATE, TRUE, + NULL); + + /* FIXME: These commented settings should be set as well, update NMSettingPpp first. */ +#if 0 + setting->noipdefault = TRUE; + setting->default_asyncmap = TRUE; + setting->defaultroute = TRUE; + setting->hide_password = TRUE; + setting->noaccomp = TRUE; + setting->nopcomp = TRUE; + setting->novj = TRUE; + setting->novjccomp = TRUE; +#endif +} + +static gboolean +_ppp_manager_start (NMPPPManager *manager, + NMActRequest *req, + const char *ppp_name, + guint32 timeout_secs, + guint baud_override, + GError **err) +{ + NMPPPManagerPrivate *priv; + NMConnection *connection; + NMSettingPpp *s_ppp; + gs_unref_object NMSettingPpp *s_ppp_free = NULL; + NMSettingPppoe *pppoe_setting; + NMSettingAdsl *adsl_setting; + NMCmdLine *ppp_cmd; + char *cmd_str; + struct stat st; + + g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE); + g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE); + + priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + +#if !WITH_PPP + /* PPP support disabled */ + g_set_error_literal (err, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "PPP support is not enabled."); + return FALSE; +#endif + + nm_exported_object_export (NM_EXPORTED_OBJECT (manager)); + + priv->pid = 0; + + /* Make sure /dev/ppp exists (bgo #533064) */ + if (stat ("/dev/ppp", &st) || !S_ISCHR (st.st_mode)) + nm_utils_modprobe (NULL, FALSE, "ppp_generic", NULL); + + connection = nm_act_request_get_applied_connection (req); + g_return_val_if_fail (connection, FALSE); + + s_ppp = nm_connection_get_setting_ppp (connection); + if (!s_ppp) { + /* If the PPP settings are all default we may not have a PPP setting yet, + * so just make a default one here. + */ + s_ppp = s_ppp_free = NM_SETTING_PPP (nm_setting_ppp_new ()); + } + + pppoe_setting = nm_connection_get_setting_pppoe (connection); + if (pppoe_setting) { + /* We can't modify the applied connection's setting, make a copy */ + if (!s_ppp_free) + s_ppp = s_ppp_free = NM_SETTING_PPP (nm_setting_duplicate ((NMSetting *) s_ppp)); + pppoe_fill_defaults (s_ppp); + } + + adsl_setting = (NMSettingAdsl *) nm_connection_get_setting (connection, NM_TYPE_SETTING_ADSL); + + ppp_cmd = create_pppd_cmd_line (manager, s_ppp, pppoe_setting, adsl_setting, ppp_name, baud_override, err); + if (!ppp_cmd) + goto out; + + g_ptr_array_add (ppp_cmd->array, NULL); + + _LOGI ("starting PPP connection"); + + cmd_str = nm_cmd_line_to_str (ppp_cmd); + _LOGD ("command line: %s", cmd_str); + g_free (cmd_str); + + priv->pid = 0; + if (!g_spawn_async (NULL, (char **) ppp_cmd->array->pdata, NULL, + G_SPAWN_DO_NOT_REAP_CHILD, + nm_utils_setpgid, NULL, + &priv->pid, err)) { + goto out; + } + + _LOGI ("pppd started with pid %d", priv->pid); + + priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, manager); + priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, manager); + priv->act_req = g_object_ref (req); + +out: + if (ppp_cmd) + nm_cmd_line_destroy (ppp_cmd); + + if (priv->pid <= 0) + nm_exported_object_unexport (NM_EXPORTED_OBJECT (manager)); + + return priv->pid > 0; +} + +static void +_ppp_kill (NMPPPManager *manager) +{ + NMPPPManagerPrivate *priv; + + g_return_if_fail (NM_IS_PPP_MANAGER (manager)); + + priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + + if (priv->pid) { + nm_utils_kill_child_async (priv->pid, SIGTERM, LOGD_PPP, "pppd", 2000, NULL, NULL); + priv->pid = 0; + } +} + +static void +_ppp_cleanup (NMPPPManager *manager) +{ + NMPPPManagerPrivate *priv; + + g_return_if_fail (NM_IS_PPP_MANAGER (manager)); + + priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + + cancel_get_secrets (manager); + + nm_clear_g_source (&priv->monitor_id); + + if (priv->monitor_fd >= 0) { + /* Get the stats one last time */ + monitor_cb (manager); + close (priv->monitor_fd); + priv->monitor_fd = -1; + } + + nm_clear_g_source (&priv->ppp_timeout_handler); + nm_clear_g_source (&priv->ppp_watch_id); +} + +/*****************************************************************************/ + +typedef struct { + NMPPPManager *manager; + GSimpleAsyncResult *result; + GCancellable *cancellable; +} StopContext; + +static void +stop_context_complete (StopContext *ctx) +{ + if (ctx->cancellable) + g_object_unref (ctx->cancellable); + g_simple_async_result_complete_in_idle (ctx->result); + g_object_unref (ctx->result); + g_object_unref (ctx->manager); + g_slice_free (StopContext, ctx); +} + +static gboolean +stop_context_complete_if_cancelled (StopContext *ctx) +{ + GError *error = NULL; + + if (g_cancellable_set_error_if_cancelled (ctx->cancellable, &error)) { + g_simple_async_result_take_error (ctx->result, error); + stop_context_complete (ctx); + return TRUE; + } + return FALSE; +} + +static gboolean +_ppp_manager_stop_finish (NMPPPManager *manager, + GAsyncResult *res, + GError **error) +{ + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); +} + +static void +kill_child_ready (pid_t pid, + gboolean success, + int child_status, + StopContext *ctx) +{ + if (stop_context_complete_if_cancelled (ctx)) + return; + stop_context_complete (ctx); +} + +static void +_ppp_manager_stop_async (NMPPPManager *manager, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager); + StopContext *ctx; + + nm_exported_object_unexport (NM_EXPORTED_OBJECT (manager)); + + ctx = g_slice_new0 (StopContext); + ctx->manager = g_object_ref (manager); + ctx->result = g_simple_async_result_new (G_OBJECT (manager), + callback, + user_data, + _ppp_manager_stop_async); + + /* Setup cancellable */ + ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL; + if (stop_context_complete_if_cancelled (ctx)) + return; + + /* Cleanup internals */ + _ppp_cleanup (manager); + + /* If no pppd running, we're done */ + if (!priv->pid) { + stop_context_complete (ctx); + return; + } + + /* No cancellable operation, so just wait until it returns always */ + nm_utils_kill_child_async (priv->pid, + SIGTERM, + LOGD_PPP, + "pppd", + 2000, + (NMUtilsKillChildAsyncCb) kill_child_ready, + ctx); + priv->pid = 0; +} + +static void +_ppp_manager_stop_sync (NMPPPManager *manager) +{ + NMExportedObject *exported = NM_EXPORTED_OBJECT (manager); + + if (nm_exported_object_is_exported (exported)) + nm_exported_object_unexport (exported); + + _ppp_cleanup (manager); + _ppp_kill (manager); +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE ((NMPPPManager *) object); + + switch (prop_id) { + case PROP_PARENT_IFACE: + g_value_set_string (value, priv->parent_iface); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE ((NMPPPManager *) object); + + switch (prop_id) { + case PROP_PARENT_IFACE: + g_free (priv->parent_iface); + priv->parent_iface = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_ppp_manager_init (NMPPPManager *manager) +{ + NM_PPP_MANAGER_GET_PRIVATE (manager)->monitor_fd = -1; +} + +static NMPPPManager * +_ppp_manager_new (const char *iface) +{ + g_return_val_if_fail (iface != NULL, NULL); + + return (NMPPPManager *) g_object_new (NM_TYPE_PPP_MANAGER, + NM_PPP_MANAGER_PARENT_IFACE, iface, + NULL); +} + +static void +dispose (GObject *object) +{ + NMPPPManager *self = (NMPPPManager *) object; + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); + + _ppp_cleanup (self); + _ppp_kill (self); + + g_clear_object (&priv->act_req); + + G_OBJECT_CLASS (nm_ppp_manager_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE ((NMPPPManager *) object); + + g_free (priv->ip_iface); + g_free (priv->parent_iface); + + G_OBJECT_CLASS (nm_ppp_manager_parent_class)->finalize (object); +} + +static void +nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (manager_class); + NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (manager_class); + + object_class->dispose = dispose; + object_class->finalize = finalize; + object_class->get_property = get_property; + object_class->set_property = set_property; + + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/PPP"); + + obj_properties[PROP_PARENT_IFACE] = + g_param_spec_string (NM_PPP_MANAGER_PARENT_IFACE, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + signals[STATE_CHANGED] = + g_signal_new (NM_PPP_MANAGER_SIGNAL_STATE_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, + G_TYPE_UINT); + + signals[IP4_CONFIG] = + g_signal_new (NM_PPP_MANAGER_SIGNAL_IP4_CONFIG, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_STRING, + G_TYPE_OBJECT); + + signals[IP6_CONFIG] = + g_signal_new (NM_PPP_MANAGER_SIGNAL_IP6_CONFIG, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_OBJECT); + + signals[STATS] = + g_signal_new (NM_PPP_MANAGER_SIGNAL_STATS, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); + + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class), + 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); +} + +NMPPPOps ppp_ops = { + .create = _ppp_manager_new, + .start = _ppp_manager_start, + .stop_async = _ppp_manager_stop_async, + .stop_finish = _ppp_manager_stop_finish, + .stop_sync = _ppp_manager_stop_sync, +}; diff --git a/src/ppp/nm-ppp-manager.h b/src/ppp/nm-ppp-manager.h new file mode 100644 index 00000000..b1a7bb60 --- /dev/null +++ b/src/ppp/nm-ppp-manager.h @@ -0,0 +1,34 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2016 Red Hat, Inc. + */ + +#ifndef __NM_PPP_MANAGER_H__ +#define __NM_PPP_MANAGER_H__ + +#define NM_PPP_MANAGER_PARENT_IFACE "parent-iface" + +#define NM_PPP_MANAGER_SIGNAL_STATE_CHANGED "state-changed" +#define NM_PPP_MANAGER_SIGNAL_IP4_CONFIG "ip4-config" +#define NM_PPP_MANAGER_SIGNAL_IP6_CONFIG "ip6-config" +#define NM_PPP_MANAGER_SIGNAL_STATS "stats" + +typedef struct _NMPPPManager NMPPPManager; + +#endif /* __NM_PPP_MANAGER_H__ */ diff --git a/src/ppp/nm-ppp-plugin-api.h b/src/ppp/nm-ppp-plugin-api.h new file mode 100644 index 00000000..0a38fe05 --- /dev/null +++ b/src/ppp/nm-ppp-plugin-api.h @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2016 Red Hat, Inc. + */ + +#ifndef __NM_PPP_PLUGIN_API_H__ +#define __NM_PPP_PLUGIN_API_H__ + +typedef const struct { + NMPPPManager *(*create) (const char *iface); + + gboolean (*start) (NMPPPManager *manager, + NMActRequest *req, + const char *ppp_name, + guint32 timeout_secs, + guint baud_override, + GError **err); + + void (*stop_async) (NMPPPManager *manager, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + gboolean (*stop_finish) (NMPPPManager *manager, + GAsyncResult *res, + GError **error); + + void (*stop_sync) (NMPPPManager *manager); +} NMPPPOps; + +#endif /* __NM_PPP_PLUGIN_API_H__ */ diff --git a/src/ppp/nm-ppp-plugin.ver b/src/ppp/nm-ppp-plugin.ver new file mode 100644 index 00000000..fee55787 --- /dev/null +++ b/src/ppp/nm-ppp-plugin.ver @@ -0,0 +1,6 @@ +{ +global: + ppp_ops; +local: + *; +}; diff --git a/src/ppp/nm-ppp-status.h b/src/ppp/nm-ppp-status.h new file mode 100644 index 00000000..d785cc2c --- /dev/null +++ b/src/ppp/nm-ppp-status.h @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008-2016 Red Hat, Inc. + */ + +#ifndef __NM_PPP_STATUS_H__ +#define __NM_PPP_STATUS_H__ + +typedef enum { + NM_PPP_STATUS_UNKNOWN, + + NM_PPP_STATUS_DEAD, + NM_PPP_STATUS_INITIALIZE, + NM_PPP_STATUS_SERIALCONN, + NM_PPP_STATUS_DORMANT, + NM_PPP_STATUS_ESTABLISH, + NM_PPP_STATUS_AUTHENTICATE, + NM_PPP_STATUS_CALLBACK, + NM_PPP_STATUS_NETWORK, + NM_PPP_STATUS_RUNNING, + NM_PPP_STATUS_TERMINATE, + NM_PPP_STATUS_DISCONNECT, + NM_PPP_STATUS_HOLDOFF, + NM_PPP_STATUS_MASTER +} NMPPPStatus; + +#endif /* __NM_PPP_STATUS_H__ */ diff --git a/src/ppp/nm-pppd-plugin.c b/src/ppp/nm-pppd-plugin.c new file mode 100644 index 00000000..9c47c339 --- /dev/null +++ b/src/ppp/nm-pppd-plugin.c @@ -0,0 +1,417 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 Red Hat, Inc. + */ + +#include +#define ___CONFIG_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define INET6 +#include +#include + +#include "nm-default.h" +#include "nm-dbus-interface.h" +#include "nm-pppd-plugin.h" +#include "nm-ppp-status.h" + +int plugin_init (void); + +char pppd_version[] = VERSION; + +static GDBusProxy *proxy = NULL; + +static void +nm_phasechange (void *data, int arg) +{ + NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN; + char *ppp_phase; + + g_return_if_fail (G_IS_DBUS_PROXY (proxy)); + + switch (arg) { + case PHASE_DEAD: + ppp_status = NM_PPP_STATUS_DEAD; + ppp_phase = "dead"; + break; + case PHASE_INITIALIZE: + ppp_status = NM_PPP_STATUS_INITIALIZE; + ppp_phase = "initialize"; + break; + case PHASE_SERIALCONN: + ppp_status = NM_PPP_STATUS_SERIALCONN; + ppp_phase = "serial connection"; + break; + case PHASE_DORMANT: + ppp_status = NM_PPP_STATUS_DORMANT; + ppp_phase = "dormant"; + break; + case PHASE_ESTABLISH: + ppp_status = NM_PPP_STATUS_ESTABLISH; + ppp_phase = "establish"; + break; + case PHASE_AUTHENTICATE: + ppp_status = NM_PPP_STATUS_AUTHENTICATE; + ppp_phase = "authenticate"; + break; + case PHASE_CALLBACK: + ppp_status = NM_PPP_STATUS_CALLBACK; + ppp_phase = "callback"; + break; + case PHASE_NETWORK: + ppp_status = NM_PPP_STATUS_NETWORK; + ppp_phase = "network"; + break; + case PHASE_RUNNING: + ppp_status = NM_PPP_STATUS_RUNNING; + ppp_phase = "running"; + break; + case PHASE_TERMINATE: + ppp_status = NM_PPP_STATUS_TERMINATE; + ppp_phase = "terminate"; + break; + case PHASE_DISCONNECT: + ppp_status = NM_PPP_STATUS_DISCONNECT; + ppp_phase = "disconnect"; + break; + case PHASE_HOLDOFF: + ppp_status = NM_PPP_STATUS_HOLDOFF; + ppp_phase = "holdoff"; + break; + case PHASE_MASTER: + ppp_status = NM_PPP_STATUS_MASTER; + ppp_phase = "master"; + break; + + default: + ppp_phase = "unknown"; + break; + } + + g_message ("nm-ppp-plugin: (%s): status %d / phase '%s'", + __func__, + ppp_status, + ppp_phase); + + if (ppp_status != NM_PPP_STATUS_UNKNOWN) { + g_dbus_proxy_call (proxy, + "SetState", + g_variant_new ("(u)", ppp_status), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + NULL, NULL); + } +} + +static void +nm_ip_up (void *data, int arg) +{ + ipcp_options opts = ipcp_gotoptions[0]; + ipcp_options peer_opts = ipcp_hisoptions[0]; + GVariantBuilder builder; + guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit); + + g_return_if_fail (G_IS_DBUS_PROXY (proxy)); + + g_message ("nm-ppp-plugin: (%s): ip-up event", __func__); + + if (!opts.ouraddr) { + g_warning ("nm-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__); + nm_phasechange (NULL, PHASE_DEAD); + return; + } + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_INTERFACE, + g_variant_new_string (ifname)); + + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_ADDRESS, + g_variant_new_uint32 (opts.ouraddr)); + + /* Prefer the peer options remote address first, _unless_ pppd made the + * address up, at which point prefer the local options remote address, + * and if that's not right, use the made-up address as a last resort. + */ + if (peer_opts.hisaddr && (peer_opts.hisaddr != pppd_made_up_address)) { + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_GATEWAY, + g_variant_new_uint32 (peer_opts.hisaddr)); + } else if (opts.hisaddr) { + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_GATEWAY, + g_variant_new_uint32 (opts.hisaddr)); + } else if (peer_opts.hisaddr == pppd_made_up_address) { + /* As a last resort, use the made-up address */ + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_GATEWAY, + g_variant_new_uint32 (peer_opts.ouraddr)); + } + + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_PREFIX, + g_variant_new_uint32 (32)); + + if (opts.dnsaddr[0] || opts.dnsaddr[1]) { + guint32 dns[2]; + int len = 0; + + if (opts.dnsaddr[0]) + dns[len++] = opts.dnsaddr[0]; + if (opts.dnsaddr[1]) + dns[len++] = opts.dnsaddr[1]; + + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_DNS, + g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, + dns, len, sizeof (guint32))); + } + + if (opts.winsaddr[0] || opts.winsaddr[1]) { + guint32 wins[2]; + int len = 0; + + if (opts.winsaddr[0]) + wins[len++] = opts.winsaddr[0]; + if (opts.winsaddr[1]) + wins[len++] = opts.winsaddr[1]; + + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP4_CONFIG_WINS, + g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, + wins, len, sizeof (guint32))); + } + + g_message ("nm-ppp-plugin: (%s): sending IPv4 config to NetworkManager...", __func__); + + g_dbus_proxy_call (proxy, + "SetIp4Config", + g_variant_new ("(a{sv})", &builder), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + NULL, NULL); +} + +static GVariant * +eui64_to_variant (eui64_t eui) +{ + guint64 iid; + + G_STATIC_ASSERT (sizeof (iid) == sizeof (eui)); + + memcpy (&iid, &eui, sizeof (eui)); + return g_variant_new_uint64 (iid); +} + +static void +nm_ip6_up (void *data, int arg) +{ + ipv6cp_options *ho = &ipv6cp_hisoptions[0]; + ipv6cp_options *go = &ipv6cp_gotoptions[0]; + GVariantBuilder builder; + + g_return_if_fail (G_IS_DBUS_PROXY (proxy)); + + g_message ("nm-ppp-plugin: (%s): ip6-up event", __func__); + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP6_CONFIG_INTERFACE, + g_variant_new_string (ifname)); + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP6_CONFIG_OUR_IID, + eui64_to_variant (go->ourid)); + g_variant_builder_add (&builder, "{sv}", + NM_PPP_IP6_CONFIG_PEER_IID, + eui64_to_variant (ho->hisid)); + + /* DNS is done via DHCPv6 or router advertisements */ + + g_message ("nm-ppp-plugin: (%s): sending IPv6 config to NetworkManager...", __func__); + + g_dbus_proxy_call (proxy, + "SetIp6Config", + g_variant_new ("(a{sv})", &builder), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + NULL, NULL); +} + +static int +get_chap_check (void) +{ + return 1; +} + +static int +get_pap_check (void) +{ + return 1; +} + +static int +get_credentials (char *username, char *password) +{ + const char *my_username = NULL; + const char *my_password = NULL; + size_t len; + GVariant *ret; + GError *err = NULL; + + if (!password) { + /* pppd is checking pap support; return 1 for supported */ + g_return_val_if_fail (username, -1); + return 1; + } + + g_return_val_if_fail (username, -1); + g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), -1); + + g_message ("nm-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__); + + ret = g_dbus_proxy_call_sync (proxy, + "NeedSecrets", + NULL, + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, &err); + if (!ret) { + g_warning ("nm-ppp-plugin: (%s): could not get secrets: %s", + __func__, + err->message); + g_error_free (err); + return -1; + } + + g_message ("nm-ppp-plugin: (%s): got credentials from NetworkManager", __func__); + + g_variant_get (ret, "(&s&s)", &my_username, &my_password); + + if (my_username) { + len = strlen (my_username) + 1; + len = len < MAXNAMELEN ? len : MAXNAMELEN; + + strncpy (username, my_username, len); + username[len - 1] = '\0'; + } + + if (my_password) { + len = strlen (my_password) + 1; + len = len < MAXSECRETLEN ? len : MAXSECRETLEN; + + strncpy (password, my_password, len); + password[len - 1] = '\0'; + } + + g_variant_unref (ret); + + return 1; +} + +static void +nm_exit_notify (void *data, int arg) +{ + g_return_if_fail (G_IS_DBUS_PROXY (proxy)); + + g_message ("nm-ppp-plugin: (%s): cleaning up", __func__); + + g_object_unref (proxy); + proxy = NULL; +} + +static void +add_ip6_notifier (void) +{ + static struct notifier **notifier = NULL; + static gsize load_once = 0; + + if (g_once_init_enter (&load_once)) { + void *handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); + + if (handle) { + notifier = dlsym (handle, "ipv6_up_notifier"); + dlclose (handle); + } + g_once_init_leave (&load_once, 1); + } + if (notifier) + add_notifier (notifier, nm_ip6_up, NULL); + else + g_message ("nm-ppp-plugin: no IPV6CP notifier support; IPv6 not available"); +} + +int +plugin_init (void) +{ + GDBusConnection *bus; + GError *err = NULL; + + nm_g_type_init (); + + g_message ("nm-ppp-plugin: (%s): initializing", __func__); + + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err); + if (!bus) { + g_warning ("nm-pppd-plugin: (%s): couldn't connect to system bus: %s", + __func__, err->message); + g_error_free (err); + return -1; + } + + /* NM passes in the object path of the corresponding PPPManager + * object as the 'ipparam' argument to pppd. + */ + proxy = g_dbus_proxy_new_sync (bus, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + NM_DBUS_SERVICE, + ipparam, + NM_DBUS_INTERFACE_PPP, + NULL, &err); + g_object_unref (bus); + + if (!proxy) { + g_warning ("nm-pppd-plugin: (%s): couldn't create D-Bus proxy: %s", + __func__, err->message); + g_error_free (err); + return -1; + } + + chap_passwd_hook = get_credentials; + chap_check_hook = get_chap_check; + pap_passwd_hook = get_credentials; + pap_check_hook = get_pap_check; + + add_notifier (&phasechange, nm_phasechange, NULL); + add_notifier (&ip_up_notifier, nm_ip_up, NULL); + add_notifier (&exitnotify, nm_exit_notify, proxy); + add_ip6_notifier (); + + return 0; +} diff --git a/src/ppp/nm-pppd-plugin.h b/src/ppp/nm-pppd-plugin.h new file mode 100644 index 00000000..1a2ea09e --- /dev/null +++ b/src/ppp/nm-pppd-plugin.h @@ -0,0 +1,34 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2014 Red Hat, Inc. + */ + +#define NM_DBUS_INTERFACE_PPP "org.freedesktop.NetworkManager.PPP" + +#define NM_PPP_IP4_CONFIG_INTERFACE "interface" +#define NM_PPP_IP4_CONFIG_ADDRESS "address" +#define NM_PPP_IP4_CONFIG_PREFIX "prefix" +#define NM_PPP_IP4_CONFIG_GATEWAY "gateway" +#define NM_PPP_IP4_CONFIG_DNS "dns" +#define NM_PPP_IP4_CONFIG_WINS "wins" + +#define NM_PPP_IP6_CONFIG_INTERFACE "interface" +#define NM_PPP_IP6_CONFIG_OUR_IID "our-iid" +#define NM_PPP_IP6_CONFIG_PEER_IID "peer-iid" + diff --git a/src/rdisc/Makefile.am b/src/rdisc/Makefile.am deleted file mode 100644 index 3c6155b9..00000000 --- a/src/rdisc/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = tests diff --git a/src/rdisc/Makefile.in b/src/rdisc/Makefile.in deleted file mode 100644 index 719ce8a2..00000000 --- a/src/rdisc/Makefile.in +++ /dev/null @@ -1,781 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/rdisc -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = tests -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/rdisc/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/rdisc/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/rdisc/nm-fake-rdisc.c b/src/rdisc/nm-fake-rdisc.c deleted file mode 100644 index 46f2b08c..00000000 --- a/src/rdisc/nm-fake-rdisc.c +++ /dev/null @@ -1,396 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-fake-rdisc.c - Fake implementation of router discovery - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-fake-rdisc.h" -#include "nm-rdisc-private.h" - -#define _NMLOG_PREFIX_NAME "rdisc-fake" - -typedef struct { - guint id; - guint when; - - NMRDiscDHCPLevel dhcp_level; - GArray *gateways; - GArray *prefixes; - GArray *dns_servers; - GArray *dns_domains; - int hop_limit; - guint32 mtu; -} FakeRa; - -typedef struct { - struct in6_addr network; - int plen; - struct in6_addr gateway; - guint32 timestamp; - guint32 lifetime; - guint32 preferred; - NMRDiscPreference preference; -} FakePrefix; - -typedef struct { - guint receive_ra_id; - GSList *ras; -} NMFakeRDiscPrivate; - -#define NM_FAKE_RDISC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_FAKE_RDISC, NMFakeRDiscPrivate)) - -G_DEFINE_TYPE (NMFakeRDisc, nm_fake_rdisc, NM_TYPE_RDISC) - -enum { - RS_SENT, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -/******************************************************************/ - -static void -fake_ra_free (gpointer data) -{ - FakeRa *ra = data; - - g_array_free (ra->gateways, TRUE); - g_array_free (ra->prefixes, TRUE); - g_array_free (ra->dns_servers, TRUE); - g_array_free (ra->dns_domains, TRUE); - g_free (ra); -} - -static void -ra_dns_domain_free (gpointer data) -{ - g_free (((NMRDiscDNSDomain *)(data))->domain); -} - -static FakeRa * -find_ra (GSList *ras, guint id) -{ - GSList *iter; - - for (iter = ras; iter; iter = iter->next) { - if (((FakeRa *) iter->data)->id == id) - return iter->data; - } - return NULL; -} - -guint -nm_fake_rdisc_add_ra (NMFakeRDisc *self, - guint seconds_after_previous, - NMRDiscDHCPLevel dhcp_level, - int hop_limit, - guint32 mtu) -{ - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (self); - static guint counter = 1; - FakeRa *ra; - - ra = g_malloc0 (sizeof (*ra)); - ra->id = counter++; - ra->when = seconds_after_previous; - ra->dhcp_level = dhcp_level; - ra->hop_limit = hop_limit; - ra->mtu = mtu; - ra->gateways = g_array_new (FALSE, FALSE, sizeof (NMRDiscGateway)); - ra->prefixes = g_array_new (FALSE, FALSE, sizeof (FakePrefix)); - ra->dns_servers = g_array_new (FALSE, FALSE, sizeof (NMRDiscDNSServer)); - ra->dns_domains = g_array_new (FALSE, FALSE, sizeof (NMRDiscDNSDomain)); - g_array_set_clear_func (ra->dns_domains, ra_dns_domain_free); - - priv->ras = g_slist_append (priv->ras, ra); - return ra->id; -} - -void -nm_fake_rdisc_add_gateway (NMFakeRDisc *self, - guint ra_id, - const char *addr, - guint32 timestamp, - guint32 lifetime, - NMRDiscPreference preference) -{ - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (self); - FakeRa *ra = find_ra (priv->ras, ra_id); - NMRDiscGateway *gw; - - g_assert (ra); - g_array_set_size (ra->gateways, ra->gateways->len + 1); - gw = &g_array_index (ra->gateways, NMRDiscGateway, ra->gateways->len - 1); - g_assert (inet_pton (AF_INET6, addr, &gw->address) == 1); - gw->timestamp = timestamp; - gw->lifetime = lifetime; - gw->preference = preference; -} - -void -nm_fake_rdisc_add_prefix (NMFakeRDisc *self, - guint ra_id, - const char *network, - guint plen, - const char *gateway, - guint32 timestamp, - guint32 lifetime, - guint32 preferred, - NMRDiscPreference preference) -{ - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (self); - FakeRa *ra = find_ra (priv->ras, ra_id); - FakePrefix *prefix; - - g_assert (ra); - g_array_set_size (ra->prefixes, ra->prefixes->len + 1); - prefix = &g_array_index (ra->prefixes, FakePrefix, ra->prefixes->len - 1); - memset (prefix, 0, sizeof (*prefix)); - g_assert (inet_pton (AF_INET6, network, &prefix->network) == 1); - g_assert (inet_pton (AF_INET6, gateway, &prefix->gateway) == 1); - prefix->plen = plen; - prefix->timestamp = timestamp; - prefix->lifetime = lifetime; - prefix->preferred = preferred; - prefix->preference = preference; -} - -void -nm_fake_rdisc_add_dns_server (NMFakeRDisc *self, - guint ra_id, - const char *address, - guint32 timestamp, - guint32 lifetime) -{ - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (self); - FakeRa *ra = find_ra (priv->ras, ra_id); - NMRDiscDNSServer *dns; - - g_assert (ra); - g_array_set_size (ra->dns_servers, ra->dns_servers->len + 1); - dns = &g_array_index (ra->dns_servers, NMRDiscDNSServer, ra->dns_servers->len - 1); - g_assert (inet_pton (AF_INET6, address, &dns->address) == 1); - dns->timestamp = timestamp; - dns->lifetime = lifetime; -} - -void -nm_fake_rdisc_add_dns_domain (NMFakeRDisc *self, - guint ra_id, - const char *domain, - guint32 timestamp, - guint32 lifetime) -{ - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (self); - FakeRa *ra = find_ra (priv->ras, ra_id); - NMRDiscDNSDomain *dns; - - g_assert (ra); - g_array_set_size (ra->dns_domains, ra->dns_domains->len + 1); - dns = &g_array_index (ra->dns_domains, NMRDiscDNSDomain, ra->dns_domains->len - 1); - dns->domain = g_strdup (domain); - dns->timestamp = timestamp; - dns->lifetime = lifetime; -} - -gboolean -nm_fake_rdisc_done (NMFakeRDisc *self) -{ - return !NM_FAKE_RDISC_GET_PRIVATE (self)->ras; -} - -/******************************************************************/ - -static gboolean -send_rs (NMRDisc *rdisc, GError **error) -{ - g_signal_emit (rdisc, signals[RS_SENT], 0); - return TRUE; -} - -static gboolean -receive_ra (gpointer user_data) -{ - NMFakeRDisc *self = user_data; - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (self); - NMRDisc *rdisc = NM_RDISC (self); - NMRDiscDataInternal *rdata = rdisc->rdata; - FakeRa *ra = priv->ras->data; - NMRDiscConfigMap changed = 0; - guint32 now = nm_utils_get_monotonic_timestamp_s (); - guint i; - NMRDiscDHCPLevel dhcp_level; - - priv->receive_ra_id = 0; - - /* preserve the "most managed" level on updates. */ - dhcp_level = MAX (rdata->public.dhcp_level, ra->dhcp_level); - - if (rdata->public.dhcp_level != dhcp_level) { - rdata->public.dhcp_level = dhcp_level; - changed |= NM_RDISC_CONFIG_DHCP_LEVEL; - } - - for (i = 0; i < ra->gateways->len; i++) { - NMRDiscGateway *item = &g_array_index (ra->gateways, NMRDiscGateway, i); - - if (nm_rdisc_add_gateway (rdisc, item)) - changed |= NM_RDISC_CONFIG_GATEWAYS; - } - - for (i = 0; i < ra->prefixes->len; i++) { - FakePrefix *item = &g_array_index (ra->prefixes, FakePrefix, i); - NMRDiscRoute route = { - .network = item->network, - .plen = item->plen, - .gateway = item->gateway, - .timestamp = item->timestamp, - .lifetime = item->lifetime, - .preference = item->preference, - }; - - g_assert (route.plen > 0 && route.plen <= 128); - - if (nm_rdisc_add_route (rdisc, &route)) - changed |= NM_RDISC_CONFIG_ROUTES; - - if (item->plen == 64) { - NMRDiscAddress address = { - .address = item->network, - .timestamp = item->timestamp, - .lifetime = item->lifetime, - .preferred = item->preferred, - .dad_counter = 0, - }; - - if (nm_rdisc_complete_and_add_address (rdisc, &address)) - changed |= NM_RDISC_CONFIG_ADDRESSES; - } - } - - for (i = 0; i < ra->dns_servers->len; i++) { - NMRDiscDNSServer *item = &g_array_index (ra->dns_servers, NMRDiscDNSServer, i); - - if (nm_rdisc_add_dns_server (rdisc, item)) - changed |= NM_RDISC_CONFIG_DNS_SERVERS; - } - - for (i = 0; i < ra->dns_domains->len; i++) { - NMRDiscDNSDomain *item = &g_array_index (ra->dns_domains, NMRDiscDNSDomain, i); - - if (nm_rdisc_add_dns_domain (rdisc, item)) - changed |= NM_RDISC_CONFIG_DNS_DOMAINS; - } - - if (rdata->public.mtu != ra->mtu) { - rdata->public.mtu = ra->mtu; - changed |= NM_RDISC_CONFIG_MTU; - } - - if (rdata->public.hop_limit != ra->hop_limit) { - rdata->public.hop_limit = ra->hop_limit; - changed |= NM_RDISC_CONFIG_HOP_LIMIT; - } - - priv->ras = g_slist_remove (priv->ras, priv->ras->data); - fake_ra_free (ra); - - nm_rdisc_ra_received (NM_RDISC (self), now, changed); - - /* Schedule next RA */ - if (priv->ras) { - ra = priv->ras->data; - priv->receive_ra_id = g_timeout_add_seconds (ra->when, receive_ra, self); - } - - return G_SOURCE_REMOVE; -} - -static void -start (NMRDisc *rdisc) -{ - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (rdisc); - FakeRa *ra; - - /* Queue up the first fake RA */ - g_assert (priv->ras); - ra = NM_FAKE_RDISC_GET_PRIVATE (rdisc)->ras->data; - - g_assert (!priv->receive_ra_id); - priv->receive_ra_id = g_timeout_add_seconds (ra->when, receive_ra, rdisc); -} - -void -nm_fake_rdisc_emit_new_ras (NMFakeRDisc *self) -{ - if (!NM_FAKE_RDISC_GET_PRIVATE (self)->receive_ra_id) - start (NM_RDISC (self)); -} - -/******************************************************************/ - -NMRDisc * -nm_fake_rdisc_new (int ifindex, const char *ifname) -{ - return g_object_new (NM_TYPE_FAKE_RDISC, - NM_RDISC_IFINDEX, ifindex, - NM_RDISC_IFNAME, ifname, - NULL); -} - -static void -nm_fake_rdisc_init (NMFakeRDisc *fake_rdisc) -{ -} - -static void -dispose (GObject *object) -{ - NMFakeRDiscPrivate *priv = NM_FAKE_RDISC_GET_PRIVATE (object); - - nm_clear_g_source (&priv->receive_ra_id); - - g_slist_free_full (priv->ras, fake_ra_free); - priv->ras = NULL; - - G_OBJECT_CLASS (nm_fake_rdisc_parent_class)->dispose (object); -} - -static void -nm_fake_rdisc_class_init (NMFakeRDiscClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - NMRDiscClass *rdisc_class = NM_RDISC_CLASS (klass); - - g_type_class_add_private (klass, sizeof (NMFakeRDiscPrivate)); - - object_class->dispose = dispose; - rdisc_class->start = start; - rdisc_class->send_rs = send_rs; - - signals[RS_SENT] = - g_signal_new (NM_FAKE_RDISC_RS_SENT, - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, NULL, - G_TYPE_NONE, 0); -} diff --git a/src/rdisc/nm-fake-rdisc.h b/src/rdisc/nm-fake-rdisc.h deleted file mode 100644 index 1082ba5e..00000000 --- a/src/rdisc/nm-fake-rdisc.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-fake-rdisc.h - Fake implementation of router discovery - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_FAKE_RDISC_H__ -#define __NETWORKMANAGER_FAKE_RDISC_H__ - -#include "nm-rdisc.h" - -#define NM_TYPE_FAKE_RDISC (nm_fake_rdisc_get_type ()) -#define NM_FAKE_RDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_FAKE_RDISC, NMFakeRDisc)) -#define NM_FAKE_RDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_FAKE_RDISC, NMFakeRDiscClass)) -#define NM_IS_FAKE_RDISC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_FAKE_RDISC)) -#define NM_IS_FAKE_RDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_FAKE_RDISC)) -#define NM_FAKE_RDISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_FAKE_RDISC, NMFakeRDiscClass)) - -#define NM_FAKE_RDISC_RS_SENT "rs-sent" - -typedef struct { - NMRDisc parent; -} NMFakeRDisc; - -typedef struct { - NMRDiscClass parent; -} NMFakeRDiscClass; - -/******************************************************************/ - -GType nm_fake_rdisc_get_type (void); - -NMRDisc *nm_fake_rdisc_new (int ifindex, const char *ifname); - -guint nm_fake_rdisc_add_ra (NMFakeRDisc *self, - guint seconds, - NMRDiscDHCPLevel dhcp_level, - int hop_limit, - guint32 mtu); - -void nm_fake_rdisc_add_gateway (NMFakeRDisc *self, - guint ra_id, - const char *addr, - guint32 timestamp, - guint32 lifetime, - NMRDiscPreference preference); - -void nm_fake_rdisc_add_prefix (NMFakeRDisc *self, - guint ra_id, - const char *network, - guint plen, - const char *gateway, - guint32 timestamp, - guint32 lifetime, - guint32 preferred, - NMRDiscPreference preference); - -void nm_fake_rdisc_add_dns_server (NMFakeRDisc *self, - guint ra_id, - const char *address, - guint32 timestamp, - guint32 lifetime); - -void nm_fake_rdisc_add_dns_domain (NMFakeRDisc *self, - guint ra_id, - const char *domain, - guint32 timestamp, - guint32 lifetime); - -void nm_fake_rdisc_emit_new_ras (NMFakeRDisc *self); - -gboolean nm_fake_rdisc_done (NMFakeRDisc *self); - -#endif /* __NETWORKMANAGER_FAKE_RDISC_H__ */ diff --git a/src/rdisc/nm-lndp-rdisc.c b/src/rdisc/nm-lndp-rdisc.c deleted file mode 100644 index db2965b1..00000000 --- a/src/rdisc/nm-lndp-rdisc.c +++ /dev/null @@ -1,434 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-lndp-rdisc.c - Router discovery implementation using libndp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "nm-lndp-rdisc.h" - -#include -#include -/* stdarg.h included because of a bug in ndp.h */ -#include -#include - -#include "nm-rdisc-private.h" -#include "NetworkManagerUtils.h" -#include "nm-platform.h" -#include "nmp-netns.h" - -#define _NMLOG_PREFIX_NAME "rdisc-lndp" - -/*****************************************************************************/ - -typedef struct { - struct ndp *ndp; - - GIOChannel *event_channel; - guint event_id; - guint ra_timeout_id; /* first RA timeout */ -} NMLndpRDiscPrivate; - -/*****************************************************************************/ - -struct _NMLndpRDisc { - NMRDisc parent; - NMLndpRDiscPrivate _priv; -}; - -struct _NMLndpRDiscClass { - NMRDiscClass parent; -}; - -/*****************************************************************************/ - -G_DEFINE_TYPE (NMLndpRDisc, nm_lndp_rdisc, NM_TYPE_RDISC) - -#define NM_LNDP_RDISC_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMLndpRDisc, NM_IS_LNDP_RDISC) - -/*****************************************************************************/ - -static gboolean -send_rs (NMRDisc *rdisc, GError **error) -{ - NMLndpRDiscPrivate *priv = NM_LNDP_RDISC_GET_PRIVATE ((NMLndpRDisc *) rdisc); - struct ndp_msg *msg; - int errsv; - - errsv = ndp_msg_new (&msg, NDP_MSG_RS); - if (errsv) { - errsv = errsv > 0 ? errsv : -errsv; - g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "cannot create router solicitation"); - return FALSE; - } - ndp_msg_ifindex_set (msg, nm_rdisc_get_ifindex (rdisc)); - - errsv = ndp_msg_send (priv->ndp, msg); - ndp_msg_destroy (msg); - if (errsv) { - errsv = errsv > 0 ? errsv : -errsv; - g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "%s (%d)", - g_strerror (errsv), errsv); - return FALSE; - } - - return TRUE; -} - -_NM_UTILS_LOOKUP_DEFINE (static, translate_preference, enum ndp_route_preference, NMRDiscPreference, - NM_UTILS_LOOKUP_DEFAULT (NM_RDISC_PREFERENCE_INVALID), - NM_UTILS_LOOKUP_ITEM (NDP_ROUTE_PREF_LOW, NM_RDISC_PREFERENCE_LOW), - NM_UTILS_LOOKUP_ITEM (NDP_ROUTE_PREF_MEDIUM, NM_RDISC_PREFERENCE_MEDIUM), - NM_UTILS_LOOKUP_ITEM (NDP_ROUTE_PREF_HIGH, NM_RDISC_PREFERENCE_HIGH), -); - -static int -receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data) -{ - NMRDisc *rdisc = (NMRDisc *) user_data; - NMRDiscDataInternal *rdata = rdisc->rdata; - NMRDiscConfigMap changed = 0; - struct ndp_msgra *msgra = ndp_msgra (msg); - struct in6_addr gateway_addr; - guint32 now = nm_utils_get_monotonic_timestamp_s (); - int offset; - int hop_limit; - - /* Router discovery is subject to the following RFC documents: - * - * http://tools.ietf.org/html/rfc4861 - * http://tools.ietf.org/html/rfc4862 - * - * The biggest difference from good old DHCP is that all configuration - * items have their own lifetimes and they are merged from various - * sources. Router discovery is *not* contract-based, so there is *no* - * single time when the configuration is finished and updates can - * come at any time. - */ - _LOGD ("received router advertisement at %u", now); - - /* DHCP level: - * - * The problem with DHCP level is what to do if subsequent - * router advertisements carry different flags. Currently we just - * rewrite the flag with every inbound RA. - */ - { - NMRDiscDHCPLevel dhcp_level; - - if (ndp_msgra_flag_managed (msgra)) - dhcp_level = NM_RDISC_DHCP_LEVEL_MANAGED; - else if (ndp_msgra_flag_other (msgra)) - dhcp_level = NM_RDISC_DHCP_LEVEL_OTHERCONF; - else - dhcp_level = NM_RDISC_DHCP_LEVEL_NONE; - - /* when receiving multiple RA (possibly from different routers), - * let's keep the "most managed" level. */ - G_STATIC_ASSERT_EXPR (NM_RDISC_DHCP_LEVEL_MANAGED > NM_RDISC_DHCP_LEVEL_OTHERCONF); - G_STATIC_ASSERT_EXPR (NM_RDISC_DHCP_LEVEL_OTHERCONF > NM_RDISC_DHCP_LEVEL_NONE); - dhcp_level = MAX (dhcp_level, rdata->public.dhcp_level); - - if (dhcp_level != rdata->public.dhcp_level) { - rdata->public.dhcp_level = dhcp_level; - changed |= NM_RDISC_CONFIG_DHCP_LEVEL; - } - } - - /* Default gateway: - * - * Subsequent router advertisements can represent new default gateways - * on the network. We should present all of them in router preference - * order. - */ - gateway_addr = *ndp_msg_addrto (msg); - { - NMRDiscGateway gateway = { - .address = gateway_addr, - .timestamp = now, - .lifetime = ndp_msgra_router_lifetime (msgra), - .preference = translate_preference (ndp_msgra_route_preference (msgra)), - }; - - if (nm_rdisc_add_gateway (rdisc, &gateway)) - changed |= NM_RDISC_CONFIG_GATEWAYS; - } - - /* Addresses & Routes */ - ndp_msg_opt_for_each_offset (offset, msg, NDP_MSG_OPT_PREFIX) { - guint8 r_plen; - struct in6_addr r_network; - - /* Device route */ - - r_plen = ndp_msg_opt_prefix_len (msg, offset); - if (r_plen == 0 || r_plen > 128) - continue; - nm_utils_ip6_address_clear_host_address (&r_network, ndp_msg_opt_prefix (msg, offset), r_plen); - - if (ndp_msg_opt_prefix_flag_on_link (msg, offset)) { - NMRDiscRoute route = { - .network = r_network, - .plen = r_plen, - .timestamp = now, - .lifetime = ndp_msg_opt_prefix_valid_time (msg, offset), - }; - - if (nm_rdisc_add_route (rdisc, &route)) - changed |= NM_RDISC_CONFIG_ROUTES; - } - - /* Address */ - if ( r_plen == 64 - && ndp_msg_opt_prefix_flag_auto_addr_conf (msg, offset)) { - NMRDiscAddress address = { - .address = r_network, - .timestamp = now, - .lifetime = ndp_msg_opt_prefix_valid_time (msg, offset), - .preferred = ndp_msg_opt_prefix_preferred_time (msg, offset), - }; - - if (address.preferred > address.lifetime) - address.preferred = address.lifetime; - if (nm_rdisc_complete_and_add_address (rdisc, &address)) - changed |= NM_RDISC_CONFIG_ADDRESSES; - } - } - ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_ROUTE) { - NMRDiscRoute route = { - .gateway = gateway_addr, - .plen = ndp_msg_opt_route_prefix_len (msg, offset), - .timestamp = now, - .lifetime = ndp_msg_opt_route_lifetime (msg, offset), - .preference = translate_preference (ndp_msg_opt_route_preference (msg, offset)), - }; - - if (route.plen == 0 || route.plen > 128) - continue; - - /* Routers through this particular gateway */ - nm_utils_ip6_address_clear_host_address (&route.network, ndp_msg_opt_route_prefix (msg, offset), route.plen); - if (nm_rdisc_add_route (rdisc, &route)) - changed |= NM_RDISC_CONFIG_ROUTES; - } - - /* DNS information */ - ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_RDNSS) { - static struct in6_addr *addr; - int addr_index; - - ndp_msg_opt_rdnss_for_each_addr (addr, addr_index, msg, offset) { - NMRDiscDNSServer dns_server = { - .address = *addr, - .timestamp = now, - .lifetime = ndp_msg_opt_rdnss_lifetime (msg, offset), - }; - - /* Pad the lifetime somewhat to give a bit of slack in cases - * where one RA gets lost or something (which can happen on unreliable - * links like WiFi where certain types of frames are not retransmitted). - * Note that 0 has special meaning and is therefore not adjusted. - */ - if (dns_server.lifetime && dns_server.lifetime < 7200) - dns_server.lifetime = 7200; - if (nm_rdisc_add_dns_server (rdisc, &dns_server)) - changed |= NM_RDISC_CONFIG_DNS_SERVERS; - } - } - ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_DNSSL) { - char *domain; - int domain_index; - - ndp_msg_opt_dnssl_for_each_domain (domain, domain_index, msg, offset) { - NMRDiscDNSDomain dns_domain = { - .domain = domain, - .timestamp = now, - .lifetime = ndp_msg_opt_rdnss_lifetime (msg, offset), - }; - - /* Pad the lifetime somewhat to give a bit of slack in cases - * where one RA gets lost or something (which can happen on unreliable - * links like WiFi where certain types of frames are not retransmitted). - * Note that 0 has special meaning and is therefore not adjusted. - */ - if (dns_domain.lifetime && dns_domain.lifetime < 7200) - dns_domain.lifetime = 7200; - if (nm_rdisc_add_dns_domain (rdisc, &dns_domain)) - changed |= NM_RDISC_CONFIG_DNS_DOMAINS; - } - } - - hop_limit = ndp_msgra_curhoplimit (msgra); - if (rdata->public.hop_limit != hop_limit) { - rdata->public.hop_limit = hop_limit; - changed |= NM_RDISC_CONFIG_HOP_LIMIT; - } - - /* MTU */ - ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_MTU) { - guint32 mtu = ndp_msg_opt_mtu(msg, offset); - if (mtu >= 1280) { - if (rdata->public.mtu != mtu) { - rdata->public.mtu = mtu; - changed |= NM_RDISC_CONFIG_MTU; - } - } else { - /* All sorts of bad things would happen if we accepted this. - * Kernel would set it, but would flush out all IPv6 addresses away - * from the link, even the link-local, and we wouldn't be able to - * listen for further RAs that could fix the MTU. */ - _LOGW ("MTU too small for IPv6 ignored: %d", mtu); - } - } - - nm_rdisc_ra_received (rdisc, now, changed); - return 0; -} - -static gboolean -event_ready (GIOChannel *source, GIOCondition condition, NMRDisc *rdisc) -{ - nm_auto_pop_netns NMPNetns *netns = NULL; - NMLndpRDiscPrivate *priv = NM_LNDP_RDISC_GET_PRIVATE ((NMLndpRDisc *) rdisc); - - _LOGD ("processing libndp events"); - - if (!nm_rdisc_netns_push (rdisc, &netns)) - return G_SOURCE_CONTINUE; - - ndp_callall_eventfd_handler (priv->ndp); - return G_SOURCE_CONTINUE; -} - -static void -start (NMRDisc *rdisc) -{ - NMLndpRDiscPrivate *priv = NM_LNDP_RDISC_GET_PRIVATE ((NMLndpRDisc *) rdisc); - int fd = ndp_get_eventfd (priv->ndp); - - priv->event_channel = g_io_channel_unix_new (fd); - priv->event_id = g_io_add_watch (priv->event_channel, G_IO_IN, (GIOFunc) event_ready, rdisc); - - /* Flush any pending messages to avoid using obsolete information */ - event_ready (priv->event_channel, 0, rdisc); - - ndp_msgrcv_handler_register (priv->ndp, receive_ra, NDP_MSG_RA, nm_rdisc_get_ifindex (rdisc), rdisc); -} - -/*****************************************************************************/ - -static inline int -ipv6_sysctl_get (NMPlatform *platform, const char *ifname, const char *property, int min, int max, int defval) -{ - return (int) nm_platform_sysctl_get_int_checked (platform, - nm_utils_ip6_property_path (ifname, property), - 10, - min, - max, - defval); -} - -static void -nm_lndp_rdisc_init (NMLndpRDisc *lndp_rdisc) -{ -} - -NMRDisc * -nm_lndp_rdisc_new (NMPlatform *platform, - int ifindex, - const char *ifname, - NMUtilsStableType stable_type, - const char *network_id, - NMSettingIP6ConfigAddrGenMode addr_gen_mode, - GError **error) -{ - nm_auto_pop_netns NMPNetns *netns = NULL; - NMRDisc *rdisc; - NMLndpRDiscPrivate *priv; - int errsv; - - g_return_val_if_fail (NM_IS_PLATFORM (platform), NULL); - g_return_val_if_fail (!error || !*error, NULL); - - if (!nm_platform_netns_push (platform, &netns)) - return NULL; - - rdisc = g_object_new (NM_TYPE_LNDP_RDISC, - NM_RDISC_PLATFORM, platform, - NM_RDISC_STABLE_TYPE, (int) stable_type, - NM_RDISC_IFINDEX, ifindex, - NM_RDISC_IFNAME, ifname, - NM_RDISC_NETWORK_ID, network_id, - NM_RDISC_ADDR_GEN_MODE, (int) addr_gen_mode, - NM_RDISC_MAX_ADDRESSES, ipv6_sysctl_get (platform, ifname, - "max_addresses", - 0, G_MAXINT32, NM_RDISC_MAX_ADDRESSES_DEFAULT), - NM_RDISC_ROUTER_SOLICITATIONS, ipv6_sysctl_get (platform, ifname, - "router_solicitations", - 1, G_MAXINT32, NM_RDISC_ROUTER_SOLICITATIONS_DEFAULT), - NM_RDISC_ROUTER_SOLICITATION_INTERVAL, ipv6_sysctl_get (platform, ifname, - "router_solicitation_interval", - 1, G_MAXINT32, NM_RDISC_ROUTER_SOLICITATION_INTERVAL_DEFAULT), - NULL); - - priv = NM_LNDP_RDISC_GET_PRIVATE ((NMLndpRDisc *) rdisc); - - errsv = ndp_open (&priv->ndp); - - if (errsv != 0) { - errsv = errsv > 0 ? errsv : -errsv; - g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, - "failure creating libndp socket: %s (%d)", - g_strerror (errsv), errsv); - g_object_unref (rdisc); - return NULL; - } - return rdisc; -} - -static void -dispose (GObject *object) -{ - NMRDisc *rdisc = (NMRDisc *) object; - NMLndpRDiscPrivate *priv = NM_LNDP_RDISC_GET_PRIVATE ((NMLndpRDisc *) rdisc); - - nm_clear_g_source (&priv->event_id); - g_clear_pointer (&priv->event_channel, g_io_channel_unref); - - if (priv->ndp) { - ndp_msgrcv_handler_unregister (priv->ndp, receive_ra, NDP_MSG_RA, nm_rdisc_get_ifindex (rdisc), rdisc); - ndp_close (priv->ndp); - priv->ndp = NULL; - } - - G_OBJECT_CLASS (nm_lndp_rdisc_parent_class)->dispose (object); -} - -static void -nm_lndp_rdisc_class_init (NMLndpRDiscClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - NMRDiscClass *rdisc_class = NM_RDISC_CLASS (klass); - - object_class->dispose = dispose; - rdisc_class->start = start; - rdisc_class->send_rs = send_rs; -} diff --git a/src/rdisc/nm-lndp-rdisc.h b/src/rdisc/nm-lndp-rdisc.h deleted file mode 100644 index e2b47c04..00000000 --- a/src/rdisc/nm-lndp-rdisc.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-lndp-rdisc.h - Implementation of router discovery using libndp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_LNDP_RDISC_H__ -#define __NETWORKMANAGER_LNDP_RDISC_H__ - -#include "nm-rdisc.h" -#include "nm-core-utils.h" - -#define NM_TYPE_LNDP_RDISC (nm_lndp_rdisc_get_type ()) -#define NM_LNDP_RDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_LNDP_RDISC, NMLndpRDisc)) -#define NM_LNDP_RDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_LNDP_RDISC, NMLndpRDiscClass)) -#define NM_IS_LNDP_RDISC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_LNDP_RDISC)) -#define NM_IS_LNDP_RDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_LNDP_RDISC)) -#define NM_LNDP_RDISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_LNDP_RDISC, NMLndpRDiscClass)) - -typedef struct _NMLndpRDisc NMLndpRDisc; -typedef struct _NMLndpRDiscClass NMLndpRDiscClass; - -GType nm_lndp_rdisc_get_type (void); - -NMRDisc *nm_lndp_rdisc_new (NMPlatform *platform, - int ifindex, - const char *ifname, - NMUtilsStableType stable_type, - const char *network_id, - NMSettingIP6ConfigAddrGenMode addr_gen_mode, - GError **error); - -#endif /* __NETWORKMANAGER_LNDP_RDISC_H__ */ diff --git a/src/rdisc/nm-rdisc-private.h b/src/rdisc/nm-rdisc-private.h deleted file mode 100644 index abc5a399..00000000 --- a/src/rdisc/nm-rdisc-private.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-rdisc.h - Perform IPv6 router discovery - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2015 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_RDISC_PRIVATE_H__ -#define __NETWORKMANAGER_RDISC_PRIVATE_H__ - -#include "nm-rdisc.h" - -/* Functions only used by rdisc implementations */ - -struct _NMRDiscDataInternal { - NMRDiscData public; - GArray *gateways; - GArray *addresses; - GArray *routes; - GArray *dns_servers; - GArray *dns_domains; -}; - -typedef struct _NMRDiscDataInternal NMRDiscDataInternal; - -void nm_rdisc_ra_received (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap changed); - -gboolean nm_rdisc_add_gateway (NMRDisc *rdisc, const NMRDiscGateway *new); -gboolean nm_rdisc_complete_and_add_address (NMRDisc *rdisc, NMRDiscAddress *new); -gboolean nm_rdisc_add_route (NMRDisc *rdisc, const NMRDiscRoute *new); -gboolean nm_rdisc_add_dns_server (NMRDisc *rdisc, const NMRDiscDNSServer *new); -gboolean nm_rdisc_add_dns_domain (NMRDisc *rdisc, const NMRDiscDNSDomain *new); - -/*********************************************************************************************/ - -#define _NMLOG_DOMAIN LOGD_IP6 -#define _NMLOG(level, ...) _LOG(level, _NMLOG_DOMAIN, rdisc, __VA_ARGS__) - -#define _LOG(level, domain, self, ...) \ - G_STMT_START { \ - const NMLogLevel __level = (level); \ - const NMLogDomain __domain = (domain); \ - \ - if (nm_logging_enabled (__level, __domain)) { \ - NMRDisc *const __self = (self); \ - char __prefix[64]; \ - \ - _nm_log (__level, __domain, 0, \ - "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - (__self \ - ? ({ \ - const char *__ifname = nm_rdisc_get_ifname (__self); \ - nm_sprintf_buf (__prefix, "%s[%p,%s%s%s]", \ - _NMLOG_PREFIX_NAME, __self, \ - NM_PRINT_FMT_QUOTE_STRING (__ifname)); \ - }) \ - : _NMLOG_PREFIX_NAME) \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -/*********************************************************************************************/ - -#endif /* __NETWORKMANAGER_RDISC_PRIVATE_H__ */ diff --git a/src/rdisc/nm-rdisc.c b/src/rdisc/nm-rdisc.c deleted file mode 100644 index 3bc69750..00000000 --- a/src/rdisc/nm-rdisc.c +++ /dev/null @@ -1,1073 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-rdisc.c - Perform IPv6 router discovery - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "nm-rdisc.h" - -#include -#include -#include - -#include "nm-setting-ip6-config.h" - -#include "nm-rdisc-private.h" -#include "nm-utils.h" -#include "nm-platform.h" -#include "nmp-netns.h" - -#define _NMLOG_PREFIX_NAME "rdisc" - -/*****************************************************************************/ - -struct _NMRDiscPrivate { - /* this *must* be the first field. */ - NMRDiscDataInternal rdata; - - gint32 solicitations_left; - guint send_rs_id; - gint32 last_rs; - guint ra_timeout_id; /* first RA timeout */ - guint timeout_id; /* prefix/dns/etc lifetime timeout */ - char *last_send_rs_error; - NMUtilsIPv6IfaceId iid; - - /* immutable values: */ - int ifindex; - char *ifname; - char *network_id; - NMSettingIP6ConfigAddrGenMode addr_gen_mode; - NMUtilsStableType stable_type; - gint32 max_addresses; - gint32 router_solicitations; - gint32 router_solicitation_interval; - - NMPlatform *platform; - NMPNetns *netns; -}; - -typedef struct _NMRDiscPrivate NMRDiscPrivate; - -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PLATFORM, - PROP_IFINDEX, - PROP_IFNAME, - PROP_STABLE_TYPE, - PROP_NETWORK_ID, - PROP_ADDR_GEN_MODE, - PROP_MAX_ADDRESSES, - PROP_ROUTER_SOLICITATIONS, - PROP_ROUTER_SOLICITATION_INTERVAL, -); - -enum { - CONFIG_CHANGED, - RA_TIMEOUT, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE (NMRDisc, nm_rdisc, G_TYPE_OBJECT) - -#define NM_RDISC_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMRDisc, NM_IS_RDISC) - -/*****************************************************************************/ - -static void _config_changed_log (NMRDisc *rdisc, NMRDiscConfigMap changed); - -/*****************************************************************************/ - -NMPNetns * -nm_rdisc_netns_get (NMRDisc *self) -{ - g_return_val_if_fail (NM_IS_RDISC (self), NULL); - - return NM_RDISC_GET_PRIVATE (self)->netns; -} - -gboolean -nm_rdisc_netns_push (NMRDisc *self, NMPNetns **netns) -{ - NMRDiscPrivate *priv; - - g_return_val_if_fail (NM_IS_RDISC (self), FALSE); - - priv = NM_RDISC_GET_PRIVATE (self); - if ( priv->netns - && !nmp_netns_push (priv->netns)) { - NM_SET_OUT (netns, NULL); - return FALSE; - } - - NM_SET_OUT (netns, priv->netns); - return TRUE; -} - -/*****************************************************************************/ - -int -nm_rdisc_get_ifindex (NMRDisc *self) -{ - g_return_val_if_fail (NM_IS_RDISC (self), 0); - - return NM_RDISC_GET_PRIVATE (self)->ifindex; -} - -const char * -nm_rdisc_get_ifname (NMRDisc *self) -{ - g_return_val_if_fail (NM_IS_RDISC (self), NULL); - - return NM_RDISC_GET_PRIVATE (self)->ifname; -} - -/*****************************************************************************/ - -static const NMRDiscData * -_data_complete (NMRDiscDataInternal *data) -{ -#define _SET(data, field) \ - G_STMT_START { \ - if ((data->public.field##_n = data->field->len) > 0) \ - data->public.field = (gpointer) data->field->data; \ - else \ - data->public.field = NULL; \ - } G_STMT_END - _SET (data, gateways); - _SET (data, addresses); - _SET (data, routes); - _SET (data, dns_servers); - _SET (data, dns_domains); -#undef _SET - return &data->public; -} - -static void -_emit_config_change (NMRDisc *self, NMRDiscConfigMap changed) -{ - _config_changed_log (self, changed); - g_signal_emit (self, signals[CONFIG_CHANGED], 0, - _data_complete (&NM_RDISC_GET_PRIVATE (self)->rdata), - (guint) changed); -} - -/*****************************************************************************/ - -gboolean -nm_rdisc_add_gateway (NMRDisc *rdisc, const NMRDiscGateway *new) -{ - NMRDiscDataInternal *rdata = &NM_RDISC_GET_PRIVATE(rdisc)->rdata; - int i, insert_idx = -1; - - for (i = 0; i < rdata->gateways->len; i++) { - NMRDiscGateway *item = &g_array_index (rdata->gateways, NMRDiscGateway, i); - - if (IN6_ARE_ADDR_EQUAL (&item->address, &new->address)) { - if (new->lifetime == 0) { - g_array_remove_index (rdata->gateways, i--); - return TRUE; - } - - if (item->preference != new->preference) { - g_array_remove_index (rdata->gateways, i--); - continue; - } - - memcpy (item, new, sizeof (*new)); - return FALSE; - } - - /* Put before less preferable gateways. */ - if (item->preference < new->preference && insert_idx < 0) - insert_idx = i; - } - - if (new->lifetime) - g_array_insert_val (rdata->gateways, MAX (insert_idx, 0), *new); - return !!new->lifetime; -} - -/** - * complete_address: - * @rdisc: the #NMRDisc - * @addr: the #NMRDiscAddress - * - * Adds the host part to the address that has network part set. - * If the address already has a host part, add a different host part - * if possible (this is useful in case DAD failed). - * - * Can fail if a different address can not be generated (DAD failure - * for an EUI-64 address or DAD counter overflow). - * - * Returns: %TRUE if the address could be completed, %FALSE otherwise. - **/ -static gboolean -complete_address (NMRDisc *rdisc, NMRDiscAddress *addr) -{ - NMRDiscPrivate *priv; - GError *error = NULL; - - g_return_val_if_fail (NM_IS_RDISC (rdisc), FALSE); - - priv = NM_RDISC_GET_PRIVATE (rdisc); - if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { - if (!nm_utils_ipv6_addr_set_stable_privacy (priv->stable_type, - &addr->address, - priv->ifname, - priv->network_id, - addr->dad_counter++, - &error)) { - _LOGW ("complete-address: failed to generate an stable-privacy address: %s", - error->message); - g_clear_error (&error); - return FALSE; - } - _LOGD ("complete-address: using an stable-privacy address"); - return TRUE; - } - - if (!priv->iid.id) { - _LOGW ("complete-address: can't generate an EUI-64 address: no interface identifier"); - return FALSE; - } - - if (addr->address.s6_addr32[2] == 0x0 && addr->address.s6_addr32[3] == 0x0) { - _LOGD ("complete-address: adding an EUI-64 address"); - nm_utils_ipv6_addr_set_interface_identifier (&addr->address, priv->iid); - return TRUE; - } - - _LOGW ("complete-address: can't generate a new EUI-64 address"); - return FALSE; -} - -gboolean -nm_rdisc_complete_and_add_address (NMRDisc *rdisc, NMRDiscAddress *new) -{ - NMRDiscPrivate *priv; - NMRDiscDataInternal *rdata; - int i; - - if (!complete_address (rdisc, new)) - return FALSE; - - priv = NM_RDISC_GET_PRIVATE (rdisc); - rdata = &priv->rdata; - - for (i = 0; i < rdata->addresses->len; i++) { - NMRDiscAddress *item = &g_array_index (rdata->addresses, NMRDiscAddress, i); - - if (IN6_ARE_ADDR_EQUAL (&item->address, &new->address)) { - gboolean changed; - - if (new->lifetime == 0) { - g_array_remove_index (rdata->addresses, i--); - return TRUE; - } - - changed = item->timestamp + item->lifetime != new->timestamp + new->lifetime || - item->timestamp + item->preferred != new->timestamp + new->preferred; - *item = *new; - return changed; - } - } - - /* we create at most max_addresses autoconf addresses. This is different from - * what the kernel does, because it considers *all* addresses (including - * static and other temporary addresses). - **/ - if (priv->max_addresses && rdata->addresses->len >= priv->max_addresses) - return FALSE; - - if (new->lifetime) - g_array_insert_val (rdata->addresses, i, *new); - return !!new->lifetime; -} - -gboolean -nm_rdisc_add_route (NMRDisc *rdisc, const NMRDiscRoute *new) -{ - NMRDiscPrivate *priv; - NMRDiscDataInternal *rdata; - int i, insert_idx = -1; - - if (new->plen == 0 || new->plen > 128) { - /* Only expect non-default routes. The router has no idea what the - * local configuration or user preferences are, so sending routes - * with a prefix length of 0 must be ignored by NMRDisc. - * - * Also, upper layers also don't expect that NMRDisc exposes routes - * with a plen or zero or larger then 128. - */ - g_return_val_if_reached (FALSE); - } - - priv = NM_RDISC_GET_PRIVATE (rdisc); - rdata = &priv->rdata; - - for (i = 0; i < rdata->routes->len; i++) { - NMRDiscRoute *item = &g_array_index (rdata->routes, NMRDiscRoute, i); - - if (IN6_ARE_ADDR_EQUAL (&item->network, &new->network) && item->plen == new->plen) { - if (new->lifetime == 0) { - g_array_remove_index (rdata->routes, i--); - return TRUE; - } - - if (item->preference != new->preference) { - g_array_remove_index (rdata->routes, i--); - continue; - } - - memcpy (item, new, sizeof (*new)); - return FALSE; - } - - /* Put before less preferable routes. */ - if (item->preference < new->preference && insert_idx < 0) - insert_idx = i; - } - - if (new->lifetime) - g_array_insert_val (rdata->routes, CLAMP (insert_idx, 0, G_MAXINT), *new); - return !!new->lifetime; -} - -gboolean -nm_rdisc_add_dns_server (NMRDisc *rdisc, const NMRDiscDNSServer *new) -{ - NMRDiscPrivate *priv; - NMRDiscDataInternal *rdata; - int i; - - priv = NM_RDISC_GET_PRIVATE (rdisc); - rdata = &priv->rdata; - - for (i = 0; i < rdata->dns_servers->len; i++) { - NMRDiscDNSServer *item = &g_array_index (rdata->dns_servers, NMRDiscDNSServer, i); - - if (IN6_ARE_ADDR_EQUAL (&item->address, &new->address)) { - if (new->lifetime == 0) { - g_array_remove_index (rdata->dns_servers, i); - return TRUE; - } - if (item->timestamp != new->timestamp || item->lifetime != new->lifetime) { - *item = *new; - return TRUE; - } - return FALSE; - } - } - - if (new->lifetime) - g_array_insert_val (rdata->dns_servers, i, *new); - return !!new->lifetime; -} - -/* Copies new->domain if 'new' is added to the dns_domains list */ -gboolean -nm_rdisc_add_dns_domain (NMRDisc *rdisc, const NMRDiscDNSDomain *new) -{ - NMRDiscPrivate *priv; - NMRDiscDataInternal *rdata; - NMRDiscDNSDomain *item; - int i; - - priv = NM_RDISC_GET_PRIVATE (rdisc); - rdata = &priv->rdata; - - for (i = 0; i < rdata->dns_domains->len; i++) { - item = &g_array_index (rdata->dns_domains, NMRDiscDNSDomain, i); - - if (!g_strcmp0 (item->domain, new->domain)) { - gboolean changed; - - if (new->lifetime == 0) { - g_array_remove_index (rdata->dns_domains, i); - return TRUE; - } - - changed = (item->timestamp != new->timestamp || - item->lifetime != new->lifetime); - if (changed) { - item->timestamp = new->timestamp; - item->lifetime = new->lifetime; - } - return changed; - } - } - - if (new->lifetime) { - g_array_insert_val (rdata->dns_domains, i, *new); - item = &g_array_index (rdata->dns_domains, NMRDiscDNSDomain, i); - item->domain = g_strdup (new->domain); - } - return !!new->lifetime; -} - -/******************************************************************/ - -/** - * nm_rdisc_set_iid: - * @rdisc: the #NMRDisc - * @iid: the new interface ID - * - * Sets the "Modified EUI-64" interface ID to be used when generating - * IPv6 addresses using received prefixes. Identifiers are either generated - * from the hardware addresses or manually set by the operator with - * "ip token" command. - * - * Upon token change (or initial setting) all addresses generated using - * the old identifier are removed. The caller should ensure the addresses - * will be reset by soliciting router advertisements. - * - * In case the stable privacy addressing is used %FALSE is returned and - * addresses are left untouched. - * - * Returns: %TRUE if addresses need to be regenerated, %FALSE otherwise. - **/ -gboolean -nm_rdisc_set_iid (NMRDisc *rdisc, const NMUtilsIPv6IfaceId iid) -{ - NMRDiscPrivate *priv; - NMRDiscDataInternal *rdata; - - g_return_val_if_fail (NM_IS_RDISC (rdisc), FALSE); - - priv = NM_RDISC_GET_PRIVATE (rdisc); - rdata = &priv->rdata; - - if (priv->iid.id != iid.id) { - priv->iid = iid; - - if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) - return FALSE; - - if (rdata->addresses->len) { - _LOGD ("IPv6 interface identifier changed, flushing addresses"); - g_array_remove_range (rdata->addresses, 0, rdata->addresses->len); - _emit_config_change (rdisc, NM_RDISC_CONFIG_ADDRESSES); - } - return TRUE; - } - - return FALSE; -} - -static gboolean -send_rs_timeout (NMRDisc *rdisc) -{ - nm_auto_pop_netns NMPNetns *netns = NULL; - NMRDiscClass *klass = NM_RDISC_GET_CLASS (rdisc); - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (rdisc); - GError *error = NULL; - - priv->send_rs_id = 0; - - if (!nm_rdisc_netns_push (rdisc, &netns)) - return G_SOURCE_REMOVE; - - if (klass->send_rs (rdisc, &error)) { - _LOGD ("router solicitation sent"); - priv->solicitations_left--; - g_clear_pointer (&priv->last_send_rs_error, g_free); - } else { - gboolean different_message; - - different_message = g_strcmp0 (priv->last_send_rs_error, error->message) != 0; - _NMLOG (different_message ? LOGL_WARN : LOGL_DEBUG, - "failure sending router solicitation: %s", error->message); - if (different_message) { - g_clear_pointer (&priv->last_send_rs_error, g_free); - priv->last_send_rs_error = g_strdup (error->message); - } - g_clear_error (&error); - } - - priv->last_rs = nm_utils_get_monotonic_timestamp_s (); - if (priv->solicitations_left > 0) { - _LOGD ("scheduling router solicitation retry in %d seconds.", - (int) priv->router_solicitation_interval); - priv->send_rs_id = g_timeout_add_seconds (priv->router_solicitation_interval, - (GSourceFunc) send_rs_timeout, rdisc); - } else { - _LOGD ("did not receive a router advertisement after %d solicitations.", - (int) priv->router_solicitations); - } - - return G_SOURCE_REMOVE; -} - -static void -solicit (NMRDisc *rdisc) -{ - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (rdisc); - gint64 next, now; - - if (priv->send_rs_id) - return; - - now = nm_utils_get_monotonic_timestamp_s (); - - priv->solicitations_left = priv->router_solicitations; - - next = (((gint64) priv->last_rs) + priv->router_solicitation_interval) - now; - next = CLAMP (next, 0, G_MAXINT32); - _LOGD ("scheduling explicit router solicitation request in %" G_GINT64_FORMAT " seconds.", - next); - priv->send_rs_id = g_timeout_add_seconds ((guint32) next, (GSourceFunc) send_rs_timeout, rdisc); -} - -static gboolean -rdisc_ra_timeout_cb (gpointer user_data) -{ - NMRDisc *rdisc = NM_RDISC (user_data); - - NM_RDISC_GET_PRIVATE (rdisc)->ra_timeout_id = 0; - g_signal_emit (rdisc, signals[RA_TIMEOUT], 0); - return G_SOURCE_REMOVE; -} - -void -nm_rdisc_start (NMRDisc *rdisc) -{ - nm_auto_pop_netns NMPNetns *netns = NULL; - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (rdisc); - NMRDiscClass *klass = NM_RDISC_GET_CLASS (rdisc); - gint64 ra_wait_secs; - - g_assert (klass->start); - - _LOGD ("starting router discovery: %d", priv->ifindex); - - if (!nm_rdisc_netns_push (rdisc, &netns)) - return; - - nm_clear_g_source (&priv->ra_timeout_id); - ra_wait_secs = (((gint64) priv->router_solicitations) * priv->router_solicitation_interval) + 1; - ra_wait_secs = CLAMP (ra_wait_secs, 30, 120); - priv->ra_timeout_id = g_timeout_add_seconds (ra_wait_secs, rdisc_ra_timeout_cb, rdisc); - _LOGD ("scheduling RA timeout in %d seconds", (int) ra_wait_secs); - - if (klass->start) - klass->start (rdisc); - - solicit (rdisc); -} - -void -nm_rdisc_dad_failed (NMRDisc *rdisc, struct in6_addr *address) -{ - NMRDiscDataInternal *rdata; - int i; - gboolean changed = FALSE; - - rdata = &NM_RDISC_GET_PRIVATE (rdisc)->rdata; - - for (i = 0; i < rdata->addresses->len; i++) { - NMRDiscAddress *item = &g_array_index (rdata->addresses, NMRDiscAddress, i); - - if (!IN6_ARE_ADDR_EQUAL (&item->address, address)) - continue; - - _LOGD ("DAD failed for discovered address %s", nm_utils_inet6_ntop (address, NULL)); - if (!complete_address (rdisc, item)) - g_array_remove_index (rdata->addresses, i--); - changed = TRUE; - } - - if (changed) - _emit_config_change (rdisc, NM_RDISC_CONFIG_ADDRESSES); -} - -#define CONFIG_MAP_MAX_STR 7 - -static void -config_map_to_string (NMRDiscConfigMap map, char *p) -{ - if (map & NM_RDISC_CONFIG_DHCP_LEVEL) - *p++ = 'd'; - if (map & NM_RDISC_CONFIG_GATEWAYS) - *p++ = 'G'; - if (map & NM_RDISC_CONFIG_ADDRESSES) - *p++ = 'A'; - if (map & NM_RDISC_CONFIG_ROUTES) - *p++ = 'R'; - if (map & NM_RDISC_CONFIG_DNS_SERVERS) - *p++ = 'S'; - if (map & NM_RDISC_CONFIG_DNS_DOMAINS) - *p++ = 'D'; - *p = '\0'; -} - -static const char * -dhcp_level_to_string (NMRDiscDHCPLevel dhcp_level) -{ - switch (dhcp_level) { - case NM_RDISC_DHCP_LEVEL_NONE: - return "none"; - case NM_RDISC_DHCP_LEVEL_OTHERCONF: - return "otherconf"; - case NM_RDISC_DHCP_LEVEL_MANAGED: - return "managed"; - default: - return "INVALID"; - } -} - -#define expiry(item) (item->timestamp + item->lifetime) - -static void -_config_changed_log (NMRDisc *rdisc, NMRDiscConfigMap changed) -{ - NMRDiscPrivate *priv; - NMRDiscDataInternal *rdata; - int i; - char changedstr[CONFIG_MAP_MAX_STR]; - char addrstr[INET6_ADDRSTRLEN]; - - if (!_LOGD_ENABLED ()) - return; - - priv = NM_RDISC_GET_PRIVATE (rdisc); - rdata = &priv->rdata; - - config_map_to_string (changed, changedstr); - _LOGD ("router discovery configuration changed [%s]:", changedstr); - _LOGD (" dhcp-level %s", dhcp_level_to_string (priv->rdata.public.dhcp_level)); - for (i = 0; i < rdata->gateways->len; i++) { - NMRDiscGateway *gateway = &g_array_index (rdata->gateways, NMRDiscGateway, i); - - inet_ntop (AF_INET6, &gateway->address, addrstr, sizeof (addrstr)); - _LOGD (" gateway %s pref %d exp %u", addrstr, gateway->preference, expiry (gateway)); - } - for (i = 0; i < rdata->addresses->len; i++) { - NMRDiscAddress *address = &g_array_index (rdata->addresses, NMRDiscAddress, i); - - inet_ntop (AF_INET6, &address->address, addrstr, sizeof (addrstr)); - _LOGD (" address %s exp %u", addrstr, expiry (address)); - } - for (i = 0; i < rdata->routes->len; i++) { - NMRDiscRoute *route = &g_array_index (rdata->routes, NMRDiscRoute, i); - - inet_ntop (AF_INET6, &route->network, addrstr, sizeof (addrstr)); - _LOGD (" route %s/%d via %s pref %d exp %u", addrstr, (int) route->plen, - nm_utils_inet6_ntop (&route->gateway, NULL), route->preference, - expiry (route)); - } - for (i = 0; i < rdata->dns_servers->len; i++) { - NMRDiscDNSServer *dns_server = &g_array_index (rdata->dns_servers, NMRDiscDNSServer, i); - - inet_ntop (AF_INET6, &dns_server->address, addrstr, sizeof (addrstr)); - _LOGD (" dns_server %s exp %u", addrstr, expiry (dns_server)); - } - for (i = 0; i < rdata->dns_domains->len; i++) { - NMRDiscDNSDomain *dns_domain = &g_array_index (rdata->dns_domains, NMRDiscDNSDomain, i); - - _LOGD (" dns_domain %s exp %u", dns_domain->domain, expiry (dns_domain)); - } -} - -static void -clean_gateways (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap *changed, guint32 *nextevent) -{ - NMRDiscDataInternal *rdata; - guint i; - - rdata = &NM_RDISC_GET_PRIVATE (rdisc)->rdata; - - for (i = 0; i < rdata->gateways->len; i++) { - NMRDiscGateway *item = &g_array_index (rdata->gateways, NMRDiscGateway, i); - guint64 expiry = (guint64) item->timestamp + item->lifetime; - - if (item->lifetime == G_MAXUINT32) - continue; - - if (now >= expiry) { - g_array_remove_index (rdata->gateways, i--); - *changed |= NM_RDISC_CONFIG_GATEWAYS; - } else if (*nextevent > expiry) - *nextevent = expiry; - } -} - -static void -clean_addresses (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap *changed, guint32 *nextevent) -{ - NMRDiscDataInternal *rdata; - guint i; - - rdata = &NM_RDISC_GET_PRIVATE (rdisc)->rdata; - - for (i = 0; i < rdata->addresses->len; i++) { - NMRDiscAddress *item = &g_array_index (rdata->addresses, NMRDiscAddress, i); - guint64 expiry = (guint64) item->timestamp + item->lifetime; - - if (item->lifetime == G_MAXUINT32) - continue; - - if (now >= expiry) { - g_array_remove_index (rdata->addresses, i--); - *changed |= NM_RDISC_CONFIG_ADDRESSES; - } else if (*nextevent > expiry) - *nextevent = expiry; - } -} - -static void -clean_routes (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap *changed, guint32 *nextevent) -{ - NMRDiscDataInternal *rdata; - guint i; - - rdata = &NM_RDISC_GET_PRIVATE (rdisc)->rdata; - - for (i = 0; i < rdata->routes->len; i++) { - NMRDiscRoute *item = &g_array_index (rdata->routes, NMRDiscRoute, i); - guint64 expiry = (guint64) item->timestamp + item->lifetime; - - if (item->lifetime == G_MAXUINT32) - continue; - - if (now >= expiry) { - g_array_remove_index (rdata->routes, i--); - *changed |= NM_RDISC_CONFIG_ROUTES; - } else if (*nextevent > expiry) - *nextevent = expiry; - } -} - -static void -clean_dns_servers (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap *changed, guint32 *nextevent) -{ - NMRDiscDataInternal *rdata; - guint i; - - rdata = &NM_RDISC_GET_PRIVATE (rdisc)->rdata; - - for (i = 0; i < rdata->dns_servers->len; i++) { - NMRDiscDNSServer *item = &g_array_index (rdata->dns_servers, NMRDiscDNSServer, i); - guint64 expiry = (guint64) item->timestamp + item->lifetime; - guint64 refresh = (guint64) item->timestamp + item->lifetime / 2; - - if (item->lifetime == G_MAXUINT32) - continue; - - if (now >= expiry) { - g_array_remove_index (rdata->dns_servers, i--); - *changed |= NM_RDISC_CONFIG_DNS_SERVERS; - } else if (now >= refresh) - solicit (rdisc); - else if (*nextevent > refresh) - *nextevent = refresh; - } -} - -static void -clean_dns_domains (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap *changed, guint32 *nextevent) -{ - NMRDiscDataInternal *rdata; - guint i; - - rdata = &NM_RDISC_GET_PRIVATE (rdisc)->rdata; - - for (i = 0; i < rdata->dns_domains->len; i++) { - NMRDiscDNSDomain *item = &g_array_index (rdata->dns_domains, NMRDiscDNSDomain, i); - guint64 expiry = (guint64) item->timestamp + item->lifetime; - guint64 refresh = (guint64) item->timestamp + item->lifetime / 2; - - if (item->lifetime == G_MAXUINT32) - continue; - - if (now >= expiry) { - g_array_remove_index (rdata->dns_domains, i--); - *changed |= NM_RDISC_CONFIG_DNS_DOMAINS; - } else if (now >= refresh) - solicit (rdisc); - else if (*nextevent > refresh) - *nextevent = refresh; - } -} - -static gboolean timeout_cb (gpointer user_data); - -static void -check_timestamps (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap changed) -{ - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (rdisc); - /* Use a magic date in the distant future (~68 years) */ - guint32 never = G_MAXINT32; - guint32 nextevent = never; - - nm_clear_g_source (&priv->timeout_id); - - clean_gateways (rdisc, now, &changed, &nextevent); - clean_addresses (rdisc, now, &changed, &nextevent); - clean_routes (rdisc, now, &changed, &nextevent); - clean_dns_servers (rdisc, now, &changed, &nextevent); - clean_dns_domains (rdisc, now, &changed, &nextevent); - - if (changed) - _emit_config_change (rdisc, changed); - - if (nextevent != never) { - g_return_if_fail (nextevent > now); - _LOGD ("scheduling next now/lifetime check: %u seconds", - nextevent - now); - priv->timeout_id = g_timeout_add_seconds (nextevent - now, timeout_cb, rdisc); - } -} - -static gboolean -timeout_cb (gpointer user_data) -{ - NMRDisc *self = user_data; - - NM_RDISC_GET_PRIVATE (self)->timeout_id = 0; - check_timestamps (self, nm_utils_get_monotonic_timestamp_s (), 0); - return G_SOURCE_REMOVE; -} - -void -nm_rdisc_ra_received (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap changed) -{ - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (rdisc); - - nm_clear_g_source (&priv->ra_timeout_id); - nm_clear_g_source (&priv->send_rs_id); - g_clear_pointer (&priv->last_send_rs_error, g_free); - check_timestamps (rdisc, now, changed); -} - -/******************************************************************/ - -static void -dns_domain_free (gpointer data) -{ - g_free (((NMRDiscDNSDomain *)(data))->domain); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMRDisc *self = NM_RDISC (object); - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (self); - - switch (prop_id) { - case PROP_PLATFORM: - /* construct-only */ - priv->platform = g_value_get_object (value) ? : NM_PLATFORM_GET; - if (!priv->platform) - g_return_if_reached (); - - g_object_ref (priv->platform); - - priv->netns = nm_platform_netns_get (priv->platform); - if (priv->netns) - g_object_ref (priv->netns); - - g_return_if_fail (!priv->netns || priv->netns == nmp_netns_get_current ()); - break; - case PROP_IFINDEX: - /* construct-only */ - priv->ifindex = g_value_get_int (value); - g_return_if_fail (priv->ifindex > 0); - break; - case PROP_IFNAME: - /* construct-only */ - priv->ifname = g_value_dup_string (value); - g_return_if_fail (priv->ifname && priv->ifname[0]); - break; - case PROP_STABLE_TYPE: - /* construct-only */ - priv->stable_type = g_value_get_int (value); - break; - case PROP_NETWORK_ID: - /* construct-only */ - priv->network_id = g_value_dup_string (value); - break; - case PROP_ADDR_GEN_MODE: - /* construct-only */ - priv->addr_gen_mode = g_value_get_int (value); - break; - case PROP_MAX_ADDRESSES: - /* construct-only */ - priv->max_addresses = g_value_get_int (value); - break; - case PROP_ROUTER_SOLICITATIONS: - /* construct-only */ - priv->router_solicitations = g_value_get_int (value); - break; - case PROP_ROUTER_SOLICITATION_INTERVAL: - /* construct-only */ - priv->router_solicitation_interval = g_value_get_int (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -nm_rdisc_init (NMRDisc *rdisc) -{ - NMRDiscPrivate *priv; - NMRDiscDataInternal *rdata; - - priv = G_TYPE_INSTANCE_GET_PRIVATE (rdisc, NM_TYPE_RDISC, NMRDiscPrivate); - rdisc->_priv = priv; - - rdata = &priv->rdata; - - rdata->gateways = g_array_new (FALSE, FALSE, sizeof (NMRDiscGateway)); - rdata->addresses = g_array_new (FALSE, FALSE, sizeof (NMRDiscAddress)); - rdata->routes = g_array_new (FALSE, FALSE, sizeof (NMRDiscRoute)); - rdata->dns_servers = g_array_new (FALSE, FALSE, sizeof (NMRDiscDNSServer)); - rdata->dns_domains = g_array_new (FALSE, FALSE, sizeof (NMRDiscDNSDomain)); - g_array_set_clear_func (rdata->dns_domains, dns_domain_free); - priv->rdata.public.hop_limit = 64; - - /* Start at very low number so that last_rs - router_solicitation_interval - * is much lower than nm_utils_get_monotonic_timestamp_s() at startup. - */ - priv->last_rs = G_MININT32; -} - -static void -dispose (GObject *object) -{ - NMRDisc *rdisc = NM_RDISC (object); - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (rdisc); - - nm_clear_g_source (&priv->ra_timeout_id); - nm_clear_g_source (&priv->send_rs_id); - g_clear_pointer (&priv->last_send_rs_error, g_free); - - nm_clear_g_source (&priv->timeout_id); - - G_OBJECT_CLASS (nm_rdisc_parent_class)->dispose (object); -} - -static void -finalize (GObject *object) -{ - NMRDisc *rdisc = NM_RDISC (object); - NMRDiscPrivate *priv = NM_RDISC_GET_PRIVATE (rdisc); - NMRDiscDataInternal *rdata = &priv->rdata; - - g_free (priv->ifname); - g_free (priv->network_id); - - g_array_unref (rdata->gateways); - g_array_unref (rdata->addresses); - g_array_unref (rdata->routes); - g_array_unref (rdata->dns_servers); - g_array_unref (rdata->dns_domains); - - g_clear_object (&priv->netns); - g_clear_object (&priv->platform); - - G_OBJECT_CLASS (nm_rdisc_parent_class)->finalize (object); -} - -static void -nm_rdisc_class_init (NMRDiscClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (NMRDiscPrivate)); - - object_class->set_property = set_property; - object_class->dispose = dispose; - object_class->finalize = finalize; - - obj_properties[PROP_PLATFORM] = - g_param_spec_object (NM_RDISC_PLATFORM, "", "", - NM_TYPE_PLATFORM, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFINDEX] = - g_param_spec_int (NM_RDISC_IFINDEX, "", "", - 0, G_MAXINT, 0, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFNAME] = - g_param_spec_string (NM_RDISC_IFNAME, "", "", - NULL, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_STABLE_TYPE] = - g_param_spec_int (NM_RDISC_STABLE_TYPE, "", "", - NM_UTILS_STABLE_TYPE_UUID, NM_UTILS_STABLE_TYPE_STABLE_ID, NM_UTILS_STABLE_TYPE_UUID, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_NETWORK_ID] = - g_param_spec_string (NM_RDISC_NETWORK_ID, "", "", - NULL, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ADDR_GEN_MODE] = - g_param_spec_int (NM_RDISC_ADDR_GEN_MODE, "", "", - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_MAX_ADDRESSES] = - g_param_spec_int (NM_RDISC_MAX_ADDRESSES, "", "", - 0, G_MAXINT32, NM_RDISC_MAX_ADDRESSES_DEFAULT, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTER_SOLICITATIONS] = - g_param_spec_int (NM_RDISC_ROUTER_SOLICITATIONS, "", "", - 1, G_MAXINT32, NM_RDISC_ROUTER_SOLICITATIONS_DEFAULT, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_ROUTER_SOLICITATION_INTERVAL] = - g_param_spec_int (NM_RDISC_ROUTER_SOLICITATION_INTERVAL, "", "", - 1, G_MAXINT32, NM_RDISC_ROUTER_SOLICITATION_INTERVAL_DEFAULT, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - - signals[CONFIG_CHANGED] = - g_signal_new (NM_RDISC_CONFIG_CHANGED, - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT); - signals[RA_TIMEOUT] = - g_signal_new (NM_RDISC_RA_TIMEOUT, - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, NULL, - G_TYPE_NONE, 0); -} diff --git a/src/rdisc/nm-rdisc.h b/src/rdisc/nm-rdisc.h deleted file mode 100644 index 9e5e9349..00000000 --- a/src/rdisc/nm-rdisc.h +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* nm-rdisc.h - Perform IPv6 router discovery - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_RDISC_H__ -#define __NETWORKMANAGER_RDISC_H__ - -#include -#include - -#include "nm-setting-ip6-config.h" -#include "NetworkManagerUtils.h" - -#define NM_TYPE_RDISC (nm_rdisc_get_type ()) -#define NM_RDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_RDISC, NMRDisc)) -#define NM_RDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_RDISC, NMRDiscClass)) -#define NM_IS_RDISC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_RDISC)) -#define NM_IS_RDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_RDISC)) -#define NM_RDISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_RDISC, NMRDiscClass)) - -#define NM_RDISC_PLATFORM "platform" -#define NM_RDISC_IFINDEX "ifindex" -#define NM_RDISC_IFNAME "ifname" -#define NM_RDISC_NETWORK_ID "network-id" -#define NM_RDISC_ADDR_GEN_MODE "addr-gen-mode" -#define NM_RDISC_STABLE_TYPE "stable-type" -#define NM_RDISC_MAX_ADDRESSES "max-addresses" -#define NM_RDISC_ROUTER_SOLICITATIONS "router-solicitations" -#define NM_RDISC_ROUTER_SOLICITATION_INTERVAL "router-solicitation-interval" - -#define NM_RDISC_CONFIG_CHANGED "config-changed" -#define NM_RDISC_RA_TIMEOUT "ra-timeout" - -typedef enum { - NM_RDISC_DHCP_LEVEL_UNKNOWN, - NM_RDISC_DHCP_LEVEL_NONE, - NM_RDISC_DHCP_LEVEL_OTHERCONF, - NM_RDISC_DHCP_LEVEL_MANAGED -} NMRDiscDHCPLevel; - -typedef enum { - NM_RDISC_PREFERENCE_INVALID, - NM_RDISC_PREFERENCE_LOW, - NM_RDISC_PREFERENCE_MEDIUM, - NM_RDISC_PREFERENCE_HIGH -} NMRDiscPreference; - -typedef struct { - struct in6_addr address; - guint32 timestamp; - guint32 lifetime; - NMRDiscPreference preference; -} NMRDiscGateway; - -typedef struct { - struct in6_addr address; - guint8 dad_counter; - guint32 timestamp; - guint32 lifetime; - guint32 preferred; -} NMRDiscAddress; - -typedef struct { - struct in6_addr network; - guint8 plen; - struct in6_addr gateway; - guint32 timestamp; - guint32 lifetime; - NMRDiscPreference preference; -} NMRDiscRoute; - -typedef struct { - struct in6_addr address; - guint32 timestamp; - guint32 lifetime; -} NMRDiscDNSServer; - -typedef struct { - char *domain; - guint32 timestamp; - guint32 lifetime; -} NMRDiscDNSDomain; - -typedef enum { - NM_RDISC_CONFIG_DHCP_LEVEL = 1 << 0, - NM_RDISC_CONFIG_GATEWAYS = 1 << 1, - NM_RDISC_CONFIG_ADDRESSES = 1 << 2, - NM_RDISC_CONFIG_ROUTES = 1 << 3, - NM_RDISC_CONFIG_DNS_SERVERS = 1 << 4, - NM_RDISC_CONFIG_DNS_DOMAINS = 1 << 5, - NM_RDISC_CONFIG_HOP_LIMIT = 1 << 6, - NM_RDISC_CONFIG_MTU = 1 << 7, -} NMRDiscConfigMap; - -#define NM_RDISC_MAX_ADDRESSES_DEFAULT 16 -#define NM_RDISC_ROUTER_SOLICITATIONS_DEFAULT 3 -#define NM_RDISC_ROUTER_SOLICITATION_INTERVAL_DEFAULT 4 - -struct _NMRDiscPrivate; -struct _NMRDiscDataInternal; - -typedef struct { - NMRDiscDHCPLevel dhcp_level; - guint32 mtu; - int hop_limit; - - guint gateways_n; - guint addresses_n; - guint routes_n; - guint dns_servers_n; - guint dns_domains_n; - - const NMRDiscGateway *gateways; - const NMRDiscAddress *addresses; - const NMRDiscRoute *routes; - const NMRDiscDNSServer *dns_servers; - const NMRDiscDNSDomain *dns_domains; -} NMRDiscData; - -/** - * NMRDisc: - * - * Interface-specific structure that handles incoming router advertisements, - * caches advertised items and removes them when they are obsolete. - */ -typedef struct { - GObject parent; - union { - struct _NMRDiscPrivate *_priv; - struct _NMRDiscDataInternal *rdata; - }; -} NMRDisc; - -typedef struct { - GObjectClass parent; - - void (*start) (NMRDisc *rdisc); - gboolean (*send_rs) (NMRDisc *rdisc, GError **error); -} NMRDiscClass; - -GType nm_rdisc_get_type (void); - -int nm_rdisc_get_ifindex (NMRDisc *self); -const char *nm_rdisc_get_ifname (NMRDisc *self); - -gboolean nm_rdisc_set_iid (NMRDisc *rdisc, const NMUtilsIPv6IfaceId iid); -void nm_rdisc_start (NMRDisc *rdisc); -void nm_rdisc_dad_failed (NMRDisc *rdisc, struct in6_addr *address); - -NMPlatform *nm_rdisc_get_platform (NMRDisc *self); -NMPNetns *nm_rdisc_netns_get (NMRDisc *self); -gboolean nm_rdisc_netns_push (NMRDisc *self, NMPNetns **netns); - -#endif /* __NETWORKMANAGER_RDISC_H__ */ diff --git a/src/rdisc/tests/Makefile.am b/src/rdisc/tests/Makefile.am deleted file mode 100644 index b054179e..00000000 --- a/src/rdisc/tests/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -AM_CPPFLAGS = \ - -I${top_srcdir} \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I${top_srcdir}/src \ - -I${top_srcdir}/src/platform \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I${srcdir}/.. \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(LIBNDP_CFLAGS) - -AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -AM_LDFLAGS = \ - $(GLIB_LIBS) \ - $(CODE_COVERAGE_LDFLAGS) - -@GNOME_CODE_COVERAGE_RULES@ - -noinst_PROGRAMS = test-rdisc-linux test-rdisc-fake - -test_rdisc_linux_SOURCES = \ - test-rdisc-linux.c -test_rdisc_linux_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -test_rdisc_fake_SOURCES = \ - test-rdisc-fake.c -test_rdisc_fake_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -@VALGRIND_RULES@ -TESTS = test-rdisc-fake - diff --git a/src/rdisc/tests/Makefile.in b/src/rdisc/tests/Makefile.in deleted file mode 100644 index 3cbc48a0..00000000 --- a/src/rdisc/tests/Makefile.in +++ /dev/null @@ -1,1164 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-rdisc-linux$(EXEEXT) test-rdisc-fake$(EXEEXT) -TESTS = test-rdisc-fake$(EXEEXT) -subdir = src/rdisc/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_rdisc_fake_OBJECTS = test-rdisc-fake.$(OBJEXT) -test_rdisc_fake_OBJECTS = $(am_test_rdisc_fake_OBJECTS) -test_rdisc_fake_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManagerTest.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -am_test_rdisc_linux_OBJECTS = test-rdisc-linux.$(OBJEXT) -test_rdisc_linux_OBJECTS = $(am_test_rdisc_linux_OBJECTS) -test_rdisc_linux_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_rdisc_fake_SOURCES) $(test_rdisc_linux_SOURCES) -DIST_SOURCES = $(test_rdisc_fake_SOURCES) $(test_rdisc_linux_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I${top_srcdir} \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I${top_srcdir}/src \ - -I${top_srcdir}/src/platform \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I${srcdir}/.. \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(LIBNDP_CFLAGS) - -AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -AM_LDFLAGS = \ - $(GLIB_LIBS) \ - $(CODE_COVERAGE_LDFLAGS) - -test_rdisc_linux_SOURCES = \ - test-rdisc-linux.c - -test_rdisc_linux_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -test_rdisc_fake_SOURCES = \ - test-rdisc-fake.c - -test_rdisc_fake_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/rdisc/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/rdisc/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-rdisc-fake$(EXEEXT): $(test_rdisc_fake_OBJECTS) $(test_rdisc_fake_DEPENDENCIES) $(EXTRA_test_rdisc_fake_DEPENDENCIES) - @rm -f test-rdisc-fake$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_rdisc_fake_OBJECTS) $(test_rdisc_fake_LDADD) $(LIBS) - -test-rdisc-linux$(EXEEXT): $(test_rdisc_linux_OBJECTS) $(test_rdisc_linux_DEPENDENCIES) $(EXTRA_test_rdisc_linux_DEPENDENCIES) - @rm -f test-rdisc-linux$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_rdisc_linux_OBJECTS) $(test_rdisc_linux_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-rdisc-fake.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-rdisc-linux.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-rdisc-fake.log: test-rdisc-fake$(EXEEXT) - @p='test-rdisc-fake$(EXEEXT)'; \ - b='test-rdisc-fake'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/rdisc/tests/test-rdisc-fake.c b/src/rdisc/tests/test-rdisc-fake.c deleted file mode 100644 index 02ffb510..00000000 --- a/src/rdisc/tests/test-rdisc-fake.c +++ /dev/null @@ -1,483 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* rdisc.c - test program - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2015 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-rdisc.h" -#include "nm-fake-rdisc.h" - -#include "nm-fake-platform.h" - -#include "nm-test-utils-core.h" - -static NMFakeRDisc * -rdisc_new (void) -{ - NMRDisc *rdisc; - const int ifindex = 1; - const char *ifname = nm_platform_link_get_name (NM_PLATFORM_GET, ifindex); - NMUtilsIPv6IfaceId iid = { }; - - rdisc = nm_fake_rdisc_new (ifindex, ifname); - iid.id_u8[7] = 1; - nm_rdisc_set_iid (rdisc, iid); - g_assert (rdisc); - return NM_FAKE_RDISC (rdisc); -} - -static void -match_gateway (const NMRDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt, NMRDiscPreference pref) -{ - const NMRDiscGateway *gw; - char buf[INET6_ADDRSTRLEN]; - - g_assert (rdata); - g_assert_cmpint (idx, <, rdata->gateways_n); - g_assert (rdata->gateways); - - gw = &rdata->gateways[idx]; - - g_assert_cmpstr (inet_ntop (AF_INET6, &gw->address, buf, sizeof (buf)), ==, addr); - g_assert_cmpint (gw->timestamp, ==, ts); - g_assert_cmpint (gw->lifetime, ==, lt); - g_assert_cmpint (gw->preference, ==, pref); -} - -static void -match_address (const NMRDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt, guint32 preferred) -{ - const NMRDiscAddress *a; - char buf[INET6_ADDRSTRLEN]; - - g_assert (rdata); - g_assert_cmpint (idx, <, rdata->addresses_n); - g_assert (rdata->addresses); - - a = &rdata->addresses[idx]; - - g_assert_cmpstr (inet_ntop (AF_INET6, &a->address, buf, sizeof (buf)), ==, addr); - g_assert_cmpint (a->timestamp, ==, ts); - g_assert_cmpint (a->lifetime, ==, lt); - g_assert_cmpint (a->preferred, ==, preferred); -} - -static void -match_route (const NMRDiscData *rdata, guint idx, const char *nw, int plen, const char *gw, guint32 ts, guint32 lt, NMRDiscPreference pref) -{ - const NMRDiscRoute *route; - char buf[INET6_ADDRSTRLEN]; - - g_assert (rdata); - g_assert_cmpint (idx, <, rdata->routes_n); - g_assert (rdata->routes); - g_assert (plen > 0 && plen <= 128); - - route = &rdata->routes[idx]; - - g_assert_cmpstr (inet_ntop (AF_INET6, &route->network, buf, sizeof (buf)), ==, nw); - g_assert_cmpint ((int) route->plen, ==, plen); - g_assert_cmpstr (inet_ntop (AF_INET6, &route->gateway, buf, sizeof (buf)), ==, gw); - g_assert_cmpint (route->timestamp, ==, ts); - g_assert_cmpint (route->lifetime, ==, lt); - g_assert_cmpint (route->preference, ==, pref); -} - -static void -match_dns_server (const NMRDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt) -{ - const NMRDiscDNSServer *dns; - char buf[INET6_ADDRSTRLEN]; - - g_assert (rdata); - g_assert_cmpint (idx, <, rdata->dns_servers_n); - g_assert (rdata->dns_servers); - - dns = &rdata->dns_servers[idx]; - - g_assert_cmpstr (inet_ntop (AF_INET6, &dns->address, buf, sizeof (buf)), ==, addr); - g_assert_cmpint (dns->timestamp, ==, ts); - g_assert_cmpint (dns->lifetime, ==, lt); -} - -static void -match_dns_domain (const NMRDiscData *rdata, guint idx, const char *domain, guint32 ts, guint32 lt) -{ - const NMRDiscDNSDomain *dns; - - g_assert (rdata); - g_assert_cmpint (idx, <, rdata->dns_domains_n); - g_assert (rdata->dns_domains); - - dns = &rdata->dns_domains[idx]; - - g_assert_cmpstr (dns->domain, ==, domain); - g_assert_cmpint (dns->timestamp, ==, ts); - g_assert_cmpint (dns->lifetime, ==, lt); -} - -typedef struct { - GMainLoop *loop; - guint counter; - guint rs_counter; - guint32 timestamp1; - guint32 first_solicit; - guint32 timeout_id; -} TestData; - -static void -test_simple_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_int, TestData *data) -{ - NMRDiscConfigMap changed = changed_int; - - g_assert_cmpint (changed, ==, NM_RDISC_CONFIG_DHCP_LEVEL | - NM_RDISC_CONFIG_GATEWAYS | - NM_RDISC_CONFIG_ADDRESSES | - NM_RDISC_CONFIG_ROUTES | - NM_RDISC_CONFIG_DNS_SERVERS | - NM_RDISC_CONFIG_DNS_DOMAINS | - NM_RDISC_CONFIG_HOP_LIMIT | - NM_RDISC_CONFIG_MTU); - g_assert_cmpint (rdata->dhcp_level, ==, NM_RDISC_DHCP_LEVEL_OTHERCONF); - match_gateway (rdata, 0, "fe80::1", data->timestamp1, 10, NM_RDISC_PREFERENCE_MEDIUM); - match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1, 10, 10); - match_route (rdata, 0, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1, 10, 10); - match_dns_server (rdata, 0, "2001:db8:c:c::1", data->timestamp1, 10); - match_dns_domain (rdata, 0, "foobar.com", data->timestamp1, 10); - - g_assert (nm_fake_rdisc_done (NM_FAKE_RDISC (rdisc))); - data->counter++; - g_main_loop_quit (data->loop); -} - -static void -test_simple (void) -{ - NMFakeRDisc *rdisc = rdisc_new (); - guint32 now = nm_utils_get_monotonic_timestamp_s (); - TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now }; - guint id; - - id = nm_fake_rdisc_add_ra (rdisc, 1, NM_RDISC_DHCP_LEVEL_OTHERCONF, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::1", now, 10, NM_RDISC_PREFERENCE_MEDIUM); - nm_fake_rdisc_add_prefix (rdisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 10); - nm_fake_rdisc_add_dns_server (rdisc, id, "2001:db8:c:c::1", now, 10); - nm_fake_rdisc_add_dns_domain (rdisc, id, "foobar.com", now, 10); - - g_signal_connect (rdisc, - NM_RDISC_CONFIG_CHANGED, - G_CALLBACK (test_simple_changed), - &data); - - nm_rdisc_start (NM_RDISC (rdisc)); - g_main_loop_run (data.loop); - g_assert_cmpint (data.counter, ==, 1); - - g_object_unref (rdisc); - g_main_loop_unref (data.loop); -} - -static void -test_everything_rs_sent (NMRDisc *rdisc, TestData *data) -{ - g_assert_cmpint (data->rs_counter, ==, 0); - data->rs_counter++; -} - -static void -test_everything_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_int, TestData *data) -{ - NMRDiscConfigMap changed = changed_int; - - if (data->counter == 0) { - g_assert_cmpint (data->rs_counter, ==, 1); - g_assert_cmpint (changed, ==, NM_RDISC_CONFIG_DHCP_LEVEL | - NM_RDISC_CONFIG_GATEWAYS | - NM_RDISC_CONFIG_ADDRESSES | - NM_RDISC_CONFIG_ROUTES | - NM_RDISC_CONFIG_DNS_SERVERS | - NM_RDISC_CONFIG_DNS_DOMAINS | - NM_RDISC_CONFIG_HOP_LIMIT | - NM_RDISC_CONFIG_MTU); - match_gateway (rdata, 0, "fe80::1", data->timestamp1, 10, NM_RDISC_PREFERENCE_MEDIUM); - match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1, 10, 10); - match_route (rdata, 0, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1, 10, 10); - match_dns_server (rdata, 0, "2001:db8:c:c::1", data->timestamp1, 10); - match_dns_domain (rdata, 0, "foobar.com", data->timestamp1, 10); - } else if (data->counter == 1) { - g_assert_cmpint (changed, ==, NM_RDISC_CONFIG_GATEWAYS | - NM_RDISC_CONFIG_ADDRESSES | - NM_RDISC_CONFIG_ROUTES | - NM_RDISC_CONFIG_DNS_SERVERS | - NM_RDISC_CONFIG_DNS_DOMAINS); - - g_assert_cmpint (rdata->gateways_n, ==, 1); - match_gateway (rdata, 0, "fe80::2", data->timestamp1, 10, NM_RDISC_PREFERENCE_MEDIUM); - g_assert_cmpint (rdata->addresses_n, ==, 1); - match_address (rdata, 0, "2001:db8:a:b::1", data->timestamp1, 10, 10); - g_assert_cmpint (rdata->routes_n, ==, 1); - match_route (rdata, 0, "2001:db8:a:b::", 64, "fe80::2", data->timestamp1, 10, 10); - g_assert_cmpint (rdata->dns_servers_n, ==, 1); - match_dns_server (rdata, 0, "2001:db8:c:c::2", data->timestamp1, 10); - g_assert_cmpint (rdata->dns_domains_n, ==, 1); - match_dns_domain (rdata, 0, "foobar2.com", data->timestamp1, 10); - - g_assert (nm_fake_rdisc_done (NM_FAKE_RDISC (rdisc))); - g_main_loop_quit (data->loop); - } else - g_assert_not_reached (); - - data->counter++; -} - -static void -test_everything (void) -{ - NMFakeRDisc *rdisc = rdisc_new (); - guint32 now = nm_utils_get_monotonic_timestamp_s (); - TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now }; - guint id; - - id = nm_fake_rdisc_add_ra (rdisc, 1, NM_RDISC_DHCP_LEVEL_NONE, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::1", now, 10, NM_RDISC_PREFERENCE_MEDIUM); - nm_fake_rdisc_add_prefix (rdisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 10); - nm_fake_rdisc_add_dns_server (rdisc, id, "2001:db8:c:c::1", now, 10); - nm_fake_rdisc_add_dns_domain (rdisc, id, "foobar.com", now, 10); - - /* expire everything from the first RA in the second */ - id = nm_fake_rdisc_add_ra (rdisc, 1, NM_RDISC_DHCP_LEVEL_NONE, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::1", now, 0, NM_RDISC_PREFERENCE_MEDIUM); - nm_fake_rdisc_add_prefix (rdisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 0, 0, 0); - nm_fake_rdisc_add_dns_server (rdisc, id, "2001:db8:c:c::1", now, 0); - nm_fake_rdisc_add_dns_domain (rdisc, id, "foobar.com", now, 0); - - /* and add some new stuff */ - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::2", now, 10, NM_RDISC_PREFERENCE_MEDIUM); - nm_fake_rdisc_add_prefix (rdisc, id, "2001:db8:a:b::", 64, "fe80::2", now, 10, 10, 10); - nm_fake_rdisc_add_dns_server (rdisc, id, "2001:db8:c:c::2", now, 10); - nm_fake_rdisc_add_dns_domain (rdisc, id, "foobar2.com", now, 10); - - g_signal_connect (rdisc, - NM_RDISC_CONFIG_CHANGED, - G_CALLBACK (test_everything_changed), - &data); - g_signal_connect (rdisc, - NM_FAKE_RDISC_RS_SENT, - G_CALLBACK (test_everything_rs_sent), - &data); - - nm_rdisc_start (NM_RDISC (rdisc)); - g_main_loop_run (data.loop); - g_assert_cmpint (data.counter, ==, 2); - g_assert_cmpint (data.rs_counter, ==, 1); - - g_object_unref (rdisc); - g_main_loop_unref (data.loop); -} - -static void -test_preference_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_int, TestData *data) -{ - NMRDiscConfigMap changed = changed_int; - - if (data->counter == 1) { - g_assert_cmpint (changed, ==, NM_RDISC_CONFIG_GATEWAYS | - NM_RDISC_CONFIG_ADDRESSES | - NM_RDISC_CONFIG_ROUTES); - g_assert_cmpint (rdata->gateways_n, ==, 2); - match_gateway (rdata, 0, "fe80::2", data->timestamp1 + 1, 10, NM_RDISC_PREFERENCE_MEDIUM); - match_gateway (rdata, 1, "fe80::1", data->timestamp1, 10, NM_RDISC_PREFERENCE_LOW); - g_assert_cmpint (rdata->addresses_n, ==, 2); - match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1, 10, 10); - match_address (rdata, 1, "2001:db8:a:b::1", data->timestamp1 + 1, 10, 10); - g_assert_cmpint (rdata->routes_n, ==, 2); - match_route (rdata, 0, "2001:db8:a:b::", 64, "fe80::2", data->timestamp1 + 1, 10, 10); - match_route (rdata, 1, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1, 10, 5); - } else if (data->counter == 2) { - g_assert_cmpint (changed, ==, NM_RDISC_CONFIG_GATEWAYS | - NM_RDISC_CONFIG_ADDRESSES | - NM_RDISC_CONFIG_ROUTES); - - g_assert_cmpint (rdata->gateways_n, ==, 2); - match_gateway (rdata, 0, "fe80::1", data->timestamp1 + 2, 10, NM_RDISC_PREFERENCE_HIGH); - match_gateway (rdata, 1, "fe80::2", data->timestamp1 + 1, 10, NM_RDISC_PREFERENCE_MEDIUM); - g_assert_cmpint (rdata->addresses_n, ==, 2); - match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1 + 2, 10, 10); - match_address (rdata, 1, "2001:db8:a:b::1", data->timestamp1 + 1, 10, 10); - g_assert_cmpint (rdata->routes_n, ==, 2); - match_route (rdata, 0, "2001:db8:a:a::", 64, "fe80::1", data->timestamp1 + 2, 10, 15); - match_route (rdata, 1, "2001:db8:a:b::", 64, "fe80::2", data->timestamp1 + 1, 10, 10); - - g_assert (nm_fake_rdisc_done (NM_FAKE_RDISC (rdisc))); - g_main_loop_quit (data->loop); - } - - data->counter++; -} - -static void -test_preference (void) -{ - NMFakeRDisc *rdisc = rdisc_new (); - guint32 now = nm_utils_get_monotonic_timestamp_s (); - TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now }; - guint id; - - /* Test that when a low-preference and medium gateway send advertisements, - * that if the low-preference gateway switches to high-preference, we do - * not get duplicates in the gateway list. - */ - - id = nm_fake_rdisc_add_ra (rdisc, 1, NM_RDISC_DHCP_LEVEL_NONE, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::1", now, 10, NM_RDISC_PREFERENCE_LOW); - nm_fake_rdisc_add_prefix (rdisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 5); - - id = nm_fake_rdisc_add_ra (rdisc, 1, NM_RDISC_DHCP_LEVEL_NONE, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::2", ++now, 10, NM_RDISC_PREFERENCE_MEDIUM); - nm_fake_rdisc_add_prefix (rdisc, id, "2001:db8:a:b::", 64, "fe80::2", now, 10, 10, 10); - - id = nm_fake_rdisc_add_ra (rdisc, 1, NM_RDISC_DHCP_LEVEL_NONE, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::1", ++now, 10, NM_RDISC_PREFERENCE_HIGH); - nm_fake_rdisc_add_prefix (rdisc, id, "2001:db8:a:a::", 64, "fe80::1", now, 10, 10, 15); - - g_signal_connect (rdisc, - NM_RDISC_CONFIG_CHANGED, - G_CALLBACK (test_preference_changed), - &data); - - nm_rdisc_start (NM_RDISC (rdisc)); - g_main_loop_run (data.loop); - g_assert_cmpint (data.counter, ==, 3); - - g_object_unref (rdisc); - g_main_loop_unref (data.loop); -} - -static void -test_dns_solicit_loop_changed (NMRDisc *rdisc, const NMRDiscData *rdata, guint changed_int, TestData *data) -{ - data->counter++; -} - -static gboolean -success_timeout (TestData *data) -{ - data->timeout_id = 0; - g_main_loop_quit (data->loop); - return G_SOURCE_REMOVE; -} - -static void -test_dns_solicit_loop_rs_sent (NMFakeRDisc *rdisc, TestData *data) -{ - guint32 now = nm_utils_get_monotonic_timestamp_s (); - guint id; - - if (data->rs_counter > 0 && data->rs_counter < 6) { - if (data->rs_counter == 1) { - data->first_solicit = now; - /* Kill the test after 10 seconds if it hasn't failed yet */ - data->timeout_id = g_timeout_add_seconds (10, (GSourceFunc) success_timeout, data); - } - - /* On all but the first solicitation, which should be triggered by the - * DNS servers reaching 1/2 lifetime, emit a new RA without the DNS - * servers again. - */ - id = nm_fake_rdisc_add_ra (rdisc, 0, NM_RDISC_DHCP_LEVEL_NONE, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::1", now, 10, NM_RDISC_PREFERENCE_MEDIUM); - - nm_fake_rdisc_emit_new_ras (rdisc); - } else if (data->rs_counter >= 6) { - /* Fail if we've sent too many solicitations in the past 4 seconds */ - g_assert_cmpint (now - data->first_solicit, >, 4); - g_source_remove (data->timeout_id); - g_main_loop_quit (data->loop); - } - data->rs_counter++; -} - -static void -test_dns_solicit_loop (void) -{ - NMFakeRDisc *rdisc = rdisc_new (); - guint32 now = nm_utils_get_monotonic_timestamp_s (); - TestData data = { g_main_loop_new (NULL, FALSE), 0, 0, now, 0 }; - guint id; - - /* Ensure that no solicitation loop happens when DNS servers or domains - * stop being sent in advertisements. This can happen if two routers - * send RAs, but the one sending DNS info stops responding, or if one - * router removes the DNS info from the RA without zero-lifetiming them - * first. - */ - - id = nm_fake_rdisc_add_ra (rdisc, 1, NM_RDISC_DHCP_LEVEL_NONE, 4, 1500); - g_assert (id); - nm_fake_rdisc_add_gateway (rdisc, id, "fe80::1", now, 10, NM_RDISC_PREFERENCE_LOW); - nm_fake_rdisc_add_dns_server (rdisc, id, "2001:db8:c:c::1", now, 6); - - g_signal_connect (rdisc, - NM_RDISC_CONFIG_CHANGED, - G_CALLBACK (test_dns_solicit_loop_changed), - &data); - g_signal_connect (rdisc, - NM_FAKE_RDISC_RS_SENT, - G_CALLBACK (test_dns_solicit_loop_rs_sent), - &data); - - nm_rdisc_start (NM_RDISC (rdisc)); - g_main_loop_run (data.loop); - g_assert_cmpint (data.counter, ==, 3); - - g_object_unref (rdisc); - g_main_loop_unref (data.loop); -} - -NMTST_DEFINE (); - -int -main (int argc, char **argv) -{ - nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT"); - - if (nmtst_test_quick ()) { - g_print ("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", g_get_prgname () ?: "test-rdisc-fake"); - return g_test_run (); - } - - nm_fake_platform_setup (); - - g_test_add_func ("/rdisc/simple", test_simple); - g_test_add_func ("/rdisc/everything-changed", test_everything); - g_test_add_func ("/rdisc/preference-changed", test_preference); - g_test_add_func ("/rdisc/dns-solicit-loop", test_dns_solicit_loop); - - return g_test_run (); -} diff --git a/src/rdisc/tests/test-rdisc-linux.c b/src/rdisc/tests/test-rdisc-linux.c deleted file mode 100644 index 299abf3e..00000000 --- a/src/rdisc/tests/test-rdisc-linux.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* rdisc.c - test program - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2013 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-rdisc.h" -#include "nm-lndp-rdisc.h" - -#include "nm-linux-platform.h" - -#include "nm-test-utils-core.h" - -NMTST_DEFINE (); - -int -main (int argc, char **argv) -{ - GMainLoop *loop; - NMRDisc *rdisc; - int ifindex = 1; - const char *ifname; - NMUtilsIPv6IfaceId iid = { }; - GError *error = NULL; - - nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT"); - - if (getuid () != 0) { - g_print ("Missing permission: must run as root\n"); - return EXIT_FAILURE; - } - - loop = g_main_loop_new (NULL, FALSE); - - nm_linux_platform_setup (); - - if (argv[1]) { - ifname = argv[1]; - ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname); - } else { - g_print ("Missing command line argument \"interface-name\"\n"); - return EXIT_FAILURE; - } - - rdisc = nm_lndp_rdisc_new (NM_PLATFORM_GET, - ifindex, - ifname, - NM_UTILS_STABLE_TYPE_UUID, - "8ce666e8-d34d-4fb1-b858-f15a7al28086", - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, - &error); - if (!rdisc) { - g_print ("Failed to create NMRDisc instance: %s\n", error->message); - g_error_free (error); - return EXIT_FAILURE; - } - - iid.id_u8[7] = 1; - nm_rdisc_set_iid (rdisc, iid); - nm_rdisc_start (rdisc); - g_main_loop_run (loop); - - g_clear_object (&rdisc); - - return EXIT_SUCCESS; -} diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index 54ca2f55..0db20979 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -30,7 +30,6 @@ #include "nm-secret-agent.h" #include "nm-auth-utils.h" #include "nm-setting-vpn.h" -#include "nm-enum-types.h" #include "nm-auth-manager.h" #include "nm-bus-manager.h" #include "nm-session-monitor.h" @@ -38,9 +37,49 @@ #include "NetworkManagerUtils.h" #include "nm-core-internal.h" -#include "nmdbus-agent-manager.h" +#include "introspection/org.freedesktop.NetworkManager.AgentManager.h" -NM_DEFINE_SINGLETON_INSTANCE (NMAgentManager); +/*****************************************************************************/ + +enum { + AGENT_REGISTERED, + LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct { + NMAuthManager *auth_mgr; + + /* Auth chains for checking agent permissions */ + GSList *chains; + + /* Hashed by owner name, not identifier, since two agents in different + * sessions can use the same identifier. + */ + GHashTable *agents; + + GHashTable *requests; +} NMAgentManagerPrivate; + +struct _NMAgentManager { + NMExportedObject parent; + NMAgentManagerPrivate _priv; +}; + +struct _NMAgentManagerClass { + NMExportedObjectClass parent; +}; + +G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, NM_TYPE_EXPORTED_OBJECT) + +#define NM_AGENT_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMAgentManager, NM_IS_AGENT_MANAGER) + +/*****************************************************************************/ + +NM_DEFINE_SINGLETON_GETTER (NMAgentManager, nm_agent_manager_get, NM_TYPE_AGENT_MANAGER); + +/*****************************************************************************/ #define _NMLOG_PREFIX_NAME "agent-manager" #define _NMLOG_DOMAIN LOGD_AGENTS @@ -78,6 +117,24 @@ NM_DEFINE_SINGLETON_INSTANCE (NMAgentManager); "/\"", (req)->con.get.setting_name, "\"", \ ((req)->request_type == REQUEST_TYPE_CON_GET ? "/(none)" : _request_type_to_string ((req)->request_type, FALSE))) +/*****************************************************************************/ + +typedef struct _NMAgentManagerCallId Request; + +static void request_add_agent (Request *req, NMSecretAgent *agent); + +static void request_remove_agent (Request *req, NMSecretAgent *agent, GSList **pending_reqs); + +static void request_next_agent (Request *req); + +static void _con_get_request_start (Request *req); +static void _con_save_request_start (Request *req); +static void _con_del_request_start (Request *req); + +static gboolean _con_get_try_complete_early (Request *req); + +/*****************************************************************************/ + typedef enum { REQUEST_TYPE_INVALID, REQUEST_TYPE_CON_GET, @@ -96,49 +153,7 @@ _request_type_to_string (RequestType request_type, gboolean verbose) } } -G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, NM_TYPE_EXPORTED_OBJECT) - -#define NM_AGENT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_AGENT_MANAGER, \ - NMAgentManagerPrivate)) - -typedef struct { - NMAuthManager *auth_mgr; - - /* Auth chains for checking agent permissions */ - GSList *chains; - - /* Hashed by owner name, not identifier, since two agents in different - * sessions can use the same identifier. - */ - GHashTable *agents; - - GHashTable *requests; -} NMAgentManagerPrivate; - -enum { - AGENT_REGISTERED, - - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - - -typedef struct _NMAgentManagerCallId Request; - -static void request_add_agent (Request *req, NMSecretAgent *agent); - -static void request_remove_agent (Request *req, NMSecretAgent *agent, GSList **pending_reqs); - -static void request_next_agent (Request *req); - -static void _con_get_request_start (Request *req); -static void _con_save_request_start (Request *req); -static void _con_del_request_start (Request *req); - -static gboolean _con_get_try_complete_early (Request *req); - -/*************************************************************/ +/*****************************************************************************/ static gboolean remove_agent (NMAgentManager *self, const char *owner) @@ -186,7 +201,7 @@ maybe_remove_agent_on_error (NMSecretAgent *agent, remove_agent (nm_agent_manager_get (), nm_secret_agent_get_dbus_owner (agent)); } -/*************************************************************/ +/*****************************************************************************/ static gboolean validate_identifier (const char *identifier, GError **error) @@ -433,7 +448,7 @@ done: g_free (sender); } -/*************************************************************/ +/*****************************************************************************/ struct _NMAgentManagerCallId { NMAgentManager *self; @@ -582,7 +597,7 @@ req_complete_cancel (Request *req, gboolean is_disposing) gs_free_error GError *error = NULL; nm_assert (req && req->self); - nm_assert (!g_hash_table_contains (NM_AGENT_MANAGER_GET_PRIVATE (req->self)->requests, req)); + nm_assert (!g_hash_table_contains (req->self->_priv.requests, req)); nm_utils_error_set_cancelled (&error, is_disposing, "NMAgentManager"); req_complete_release (req, NULL, NULL, NULL, error); @@ -815,7 +830,7 @@ out: return FALSE; } -/*************************************************************/ +/*****************************************************************************/ static void _con_get_request_done (NMSecretAgent *agent, @@ -1263,7 +1278,7 @@ nm_agent_manager_cancel_secrets (NMAgentManager *self, req_complete_cancel (request_id, FALSE); } -/*************************************************************/ +/*****************************************************************************/ static void _con_save_request_done (NMSecretAgent *agent, @@ -1352,7 +1367,7 @@ nm_agent_manager_save_secrets (NMAgentManager *self, req->idle_id = g_idle_add (request_start, req); } -/*************************************************************/ +/*****************************************************************************/ static void _con_del_request_done (NMSecretAgent *agent, @@ -1440,7 +1455,7 @@ nm_agent_manager_delete_secrets (NMAgentManager *self, req->idle_id = g_idle_add (request_start, req); } -/*************************************************************/ +/*****************************************************************************/ NMSecretAgent * nm_agent_manager_get_agent_by_user (NMAgentManager *self, const char *username) @@ -1458,7 +1473,7 @@ nm_agent_manager_get_agent_by_user (NMAgentManager *self, const char *username) return NULL; } -/*************************************************************/ +/*****************************************************************************/ gboolean nm_agent_manager_all_agents_have_capability (NMAgentManager *manager, @@ -1484,7 +1499,7 @@ nm_agent_manager_all_agents_have_capability (NMAgentManager *manager, return TRUE; } -/*************************************************************/ +/*****************************************************************************/ static void agent_permissions_changed_done (NMAuthChain *chain, @@ -1548,9 +1563,7 @@ authority_changed_cb (NMAuthManager *auth_manager, NMAgentManager *self) } } -/*************************************************************/ - -NM_DEFINE_SINGLETON_GETTER (NMAgentManager, nm_agent_manager_get, NM_TYPE_AGENT_MANAGER); +/*****************************************************************************/ static void nm_agent_manager_init (NMAgentManager *self) @@ -1564,7 +1577,7 @@ nm_agent_manager_init (NMAgentManager *self) static void constructed (GObject *object) { - NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (object); + NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE ((NMAgentManager *) object); G_OBJECT_CLASS (nm_agent_manager_parent_class)->constructed (object); @@ -1583,7 +1596,7 @@ constructed (GObject *object) static void dispose (GObject *object) { - NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (object); + NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE ((NMAgentManager *) object); if (priv->requests) { GHashTableIter iter; @@ -1626,24 +1639,20 @@ nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class) GObjectClass *object_class = G_OBJECT_CLASS (agent_manager_class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (agent_manager_class); - g_type_class_add_private (agent_manager_class, sizeof (NMAgentManagerPrivate)); - exported_object_class->export_path = NM_DBUS_PATH_AGENT_MANAGER; - /* virtual methods */ object_class->constructed = constructed; object_class->dispose = dispose; - /* Signals */ signals[AGENT_REGISTERED] = - g_signal_new ("agent-registered", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMAgentManagerClass, agent_registered), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - G_TYPE_OBJECT); + g_signal_new ("agent-registered", + 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); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (agent_manager_class), NMDBUS_TYPE_AGENT_MANAGER_SKELETON, diff --git a/src/settings/nm-agent-manager.h b/src/settings/nm-agent-manager.h index 8240a2b5..7f812693 100644 --- a/src/settings/nm-agent-manager.h +++ b/src/settings/nm-agent-manager.h @@ -33,19 +33,9 @@ #define NM_IS_AGENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AGENT_MANAGER)) #define NM_AGENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AGENT_MANAGER, NMAgentManagerClass)) -struct _NMAgentManagerCallId; typedef struct _NMAgentManagerCallId *NMAgentManagerCallId; -struct _NMAgentManager { - NMExportedObject parent; -}; - -typedef struct { - NMExportedObjectClass parent; - - /* Signals */ - void (*agent_registered) (NMAgentManager *agent_mgr, NMSecretAgent *agent); -} NMAgentManagerClass; +typedef struct _NMAgentManagerClass NMAgentManagerClass; GType nm_agent_manager_get_type (void); diff --git a/src/settings/nm-inotify-helper.c b/src/settings/nm-inotify-helper.c index 46112648..a0432a25 100644 --- a/src/settings/nm-inotify-helper.c +++ b/src/settings/nm-inotify-helper.c @@ -20,35 +20,51 @@ #include "nm-default.h" +#include "nm-inotify-helper.h" + #include #include #include #include -#include "nm-inotify-helper.h" #include "NetworkManagerUtils.h" /* NOTE: this code should be killed once we depend on a new enough glib to * include the patches from https://bugzilla.gnome.org/show_bug.cgi?id=532815 */ -G_DEFINE_TYPE (NMInotifyHelper, nm_inotify_helper, G_TYPE_OBJECT) +/*****************************************************************************/ -#define NM_INOTIFY_HELPER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_INOTIFY_HELPER, NMInotifyHelperPrivate)) +enum { + EVENT, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { int ifd; - GHashTable *wd_refs; } NMInotifyHelperPrivate; -/* Signals */ -enum { - EVENT, - LAST_SIGNAL +struct _NMInotifyHelper { + GObject parent; + NMInotifyHelperPrivate _priv; }; -static guint signals[LAST_SIGNAL] = { 0 }; +struct _NMInotifyHelperClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMInotifyHelper, nm_inotify_helper, G_TYPE_OBJECT) + +#define NM_INOTIFY_HELPER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMInotifyHelper, NM_IS_INOTIFY_HELPER) + +/*****************************************************************************/ + +NM_DEFINE_SINGLETON_GETTER (NMInotifyHelper, nm_inotify_helper_get, NM_TYPE_INOTIFY_HELPER); + +/*****************************************************************************/ int nm_inotify_helper_add_watch (NMInotifyHelper *self, const char *path) @@ -139,7 +155,7 @@ init_inotify (NMInotifyHelper *self) /* Watch the inotify descriptor for file/directory change events */ channel = g_io_channel_unix_new (priv->ifd); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); - g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_encoding (channel, NULL, NULL); source_id = g_io_add_watch (channel, G_IO_IN | G_IO_ERR, @@ -149,7 +165,7 @@ init_inotify (NMInotifyHelper *self) return TRUE; } -NM_DEFINE_SINGLETON_GETTER (NMInotifyHelper, nm_inotify_helper_get, NM_TYPE_INOTIFY_HELPER); +/*****************************************************************************/ static void nm_inotify_helper_init (NMInotifyHelper *self) @@ -170,7 +186,7 @@ constructed (GObject *object) static void finalize (GObject *object) { - NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE (object); + NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE ((NMInotifyHelper *) object); if (priv->ifd >= 0) close (priv->ifd); @@ -185,19 +201,15 @@ nm_inotify_helper_class_init (NMInotifyHelperClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMInotifyHelperPrivate)); - - /* Virtual methods */ object_class->constructed = constructed; object_class->finalize = finalize; - /* Signals */ signals[EVENT] = - g_signal_new ("event", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMInotifyHelperClass, event), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING); + g_signal_new ("event", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING); } diff --git a/src/settings/nm-inotify-helper.h b/src/settings/nm-inotify-helper.h index 2ac9376c..2715f3ee 100644 --- a/src/settings/nm-inotify-helper.h +++ b/src/settings/nm-inotify-helper.h @@ -18,10 +18,8 @@ * (C) Copyright 2008 Red Hat, Inc. */ -#ifndef __INOTIFY_HELPER_H__ -#define __INOTIFY_HELPER_H__ - -#include +#ifndef __NM_INOTIFY_HELPER_H__ +#define __NM_INOTIFY_HELPER_H__ /* NOTE: this code should be killed once we depend on a new enough glib to * include the patches from https://bugzilla.gnome.org/show_bug.cgi?id=532815 @@ -34,16 +32,8 @@ #define NM_IS_INOTIFY_HELPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_INOTIFY_HELPER)) #define NM_INOTIFY_HELPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_INOTIFY_HELPER, NMInotifyHelperClass)) -typedef struct { - GObject parent; -} NMInotifyHelper; - -typedef struct { - GObjectClass parent; - - /* signals */ - void (* event) (NMInotifyHelper *helper, struct inotify_event *evt, const char *filename); -} NMInotifyHelperClass; +typedef struct _NMInotifyHelper NMInotifyHelper; +typedef struct _NMInotifyHelperClass NMInotifyHelperClass; GType nm_inotify_helper_get_type (void); @@ -53,4 +43,4 @@ int nm_inotify_helper_add_watch (NMInotifyHelper *helper, const char *path); void nm_inotify_helper_remove_watch (NMInotifyHelper *helper, int wd); -#endif /* __INOTIFY_HELPER_H__ */ +#endif /* __NM_INOTIFY_HELPER_H__ */ diff --git a/src/settings/nm-secret-agent.c b/src/settings/nm-secret-agent.c index 8bc88fd4..6ec96a32 100644 --- a/src/settings/nm-secret-agent.c +++ b/src/settings/nm-secret-agent.c @@ -20,43 +20,27 @@ #include "nm-default.h" +#include "nm-secret-agent.h" + #include #include #include "nm-dbus-interface.h" -#include "nm-secret-agent.h" #include "nm-bus-manager.h" #include "nm-auth-subject.h" #include "nm-simple-connection.h" #include "NetworkManagerUtils.h" -#include "nmdbus-secret-agent.h" +#include "introspection/org.freedesktop.NetworkManager.SecretAgent.h" -#define _NMLOG_PREFIX_NAME "secret-agent" -#define _NMLOG_DOMAIN LOGD_AGENTS -#define _NMLOG(level, ...) \ - G_STMT_START { \ - if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \ - char __prefix[32]; \ - \ - if ((self)) \ - g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \ - else \ - g_strlcpy (__prefix, _NMLOG_PREFIX_NAME, sizeof (__prefix)); \ - _nm_log ((level), (_NMLOG_DOMAIN), 0, \ - "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } \ - } G_STMT_END - -#define LOG_REQ_FMT "req[%p,%s,%s%s%s%s]" -#define LOG_REQ_ARG(req) (req), (req)->dbus_command, NM_PRINT_FMT_QUOTE_STRING ((req)->path), ((req)->cancellable ? "" : " (cancelled)") +/*****************************************************************************/ -G_DEFINE_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT) +enum { + DISCONNECTED, -#define NM_SECRET_AGENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_SECRET_AGENT, \ - NMSecretAgentPrivate)) + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { char *description; @@ -77,14 +61,42 @@ typedef struct { GHashTable *requests; } NMSecretAgentPrivate; -enum { - DISCONNECTED, +struct _NMSecretAgent { + GObject parent; + NMSecretAgentPrivate _priv; +}; - LAST_SIGNAL +struct _NMSecretAgentClass { + GObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; -/*************************************************************/ +G_DEFINE_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT) + +#define NM_SECRET_AGENT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSecretAgent, NM_IS_SECRET_AGENT) + +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "secret-agent" +#define _NMLOG_DOMAIN LOGD_AGENTS +#define _NMLOG(level, ...) \ + G_STMT_START { \ + if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \ + char __prefix[32]; \ + \ + if ((self)) \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \ + else \ + g_strlcpy (__prefix, _NMLOG_PREFIX_NAME, sizeof (__prefix)); \ + _nm_log ((level), (_NMLOG_DOMAIN), 0, \ + "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } \ + } G_STMT_END + +#define LOG_REQ_FMT "req[%p,%s,%s%s%s%s]" +#define LOG_REQ_ARG(req) (req), (req)->dbus_command, NM_PRINT_FMT_QUOTE_STRING ((req)->path), ((req)->cancellable ? "" : " (cancelled)") + +/*****************************************************************************/ struct _NMSecretAgentCallId { NMSecretAgent *agent; @@ -153,7 +165,7 @@ request_check_return (Request *r) return TRUE; } -/*************************************************************/ +/*****************************************************************************/ static char * _create_description (const char *dbus_owner, const char *identifier, gulong uid) @@ -307,7 +319,7 @@ nm_secret_agent_has_permission (NMSecretAgent *agent, const char *permission) return FALSE; } -/*************************************************************/ +/*****************************************************************************/ static void get_callback (GObject *proxy, @@ -378,7 +390,7 @@ nm_secret_agent_get_secrets (NMSecretAgent *self, return r; } -/*************************************************************/ +/*****************************************************************************/ static void cancel_done (GObject *proxy, GAsyncResult *result, gpointer user_data) @@ -468,7 +480,7 @@ nm_secret_agent_cancel_secrets (NMSecretAgent *self, NMSecretAgentCallId call_id do_cancel_secrets (self, r, FALSE); } -/*************************************************************/ +/*****************************************************************************/ static void agent_save_cb (GObject *proxy, @@ -521,7 +533,7 @@ nm_secret_agent_save_secrets (NMSecretAgent *self, return r; } -/*************************************************************/ +/*****************************************************************************/ static void agent_delete_cb (GObject *proxy, @@ -574,7 +586,7 @@ nm_secret_agent_delete_secrets (NMSecretAgent *self, return r; } -/*************************************************************/ +/*****************************************************************************/ static void _on_disconnected_cleanup (NMSecretAgentPrivate *priv) @@ -640,7 +652,7 @@ _on_disconnected_name_owner_changed (GDBusConnection *connection, } } -/*************************************************************/ +/*****************************************************************************/ NMSecretAgent * nm_secret_agent_new (GDBusMethodInvocation *context, @@ -783,20 +795,16 @@ nm_secret_agent_class_init (NMSecretAgentClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); - g_type_class_add_private (config_class, sizeof (NMSecretAgentPrivate)); - - /* virtual methods */ object_class->dispose = dispose; object_class->finalize = finalize; - /* signals */ signals[DISCONNECTED] = - g_signal_new (NM_SECRET_AGENT_DISCONNECTED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSecretAgentClass, disconnected), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + g_signal_new (NM_SECRET_AGENT_DISCONNECTED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } diff --git a/src/settings/nm-secret-agent.h b/src/settings/nm-secret-agent.h index 916623a7..0b6da136 100644 --- a/src/settings/nm-secret-agent.h +++ b/src/settings/nm-secret-agent.h @@ -32,15 +32,7 @@ #define NM_SECRET_AGENT_DISCONNECTED "disconnected" -struct _NMSecretAgent { - GObject parent; -}; - -typedef struct { - GObjectClass parent; - - void (*disconnected) (NMSecretAgent *self); -} NMSecretAgentClass; +typedef struct _NMSecretAgentClass NMSecretAgentClass; typedef struct _NMSecretAgentCallId *NMSecretAgentCallId; diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index f22807d3..81dcb698 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -26,6 +26,8 @@ #include #include "nm-common-macros.h" +#include "nm-config.h" +#include "nm-config-data.h" #include "nm-dbus-interface.h" #include "nm-session-monitor.h" #include "nm-auth-utils.h" @@ -35,42 +37,19 @@ #include "nm-core-internal.h" #include "nm-audit-manager.h" -#include "nmdbus-settings-connection.h" +#include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h" #define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps" #define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids" -#define _NMLOG_DOMAIN LOGD_SETTINGS -#define _NMLOG_PREFIX_NAME "settings-connection" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - const NMLogLevel __level = (level); \ - \ - if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ - char __prefix[128]; \ - const char *__p_prefix = _NMLOG_PREFIX_NAME; \ - \ - if (self) { \ - const char *__uuid = nm_settings_connection_get_uuid (self); \ - \ - g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, self, __uuid ? "," : "", __uuid ? __uuid : ""); \ - __p_prefix = __prefix; \ - } \ - _nm_log (__level, _NMLOG_DOMAIN, 0, \ - "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -static void nm_settings_connection_connection_interface_init (NMConnectionInterface *iface); +#define AUTOCONNECT_RETRIES_UNSET -2 +#define AUTOCONNECT_RETRIES_FOREVER -1 +#define AUTOCONNECT_RETRIES_DEFAULT 4 +#define AUTOCONNECT_RESET_RETRIES_TIMER 300 -G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_EXPORTED_OBJECT, - G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init) - ) +/*****************************************************************************/ -#define NM_SETTINGS_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_SETTINGS_CONNECTION, \ - NMSettingsConnectionPrivate)) +static void nm_settings_connection_connection_interface_init (NMConnectionInterface *iface); NM_GOBJECT_PROPERTIES_DEFINE (NMSettingsConnection, PROP_VISIBLE, @@ -86,9 +65,10 @@ enum { UPDATED_INTERNAL, LAST_SIGNAL }; + static guint signals[LAST_SIGNAL] = { 0 }; -typedef struct { +typedef struct _NMSettingsConnectionPrivate { gboolean removed; NMAgentManager *agent_mgr; @@ -127,10 +107,39 @@ typedef struct { NMDeviceStateReason autoconnect_blocked_reason; char *filename; - } NMSettingsConnectionPrivate; -/*******************************************************************/ +G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_EXPORTED_OBJECT, + G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init) + ) + +#define NM_SETTINGS_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMSettingsConnection, NM_IS_SETTINGS_CONNECTION) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG_PREFIX_NAME "settings-connection" +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ + char __prefix[128]; \ + const char *__p_prefix = _NMLOG_PREFIX_NAME; \ + \ + if (self) { \ + const char *__uuid = nm_settings_connection_get_uuid (self); \ + \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, self, __uuid ? "," : "", __uuid ? __uuid : ""); \ + __p_prefix = __prefix; \ + } \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ + "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +/*****************************************************************************/ static void _emit_updated (NMSettingsConnection *self, gboolean by_user) @@ -139,7 +148,7 @@ _emit_updated (NMSettingsConnection *self, gboolean by_user) g_signal_emit (self, signals[UPDATED_INTERNAL], 0, by_user); } -/*******************************************************************/ +/*****************************************************************************/ gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *self, @@ -155,7 +164,7 @@ nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection * return nm_connection_compare (NM_CONNECTION (self), applied_connection, compare_flags); } -/**************************************************************/ +/*****************************************************************************/ /* Return TRUE to keep, FALSE to drop */ typedef gboolean (*ForEachSecretFunc) (NMSettingSecretFlags flags, @@ -290,7 +299,7 @@ find_secret (NMConnection *self, return data.found; } -/**************************************************************/ +/*****************************************************************************/ static void set_visible (NMSettingsConnection *self, gboolean new_visible) @@ -357,7 +366,7 @@ session_changed_cb (NMSessionMonitor *self, gpointer user_data) nm_settings_connection_recheck_visibility (NM_SETTINGS_CONNECTION (user_data)); } -/**************************************************************/ +/*****************************************************************************/ /* Return TRUE if any active user in the connection's ACL has the given * permission without having to authorize for it via PolicyKit. Connections @@ -408,7 +417,7 @@ nm_settings_connection_check_permission (NMSettingsConnection *self, return FALSE; } -/**************************************************************/ +/*****************************************************************************/ static gboolean secrets_filter_cb (NMSetting *setting, @@ -752,14 +761,14 @@ do_delete (NMSettingsConnection *self, /* Remove connection from seen-bssids database file */ remove_entry_from_db (self, "seen-bssids"); - nm_settings_connection_signal_remove (self); + nm_settings_connection_signal_remove (self, FALSE); callback (self, NULL, user_data); g_object_unref (self); } -/**************************************************************/ +/*****************************************************************************/ typedef enum { @@ -1933,7 +1942,7 @@ out_err: g_dbus_method_invocation_take_error (context, error); } -/**************************************************************/ +/*****************************************************************************/ static void dbus_get_agent_secrets_cb (NMSettingsConnection *self, @@ -2084,16 +2093,18 @@ impl_settings_connection_clear_secrets (NMSettingsConnection *self, } } -/**************************************************************/ +/*****************************************************************************/ void -nm_settings_connection_signal_remove (NMSettingsConnection *self) +nm_settings_connection_signal_remove (NMSettingsConnection *self, gboolean allow_reuse) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - if (priv->removed) - g_return_if_reached (); - priv->removed = TRUE; + if (!allow_reuse) { + if (priv->removed) + g_return_if_reached (); + priv->removed = TRUE; + } g_signal_emit_by_name (self, NM_SETTINGS_CONNECTION_REMOVED); } @@ -2103,7 +2114,7 @@ nm_settings_connection_get_unsaved (NMSettingsConnection *self) return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_UNSAVED); } -/**************************************************************/ +/*****************************************************************************/ NMSettingsConnectionFlags nm_settings_connection_get_flags (NMSettingsConnection *self) @@ -2149,7 +2160,7 @@ nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConn return old_flags; } -/*************************************************************/ +/*****************************************************************************/ /** * nm_settings_connection_get_timestamp: @@ -2431,12 +2442,47 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self) } } -#define AUTOCONNECT_RETRIES_DEFAULT 4 -#define AUTOCONNECT_RESET_RETRIES_TIMER 300 - +/** + * nm_settings_connection_get_autoconnect_retries: + * @self: the settings connection + * + * Returns the number of autoconnect retries left. If the value is + * not yet set, initialize it with the value from the connection or + * with the global default. + */ int nm_settings_connection_get_autoconnect_retries (NMSettingsConnection *self) { + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); + + if (priv->autoconnect_retries == AUTOCONNECT_RETRIES_UNSET) { + NMSettingConnection *s_con; + int retries = -1; + const char *value; + + s_con = nm_connection_get_setting_connection ((NMConnection *) self); + if (s_con) + retries = nm_setting_connection_get_autoconnect_retries (s_con); + + /* -1 means 'default' */ + if (retries == -1) { + value = nm_config_data_get_value_cached (NM_CONFIG_GET_DATA, + NM_CONFIG_KEYFILE_GROUP_MAIN, + "autoconnect-retries-default", + NM_CONFIG_GET_VALUE_STRIP); + + retries = _nm_utils_ascii_str_to_int64 (value, + 10, 0, G_MAXINT32, + AUTOCONNECT_RETRIES_DEFAULT); + } + + /* 0 means 'forever', which is translated to a retry count of -1 */ + if (retries == 0) + retries = AUTOCONNECT_RETRIES_FOREVER; + + priv->autoconnect_retries = retries; + } + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->autoconnect_retries; } @@ -2456,7 +2502,7 @@ nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *self, void nm_settings_connection_reset_autoconnect_retries (NMSettingsConnection *self) { - nm_settings_connection_set_autoconnect_retries (self, AUTOCONNECT_RETRIES_DEFAULT); + nm_settings_connection_set_autoconnect_retries (self, AUTOCONNECT_RETRIES_UNSET); } gint32 @@ -2604,12 +2650,15 @@ nm_settings_connection_get_uuid (NMSettingsConnection *self) return nm_connection_get_uuid (NM_CONNECTION (self)); } -/**************************************************************/ +/*****************************************************************************/ static void nm_settings_connection_init (NMSettingsConnection *self) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); + NMSettingsConnectionPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_SETTINGS_CONNECTION, NMSettingsConnectionPrivate); + self->_priv = priv; priv->visible = FALSE; priv->ready = TRUE; @@ -2623,7 +2672,7 @@ nm_settings_connection_init (NMSettingsConnection *self) priv->seen_bssids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - priv->autoconnect_retries = AUTOCONNECT_RETRIES_DEFAULT; + priv->autoconnect_retries = AUTOCONNECT_RETRIES_UNSET; priv->autoconnect_blocked_reason = NM_DEVICE_STATE_REASON_NONE; g_signal_connect (self, NM_CONNECTION_SECRETS_CLEARED, G_CALLBACK (secrets_cleared_cb), NULL); @@ -2746,9 +2795,8 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) g_type_class_add_private (class, sizeof (NMSettingsConnectionPrivate)); - exported_object_class->export_path = NM_DBUS_PATH_SETTINGS "/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH_SETTINGS); - /* Virtual methods */ object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; @@ -2759,7 +2807,6 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) class->delete = do_delete; class->supports_secrets = supports_secrets; - /* Properties */ obj_properties[PROP_VISIBLE] = g_param_spec_boolean (NM_SETTINGS_CONNECTION_VISIBLE, "", "", FALSE, @@ -2794,7 +2841,6 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - /* Signals */ signals[UPDATED] = g_signal_new (NM_SETTINGS_CONNECTION_UPDATED, diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 761203ea..c5ddd817 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -95,8 +95,11 @@ typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *self, GError *error, gpointer user_data); +struct _NMSettingsConnectionPrivate; + struct _NMSettingsConnection { NMExportedObject parent; + struct _NMSettingsConnectionPrivate *_priv; }; struct _NMSettingsConnectionClass { @@ -173,7 +176,7 @@ void nm_settings_connection_recheck_visibility (NMSettingsConnection *self); gboolean nm_settings_connection_check_permission (NMSettingsConnection *self, const char *permission); -void nm_settings_connection_signal_remove (NMSettingsConnection *self); +void nm_settings_connection_signal_remove (NMSettingsConnection *self, gboolean allow_reuse); gboolean nm_settings_connection_get_unsaved (NMSettingsConnection *self); diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index cd54e52c..6a920d5c 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -57,40 +57,32 @@ #include "nm-setting-adsl.h" #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" +#include "nm-setting-proxy.h" #include "nm-setting-bond.h" #include "nm-utils.h" #include "nm-core-internal.h" -#include "nm-device-ethernet.h" +#include "devices/nm-device-ethernet.h" #include "nm-settings-connection.h" #include "nm-settings-plugin.h" #include "nm-bus-manager.h" #include "nm-auth-utils.h" #include "nm-auth-subject.h" #include "nm-session-monitor.h" -#include "plugins/keyfile/plugin.h" +#include "plugins/keyfile/nms-keyfile-plugin.h" #include "nm-agent-manager.h" #include "nm-config.h" #include "nm-audit-manager.h" #include "NetworkManagerUtils.h" #include "nm-dispatcher.h" +#include "nm-inotify-helper.h" -#include "nmdbus-settings.h" +#include "introspection/org.freedesktop.NetworkManager.Settings.h" + +/*****************************************************************************/ -#define _NMLOG_DOMAIN LOGD_SETTINGS -#define _NMLOG_PREFIX_NAME "settings" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -/* LINKER CRACKROCK */ #define EXPORT(sym) void * __export_##sym = &sym; -#include "nm-inotify-helper.h" EXPORT(nm_inotify_helper_get_type) EXPORT(nm_inotify_helper_get) EXPORT(nm_inotify_helper_add_watch) @@ -99,7 +91,8 @@ EXPORT(nm_inotify_helper_remove_watch) EXPORT(nm_settings_connection_get_type) EXPORT(nm_settings_connection_replace_settings) EXPORT(nm_settings_connection_replace_and_commit) -/* END LINKER CRACKROCK */ + +/*****************************************************************************/ #define HOSTNAMED_SERVICE_NAME "org.freedesktop.hostname1" #define HOSTNAMED_SERVICE_PATH "/org/freedesktop/hostname1" @@ -127,17 +120,27 @@ EXPORT(nm_settings_connection_replace_and_commit) #define HOSTNAME_FILE HOSTNAME_FILE_DEFAULT #endif -static void claim_connection (NMSettings *self, - NMSettingsConnection *connection); +/*****************************************************************************/ -static void unmanaged_specs_changed (NMSettingsPlugin *config, gpointer user_data); -static void unrecognized_specs_changed (NMSettingsPlugin *config, gpointer user_data); +NM_GOBJECT_PROPERTIES_DEFINE (NMSettings, + PROP_UNMANAGED_SPECS, + PROP_HOSTNAME, + PROP_CAN_MODIFY, + PROP_CONNECTIONS, + PROP_STARTUP_COMPLETE, +); -static void connection_ready_changed (NMSettingsConnection *conn, - GParamSpec *pspec, - gpointer user_data); +enum { + CONNECTION_ADDED, + CONNECTION_UPDATED, + CONNECTION_REMOVED, + CONNECTION_VISIBILITY_CHANGED, + AGENT_REGISTERED, + NEW_CONNECTION, /* exported, not used internally */ + LAST_SIGNAL +}; -G_DEFINE_TYPE (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT); +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { NMAgentManager *agent_mgr; @@ -166,27 +169,37 @@ typedef struct { } hostname; } NMSettingsPrivate; -#define NM_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTINGS, NMSettingsPrivate)) - -enum { - CONNECTION_ADDED, - CONNECTION_UPDATED, - CONNECTION_REMOVED, - CONNECTION_VISIBILITY_CHANGED, - AGENT_REGISTERED, +struct _NMSettings { + NMExportedObject parent; + NMSettingsPrivate _priv; +}; - NEW_CONNECTION, /* exported, not used internally */ - LAST_SIGNAL +struct _NMSettingsClass { + NMExportedObjectClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; -NM_GOBJECT_PROPERTIES_DEFINE (NMSettings, - PROP_UNMANAGED_SPECS, - PROP_HOSTNAME, - PROP_CAN_MODIFY, - PROP_CONNECTIONS, - PROP_STARTUP_COMPLETE, -); +G_DEFINE_TYPE (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT); + +#define NM_SETTINGS_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSettings, NM_IS_SETTINGS) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "settings", __VA_ARGS__) + +/*****************************************************************************/ + +static void claim_connection (NMSettings *self, + NMSettingsConnection *connection); + +static void unmanaged_specs_changed (NMSettingsPlugin *config, gpointer user_data); +static void unrecognized_specs_changed (NMSettingsPlugin *config, gpointer user_data); + +static void connection_ready_changed (NMSettingsConnection *conn, + GParamSpec *pspec, + gpointer user_data); + +/*****************************************************************************/ static void check_startup_complete (NMSettings *self) @@ -778,10 +791,9 @@ find_plugin (GSList *list, const char *pname) static void add_keyfile_plugin (NMSettings *self) { - gs_unref_object GObject *keyfile_plugin = NULL; + gs_unref_object NMSKeyfilePlugin *keyfile_plugin = NULL; - keyfile_plugin = nm_settings_keyfile_plugin_new (); - g_assert (keyfile_plugin); + keyfile_plugin = nms_keyfile_plugin_new (); if (!add_plugin (self, NM_SETTINGS_PLUGIN (keyfile_plugin))) g_return_if_reached (); } @@ -1700,9 +1712,6 @@ write_hostname (NMSettingsPrivate *priv, const char *hostname) hostname_eol = g_strdup_printf ("%s\n", hostname); #endif - /* FIXME: g_file_set_contents() writes first to a temporary file - * and renames it atomically. We should hack g_file_set_contents() - * to set the SELINUX labels before renaming the file. */ ret = g_file_set_contents (file, hostname_eol, -1, &error); #if HAVE_SELINUX @@ -2072,7 +2081,7 @@ nm_settings_device_removed (NMSettings *self, NMDevice *device, gboolean quittin } } -/***************************************************************/ +/*****************************************************************************/ /* GCompareFunc helper for sorting "best" connections. * The function sorts connections in ascending timestamp order. @@ -2173,7 +2182,7 @@ nm_settings_get_best_connections (NMSettings *self, return g_slist_reverse (sorted); } -/***************************************************************/ +/*****************************************************************************/ gboolean nm_settings_get_startup_complete (NMSettings *self) @@ -2183,7 +2192,7 @@ nm_settings_get_startup_complete (NMSettings *self) return priv->startup_complete; } -/***************************************************************/ +/*****************************************************************************/ static void hostnamed_properties_changed (GDBusProxy *proxy, @@ -2268,22 +2277,6 @@ setup_hostname_file_monitors (NMSettings *self) hostname_maybe_changed (self); } -NMSettings * -nm_settings_new (void) -{ - NMSettings *self; - NMSettingsPrivate *priv; - - self = g_object_new (NM_TYPE_SETTINGS, NULL); - - priv = NM_SETTINGS_GET_PRIVATE (self); - - priv->config = nm_config_get (); - - nm_exported_object_export (NM_EXPORTED_OBJECT (self)); - return self; -} - gboolean nm_settings_start (NMSettings *self, GError **error) { @@ -2291,11 +2284,14 @@ nm_settings_start (NMSettings *self, GError **error) GDBusProxy *proxy; GVariant *variant; GError *local_error = NULL; + gs_strfreev char **plugins = 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)) { + plugins = nm_config_data_get_plugins (nm_config_get_data_orig (priv->config), TRUE); + + if (!load_plugins (self, (const char **) plugins, error)) { g_object_unref (self); return FALSE; } @@ -2333,6 +2329,57 @@ nm_settings_start (NMSettings *self, GError **error) return TRUE; } +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMSettings *self = NM_SETTINGS (object); + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); + const GSList *specs, *iter; + 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)) + 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)); + + /* Don't ever pass NULL through D-Bus */ + if (!g_value_get_string (value)) + g_value_set_static_string (value, ""); + break; + case PROP_CAN_MODIFY: + g_value_set_boolean (value, !!get_plugin (self, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS)); + break; + case PROP_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_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)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + static void nm_settings_init (NMSettings *self) { @@ -2347,9 +2394,17 @@ nm_settings_init (NMSettings *self) */ priv->agent_mgr = g_object_ref (nm_agent_manager_get ()); + priv->config = g_object_ref (nm_config_get ()); + g_signal_connect (priv->agent_mgr, "agent-registered", G_CALLBACK (secret_agent_registered), self); } +NMSettings * +nm_settings_new (void) +{ + return g_object_new (NM_TYPE_SETTINGS, NULL); +} + static void dispose (GObject *object) { @@ -2404,54 +2459,9 @@ finalize (GObject *object) g_slist_free_full (priv->plugins, g_object_unref); - G_OBJECT_CLASS (nm_settings_parent_class)->finalize (object); -} + g_clear_object (&priv->config); -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMSettings *self = NM_SETTINGS (object); - NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); - const GSList *specs, *iter; - 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)) - 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)); - - /* Don't ever pass NULL through D-Bus */ - if (!g_value_get_string (value)) - g_value_set_static_string (value, ""); - break; - case PROP_CAN_MODIFY: - g_value_set_boolean (value, !!get_plugin (self, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS)); - break; - case PROP_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_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)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + G_OBJECT_CLASS (nm_settings_parent_class)->finalize (object); } static void @@ -2460,17 +2470,12 @@ nm_settings_class_init (NMSettingsClass *class) GObjectClass *object_class = G_OBJECT_CLASS (class); NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (class); - g_type_class_add_private (class, sizeof (NMSettingsPrivate)); - exported_object_class->export_path = NM_DBUS_PATH_SETTINGS; - /* virtual methods */ object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; - /* properties */ - obj_properties[PROP_UNMANAGED_SPECS] = g_param_spec_boxed (NM_SETTINGS_UNMANAGED_SPECS, "", "", G_TYPE_STRV, @@ -2503,7 +2508,6 @@ nm_settings_class_init (NMSettingsClass *class) g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - /* signals */ signals[CONNECTION_ADDED] = g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_ADDED, G_OBJECT_CLASS_TYPE (object_class), diff --git a/src/settings/nm-settings.h b/src/settings/nm-settings.h index a0be42ee..c8a7ebae 100644 --- a/src/settings/nm-settings.h +++ b/src/settings/nm-settings.h @@ -61,13 +61,7 @@ typedef gboolean (*NMConnectionFilterFunc) (NMSettings *settings, NMConnection *connection, gpointer func_data); -struct _NMSettings { - NMExportedObject parent_instance; -}; - -typedef struct { - NMExportedObjectClass parent_class; -} NMSettingsClass; +typedef struct _NMSettingsClass NMSettingsClass; typedef void (*NMSettingsSetHostnameCb) (const char *name, gboolean result, gpointer user_data); diff --git a/src/settings/plugins/Makefile.am b/src/settings/plugins/Makefile.am deleted file mode 100644 index 278d455d..00000000 --- a/src/settings/plugins/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -SUBDIRS=keyfile - -@GNOME_CODE_COVERAGE_RULES@ - -if CONFIG_PLUGIN_IBFT -SUBDIRS+=ibft -endif - -if CONFIG_PLUGIN_IFCFG_RH -SUBDIRS+=ifcfg-rh -endif - -if CONFIG_PLUGIN_IFUPDOWN -SUBDIRS+=ifupdown -endif - -if CONFIG_PLUGIN_IFNET -SUBDIRS+=ifnet -endif diff --git a/src/settings/plugins/Makefile.in b/src/settings/plugins/Makefile.in deleted file mode 100644 index dfe5a45f..00000000 --- a/src/settings/plugins/Makefile.in +++ /dev/null @@ -1,788 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@CONFIG_PLUGIN_IBFT_TRUE@am__append_1 = ibft -@CONFIG_PLUGIN_IFCFG_RH_TRUE@am__append_2 = ifcfg-rh -@CONFIG_PLUGIN_IFUPDOWN_TRUE@am__append_3 = ifupdown -@CONFIG_PLUGIN_IFNET_TRUE@am__append_4 = ifnet -subdir = src/settings/plugins -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = keyfile ibft ifcfg-rh ifupdown ifnet -am__DIST_COMMON = $(srcdir)/Makefile.in README -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = keyfile $(am__append_1) $(am__append_2) $(am__append_3) \ - $(am__append_4) -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ibft/Makefile.am b/src/settings/plugins/ibft/Makefile.am deleted file mode 100644 index d19f36f2..00000000 --- a/src/settings/plugins/ibft/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -SUBDIRS = . tests - -@GNOME_CODE_COVERAGE_RULES@ - -pkglib_LTLIBRARIES = libnm-settings-plugin-ibft.la - -noinst_LTLIBRARIES = libibft-io.la - -libibft_io_la_SOURCES = \ - reader.c \ - reader.h - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" - -libnm_settings_plugin_ibft_la_SOURCES = \ - plugin.c \ - plugin.h \ - nm-ibft-connection.c \ - nm-ibft-connection.h - -libnm_settings_plugin_ibft_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ibft_la_LIBADD = libibft-io.la - -CLEANFILES = $(BUILT_SOURCES) - diff --git a/src/settings/plugins/ibft/Makefile.in b/src/settings/plugins/ibft/Makefile.in deleted file mode 100644 index ea6a3a63..00000000 --- a/src/settings/plugins/ibft/Makefile.in +++ /dev/null @@ -1,979 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ibft -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES) -libibft_io_la_LIBADD = -am_libibft_io_la_OBJECTS = reader.lo -libibft_io_la_OBJECTS = $(am_libibft_io_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_ibft_la_DEPENDENCIES = libibft-io.la -am_libnm_settings_plugin_ibft_la_OBJECTS = plugin.lo \ - nm-ibft-connection.lo -libnm_settings_plugin_ibft_la_OBJECTS = \ - $(am_libnm_settings_plugin_ibft_la_OBJECTS) -libnm_settings_plugin_ibft_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_ibft_la_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libibft_io_la_SOURCES) \ - $(libnm_settings_plugin_ibft_la_SOURCES) -DIST_SOURCES = $(libibft_io_la_SOURCES) \ - $(libnm_settings_plugin_ibft_la_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = . tests -pkglib_LTLIBRARIES = libnm-settings-plugin-ibft.la -noinst_LTLIBRARIES = libibft-io.la -libibft_io_la_SOURCES = \ - reader.c \ - reader.h - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" - -libnm_settings_plugin_ibft_la_SOURCES = \ - plugin.c \ - plugin.h \ - nm-ibft-connection.c \ - nm-ibft-connection.h - -libnm_settings_plugin_ibft_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ibft_la_LIBADD = libibft-io.la -CLEANFILES = $(BUILT_SOURCES) -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ibft/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ibft/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libibft-io.la: $(libibft_io_la_OBJECTS) $(libibft_io_la_DEPENDENCIES) $(EXTRA_libibft_io_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libibft_io_la_OBJECTS) $(libibft_io_la_LIBADD) $(LIBS) - -libnm-settings-plugin-ibft.la: $(libnm_settings_plugin_ibft_la_OBJECTS) $(libnm_settings_plugin_ibft_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ibft_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_ibft_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ibft_la_OBJECTS) $(libnm_settings_plugin_ibft_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ibft-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile $(LTLIBRARIES) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - clean-pkglibLTLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-pkglibLTLIBRARIES install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ibft/nm-ibft-connection.c b/src/settings/plugins/ibft/nm-ibft-connection.c deleted file mode 100644 index 95495b5c..00000000 --- a/src/settings/plugins/ibft/nm-ibft-connection.c +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include - -#include - -#include "nm-ibft-connection.h" -#include "reader.h" - -G_DEFINE_TYPE (NMIbftConnection, nm_ibft_connection, NM_TYPE_SETTINGS_CONNECTION) - -NMIbftConnection * -nm_ibft_connection_new (const GPtrArray *block, GError **error) -{ - NMConnection *source; - GObject *object; - - source = connection_from_block (block, error); - if (!source) - return NULL; - - object = g_object_new (NM_TYPE_IBFT_CONNECTION, NULL); - /* Update settings with what was read from iscsiadm */ - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - source, - FALSE, - NULL, - error)) - g_clear_object (&object); - - return (NMIbftConnection *) object; -} - -/* GObject */ - -static void -nm_ibft_connection_init (NMIbftConnection *connection) -{ -} - -static void -nm_ibft_connection_class_init (NMIbftConnectionClass *ibft_connection_class) -{ -} - diff --git a/src/settings/plugins/ibft/nm-ibft-connection.h b/src/settings/plugins/ibft/nm-ibft-connection.h deleted file mode 100644 index a4ee17ac..00000000 --- a/src/settings/plugins/ibft/nm-ibft-connection.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#ifndef NM_IBFT_CONNECTION_H -#define NM_IBFT_CONNECTION_H - -#include - -#define NM_TYPE_IBFT_CONNECTION (nm_ibft_connection_get_type ()) -#define NM_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IBFT_CONNECTION, NMIbftConnection)) -#define NM_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IBFT_CONNECTION, NMIbftConnectionClass)) -#define NM_IS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IBFT_CONNECTION)) -#define NM_IS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IBFT_CONNECTION)) -#define NM_IBFT_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IBFT_CONNECTION, NMIbftConnectionClass)) - -typedef struct { - NMSettingsConnection parent; -} NMIbftConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMIbftConnectionClass; - -GType nm_ibft_connection_get_type (void); - -NMIbftConnection *nm_ibft_connection_new (const GPtrArray *block, - GError **error); - -#endif /* NM_IBFT_CONNECTION_H */ diff --git a/src/settings/plugins/ibft/nms-ibft-connection.c b/src/settings/plugins/ibft/nms-ibft-connection.c new file mode 100644 index 00000000..834ba834 --- /dev/null +++ b/src/settings/plugins/ibft/nms-ibft-connection.c @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ibft-connection.h" + +#include +#include +#include +#include + +#include "nms-ibft-reader.h" + +/*****************************************************************************/ + +struct _NMSIbftConnection { + NMSettingsConnection parent; +}; + +struct _NMSIbftConnectionClass { + NMSettingsConnectionClass parent; +}; + +G_DEFINE_TYPE (NMSIbftConnection, nms_ibft_connection, NM_TYPE_SETTINGS_CONNECTION) + +/*****************************************************************************/ + +static void +nms_ibft_connection_init (NMSIbftConnection *connection) +{ +} + +NMSIbftConnection * +nms_ibft_connection_new (const GPtrArray *block, GError **error) +{ + NMConnection *source; + GObject *object; + + source = nms_ibft_reader_get_connection_from_block (block, error); + if (!source) + return NULL; + + object = g_object_new (NMS_TYPE_IBFT_CONNECTION, NULL); + /* Update settings with what was read from iscsiadm */ + if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), + source, + FALSE, + NULL, + error)) + g_clear_object (&object); + + return (NMSIbftConnection *) object; +} + +static void +nms_ibft_connection_class_init (NMSIbftConnectionClass *ibft_connection_class) +{ +} + diff --git a/src/settings/plugins/ibft/nms-ibft-connection.h b/src/settings/plugins/ibft/nms-ibft-connection.h new file mode 100644 index 00000000..de050662 --- /dev/null +++ b/src/settings/plugins/ibft/nms-ibft-connection.h @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NMS_IBFT_CONNECTION_H__ +#define __NMS_IBFT_CONNECTION_H__ + +#include "settings/nm-settings-connection.h" + +#define NMS_TYPE_IBFT_CONNECTION (nms_ibft_connection_get_type ()) +#define NMS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnection)) +#define NMS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnectionClass)) +#define NMS_IS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_IBFT_CONNECTION)) +#define NMS_IS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_IBFT_CONNECTION)) +#define NMS_IBFT_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnectionClass)) + +typedef struct _NMSIbftConnection NMSIbftConnection; +typedef struct _NMSIbftConnectionClass NMSIbftConnectionClass; + +GType nms_ibft_connection_get_type (void); + +NMSIbftConnection *nms_ibft_connection_new (const GPtrArray *block, + GError **error); + +#endif /* __NMS_IBFT_CONNECTION_H__ */ diff --git a/src/settings/plugins/ibft/nms-ibft-plugin.c b/src/settings/plugins/ibft/nms-ibft-plugin.c new file mode 100644 index 00000000..c9069dc7 --- /dev/null +++ b/src/settings/plugins/ibft/nms-ibft-plugin.c @@ -0,0 +1,206 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ibft-plugin.h" + +#include +#include +#include +#include + +#include "nm-setting-connection.h" +#include "settings/nm-settings-plugin.h" +#include "NetworkManagerUtils.h" + +#include "nms-ibft-reader.h" +#include "nms-ibft-connection.h" + +/*****************************************************************************/ + +typedef struct { + GHashTable *connections; /* uuid::connection */ + gboolean initialized; +} NMSIbftPluginPrivate; + +struct _NMSIbftPlugin { + GObject parent; + NMSIbftPluginPrivate _priv; +}; + +struct _NMSIbftPluginClass { + GObjectClass parent; +}; + +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); + +G_DEFINE_TYPE_EXTENDED (NMSIbftPlugin, nms_ibft_plugin, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) + +#define NMS_IBFT_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSIbftPlugin, NMS_IS_IBFT_PLUGIN) + +/*****************************************************************************/ + +static NMSIbftPlugin *nms_ibft_plugin_get (void); + +NM_DEFINE_SINGLETON_GETTER (NMSIbftPlugin, nms_ibft_plugin_get, NMS_TYPE_IBFT_PLUGIN); + +/*****************************************************************************/ + +static void +read_connections (NMSIbftPlugin *self) +{ + NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self); + GSList *blocks = NULL, *iter; + GError *error = NULL; + NMSIbftConnection *connection; + + if (!nms_ibft_reader_load_blocks ("/sbin/iscsiadm", &blocks, &error)) { + nm_log_dbg (LOGD_SETTINGS, "ibft: failed to read iscsiadm records: %s", error->message); + g_error_free (error); + return; + } + + for (iter = blocks; iter; iter = iter->next) { + connection = nms_ibft_connection_new (iter->data, &error); + if (connection) { + nm_log_info (LOGD_SETTINGS, "ibft: read connection '%s'", + nm_connection_get_id (NM_CONNECTION (connection))); + g_hash_table_insert (priv->connections, + g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), + connection); + } else { + nm_log_warn (LOGD_SETTINGS, "ibft: failed to read iscsiadm record: %s", error->message); + g_clear_error (&error); + } + } + + g_slist_free_full (blocks, (GDestroyNotify) g_ptr_array_unref); +} + +static GSList * +get_connections (NMSettingsPlugin *config) +{ + NMSIbftPlugin *self = NMS_IBFT_PLUGIN (config); + NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self); + GSList *list = NULL; + GHashTableIter iter; + NMSIbftConnection *connection; + + if (!priv->initialized) { + read_connections (self); + priv->initialized = TRUE; + } + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) + list = g_slist_prepend (list, connection); + + return list; +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case NM_SETTINGS_PLUGIN_PROP_NAME: + g_value_set_string (value, "iBFT"); + break; + case NM_SETTINGS_PLUGIN_PROP_INFO: + g_value_set_string (value, "(c) 2014 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."); + break; + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_NONE); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +init (NMSettingsPlugin *config) +{ +} + +static void +nms_ibft_plugin_init (NMSIbftPlugin *self) +{ + NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self); + + priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); +} + +static void +dispose (GObject *object) +{ + NMSIbftPlugin *self = NMS_IBFT_PLUGIN (object); + NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self); + + if (priv->connections) { + g_hash_table_destroy (priv->connections); + priv->connections = NULL; + } + + G_OBJECT_CLASS (nms_ibft_plugin_parent_class)->dispose (object); +} + +static void +nms_ibft_plugin_class_init (NMSIbftPluginClass *req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + + object_class->dispose = dispose; + object_class->get_property = get_property; + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); +} + +static void +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) +{ + plugin_iface->get_connections = get_connections; + plugin_iface->init = init; +} + +/*****************************************************************************/ + +G_MODULE_EXPORT GObject * +nm_settings_plugin_factory (void) +{ + return g_object_ref (nms_ibft_plugin_get ()); +} diff --git a/src/settings/plugins/ibft/nms-ibft-plugin.h b/src/settings/plugins/ibft/nms-ibft-plugin.h new file mode 100644 index 00000000..33a7620b --- /dev/null +++ b/src/settings/plugins/ibft/nms-ibft-plugin.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NMS_IBFT_PLUGIN_H__ +#define __NMS_IBFT_PLUGIN_H__ + +#define NMS_TYPE_IBFT_PLUGIN (nms_ibft_plugin_get_type ()) +#define NMS_IBFT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_IBFT_PLUGIN, NMSIbftPlugin)) +#define NMS_IBFT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_IBFT_PLUGIN, NMSIbftPluginClass)) +#define NMS_IS_IBFT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_IBFT_PLUGIN)) +#define NMS_IS_IBFT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_IBFT_PLUGIN)) +#define NMS_IBFT_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_IBFT_PLUGIN, NMSIbftPluginClass)) + +typedef struct _NMSIbftPlugin NMSIbftPlugin; +typedef struct _NMSIbftPluginClass NMSIbftPluginClass; + +GType nms_ibft_plugin_get_type (void); + +#endif /* __NMS_IBFT_PLUGIN_H__ */ diff --git a/src/settings/plugins/ibft/nms-ibft-reader.c b/src/settings/plugins/ibft/nms-ibft-reader.c new file mode 100644 index 00000000..d26c8334 --- /dev/null +++ b/src/settings/plugins/ibft/nms-ibft-reader.c @@ -0,0 +1,549 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ibft-reader.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-core-internal.h" +#include "platform/nm-platform.h" +#include "NetworkManagerUtils.h" + +/*****************************************************************************/ + +#define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg) + +/* Removes trailing whitespace and whitespace before and immediately after the '=' */ +static char * +remove_most_whitespace (const char *src) +{ + char *s_new, *s2; + const char *svalue; + + while (*src && g_ascii_isspace (*src)) + src++; + + svalue = strchr (src, '='); + if (!svalue || svalue == src) + return NULL; + + s_new = g_new (char, strlen (src) + 1); + + memcpy (s_new, src, svalue - src); + s_new[svalue - src] = '\0'; + g_strchomp (s_new); + + svalue++; + while (*svalue && g_ascii_isspace (*svalue)) + svalue++; + + s2 = strchr (s_new, '\0'); + s2[0] = '='; + strcpy (++s2, svalue); + g_strchomp (s2); + + return s_new; +} + +#define TAG_BEGIN "# BEGIN RECORD" +#define TAG_END "# END RECORD" + +/** + * nms_ibft_reader_load_blocks: + * @iscsiadm_path: path to iscsiadm program + * @out_blocks: on return if successful, a #GSList of #GPtrArray, or %NULL on + * failure + * @error: location for an error on failure + * + * Parses iscsiadm output and returns a #GSList of #GPtrArray in the @out_blocks + * argument on success, otherwise @out_blocks is set to %NULL. Each #GPtrArray + * in @out_blocks contains the lines from an iscsiadm interface block. + * + * Returns: %TRUE on success, %FALSE on errors + */ +gboolean +nms_ibft_reader_load_blocks (const char *iscsiadm_path, + GSList **out_blocks, + GError **error) +{ + const char *argv[4] = { iscsiadm_path, "-m", "fw", NULL }; + const char *envp[1] = { NULL }; + GSList *blocks = NULL; + char *out = NULL, *err = NULL; + gint status = 0; + char **lines = NULL, **iter; + GPtrArray *block_lines = NULL; + gboolean success = FALSE; + + g_return_val_if_fail (iscsiadm_path != NULL, FALSE); + g_return_val_if_fail (out_blocks != NULL && *out_blocks == NULL, FALSE); + + if (!g_spawn_sync ("/", (char **) argv, (char **) envp, 0, + NULL, NULL, &out, &err, &status, error)) + goto done; + + if (!WIFEXITED (status)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "iBFT: %s exited abnormally.", iscsiadm_path); + goto done; + } + + if (WEXITSTATUS (status) != 0) { + if (err) { + char *nl; + + /* the error message contains newlines. concatenate the lines with whitespace */ + for (nl = err; *nl; nl++) { + if (*nl == '\n') + *nl = ' '; + } + } + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "iBFT: %s exited with error %d. Message: '%s'", + iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)"); + goto done; + } + + nm_log_dbg (LOGD_SETTINGS, "iBFT records:\n%s", out); + + lines = g_strsplit_set (out, "\n\r", -1); + for (iter = lines; iter && *iter; iter++) { + if (!*iter[0]) + continue; + + if (!g_ascii_strncasecmp (*iter, TAG_BEGIN, NM_STRLEN (TAG_BEGIN))) { + if (block_lines) { + PARSE_WARNING ("malformed iscsiadm record: missing END RECORD."); + g_ptr_array_unref (block_lines); + } + /* Start new record */ + block_lines = g_ptr_array_new_full (15, g_free); + } else if (!g_ascii_strncasecmp (*iter, TAG_END, NM_STRLEN (TAG_END))) { + if (block_lines) { + if (block_lines->len) + blocks = g_slist_prepend (blocks, block_lines); + else + g_ptr_array_unref (block_lines); + block_lines = NULL; + } + } else if (block_lines) { + char *s = remove_most_whitespace (*iter); + + if (s) + g_ptr_array_add (block_lines, s); + else { + PARSE_WARNING ("malformed iscsiadm record: no = in '%s'.", *iter); + g_clear_pointer (&block_lines, g_ptr_array_unref); + } + } + } + + if (block_lines) { + PARSE_WARNING ("malformed iscsiadm record: missing # END RECORD."); + g_clear_pointer (&block_lines, g_ptr_array_unref); + } + success = TRUE; + +done: + if (lines) + g_strfreev (lines); + g_free (out); + g_free (err); + if (success) + *out_blocks = blocks; + else + g_slist_free_full (blocks, (GDestroyNotify) g_ptr_array_unref); + return success; +} + +#define ISCSI_HWADDR_TAG "iface.hwaddress" +#define ISCSI_BOOTPROTO_TAG "iface.bootproto" +#define ISCSI_IPADDR_TAG "iface.ipaddress" +#define ISCSI_SUBNET_TAG "iface.subnet_mask" +#define ISCSI_GATEWAY_TAG "iface.gateway" +#define ISCSI_DNS1_TAG "iface.primary_dns" +#define ISCSI_DNS2_TAG "iface.secondary_dns" +#define ISCSI_VLAN_ID_TAG "iface.vlan_id" +#define ISCSI_IFACE_TAG "iface.net_ifacename" + +static const char * +match_iscsiadm_tag (const char *line, const char *tag) +{ + gsize taglen = strlen (tag); + + if (g_ascii_strncasecmp (line, tag, taglen) != 0) + return NULL; + if (line[taglen] != '=') + return NULL; + return line + taglen + 1; +} + +/** + * nms_ibft_reader_parse_block: + * @block: an array of iscsiadm interface block lines + * @error: return location for errors + * @...: pairs of key (const char *) : location (const char **) indicating the + * key to look for and the location to store the retrieved value in + * + * Parses an iscsiadm interface block into variables requested by the caller. + * Callers should verify the returned data is complete and valid. Returned + * strings are owned by @block and should not be used after @block is freed. + * + * Returns: %TRUE if at least , %FALSE on failure + */ +gboolean +nms_ibft_reader_parse_block (const GPtrArray *block, GError **error, ...) +{ + gboolean success = FALSE; + const char **out_value, *p; + va_list ap; + const char *key; + guint i; + + g_return_val_if_fail (block != NULL, FALSE); + g_return_val_if_fail (block->len > 0, FALSE); + + /* Find requested keys and populate return values */ + va_start (ap, error); + while ((key = va_arg (ap, const char *))) { + out_value = va_arg (ap, const char **); + *out_value = NULL; + for (i = 0; i < block->len; i++) { + p = match_iscsiadm_tag (g_ptr_array_index (block, i), key); + if (p) { + *out_value = p; + success = TRUE; + break; + } + } + } + va_end (ap); + + if (!success) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: failed to match at least one iscsiadm block field"); + } + return success; +} + +static gboolean +ip4_setting_add_from_block (const GPtrArray *block, + NMConnection *connection, + GError **error) +{ + NMSettingIPConfig *s_ip4 = NULL; + NMIPAddress *addr; + const char *s_method = NULL; + const char *s_ipaddr = NULL; + const char *s_gateway = NULL; + const char *s_dns1 = NULL; + const char *s_dns2 = NULL; + const char *s_netmask = NULL; + guint32 netmask = 0; + guint32 prefix; + + g_assert (block); + + if (!nms_ibft_reader_parse_block (block, error, + ISCSI_BOOTPROTO_TAG, &s_method, + ISCSI_IPADDR_TAG, &s_ipaddr, + ISCSI_SUBNET_TAG, &s_netmask, + ISCSI_GATEWAY_TAG, &s_gateway, + ISCSI_DNS1_TAG, &s_dns1, + ISCSI_DNS2_TAG, &s_dns2, + NULL)) + goto error; + + if (!s_method) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: missing " ISCSI_BOOTPROTO_TAG); + goto error; + } + + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + + if (!g_ascii_strcasecmp (s_method, "dhcp")) { + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + goto success; + } else if (g_ascii_strcasecmp (s_method, "static") != 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: unknown " ISCSI_BOOTPROTO_TAG " '%s'.", + s_method); + goto error; + } + + /* Static configuration stuff */ + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL); + + /* IP address */ + if (!s_ipaddr || !nm_utils_ipaddr_valid (AF_INET, s_ipaddr)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: invalid IP address '%s'.", + s_ipaddr); + goto error; + } + + /* Subnet/prefix */ + if (!s_netmask || inet_pton (AF_INET, s_netmask, &netmask) != 1) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: invalid subnet mask '%s'.", + s_netmask); + goto error; + } + prefix = nm_utils_ip4_netmask_to_prefix (netmask); + + if (s_gateway && !nm_utils_ipaddr_valid (AF_INET, s_gateway)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: invalid IP gateway '%s'.", + s_gateway); + goto error; + } + + if (s_dns1 && !nm_utils_ipaddr_valid (AF_INET, s_dns1)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: invalid DNS1 address '%s'.", + s_dns1); + goto error; + } + + if (s_dns2 && !nm_utils_ipaddr_valid (AF_INET, s_dns2)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: invalid DNS2 address '%s'.", + s_dns2); + goto error; + } + + addr = nm_ip_address_new (AF_INET, s_ipaddr, prefix, error); + if (!addr) { + g_prefix_error (error, "iBFT: malformed iscsiadm record: "); + goto error; + } + + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); + + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, s_gateway, NULL); + + if (s_dns1) + nm_setting_ip_config_add_dns (s_ip4, s_dns1); + if (s_dns2) + nm_setting_ip_config_add_dns (s_ip4, s_dns2); + +success: + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + return TRUE; + +error: + g_clear_object (&s_ip4); + return FALSE; +} + +static gboolean +connection_setting_add (const GPtrArray *block, + NMConnection *connection, + const char *type, + const char *prefix, + const char *iface, + GError **error) +{ + NMSetting *s_con; + char *id, *uuid; + const char *s_hwaddr = NULL, *s_ip4addr = NULL, *s_vlanid; + + if (!nms_ibft_reader_parse_block (block, error, + ISCSI_VLAN_ID_TAG, &s_vlanid, + ISCSI_HWADDR_TAG, &s_hwaddr, + ISCSI_IPADDR_TAG, &s_ip4addr, + NULL)) + return FALSE; + if (!s_hwaddr) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG); + return FALSE; + } + + id = g_strdup_printf ("iBFT%s%s %s", + prefix ? " " : "", + prefix ? prefix : "", + iface); + + uuid = _nm_utils_uuid_generate_from_strings ("ibft", + s_hwaddr, + s_vlanid ? "V" : "v", + s_vlanid ? s_vlanid : "", + s_ip4addr ? "A" : "DHCP", + s_ip4addr ? s_ip4addr : "", + NULL); + + s_con = nm_setting_connection_new (); + g_object_set (s_con, + NM_SETTING_CONNECTION_TYPE, type, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_ID, id, + NM_SETTING_CONNECTION_READ_ONLY, TRUE, + NULL); + + g_free (uuid); + g_free (id); + + nm_connection_add_setting (connection, NM_SETTING (s_con)); + return TRUE; +} + +static gboolean +is_ibft_vlan_device (const GPtrArray *block) +{ + char *s_vlan_id = NULL; + + if (nms_ibft_reader_parse_block (block, NULL, ISCSI_VLAN_ID_TAG, &s_vlan_id, NULL)) { + g_assert (s_vlan_id); + + /* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it + * means "no VLAN". + */ + if (_nm_utils_ascii_str_to_int64 (s_vlan_id, 10, 1, 4095, -1) != -1) + return TRUE; + } + return FALSE; +} + +static gboolean +vlan_setting_add_from_block (const GPtrArray *block, + NMConnection *connection, + GError **error) +{ + NMSetting *s_vlan = NULL; + const char *vlan_id_str = NULL; + gint64 vlan_id = -1; + gboolean success; + + g_assert (block); + g_assert (connection); + + /* This won't fail since this function shouldn't be called unless the + * iBFT VLAN ID exists and is > 0. + */ + success = nms_ibft_reader_parse_block (block, NULL, ISCSI_VLAN_ID_TAG, &vlan_id_str, NULL); + g_assert (success); + g_assert (vlan_id_str); + + /* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it means "no VLAN" */ + vlan_id = _nm_utils_ascii_str_to_int64 (vlan_id_str, 10, 1, 4095, -1); + if (vlan_id == -1) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid VLAN_ID '%s'", vlan_id_str); + return FALSE; + } + + s_vlan = nm_setting_vlan_new (); + g_object_set (s_vlan, NM_SETTING_VLAN_ID, (guint32) vlan_id, NULL); + nm_connection_add_setting (connection, NM_SETTING (s_vlan)); + + return TRUE; +} + +static gboolean +wired_setting_add_from_block (const GPtrArray *block, + NMConnection *connection, + GError **error) +{ + NMSetting *s_wired = NULL; + const char *hwaddr = NULL; + + g_assert (block); + g_assert (connection); + + if (!nms_ibft_reader_parse_block (block, NULL, ISCSI_HWADDR_TAG, &hwaddr, NULL)) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG); + return FALSE; + } + + if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: invalid " ISCSI_HWADDR_TAG " '%s'.", + hwaddr); + return FALSE; + } + + s_wired = nm_setting_wired_new (); + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, hwaddr, NULL); + + nm_connection_add_setting (connection, s_wired); + return TRUE; +} + +NMConnection * +nms_ibft_reader_get_connection_from_block (const GPtrArray *block, GError **error) +{ + NMConnection *connection = NULL; + gboolean is_vlan = FALSE; + const char *iface = NULL; + + g_assert (block); + + if (!nms_ibft_reader_parse_block (block, error, ISCSI_IFACE_TAG, &iface, NULL)) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "iBFT: malformed iscsiadm record: missing " ISCSI_IFACE_TAG); + return NULL; + } + + connection = nm_simple_connection_new (); + + is_vlan = is_ibft_vlan_device (block); + if (is_vlan && !vlan_setting_add_from_block (block, connection, error)) + goto error; + + /* Always have a wired setting; for VLAN it defines the parent */ + if (!wired_setting_add_from_block (block, connection, error)) + goto error; + + if (!ip4_setting_add_from_block (block, connection, error)) + goto error; + + if (!connection_setting_add (block, + connection, + is_vlan ? NM_SETTING_VLAN_SETTING_NAME : NM_SETTING_WIRED_SETTING_NAME, + is_vlan ? "VLAN" : NULL, + iface, + error)) + goto error; + + if (!nm_connection_normalize (connection, NULL, NULL, error)) + goto error; + + return connection; + +error: + g_object_unref (connection); + return NULL; +} + diff --git a/src/settings/plugins/ibft/nms-ibft-reader.h b/src/settings/plugins/ibft/nms-ibft-reader.h new file mode 100644 index 00000000..e2be7b02 --- /dev/null +++ b/src/settings/plugins/ibft/nms-ibft-reader.h @@ -0,0 +1,34 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NMS_IBFT_READER_H__ +#define __NMS_IBFT_READER_H__ + +#include + +gboolean nms_ibft_reader_load_blocks (const char *iscsiadm_path, + GSList **out_blocks, + GError **error); + +NMConnection *nms_ibft_reader_get_connection_from_block (const GPtrArray *block, GError **error); + +gboolean nms_ibft_reader_parse_block (const GPtrArray *block, GError **error, ...) G_GNUC_NULL_TERMINATED; + +#endif /* __NMS_IBFT_READER_H__ */ diff --git a/src/settings/plugins/ibft/plugin.c b/src/settings/plugins/ibft/plugin.c deleted file mode 100644 index 6f9b8c82..00000000 --- a/src/settings/plugins/ibft/plugin.c +++ /dev/null @@ -1,197 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include - -#include - -#include "nm-setting-connection.h" - -#include "nm-settings-plugin.h" -#include "NetworkManagerUtils.h" - -#include "plugin.h" -#include "reader.h" -#include "nm-ibft-connection.h" - -static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); - -G_DEFINE_TYPE_EXTENDED (SettingsPluginIbft, settings_plugin_ibft, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_interface_init)) - -#define SETTINGS_PLUGIN_IBFT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftPrivate)) - - -typedef struct { - GHashTable *connections; /* uuid::connection */ - gboolean initialized; -} SettingsPluginIbftPrivate; - -static SettingsPluginIbft *settings_plugin_ibft_get (void); -NM_DEFINE_SINGLETON_GETTER (SettingsPluginIbft, settings_plugin_ibft_get, SETTINGS_TYPE_PLUGIN_IBFT); - -static void -read_connections (SettingsPluginIbft *self) -{ - SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); - GSList *blocks = NULL, *iter; - GError *error = NULL; - NMIbftConnection *connection; - - if (!read_ibft_blocks ("/sbin/iscsiadm", &blocks, &error)) { - nm_log_dbg (LOGD_SETTINGS, "ibft: failed to read iscsiadm records: %s", error->message); - g_error_free (error); - return; - } - - for (iter = blocks; iter; iter = iter->next) { - connection = nm_ibft_connection_new (iter->data, &error); - if (connection) { - nm_log_info (LOGD_SETTINGS, "ibft: read connection '%s'", - nm_connection_get_id (NM_CONNECTION (connection))); - g_hash_table_insert (priv->connections, - g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), - connection); - } else { - nm_log_warn (LOGD_SETTINGS, "ibft: failed to read iscsiadm record: %s", error->message); - g_clear_error (&error); - } - } - - g_slist_free_full (blocks, (GDestroyNotify) g_ptr_array_unref); -} - -static GSList * -get_connections (NMSettingsPlugin *config) -{ - SettingsPluginIbft *self = SETTINGS_PLUGIN_IBFT (config); - SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); - GSList *list = NULL; - GHashTableIter iter; - NMIbftConnection *connection; - - if (!priv->initialized) { - read_connections (self); - priv->initialized = TRUE; - } - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) - list = g_slist_prepend (list, connection); - - return list; -} - -static void -init (NMSettingsPlugin *config) -{ -} - -static void -settings_plugin_ibft_init (SettingsPluginIbft *self) -{ - SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); - - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); -} - -static void -dispose (GObject *object) -{ - SettingsPluginIbft *self = SETTINGS_PLUGIN_IBFT (object); - SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); - - if (priv->connections) { - g_hash_table_destroy (priv->connections); - priv->connections = NULL; - } - - G_OBJECT_CLASS (settings_plugin_ibft_parent_class)->dispose (object); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, "iBFT"); - break; - case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, "(c) 2014 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."); - break; - case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_NONE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); -} - -static void -settings_plugin_ibft_class_init (SettingsPluginIbftClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (SettingsPluginIbftPrivate)); - - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_NAME, - NM_SETTINGS_PLUGIN_NAME); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_INFO, - NM_SETTINGS_PLUGIN_INFO); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, - NM_SETTINGS_PLUGIN_CAPABILITIES); -} - -static void -settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) -{ - /* interface implementation */ - plugin_iface->get_connections = get_connections; - plugin_iface->init = init; -} - -G_MODULE_EXPORT GObject * -nm_settings_plugin_factory (void) -{ - return g_object_ref (settings_plugin_ibft_get ()); -} diff --git a/src/settings/plugins/ibft/plugin.h b/src/settings/plugins/ibft/plugin.h deleted file mode 100644 index 4867e07d..00000000 --- a/src/settings/plugins/ibft/plugin.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#define SETTINGS_TYPE_PLUGIN_IBFT (settings_plugin_ibft_get_type ()) -#define SETTINGS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbft)) -#define SETTINGS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftClass)) -#define SETTINGS_IS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IBFT)) -#define SETTINGS_IS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IBFT)) -#define SETTINGS_PLUGIN_IBFT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftClass)) - -typedef struct _SettingsPluginIbft SettingsPluginIbft; -typedef struct _SettingsPluginIbftClass SettingsPluginIbftClass; - -struct _SettingsPluginIbft { - GObject parent; -}; - -struct _SettingsPluginIbftClass { - GObjectClass parent; -}; - -GType settings_plugin_ibft_get_type (void); - -#endif /* _PLUGIN_H_ */ - diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c deleted file mode 100644 index c39d875c..00000000 --- a/src/settings/plugins/ibft/reader.c +++ /dev/null @@ -1,547 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-core-internal.h" -#include "nm-platform.h" -#include "NetworkManagerUtils.h" - -#include "reader.h" - -#define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg) - -/* Removes trailing whitespace and whitespace before and immediately after the '=' */ -static char * -remove_most_whitespace (const char *src) -{ - char *s_new, *s2; - const char *svalue; - - while (*src && g_ascii_isspace (*src)) - src++; - - svalue = strchr (src, '='); - if (!svalue || svalue == src) - return NULL; - - s_new = g_new (char, strlen (src) + 1); - - memcpy (s_new, src, svalue - src); - s_new[svalue - src] = '\0'; - g_strchomp (s_new); - - svalue++; - while (*svalue && g_ascii_isspace (*svalue)) - svalue++; - - s2 = strchr (s_new, '\0'); - s2[0] = '='; - strcpy (++s2, svalue); - g_strchomp (s2); - - return s_new; -} - -#define TAG_BEGIN "# BEGIN RECORD" -#define TAG_END "# END RECORD" - -/** - * read_ibft_blocks: - * @iscsiadm_path: path to iscsiadm program - * @out_blocks: on return if successful, a #GSList of #GPtrArray, or %NULL on - * failure - * @error: location for an error on failure - * - * Parses iscsiadm output and returns a #GSList of #GPtrArray in the @out_blocks - * argument on success, otherwise @out_blocks is set to %NULL. Each #GPtrArray - * in @out_blocks contains the lines from an iscsiadm interface block. - * - * Returns: %TRUE on success, %FALSE on errors - */ -gboolean -read_ibft_blocks (const char *iscsiadm_path, - GSList **out_blocks, - GError **error) -{ - const char *argv[4] = { iscsiadm_path, "-m", "fw", NULL }; - const char *envp[1] = { NULL }; - GSList *blocks = NULL; - char *out = NULL, *err = NULL; - gint status = 0; - char **lines = NULL, **iter; - GPtrArray *block_lines = NULL; - gboolean success = FALSE; - - g_return_val_if_fail (iscsiadm_path != NULL, FALSE); - g_return_val_if_fail (out_blocks != NULL && *out_blocks == NULL, FALSE); - - if (!g_spawn_sync ("/", (char **) argv, (char **) envp, 0, - NULL, NULL, &out, &err, &status, error)) - goto done; - - if (!WIFEXITED (status)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "iBFT: %s exited abnormally.", iscsiadm_path); - goto done; - } - - if (WEXITSTATUS (status) != 0) { - if (err) { - char *nl; - - /* the error message contains newlines. concatenate the lines with whitespace */ - for (nl = err; *nl; nl++) { - if (*nl == '\n') - *nl = ' '; - } - } - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "iBFT: %s exited with error %d. Message: '%s'", - iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)"); - goto done; - } - - nm_log_dbg (LOGD_SETTINGS, "iBFT records:\n%s", out); - - lines = g_strsplit_set (out, "\n\r", -1); - for (iter = lines; iter && *iter; iter++) { - if (!*iter[0]) - continue; - - if (!g_ascii_strncasecmp (*iter, TAG_BEGIN, NM_STRLEN (TAG_BEGIN))) { - if (block_lines) { - PARSE_WARNING ("malformed iscsiadm record: missing END RECORD."); - g_ptr_array_unref (block_lines); - } - /* Start new record */ - block_lines = g_ptr_array_new_full (15, g_free); - } else if (!g_ascii_strncasecmp (*iter, TAG_END, NM_STRLEN (TAG_END))) { - if (block_lines) { - if (block_lines->len) - blocks = g_slist_prepend (blocks, block_lines); - else - g_ptr_array_unref (block_lines); - block_lines = NULL; - } - } else if (block_lines) { - char *s = remove_most_whitespace (*iter); - - if (s) - g_ptr_array_add (block_lines, s); - else { - PARSE_WARNING ("malformed iscsiadm record: no = in '%s'.", *iter); - g_clear_pointer (&block_lines, g_ptr_array_unref); - } - } - } - - if (block_lines) { - PARSE_WARNING ("malformed iscsiadm record: missing # END RECORD."); - g_clear_pointer (&block_lines, g_ptr_array_unref); - } - success = TRUE; - -done: - if (lines) - g_strfreev (lines); - g_free (out); - g_free (err); - if (success) - *out_blocks = blocks; - else - g_slist_free_full (blocks, (GDestroyNotify) g_ptr_array_unref); - return success; -} - -#define ISCSI_HWADDR_TAG "iface.hwaddress" -#define ISCSI_BOOTPROTO_TAG "iface.bootproto" -#define ISCSI_IPADDR_TAG "iface.ipaddress" -#define ISCSI_SUBNET_TAG "iface.subnet_mask" -#define ISCSI_GATEWAY_TAG "iface.gateway" -#define ISCSI_DNS1_TAG "iface.primary_dns" -#define ISCSI_DNS2_TAG "iface.secondary_dns" -#define ISCSI_VLAN_ID_TAG "iface.vlan_id" -#define ISCSI_IFACE_TAG "iface.net_ifacename" - -static const char * -match_iscsiadm_tag (const char *line, const char *tag) -{ - gsize taglen = strlen (tag); - - if (g_ascii_strncasecmp (line, tag, taglen) != 0) - return NULL; - if (line[taglen] != '=') - return NULL; - return line + taglen + 1; -} - -/** - * parse_ibft_config: - * @data: an array of iscsiadm interface block lines - * @error: return location for errors - * @...: pairs of key (const char *) : location (const char **) indicating the - * key to look for and the location to store the retrieved value in - * - * Parses an iscsiadm interface block into variables requested by the caller. - * Callers should verify the returned data is complete and valid. Returned - * strings are owned by @data and should not be used after @data is freed. - * - * Returns: %TRUE if at least , %FALSE on failure - */ -gboolean -parse_ibft_config (const GPtrArray *data, GError **error, ...) -{ - gboolean success = FALSE; - const char **out_value, *p; - va_list ap; - const char *key; - guint i; - - g_return_val_if_fail (data != NULL, FALSE); - g_return_val_if_fail (data->len > 0, FALSE); - - /* Find requested keys and populate return values */ - va_start (ap, error); - while ((key = va_arg (ap, const char *))) { - out_value = va_arg (ap, const char **); - *out_value = NULL; - for (i = 0; i < data->len; i++) { - p = match_iscsiadm_tag (g_ptr_array_index (data, i), key); - if (p) { - *out_value = p; - success = TRUE; - break; - } - } - } - va_end (ap); - - if (!success) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: failed to match at least one iscsiadm block field"); - } - return success; -} - -static gboolean -ip4_setting_add_from_block (const GPtrArray *block, - NMConnection *connection, - GError **error) -{ - NMSettingIPConfig *s_ip4 = NULL; - NMIPAddress *addr; - const char *s_method = NULL; - const char *s_ipaddr = NULL; - const char *s_gateway = NULL; - const char *s_dns1 = NULL; - const char *s_dns2 = NULL; - const char *s_netmask = NULL; - guint32 netmask = 0; - guint32 prefix; - - g_assert (block); - - if (!parse_ibft_config (block, error, - ISCSI_BOOTPROTO_TAG, &s_method, - ISCSI_IPADDR_TAG, &s_ipaddr, - ISCSI_SUBNET_TAG, &s_netmask, - ISCSI_GATEWAY_TAG, &s_gateway, - ISCSI_DNS1_TAG, &s_dns1, - ISCSI_DNS2_TAG, &s_dns2, - NULL)) - goto error; - - if (!s_method) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: missing " ISCSI_BOOTPROTO_TAG); - goto error; - } - - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - - if (!g_ascii_strcasecmp (s_method, "dhcp")) { - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - goto success; - } else if (g_ascii_strcasecmp (s_method, "static") != 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: unknown " ISCSI_BOOTPROTO_TAG " '%s'.", - s_method); - goto error; - } - - /* Static configuration stuff */ - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL); - - /* IP address */ - if (!s_ipaddr || !nm_utils_ipaddr_valid (AF_INET, s_ipaddr)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: invalid IP address '%s'.", - s_ipaddr); - goto error; - } - - /* Subnet/prefix */ - if (!s_netmask || inet_pton (AF_INET, s_netmask, &netmask) != 1) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: invalid subnet mask '%s'.", - s_netmask); - goto error; - } - prefix = nm_utils_ip4_netmask_to_prefix (netmask); - - if (s_gateway && !nm_utils_ipaddr_valid (AF_INET, s_gateway)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: invalid IP gateway '%s'.", - s_gateway); - goto error; - } - - if (s_dns1 && !nm_utils_ipaddr_valid (AF_INET, s_dns1)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: invalid DNS1 address '%s'.", - s_dns1); - goto error; - } - - if (s_dns2 && !nm_utils_ipaddr_valid (AF_INET, s_dns2)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: invalid DNS2 address '%s'.", - s_dns2); - goto error; - } - - addr = nm_ip_address_new (AF_INET, s_ipaddr, prefix, error); - if (!addr) { - g_prefix_error (error, "iBFT: malformed iscsiadm record: "); - goto error; - } - - nm_setting_ip_config_add_address (s_ip4, addr); - nm_ip_address_unref (addr); - - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, s_gateway, NULL); - - if (s_dns1) - nm_setting_ip_config_add_dns (s_ip4, s_dns1); - if (s_dns2) - nm_setting_ip_config_add_dns (s_ip4, s_dns2); - -success: - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - return TRUE; - -error: - g_clear_object (&s_ip4); - return FALSE; -} - -static gboolean -connection_setting_add (const GPtrArray *block, - NMConnection *connection, - const char *type, - const char *prefix, - const char *iface, - GError **error) -{ - NMSetting *s_con; - char *id, *uuid; - const char *s_hwaddr = NULL, *s_ip4addr = NULL, *s_vlanid; - - if (!parse_ibft_config (block, error, - ISCSI_VLAN_ID_TAG, &s_vlanid, - ISCSI_HWADDR_TAG, &s_hwaddr, - ISCSI_IPADDR_TAG, &s_ip4addr, - NULL)) - return FALSE; - if (!s_hwaddr) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG); - return FALSE; - } - - id = g_strdup_printf ("iBFT%s%s %s", - prefix ? " " : "", - prefix ? prefix : "", - iface); - - uuid = _nm_utils_uuid_generate_from_strings ("ibft", - s_hwaddr, - s_vlanid ? "V" : "v", - s_vlanid ? s_vlanid : "", - s_ip4addr ? "A" : "DHCP", - s_ip4addr ? s_ip4addr : "", - NULL); - - s_con = nm_setting_connection_new (); - g_object_set (s_con, - NM_SETTING_CONNECTION_TYPE, type, - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_ID, id, - NM_SETTING_CONNECTION_READ_ONLY, TRUE, - NULL); - - g_free (uuid); - g_free (id); - - nm_connection_add_setting (connection, NM_SETTING (s_con)); - return TRUE; -} - -static gboolean -is_ibft_vlan_device (const GPtrArray *block) -{ - char *s_vlan_id = NULL; - - if (parse_ibft_config (block, NULL, ISCSI_VLAN_ID_TAG, &s_vlan_id, NULL)) { - g_assert (s_vlan_id); - - /* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it - * means "no VLAN". - */ - if (_nm_utils_ascii_str_to_int64 (s_vlan_id, 10, 1, 4095, -1) != -1) - return TRUE; - } - return FALSE; -} - -static gboolean -vlan_setting_add_from_block (const GPtrArray *block, - NMConnection *connection, - GError **error) -{ - NMSetting *s_vlan = NULL; - const char *vlan_id_str = NULL; - gint64 vlan_id = -1; - gboolean success; - - g_assert (block); - g_assert (connection); - - /* This won't fail since this function shouldn't be called unless the - * iBFT VLAN ID exists and is > 0. - */ - success = parse_ibft_config (block, NULL, ISCSI_VLAN_ID_TAG, &vlan_id_str, NULL); - g_assert (success); - g_assert (vlan_id_str); - - /* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it means "no VLAN" */ - vlan_id = _nm_utils_ascii_str_to_int64 (vlan_id_str, 10, 1, 4095, -1); - if (vlan_id == -1) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid VLAN_ID '%s'", vlan_id_str); - return FALSE; - } - - s_vlan = nm_setting_vlan_new (); - g_object_set (s_vlan, NM_SETTING_VLAN_ID, (guint32) vlan_id, NULL); - nm_connection_add_setting (connection, NM_SETTING (s_vlan)); - - return TRUE; -} - -static gboolean -wired_setting_add_from_block (const GPtrArray *block, - NMConnection *connection, - GError **error) -{ - NMSetting *s_wired = NULL; - const char *hwaddr = NULL; - - g_assert (block); - g_assert (connection); - - if (!parse_ibft_config (block, NULL, ISCSI_HWADDR_TAG, &hwaddr, NULL)) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG); - return FALSE; - } - - if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: invalid " ISCSI_HWADDR_TAG " '%s'.", - hwaddr); - return FALSE; - } - - s_wired = nm_setting_wired_new (); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, hwaddr, NULL); - - nm_connection_add_setting (connection, s_wired); - return TRUE; -} - -NMConnection * -connection_from_block (const GPtrArray *block, GError **error) -{ - NMConnection *connection = NULL; - gboolean is_vlan = FALSE; - const char *iface = NULL; - - g_assert (block); - - if (!parse_ibft_config (block, error, ISCSI_IFACE_TAG, &iface, NULL)) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "iBFT: malformed iscsiadm record: missing " ISCSI_IFACE_TAG); - return NULL; - } - - connection = nm_simple_connection_new (); - - is_vlan = is_ibft_vlan_device (block); - if (is_vlan && !vlan_setting_add_from_block (block, connection, error)) - goto error; - - /* Always have a wired setting; for VLAN it defines the parent */ - if (!wired_setting_add_from_block (block, connection, error)) - goto error; - - if (!ip4_setting_add_from_block (block, connection, error)) - goto error; - - if (!connection_setting_add (block, - connection, - is_vlan ? NM_SETTING_VLAN_SETTING_NAME : NM_SETTING_WIRED_SETTING_NAME, - is_vlan ? "VLAN" : NULL, - iface, - error)) - goto error; - - if (!nm_connection_normalize (connection, NULL, NULL, error)) - goto error; - - return connection; - -error: - g_object_unref (connection); - return NULL; -} - diff --git a/src/settings/plugins/ibft/reader.h b/src/settings/plugins/ibft/reader.h deleted file mode 100644 index 97ef0c71..00000000 --- a/src/settings/plugins/ibft/reader.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#ifndef __READER_H__ -#define __READER_H__ - -#include - -gboolean read_ibft_blocks (const char *iscsiadm_path, - GSList **out_blocks, - GError **error); - -NMConnection *connection_from_block (const GPtrArray *block, GError **error); - -/* For testcases */ -gboolean parse_ibft_config (const GPtrArray *data, GError **error, ...) G_GNUC_NULL_TERMINATED; - -#endif /* __READER_H__ */ diff --git a/src/settings/plugins/ibft/tests/Makefile.am b/src/settings/plugins/ibft/tests/Makefile.am deleted file mode 100644 index e5cff73f..00000000 --- a/src/settings/plugins/ibft/tests/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -if ENABLE_TESTS - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(srcdir)/../ \ - -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - -DTEST_IBFT_DIR=\"$(abs_srcdir)\" \ - -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" - -AM_LDFLAGS = \ - $(GLIB_LIBS) \ - $(CODE_COVERAGE_LDFLAGS) - -noinst_PROGRAMS = test-ibft - -test_ibft_SOURCES = \ - test-ibft.c \ - ../reader.c - -test_ibft_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-ibft - -check-local: - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ibft.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - -EXTRA_DIST = \ - iscsiadm-test-dhcp \ - iscsiadm-test-static \ - iscsiadm-test-bad-ipaddr \ - iscsiadm-test-bad-gateway \ - iscsiadm-test-bad-dns1 \ - iscsiadm-test-bad-dns2 \ - iscsiadm-test-bad-entry \ - iscsiadm-test-bad-record \ - iscsiadm-test-vlan - diff --git a/src/settings/plugins/ibft/tests/Makefile.in b/src/settings/plugins/ibft/tests/Makefile.in deleted file mode 100644 index 4de64380..00000000 --- a/src/settings/plugins/ibft/tests/Makefile.in +++ /dev/null @@ -1,1184 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-ibft$(EXEEXT) -@ENABLE_TESTS_TRUE@TESTS = test-ibft$(EXEEXT) -subdir = src/settings/plugins/ibft/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am__test_ibft_SOURCES_DIST = test-ibft.c ../reader.c -@ENABLE_TESTS_TRUE@am_test_ibft_OBJECTS = test-ibft.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ reader.$(OBJEXT) -test_ibft_OBJECTS = $(am_test_ibft_OBJECTS) -@ENABLE_TESTS_TRUE@test_ibft_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_ibft_SOURCES) -DIST_SOURCES = $(am__test_ibft_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/platform \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ -@ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -@ENABLE_TESTS_TRUE@ -DTEST_IBFT_DIR=\"$(abs_srcdir)\" \ -@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" - -@ENABLE_TESTS_TRUE@AM_LDFLAGS = \ -@ENABLE_TESTS_TRUE@ $(GLIB_LIBS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) - -@ENABLE_TESTS_TRUE@test_ibft_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-ibft.c \ -@ENABLE_TESTS_TRUE@ ../reader.c - -@ENABLE_TESTS_TRUE@test_ibft_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la - -EXTRA_DIST = \ - iscsiadm-test-dhcp \ - iscsiadm-test-static \ - iscsiadm-test-bad-ipaddr \ - iscsiadm-test-bad-gateway \ - iscsiadm-test-bad-dns1 \ - iscsiadm-test-bad-dns2 \ - iscsiadm-test-bad-entry \ - iscsiadm-test-bad-record \ - iscsiadm-test-vlan - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ibft/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ibft/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-ibft$(EXEEXT): $(test_ibft_OBJECTS) $(test_ibft_DEPENDENCIES) $(EXTRA_test_ibft_DEPENDENCIES) - @rm -f test-ibft$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ibft_OBJECTS) $(test_ibft_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ibft.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -reader.o: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.o -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c - -reader.obj: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.obj -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-ibft.log: test-ibft$(EXEEXT) - @p='test-ibft$(EXEEXT)'; \ - b='test-ibft'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am \ - check-local clean clean-generic clean-libtool \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am recheck tags tags-am uninstall \ - uninstall-am - -.PRECIOUS: Makefile - - -@ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@@VALGRIND_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ibft.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c index cab468de..72d1a7db 100644 --- a/src/settings/plugins/ibft/tests/test-ibft.c +++ b/src/settings/plugins/ibft/tests/test-ibft.c @@ -32,7 +32,7 @@ #include "nm-core-internal.h" #include "NetworkManagerUtils.h" -#include "reader.h" +#include "settings/plugins/ibft/nms-ibft-reader.h" #include "nm-test-utils-core.h" @@ -44,7 +44,7 @@ read_block (const char *iscsiadm_path, const char *expected_mac) GError *error = NULL; gboolean success; - success = read_ibft_blocks (iscsiadm_path, &blocks, &error); + success = nms_ibft_reader_load_blocks (iscsiadm_path, &blocks, &error); g_assert_no_error (error); g_assert (success); g_assert (blocks); @@ -52,7 +52,7 @@ read_block (const char *iscsiadm_path, const char *expected_mac) for (iter = blocks; iter; iter = iter->next) { const char *s_hwaddr = NULL; - if (!parse_ibft_config (iter->data, NULL, "iface.hwaddress", &s_hwaddr, NULL)) + if (!nms_ibft_reader_parse_block (iter->data, NULL, "iface.hwaddress", &s_hwaddr, NULL)) continue; g_assert (s_hwaddr); if (nm_utils_hwaddr_matches (s_hwaddr, -1, expected_mac, -1)) { @@ -80,7 +80,7 @@ test_read_ibft_dhcp (void) block = read_block (TEST_IBFT_DIR "/iscsiadm-test-dhcp", expected_mac_address); - connection = connection_from_block (block, &error); + connection = nms_ibft_reader_get_connection_from_block (block, &error); g_assert_no_error (error); nmtst_assert_connection_verifies_without_normalization (connection); @@ -127,7 +127,7 @@ test_read_ibft_static (void) block = read_block (TEST_IBFT_DIR "/iscsiadm-test-static", expected_mac_address); - connection = connection_from_block (block, &error); + connection = nms_ibft_reader_get_connection_from_block (block, &error); g_assert_no_error (error); nmtst_assert_connection_verifies_without_normalization (connection); @@ -183,7 +183,7 @@ test_read_ibft_malformed (gconstpointer user_data) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*malformed iscsiadm record*"); - success = read_ibft_blocks (iscsiadm_path, &blocks, &error); + success = nms_ibft_reader_load_blocks (iscsiadm_path, &blocks, &error); g_assert_no_error (error); g_assert (success); g_assert (blocks == NULL); @@ -204,7 +204,7 @@ test_read_ibft_bad_address (gconstpointer user_data) block = read_block (iscsiadm_path, expected_mac_address); - connection = connection_from_block (block, &error); + connection = nms_ibft_reader_get_connection_from_block (block, &error); g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "iBFT: malformed iscsiadm record: invalid")); g_clear_error (&error); @@ -229,7 +229,7 @@ test_read_ibft_vlan (void) block = read_block (TEST_IBFT_DIR "/iscsiadm-test-vlan", expected_mac_address); - connection = connection_from_block (block, &error); + connection = nms_ibft_reader_get_connection_from_block (block, &error); g_assert_no_error (error); nmtst_assert_connection_verifies_without_normalization (connection); diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am deleted file mode 100644 index d2899a26..00000000 --- a/src/settings/plugins/ifcfg-rh/Makefile.am +++ /dev/null @@ -1,74 +0,0 @@ -SUBDIRS = . tests - -@GNOME_CODE_COVERAGE_RULES@ - -# See note about gdbus-codegen in introspection/Makefile.am - -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 - -libifcfg_rh_io_la_SOURCES = \ - shvar.c \ - shvar.h \ - reader.c \ - reader.h \ - writer.c \ - writer.h \ - common.h \ - utils.c \ - utils.h - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(NSS_CFLAGS) \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" - -libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ - plugin.c \ - plugin.h \ - nm-ifcfg-connection.c \ - 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 libnmdbus-ifcfg-rh.la - -dbusservicedir = $(DBUS_SYS_DIR) -dbusservice_DATA = nm-ifcfg-rh.conf - -EXTRA_DIST = \ - $(dbusservice_DATA) \ - nm-ifcfg-rh.xml - -CLEANFILES = $(BUILT_SOURCES) - diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in deleted file mode 100644 index 200289e5..00000000 --- a/src/settings/plugins/ifcfg-rh/Makefile.in +++ /dev/null @@ -1,1062 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ifcfg-rh -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" \ - "$(DESTDIR)$(dbusservicedir)" -LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES) -libifcfg_rh_io_la_LIBADD = -am_libifcfg_rh_io_la_OBJECTS = shvar.lo reader.lo writer.lo utils.lo -libifcfg_rh_io_la_OBJECTS = $(am_libifcfg_rh_io_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES = libifcfg-rh-io.la \ - libnmdbus-ifcfg-rh.la -am_libnm_settings_plugin_ifcfg_rh_la_OBJECTS = plugin.lo \ - nm-ifcfg-connection.lo -libnm_settings_plugin_ifcfg_rh_la_OBJECTS = \ - $(am_libnm_settings_plugin_ifcfg_rh_la_OBJECTS) -libnm_settings_plugin_ifcfg_rh_la_LINK = $(LIBTOOL) $(AM_V_lt) \ - --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ - $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_ifcfg_rh_la_LDFLAGS) $(LDFLAGS) -o $@ -libnmdbus_ifcfg_rh_la_LIBADD = -nodist_libnmdbus_ifcfg_rh_la_OBJECTS = \ - libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo -libnmdbus_ifcfg_rh_la_OBJECTS = \ - $(nodist_libnmdbus_ifcfg_rh_la_OBJECTS) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libifcfg_rh_io_la_SOURCES) \ - $(libnm_settings_plugin_ifcfg_rh_la_SOURCES) \ - $(nodist_libnmdbus_ifcfg_rh_la_SOURCES) -DIST_SOURCES = $(libifcfg_rh_io_la_SOURCES) \ - $(libnm_settings_plugin_ifcfg_rh_la_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -DATA = $(dbusservice_DATA) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = . tests - -# See note about gdbus-codegen in introspection/Makefile.am -noinst_LTLIBRARIES = libnmdbus-ifcfg-rh.la libifcfg-rh-io.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)) -BUILT_SOURCES = nmdbus-ifcfg-rh.h nmdbus-ifcfg-rh.c -pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la -libifcfg_rh_io_la_SOURCES = \ - shvar.c \ - shvar.h \ - reader.c \ - reader.h \ - writer.c \ - writer.h \ - common.h \ - utils.c \ - utils.h - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(NSS_CFLAGS) \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" - -libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ - plugin.c \ - plugin.h \ - nm-ifcfg-connection.c \ - 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 libnmdbus-ifcfg-rh.la -dbusservicedir = $(DBUS_SYS_DIR) -dbusservice_DATA = nm-ifcfg-rh.conf -EXTRA_DIST = \ - $(dbusservice_DATA) \ - nm-ifcfg-rh.xml - -CLEANFILES = $(BUILT_SOURCES) -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libifcfg-rh-io.la: $(libifcfg_rh_io_la_OBJECTS) $(libifcfg_rh_io_la_DEPENDENCIES) $(EXTRA_libifcfg_rh_io_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libifcfg_rh_io_la_OBJECTS) $(libifcfg_rh_io_la_LIBADD) $(LIBS) - -libnm-settings-plugin-ifcfg-rh.la: $(libnm_settings_plugin_ifcfg_rh_la_OBJECTS) $(libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_ifcfg_rh_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ifcfg_rh_la_OBJECTS) $(libnm_settings_plugin_ifcfg_rh_la_LIBADD) $(LIBS) - -libnmdbus-ifcfg-rh.la: $(libnmdbus_ifcfg_rh_la_OBJECTS) $(libnmdbus_ifcfg_rh_la_DEPENDENCIES) $(EXTRA_libnmdbus_ifcfg_rh_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libnmdbus_ifcfg_rh_la_OBJECTS) $(libnmdbus_ifcfg_rh_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ifcfg-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shvar.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo: nmdbus-ifcfg-rh.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnmdbus_ifcfg_rh_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo -MD -MP -MF $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Tpo -c -o libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo `test -f 'nmdbus-ifcfg-rh.c' || echo '$(srcdir)/'`nmdbus-ifcfg-rh.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Tpo $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nmdbus-ifcfg-rh.c' object='libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnmdbus_ifcfg_rh_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo `test -f 'nmdbus-ifcfg-rh.c' || echo '$(srcdir)/'`nmdbus-ifcfg-rh.c - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-dbusserviceDATA: $(dbusservice_DATA) - @$(NORMAL_INSTALL) - @list='$(dbusservice_DATA)'; test -n "$(dbusservicedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(dbusservicedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(dbusservicedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dbusservicedir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(dbusservicedir)" || exit $$?; \ - done - -uninstall-dbusserviceDATA: - @$(NORMAL_UNINSTALL) - @list='$(dbusservice_DATA)'; test -n "$(dbusservicedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(dbusservicedir)'; $(am__uninstall_files_from_dir) - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-recursive -all-am: Makefile $(LTLIBRARIES) $(DATA) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(dbusservicedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - clean-pkglibLTLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-dbusserviceDATA - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-dbusserviceDATA uninstall-pkglibLTLIBRARIES - -.MAKE: $(am__recursive_targets) all check install install-am \ - install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dbusserviceDATA install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-pkglibLTLIBRARIES \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-dbusserviceDATA \ - uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -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 - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/common.h deleted file mode 100644 index d850ac4e..00000000 --- a/src/settings/plugins/ifcfg-rh/common.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 - 2013 Red Hat, Inc. - */ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#define IFCFG_TAG "ifcfg-" -#define KEYS_TAG "keys-" -#define ROUTE_TAG "route-" -#define RULE_TAG "rule-" -#define ROUTE6_TAG "route6-" -#define RULE6_TAG "rule6-" - -#define BAK_TAG ".bak" -#define TILDE_TAG "~" -#define ORIG_TAG ".orig" -#define REJ_TAG ".rej" -#define RPMNEW_TAG ".rpmnew" -#define AUGNEW_TAG ".augnew" -#define AUGTMP_TAG ".augtmp" - -#define IFCFG_DIR SYSCONFDIR "/sysconfig/network-scripts" - -#define IFCFG_PLUGIN_NAME "ifcfg-rh" -#define IFCFG_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." - -#define TYPE_ETHERNET "Ethernet" -#define TYPE_WIRELESS "Wireless" -#define TYPE_INFINIBAND "InfiniBand" -#define TYPE_BRIDGE "Bridge" -#define TYPE_BOND "Bond" -#define TYPE_VLAN "Vlan" -#define TYPE_TEAM "Team" -#define TYPE_TEAM_PORT "TeamPort" - -#define SECRET_FLAG_AGENT "user" -#define SECRET_FLAG_NOT_SAVED "ask" -#define SECRET_FLAG_NOT_REQUIRED "unused" - -/* DCB key names */ -#define KEY_DCB_APP_FCOE_ENABLE "DCB_APP_FCOE_ENABLE" -#define KEY_DCB_APP_FCOE_ADVERTISE "DCB_APP_FCOE_ADVERTISE" -#define KEY_DCB_APP_FCOE_WILLING "DCB_APP_FCOE_WILLING" -#define KEY_DCB_APP_FCOE_MODE "DCB_APP_FCOE_MODE" -#define KEY_DCB_APP_ISCSI_ENABLE "DCB_APP_ISCSI_ENABLE" -#define KEY_DCB_APP_ISCSI_ADVERTISE "DCB_APP_ISCSI_ADVERTISE" -#define KEY_DCB_APP_ISCSI_WILLING "DCB_APP_ISCSI_WILLING" -#define KEY_DCB_APP_FIP_ENABLE "DCB_APP_FIP_ENABLE" -#define KEY_DCB_APP_FIP_ADVERTISE "DCB_APP_FIP_ADVERTISE" -#define KEY_DCB_APP_FIP_WILLING "DCB_APP_FIP_WILLING" -#define KEY_DCB_PFC_ENABLE "DCB_PFC_ENABLE" -#define KEY_DCB_PFC_ADVERTISE "DCB_PFC_ADVERTISE" -#define KEY_DCB_PFC_WILLING "DCB_PFC_WILLING" -#define KEY_DCB_PFC_UP "DCB_PFC_UP" -#define KEY_DCB_PG_ENABLE "DCB_PG_ENABLE" -#define KEY_DCB_PG_ADVERTISE "DCB_PG_ADVERTISE" -#define KEY_DCB_PG_WILLING "DCB_PG_WILLING" -#define KEY_DCB_PG_ID "DCB_PG_ID" -#define KEY_DCB_PG_PCT "DCB_PG_PCT" -#define KEY_DCB_PG_UPPCT "DCB_PG_UPPCT" -#define KEY_DCB_PG_STRICT "DCB_PG_STRICT" -#define KEY_DCB_PG_UP2TC "DCB_PG_UP2TC" - -#endif /* __COMMON_H__ */ - diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c deleted file mode 100644 index a83bd35d..00000000 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ /dev/null @@ -1,566 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "nm-ifcfg-connection.h" - -#include - -#include - -#include "nm-dbus-interface.h" -#include "nm-setting-connection.h" -#include "nm-setting-wired.h" -#include "nm-setting-wireless.h" -#include "nm-setting-gsm.h" -#include "nm-setting-cdma.h" -#include "nm-setting-pppoe.h" -#include "nm-setting-wireless-security.h" -#include "nm-setting-8021x.h" -#include "nm-platform.h" - -#include "common.h" -#include "nm-config.h" -#include "reader.h" -#include "writer.h" -#include "nm-inotify-helper.h" -#include "utils.h" - -G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SETTINGS_CONNECTION) - -#define NM_IFCFG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionPrivate)) - -typedef struct { - gulong ih_event_id; - - int file_wd; - - char *keyfile; - int keyfile_wd; - - char *routefile; - int routefile_wd; - - char *route6file; - int route6file_wd; - - char *unmanaged_spec; - char *unrecognized_spec; - - gulong devtimeout_link_changed_handler; - guint devtimeout_timeout_id; - - NMInotifyHelper *inotify_helper; -} NMIfcfgConnectionPrivate; - -enum { - PROP_0, - PROP_UNMANAGED_SPEC, - PROP_UNRECOGNIZED_SPEC, - LAST_PROP -}; - -/* Signals */ -enum { - IFCFG_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static NMInotifyHelper * -_get_inotify_helper (NMIfcfgConnectionPrivate *priv) -{ - if (!priv->inotify_helper) - priv->inotify_helper = g_object_ref (nm_inotify_helper_get ()); - return priv->inotify_helper; -} - -static gboolean -devtimeout_ready (gpointer user_data) -{ - NMIfcfgConnection *self = user_data; - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); - - priv->devtimeout_timeout_id = 0; - nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), TRUE); - return FALSE; -} - -static void -link_changed (NMPlatform *platform, NMPObjectType obj_type, int ifindex, const NMPlatformLink *link, - NMPlatformSignalChangeType change_type, - NMConnection *self) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); - const char *ifname; - - ifname = nm_connection_get_interface_name (self); - if (g_strcmp0 (link->name, ifname) != 0) - return; - - if (change_type == NM_PLATFORM_SIGNAL_REMOVED) - return; - - nm_log_info (LOGD_SETTINGS, "Device %s appeared; connection '%s' now ready", - ifname, nm_connection_get_id (self)); - - g_signal_handler_disconnect (platform, priv->devtimeout_link_changed_handler); - priv->devtimeout_link_changed_handler = 0; - g_source_remove (priv->devtimeout_timeout_id); - - /* Don't declare the connection ready right away, since NMManager may not have - * started processing the device yet. - */ - priv->devtimeout_timeout_id = g_idle_add (devtimeout_ready, self); -} - -static gboolean -devtimeout_expired (gpointer user_data) -{ - NMIfcfgConnection *self = user_data; - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); - - nm_log_info (LOGD_SETTINGS, "Device for connection '%s' did not appear before timeout", - nm_connection_get_id (NM_CONNECTION (self))); - - g_signal_handler_disconnect (NM_PLATFORM_GET, priv->devtimeout_link_changed_handler); - priv->devtimeout_link_changed_handler = 0; - priv->devtimeout_timeout_id = 0; - - nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), TRUE); - return FALSE; -} - -static void -nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); - NMSettingConnection *s_con; - const char *ifname; - const char *filename; - guint devtimeout; - const NMPlatformLink *pllink; - - s_con = nm_connection_get_setting_connection (NM_CONNECTION (self)); - - if (!nm_setting_connection_get_autoconnect (s_con)) - return; - ifname = nm_setting_connection_get_interface_name (s_con); - if (!ifname) - return; - filename = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self)); - if (!filename) - return; - - pllink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, ifname); - if (pllink && pllink->initialized) - return; - - devtimeout = devtimeout_from_file (filename); - if (!devtimeout) - return; - - /* ONBOOT=yes, DEVICE and DEVTIMEOUT are set, but device is not present */ - nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), FALSE); - - nm_log_info (LOGD_SETTINGS, "Waiting %u seconds for %s to appear for connection '%s'", - devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self))); - - priv->devtimeout_link_changed_handler = - g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED, - G_CALLBACK (link_changed), self); - priv->devtimeout_timeout_id = g_timeout_add_seconds (devtimeout, devtimeout_expired, self); -} - -static void -files_changed_cb (NMInotifyHelper *ih, - struct inotify_event *evt, - const char *path, - gpointer user_data) -{ - NMIfcfgConnection *self = NM_IFCFG_CONNECTION (user_data); - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); - - if ( (evt->wd != priv->file_wd) - && (evt->wd != priv->keyfile_wd) - && (evt->wd != priv->routefile_wd) - && (evt->wd != priv->route6file_wd)) - return; - - /* push the event up to the plugin */ - g_signal_emit (self, signals[IFCFG_CHANGED], 0); -} - -NMIfcfgConnection * -nm_ifcfg_connection_new (NMConnection *source, - const char *full_path, - GError **error, - gboolean *out_ignore_error) -{ - GObject *object; - NMConnection *tmp; - char *unhandled_spec = NULL; - const char *unmanaged_spec = NULL, *unrecognized_spec = NULL; - gboolean update_unsaved = TRUE; - - g_assert (source || full_path); - - if (out_ignore_error) - *out_ignore_error = FALSE; - - /* If we're given a connection already, prefer that instead of re-reading */ - if (source) - tmp = g_object_ref (source); - else { - tmp = connection_from_file (full_path, - &unhandled_spec, - error, - out_ignore_error); - if (!tmp) - return NULL; - - /* If we just read the connection from disk, it's clearly not Unsaved */ - update_unsaved = FALSE; - } - - if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unmanaged:")) - unmanaged_spec = unhandled_spec + strlen ("unmanaged:"); - else if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unrecognized:")) - unrecognized_spec = unhandled_spec + strlen ("unrecognized:"); - - object = (GObject *) g_object_new (NM_TYPE_IFCFG_CONNECTION, - NM_SETTINGS_CONNECTION_FILENAME, full_path, - NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec, - NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec, - NULL); - /* Update our settings with what was read from the file */ - if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - update_unsaved, - NULL, - error)) - nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object)); - else - g_clear_object (&object); - - g_object_unref (tmp); - g_free (unhandled_spec); - return (NMIfcfgConnection *) object; -} - -static void -path_watch_stop (NMIfcfgConnection *self) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); - NMInotifyHelper *ih; - - ih = _get_inotify_helper (priv); - - nm_clear_g_signal_handler (ih, &priv->ih_event_id); - - if (priv->file_wd >= 0) { - nm_inotify_helper_remove_watch (ih, priv->file_wd); - priv->file_wd = -1; - } - - g_free (priv->keyfile); - priv->keyfile = NULL; - if (priv->keyfile_wd >= 0) { - nm_inotify_helper_remove_watch (ih, priv->keyfile_wd); - priv->keyfile_wd = -1; - } - - g_free (priv->routefile); - priv->routefile = NULL; - if (priv->routefile_wd >= 0) { - nm_inotify_helper_remove_watch (ih, priv->routefile_wd); - priv->routefile_wd = -1; - } - - g_free (priv->route6file); - priv->route6file = NULL; - if (priv->route6file_wd >= 0) { - nm_inotify_helper_remove_watch (ih, priv->route6file_wd); - priv->route6file_wd = -1; - } -} - -static void -filename_changed (GObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - NMIfcfgConnection *self = NM_IFCFG_CONNECTION (object); - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); - const char *ifcfg_path; - - path_watch_stop (self); - - ifcfg_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self)); - if (!ifcfg_path) - return; - - priv->keyfile = utils_get_keys_path (ifcfg_path); - priv->routefile = utils_get_route_path (ifcfg_path); - priv->route6file = utils_get_route6_path (ifcfg_path); - - if (nm_config_get_monitor_connection_files (nm_config_get ())) { - NMInotifyHelper *ih; - - ih = _get_inotify_helper (priv); - - priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (files_changed_cb), self); - priv->file_wd = nm_inotify_helper_add_watch (ih, ifcfg_path); - priv->keyfile_wd = nm_inotify_helper_add_watch (ih, priv->keyfile); - priv->routefile_wd = nm_inotify_helper_add_watch (ih, priv->routefile); - priv->route6file_wd = nm_inotify_helper_add_watch (ih, priv->route6file); - } -} - -const char * -nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self) -{ - g_return_val_if_fail (NM_IS_IFCFG_CONNECTION (self), NULL); - - return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged_spec; -} - -const char * -nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self) -{ - g_return_val_if_fail (NM_IS_IFCFG_CONNECTION (self), NULL); - - return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unrecognized_spec; -} - -static void -replace_and_commit (NMSettingsConnection *connection, - NMConnection *new_connection, - NMSettingsConnectionCommitFunc callback, - gpointer user_data) -{ - const char *filename; - GError *error = NULL; - - filename = nm_settings_connection_get_filename (connection); - if (filename && utils_has_complex_routes (filename)) { - if (callback) { - error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Cannot modify a connection that has an associated 'rule-' or 'rule6-' file"); - callback (connection, error, user_data); - g_clear_error (&error); - } - return; - } - - NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->replace_and_commit (connection, new_connection, callback, user_data); -} - -static void -commit_changes (NMSettingsConnection *connection, - NMSettingsConnectionCommitReason commit_reason, - NMSettingsConnectionCommitFunc callback, - gpointer user_data) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); - GError *error = NULL; - NMConnection *reread; - gboolean same = FALSE, success = FALSE; - char *ifcfg_path = NULL; - const char *filename; - - /* To ensure we don't rewrite files that are only changed from other - * processes on-disk, read the existing connection back in and only rewrite - * it if it's really changed. - */ - filename = nm_settings_connection_get_filename (connection); - if (filename) { - gs_free char *unhandled = NULL; - - reread = connection_from_file (filename, &unhandled, NULL, NULL); - if (reread) { - same = nm_connection_compare (NM_CONNECTION (connection), - reread, - NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | - NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS); - g_object_unref (reread); - - /* Don't bother writing anything out if in-memory and on-disk data are the same */ - if (same) { - /* But chain up to parent to handle success - emits updated signal */ - NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); - return; - } - } - - success = writer_update_connection (NM_CONNECTION (connection), - IFCFG_DIR, - filename, - priv->keyfile, - &error); - } else { - success = writer_new_connection (NM_CONNECTION (connection), - IFCFG_DIR, - &ifcfg_path, - &error); - if (success) { - nm_settings_connection_set_filename (connection, ifcfg_path); - g_free (ifcfg_path); - } - } - - if (success) { - /* Chain up to parent to handle success */ - NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); - } else { - /* Otherwise immediate error */ - callback (connection, error, user_data); - g_error_free (error); - } -} - -static void -do_delete (NMSettingsConnection *connection, - NMSettingsConnectionDeleteFunc callback, - gpointer user_data) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); - const char *filename; - - filename = nm_settings_connection_get_filename (connection); - if (filename) { - g_unlink (filename); - if (priv->keyfile) - g_unlink (priv->keyfile); - if (priv->routefile) - g_unlink (priv->routefile); - if (priv->route6file) - g_unlink (priv->route6file); - } - - NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->delete (connection, callback, user_data); -} - -/* GObject */ - -static void -nm_ifcfg_connection_init (NMIfcfgConnection *connection) -{ - g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_FILENAME, - G_CALLBACK (filename_changed), NULL); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_UNMANAGED_SPEC: - priv->unmanaged_spec = g_value_dup_string (value); - break; - case PROP_UNRECOGNIZED_SPEC: - priv->unrecognized_spec = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_UNMANAGED_SPEC: - g_value_set_string (value, priv->unmanaged_spec); - break; - case PROP_UNRECOGNIZED_SPEC: - g_value_set_string (value, priv->unrecognized_spec); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object); - - path_watch_stop (NM_IFCFG_CONNECTION (object)); - - nm_clear_g_signal_handler (NM_PLATFORM_GET, &priv->devtimeout_link_changed_handler); - nm_clear_g_source (&priv->devtimeout_timeout_id); - - g_clear_object (&priv->inotify_helper); - - g_clear_pointer (&priv->unmanaged_spec, g_free); - g_clear_pointer (&priv->unrecognized_spec, g_free); - - G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object); -} - -static void -nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (ifcfg_connection_class); - NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (ifcfg_connection_class); - - g_type_class_add_private (ifcfg_connection_class, sizeof (NMIfcfgConnectionPrivate)); - - /* Virtual methods */ - object_class->set_property = set_property; - object_class->get_property = get_property; - object_class->dispose = dispose; - settings_class->delete = do_delete; - settings_class->replace_and_commit = replace_and_commit; - settings_class->commit_changes = commit_changes; - - /* Properties */ - g_object_class_install_property - (object_class, PROP_UNMANAGED_SPEC, - g_param_spec_string (NM_IFCFG_CONNECTION_UNMANAGED_SPEC, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); - g_object_class_install_property - (object_class, PROP_UNRECOGNIZED_SPEC, - g_param_spec_string (NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); - - signals[IFCFG_CHANGED] = - g_signal_new ("ifcfg-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h deleted file mode 100644 index 57db059b..00000000 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_IFCFG_CONNECTION_H__ -#define __NETWORKMANAGER_IFCFG_CONNECTION_H__ - -#include "nm-dbus-interface.h" -#include "nm-settings-connection.h" - -#define NM_TYPE_IFCFG_CONNECTION (nm_ifcfg_connection_get_type ()) -#define NM_IFCFG_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnection)) -#define NM_IFCFG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionClass)) -#define NM_IS_IFCFG_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFCFG_CONNECTION)) -#define NM_IS_IFCFG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFCFG_CONNECTION)) -#define NM_IFCFG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionClass)) - -#define NM_IFCFG_CONNECTION_UNMANAGED_SPEC "unmanaged-spec" -#define NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC "unrecognized-spec" - -typedef struct { - NMSettingsConnection parent; -} NMIfcfgConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMIfcfgConnectionClass; - -GType nm_ifcfg_connection_get_type (void); - -NMIfcfgConnection *nm_ifcfg_connection_new (NMConnection *source, - const char *full_path, - GError **error, - gboolean *out_ignore_error); - -const char *nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self); -const char *nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self); - -gboolean nm_ifcfg_connection_update (NMIfcfgConnection *self, - GHashTable *new_settings, - GError **error); - -#endif /* __NETWORKMANAGER_IFCFG_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h new file mode 100644 index 00000000..d850ac4e --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h @@ -0,0 +1,82 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2008 - 2013 Red Hat, Inc. + */ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#define IFCFG_TAG "ifcfg-" +#define KEYS_TAG "keys-" +#define ROUTE_TAG "route-" +#define RULE_TAG "rule-" +#define ROUTE6_TAG "route6-" +#define RULE6_TAG "rule6-" + +#define BAK_TAG ".bak" +#define TILDE_TAG "~" +#define ORIG_TAG ".orig" +#define REJ_TAG ".rej" +#define RPMNEW_TAG ".rpmnew" +#define AUGNEW_TAG ".augnew" +#define AUGTMP_TAG ".augtmp" + +#define IFCFG_DIR SYSCONFDIR "/sysconfig/network-scripts" + +#define IFCFG_PLUGIN_NAME "ifcfg-rh" +#define IFCFG_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." + +#define TYPE_ETHERNET "Ethernet" +#define TYPE_WIRELESS "Wireless" +#define TYPE_INFINIBAND "InfiniBand" +#define TYPE_BRIDGE "Bridge" +#define TYPE_BOND "Bond" +#define TYPE_VLAN "Vlan" +#define TYPE_TEAM "Team" +#define TYPE_TEAM_PORT "TeamPort" + +#define SECRET_FLAG_AGENT "user" +#define SECRET_FLAG_NOT_SAVED "ask" +#define SECRET_FLAG_NOT_REQUIRED "unused" + +/* DCB key names */ +#define KEY_DCB_APP_FCOE_ENABLE "DCB_APP_FCOE_ENABLE" +#define KEY_DCB_APP_FCOE_ADVERTISE "DCB_APP_FCOE_ADVERTISE" +#define KEY_DCB_APP_FCOE_WILLING "DCB_APP_FCOE_WILLING" +#define KEY_DCB_APP_FCOE_MODE "DCB_APP_FCOE_MODE" +#define KEY_DCB_APP_ISCSI_ENABLE "DCB_APP_ISCSI_ENABLE" +#define KEY_DCB_APP_ISCSI_ADVERTISE "DCB_APP_ISCSI_ADVERTISE" +#define KEY_DCB_APP_ISCSI_WILLING "DCB_APP_ISCSI_WILLING" +#define KEY_DCB_APP_FIP_ENABLE "DCB_APP_FIP_ENABLE" +#define KEY_DCB_APP_FIP_ADVERTISE "DCB_APP_FIP_ADVERTISE" +#define KEY_DCB_APP_FIP_WILLING "DCB_APP_FIP_WILLING" +#define KEY_DCB_PFC_ENABLE "DCB_PFC_ENABLE" +#define KEY_DCB_PFC_ADVERTISE "DCB_PFC_ADVERTISE" +#define KEY_DCB_PFC_WILLING "DCB_PFC_WILLING" +#define KEY_DCB_PFC_UP "DCB_PFC_UP" +#define KEY_DCB_PG_ENABLE "DCB_PG_ENABLE" +#define KEY_DCB_PG_ADVERTISE "DCB_PG_ADVERTISE" +#define KEY_DCB_PG_WILLING "DCB_PG_WILLING" +#define KEY_DCB_PG_ID "DCB_PG_ID" +#define KEY_DCB_PG_PCT "DCB_PG_PCT" +#define KEY_DCB_PG_UPPCT "DCB_PG_UPPCT" +#define KEY_DCB_PG_STRICT "DCB_PG_STRICT" +#define KEY_DCB_PG_UP2TC "DCB_PG_UP2TC" + +#endif /* __COMMON_H__ */ + diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c new file mode 100644 index 00000000..33f4847e --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c @@ -0,0 +1,575 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 - 2011 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifcfg-rh-connection.h" + +#include +#include +#include + +#include "nm-dbus-interface.h" +#include "nm-setting-connection.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-gsm.h" +#include "nm-setting-cdma.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-wireless-security.h" +#include "nm-setting-8021x.h" +#include "platform/nm-platform.h" +#include "settings/nm-inotify-helper.h" +#include "nm-config.h" + +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-reader.h" +#include "nms-ifcfg-rh-writer.h" +#include "nms-ifcfg-rh-utils.h" + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_UNMANAGED_SPEC, + PROP_UNRECOGNIZED_SPEC, +); + +enum { + IFCFG_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct { + gulong ih_event_id; + + int file_wd; + + char *keyfile; + int keyfile_wd; + + char *routefile; + int routefile_wd; + + char *route6file; + int route6file_wd; + + char *unmanaged_spec; + char *unrecognized_spec; + + gulong devtimeout_link_changed_handler; + guint devtimeout_timeout_id; + + NMInotifyHelper *inotify_helper; +} NMIfcfgConnectionPrivate; + +struct _NMIfcfgConnection { + NMSettingsConnection parent; + NMIfcfgConnectionPrivate _priv; +}; + +struct _NMIfcfgConnectionClass { + NMSettingsConnectionClass parent; +}; + +G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SETTINGS_CONNECTION) + +#define NM_IFCFG_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMIfcfgConnection, NM_IS_IFCFG_CONNECTION) + +/*****************************************************************************/ + +static NMInotifyHelper * +_get_inotify_helper (NMIfcfgConnectionPrivate *priv) +{ + if (!priv->inotify_helper) + priv->inotify_helper = g_object_ref (nm_inotify_helper_get ()); + return priv->inotify_helper; +} + +static gboolean +devtimeout_ready (gpointer user_data) +{ + NMIfcfgConnection *self = user_data; + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); + + priv->devtimeout_timeout_id = 0; + nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), TRUE); + return FALSE; +} + +static void +link_changed (NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformLink *link, + int change_type_i, + NMConnection *self) +{ + const NMPlatformSignalChangeType change_type = change_type_i; + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) self); + const char *ifname; + + ifname = nm_connection_get_interface_name (self); + if (g_strcmp0 (link->name, ifname) != 0) + return; + + if (change_type == NM_PLATFORM_SIGNAL_REMOVED) + return; + + nm_log_info (LOGD_SETTINGS, "Device %s appeared; connection '%s' now ready", + ifname, nm_connection_get_id (self)); + + g_signal_handler_disconnect (platform, priv->devtimeout_link_changed_handler); + priv->devtimeout_link_changed_handler = 0; + g_source_remove (priv->devtimeout_timeout_id); + + /* Don't declare the connection ready right away, since NMManager may not have + * started processing the device yet. + */ + priv->devtimeout_timeout_id = g_idle_add (devtimeout_ready, self); +} + +static gboolean +devtimeout_expired (gpointer user_data) +{ + NMIfcfgConnection *self = user_data; + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); + + nm_log_info (LOGD_SETTINGS, "Device for connection '%s' did not appear before timeout", + nm_connection_get_id (NM_CONNECTION (self))); + + g_signal_handler_disconnect (NM_PLATFORM_GET, priv->devtimeout_link_changed_handler); + priv->devtimeout_link_changed_handler = 0; + priv->devtimeout_timeout_id = 0; + + nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), TRUE); + return FALSE; +} + +static void +nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self) +{ + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); + NMSettingConnection *s_con; + const char *ifname; + const char *filename; + guint devtimeout; + const NMPlatformLink *pllink; + + s_con = nm_connection_get_setting_connection (NM_CONNECTION (self)); + + if (!nm_setting_connection_get_autoconnect (s_con)) + return; + ifname = nm_setting_connection_get_interface_name (s_con); + if (!ifname) + return; + filename = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self)); + if (!filename) + return; + + pllink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, ifname); + if (pllink && pllink->initialized) + return; + + devtimeout = devtimeout_from_file (filename); + if (!devtimeout) + return; + + /* ONBOOT=yes, DEVICE and DEVTIMEOUT are set, but device is not present */ + nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), FALSE); + + nm_log_info (LOGD_SETTINGS, "Waiting %u seconds for %s to appear for connection '%s'", + devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self))); + + priv->devtimeout_link_changed_handler = + g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED, + G_CALLBACK (link_changed), self); + priv->devtimeout_timeout_id = g_timeout_add_seconds (devtimeout, devtimeout_expired, self); +} + +static void +files_changed_cb (NMInotifyHelper *ih, + struct inotify_event *evt, + const char *path, + gpointer user_data) +{ + NMIfcfgConnection *self = NM_IFCFG_CONNECTION (user_data); + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); + + if ( (evt->wd != priv->file_wd) + && (evt->wd != priv->keyfile_wd) + && (evt->wd != priv->routefile_wd) + && (evt->wd != priv->route6file_wd)) + return; + + /* push the event up to the plugin */ + g_signal_emit (self, signals[IFCFG_CHANGED], 0); +} + +static void +path_watch_stop (NMIfcfgConnection *self) +{ + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); + NMInotifyHelper *ih; + + ih = _get_inotify_helper (priv); + + nm_clear_g_signal_handler (ih, &priv->ih_event_id); + + if (priv->file_wd >= 0) { + nm_inotify_helper_remove_watch (ih, priv->file_wd); + priv->file_wd = -1; + } + + g_free (priv->keyfile); + priv->keyfile = NULL; + if (priv->keyfile_wd >= 0) { + nm_inotify_helper_remove_watch (ih, priv->keyfile_wd); + priv->keyfile_wd = -1; + } + + g_free (priv->routefile); + priv->routefile = NULL; + if (priv->routefile_wd >= 0) { + nm_inotify_helper_remove_watch (ih, priv->routefile_wd); + priv->routefile_wd = -1; + } + + g_free (priv->route6file); + priv->route6file = NULL; + if (priv->route6file_wd >= 0) { + nm_inotify_helper_remove_watch (ih, priv->route6file_wd); + priv->route6file_wd = -1; + } +} + +static void +filename_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + NMIfcfgConnection *self = NM_IFCFG_CONNECTION (object); + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); + const char *ifcfg_path; + + path_watch_stop (self); + + ifcfg_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self)); + if (!ifcfg_path) + return; + + priv->keyfile = utils_get_keys_path (ifcfg_path); + priv->routefile = utils_get_route_path (ifcfg_path); + priv->route6file = utils_get_route6_path (ifcfg_path); + + if (nm_config_get_monitor_connection_files (nm_config_get ())) { + NMInotifyHelper *ih; + + ih = _get_inotify_helper (priv); + + priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (files_changed_cb), self); + priv->file_wd = nm_inotify_helper_add_watch (ih, ifcfg_path); + priv->keyfile_wd = nm_inotify_helper_add_watch (ih, priv->keyfile); + priv->routefile_wd = nm_inotify_helper_add_watch (ih, priv->routefile); + priv->route6file_wd = nm_inotify_helper_add_watch (ih, priv->route6file); + } +} + +const char * +nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self) +{ + g_return_val_if_fail (NM_IS_IFCFG_CONNECTION (self), NULL); + + return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged_spec; +} + +const char * +nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self) +{ + g_return_val_if_fail (NM_IS_IFCFG_CONNECTION (self), NULL); + + return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unrecognized_spec; +} + +static void +replace_and_commit (NMSettingsConnection *connection, + NMConnection *new_connection, + NMSettingsConnectionCommitFunc callback, + gpointer user_data) +{ + const char *filename; + GError *error = NULL; + + filename = nm_settings_connection_get_filename (connection); + if (filename && utils_has_complex_routes (filename)) { + if (callback) { + error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Cannot modify a connection that has an associated 'rule-' or 'rule6-' file"); + callback (connection, error, user_data); + g_clear_error (&error); + } + return; + } + + NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->replace_and_commit (connection, new_connection, callback, user_data); +} + +static void +commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, + NMSettingsConnectionCommitFunc callback, + gpointer user_data) +{ + GError *error = NULL; + NMConnection *reread; + gboolean same = FALSE, success = FALSE; + char *ifcfg_path = NULL; + const char *filename; + + /* To ensure we don't rewrite files that are only changed from other + * processes on-disk, read the existing connection back in and only rewrite + * it if it's really changed. + */ + filename = nm_settings_connection_get_filename (connection); + if (filename) { + gs_free char *unhandled = NULL; + + reread = connection_from_file (filename, &unhandled, NULL, NULL); + if (reread) { + same = nm_connection_compare (NM_CONNECTION (connection), + reread, + NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | + NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS); + g_object_unref (reread); + + /* Don't bother writing anything out if in-memory and on-disk data are the same */ + if (same) { + /* But chain up to parent to handle success - emits updated signal */ + NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); + return; + } + } + + success = writer_update_connection (NM_CONNECTION (connection), + IFCFG_DIR, + filename, + &error); + } else { + success = writer_new_connection (NM_CONNECTION (connection), + IFCFG_DIR, + &ifcfg_path, + &error); + if (success) { + nm_settings_connection_set_filename (connection, ifcfg_path); + g_free (ifcfg_path); + } + } + + if (success) { + /* Chain up to parent to handle success */ + NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); + } else { + /* Otherwise immediate error */ + callback (connection, error, user_data); + g_error_free (error); + } +} + +static void +do_delete (NMSettingsConnection *connection, + NMSettingsConnectionDeleteFunc callback, + gpointer user_data) +{ + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) connection); + const char *filename; + + filename = nm_settings_connection_get_filename (connection); + if (filename) { + g_unlink (filename); + if (priv->keyfile) + g_unlink (priv->keyfile); + if (priv->routefile) + g_unlink (priv->routefile); + if (priv->route6file) + g_unlink (priv->route6file); + } + + NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->delete (connection, callback, user_data); +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) object); + + switch (prop_id) { + case PROP_UNMANAGED_SPEC: + g_value_set_string (value, priv->unmanaged_spec); + break; + case PROP_UNRECOGNIZED_SPEC: + g_value_set_string (value, priv->unrecognized_spec); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) object); + + switch (prop_id) { + case PROP_UNMANAGED_SPEC: + priv->unmanaged_spec = g_value_dup_string (value); + break; + case PROP_UNRECOGNIZED_SPEC: + priv->unrecognized_spec = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_ifcfg_connection_init (NMIfcfgConnection *connection) +{ + g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_FILENAME, + G_CALLBACK (filename_changed), NULL); +} + +NMIfcfgConnection * +nm_ifcfg_connection_new (NMConnection *source, + const char *full_path, + GError **error, + gboolean *out_ignore_error) +{ + GObject *object; + NMConnection *tmp; + char *unhandled_spec = NULL; + const char *unmanaged_spec = NULL, *unrecognized_spec = NULL; + gboolean update_unsaved = TRUE; + + g_assert (source || full_path); + + if (out_ignore_error) + *out_ignore_error = FALSE; + + /* If we're given a connection already, prefer that instead of re-reading */ + if (source) + tmp = g_object_ref (source); + else { + tmp = connection_from_file (full_path, + &unhandled_spec, + error, + out_ignore_error); + if (!tmp) + return NULL; + + /* If we just read the connection from disk, it's clearly not Unsaved */ + update_unsaved = FALSE; + } + + if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unmanaged:")) + unmanaged_spec = unhandled_spec + strlen ("unmanaged:"); + else if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unrecognized:")) + unrecognized_spec = unhandled_spec + strlen ("unrecognized:"); + + object = (GObject *) g_object_new (NM_TYPE_IFCFG_CONNECTION, + NM_SETTINGS_CONNECTION_FILENAME, full_path, + NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec, + NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec, + NULL); + /* Update our settings with what was read from the file */ + if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), + tmp, + update_unsaved, + NULL, + error)) + nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object)); + else + g_clear_object (&object); + + g_object_unref (tmp); + g_free (unhandled_spec); + return (NMIfcfgConnection *) object; +} + +static void +dispose (GObject *object) +{ + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) object); + + path_watch_stop (NM_IFCFG_CONNECTION (object)); + + nm_clear_g_signal_handler (NM_PLATFORM_GET, &priv->devtimeout_link_changed_handler); + nm_clear_g_source (&priv->devtimeout_timeout_id); + + g_clear_object (&priv->inotify_helper); + + g_clear_pointer (&priv->unmanaged_spec, g_free); + g_clear_pointer (&priv->unrecognized_spec, g_free); + + G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object); +} + +static void +nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (ifcfg_connection_class); + NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (ifcfg_connection_class); + + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->dispose = dispose; + + settings_class->delete = do_delete; + settings_class->replace_and_commit = replace_and_commit; + settings_class->commit_changes = commit_changes; + + obj_properties[PROP_UNMANAGED_SPEC] = + g_param_spec_string (NM_IFCFG_CONNECTION_UNMANAGED_SPEC, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_UNRECOGNIZED_SPEC] = + g_param_spec_string (NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + signals[IFCFG_CHANGED] = + g_signal_new ("ifcfg-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} + diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.h new file mode 100644 index 00000000..fd68f2d3 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.h @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 - 2011 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_IFCFG_CONNECTION_H__ +#define __NETWORKMANAGER_IFCFG_CONNECTION_H__ + +#include "nm-dbus-interface.h" +#include "settings/nm-settings-connection.h" + +#define NM_TYPE_IFCFG_CONNECTION (nm_ifcfg_connection_get_type ()) +#define NM_IFCFG_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnection)) +#define NM_IFCFG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionClass)) +#define NM_IS_IFCFG_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFCFG_CONNECTION)) +#define NM_IS_IFCFG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFCFG_CONNECTION)) +#define NM_IFCFG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionClass)) + +#define NM_IFCFG_CONNECTION_UNMANAGED_SPEC "unmanaged-spec" +#define NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC "unrecognized-spec" + +typedef struct _NMIfcfgConnection NMIfcfgConnection; +typedef struct _NMIfcfgConnectionClass NMIfcfgConnectionClass; + +GType nm_ifcfg_connection_get_type (void); + +NMIfcfgConnection *nm_ifcfg_connection_new (NMConnection *source, + const char *full_path, + GError **error, + gboolean *out_ignore_error); + +const char *nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self); +const char *nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self); + +gboolean nm_ifcfg_connection_update (NMIfcfgConnection *self, + GHashTable *new_settings, + GError **error); + +#endif /* __NETWORKMANAGER_IFCFG_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c new file mode 100644 index 00000000..414f593b --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c @@ -0,0 +1,1085 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * Dan Williams + * Søren Sandmann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2007 - 2011 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifcfg-rh-plugin.h" + +#include +#include +#include +#include +#include +#include + +#include "nm-dbus-compat.h" +#include "nm-setting-connection.h" +#include "settings/nm-settings-plugin.h" +#include "nm-config.h" +#include "NetworkManagerUtils.h" +#include "nm-exported-object.h" + +#include "nms-ifcfg-rh-connection.h" +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-reader.h" +#include "nms-ifcfg-rh-writer.h" +#include "nms-ifcfg-rh-utils.h" +#include "shvar.h" + +#include "settings/plugins/ifcfg-rh/nmdbus-ifcfg-rh.h" + +#define IFCFGRH1_DBUS_SERVICE_NAME "com.redhat.ifcfgrh1" +#define IFCFGRH1_DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1" + +/*****************************************************************************/ + +typedef struct { + NMConfig *config; + + struct { + GDBusConnection *connection; + GDBusInterfaceSkeleton *interface; + GCancellable *cancellable; + gulong signal_id; + } dbus; + + GHashTable *connections; /* uuid::connection */ + gboolean initialized; + + GFileMonitor *ifcfg_monitor; + gulong ifcfg_monitor_id; +} SettingsPluginIfcfgPrivate; + +struct _SettingsPluginIfcfg { + GObject parent; + SettingsPluginIfcfgPrivate _priv; +}; + +struct _SettingsPluginIfcfgClass { + GObjectClass parent; +}; + +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); + +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) + +#define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginIfcfg, SETTINGS_IS_PLUGIN_IFCFG) + +/*****************************************************************************/ + +static SettingsPluginIfcfg *settings_plugin_ifcfg_get (void); + +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfcfg, settings_plugin_ifcfg_get, SETTINGS_TYPE_PLUGIN_IFCFG); + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG(level, ...) \ + G_STMT_START { \ + nm_log ((level), (_NMLOG_DOMAIN), \ + "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + "ifcfg-rh: " \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + +/*****************************************************************************/ + +static NMIfcfgConnection *update_connection (SettingsPluginIfcfg *plugin, + NMConnection *source, + const char *full_path, + NMIfcfgConnection *connection, + gboolean protect_existing_connection, + GHashTable *protected_connections, + GError **error); + +/*****************************************************************************/ + +static void +connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (user_data); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + const char *path; + + path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)); + g_return_if_fail (path != NULL); + + + if (!priv->ifcfg_monitor) { + _LOGD ("connection_ifcfg_changed("NM_IFCFG_CONNECTION_LOG_FMTD"): %s", NM_IFCFG_CONNECTION_LOG_ARGD (connection), "ignore event"); + return; + } + + _LOGD ("connection_ifcfg_changed("NM_IFCFG_CONNECTION_LOG_FMTD"): %s", NM_IFCFG_CONNECTION_LOG_ARGD (connection), "reload"); + + update_connection (self, NULL, path, connection, TRUE, NULL, NULL); +} + +static void +connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) +{ + g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) user_data)->connections, + nm_connection_get_uuid (NM_CONNECTION (obj))); +} + +static void +remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + gboolean unmanaged, unrecognized; + + g_return_if_fail (self != NULL); + g_return_if_fail (connection != NULL); + + _LOGI ("remove "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection)); + + unmanaged = !!nm_ifcfg_connection_get_unmanaged_spec (connection); + unrecognized = !!nm_ifcfg_connection_get_unrecognized_spec (connection); + + g_object_ref (connection); + g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection))); + if (!unmanaged && !unrecognized) + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection), FALSE); + g_object_unref (connection); + + /* Emit changes _after_ removing the connection */ + if (unmanaged) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); + if (unrecognized) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); +} + +static NMIfcfgConnection * +find_by_path (SettingsPluginIfcfg *self, const char *path) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + GHashTableIter iter; + NMSettingsConnection *candidate = NULL; + + g_return_val_if_fail (path != NULL, NULL); + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { + if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0) + return NM_IFCFG_CONNECTION (candidate); + } + return NULL; +} + +static NMIfcfgConnection * +update_connection (SettingsPluginIfcfg *self, + NMConnection *source, + const char *full_path, + NMIfcfgConnection *connection, + gboolean protect_existing_connection, + GHashTable *protected_connections, + GError **error) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + NMIfcfgConnection *connection_new; + NMIfcfgConnection *connection_by_uuid; + GError *local = NULL; + const char *new_unmanaged = NULL, *old_unmanaged = NULL; + const char *new_unrecognized = NULL, *old_unrecognized = NULL; + gboolean unmanaged_changed = FALSE, unrecognized_changed = FALSE; + const char *uuid; + gboolean ignore_error = FALSE; + + g_return_val_if_fail (!source || NM_IS_CONNECTION (source), NULL); + g_return_val_if_fail (full_path || source, NULL); + + if (full_path) + _LOGD ("loading from file \"%s\"...", full_path); + + /* Create a NMIfcfgConnection instance, either by reading from @full_path or + * based on @source. */ + connection_new = nm_ifcfg_connection_new (source, full_path, &local, &ignore_error); + if (!connection_new) { + /* Unexpected failure. Probably the file is invalid? */ + if ( connection + && !protect_existing_connection + && (!protected_connections || !g_hash_table_contains (protected_connections, connection))) + remove_connection (self, connection); + if (!source) { + _NMLOG (ignore_error ? LOGL_DEBUG : LOGL_WARN, + "loading \"%s\" fails: %s", full_path, local ? local->message : "(unknown reason)"); + } + g_propagate_error (error, local); + return NULL; + } + + uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new)); + connection_by_uuid = g_hash_table_lookup (priv->connections, uuid); + + if ( connection + && connection != connection_by_uuid) { + + if ( (protect_existing_connection && connection_by_uuid != NULL) + || (protected_connections && g_hash_table_contains (protected_connections, connection))) { + NMIfcfgConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection; + + if (source) + _LOGW ("cannot update protected connection "NM_IFCFG_CONNECTION_LOG_FMT" due to conflicting UUID %s", NM_IFCFG_CONNECTION_LOG_ARG (conflicting), uuid); + else + _LOGW ("cannot load %s due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, full_path, NM_IFCFG_CONNECTION_LOG_ARG (conflicting)); + g_object_unref (connection_new); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Cannot update protected connection due to conflicting UUID"); + return NULL; + } + + /* The new connection has a different UUID then the original one that we + * are about to update. Remove @connection. */ + remove_connection (self, connection); + } + + /* Check if the found connection with the same UUID is not protected from updating. */ + if ( connection_by_uuid + && ( (!connection && protect_existing_connection) + || (protected_connections && g_hash_table_contains (protected_connections, connection_by_uuid)))) { + if (source) + _LOGW ("cannot update connection due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_by_uuid)); + else + _LOGW ("cannot load %s due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, full_path, NM_IFCFG_CONNECTION_LOG_ARG (connection_by_uuid)); + g_object_unref (connection_new); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Skip updating protected connection during reload"); + return NULL; + } + + /* Evaluate unmanaged/unrecognized flags. */ + if (connection_by_uuid) + old_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (connection_by_uuid); + new_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (connection_new); + unmanaged_changed = g_strcmp0 (old_unmanaged, new_unmanaged); + + if (connection_by_uuid) + old_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (connection_by_uuid); + new_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (connection_new); + unrecognized_changed = g_strcmp0 (old_unrecognized, new_unrecognized); + + if (connection_by_uuid) { + const char *old_path; + + old_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)); + + if ( !unmanaged_changed + && !unrecognized_changed + && nm_connection_compare (NM_CONNECTION (connection_by_uuid), + NM_CONNECTION (connection_new), + NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | + NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { + if (old_path && g_strcmp0 (old_path, full_path) != 0) + _LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT" without other changes", nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)), NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + } else { + + /******************************************************* + * UPDATE + *******************************************************/ + + if (source) + _LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT" from %s", NM_IFCFG_CONNECTION_LOG_ARG (connection_new), NM_IFCFG_CONNECTION_LOG_PATH (old_path)); + else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new)))) + _LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + else if (old_path) + _LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT, old_path, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + else + _LOGI ("update and persist "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + + g_object_set (connection_by_uuid, + NM_IFCFG_CONNECTION_UNMANAGED_SPEC, new_unmanaged, + NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, new_unrecognized, + NULL); + + if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid), + NM_CONNECTION (connection_new), + FALSE, /* don't set Unsaved */ + "ifcfg-update", + &local)) { + /* Shouldn't ever get here as 'connection_new' was verified by the reader already + * and the UUID did not change. */ + g_assert_not_reached (); + } + g_assert_no_error (local); + + if (new_unmanaged || new_unrecognized) { + if (!old_unmanaged && !old_unrecognized) { + g_object_ref (connection_by_uuid); + /* Unexport the connection by telling the settings service it's + * been removed. + */ + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid), TRUE); + /* Remove the path so that claim_connection() doesn't complain later when + * interface gets managed and connection is re-added. */ + nm_connection_set_path (NM_CONNECTION (connection_by_uuid), NULL); + + /* signal_remove() will end up removing the connection from our hash, + * so add it back now. + */ + g_hash_table_insert (priv->connections, + g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection_by_uuid))), + connection_by_uuid); + } + } else { + if (old_unmanaged /* && !new_unmanaged */) { + _LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" and its device because NM_CONTROLLED was true.", + NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid); + } else if (old_unrecognized /* && !new_unrecognized */) { + _LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" because it is now a recognized type.", + NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid); + } + } + + if (unmanaged_changed) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); + if (unrecognized_changed) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); + } + nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (connection_by_uuid), full_path); + g_object_unref (connection_new); + return connection_by_uuid; + } else { + + /******************************************************* + * ADD + *******************************************************/ + + if (source) + _LOGI ("add connection "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + else + _LOGI ("new connection "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + g_hash_table_insert (priv->connections, g_strdup (uuid), connection_new); + + g_signal_connect (connection_new, NM_SETTINGS_CONNECTION_REMOVED, + G_CALLBACK (connection_removed_cb), + self); + + if (nm_ifcfg_connection_get_unmanaged_spec (connection_new)) { + _LOGI ("Ignoring connection "NM_IFCFG_CONNECTION_LOG_FMT" due to NM_CONTROLLED=no. Unmanaged: %s.", + NM_IFCFG_CONNECTION_LOG_ARG (connection_new), + nm_ifcfg_connection_get_unmanaged_spec (connection_new)); + } else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new)) + _LOGW ("Ignoring connection "NM_IFCFG_CONNECTION_LOG_FMT" of unrecognized type.", NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); + + /* watch changes of ifcfg hardlinks */ + g_signal_connect (G_OBJECT (connection_new), "ifcfg-changed", + G_CALLBACK (connection_ifcfg_changed), self); + + if (!source) { + /* Only raise the signal if we were called without source, i.e. if we read the connection from file. + * Otherwise, we were called by add_connection() which does not expect the signal. */ + if (nm_ifcfg_connection_get_unmanaged_spec (connection_new)) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); + else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new)) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); + else + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); + } + return connection_new; + } +} + +static void +ifcfg_dir_changed (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type, + gpointer user_data) +{ + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (user_data); + char *path, *ifcfg_path; + NMIfcfgConnection *connection; + + path = g_file_get_path (file); + + ifcfg_path = utils_detect_ifcfg_path (path, FALSE); + _LOGD ("ifcfg_dir_changed(%s) = %d // %s", path, event_type, ifcfg_path ? ifcfg_path : "(none)"); + if (ifcfg_path) { + connection = find_by_path (plugin, ifcfg_path); + switch (event_type) { + case G_FILE_MONITOR_EVENT_DELETED: + if (connection) + remove_connection (plugin, connection); + break; + case G_FILE_MONITOR_EVENT_CREATED: + case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: + /* Update or new */ + update_connection (plugin, NULL, ifcfg_path, connection, TRUE, NULL, NULL); + break; + default: + break; + } + g_free (ifcfg_path); + } + g_free (path); +} + +static void +setup_ifcfg_monitoring (SettingsPluginIfcfg *plugin) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); + GFile *file; + GFileMonitor *monitor; + + file = g_file_new_for_path (IFCFG_DIR "/"); + monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); + g_object_unref (file); + + if (monitor) { + priv->ifcfg_monitor_id = g_signal_connect (monitor, "changed", + G_CALLBACK (ifcfg_dir_changed), plugin); + priv->ifcfg_monitor = monitor; + } +} + +static GHashTable * +_paths_from_connections (GHashTable *connections) +{ + GHashTableIter iter; + NMIfcfgConnection *connection; + GHashTable *paths = g_hash_table_new (g_str_hash, g_str_equal); + + g_hash_table_iter_init (&iter, connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { + const char *path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)); + + if (path) + g_hash_table_add (paths, (void *) path); + } + return paths; +} + +static int +_sort_paths (const char **f1, const char **f2, GHashTable *paths) +{ + struct stat st; + gboolean c1, c2; + gint64 m1, m2; + + c1 = !!g_hash_table_contains (paths, *f1); + c2 = !!g_hash_table_contains (paths, *f2); + if (c1 != c2) + return c1 ? -1 : 1; + + m1 = stat (*f1, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; + m2 = stat (*f2, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; + if (m1 != m2) + return m1 > m2 ? -1 : 1; + + return strcmp (*f1, *f2); +} + +static void +read_connections (SettingsPluginIfcfg *plugin) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); + GDir *dir; + GError *err = NULL; + const char *item; + GHashTable *alive_connections; + GHashTableIter iter; + NMIfcfgConnection *connection; + GPtrArray *dead_connections = NULL; + guint i; + GPtrArray *filenames; + GHashTable *paths; + + dir = g_dir_open (IFCFG_DIR, 0, &err); + if (!dir) { + _LOGW ("Could not read directory '%s': %s", IFCFG_DIR, err->message); + g_error_free (err); + return; + } + + alive_connections = g_hash_table_new (NULL, NULL); + + filenames = g_ptr_array_new_with_free_func (g_free); + while ((item = g_dir_read_name (dir))) { + char *full_path, *real_path; + + full_path = g_build_filename (IFCFG_DIR, item, NULL); + real_path = utils_detect_ifcfg_path (full_path, TRUE); + + if (real_path) + g_ptr_array_add (filenames, real_path); + g_free (full_path); + } + g_dir_close (dir); + + /* While reloading, we don't replace connections that we already loaded while + * iterating over the files. + * + * To have sensible, reproducible behavior, sort the paths by last modification + * time prefering older files. + */ + paths = _paths_from_connections (priv->connections); + g_ptr_array_sort_with_data (filenames, (GCompareDataFunc) _sort_paths, paths); + g_hash_table_destroy (paths); + + for (i = 0; i < filenames->len; i++) { + connection = update_connection (plugin, NULL, filenames->pdata[i], NULL, FALSE, alive_connections, NULL); + if (connection) + g_hash_table_add (alive_connections, connection); + } + g_ptr_array_free (filenames, TRUE); + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { + if ( !g_hash_table_contains (alive_connections, connection) + && nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection))) { + if (!dead_connections) + dead_connections = g_ptr_array_new (); + g_ptr_array_add (dead_connections, connection); + } + } + g_hash_table_destroy (alive_connections); + + if (dead_connections) { + for (i = 0; i < dead_connections->len; i++) + remove_connection (plugin, dead_connections->pdata[i]); + g_ptr_array_free (dead_connections, TRUE); + } +} + +static GSList * +get_connections (NMSettingsPlugin *config) +{ + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); + GSList *list = NULL; + GHashTableIter iter; + NMIfcfgConnection *connection; + + if (!priv->initialized) { + if (nm_config_get_monitor_connection_files (nm_config_get ())) + setup_ifcfg_monitoring (plugin); + read_connections (plugin); + priv->initialized = TRUE; + } + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) { + if ( !nm_ifcfg_connection_get_unmanaged_spec (connection) + && !nm_ifcfg_connection_get_unrecognized_spec (connection)) + list = g_slist_prepend (list, connection); + } + + return list; +} + +static gboolean +load_connection (NMSettingsPlugin *config, + const char *filename) +{ + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); + NMIfcfgConnection *connection; + int dir_len = strlen (IFCFG_DIR); + char *ifcfg_path; + + if ( strncmp (filename, IFCFG_DIR, dir_len) != 0 + || filename[dir_len] != '/' + || strchr (filename + dir_len + 1, '/') != NULL) + return FALSE; + + /* get the real ifcfg-path. This allows us to properly + * handle load command using a route-* file etc. */ + ifcfg_path = utils_detect_ifcfg_path (filename, FALSE); + if (!ifcfg_path) + return FALSE; + + connection = find_by_path (plugin, ifcfg_path); + update_connection (plugin, NULL, ifcfg_path, connection, TRUE, NULL, NULL); + if (!connection) + connection = find_by_path (plugin, ifcfg_path); + + g_free (ifcfg_path); + return (connection != NULL); +} + +static void +reload_connections (NMSettingsPlugin *config) +{ + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); + + read_connections (plugin); +} + +static GSList * +get_unhandled_specs (NMSettingsPlugin *config, + const char *property) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) config); + GSList *list = NULL, *list_iter; + GHashTableIter iter; + gpointer connection; + char *spec; + gboolean found; + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, &connection)) { + g_object_get (connection, property, &spec, NULL); + if (spec) { + /* Ignore duplicates */ + for (list_iter = list, found = FALSE; list_iter; list_iter = g_slist_next (list_iter)) { + if (g_str_equal (list_iter->data, spec)) { + found = TRUE; + break; + } + } + if (found) + g_free (spec); + else + list = g_slist_prepend (list, spec); + } + } + return list; +} + +static GSList * +get_unmanaged_specs (NMSettingsPlugin *config) +{ + return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNMANAGED_SPEC); +} + +static GSList * +get_unrecognized_specs (NMSettingsPlugin *config) +{ + return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC); +} + +static NMSettingsConnection * +add_connection (NMSettingsPlugin *config, + NMConnection *connection, + gboolean save_to_disk, + GError **error) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (config); + gs_free char *path = NULL; + + /* Ensure we reject attempts to add the connection long before we're + * asked to write it to disk. + */ + if (!writer_can_write_connection (connection, error)) + return NULL; + + if (save_to_disk) { + if (!writer_new_connection (connection, IFCFG_DIR, &path, error)) + return NULL; + } + return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); +} + +static void +impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin, + GDBusMethodInvocation *context, + const char *in_ifcfg) +{ + NMIfcfgConnection *connection; + NMSettingConnection *s_con; + const char *uuid; + const char *path; + gs_free char *ifcfg_path = NULL; + + if (!g_path_is_absolute (in_ifcfg)) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "ifcfg path '%s' is not absolute", in_ifcfg); + return; + } + + ifcfg_path = utils_detect_ifcfg_path (in_ifcfg, TRUE); + if (!ifcfg_path) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "ifcfg path '%s' is not an ifcfg base file", in_ifcfg); + return; + } + + connection = find_by_path (plugin, ifcfg_path); + if ( !connection + || nm_ifcfg_connection_get_unmanaged_spec (connection) + || nm_ifcfg_connection_get_unrecognized_spec (connection)) { + 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_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_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_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_FAILED, + "unable to get the connection D-Bus path"); + return; + } + + g_dbus_method_invocation_return_value (context, + g_variant_new ("(so)", uuid, path)); +} + +/*****************************************************************************/ + +static void +_dbus_clear (SettingsPluginIfcfg *self) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + + nm_clear_g_signal_handler (priv->dbus.connection, &priv->dbus.signal_id); + + nm_clear_g_cancellable (&priv->dbus.cancellable); + + if (priv->dbus.interface) { + g_dbus_interface_skeleton_unexport (priv->dbus.interface); + nm_exported_object_skeleton_release (priv->dbus.interface); + priv->dbus.interface = NULL; + } + + g_clear_object (&priv->dbus.connection); +} + +static void +_dbus_connection_closed (GDBusConnection *connection, + gboolean remote_peer_vanished, + GError *error, + gpointer user_data) +{ + _LOGW ("dbus: %s bus closed", IFCFGRH1_DBUS_SERVICE_NAME); + _dbus_clear (SETTINGS_PLUGIN_IFCFG (user_data)); + + /* Retry or recover? */ +} + +static void +_dbus_request_name_done (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GDBusConnection *connection = G_DBUS_CONNECTION (source_object); + SettingsPluginIfcfg *self; + SettingsPluginIfcfgPrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; + guint32 result; + + ret = g_dbus_connection_call_finish (connection, res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = SETTINGS_PLUGIN_IFCFG (user_data); + priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + + g_clear_object (&priv->dbus.cancellable); + + if (!ret) { + _LOGW ("dbus: couldn't acquire D-Bus service: %s", error->message); + _dbus_clear (self); + return; + } + + g_variant_get (ret, "(u)", &result); + + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + _LOGW ("dbus: couldn't acquire ifcfgrh1 D-Bus service (already taken)"); + _dbus_clear (self); + return; + } + + { + GType skeleton_type = NMDBUS_TYPE_IFCFGRH1_SKELETON; + gs_free char *method_name_get_ifcfg_details = NULL; + NMExportedObjectDBusMethodImpl methods[] = { + { + .method_name = (method_name_get_ifcfg_details = nm_exported_object_skeletonify_method_name ("GetIfcfgDetails")), + .impl = G_CALLBACK (impl_ifcfgrh_get_ifcfg_details), + }, + }; + + priv->dbus.interface = nm_exported_object_skeleton_create (skeleton_type, + g_type_class_peek (SETTINGS_TYPE_PLUGIN_IFCFG), + methods, + G_N_ELEMENTS (methods), + (GObject *) self); + + if (!g_dbus_interface_skeleton_export (priv->dbus.interface, + priv->dbus.connection, + IFCFGRH1_DBUS_OBJECT_PATH, + &error)) { + nm_exported_object_skeleton_release (priv->dbus.interface); + priv->dbus.interface = NULL; + _LOGW ("dbus: failed exporting interface: %s", error->message); + _dbus_clear (self); + return; + } + } + + _LOGD ("dbus: aquired D-Bus service %s and exported %s object", + IFCFGRH1_DBUS_SERVICE_NAME, + IFCFGRH1_DBUS_OBJECT_PATH); +} + +static void +_dbus_create_done (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + SettingsPluginIfcfg *self; + SettingsPluginIfcfgPrivate *priv; + gs_free_error GError *error = NULL; + GDBusConnection *connection; + + connection = g_dbus_connection_new_for_address_finish (res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = SETTINGS_PLUGIN_IFCFG (user_data); + priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + + g_clear_object (&priv->dbus.cancellable); + + if (!connection) { + _LOGW ("dbus: couldn't initialize system bus: %s", error->message); + return; + } + + priv->dbus.connection = connection; + priv->dbus.cancellable = g_cancellable_new (); + + priv->dbus.signal_id = g_signal_connect (priv->dbus.connection, + "closed", + G_CALLBACK (_dbus_connection_closed), + self); + + g_dbus_connection_call (priv->dbus.connection, + 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, + priv->dbus.cancellable, + _dbus_request_name_done, + self); +} + +static void +_dbus_setup (SettingsPluginIfcfg *self) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + gs_free char *address = NULL; + gs_free_error GError *error = NULL; + + g_return_if_fail (!priv->dbus.connection); + + address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, &error); + if (address == NULL) { + _LOGW ("dbus: failed getting address for system bus: %s", error->message); + return; + } + + priv->dbus.cancellable = g_cancellable_new (); + + g_dbus_connection_new_for_address (address, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT + | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, + NULL, + priv->dbus.cancellable, + _dbus_create_done, + self); +} + +static void +config_changed_cb (NMConfig *config, + NMConfigData *config_data, + NMConfigChangeFlags changes, + NMConfigData *old_data, + SettingsPluginIfcfg *self) +{ + /* If the dbus connection for some reason is borked the D-Bus service + * won't be offered. + * + * On SIGHUP and SIGUSR1 try to re-connect to D-Bus. So in the unlikely + * event that the D-Bus conneciton is broken, that allows for recovery + * without need for restarting NetworkManager. */ + if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP + | NM_CONFIG_CHANGE_CAUSE_SIGUSR1)) { + if (!SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self)->dbus.connection) + _dbus_setup (self); + } +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case NM_SETTINGS_PLUGIN_PROP_NAME: + g_value_set_string (value, IFCFG_PLUGIN_NAME); + break; + case NM_SETTINGS_PLUGIN_PROP_INFO: + g_value_set_string (value, IFCFG_PLUGIN_INFO); + break; + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +init (NMSettingsPlugin *config) +{ +} + +static void +settings_plugin_ifcfg_init (SettingsPluginIfcfg *plugin) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) plugin); + + priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); +} + +static void +constructed (GObject *object) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + + G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->constructed (object); + + priv->config = nm_config_get (); + g_object_add_weak_pointer ((GObject *) priv->config, (gpointer *) &priv->config); + g_signal_connect (priv->config, + NM_CONFIG_SIGNAL_CONFIG_CHANGED, + G_CALLBACK (config_changed_cb), + self); + + _dbus_setup (self); +} + +static void +dispose (GObject *object) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + + if (priv->config) { + g_object_remove_weak_pointer ((GObject *) priv->config, (gpointer *) &priv->config); + g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, self); + priv->config = NULL; + } + + _dbus_clear (self); + + if (priv->connections) { + g_hash_table_destroy (priv->connections); + priv->connections = NULL; + } + + if (priv->ifcfg_monitor) { + if (priv->ifcfg_monitor_id) + g_signal_handler_disconnect (priv->ifcfg_monitor, priv->ifcfg_monitor_id); + + g_file_monitor_cancel (priv->ifcfg_monitor); + g_object_unref (priv->ifcfg_monitor); + } + + G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->dispose (object); +} + +static void +settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + + object_class->constructed = constructed; + object_class->dispose = dispose; + object_class->get_property = get_property; + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); +} + +static void +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) +{ + plugin_iface->get_connections = get_connections; + plugin_iface->add_connection = add_connection; + plugin_iface->load_connection = load_connection; + plugin_iface->reload_connections = reload_connections; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; + plugin_iface->get_unrecognized_specs = get_unrecognized_specs; + plugin_iface->init = init; +} + +/*****************************************************************************/ + +G_MODULE_EXPORT GObject * +nm_settings_plugin_factory (void) +{ + return g_object_ref (settings_plugin_ifcfg_get ()); +} diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h new file mode 100644 index 00000000..d815cc51 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * Dan Williams + * Søren Sandmann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2007 - 2008 Red Hat, Inc. + */ + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#define SETTINGS_TYPE_PLUGIN_IFCFG (settings_plugin_ifcfg_get_type ()) +#define SETTINGS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfg)) +#define SETTINGS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgClass)) +#define SETTINGS_IS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFCFG)) +#define SETTINGS_IS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFCFG)) +#define SETTINGS_PLUGIN_IFCFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgClass)) + +typedef struct _SettingsPluginIfcfg SettingsPluginIfcfg; +typedef struct _SettingsPluginIfcfgClass SettingsPluginIfcfgClass; + +GType settings_plugin_ifcfg_get_type (void); + +#endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c new file mode 100644 index 00000000..b64cad35 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -0,0 +1,5361 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2008 - 2015 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifcfg-rh-reader.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-connection.h" +#include "nm-dbus-interface.h" +#include "nm-setting-connection.h" +#include "nm-setting-ip4-config.h" +#include "nm-setting-vlan.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-8021x.h" +#include "nm-setting-bond.h" +#include "nm-setting-team.h" +#include "nm-setting-team-port.h" +#include "nm-setting-bridge.h" +#include "nm-setting-bridge-port.h" +#include "nm-setting-dcb.h" +#include "nm-setting-proxy.h" +#include "nm-setting-generic.h" +#include "nm-core-internal.h" +#include "nm-utils.h" + +#include "platform/nm-platform.h" +#include "NetworkManagerUtils.h" + +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-utils.h" +#include "shvar.h" + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG_PREFIX_NAME "ifcfg-rh" +#define _NMLOG(level, ...) \ + G_STMT_START { \ + nm_log ((level), (_NMLOG_DOMAIN), \ + "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + _NMLOG_PREFIX_NAME": " \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + +#define PARSE_WARNING(...) _LOGW ("%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), " " _NM_UTILS_MACRO_REST(__VA_ARGS__)) + +/*****************************************************************************/ + +static gboolean +get_uint (const char *str, guint32 *value) +{ + gint64 tmp; + + tmp = _nm_utils_ascii_str_to_int64 (str, 0, 0, G_MAXUINT32, -1); + if (tmp == -1) + return FALSE; + *value = tmp; + return TRUE; +} + +static char * +make_connection_name (shvarFile *ifcfg, + const char *ifcfg_name, + const char *suggested, + const char *prefix) +{ + char *full_name = NULL, *name; + + /* If the ifcfg file already has a NAME, always use that */ + name = svGetValueString (ifcfg, "NAME"); + if (name && strlen (name)) + return name; + + /* Otherwise construct a new NAME */ + g_free (name); + if (!prefix) + prefix = _("System"); + + /* For cosmetic reasons, if the suggested name is the same as + * the ifcfg files name, don't use it. Mainly for wifi so that + * the SSID is shown in the connection ID instead of just "wlan0". + */ + if (suggested && strcmp (ifcfg_name, suggested)) + full_name = g_strdup_printf ("%s %s (%s)", prefix, suggested, ifcfg_name); + else + full_name = g_strdup_printf ("%s %s", prefix, ifcfg_name); + + return full_name; +} + +static NMSetting * +make_connection_setting (const char *file, + shvarFile *ifcfg, + const char *type, + const char *suggested, + const char *prefix) +{ + NMSettingConnection *s_con; + NMSettingConnectionLldp lldp; + const char *ifcfg_name = NULL; + char *new_id, *uuid = NULL, *zone = NULL, *value; + gs_free char *stable_id = NULL; + + ifcfg_name = utils_get_ifcfg_name (file, TRUE); + if (!ifcfg_name) + return NULL; + + s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); + + new_id = make_connection_name (ifcfg, ifcfg_name, suggested, prefix); + g_object_set (s_con, NM_SETTING_CONNECTION_ID, new_id, NULL); + g_free (new_id); + + /* Try for a UUID key before falling back to hashing the file name */ + uuid = svGetValueString (ifcfg, "UUID"); + if (!uuid || !strlen (uuid)) { + g_free (uuid); + uuid = nm_utils_uuid_generate_from_string (svFileGetName (ifcfg), -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); + } + + stable_id = svGetValueString (ifcfg, "STABLE_ID"); + + g_object_set (s_con, + NM_SETTING_CONNECTION_TYPE, type, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_STABLE_ID, stable_id, + NULL); + g_free (uuid); + + value = svGetValueString (ifcfg, "DEVICE"); + if (value) { + GError *error = NULL; + + if (nm_utils_is_valid_iface_name (value, &error)) { + g_object_set (s_con, + NM_SETTING_CONNECTION_INTERFACE_NAME, value, + NULL); + } else { + PARSE_WARNING ("invalid DEVICE name '%s': %s", value, error->message); + g_error_free (error); + } + g_free (value); + } + + value = svGetValueString (ifcfg, "LLDP"); + if (!g_strcmp0 (value, "rx")) + lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX; + else + lldp = svParseBoolean (value, NM_SETTING_CONNECTION_LLDP_DEFAULT); + g_free (value); + + /* Missing ONBOOT is treated as "ONBOOT=true" by the old network service */ + g_object_set (s_con, + NM_SETTING_CONNECTION_AUTOCONNECT, + svGetValueBoolean (ifcfg, "ONBOOT", TRUE), + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, + (gint) svGetValueInt64 (ifcfg, "AUTOCONNECT_PRIORITY", 10, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT), + NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, + (gint) svGetValueInt64 (ifcfg, "AUTOCONNECT_RETRIES", 10, + -1, G_MAXINT32, -1), + NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, + svGetValueBoolean (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), + NM_SETTING_CONNECTION_LLDP, lldp, + NULL); + + value = svGetValueString (ifcfg, "USERS"); + if (value) { + char **items, **iter; + + items = g_strsplit_set (value, " ", -1); + for (iter = items; iter && *iter; iter++) { + if (strlen (*iter)) { + if (!nm_setting_connection_add_permission (s_con, "user", *iter, NULL)) + PARSE_WARNING ("invalid USERS item '%s'", *iter); + } + } + g_free (value); + g_strfreev (items); + } + + + zone = svGetValueString (ifcfg, "ZONE"); + if (!zone || !strlen (zone)) { + g_free (zone); + zone = NULL; + } + g_object_set (s_con, NM_SETTING_CONNECTION_ZONE, zone, NULL); + g_free (zone); + + value = svGetValueString (ifcfg, "SECONDARY_UUIDS"); + if (value) { + char **items, **iter; + + items = g_strsplit_set (value, " \t", -1); + for (iter = items; iter && *iter; iter++) { + if (strlen (*iter)) { + if (!nm_setting_connection_add_secondary (s_con, *iter)) + PARSE_WARNING ("secondary connection UUID '%s' already added", *iter); + } + } + g_free (value); + g_strfreev (items); + } + + value = svGetValueString (ifcfg, "BRIDGE_UUID"); + if (!value) + value = svGetValueString (ifcfg, "BRIDGE"); + if (value) { + const char *old_value; + + if ((old_value = nm_setting_connection_get_master (s_con))) { + PARSE_WARNING ("Already configured as slave of %s. Ignoring BRIDGE=\"%s\"", + old_value, value); + } else { + g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); + g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, + NM_SETTING_BRIDGE_SETTING_NAME, NULL); + } + g_free (value); + } + + value = svGetValueString (ifcfg, "GATEWAY_PING_TIMEOUT"); + if (value) { + gint64 tmp; + + tmp = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT32 - 1, -1); + if (tmp >= 0) + g_object_set (s_con, NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, (guint) tmp, NULL); + else + PARSE_WARNING ("invalid GATEWAY_PING_TIMEOUT time"); + g_free (value); + } + + switch (svGetValueBoolean (ifcfg, "CONNECTION_METERED", -1)) { + case TRUE: + g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_YES, NULL); + break; + case FALSE: + g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_NO, NULL); + break; + } + + return NM_SETTING (s_con); +} + +/* Returns TRUE on missing address or valid address */ +static gboolean +read_ip4_address (shvarFile *ifcfg, + const char *tag, + char **out_addr, + GError **error) +{ + char *value = NULL; + + g_return_val_if_fail (ifcfg != NULL, FALSE); + g_return_val_if_fail (tag != NULL, FALSE); + g_return_val_if_fail (out_addr != NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + *out_addr = NULL; + + value = svGetValueString (ifcfg, tag); + if (!value) + return TRUE; + + if (nm_utils_ipaddr_valid (AF_INET, value)) { + *out_addr = value; + return TRUE; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid %s IP4 address '%s'", tag, value); + g_free (value); + return FALSE; + } +} + +static char * +get_numbered_tag (char *tag_name, int which) +{ + if (which == -1) + return g_strdup (tag_name); + return g_strdup_printf ("%s%u", tag_name, which); +} + +static gboolean +is_any_ip4_address_defined (shvarFile *ifcfg, int *idx) +{ + int i, ignore, *ret_idx;; + + ret_idx = idx ? idx : &ignore; + + for (i = -1; i <= 2; i++) { + char *tag; + char *value; + + tag = get_numbered_tag ("IPADDR", i); + value = svGetValueString (ifcfg, tag); + g_free (tag); + if (value) { + g_free (value); + *ret_idx = i; + return TRUE; + } + + tag = get_numbered_tag ("PREFIX", i); + value = svGetValueString (ifcfg, tag); + g_free(tag); + if (value) { + g_free (value); + *ret_idx = i; + return TRUE; + } + + tag = get_numbered_tag ("NETMASK", i); + value = svGetValueString (ifcfg, tag); + g_free(tag); + if (value) { + g_free (value); + *ret_idx = i; + return TRUE; + } + } + return FALSE; +} + +/* Returns TRUE on missing address or valid address */ +static gboolean +read_full_ip4_address (shvarFile *ifcfg, + gint32 which, + NMIPAddress *base_addr, + NMIPAddress **out_address, + char **out_gateway, + GError **error) +{ + char *ip_tag, *prefix_tag, *netmask_tag, *gw_tag; + char *ip = NULL; + int prefix = 0; + gboolean success = FALSE; + char *value; + guint32 tmp; + + g_return_val_if_fail (which >= -1, FALSE); + g_return_val_if_fail (ifcfg != NULL, FALSE); + g_return_val_if_fail (out_address != NULL, FALSE); + g_return_val_if_fail (*out_address == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + ip_tag = get_numbered_tag ("IPADDR", which); + prefix_tag = get_numbered_tag ("PREFIX", which); + netmask_tag = get_numbered_tag ("NETMASK", which); + gw_tag = get_numbered_tag ("GATEWAY", which); + + /* IP address */ + if (!read_ip4_address (ifcfg, ip_tag, &ip, error)) + goto done; + if (!ip) { + if (base_addr) + ip = g_strdup (nm_ip_address_get_address (base_addr)); + else { + success = TRUE; + goto done; + } + } + + /* Gateway */ + if (out_gateway && !*out_gateway) { + if (!read_ip4_address (ifcfg, gw_tag, out_gateway, error)) + goto done; + } + + /* Prefix */ + value = svGetValueString (ifcfg, prefix_tag); + if (value) { + prefix = _nm_utils_ascii_str_to_int64 (value, 10, 0, 32, -1); + if (prefix < 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 prefix '%s'", value); + g_free (value); + goto done; + } + g_free (value); + } else { + /* Fall back to NETMASK if no PREFIX was specified */ + if (!read_ip4_address (ifcfg, netmask_tag, &value, error)) + goto done; + if (value) { + inet_pton (AF_INET, value, &tmp); + prefix = nm_utils_ip4_netmask_to_prefix (tmp); + g_free (value); + } else { + if (base_addr) + prefix = nm_ip_address_get_prefix (base_addr); + else { + /* Try to autodetermine the prefix for the address' class */ + if (inet_pton (AF_INET, ip, &tmp) == 1) { + prefix = nm_utils_ip4_get_default_prefix (tmp); + + PARSE_WARNING ("missing %s, assuming %s/%d", prefix_tag, ip, prefix); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP4 prefix"); + goto done; + } + } + } + } + + *out_address = nm_ip_address_new (AF_INET, ip, prefix, error); + if (*out_address) + success = TRUE; + +done: + g_free (ip); + g_free (ip_tag); + g_free (prefix_tag); + g_free (netmask_tag); + g_free (gw_tag); + + return success; +} + +/* Returns TRUE on missing route or valid route */ +static gboolean +read_one_ip4_route (shvarFile *ifcfg, + guint32 which, + NMIPRoute **out_route, + GError **error) +{ + char *ip_tag, *netmask_tag, *gw_tag, *metric_tag, *value; + char *dest = NULL, *next_hop = NULL; + gint64 prefix, metric; + gboolean success = FALSE; + + g_return_val_if_fail (ifcfg != NULL, FALSE); + g_return_val_if_fail (out_route != NULL, FALSE); + g_return_val_if_fail (*out_route == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + ip_tag = g_strdup_printf ("ADDRESS%u", which); + netmask_tag = g_strdup_printf ("NETMASK%u", which); + gw_tag = g_strdup_printf ("GATEWAY%u", which); + metric_tag = g_strdup_printf ("METRIC%u", which); + + /* Destination */ + if (!read_ip4_address (ifcfg, ip_tag, &dest, error)) + goto out; + if (!dest) { + /* Check whether IP is missing or 0.0.0.0 */ + char *val; + val = svGetValueString (ifcfg, ip_tag); + if (!val) { + *out_route = NULL; + success = TRUE; /* missing route = success */ + goto out; + } + g_free (val); + } + + /* Next hop */ + if (!read_ip4_address (ifcfg, gw_tag, &next_hop, error)) + goto out; + /* We don't make distinction between missing GATEWAY IP and 0.0.0.0 */ + + /* Prefix */ + if (!read_ip4_address (ifcfg, netmask_tag, &value, error)) + goto out; + if (value) { + guint32 netmask; + + inet_pton (AF_INET, value, &netmask); + prefix = nm_utils_ip4_netmask_to_prefix (netmask); + g_free (value); + if (prefix == 0 || netmask != nm_utils_ip4_prefix_to_netmask (prefix)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 netmask '%s' \"%s\"", netmask_tag, nm_utils_inet4_ntop (netmask, NULL)); + goto out; + } + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP4 route element '%s'", netmask_tag); + goto out; + } + + /* Metric */ + value = svGetValueString (ifcfg, metric_tag); + if (value) { + metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1); + if (metric < 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route metric '%s'", value); + g_free (value); + goto out; + } + g_free (value); + } else + metric = -1; + + *out_route = nm_ip_route_new (AF_INET, dest, prefix, next_hop, metric, error); + if (*out_route) + success = TRUE; + +out: + g_free (dest); + g_free (next_hop); + g_free (ip_tag); + g_free (netmask_tag); + g_free (gw_tag); + g_free (metric_tag); + return success; +} + +static gboolean +read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError **error) +{ + char *contents = NULL; + gsize len = 0; + char **lines = NULL, **iter; + GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric; + GMatchInfo *match_info; + int prefix_int; + gint64 metric_int; + gboolean success = FALSE; + + const char *pattern_empty = "^\\s*(\\#.*)?$"; + const char *pattern_to1 = "^\\s*(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|default)" /* IP or 'default' keyword */ + "(?:/(\\d{1,2}))?"; /* optional prefix */ + const char *pattern_to2 = "to\\s+(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|default)" /* IP or 'default' keyword */ + "(?:/(\\d{1,2}))?"; /* optional prefix */ + const char *pattern_via = "via\\s+(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})"; /* IP of gateway */ + const char *pattern_metric = "metric\\s+(\\d+)"; /* metric */ + + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (s_ip4 != NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + /* Read the route file */ + if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { + g_free (contents); + return TRUE; /* missing/empty = success */ + } + + /* Create regexes for pieces to be matched */ + regex_to1 = g_regex_new (pattern_to1, 0, 0, NULL); + regex_to2 = g_regex_new (pattern_to2, 0, 0, NULL); + regex_via = g_regex_new (pattern_via, 0, 0, NULL); + regex_metric = g_regex_new (pattern_metric, 0, 0, NULL); + + /* Iterate through file lines */ + lines = g_strsplit_set (contents, "\n\r", -1); + for (iter = lines; iter && *iter; iter++) { + gs_free char *next_hop = NULL, *dest = NULL; + char *prefix, *metric; + NMIPRoute *route; + + /* Skip empty lines */ + if (g_regex_match_simple (pattern_empty, *iter, 0, 0)) + continue; + + /* Destination */ + g_regex_match (regex_to1, *iter, 0, &match_info); + if (!g_match_info_matches (match_info)) { + g_match_info_free (match_info); + g_regex_match (regex_to2, *iter, 0, &match_info); + if (!g_match_info_matches (match_info)) { + g_match_info_free (match_info); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP4 route destination address in record: '%s'", *iter); + goto error; + } + } + dest = g_match_info_fetch (match_info, 1); + if (!strcmp (dest, "default")) { + g_match_info_free (match_info); + PARSE_WARNING ("ignoring manual default route: '%s' (%s)", *iter, filename); + continue; + } + if (!nm_utils_ipaddr_valid (AF_INET, dest)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route destination address '%s'", dest); + g_match_info_free (match_info); + goto error; + } + + /* Prefix - is optional; 32 if missing */ + prefix = g_match_info_fetch (match_info, 2); + g_match_info_free (match_info); + prefix_int = 32; + if (prefix) { + prefix_int = _nm_utils_ascii_str_to_int64 (prefix, 10, 1, 32, -1); + if (prefix_int == -1) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route destination prefix '%s'", prefix); + g_free (prefix); + goto error; + } + } + g_free (prefix); + + /* Next hop */ + g_regex_match (regex_via, *iter, 0, &match_info); + if (g_match_info_matches (match_info)) { + next_hop = g_match_info_fetch (match_info, 1); + if (!nm_utils_ipaddr_valid (AF_INET, next_hop)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route gateway address '%s'", + next_hop); + g_match_info_free (match_info); + goto error; + } + } else { + /* we don't make distinction between missing GATEWAY IP and 0.0.0.0 */ + } + g_match_info_free (match_info); + + /* Metric */ + g_regex_match (regex_metric, *iter, 0, &match_info); + metric_int = -1; + if (g_match_info_matches (match_info)) { + metric = g_match_info_fetch (match_info, 1); + metric_int = _nm_utils_ascii_str_to_int64 (metric, 10, 0, G_MAXUINT32, -1); + if (metric_int == -1) { + g_match_info_free (match_info); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route metric '%s'", metric); + g_free (metric); + goto error; + } + g_free (metric); + } + g_match_info_free (match_info); + + route = nm_ip_route_new (AF_INET, dest, prefix_int, next_hop, metric_int, error); + if (!route) + goto error; + if (!nm_setting_ip_config_add_route (s_ip4, route)) + PARSE_WARNING ("duplicate IP4 route"); + nm_ip_route_unref (route); + } + + success = TRUE; + +error: + g_free (contents); + g_strfreev (lines); + g_regex_unref (regex_to1); + g_regex_unref (regex_to2); + g_regex_unref (regex_via); + g_regex_unref (regex_metric); + + return success; +} + +static void +parse_dns_options (NMSettingIPConfig *ip_config, const char *value) +{ + char **options = NULL; + + g_return_if_fail (ip_config); + + if (!value) + return; + + if (!nm_setting_ip_config_has_dns_options (ip_config)) + nm_setting_ip_config_clear_dns_options (ip_config, TRUE); + + options = g_strsplit (value, " ", 0); + if (options) { + char **item; + for (item = options; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_option (ip_config, *item)) + PARSE_WARNING ("can't add DNS option '%s'", *item); + } + } + g_strfreev (options); + } +} + +static gboolean +parse_full_ip6_address (shvarFile *ifcfg, + const char *addr_str, + int i, + NMIPAddress **out_address, + GError **error) +{ + char **list; + char *ip_val, *prefix_val; + int prefix; + gboolean success = FALSE; + + g_return_val_if_fail (addr_str != NULL, FALSE); + g_return_val_if_fail (out_address != NULL, FALSE); + g_return_val_if_fail (*out_address == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + /* Split the address and prefix */ + list = g_strsplit_set (addr_str, "/", 2); + if (g_strv_length (list) < 1) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 address '%s'", addr_str); + goto error; + } + + ip_val = list[0]; + + prefix_val = list[1]; + if (prefix_val) { + prefix = _nm_utils_ascii_str_to_int64 (prefix_val, 10, 0, 128, -1); + if (prefix < 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 prefix '%s'", prefix_val); + goto error; + } + } else { + /* Missing prefix is treated as prefix of 64 */ + prefix = 64; + } + + *out_address = nm_ip_address_new (AF_INET6, ip_val, prefix, error); + if (*out_address) + success = TRUE; + +error: + g_strfreev (list); + return success; +} + +/* IPv6 address is very complex to describe completely by a regular expression, + * so don't try to, rather use looser syntax to comprise all possibilities + * NOTE: The regexes below don't describe all variants allowed by 'ip route add', + * namely destination IP without 'to' keyword is recognized just at line start. + */ +#define IPV6_ADDR_REGEX "[0-9A-Fa-f:.]+" + +static gboolean +read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error) +{ + char *contents = NULL; + gsize len = 0; + char **lines = NULL, **iter; + GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric; + GMatchInfo *match_info; + char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL; + int prefix_int; + gint64 metric_int; + gboolean success = FALSE; + + const char *pattern_empty = "^\\s*(\\#.*)?$"; + const char *pattern_to1 = "^\\s*(default|" IPV6_ADDR_REGEX ")" /* IPv6 or 'default' keyword */ + "(?:/(\\d{1,3}))?"; /* optional prefix */ + const char *pattern_to2 = "to\\s+(default|" IPV6_ADDR_REGEX ")" /* IPv6 or 'default' keyword */ + "(?:/(\\d{1,3}))?"; /* optional prefix */ + const char *pattern_via = "via\\s+(" IPV6_ADDR_REGEX ")"; /* IPv6 of gateway */ + const char *pattern_metric = "metric\\s+(\\d+)"; /* metric */ + + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (s_ip6 != NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + /* Read the route file */ + if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { + g_free (contents); + return TRUE; /* missing/empty = success */ + } + + /* Create regexes for pieces to be matched */ + regex_to1 = g_regex_new (pattern_to1, 0, 0, NULL); + regex_to2 = g_regex_new (pattern_to2, 0, 0, NULL); + regex_via = g_regex_new (pattern_via, 0, 0, NULL); + regex_metric = g_regex_new (pattern_metric, 0, 0, NULL); + + /* Iterate through file lines */ + lines = g_strsplit_set (contents, "\n\r", -1); + for (iter = lines; iter && *iter; iter++) { + NMIPRoute *route; + + /* Skip empty lines */ + if (g_regex_match_simple (pattern_empty, *iter, 0, 0)) + continue; + + /* Destination */ + g_regex_match (regex_to1, *iter, 0, &match_info); + if (!g_match_info_matches (match_info)) { + g_match_info_free (match_info); + g_regex_match (regex_to2, *iter, 0, &match_info); + if (!g_match_info_matches (match_info)) { + g_match_info_free (match_info); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP6 route destination address in record: '%s'", *iter); + goto error; + } + } + dest = g_match_info_fetch (match_info, 1); + if (!g_strcmp0 (dest, "default")) { + /* Ignore default route - NM handles it internally */ + g_clear_pointer (&dest, g_free); + g_match_info_free (match_info); + PARSE_WARNING ("ignoring manual default route: '%s' (%s)", *iter, filename); + continue; + } + + /* Prefix - is optional; 128 if missing */ + prefix = g_match_info_fetch (match_info, 2); + g_match_info_free (match_info); + prefix_int = 128; + if (prefix) { + prefix_int = _nm_utils_ascii_str_to_int64 (prefix, 10, 1, 128, -1); + if (prefix_int == -1) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 route destination prefix '%s'", prefix); + g_free (dest); + g_free (prefix); + goto error; + } + } + g_free (prefix); + + /* Next hop */ + g_regex_match (regex_via, *iter, 0, &match_info); + if (g_match_info_matches (match_info)) { + next_hop = g_match_info_fetch (match_info, 1); + if (!nm_utils_ipaddr_valid (AF_INET6, next_hop)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IPv6 route nexthop address '%s'", + next_hop); + g_match_info_free (match_info); + g_free (dest); + g_free (next_hop); + goto error; + } + } else { + /* Missing "via" is taken as :: */ + next_hop = NULL; + } + g_match_info_free (match_info); + + /* Metric */ + g_regex_match (regex_metric, *iter, 0, &match_info); + metric_int = -1; + if (g_match_info_matches (match_info)) { + metric = g_match_info_fetch (match_info, 1); + metric_int = _nm_utils_ascii_str_to_int64 (metric, 10, 0, G_MAXUINT32, -1); + if (metric_int == -1) { + g_match_info_free (match_info); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 route metric '%s'", metric); + g_free (dest); + g_free (next_hop); + g_free (metric); + goto error; + } + g_free (metric); + } + g_match_info_free (match_info); + + route = nm_ip_route_new (AF_INET6, dest, prefix_int, next_hop, metric_int, error); + g_free (dest); + g_free (next_hop); + if (!route) + goto error; + if (!nm_setting_ip_config_add_route (s_ip6, route)) + PARSE_WARNING ("duplicate IP6 route"); + nm_ip_route_unref (route); + } + + success = TRUE; + +error: + g_free (contents); + g_strfreev (lines); + g_regex_unref (regex_to1); + g_regex_unref (regex_to2); + g_regex_unref (regex_via); + g_regex_unref (regex_metric); + + return success; +} + +static NMSetting * +make_proxy_setting (shvarFile *ifcfg, GError **error) +{ + NMSettingProxy *s_proxy = NULL; + char *value = NULL; + NMSettingProxyMethod method; + + value = svGetValueString (ifcfg, "PROXY_METHOD"); + if (!value) + return NULL; + + if (!g_ascii_strcasecmp (value, "auto")) + method = NM_SETTING_PROXY_METHOD_AUTO; + else + method = NM_SETTING_PROXY_METHOD_NONE; + g_free (value); + + s_proxy = (NMSettingProxy *) nm_setting_proxy_new (); + + switch (method) { + case NM_SETTING_PROXY_METHOD_AUTO: + g_object_set (s_proxy, + NM_SETTING_PROXY_METHOD, (int) NM_SETTING_PROXY_METHOD_AUTO, + NULL); + + value = svGetValueString (ifcfg, "PAC_URL"); + if (value) { + value = g_strstrip (value); + g_object_set (s_proxy, NM_SETTING_PROXY_PAC_URL, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "PAC_SCRIPT"); + if (value) { + value = g_strstrip (value); + g_object_set (s_proxy, NM_SETTING_PROXY_PAC_SCRIPT, value, NULL); + g_free (value); + } + + break; + case NM_SETTING_PROXY_METHOD_NONE: + g_object_set (s_proxy, + NM_SETTING_PROXY_METHOD, (int) NM_SETTING_PROXY_METHOD_NONE, + NULL); + break; + } + + value = svGetValueString (ifcfg, "BROWSER_ONLY"); + if (value) { + if (!g_ascii_strcasecmp (value, "yes")) + g_object_set (s_proxy, NM_SETTING_PROXY_BROWSER_ONLY, TRUE, NULL); + g_free (value); + } + + return NM_SETTING (s_proxy); +} + +static NMSetting * +make_ip4_setting (shvarFile *ifcfg, + const char *network_file, + GError **error) +{ + NMSettingIPConfig *s_ip4 = NULL; + char *value = NULL; + char *route_path = NULL; + char *method; + gs_free char *dns_options_free = NULL; + const char *dns_options = NULL; + gs_free char *gateway = NULL; + gint32 i; + shvarFile *network_ifcfg; + shvarFile *route_ifcfg; + gboolean never_default = FALSE; + gint64 timeout; + gint priority; + + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + + /* First check if DEFROUTE is set for this device; DEFROUTE has the + * opposite meaning from never-default. The default if DEFROUTE is not + * specified is DEFROUTE=yes which means that this connection can be used + * as a default route + */ + never_default = !svGetValueBoolean (ifcfg, "DEFROUTE", TRUE); + + /* Then check if GATEWAYDEV; it's global and overrides DEFROUTE */ + network_ifcfg = svOpenFile (network_file, NULL); + if (network_ifcfg) { + char *gatewaydev; + + /* Get the connection ifcfg device name and the global gateway device */ + value = svGetValueString (ifcfg, "DEVICE"); + gatewaydev = svGetValueString (network_ifcfg, "GATEWAYDEV"); + dns_options = svGetValue (network_ifcfg, "RES_OPTIONS", &dns_options_free); + + /* If there was a global gateway device specified, then only connections + * for that device can be the default connection. + */ + if (gatewaydev && value) + never_default = !!strcmp (value, gatewaydev); + + g_free (gatewaydev); + g_free (value); + svCloseFile (network_ifcfg); + } + + value = svGetValueString (ifcfg, "BOOTPROTO"); + + if (!value || !*value || !g_ascii_strcasecmp (value, "none")) { + if (is_any_ip4_address_defined (ifcfg, NULL)) + method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; + else + method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + } else if (!g_ascii_strcasecmp (value, "bootp") || !g_ascii_strcasecmp (value, "dhcp")) { + method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; + } else if (!g_ascii_strcasecmp (value, "static")) { + if (is_any_ip4_address_defined (ifcfg, NULL)) + method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; + else + method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + } else if (!g_ascii_strcasecmp (value, "autoip")) { + method = NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL; + } else if (!g_ascii_strcasecmp (value, "shared")) { + int idx; + + g_free (value); + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, + NULL); + /* 1 IP address is allowed for shared connections. Read it. */ + if (is_any_ip4_address_defined (ifcfg, &idx)) { + NMIPAddress *addr = NULL; + + if (!read_full_ip4_address (ifcfg, idx, NULL, &addr, NULL, error)) + goto done; + if (!read_ip4_address (ifcfg, "GATEWAY", &gateway, error)) + goto done; + (void) nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); + if (never_default) + PARSE_WARNING ("GATEWAY will be ignored when DEFROUTE is disabled"); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL); + } + return NM_SETTING (s_ip4); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown BOOTPROTO '%s'", value); + g_free (value); + goto done; + } + g_free (value); + + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_METHOD, method, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svGetValueBoolean (ifcfg, "PEERDNS", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svGetValueBoolean (ifcfg, "PEERROUTES", TRUE), + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, + NM_SETTING_IP_CONFIG_MAY_FAIL, !svGetValueBoolean (ifcfg, "IPV4_FAILURE_FATAL", FALSE), + NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV4_ROUTE_METRIC", 10, + -1, G_MAXUINT32, -1), + NULL); + + if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) + return NM_SETTING (s_ip4); + + /* Handle DHCP settings */ + value = svGetValueString (ifcfg, "DHCP_HOSTNAME"); + if (value && *value) + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); + g_free (value); + + value = svGetValueString (ifcfg, "DHCP_FQDN"); + if (value && *value) { + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NULL, + NM_SETTING_IP4_CONFIG_DHCP_FQDN, value, + NULL); + } + g_free (value); + + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), + NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXINT32, 0), + NULL); + + value = svGetValueString (ifcfg, "DHCP_CLIENT_ID"); + if (value && strlen (value)) + g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, value, NULL); + g_free (value); + + /* Read static IP addresses. + * Read them even for AUTO method - in this case the addresses are + * added to the automatic ones. Note that this is not currently supported by + * the legacy 'network' service (ifup-eth). + */ + for (i = -1; i < 256; i++) { + NMIPAddress *addr = NULL; + + /* gateway will only be set if still unset. Hence, we don't leak gateway + * here by calling read_full_ip4_address() repeatedly */ + if (!read_full_ip4_address (ifcfg, i, NULL, &addr, &gateway, error)) + goto done; + + if (!addr) { + /* The first mandatory variable is 2-indexed (IPADDR2) + * Variables IPADDR, IPADDR0 and IPADDR1 are optional */ + if (i > 1) + break; + continue; + } + + if (!nm_setting_ip_config_add_address (s_ip4, addr)) + PARSE_WARNING ("duplicate IP4 address"); + nm_ip_address_unref (addr); + } + + /* Gateway */ + if (!gateway) { + network_ifcfg = svOpenFile (network_file, NULL); + if (network_ifcfg) { + gboolean read_success; + + read_success = read_ip4_address (network_ifcfg, "GATEWAY", &gateway, error); + svCloseFile (network_ifcfg); + if (!read_success) + goto done; + + if (gateway && nm_setting_ip_config_get_num_addresses (s_ip4) == 0) { + gs_free char *f = g_path_get_basename (svFileGetName (ifcfg)); + PARSE_WARNING ("ignoring GATEWAY (/etc/sysconfig/network) for %s " + "because the connection has no static addresses", f); + g_clear_pointer (&gateway, g_free); + } + } + } + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL); + + if (gateway && never_default) + PARSE_WARNING ("GATEWAY will be ignored when DEFROUTE is disabled"); + + /* DNS servers + * Pick up just IPv4 addresses (IPv6 addresses are taken by make_ip6_setting()) + */ + for (i = 1; i <= 10; i++) { + char *tag; + + tag = g_strdup_printf ("DNS%u", i); + value = svGetValueString (ifcfg, tag); + if (value) { + if (nm_utils_ipaddr_valid (AF_INET, value)) { + if (!nm_setting_ip_config_add_dns (s_ip4, value)) + PARSE_WARNING ("duplicate DNS server %s", tag); + } else if (nm_utils_ipaddr_valid (AF_INET6, value)) { + /* Ignore IPv6 addresses */ + } else { + PARSE_WARNING ("invalid DNS server address %s", value); + g_free (tag); + g_free (value); + goto done; + } + + g_free (value); + } + + g_free (tag); + } + + /* DNS searches */ + value = svGetValueString (ifcfg, "DOMAIN"); + if (value) { + char **searches = NULL; + + searches = g_strsplit (value, " ", 0); + if (searches) { + char **item; + for (item = searches; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_search (s_ip4, *item)) + PARSE_WARNING ("duplicate DNS domain '%s'", *item); + } + } + g_strfreev (searches); + } + g_free (value); + } + + /* DNS options */ + parse_dns_options (s_ip4, svGetValue (ifcfg, "RES_OPTIONS", &value)); + parse_dns_options (s_ip4, dns_options); + g_free (value); + + /* DNS priority */ + priority = svGetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0); + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_DNS_PRIORITY, + priority, + NULL); + + /* Static routes - route- file */ + route_path = utils_get_route_path (svFileGetName (ifcfg)); + + if (utils_has_complex_routes (route_path)) { + PARSE_WARNING ("'rule-' or 'rule6-' file is present; you will need to use a dispatcher script to apply these routes"); + } else if (utils_has_route_file_new_syntax (route_path)) { + /* Parse route file in new syntax */ + route_ifcfg = utils_get_route_ifcfg (svFileGetName (ifcfg), FALSE); + if (route_ifcfg) { + for (i = 0; i < 256; i++) { + NMIPRoute *route = NULL; + + if (!read_one_ip4_route (route_ifcfg, i, &route, error)) { + svCloseFile (route_ifcfg); + goto done; + } + + if (!route) + break; + + if (!nm_setting_ip_config_add_route (s_ip4, route)) + PARSE_WARNING ("duplicate IP4 route"); + nm_ip_route_unref (route); + } + svCloseFile (route_ifcfg); + } + } else { + if (!read_route_file_legacy (route_path, s_ip4, error)) + goto done; + } + g_free (route_path); + + /* Legacy value NM used for a while but is incorrect (rh #459370) */ + if (!nm_setting_ip_config_get_num_dns_searches (s_ip4)) { + value = svGetValueString (ifcfg, "SEARCH"); + if (value) { + char **searches = NULL; + + searches = g_strsplit (value, " ", 0); + if (searches) { + char **item; + for (item = searches; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_search (s_ip4, *item)) + PARSE_WARNING ("duplicate DNS search '%s'", *item); + } + } + g_strfreev (searches); + } + g_free (value); + } + } + + timeout = svGetValueInt64 (ifcfg, "ARPING_WAIT", 10, -1, + NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX / 1000, -1); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DAD_TIMEOUT, + (gint) (timeout <= 0 ? timeout : timeout * 1000), NULL); + + return NM_SETTING (s_ip4); + +done: + g_free (route_path); + g_object_unref (s_ip4); + return NULL; +} + +static void +read_aliases (NMSettingIPConfig *s_ip4, const char *filename) +{ + GDir *dir; + char *dirname, *base; + shvarFile *parsed; + NMIPAddress *base_addr = NULL; + GError *err = NULL; + + g_return_if_fail (s_ip4 != NULL); + g_return_if_fail (filename != NULL); + + if (nm_setting_ip_config_get_num_addresses (s_ip4) > 0) + base_addr = nm_setting_ip_config_get_address (s_ip4, 0); + + dirname = g_path_get_dirname (filename); + g_return_if_fail (dirname != NULL); + base = g_path_get_basename (filename); + g_return_if_fail (base != NULL); + + dir = g_dir_open (dirname, 0, &err); + if (dir) { + const char *item; + NMIPAddress *addr; + gboolean ok; + + while ((item = g_dir_read_name (dir))) { + char *full_path, *device; + const char *p; + + if (!utils_is_ifcfg_alias_file (item, base)) + continue; + + full_path = g_build_filename (dirname, item, NULL); + + p = strchr (item, ':'); + g_assert (p != NULL); /* we know this is true from utils_is_ifcfg_alias_file() */ + for (p++; *p; p++) { + if (!g_ascii_isalnum (*p) && *p != '_') + break; + } + if (*p) { + PARSE_WARNING ("ignoring alias file '%s' with invalid name", full_path); + g_free (full_path); + continue; + } + + parsed = svOpenFile (full_path, &err); + if (!parsed) { + PARSE_WARNING ("couldn't parse alias file '%s': %s", full_path, err->message); + g_free (full_path); + g_clear_error (&err); + continue; + } + + device = svGetValueString (parsed, "DEVICE"); + if (!device) { + PARSE_WARNING ("alias file '%s' has no DEVICE", full_path); + svCloseFile (parsed); + g_free (full_path); + continue; + } + /* We know that item starts with IFCFG_TAG from utils_is_ifcfg_alias_file() */ + if (strcmp (device, item + strlen (IFCFG_TAG)) != 0) { + PARSE_WARNING ("alias file '%s' has invalid DEVICE (%s) for filename", + full_path, device); + g_free (device); + svCloseFile (parsed); + g_free (full_path); + continue; + } + + addr = NULL; + ok = read_full_ip4_address (parsed, -1, base_addr, &addr, NULL, &err); + svCloseFile (parsed); + if (ok) { + nm_ip_address_set_attribute (addr, "label", g_variant_new_string (device)); + if (!nm_setting_ip_config_add_address (s_ip4, addr)) + PARSE_WARNING ("duplicate IP4 address in alias file %s", item); + } else { + PARSE_WARNING ("error reading IP4 address from alias file '%s': %s", + full_path, err ? err->message : "no address"); + g_clear_error (&err); + } + nm_ip_address_unref (addr); + + g_free (device); + g_free (full_path); + } + + g_dir_close (dir); + } else { + PARSE_WARNING ("can not read directory '%s': %s", dirname, err->message); + g_error_free (err); + } + + g_free (base); + g_free (dirname); +} + +static NMSetting * +make_ip6_setting (shvarFile *ifcfg, + const char *network_file, + GError **error) +{ + NMSettingIPConfig *s_ip6 = NULL; + char *value = NULL; + char *str_value; + char *route6_path = NULL; + gs_free char *dns_options_free = NULL; + const char *dns_options = NULL; + gboolean ipv6init, ipv6forwarding, dhcp6 = FALSE; + char *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + char *ipv6addr, *ipv6addr_secondaries; + char **list = NULL, **iter; + guint32 i; + gint priority; + shvarFile *network_ifcfg; + gboolean never_default = FALSE; + gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip; + NMSettingIP6ConfigPrivacy ip6_privacy_val; + NMSettingIP6ConfigAddrGenMode addr_gen_mode; + + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); + + /* First check if IPV6_DEFROUTE is set for this device; IPV6_DEFROUTE has the + * opposite meaning from never-default. The default if IPV6_DEFROUTE is not + * specified is IPV6_DEFROUTE=yes which means that this connection can be used + * as a default route + */ + never_default = !svGetValueBoolean (ifcfg, "IPV6_DEFROUTE", TRUE); + + /* Then check if IPV6_DEFAULTGW or IPV6_DEFAULTDEV is specified; + * they are global and override IPV6_DEFROUTE + * When both are set, the device specified in IPV6_DEFAULTGW takes preference. + */ + network_ifcfg = svOpenFile (network_file, NULL); + if (network_ifcfg) { + char *ipv6_defaultgw, *ipv6_defaultdev; + char *default_dev = NULL; + + /* Get the connection ifcfg device name and the global default route device */ + value = svGetValueString (ifcfg, "DEVICE"); + ipv6_defaultgw = svGetValueString (network_ifcfg, "IPV6_DEFAULTGW"); + ipv6_defaultdev = svGetValueString (network_ifcfg, "IPV6_DEFAULTDEV"); + dns_options = svGetValue (network_ifcfg, "RES_OPTIONS", &dns_options_free); + + if (ipv6_defaultgw) { + default_dev = strchr (ipv6_defaultgw, '%'); + if (default_dev) + default_dev++; + } + if (!default_dev) + default_dev = ipv6_defaultdev; + + /* If there was a global default route device specified, then only connections + * for that device can be the default connection. + */ + if (default_dev && value) + never_default = !!strcmp (value, default_dev); + + g_free (ipv6_defaultgw); + g_free (ipv6_defaultdev); + g_free (value); + svCloseFile (network_ifcfg); + } + + /* Find out method property */ + /* Is IPV6 enabled? Set method to "ignored", when not enabled */ + str_value = svGetValueString (ifcfg, "IPV6INIT"); + ipv6init = svGetValueBoolean (ifcfg, "IPV6INIT", FALSE); + if (!str_value) { + network_ifcfg = svOpenFile (network_file, NULL); + if (network_ifcfg) { + ipv6init = svGetValueBoolean (network_ifcfg, "IPV6INIT", FALSE); + svCloseFile (network_ifcfg); + } + } + g_free (str_value); + + if (!ipv6init) + method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; /* IPv6 is disabled */ + else { + ipv6forwarding = svGetValueBoolean (ifcfg, "IPV6FORWARDING", FALSE); + str_value = svGetValueString (ifcfg, "IPV6_AUTOCONF"); + dhcp6 = svGetValueBoolean (ifcfg, "DHCPV6C", FALSE); + + if (!g_strcmp0 (str_value, "shared")) + method = NM_SETTING_IP6_CONFIG_METHOD_SHARED; + else if (svParseBoolean (str_value, !ipv6forwarding)) + method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; + else if (dhcp6) + method = NM_SETTING_IP6_CONFIG_METHOD_DHCP; + else { + /* IPV6_AUTOCONF=no and no IPv6 address -> method 'link-local' */ + g_free (str_value); + str_value = svGetValueString (ifcfg, "IPV6ADDR"); + if (!str_value) + str_value = svGetValueString (ifcfg, "IPV6ADDR_SECONDARIES"); + + if (!str_value) + method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; + } + g_free (str_value); + } + /* TODO - handle other methods */ + + /* Read IPv6 Privacy Extensions configuration */ + str_value = svGetValueString (ifcfg, "IPV6_PRIVACY"); + if (str_value) { + ip6_privacy = svParseBoolean (str_value, FALSE); + if (!ip6_privacy) + ip6_privacy = (g_strcmp0 (str_value, "rfc4941") == 0) || + (g_strcmp0 (str_value, "rfc3041") == 0); + } + ip6_privacy_prefer_public_ip = svGetValueBoolean (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", FALSE); + ip6_privacy_val = str_value ? + (ip6_privacy ? + (ip6_privacy_prefer_public_ip ? NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR : NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) : + NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED) : + NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; + g_free (str_value); + + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, method, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svGetValueBoolean (ifcfg, "IPV6_PEERDNS", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svGetValueBoolean (ifcfg, "IPV6_PEERROUTES", TRUE), + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, + NM_SETTING_IP_CONFIG_MAY_FAIL, !svGetValueBoolean (ifcfg, "IPV6_FAILURE_FATAL", FALSE), + NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV6_ROUTE_METRIC", 10, + -1, G_MAXUINT32, -1), + NM_SETTING_IP6_CONFIG_IP6_PRIVACY, ip6_privacy_val, + NULL); + + /* Don't bother to read IP, DNS and routes when IPv6 is disabled */ + if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) + return NM_SETTING (s_ip6); + + value = svGetValueString (ifcfg, "DHCPV6_HOSTNAME"); + /* Use DHCP_HOSTNAME as fallback if it is in FQDN format and ipv6.method is + * auto or dhcp: this is required to support old ifcfg files + */ + if (!value && ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) + || !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP))) { + value = svGetValueString (ifcfg, "DHCP_HOSTNAME"); + if (value && !strchr (value, '.')) + g_clear_pointer (&value, g_free); + } + if (value) + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); + g_free (value); + + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, + svGetValueBoolean (ifcfg, "DHCPV6_SEND_HOSTNAME", TRUE), NULL); + + /* Read static IP addresses. + * Read them even for AUTO and DHCP methods - in this case the addresses are + * added to the automatic ones. Note that this is not currently supported by + * the legacy 'network' service (ifup-eth). + */ + ipv6addr = svGetValueString (ifcfg, "IPV6ADDR"); + ipv6addr_secondaries = svGetValueString (ifcfg, "IPV6ADDR_SECONDARIES"); + + value = g_strjoin (ipv6addr && ipv6addr_secondaries ? " " : NULL, + ipv6addr ? ipv6addr : "", + ipv6addr_secondaries ? ipv6addr_secondaries : "", + NULL); + g_free (ipv6addr); + g_free (ipv6addr_secondaries); + + list = g_strsplit_set (value, " ", 0); + g_free (value); + for (iter = list, i = 0; iter && *iter; iter++, i++) { + NMIPAddress *addr = NULL; + + if (!parse_full_ip6_address (ifcfg, *iter, i, &addr, error)) { + g_strfreev (list); + goto error; + } + + if (!nm_setting_ip_config_add_address (s_ip6, addr)) + PARSE_WARNING ("duplicate IP6 address"); + nm_ip_address_unref (addr); + } + g_strfreev (list); + + /* Gateway */ + if (nm_setting_ip_config_get_num_addresses (s_ip6)) { + value = svGetValueString (ifcfg, "IPV6_DEFAULTGW"); + if (!value) { + /* If no gateway in the ifcfg, try global /etc/sysconfig/network instead */ + network_ifcfg = svOpenFile (network_file, NULL); + if (network_ifcfg) { + value = svGetValueString (network_ifcfg, "IPV6_DEFAULTGW"); + svCloseFile (network_ifcfg); + } + } + if (value) { + char *ptr; + if ((ptr = strchr (value, '%')) != NULL) + *ptr = '\0'; /* remove %interface prefix if present */ + if (!nm_utils_ipaddr_valid (AF_INET6, value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 address '%s'", value); + g_free (value); + goto error; + } + + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, value, NULL); + g_free (value); + } + } + + /* IPv6 addressing mode configuration */ + str_value = svGetValueString (ifcfg, "IPV6_ADDR_GEN_MODE"); + if (str_value) { + if (nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), str_value, + (int *) &addr_gen_mode, NULL)) + g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, addr_gen_mode, NULL); + else + PARSE_WARNING ("Invalid IPV6_ADDR_GEN_MODE"); + g_free (str_value); + } else { + g_object_set (s_ip6, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + NULL); + } + + /* IPv6 tokenized interface identifier */ + str_value = svGetValueString (ifcfg, "IPV6_TOKEN"); + if (str_value) { + g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, str_value, NULL); + g_free (str_value); + } + + /* DNS servers + * Pick up just IPv6 addresses (IPv4 addresses are taken by make_ip4_setting()) + */ + for (i = 1; i <= 10; i++) { + char *tag; + + tag = g_strdup_printf ("DNS%u", i); + value = svGetValueString (ifcfg, tag); + if (!value) { + g_free (tag); + break; /* all done */ + } + + if (nm_utils_ipaddr_valid (AF_INET6, value)) { + if (!nm_setting_ip_config_add_dns (s_ip6, value)) + PARSE_WARNING ("duplicate DNS server %s", tag); + } else if (nm_utils_ipaddr_valid (AF_INET, value)) { + /* Ignore IPv4 addresses */ + } else { + PARSE_WARNING ("invalid DNS server address %s", value); + g_free (tag); + g_free (value); + goto error; + } + + g_free (tag); + g_free (value); + } + + /* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */ + + if (!utils_has_complex_routes (svFileGetName (ifcfg))) { + /* Read static routes from route6- file */ + route6_path = utils_get_route6_path (svFileGetName (ifcfg)); + if (!read_route6_file (route6_path, s_ip6, error)) + goto error; + + g_free (route6_path); + } + + /* DNS options */ + parse_dns_options (s_ip6, svGetValue (ifcfg, "RES_OPTIONS", &value)); + parse_dns_options (s_ip6, dns_options); + g_free (value); + + /* DNS priority */ + priority = svGetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0); + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_DNS_PRIORITY, + priority, + NULL); + + return NM_SETTING (s_ip6); + +error: + g_free (route6_path); + g_object_unref (s_ip6); + return NULL; +} + +static void +check_if_bond_slave (shvarFile *ifcfg, + NMSettingConnection *s_con) +{ + char *value; + + value = svGetValueString (ifcfg, "MASTER_UUID"); + if (!value) + value = svGetValueString (ifcfg, "MASTER"); + + if (value) { + g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); + g_object_set (s_con, + NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME, + NULL); + g_free (value); + } + + /* We should be checking for SLAVE=yes as well, but NM used to not set that, + * so for backward-compatibility, we don't check. + */ +} + +static gboolean +check_if_team_slave (shvarFile *ifcfg, + NMSettingConnection *s_con) +{ + gs_free char *value = NULL; + + value = svGetValueString (ifcfg, "TEAM_MASTER_UUID"); + if (!value) + value = svGetValueString (ifcfg, "TEAM_MASTER"); + if (!value) + return FALSE; + + g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); + g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); + return TRUE; +} + +static void +check_if_slave (shvarFile *ifcfg, + NMSettingConnection *s_con) +{ + g_return_if_fail (NM_IS_SETTING_CONNECTION (s_con)); + + if (check_if_team_slave (ifcfg, s_con)) + return; + check_if_bond_slave (ifcfg, s_con); +} + +typedef struct { + const char *enable_key; + const char *advertise_key; + const char *willing_key; + const char *flags_prop; +} DcbFlagsProperty; + +enum { + DCB_APP_FCOE_FLAGS = 0, + DCB_APP_ISCSI_FLAGS = 1, + DCB_APP_FIP_FLAGS = 2, + DCB_PFC_FLAGS = 3, + DCB_PG_FLAGS = 4, +}; + +static DcbFlagsProperty dcb_flags_props[] = { + { KEY_DCB_APP_FCOE_ENABLE, KEY_DCB_APP_FCOE_ADVERTISE, KEY_DCB_APP_FCOE_WILLING, NM_SETTING_DCB_APP_FCOE_FLAGS }, + { KEY_DCB_APP_ISCSI_ENABLE, KEY_DCB_APP_ISCSI_ADVERTISE, KEY_DCB_APP_ISCSI_WILLING, NM_SETTING_DCB_APP_ISCSI_FLAGS }, + { KEY_DCB_APP_FIP_ENABLE, KEY_DCB_APP_FIP_ADVERTISE, KEY_DCB_APP_FIP_WILLING, NM_SETTING_DCB_APP_FIP_FLAGS }, + { KEY_DCB_PFC_ENABLE, KEY_DCB_PFC_ADVERTISE, KEY_DCB_PFC_WILLING, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS }, + { KEY_DCB_PG_ENABLE, KEY_DCB_PG_ADVERTISE, KEY_DCB_PG_WILLING, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS }, + { NULL }, +}; + +static NMSettingDcbFlags +read_dcb_flags (shvarFile *ifcfg, DcbFlagsProperty *property) +{ + NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; + + if (svGetValueBoolean (ifcfg, property->enable_key, FALSE)) + flags |= NM_SETTING_DCB_FLAG_ENABLE; + if (svGetValueBoolean (ifcfg, property->advertise_key, FALSE)) + flags |= NM_SETTING_DCB_FLAG_ADVERTISE; + if (svGetValueBoolean (ifcfg, property->willing_key, FALSE)) + flags |= NM_SETTING_DCB_FLAG_WILLING; + + return flags; +} + +static gboolean +read_dcb_app (shvarFile *ifcfg, + NMSettingDcb *s_dcb, + const char *app, + DcbFlagsProperty *flags_prop, + const char *priority_prop, + GError **error) +{ + NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; + char *tmp, *val; + gboolean success = TRUE; + int priority = -1; + + flags = read_dcb_flags (ifcfg, flags_prop); + + /* Priority */ + tmp = g_strdup_printf ("DCB_APP_%s_PRIORITY", app); + val = svGetValueString (ifcfg, tmp); + if (val) { + priority = _nm_utils_ascii_str_to_int64 (val, 0, 0, 7, -1); + if (priority < 0) { + success = FALSE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid %s value '%s' (expected 0 - 7)", + tmp, val); + } + g_free (val); + + if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) + PARSE_WARNING ("ignoring DCB %s priority; app not enabled", app); + } + g_free (tmp); + + if (success) { + g_object_set (G_OBJECT (s_dcb), + flags_prop->flags_prop, flags, + priority_prop, (guint) priority, + NULL); + } + + return success; +} + +typedef void (*DcbSetBoolFunc) (NMSettingDcb *, guint, gboolean); + +static gboolean +read_dcb_bool_array (shvarFile *ifcfg, + NMSettingDcb *s_dcb, + NMSettingDcbFlags flags, + const char *prop, + const char *desc, + DcbSetBoolFunc set_func, + GError **error) +{ + char *val; + gboolean success = FALSE; + guint i; + + val = svGetValueString (ifcfg, prop); + if (!val) + return TRUE; + + if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { + PARSE_WARNING ("ignoring %s; %s is not enabled", prop, desc); + success = TRUE; + goto out; + } + + val = g_strstrip (val); + if (strlen (val) != 8) { + PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "boolean array must be 8 characters"); + goto out; + } + + /* All characters must be either 0 or 1 */ + for (i = 0; i < 8; i++) { + if (val[i] != '0' && val[i] != '1') { + PARSE_WARNING ("invalid %s value '%s': not all 0s and 1s", prop, val); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid boolean digit"); + goto out; + } + set_func (s_dcb, i, (val[i] == '1')); + } + success = TRUE; + +out: + g_free (val); + return success; +} + +typedef void (*DcbSetUintFunc) (NMSettingDcb *, guint, guint); + +static gboolean +read_dcb_uint_array (shvarFile *ifcfg, + NMSettingDcb *s_dcb, + NMSettingDcbFlags flags, + const char *prop, + const char *desc, + gboolean f_allowed, + DcbSetUintFunc set_func, + GError **error) +{ + char *val; + gboolean success = FALSE; + guint i; + + val = svGetValueString (ifcfg, prop); + if (!val) + return TRUE; + + if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { + PARSE_WARNING ("ignoring %s; %s is not enabled", prop, desc); + success = TRUE; + goto out; + } + + val = g_strstrip (val); + if (strlen (val) != 8) { + PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "uint array must be 8 characters"); + goto out; + } + + /* All characters must be either 0 - 7 or (optionally) f */ + for (i = 0; i < 8; i++) { + if (val[i] >= '0' && val[i] <= '7') + set_func (s_dcb, i, val[i] - '0'); + else if (f_allowed && (val[i] == 'f' || val[i] == 'F')) + set_func (s_dcb, i, 15); + else { + PARSE_WARNING ("invalid %s value '%s': not 0 - 7%s", + prop, val, f_allowed ? " or 'f'" : ""); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid uint digit"); + goto out; + } + } + success = TRUE; + +out: + g_free (val); + return success; +} + +static gboolean +read_dcb_percent_array (shvarFile *ifcfg, + NMSettingDcb *s_dcb, + NMSettingDcbFlags flags, + const char *prop, + const char *desc, + gboolean sum_pct, + DcbSetUintFunc set_func, + GError **error) +{ + char *val; + gboolean success = FALSE; + char **split = NULL, **iter; + guint i, sum = 0; + + val = svGetValueString (ifcfg, prop); + if (!val) + return TRUE; + + if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { + PARSE_WARNING ("ignoring %s; %s is not enabled", prop, desc); + success = TRUE; + goto out; + } + + val = g_strstrip (val); + split = g_strsplit_set (val, ",", 0); + if (!split || (g_strv_length (split) != 8)) { + PARSE_WARNING ("invalid %s percentage list value '%s'", prop, val); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "percent array must be 8 elements"); + goto out; + } + + for (iter = split, i = 0; iter && *iter; iter++, i++) { + int tmp; + + tmp = _nm_utils_ascii_str_to_int64 (*iter, 0, 0, 100, -1); + if (tmp < 0) { + PARSE_WARNING ("invalid %s percentage value '%s'", prop, *iter); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid percent element"); + goto out; + } + set_func (s_dcb, i, (guint) tmp); + sum += (guint) tmp; + } + + if (sum_pct && (sum != 100)) { + PARSE_WARNING ("%s percentages do not equal 100%%", prop); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid percentage sum"); + goto out; + } + + success = TRUE; + +out: + if (split) + g_strfreev (split); + g_free (val); + return success; +} + +static gboolean +make_dcb_setting (shvarFile *ifcfg, + const char *network_file, + NMSetting **out_setting, + GError **error) +{ + NMSettingDcb *s_dcb = NULL; + gboolean dcb_on; + NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; + char *val; + + g_return_val_if_fail (out_setting != NULL, FALSE); + + dcb_on = !!svGetValueBoolean (ifcfg, "DCB", FALSE); + if (!dcb_on) + return TRUE; + + s_dcb = (NMSettingDcb *) nm_setting_dcb_new (); + g_assert (s_dcb); + + /* FCOE */ + if (!read_dcb_app (ifcfg, s_dcb, "FCOE", + &dcb_flags_props[DCB_APP_FCOE_FLAGS], + NM_SETTING_DCB_APP_FCOE_PRIORITY, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + if (nm_setting_dcb_get_app_fcoe_flags (s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) { + val = svGetValueString (ifcfg, KEY_DCB_APP_FCOE_MODE); + if (val) { + if (strcmp (val, NM_SETTING_DCB_FCOE_MODE_FABRIC) == 0 || + strcmp (val, NM_SETTING_DCB_FCOE_MODE_VN2VN) == 0) + g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_FCOE_MODE, val, NULL); + else { + PARSE_WARNING ("invalid FCoE mode '%s'", val); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid FCoE mode"); + g_free (val); + g_object_unref (s_dcb); + return FALSE; + } + g_free (val); + } + } + + /* iSCSI */ + if (!read_dcb_app (ifcfg, s_dcb, "ISCSI", + &dcb_flags_props[DCB_APP_ISCSI_FLAGS], + NM_SETTING_DCB_APP_ISCSI_PRIORITY, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + /* FIP */ + if (!read_dcb_app (ifcfg, s_dcb, "FIP", + &dcb_flags_props[DCB_APP_FIP_FLAGS], + NM_SETTING_DCB_APP_FIP_PRIORITY, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + /* Priority Flow Control */ + flags = read_dcb_flags (ifcfg, &dcb_flags_props[DCB_PFC_FLAGS]); + g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, flags, NULL); + + if (!read_dcb_bool_array (ifcfg, + s_dcb, + flags, + KEY_DCB_PFC_UP, + "PFC", + nm_setting_dcb_set_priority_flow_control, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + /* Priority Groups */ + flags = read_dcb_flags (ifcfg, &dcb_flags_props[DCB_PG_FLAGS]); + g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, flags, NULL); + + if (!read_dcb_uint_array (ifcfg, + s_dcb, + flags, + KEY_DCB_PG_ID, + "PGID", + TRUE, + nm_setting_dcb_set_priority_group_id, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + /* Group bandwidth */ + if (!read_dcb_percent_array (ifcfg, + s_dcb, + flags, + KEY_DCB_PG_PCT, + "PGPCT", + TRUE, + nm_setting_dcb_set_priority_group_bandwidth, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + /* Priority bandwidth */ + if (!read_dcb_percent_array (ifcfg, + s_dcb, + flags, + KEY_DCB_PG_UPPCT, + "UPPCT", + FALSE, + nm_setting_dcb_set_priority_bandwidth, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + /* Strict Bandwidth */ + if (!read_dcb_bool_array (ifcfg, + s_dcb, + flags, + KEY_DCB_PG_STRICT, + "STRICT", + nm_setting_dcb_set_priority_strict_bandwidth, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + if (!read_dcb_uint_array (ifcfg, + s_dcb, + flags, + KEY_DCB_PG_UP2TC, + "UP2TC", + FALSE, + nm_setting_dcb_set_priority_traffic_class, + error)) { + g_object_unref (s_dcb); + return FALSE; + } + + *out_setting = NM_SETTING (s_dcb); + return TRUE; +} + +static gboolean +add_one_wep_key (shvarFile *ifcfg, + const char *shvar_key, + guint8 key_idx, + gboolean passphrase, + NMSettingWirelessSecurity *s_wsec, + GError **error) +{ + char *key = NULL; + char *value = NULL; + gboolean success = FALSE; + + g_return_val_if_fail (ifcfg != NULL, FALSE); + g_return_val_if_fail (shvar_key != NULL, FALSE); + g_return_val_if_fail (key_idx <= 3, FALSE); + g_return_val_if_fail (s_wsec != NULL, FALSE); + + value = svGetValueString (ifcfg, shvar_key); + if (!value || !strlen (value)) { + g_free (value); + return TRUE; + } + + /* Validate keys */ + if (passphrase) { + if (strlen (value) && strlen (value) < 64) { + key = g_strdup (value); + g_object_set (G_OBJECT (s_wsec), + NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, + NM_WEP_KEY_TYPE_PASSPHRASE, + NULL); + } + } else { + if (strlen (value) == 10 || strlen (value) == 26) { + /* Hexadecimal WEP key */ + char *p = value; + + while (*p) { + if (!g_ascii_isxdigit (*p)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid hexadecimal WEP key."); + goto out; + } + p++; + } + key = g_strdup (value); + } else if ( !strncmp (value, "s:", 2) + && (strlen (value) == 7 || strlen (value) == 15)) { + /* ASCII key */ + char *p = value + 2; + + while (*p) { + if (!g_ascii_isprint ((int) (*p))) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid ASCII WEP key."); + goto out; + } + p++; + } + + /* Remove 's:' prefix. + * Don't convert to hex string. wpa_supplicant takes 'wep_key0' option over D-Bus as byte array + * and converts it to hex string itself. Even though we convert hex string keys into a bin string + * before passing to wpa_supplicant, this prevents two unnecessary conversions. And mainly, + * ASCII WEP key doesn't change to HEX WEP key in UI, which could confuse users. + */ + key = g_strdup (value + 2); + } + } + + if (key) { + nm_setting_wireless_security_set_wep_key (s_wsec, key_idx, key); + g_free (key); + success = TRUE; + } else + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WEP key length."); + +out: + g_free (value); + return success; +} + +static gboolean +read_wep_keys (shvarFile *ifcfg, + guint8 def_idx, + NMSettingWirelessSecurity *s_wsec, + GError **error) +{ + /* Try hex/ascii keys first */ + if (!add_one_wep_key (ifcfg, "KEY1", 0, FALSE, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ifcfg, "KEY2", 1, FALSE, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ifcfg, "KEY3", 2, FALSE, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ifcfg, "KEY4", 3, FALSE, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ifcfg, "KEY", def_idx, FALSE, s_wsec, error)) + return FALSE; + + /* And then passphrases */ + if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE1", 0, TRUE, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE2", 1, TRUE, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE3", 2, TRUE, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE4", 3, TRUE, s_wsec, error)) + return FALSE; + + return TRUE; +} + +static NMSettingSecretFlags +read_secret_flags (shvarFile *ifcfg, const char *flags_key) +{ + NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; + char *val; + + g_return_val_if_fail (flags_key != NULL, NM_SETTING_SECRET_FLAG_NONE); + g_return_val_if_fail (flags_key[0] != '\0', NM_SETTING_SECRET_FLAG_NONE); + g_return_val_if_fail (g_str_has_suffix (flags_key, "_FLAGS"), NM_SETTING_SECRET_FLAG_NONE); + + val = svGetValueString (ifcfg, flags_key); + if (val) { + if (strstr (val, SECRET_FLAG_AGENT)) + flags |= NM_SETTING_SECRET_FLAG_AGENT_OWNED; + if (strstr (val, SECRET_FLAG_NOT_SAVED)) + flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED; + if (strstr (val, SECRET_FLAG_NOT_REQUIRED)) + flags |= NM_SETTING_SECRET_FLAG_NOT_REQUIRED; + + g_free (val); + } + return flags; +} + +static NMSetting * +make_wep_setting (shvarFile *ifcfg, + const char *file, + GError **error) +{ + NMSettingWirelessSecurity *s_wsec; + char *value; + shvarFile *keys_ifcfg = NULL; + int default_key_idx = 0; + gboolean has_default_key = FALSE; + NMSettingSecretFlags key_flags; + + s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); + g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NULL); + + value = svGetValueString (ifcfg, "DEFAULTKEY"); + if (value) { + default_key_idx = _nm_utils_ascii_str_to_int64 (value, 0, 1, 4, 0); + if (default_key_idx == 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid default WEP key '%s'", value); + g_free (value); + goto error; + } + has_default_key = TRUE; + default_key_idx--; /* convert to [0...3] */ + g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, (guint) default_key_idx, NULL); + g_free (value); + } + + /* Read WEP key flags */ + key_flags = read_secret_flags (ifcfg, "WEP_KEY_FLAGS"); + g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, key_flags, NULL); + + /* Read keys in the ifcfg file if they are system-owned */ + if (key_flags == NM_SETTING_SECRET_FLAG_NONE) { + if (!read_wep_keys (ifcfg, default_key_idx, s_wsec, error)) + goto error; + + /* Try to get keys from the "shadow" key file */ + keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); + if (keys_ifcfg) { + if (!read_wep_keys (keys_ifcfg, default_key_idx, s_wsec, error)) { + svCloseFile (keys_ifcfg); + goto error; + } + svCloseFile (keys_ifcfg); + g_assert (error == NULL || *error == NULL); + } + } + + value = svGetValueString (ifcfg, "SECURITYMODE"); + if (value) { + char *lcase; + + lcase = g_ascii_strdown (value, -1); + g_free (value); + + if (!strcmp (lcase, "open")) { + g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", NULL); + } else if (!strcmp (lcase, "restricted")) { + g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", NULL); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WEP authentication algorithm '%s'", + lcase); + g_free (lcase); + goto error; + } + g_free (lcase); + } + + /* If no WEP keys were given, and the keys are not agent-owned, and no + * default WEP key index was given, then the connection is unencrypted. + */ + if ( !nm_setting_wireless_security_get_wep_key (s_wsec, 0) + && !nm_setting_wireless_security_get_wep_key (s_wsec, 1) + && !nm_setting_wireless_security_get_wep_key (s_wsec, 2) + && !nm_setting_wireless_security_get_wep_key (s_wsec, 3) + && (has_default_key == FALSE) + && (key_flags == NM_SETTING_SECRET_FLAG_NONE)) { + const char *auth_alg; + + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + if (auth_alg && !strcmp (auth_alg, "shared")) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "WEP Shared Key authentication is invalid for " + "unencrypted connections."); + goto error; + } + + /* Unencrypted */ + g_object_unref (s_wsec); + s_wsec = NULL; + } + + return (NMSetting *) s_wsec; + +error: + if (s_wsec) + g_object_unref (s_wsec); + return NULL; +} + +static gboolean +fill_wpa_ciphers (shvarFile *ifcfg, + NMSettingWirelessSecurity *wsec, + gboolean group, + gboolean adhoc) +{ + char *value = NULL, *p; + char **list = NULL, **iter; + int i = 0; + + p = value = svGetValueString (ifcfg, group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE"); + if (!value) + return TRUE; + + list = g_strsplit_set (p, " ", 0); + for (iter = list; iter && *iter; iter++, i++) { + /* Ad-Hoc configurations cannot have pairwise ciphers, and can only + * have one group cipher. Ignore any additional group ciphers and + * any pairwise ciphers specified. + */ + if (adhoc) { + if (group && (i > 0)) { + PARSE_WARNING ("ignoring group cipher '%s' (only one group cipher allowed " + "in Ad-Hoc mode)", *iter); + continue; + } else if (!group) { + PARSE_WARNING ("ignoring pairwise cipher '%s' (pairwise not used " + "in Ad-Hoc mode)", *iter); + continue; + } + } + + if (!strcmp (*iter, "CCMP")) { + if (group) + nm_setting_wireless_security_add_group (wsec, "ccmp"); + else + nm_setting_wireless_security_add_pairwise (wsec, "ccmp"); + } else if (!strcmp (*iter, "TKIP")) { + if (group) + nm_setting_wireless_security_add_group (wsec, "tkip"); + else + nm_setting_wireless_security_add_pairwise (wsec, "tkip"); + } else if (group && !strcmp (*iter, "WEP104")) + nm_setting_wireless_security_add_group (wsec, "wep104"); + else if (group && !strcmp (*iter, "WEP40")) + nm_setting_wireless_security_add_group (wsec, "wep40"); + else { + PARSE_WARNING ("ignoring invalid %s cipher '%s'", + group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", + *iter); + } + } + + if (list) + g_strfreev (list); + g_free (value); + return TRUE; +} + +#define WPA_PMK_LEN 32 + +static char * +parse_wpa_psk (shvarFile *ifcfg, + const char *file, + GBytes *ssid, + GError **error) +{ + shvarFile *keys_ifcfg; + gs_free char *psk = NULL; + size_t plen; + + /* Passphrase must be between 10 and 66 characters in length because WPA + * hex keys are exactly 64 characters (no quoting), and WPA passphrases + * are between 8 and 63 characters (inclusive), plus optional quoting if + * the passphrase contains spaces. + */ + + /* Try to get keys from the "shadow" key file */ + keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); + if (keys_ifcfg) { + psk = svGetValueString (keys_ifcfg, "WPA_PSK"); + svCloseFile (keys_ifcfg); + } + + /* Fall back to the original ifcfg */ + if (!psk) + psk = svGetValueString (ifcfg, "WPA_PSK"); + + if (!psk) + return NULL; + + plen = strlen (psk); + + if (plen == 64) { + /* Verify the hex PSK; 64 digits */ + if (!NM_STRCHAR_ALL (psk, ch, g_ascii_isxdigit (ch))) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WPA_PSK (contains non-hexadecimal characters)"); + return NULL; + } + } else { + if (plen < 8 || plen > 63) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WPA_PSK (passphrases must be between " + "8 and 63 characters long (inclusive))"); + return NULL; + } + } + + return g_steal_pointer (&psk); +} + +static gboolean +eap_simple_reader (const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys, + NMSetting8021x *s_8021x, + gboolean phase2, + GError **error) +{ + NMSettingSecretFlags flags; + char *value; + + value = svGetValueString (ifcfg, "IEEE_8021X_IDENTITY"); + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", + eap_method); + return FALSE; + } + g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); + g_free (value); + + flags = read_secret_flags (ifcfg, "IEEE_8021X_PASSWORD_FLAGS"); + g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD_FLAGS, flags, NULL); + + /* Only read the password if it's system-owned */ + if (flags == NM_SETTING_SECRET_FLAG_NONE) { + value = svGetValueString (ifcfg, "IEEE_8021X_PASSWORD"); + if (!value && keys) { + /* Try the lookaside keys file */ + value = svGetValueString (keys, "IEEE_8021X_PASSWORD"); + } + + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_PASSWORD for EAP method '%s'.", + eap_method); + return FALSE; + } + + g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, value, NULL); + g_free (value); + } + + return TRUE; +} + +static char * +get_full_file_path (const char *ifcfg_path, const char *file_path) +{ + const char *base = file_path; + char *p, *ret, *dirname; + + g_return_val_if_fail (ifcfg_path != NULL, NULL); + g_return_val_if_fail (file_path != NULL, NULL); + + if (file_path[0] == '/') + return g_strdup (file_path); + + p = strrchr (file_path, '/'); + if (p) + base = p + 1; + + dirname = g_path_get_dirname (ifcfg_path); + ret = g_build_path ("/", dirname, base, NULL); + g_free (dirname); + return ret; +} + +static gboolean +eap_tls_reader (const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys, + NMSetting8021x *s_8021x, + gboolean phase2, + GError **error) +{ + char *value; + char *ca_cert = NULL; + char *real_path = NULL; + char *client_cert = NULL; + char *privkey = NULL; + char *privkey_password = NULL; + gboolean success = FALSE; + NMSetting8021xCKFormat privkey_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; + const char *ca_cert_key = phase2 ? "IEEE_8021X_INNER_CA_CERT" : "IEEE_8021X_CA_CERT"; + const char *pk_pw_key = phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD": "IEEE_8021X_PRIVATE_KEY_PASSWORD"; + const char *pk_key = phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" : "IEEE_8021X_PRIVATE_KEY"; + const char *cli_cert_key = phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT"; + const char *pk_pw_flags_key = phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD_FLAGS": "IEEE_8021X_PRIVATE_KEY_PASSWORD_FLAGS"; + const char *pk_pw_flags_prop = phase2 ? NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS : NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS; + NMSettingSecretFlags flags; + + value = svGetValueString (ifcfg, "IEEE_8021X_IDENTITY"); + if (value) { + g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); + g_free (value); + } + + ca_cert = svGetValueString (ifcfg, ca_cert_key); + if (ca_cert) { + real_path = get_full_file_path (svFileGetName (ifcfg), ca_cert); + if (phase2) { + if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, + real_path, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, + error)) + goto done; + } else { + if (!nm_setting_802_1x_set_ca_cert (s_8021x, + real_path, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, + error)) + goto done; + } + g_free (real_path); + real_path = NULL; + } else { + PARSE_WARNING ("missing %s for EAP method '%s'; this is insecure!", + ca_cert_key, eap_method); + } + + /* Read and set private key password flags */ + flags = read_secret_flags (ifcfg, pk_pw_flags_key); + g_object_set (s_8021x, pk_pw_flags_prop, flags, NULL); + + /* Read the private key password if it's system-owned */ + if (flags == NM_SETTING_SECRET_FLAG_NONE) { + /* Private key password */ + privkey_password = svGetValueString (ifcfg, pk_pw_key); + if (!privkey_password && keys) { + /* Try the lookaside keys file */ + privkey_password = svGetValueString (keys, pk_pw_key); + } + + if (!privkey_password) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing %s for EAP method '%s'.", + pk_pw_key, + eap_method); + goto done; + } + } + + /* The private key itself */ + privkey = svGetValueString (ifcfg, pk_key); + if (!privkey) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing %s for EAP method '%s'.", + pk_key, + eap_method); + goto done; + } + + real_path = get_full_file_path (svFileGetName (ifcfg), privkey); + if (phase2) { + if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, + real_path, + privkey_password, + NM_SETTING_802_1X_CK_SCHEME_PATH, + &privkey_format, + error)) + goto done; + } else { + if (!nm_setting_802_1x_set_private_key (s_8021x, + real_path, + privkey_password, + NM_SETTING_802_1X_CK_SCHEME_PATH, + &privkey_format, + error)) + goto done; + } + g_free (real_path); + real_path = NULL; + + /* Only set the client certificate if the private key is not PKCS#12 format, + * as NM (due to supplicant restrictions) requires. If the key was PKCS#12, + * then nm_setting_802_1x_set_private_key() already set the client certificate + * to the same value as the private key. + */ + if ( privkey_format == NM_SETTING_802_1X_CK_FORMAT_RAW_KEY + || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { + client_cert = svGetValueString (ifcfg, cli_cert_key); + if (!client_cert) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing %s for EAP method '%s'.", + cli_cert_key, + eap_method); + goto done; + } + + real_path = get_full_file_path (svFileGetName (ifcfg), client_cert); + if (phase2) { + if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, + real_path, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, + error)) + goto done; + } else { + if (!nm_setting_802_1x_set_client_cert (s_8021x, + real_path, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, + error)) + goto done; + } + g_free (real_path); + real_path = NULL; + } + + success = TRUE; + +done: + g_free (real_path); + g_free (ca_cert); + g_free (client_cert); + g_free (privkey); + g_free (privkey_password); + return success; +} + +static gboolean +eap_peap_reader (const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys, + NMSetting8021x *s_8021x, + gboolean phase2, + GError **error) +{ + char *anon_ident = NULL; + char *ca_cert = NULL; + char *real_cert_path = NULL; + char *inner_auth = NULL; + char *peapver = NULL; + char *lower; + char **list = NULL, **iter; + gboolean success = FALSE; + + ca_cert = svGetValueString (ifcfg, "IEEE_8021X_CA_CERT"); + if (ca_cert) { + real_cert_path = get_full_file_path (svFileGetName (ifcfg), ca_cert); + if (!nm_setting_802_1x_set_ca_cert (s_8021x, + real_cert_path, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, + error)) + goto done; + } else { + PARSE_WARNING ("missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", + eap_method); + } + + peapver = svGetValueString (ifcfg, "IEEE_8021X_PEAP_VERSION"); + if (peapver) { + if (!strcmp (peapver, "0")) + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "0", NULL); + else if (!strcmp (peapver, "1")) + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "1", NULL); + else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown IEEE_8021X_PEAP_VERSION value '%s'", + peapver); + goto done; + } + } + + if (svGetValueBoolean (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", FALSE)) + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPLABEL, "1", NULL); + + anon_ident = svGetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY"); + if (anon_ident && strlen (anon_ident)) + g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); + + inner_auth = svGetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); + if (!inner_auth) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_INNER_AUTH_METHODS."); + goto done; + } + + /* Handle options for the inner auth method */ + list = g_strsplit (inner_auth, " ", 0); + for (iter = list; iter && *iter; iter++) { + if (!strlen (*iter)) + continue; + + if ( !strcmp (*iter, "MSCHAPV2") + || !strcmp (*iter, "MD5") + || !strcmp (*iter, "GTC")) { + if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) + goto done; + } else if (!strcmp (*iter, "TLS")) { + if (!eap_tls_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) + goto done; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", + *iter); + goto done; + } + + lower = g_ascii_strdown (*iter, -1); + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, lower, NULL); + g_free (lower); + break; + } + + if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No valid IEEE_8021X_INNER_AUTH_METHODS found."); + goto done; + } + + success = TRUE; + +done: + if (list) + g_strfreev (list); + g_free (inner_auth); + g_free (peapver); + g_free (real_cert_path); + g_free (ca_cert); + g_free (anon_ident); + return success; +} + +static gboolean +eap_ttls_reader (const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys, + NMSetting8021x *s_8021x, + gboolean phase2, + GError **error) +{ + gboolean success = FALSE; + char *anon_ident = NULL; + char *ca_cert = NULL; + char *real_cert_path = NULL; + char *inner_auth = NULL; + char *tmp; + char **list = NULL, **iter; + + ca_cert = svGetValueString (ifcfg, "IEEE_8021X_CA_CERT"); + if (ca_cert) { + real_cert_path = get_full_file_path (svFileGetName (ifcfg), ca_cert); + if (!nm_setting_802_1x_set_ca_cert (s_8021x, + real_cert_path, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, + error)) + goto done; + } else { + PARSE_WARNING ("missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", + eap_method); + } + + anon_ident = svGetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY"); + if (anon_ident && strlen (anon_ident)) + g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); + + tmp = svGetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); + if (!tmp) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_INNER_AUTH_METHODS."); + goto done; + } + + inner_auth = g_ascii_strdown (tmp, -1); + g_free (tmp); + + /* Handle options for the inner auth method */ + list = g_strsplit (inner_auth, " ", 0); + for (iter = list; iter && *iter; iter++) { + if (!strlen (*iter)) + continue; + + if ( !strcmp (*iter, "mschapv2") + || !strcmp (*iter, "mschap") + || !strcmp (*iter, "pap") + || !strcmp (*iter, "chap")) { + if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) + goto done; + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, *iter, NULL); + } else if (!strcmp (*iter, "eap-tls")) { + if (!eap_tls_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) + goto done; + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, "tls", NULL); + } else if ( !strcmp (*iter, "eap-mschapv2") + || !strcmp (*iter, "eap-md5") + || !strcmp (*iter, "eap-gtc")) { + if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) + goto done; + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, (*iter + NM_STRLEN ("eap-")), NULL); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", + *iter); + goto done; + } + break; + } + + success = TRUE; + +done: + if (list) + g_strfreev (list); + g_free (inner_auth); + g_free (real_cert_path); + g_free (ca_cert); + g_free (anon_ident); + return success; +} + +static gboolean +eap_fast_reader (const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys, + NMSetting8021x *s_8021x, + gboolean phase2, + GError **error) +{ + char *anon_ident = NULL; + char *pac_file = NULL; + char *real_pac_path = NULL; + char *inner_auth = NULL; + char *fast_provisioning = NULL; + char *lower; + char **list = NULL, **iter; + const char* pac_prov_str; + gboolean allow_unauth = FALSE, allow_auth = FALSE; + gboolean success = FALSE; + + pac_file = svGetValueString (ifcfg, "IEEE_8021X_PAC_FILE"); + if (pac_file) { + real_pac_path = get_full_file_path (svFileGetName (ifcfg), pac_file); + g_object_set (s_8021x, NM_SETTING_802_1X_PAC_FILE, real_pac_path, NULL); + } + + fast_provisioning = svGetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING"); + if (fast_provisioning) { + list = g_strsplit_set (fast_provisioning, " \t", 0); + for (iter = list; iter && *iter; iter++) { + if (**iter == '\0') + continue; + if (strcmp (*iter, "allow-unauth") == 0) + allow_unauth = TRUE; + else if (strcmp (*iter, "allow-auth") == 0) + allow_auth = TRUE; + else { + PARSE_WARNING ("invalid IEEE_8021X_FAST_PROVISIONING '%s' " + "(space-separated list of these values [allow-auth, allow-unauth] expected)", + *iter); + } + } + g_strfreev (list); + list = NULL; + } + pac_prov_str = allow_unauth ? (allow_auth ? "3" : "1") : (allow_auth ? "2" : "0"); + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, pac_prov_str, NULL); + + if (!pac_file && !(allow_unauth || allow_auth)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "IEEE_8021X_PAC_FILE not provided and EAP-FAST automatic PAC provisioning disabled."); + goto done; + } + + anon_ident = svGetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY"); + if (anon_ident && strlen (anon_ident)) + g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); + + inner_auth = svGetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); + if (!inner_auth) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_INNER_AUTH_METHODS."); + goto done; + } + + /* Handle options for the inner auth method */ + list = g_strsplit (inner_auth, " ", 0); + for (iter = list; iter && *iter; iter++) { + if (!strlen (*iter)) + continue; + + if ( !strcmp (*iter, "MSCHAPV2") + || !strcmp (*iter, "GTC")) { + if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) + goto done; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", + *iter); + goto done; + } + + lower = g_ascii_strdown (*iter, -1); + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, lower, NULL); + g_free (lower); + break; + } + + if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No valid IEEE_8021X_INNER_AUTH_METHODS found."); + goto done; + } + + success = TRUE; + +done: + g_strfreev (list); + g_free (inner_auth); + g_free (fast_provisioning); + g_free (real_pac_path); + g_free (pac_file); + g_free (anon_ident); + return success; +} + +typedef struct { + const char *method; + gboolean (*reader)(const char *eap_method, + shvarFile *ifcfg, + shvarFile *keys, + NMSetting8021x *s_8021x, + gboolean phase2, + GError **error); + gboolean wifi_phase2_only; +} EAPReader; + +static EAPReader eap_readers[] = { + { "md5", eap_simple_reader, TRUE }, + { "pap", eap_simple_reader, TRUE }, + { "chap", eap_simple_reader, TRUE }, + { "mschap", eap_simple_reader, TRUE }, + { "mschapv2", eap_simple_reader, TRUE }, + { "leap", eap_simple_reader, FALSE }, + { "pwd", eap_simple_reader, FALSE }, + { "tls", eap_tls_reader, FALSE }, + { "peap", eap_peap_reader, FALSE }, + { "ttls", eap_ttls_reader, FALSE }, + { "fast", eap_fast_reader, FALSE }, + { NULL, NULL } +}; + +static void +read_8021x_list_value (shvarFile *ifcfg, + const char *ifcfg_var_name, + NMSetting8021x *setting, + const char *prop_name) +{ + char *value; + char **strv; + + g_return_if_fail (ifcfg != NULL); + g_return_if_fail (ifcfg_var_name != NULL); + g_return_if_fail (prop_name != NULL); + + value = svGetValueString (ifcfg, ifcfg_var_name); + if (!value) + return; + + strv = g_strsplit_set (value, " \t", 0); + if (strv && strv[0]) + g_object_set (setting, prop_name, strv, NULL); + g_strfreev (strv); + g_free (value); +} + +static NMSetting8021x * +fill_8021x (shvarFile *ifcfg, + const char *file, + const char *key_mgmt, + gboolean wifi, + GError **error) +{ + NMSetting8021x *s_8021x; + shvarFile *keys = NULL; + char *value; + char **list = NULL, **iter; + + value = svGetValueString (ifcfg, "IEEE_8021X_EAP_METHODS"); + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_EAP_METHODS for key management '%s'", + key_mgmt); + return NULL; + } + + list = g_strsplit (value, " ", 0); + g_free (value); + + s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); + + /* Read in the lookaside keys file, if present */ + keys = utils_get_keys_ifcfg (file, FALSE); + + /* Validate and handle each EAP method */ + for (iter = list; iter && *iter; iter++) { + EAPReader *eap = &eap_readers[0]; + gboolean found = FALSE; + char *lower = NULL; + + lower = g_ascii_strdown (*iter, -1); + while (eap->method) { + if (strcmp (eap->method, lower)) + goto next; + + /* Some EAP methods don't provide keying material, thus they + * cannot be used with WiFi unless they are an inner method + * used with TTLS or PEAP or whatever. + */ + if (wifi && eap->wifi_phase2_only) { + PARSE_WARNING ("ignored invalid IEEE_8021X_EAP_METHOD '%s'; not allowed for wifi.", + lower); + goto next; + } + + /* Parse EAP method specific options */ + if (!(*eap->reader)(lower, ifcfg, keys, s_8021x, FALSE, error)) { + g_free (lower); + goto error; + } + nm_setting_802_1x_add_eap_method (s_8021x, lower); + found = TRUE; + break; + + next: + eap++; + } + + if (!found) + PARSE_WARNING ("ignored unknown IEEE_8021X_EAP_METHOD '%s'.", lower); + g_free (lower); + } + + if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No valid EAP methods found in IEEE_8021X_EAP_METHODS."); + goto error; + } + + value = svGetValueString (ifcfg, "IEEE_8021X_SUBJECT_MATCH"); + g_object_set (s_8021x, NM_SETTING_802_1X_SUBJECT_MATCH, value, NULL); + g_free (value); + + value = svGetValueString (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH"); + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, value, NULL); + g_free (value); + + read_8021x_list_value (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", + s_8021x, NM_SETTING_802_1X_ALTSUBJECT_MATCHES); + read_8021x_list_value (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", + s_8021x, NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES); + + value = svGetValueString (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH"); + g_object_set (s_8021x, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, value, NULL); + g_free (value); + value = svGetValueString (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH"); + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, value, NULL); + g_free (value); + + if (list) + g_strfreev (list); + if (keys) + svCloseFile (keys); + return s_8021x; + +error: + if (list) + g_strfreev (list); + if (keys) + svCloseFile (keys); + g_object_unref (s_8021x); + return NULL; +} + +static NMSetting * +make_wpa_setting (shvarFile *ifcfg, + const char *file, + GBytes *ssid, + gboolean adhoc, + NMSetting8021x **s_8021x, + GError **error) +{ + NMSettingWirelessSecurity *wsec; + char *value, *psk, *lower; + gboolean wpa_psk = FALSE, wpa_eap = FALSE, ieee8021x = FALSE; + + wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); + + value = svGetValueString (ifcfg, "KEY_MGMT"); + wpa_psk = !g_strcmp0 (value, "WPA-PSK"); + wpa_eap = !g_strcmp0 (value, "WPA-EAP"); + ieee8021x = !g_strcmp0 (value, "IEEE8021X"); + if (!wpa_psk && !wpa_eap && !ieee8021x) + goto error; /* Not WPA or Dynamic WEP */ + + /* Pairwise and Group ciphers (only relevant for WPA/RSN) */ + if (wpa_psk || wpa_eap) { + fill_wpa_ciphers (ifcfg, wsec, FALSE, adhoc); + fill_wpa_ciphers (ifcfg, wsec, TRUE, adhoc); + } + + /* WPA and/or RSN */ + if (adhoc) { + /* Ad-Hoc mode only supports WPA proto for now */ + nm_setting_wireless_security_add_proto (wsec, "wpa"); + } else { + char *allow_wpa, *allow_rsn; + + allow_wpa = svGetValueString (ifcfg, "WPA_ALLOW_WPA"); + allow_rsn = svGetValueString (ifcfg, "WPA_ALLOW_WPA2"); + + if (allow_wpa && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA", TRUE)) + nm_setting_wireless_security_add_proto (wsec, "wpa"); + if (allow_rsn && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA2", TRUE)) + nm_setting_wireless_security_add_proto (wsec, "rsn"); + + g_free (allow_wpa); + g_free (allow_rsn); + } + + if (wpa_psk) { + NMSettingSecretFlags psk_flags; + + psk_flags = read_secret_flags (ifcfg, "WPA_PSK_FLAGS"); + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, psk_flags, NULL); + + /* Read PSK if it's system-owned */ + if (psk_flags == NM_SETTING_SECRET_FLAG_NONE) { + psk = parse_wpa_psk (ifcfg, file, ssid, error); + if (psk) { + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_PSK, psk, NULL); + g_free (psk); + } else if (error) + goto error; + } + + if (adhoc) + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL); + else + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL); + } else if (wpa_eap || ieee8021x) { + /* Adhoc mode is mutually exclusive with any 802.1x-based authentication */ + if (adhoc) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", value); + goto error; + } + + *s_8021x = fill_8021x (ifcfg, file, value, TRUE, error); + if (!*s_8021x) + goto error; + + lower = g_ascii_strdown (value, -1); + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, lower, NULL); + g_free (lower); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown wireless KEY_MGMT type '%s'", value); + goto error; + } + + g_free (value); + + value = svGetValueString (ifcfg, "SECURITYMODE"); + if (NM_IN_STRSET (value, NULL, "open")) + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, value, NULL); + + g_free (value); + return (NMSetting *) wsec; + +error: + g_free (value); + if (wsec) + g_object_unref (wsec); + return NULL; +} + +static NMSetting * +make_leap_setting (shvarFile *ifcfg, + const char *file, + GError **error) +{ + NMSettingWirelessSecurity *wsec; + shvarFile *keys_ifcfg; + char *value; + NMSettingSecretFlags flags; + + wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); + + value = svGetValueString (ifcfg, "KEY_MGMT"); + if (!value || strcmp (value, "IEEE8021X")) + goto error; /* Not LEAP */ + + g_free (value); + value = svGetValueString (ifcfg, "SECURITYMODE"); + if (!value || strcasecmp (value, "leap")) + goto error; /* Not LEAP */ + + g_free (value); + + flags = read_secret_flags (ifcfg, "IEEE_8021X_PASSWORD_FLAGS"); + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, flags, NULL); + + /* Read LEAP password if it's system-owned */ + if (flags == NM_SETTING_SECRET_FLAG_NONE) { + value = svGetValueString (ifcfg, "IEEE_8021X_PASSWORD"); + if (!value) { + /* Try to get keys from the "shadow" key file */ + keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); + if (keys_ifcfg) { + value = svGetValueString (keys_ifcfg, "IEEE_8021X_PASSWORD"); + svCloseFile (keys_ifcfg); + } + } + if (value && strlen (value)) + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "IEEE_8021X_IDENTITY"); + if (!value || !strlen (value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing LEAP identity"); + goto error; + } + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, value, NULL); + g_free (value); + + g_object_set (wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", + NULL); + + return (NMSetting *) wsec; + +error: + g_free (value); + if (wsec) + g_object_unref (wsec); + return NULL; +} + +static NMSetting * +make_wireless_security_setting (shvarFile *ifcfg, + const char *file, + GBytes *ssid, + gboolean adhoc, + NMSetting8021x **s_8021x, + GError **error) +{ + NMSetting *wsec; + + g_return_val_if_fail (error && !*error, NULL); + + if (!adhoc) { + wsec = make_leap_setting (ifcfg, file, error); + if (wsec) + return wsec; + else if (*error) + return NULL; + } + + wsec = make_wpa_setting (ifcfg, file, ssid, adhoc, s_8021x, error); + if (wsec) + return wsec; + else if (*error) + return NULL; + + wsec = make_wep_setting (ifcfg, file, error); + if (wsec) + return wsec; + else if (*error) + return NULL; + + return NULL; /* unencrypted */ +} + +static char ** +transform_hwaddr_blacklist (const char *blacklist) +{ + char **strv, **iter; + int shift = 0; + + strv = _nm_utils_strsplit_set (blacklist, " \t", 0); + for (iter = strv; iter && *iter; iter++) { + if (shift) { + *(iter - shift) = *iter; + *iter = NULL; + } + if (!nm_utils_hwaddr_valid (*(iter - shift), ETH_ALEN)) { + PARSE_WARNING ("invalid MAC in HWADDR_BLACKLIST '%s'", *(iter - shift)); + g_free (*(iter - shift)); + *(iter - shift) = NULL; + shift++; + } + } + return strv; +} + +static NMSetting * +make_wireless_setting (shvarFile *ifcfg, + GError **error) +{ + NMSettingWireless *s_wireless; + const char *cvalue; + char *value = NULL; + gint64 chan = 0; + NMSettingMacRandomization mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; + NMSettingWirelessPowersave powersave = NM_SETTING_WIRELESS_POWERSAVE_DEFAULT; + + s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); + + value = svGetValueString (ifcfg, "HWADDR"); + if (value) { + value = g_strstrip (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "MACADDR"); + if (value) { + value = g_strstrip (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK"); + g_object_set (s_wireless, NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK, value, NULL); + g_free (value); + + value = svGetValueString (ifcfg, "HWADDR_BLACKLIST"); + if (value) { + char **strv; + + strv = transform_hwaddr_blacklist (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, strv, NULL); + g_strfreev (strv); + g_free (value); + } + + value = svGetValueString (ifcfg, "ESSID"); + if (value) { + gs_unref_bytes GBytes *bytes = NULL; + gsize ssid_len = 0; + gsize value_len = strlen (value); + + if ( value_len > 2 + && (value_len % 2) == 0 + && g_str_has_prefix (value, "0x") + && NM_STRCHAR_ALL (&value[2], ch, g_ascii_isxdigit (ch))) { + /* interpret the value as hex-digits iff value starts + * with "0x" followed by pairs of hex digits */ + bytes = nm_utils_hexstr2bin (&value[2]); + } else + bytes = g_bytes_new (value, value_len); + + ssid_len = g_bytes_get_size (bytes); + if (ssid_len > 32 || ssid_len == 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", + value, ssid_len); + g_free (value); + goto error; + } + + g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, bytes, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "MODE"); + if (value) { + char *lcase; + const char *mode = NULL; + + lcase = g_ascii_strdown (value, -1); + g_free (value); + + if (!strcmp (lcase, "ad-hoc")) { + mode = "adhoc"; + } else if (!strcmp (lcase, "ap")) { + mode = "ap"; + } else if (!strcmp (lcase, "managed") || !strcmp (lcase, "auto")) { + mode = "infrastructure"; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid mode '%s' (not 'Ad-Hoc', 'Ap', 'Managed', or 'Auto')", + lcase); + g_free (lcase); + goto error; + } + g_free (lcase); + + g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, mode, NULL); + } + + value = svGetValueString (ifcfg, "BSSID"); + if (value) { + value = g_strstrip (value); + g_object_set (s_wireless, NM_SETTING_WIRELESS_BSSID, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "CHANNEL"); + if (value) { + errno = 0; + chan = _nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0); + if (errno || (chan == 0)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid wireless channel '%s'", value); + g_free (value); + goto error; + } + g_object_set (s_wireless, NM_SETTING_WIRELESS_CHANNEL, (guint32) chan, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "BAND"); + if (value) { + if (!strcmp (value, "a")) { + if (chan && chan <= 14) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Band '%s' invalid for channel %u", value, (guint32) chan); + g_free (value); + goto error; + } + } else if (!strcmp (value, "bg")) { + if (chan && chan > 14) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Band '%s' invalid for channel %u", value, (guint32) chan); + g_free (value); + goto error; + } + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid wireless band '%s'", value); + g_free (value); + goto error; + } + g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, value, NULL); + g_free (value); + } else if (chan > 0) { + if (chan > 14) + g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "a", NULL); + else + g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "bg", NULL); + } + + value = svGetValueString (ifcfg, "MTU"); + if (value) { + int mtu; + + mtu = _nm_utils_ascii_str_to_int64 (value, 10, 0, 50000, -1); + if (mtu == -1) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid wireless MTU '%s'", value); + g_free (value); + goto error; + } + g_object_set (s_wireless, NM_SETTING_WIRELESS_MTU, (guint) mtu, NULL); + g_free (value); + } + + g_object_set (s_wireless, + NM_SETTING_WIRELESS_HIDDEN, + svGetValueBoolean (ifcfg, "SSID_HIDDEN", FALSE), + NULL); + + cvalue = svGetValue (ifcfg, "POWERSAVE", &value); + if (cvalue) { + if (!strcmp (cvalue, "default")) + powersave = NM_SETTING_WIRELESS_POWERSAVE_DEFAULT; + else if (!strcmp (cvalue, "ignore")) + powersave = NM_SETTING_WIRELESS_POWERSAVE_IGNORE; + else if (!strcmp (cvalue, "disable") || !strcmp (cvalue, "no")) + powersave = NM_SETTING_WIRELESS_POWERSAVE_DISABLE; + else if (!strcmp (cvalue, "enable") || !strcmp (cvalue, "yes")) + powersave = NM_SETTING_WIRELESS_POWERSAVE_ENABLE; + else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid POWERSAVE value '%s'", cvalue); + g_free (value); + goto error; + } + g_free (value); + } + + g_object_set (s_wireless, + NM_SETTING_WIRELESS_POWERSAVE, + powersave, + NULL); + + cvalue = svGetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", &value); + if (cvalue) { + if (strcmp (cvalue, "default") == 0) + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_DEFAULT; + else if (strcmp (cvalue, "never") == 0) + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; + else if (strcmp (cvalue, "always") == 0) + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_ALWAYS; + else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid MAC_ADDRESS_RANDOMIZATION value '%s'", cvalue); + g_free (value); + goto error; + } + g_free (value); + } else + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; + + g_object_set (s_wireless, + NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, + mac_randomization, + NULL); + + return NM_SETTING (s_wireless); + +error: + if (s_wireless) + g_object_unref (s_wireless); + return NULL; +} + +static NMConnection * +wireless_connection_from_ifcfg (const char *file, + shvarFile *ifcfg, + GError **error) +{ + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *wireless_setting = NULL; + NMSetting8021x *s_8021x = NULL; + GBytes *ssid; + NMSetting *security_setting = NULL; + char *printable_ssid = NULL; + const char *mode; + gboolean adhoc = FALSE; + GError *local = NULL; + + g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail (ifcfg != NULL, NULL); + g_return_val_if_fail (!error || !*error, NULL); + + connection = nm_simple_connection_new (); + + /* Wireless */ + wireless_setting = make_wireless_setting (ifcfg, error); + if (!wireless_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, wireless_setting); + + ssid = nm_setting_wireless_get_ssid (NM_SETTING_WIRELESS (wireless_setting)); + if (ssid) { + printable_ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), + g_bytes_get_size (ssid)); + } else + printable_ssid = g_strdup_printf ("unmanaged"); + + mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (wireless_setting)); + if (mode && !strcmp (mode, "adhoc")) + adhoc = TRUE; + + /* Wireless security */ + security_setting = make_wireless_security_setting (ifcfg, file, ssid, adhoc, &s_8021x, &local); + if (local) { + g_free (printable_ssid); + g_object_unref (connection); + g_propagate_error (error, local); + return NULL; + } + if (security_setting) { + nm_connection_add_setting (connection, security_setting); + if (s_8021x) + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + } + + /* Connection */ + con_setting = make_connection_setting (file, ifcfg, + NM_SETTING_WIRELESS_SETTING_NAME, + printable_ssid, NULL); + g_free (printable_ssid); + if (!con_setting) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, con_setting); + + return connection; +} + +static void +parse_ethtool_option_autoneg (const char *value, gboolean *out_autoneg) +{ + if (!value) { + PARSE_WARNING ("Auto-negotiation option missing"); + return; + } + + if (g_str_equal (value, "off")) + *out_autoneg = FALSE; + else if (g_str_equal (value, "on")) + *out_autoneg = TRUE; + else + PARSE_WARNING ("Auto-negotiation unknown value: %s", value); +} + +static void +parse_ethtool_option_speed (const char *value, guint32 *out_speed) +{ + if (!value) { + PARSE_WARNING ("Speed option missing"); + return; + } + + *out_speed = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, 0); + if (errno) + PARSE_WARNING ("Speed value '%s' is invalid", value); +} + +static void +parse_ethtool_option_duplex (const char *value, const char **out_duplex) +{ + if (!value) { + PARSE_WARNING ("Duplex option missing"); + return; + } + + if (g_str_equal (value, "half")) + *out_duplex = "half"; + else if (g_str_equal (value, "full")) + *out_duplex = "full"; + else + PARSE_WARNING ("Duplex unknown value: %s", value); + +} + +static void +parse_ethtool_option_wol (const char *value, NMSettingWiredWakeOnLan *out_flags) +{ + NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; + + if (!value) { + PARSE_WARNING ("Wake-on-LAN options missing"); + return; + } + + for (; *value; value++) { + switch (*value) { + case 'p': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY; + break; + case 'u': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST; + break; + case 'm': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST; + break; + case 'b': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST; + break; + case 'a': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_ARP; + break; + case 'g': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; + break; + case 's': + break; + case 'd': + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; + break; + default: + PARSE_WARNING ("unrecognized Wake-on-LAN option '%c'", *value); + } + } + + *out_flags = wol_flags; +} + +static void parse_ethtool_option_sopass (const char *value, char **out_password) +{ + if (!value) { + PARSE_WARNING ("Wake-on-LAN password missing"); + return; + } + + g_clear_pointer (out_password, g_free); + if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { + PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", value); + return; + } + + *out_password = g_strdup (value); +} + +static void +parse_ethtool_option (const char *value, + NMSettingWiredWakeOnLan *out_flags, + char **out_password, + gboolean *out_autoneg, + guint32 *out_speed, + const char **out_duplex) +{ + gs_strfreev char **words = NULL; + const char **iter = NULL, *opt_val, *opt; + + if (!value || !value[0]) + return; + + words = g_strsplit_set (value, "\t ", 0); + iter = (const char **) words; + + while (iter[0]) { + /* g_strsplit_set() returns empty tokens when extra spaces are found: skip them */ + if (!*iter[0]) { + iter++; + continue; + } + + opt = iter++[0]; + + /* skip over repeated space characters like to parse "wol d". */ + while (iter[0] && !*iter[0]) + iter++; + + opt_val = iter[0]; + + if (g_str_equal (opt, "autoneg")) + parse_ethtool_option_autoneg (opt_val, out_autoneg); + else if (g_str_equal (opt, "speed")) + parse_ethtool_option_speed (opt_val, out_speed); + else if (g_str_equal (opt, "duplex")) + parse_ethtool_option_duplex (opt_val, out_duplex); + else if (g_str_equal (opt, "wol")) + parse_ethtool_option_wol (opt_val, out_flags); + else if (g_str_equal (opt, "sopass")) + parse_ethtool_option_sopass (opt_val, out_password); + else { + /* Silently skip unknown options */ + continue; + } + + if (iter[0]) + iter++; + } +} + +static void +parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, const char *value) +{ + NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; + gs_free char *wol_password = NULL, *wol_value = NULL; + gboolean ignore_wol_password = FALSE, autoneg = FALSE; + guint32 speed = 0; + const char *duplex = NULL; + + if (value) { + gs_strfreev char **opts = NULL; + const char **iter; + + /* WAKE_ON_LAN_IGNORE is inferred from a specified but empty ETHTOOL_OPTS */ + if (!value[0]) + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; + + opts = g_strsplit_set (value, ";", 0); + for (iter = (const char **) opts; iter[0]; iter++) { + /* in case of repeated wol_passwords, parse_ethtool_option() + * will do the right thing and clear wol_password before resetting. */ + parse_ethtool_option (iter[0], &wol_flags, &wol_password, &autoneg, &speed, &duplex); + } + } + + /* ETHTOOL_WAKE_ON_LAN = ignore overrides WoL settings in ETHTOOL_OPTS */ + wol_value = svGetValueString (ifcfg, "ETHTOOL_WAKE_ON_LAN"); + if (wol_value) { + if (strcmp (wol_value, "ignore") == 0) + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; + else + PARSE_WARNING ("invalid ETHTOOL_WAKE_ON_LAN value '%s'", wol_value); + } + + if ( wol_password + && !NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { + PARSE_WARNING ("Wake-on-LAN password not expected"); + ignore_wol_password = TRUE; + } + + g_object_set (s_wired, + NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, + NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, ignore_wol_password ? NULL : wol_password, + NM_SETTING_WIRED_AUTO_NEGOTIATE, autoneg, + NM_SETTING_WIRED_SPEED, autoneg ? 0 : speed, + NM_SETTING_WIRED_DUPLEX, autoneg ? NULL : duplex, + NULL); +} + +static NMSetting * +make_wired_setting (shvarFile *ifcfg, + const char *file, + NMSetting8021x **s_8021x, + GError **error) +{ + NMSettingWired *s_wired; + char *value = NULL; + char *nettype; + + s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); + + value = svGetValueString (ifcfg, "MTU"); + if (value) { + int mtu; + + mtu = _nm_utils_ascii_str_to_int64 (value, 0, 0, 65535, -1); + if (mtu >= 0) + g_object_set (s_wired, NM_SETTING_WIRED_MTU, (guint) mtu, NULL); + else + PARSE_WARNING ("invalid MTU '%s'", value); + g_free (value); + } + + value = svGetValueString (ifcfg, "HWADDR"); + if (value) { + value = g_strstrip (value); + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "SUBCHANNELS"); + if (value) { + const char *p = value; + gboolean success = TRUE; + char **chans = NULL; + + /* basic sanity checks */ + while (*p) { + if (!g_ascii_isxdigit (*p) && (*p != ',') && (*p != '.')) { + PARSE_WARNING ("invalid SUBCHANNELS '%s'", value); + success = FALSE; + break; + } + p++; + } + + if (success) { + guint32 num_chans; + + chans = g_strsplit_set (value, ",", 0); + num_chans = g_strv_length (chans); + if (num_chans < 2 || num_chans > 3) { + PARSE_WARNING ("invalid SUBCHANNELS '%s' (%d channels, 2 or 3 expected)", + value, g_strv_length (chans)); + } else + g_object_set (s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, chans, NULL); + g_strfreev (chans); + } + g_free (value); + } + + value = svGetValueString (ifcfg, "PORTNAME"); + if (value && strlen (value)) { + nm_setting_wired_add_s390_option (s_wired, "portname", value); + } + g_free (value); + + value = svGetValueString (ifcfg, "CTCPROT"); + if (value && strlen (value)) + nm_setting_wired_add_s390_option (s_wired, "ctcprot", value); + g_free (value); + + nettype = svGetValueString (ifcfg, "NETTYPE"); + if (nettype && strlen (nettype)) { + if (!strcmp (nettype, "qeth") || !strcmp (nettype, "lcs") || !strcmp (nettype, "ctc")) + g_object_set (s_wired, NM_SETTING_WIRED_S390_NETTYPE, nettype, NULL); + else + PARSE_WARNING ("unknown s390 NETTYPE '%s'", nettype); + } + g_free (nettype); + + value = svGetValueString (ifcfg, "OPTIONS"); + if (value && strlen (value)) { + char **options, **iter; + + iter = options = g_strsplit_set (value, " ", 0); + while (iter && *iter) { + char *equals = strchr (*iter, '='); + gboolean valid = FALSE; + + if (equals) { + *equals = '\0'; + valid = nm_setting_wired_add_s390_option (s_wired, *iter, equals + 1); + } + if (!valid) + PARSE_WARNING ("invalid s390 OPTION '%s'", *iter); + iter++; + } + g_strfreev (options); + } + g_free (value); + + value = svGetValueString (ifcfg, "MACADDR"); + if (value) { + value = g_strstrip (value); + g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK"); + g_object_set (s_wired, NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, value, NULL); + g_free (value); + + value = svGetValueString (ifcfg, "HWADDR_BLACKLIST"); + if (value) { + char **strv; + + strv = transform_hwaddr_blacklist (value); + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, strv, NULL); + g_strfreev (strv); + g_free (value); + } + + value = svGetValueString (ifcfg, "KEY_MGMT"); + if (value) { + if (!strcmp (value, "IEEE8021X")) { + *s_8021x = fill_8021x (ifcfg, file, value, FALSE, error); + if (!*s_8021x) + goto error; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown wired KEY_MGMT type '%s'", value); + goto error; + } + g_free (value); + } + + parse_ethtool_options (ifcfg, s_wired, + svGetValue (ifcfg, "ETHTOOL_OPTS", &value)); + g_free (value); + + return (NMSetting *) s_wired; + +error: + g_free (value); + g_object_unref (s_wired); + return NULL; +} + +static NMConnection * +wired_connection_from_ifcfg (const char *file, + shvarFile *ifcfg, + GError **error) +{ + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *wired_setting = NULL; + NMSetting8021x *s_8021x = NULL; + + g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail (ifcfg != NULL, NULL); + + connection = nm_simple_connection_new (); + + con_setting = make_connection_setting (file, ifcfg, NM_SETTING_WIRED_SETTING_NAME, NULL, NULL); + if (!con_setting) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); + g_object_unref (connection); + return NULL; + } + check_if_slave (ifcfg, (NMSettingConnection *) con_setting); + nm_connection_add_setting (connection, con_setting); + + wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); + if (!wired_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, wired_setting); + + if (s_8021x) + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + + return connection; +} + +static gboolean +parse_infiniband_p_key (shvarFile *ifcfg, + int *out_p_key, + char **out_parent, + GError **error) +{ + char *device = NULL, *physdev = NULL, *pkey_id = NULL; + char *ifname = NULL; + int id; + gboolean ret = FALSE; + + device = svGetValueString (ifcfg, "DEVICE"); + if (!device) { + PARSE_WARNING ("InfiniBand connection specified PKEY but not DEVICE"); + goto done; + } + + physdev = svGetValueString (ifcfg, "PHYSDEV"); + if (!physdev) { + PARSE_WARNING ("InfiniBand connection specified PKEY but not PHYSDEV"); + goto done; + } + + pkey_id = svGetValueString (ifcfg, "PKEY_ID"); + if (!pkey_id) { + PARSE_WARNING ("InfiniBand connection specified PKEY but not PKEY_ID"); + goto done; + } + + id = _nm_utils_ascii_str_to_int64 (pkey_id, 0, 0, 0xFFFF, -1); + if (id == -1) { + PARSE_WARNING ("invalid InfiniBand PKEY_ID '%s'", pkey_id); + goto done; + } + id = (id | 0x8000); + + ifname = g_strdup_printf ("%s.%04x", physdev, (unsigned) id); + if (strcmp (device, ifname) != 0) { + PARSE_WARNING ("InfiniBand DEVICE (%s) does not match PHYSDEV+PKEY_ID (%s)", + device, ifname); + goto done; + } + + *out_p_key = id; + *out_parent = g_strdup (physdev); + ret = TRUE; + + done: + g_free (device); + g_free (physdev); + g_free (pkey_id); + g_free (ifname); + + if (!ret) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create InfiniBand setting."); + } + return ret; +} + + +static NMSetting * +make_infiniband_setting (shvarFile *ifcfg, + const char *file, + GError **error) +{ + NMSettingInfiniband *s_infiniband; + char *value = NULL; + + s_infiniband = NM_SETTING_INFINIBAND (nm_setting_infiniband_new ()); + + value = svGetValueString (ifcfg, "MTU"); + if (value) { + int mtu; + + mtu = _nm_utils_ascii_str_to_int64 (value, 0, 0, 65535, -1); + if (mtu >= 0) + g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MTU, (guint) mtu, NULL); + else + PARSE_WARNING ("invalid MTU '%s'", value); + g_free (value); + } + + value = svGetValueString (ifcfg, "HWADDR"); + if (value) { + value = g_strstrip (value); + g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, value, NULL); + g_free (value); + } + + if (svGetValueBoolean (ifcfg, "CONNECTED_MODE", FALSE)) + g_object_set (s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", NULL); + else + g_object_set (s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); + + if (svGetValueBoolean (ifcfg, "PKEY", FALSE)) { + int p_key; + char *parent; + + if (!parse_infiniband_p_key (ifcfg, &p_key, &parent, error)) { + g_object_unref (s_infiniband); + return NULL; + } + + g_object_set (s_infiniband, + NM_SETTING_INFINIBAND_P_KEY, p_key, + NM_SETTING_INFINIBAND_PARENT, parent, + NULL); + } + + return (NMSetting *) s_infiniband; +} + +static NMConnection * +infiniband_connection_from_ifcfg (const char *file, + shvarFile *ifcfg, + GError **error) +{ + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *infiniband_setting = NULL; + + g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail (ifcfg != NULL, NULL); + + connection = nm_simple_connection_new (); + + con_setting = make_connection_setting (file, ifcfg, NM_SETTING_INFINIBAND_SETTING_NAME, NULL, NULL); + if (!con_setting) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); + g_object_unref (connection); + return NULL; + } + check_if_slave (ifcfg, (NMSettingConnection *) con_setting); + nm_connection_add_setting (connection, con_setting); + + infiniband_setting = make_infiniband_setting (ifcfg, file, error); + if (!infiniband_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, infiniband_setting); + + return connection; +} + +static void +handle_bond_option (NMSettingBond *s_bond, + const char *key, + const char *value) +{ + char *sanitized = NULL, *j; + const char *p = value; + + /* Remove any quotes or +/- from arp_ip_target */ + if (!g_strcmp0 (key, NM_SETTING_BOND_OPTION_ARP_IP_TARGET) && value && value[0]) { + if (*p == '\'' || *p == '"') + p++; + j = sanitized = g_malloc0 (strlen (p) + 1); + while (*p) { + if (*p != '+' && *p != '-' && *p != '\'' && *p != '"') + *j++ = *p; + p++; + } + } + + if (!nm_setting_bond_add_option (s_bond, key, sanitized ? sanitized : value)) + PARSE_WARNING ("invalid bonding option '%s' = %s", + key, sanitized ? sanitized : value); + g_free (sanitized); +} + +static NMSetting * +make_bond_setting (shvarFile *ifcfg, + const char *file, + GError **error) +{ + NMSettingBond *s_bond; + char *value; + + s_bond = NM_SETTING_BOND (nm_setting_bond_new ()); + + value = svGetValueString (ifcfg, "DEVICE"); + if (!value || !strlen (value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); + goto error; + } + g_free (value); + + value = svGetValueString (ifcfg, "BONDING_OPTS"); + if (value) { + char **items, **iter; + + items = g_strsplit_set (value, " ", -1); + for (iter = items; iter && *iter; iter++) { + if (strlen (*iter)) { + char **keys, *key, *val; + + keys = g_strsplit_set (*iter, "=", 2); + if (keys && *keys) { + key = *keys; + val = *(keys + 1); + if (val && strlen(key) && strlen(val)) + handle_bond_option (s_bond, key, val); + } + + g_strfreev (keys); + } + } + g_free (value); + g_strfreev (items); + } + + return (NMSetting *) s_bond; + +error: + g_object_unref (s_bond); + return NULL; +} + +static NMConnection * +bond_connection_from_ifcfg (const char *file, + shvarFile *ifcfg, + GError **error) +{ + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *bond_setting = NULL; + NMSetting *wired_setting = NULL; + NMSetting8021x *s_8021x = NULL; + + g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail (ifcfg != NULL, NULL); + + connection = nm_simple_connection_new (); + + con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BOND_SETTING_NAME, NULL, _("Bond")); + if (!con_setting) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, con_setting); + + bond_setting = make_bond_setting (ifcfg, file, error); + if (!bond_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, bond_setting); + + wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); + if (!wired_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, wired_setting); + + if (s_8021x) + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + + return connection; +} + +/* Check 'error' for errors. Missing config (NULL return value) is a valid case. */ +static char * +read_team_config (shvarFile *ifcfg, const char *key, GError **error) +{ + gs_free_error GError *local_error = NULL; + gs_free char *value = NULL; + size_t l; + + value = svGetValueString (ifcfg, key); + if (!value) + return NULL; + + l = strlen (value); + if (l > 1*1024*1024) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "%s too long (size %zd)", key, l); + return NULL; + } + + if (!nm_utils_is_json_object (value, &local_error)) { + PARSE_WARNING ("ignoring invalid team configuration: %s", local_error->message); + return NULL; + } + + return g_steal_pointer (&value); +} + +static NMSetting * +make_team_setting (shvarFile *ifcfg, + const char *file, + GError **error) +{ + NMSettingTeam *s_team; + char *value; + GError *local_err = NULL; + + s_team = NM_SETTING_TEAM (nm_setting_team_new ()); + + value = svGetValueString (ifcfg, "DEVICE"); + if (!value || !strlen (value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); + goto error; + } + g_free (value); + + value = read_team_config (ifcfg, "TEAM_CONFIG", &local_err); + if (local_err) { + g_propagate_error (error, local_err); + goto error; + } + g_object_set (s_team, NM_SETTING_TEAM_CONFIG, value, NULL); + g_free (value); + + return (NMSetting *) s_team; + +error: + g_object_unref (s_team); + return NULL; +} + +static NMConnection * +team_connection_from_ifcfg (const char *file, + shvarFile *ifcfg, + GError **error) +{ + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *team_setting = NULL; + NMSetting *wired_setting = NULL; + NMSetting8021x *s_8021x = NULL; + + g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail (ifcfg != NULL, NULL); + + connection = nm_simple_connection_new (); + + con_setting = make_connection_setting (file, ifcfg, NM_SETTING_TEAM_SETTING_NAME, NULL, _("Team")); + if (!con_setting) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, con_setting); + + team_setting = make_team_setting (ifcfg, file, error); + if (!team_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, team_setting); + + wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); + if (!wired_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, wired_setting); + + if (s_8021x) + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + + return connection; +} + +typedef void (*BridgeOptFunc) (NMSetting *setting, + gboolean stp, + const char *key, + const char *value); + +static void +handle_bridge_option (NMSetting *setting, + gboolean stp, + const char *key, + const char *value) +{ + guint32 u = 0; + + if (!strcmp (key, "priority")) { + if (stp == FALSE) { + PARSE_WARNING ("'priority' invalid when STP is disabled"); + } else if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_PRIORITY, u, NULL); + else + PARSE_WARNING ("invalid priority value '%s'", value); + } else if (!strcmp (key, "hello_time")) { + if (stp == FALSE) { + PARSE_WARNING ("'hello_time' invalid when STP is disabled"); + } else if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_HELLO_TIME, u, NULL); + else + PARSE_WARNING ("invalid hello_time value '%s'", value); + } else if (!strcmp (key, "max_age")) { + if (stp == FALSE) { + PARSE_WARNING ("'max_age' invalid when STP is disabled"); + } else if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_MAX_AGE, u, NULL); + else + PARSE_WARNING ("invalid max_age value '%s'", value); + } else if (!strcmp (key, "ageing_time")) { + if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_AGEING_TIME, u, NULL); + else + PARSE_WARNING ("invalid ageing_time value '%s'", value); + } else if (!strcmp (key, "multicast_snooping")) { + if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_MULTICAST_SNOOPING, + (gboolean) u, NULL); + else + PARSE_WARNING ("invalid multicast_snooping value '%s'", value); + } else + PARSE_WARNING ("unhandled bridge option '%s'", key); +} + +static void +handle_bridging_opts (NMSetting *setting, + gboolean stp, + const char *value, + BridgeOptFunc func) +{ + char **items, **iter; + + items = g_strsplit_set (value, " ", -1); + for (iter = items; iter && *iter; iter++) { + if (strlen (*iter)) { + char **keys, *key, *val; + + keys = g_strsplit_set (*iter, "=", 2); + if (keys && *keys) { + key = *keys; + val = *(keys + 1); + if (val && strlen(key) && strlen(val)) + func (setting, stp, key, val); + } + + g_strfreev (keys); + } + } + g_strfreev (items); +} + +static NMSetting * +make_bridge_setting (shvarFile *ifcfg, + const char *file, + GError **error) +{ + NMSettingBridge *s_bridge; + char *value; + guint32 u; + gboolean stp = FALSE; + gboolean stp_set = FALSE; + + s_bridge = NM_SETTING_BRIDGE (nm_setting_bridge_new ()); + + value = svGetValueString (ifcfg, "DEVICE"); + if (!value || !strlen (value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); + goto error; + } + g_free (value); + + value = svGetValueString (ifcfg, "MACADDR"); + if (value) { + value = g_strstrip (value); + g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "STP"); + if (value) { + if (!strcasecmp (value, "on") || !strcasecmp (value, "yes")) { + g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, TRUE, NULL); + stp = TRUE; + stp_set = TRUE; + } else if (!strcasecmp (value, "off") || !strcasecmp (value, "no")) { + g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL); + stp_set = TRUE; + } else + PARSE_WARNING ("invalid STP value '%s'", value); + g_free (value); + } + + if (!stp_set) { + /* Missing or invalid STP property means "no" */ + g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL); + } + + value = svGetValueString (ifcfg, "DELAY"); + if (value) { + if (stp) { + if (get_uint (value, &u)) + g_object_set (s_bridge, NM_SETTING_BRIDGE_FORWARD_DELAY, u, NULL); + else + PARSE_WARNING ("invalid forward delay value '%s'", value); + } else + PARSE_WARNING ("DELAY invalid when STP is disabled"); + g_free (value); + } + + value = svGetValueString (ifcfg, "BRIDGING_OPTS"); + if (value) { + handle_bridging_opts (NM_SETTING (s_bridge), stp, value, handle_bridge_option); + g_free (value); + } + + return (NMSetting *) s_bridge; + +error: + g_object_unref (s_bridge); + return NULL; +} + +static NMConnection * +bridge_connection_from_ifcfg (const char *file, + shvarFile *ifcfg, + GError **error) +{ + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *bridge_setting = NULL; + + g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail (ifcfg != NULL, NULL); + + connection = nm_simple_connection_new (); + + con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BRIDGE_SETTING_NAME, NULL, _("Bridge")); + if (!con_setting) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, con_setting); + + bridge_setting = make_bridge_setting (ifcfg, file, error); + if (!bridge_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, bridge_setting); + + return connection; +} + +static void +handle_bridge_port_option (NMSetting *setting, + gboolean stp, + const char *key, + const char *value) +{ + guint32 u = 0; + + if (!strcmp (key, "priority")) { + if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_PORT_PRIORITY, u, NULL); + else + PARSE_WARNING ("invalid priority value '%s'", value); + } else if (!strcmp (key, "path_cost")) { + if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_PORT_PATH_COST, u, NULL); + else + PARSE_WARNING ("invalid path_cost value '%s'", value); + } else if (!strcmp (key, "hairpin_mode")) { + if (!strcasecmp (value, "on") || !strcasecmp (value, "yes") || !strcmp (value, "1")) + g_object_set (setting, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, TRUE, NULL); + else if (!strcasecmp (value, "off") || !strcasecmp (value, "no")) + g_object_set (setting, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, FALSE, NULL); + else + PARSE_WARNING ("invalid hairpin_mode value '%s'", value); + } else + PARSE_WARNING ("unhandled bridge port option '%s'", key); +} + +static NMSetting * +make_bridge_port_setting (shvarFile *ifcfg) +{ + NMSetting *s_port = NULL; + char *value; + + g_return_val_if_fail (ifcfg != NULL, FALSE); + + value = svGetValueString (ifcfg, "BRIDGE_UUID"); + if (!value) + value = svGetValueString (ifcfg, "BRIDGE"); + if (value) { + g_free (value); + + s_port = nm_setting_bridge_port_new (); + value = svGetValueString (ifcfg, "BRIDGING_OPTS"); + if (value) + handle_bridging_opts (s_port, FALSE, value, handle_bridge_port_option); + g_free (value); + } + + return s_port; +} + +static NMSetting * +make_team_port_setting (shvarFile *ifcfg) +{ + NMSetting *s_port = NULL; + char *value; + GError *error = NULL; + + value = read_team_config (ifcfg, "TEAM_PORT_CONFIG", &error); + if (value) { + s_port = nm_setting_team_port_new (); + g_object_set (s_port, NM_SETTING_TEAM_PORT_CONFIG, value, NULL); + g_free (value); + } else if (error) { + PARSE_WARNING ("%s", error->message); + g_error_free (error); + } + + return s_port; +} + +static gboolean +is_bond_device (const char *name, shvarFile *parsed) +{ + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (parsed != NULL, FALSE); + + if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE)) + return TRUE; + + return FALSE; +} + +static gboolean +is_vlan_device (const char *name, shvarFile *parsed) +{ + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (parsed != NULL, FALSE); + + if (svGetValueBoolean (parsed, "VLAN", FALSE)) + return TRUE; + + return FALSE; +} + +static gboolean +is_wifi_device (const char *name, shvarFile *parsed) +{ + int ifindex; + + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (parsed != NULL, FALSE); + + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, name); + if (ifindex == 0) + return FALSE; + + return nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) == NM_LINK_TYPE_WIFI; +} + +static void +parse_prio_map_list (NMSettingVlan *s_vlan, + shvarFile *ifcfg, + const char *key, + NMVlanPriorityMap map) +{ + char *value; + gchar **list = NULL, **iter; + + value = svGetValueString (ifcfg, key); + if (!value) + return; + + list = g_strsplit_set (value, ",", -1); + g_free (value); + + for (iter = list; iter && *iter; iter++) { + if (!*iter || !strchr (*iter, ':')) + continue; + + if (!nm_setting_vlan_add_priority_str (s_vlan, map, *iter)) + PARSE_WARNING ("invalid %s priority map item '%s'", key, *iter); + } + g_strfreev (list); +} + +static NMSetting * +make_vlan_setting (shvarFile *ifcfg, + const char *file, + GError **error) +{ + NMSettingVlan *s_vlan = NULL; + char *value = NULL; + char *iface_name = NULL; + char *parent = NULL; + const char *p = NULL; + int vlan_id = -1; + guint32 vlan_flags = 0; + gint gvrp, reorder_hdr; + + value = svGetValueString (ifcfg, "VLAN_ID"); + if (value) { + vlan_id = _nm_utils_ascii_str_to_int64 (value, 10, 0, 4095, -1); + if (vlan_id == -1) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid VLAN_ID '%s'", value); + g_free (value); + return NULL; + } + g_free (value); + } + + /* Need DEVICE if we don't have a separate VLAN_ID property */ + iface_name = svGetValueString (ifcfg, "DEVICE"); + if (!iface_name && vlan_id < 0) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing DEVICE property; cannot determine VLAN ID."); + return NULL; + } + + s_vlan = NM_SETTING_VLAN (nm_setting_vlan_new ()); + + /* Parent interface from PHYSDEV takes precedence if it exists */ + parent = svGetValueString (ifcfg, "PHYSDEV"); + + if (iface_name) { + p = strchr (iface_name, '.'); + if (p) { + /* eth0.43; PHYSDEV is assumed from it if unknown */ + if (!parent) { + parent = g_strndup (iface_name, p - iface_name); + if (g_str_has_prefix (parent, "vlan")) { + /* Like initscripts, if no PHYSDEV and we get an obviously + * invalid parent interface from DEVICE, fail. + */ + g_free (parent); + parent = NULL; + } + } + p++; + } else { + /* format like vlan43; PHYSDEV must be set */ + if (g_str_has_prefix (iface_name, "vlan")) + p = iface_name + 4; + } + + if (p) { + int device_vlan_id; + + /* Grab VLAN ID from interface name; this takes precedence over the + * separate VLAN_ID property for backwards compat. + */ + device_vlan_id = _nm_utils_ascii_str_to_int64 (p, 10, 0, 4095, -1); + if (device_vlan_id != -1) + vlan_id = device_vlan_id; + } + } + + if (vlan_id < 0) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to determine VLAN ID from DEVICE or VLAN_ID."); + goto error; + } + g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL); + + if (parent == NULL) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to determine VLAN parent from DEVICE or PHYSDEV"); + goto error; + } + g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, parent, NULL); + g_clear_pointer (&parent, g_free); + + vlan_flags |= NM_VLAN_FLAG_REORDER_HEADERS; + + gvrp = svGetValueBoolean (ifcfg, "GVRP", -1); + if (gvrp > 0) + vlan_flags |= NM_VLAN_FLAG_GVRP; + + value = svGetValueString (ifcfg, "VLAN_FLAGS"); + if (value) { + gs_strfreev char **strv = NULL; + char **ptr; + + strv = g_strsplit_set (value, ", ", 0); + + for (ptr = strv; ptr && *ptr; ptr++) { + if (nm_streq (*ptr, "GVRP") && gvrp == -1) + vlan_flags |= NM_VLAN_FLAG_GVRP; + if (nm_streq (*ptr, "LOOSE_BINDING")) + vlan_flags |= NM_VLAN_FLAG_LOOSE_BINDING; + if (nm_streq (*ptr, "NO_REORDER_HDR")) + vlan_flags &= ~NM_VLAN_FLAG_REORDER_HEADERS; + } + } + + reorder_hdr = svGetValueBoolean (ifcfg, "REORDER_HDR", -1); + if ( reorder_hdr != -1 + && reorder_hdr != NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)) + PARSE_WARNING ("REORDER_HDR key is deprecated, use VLAN_FLAGS"); + + if (svGetValueBoolean (ifcfg, "MVRP", FALSE)) + vlan_flags |= NM_VLAN_FLAG_MVRP; + + g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, vlan_flags, NULL); + g_free (value); + + parse_prio_map_list (s_vlan, ifcfg, "VLAN_INGRESS_PRIORITY_MAP", NM_VLAN_INGRESS_MAP); + parse_prio_map_list (s_vlan, ifcfg, "VLAN_EGRESS_PRIORITY_MAP", NM_VLAN_EGRESS_MAP); + + g_free (iface_name); + + return (NMSetting *) s_vlan; + +error: + g_free (parent); + g_free (iface_name); + g_object_unref (s_vlan); + return NULL; +} + +static NMConnection * +vlan_connection_from_ifcfg (const char *file, + shvarFile *ifcfg, + GError **error) +{ + NMConnection *connection = NULL; + NMSetting *con_setting = NULL; + NMSetting *wired_setting = NULL; + NMSetting *vlan_setting = NULL; + NMSetting8021x *s_8021x = NULL; + + g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail (ifcfg != NULL, NULL); + + connection = nm_simple_connection_new (); + + con_setting = make_connection_setting (file, ifcfg, NM_SETTING_VLAN_SETTING_NAME, NULL, "Vlan"); + if (!con_setting) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); + g_object_unref (connection); + return NULL; + } + check_if_slave (ifcfg, (NMSettingConnection *) con_setting); + nm_connection_add_setting (connection, con_setting); + + vlan_setting = make_vlan_setting (ifcfg, file, error); + if (!vlan_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, vlan_setting); + + wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); + if (!wired_setting) { + g_object_unref (connection); + return NULL; + } + nm_connection_add_setting (connection, wired_setting); + + if (s_8021x) + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + + return connection; +} + +static NMConnection * +create_unhandled_connection (const char *filename, shvarFile *ifcfg, + const char *type, char **out_spec) +{ + NMConnection *connection; + NMSetting *s_con; + char *value; + + nm_assert (out_spec && !*out_spec); + + connection = nm_simple_connection_new (); + + /* Get NAME, UUID, etc. We need to set a connection type (generic) and add + * an empty type-specific setting as well, to make sure it passes + * nm_connection_verify() later. + */ + s_con = make_connection_setting (filename, ifcfg, NM_SETTING_GENERIC_SETTING_NAME, + NULL, NULL); + nm_connection_add_setting (connection, s_con); + + nm_connection_add_setting (connection, nm_setting_generic_new ()); + + /* Get a spec */ + value = svGetValueString (ifcfg, "HWADDR"); + if (value) { + char *lower = g_ascii_strdown (value, -1); + *out_spec = g_strdup_printf ("%s:mac:%s", type, lower); + g_free (lower); + g_free (value); + return connection; + } + + value = svGetValueString (ifcfg, "SUBCHANNELS"); + if (value) { + *out_spec = g_strdup_printf ("%s:s390-subchannels:%s", type, value); + g_free (value); + return connection; + } + + value = svGetValueString (ifcfg, "DEVICE"); + if (value) { + *out_spec = g_strdup_printf ("%s:interface-name:%s", type, value); + g_free (value); + return connection; + } + + g_object_unref (connection); + return NULL; +} + +char * +uuid_from_file (const char *filename) +{ + const char *ifcfg_name = NULL; + shvarFile *ifcfg; + char *uuid; + + g_return_val_if_fail (filename != NULL, NULL); + + ifcfg_name = utils_get_ifcfg_name (filename, TRUE); + if (!ifcfg_name) + return NULL; + + ifcfg = svOpenFile (filename, NULL); + if (!ifcfg) + return NULL; + + /* Try for a UUID key before falling back to hashing the file name */ + uuid = svGetValueString (ifcfg, "UUID"); + if (!uuid || !strlen (uuid)) { + g_free (uuid); + uuid = nm_utils_uuid_generate_from_string (svFileGetName (ifcfg), -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); + } + + svCloseFile (ifcfg); + return uuid; +} + +static void +check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) +{ + if (!s_ip6) + return; + + /* If there is no IPv4 config or it doesn't contain DNS searches, + * read DOMAIN and put the domains into IPv6. + */ + if (!s_ip4 || nm_setting_ip_config_get_num_dns_searches (NM_SETTING_IP_CONFIG (s_ip4)) == 0) { + /* DNS searches */ + char *value = svGetValueString (ifcfg, "DOMAIN"); + if (value) { + char **searches = g_strsplit (value, " ", 0); + if (searches) { + char **item; + for (item = searches; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (s_ip6), *item)) + PARSE_WARNING ("duplicate DNS domain '%s'", *item); + } + } + g_strfreev (searches); + } + g_free (value); + } + } +} + +static NMConnection * +connection_from_file_full (const char *filename, + const char *network_file, /* for unit tests only */ + const char *test_type, /* for unit tests only */ + char **out_unhandled, + GError **error, + gboolean *out_ignore_error) +{ + NMConnection *connection = NULL; + shvarFile *parsed; + gs_free char *type = NULL; + char *devtype, *bootproto; + NMSetting *s_ip4, *s_ip6, *s_proxy, *s_port, *s_dcb = NULL; + const char *ifcfg_name = NULL; + + g_return_val_if_fail (filename != NULL, NULL); + g_return_val_if_fail (out_unhandled && !*out_unhandled, NULL); + + /* Non-NULL only for unit tests; normally use /etc/sysconfig/network */ + if (!network_file) + network_file = SYSCONFDIR "/sysconfig/network"; + + ifcfg_name = utils_get_ifcfg_name (filename, TRUE); + if (!ifcfg_name) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignoring connection '%s' because it's not an ifcfg file.", filename); + return NULL; + } + + parsed = svOpenFile (filename, error); + if (!parsed) + return NULL; + + if (!svGetValueBoolean (parsed, "NM_CONTROLLED", TRUE)) { + connection = create_unhandled_connection (filename, parsed, "unmanaged", out_unhandled); + if (!connection) + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "NM_CONTROLLED was false but device was not uniquely identified; device will be managed"); + goto done; + } + + /* iBFT is handled by the iBFT settings plugin */ + bootproto = svGetValueString (parsed, "BOOTPROTO"); + if (bootproto && !g_ascii_strcasecmp (bootproto, "ibft")) { + if (out_ignore_error) + *out_ignore_error = TRUE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignoring iBFT configuration"); + g_free (bootproto); + goto done; + } + g_free (bootproto); + + devtype = svGetValueString (parsed, "DEVICETYPE"); + if (devtype) { + if (!strcasecmp (devtype, TYPE_TEAM)) + type = g_strdup (TYPE_TEAM); + else if (!strcasecmp (devtype, TYPE_TEAM_PORT)) + type = g_strdup (TYPE_ETHERNET); + g_free (devtype); + } + if (!type) { + gs_free char *t = NULL; + + /* Team and TeamPort types are also accepted by the mere + * presense of TEAM_CONFIG/TEAM_MASTER. They don't require + * DEVICETYPE. */ + t = svGetValueString (parsed, "TEAM_CONFIG"); + if (t) + type = g_strdup (TYPE_TEAM); + } + + if (!type) + type = svGetValueString (parsed, "TYPE"); + + if (!type) { + gs_free char *tmp = NULL; + char *device; + + if ((tmp = svGetValueString (parsed, "IPV6TUNNELIPV4"))) { + if (out_ignore_error) + *out_ignore_error = TRUE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignoring unsupported connection due to IPV6TUNNELIPV4"); + goto done; + } + + device = svGetValueString (parsed, "DEVICE"); + if (!device) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "File '%s' had neither TYPE nor DEVICE keys.", filename); + goto done; + } + g_assert (device[0]); + + if (!strcmp (device, "lo")) { + if (out_ignore_error) + *out_ignore_error = TRUE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignoring loopback device config."); + g_free (device); + goto done; + } + + if (!test_type) { + if (is_bond_device (device, parsed)) + type = g_strdup (TYPE_BOND); + else if (is_vlan_device (device, parsed)) + type = g_strdup (TYPE_VLAN); + else if (is_wifi_device (device, parsed)) + type = g_strdup (TYPE_WIRELESS); + else { + gs_free char *p_path = NULL; + char *p_device; + gsize i; + + /* network-functions detects DEVICETYPE based on the ifcfg-* name and the existence + * of a ifup script: + * [ -z "$DEVICETYPE" ] && DEVICETYPE=$(echo ${DEVICE} | sed "s/[0-9]*$//") + * later... + * OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" + * */ +#define IFUP_PATH_PREFIX "/etc/sysconfig/network-scripts/ifup-" + i = strlen (device); + p_path = g_malloc (NM_STRLEN (IFUP_PATH_PREFIX) + i + 1); + p_device = &p_path[NM_STRLEN (IFUP_PATH_PREFIX)]; + memcpy (p_device, device, i + 1); + + /* strip trailing numbers */ + while (i >= 1) { + i--; + if (p_device[i] < '0' || p_device[i] > '9') + break; + p_device[i] = '\0'; + } + + if (nm_streq (p_device, "eth")) + type = g_strdup (TYPE_ETHERNET); + else if (nm_streq (p_device, "wireless")) + type = g_strdup (TYPE_WIRELESS); + else if (p_device[0]) { + memcpy (p_path, IFUP_PATH_PREFIX, NM_STRLEN (IFUP_PATH_PREFIX)); + if (access (p_path, X_OK) == 0) { + /* for all other types, this is not something we want to handle. */ + if (out_ignore_error) + *out_ignore_error = TRUE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignore script for unknown device type which has a matching %s script", + p_path); + goto done; + } + } + + if (!type) + type = g_strdup (TYPE_ETHERNET); + } + } else { + /* For the unit tests, there won't necessarily be any + * adapters of the connection's type in the system so the + * type can't be tested with ioctls. + */ + type = g_strdup (test_type); + } + + g_free (device); + } else { + /* Check for IBM s390 CTC devices and call them Ethernet */ + if (g_strcmp0 (type, "CTC") == 0) { + g_free (type); + type = g_strdup (TYPE_ETHERNET); + } + } + + if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE) && + strcasecmp (type, TYPE_BOND)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "BONDING_MASTER=yes key only allowed in TYPE=bond connections"); + goto done; + } + + /* Construct the connection */ + if (!strcasecmp (type, TYPE_ETHERNET)) + connection = wired_connection_from_ifcfg (filename, parsed, error); + else if (!strcasecmp (type, TYPE_WIRELESS)) + connection = wireless_connection_from_ifcfg (filename, parsed, error); + else if (!strcasecmp (type, TYPE_INFINIBAND)) + connection = infiniband_connection_from_ifcfg (filename, parsed, error); + else if (!strcasecmp (type, TYPE_BOND)) + connection = bond_connection_from_ifcfg (filename, parsed, error); + else if (!strcasecmp (type, TYPE_TEAM)) + connection = team_connection_from_ifcfg (filename, parsed, error); + else if (!strcasecmp (type, TYPE_VLAN)) + connection = vlan_connection_from_ifcfg (filename, parsed, error); + else if (!strcasecmp (type, TYPE_BRIDGE)) + connection = bridge_connection_from_ifcfg (filename, parsed, error); + else { + connection = create_unhandled_connection (filename, parsed, "unrecognized", out_unhandled); + if (!connection) + PARSE_WARNING ("connection type was unrecognized but device was not uniquely identified; device may be managed"); + goto done; + } + + if (!connection) + goto done; + + s_ip6 = make_ip6_setting (parsed, network_file, error); + if (!s_ip6) { + g_object_unref (connection); + connection = NULL; + goto done; + } else + nm_connection_add_setting (connection, s_ip6); + + s_ip4 = make_ip4_setting (parsed, network_file, error); + if (!s_ip4) { + g_object_unref (connection); + connection = NULL; + goto done; + } else { + read_aliases (NM_SETTING_IP_CONFIG (s_ip4), filename); + nm_connection_add_setting (connection, s_ip4); + } + + /* There is only one DOMAIN variable and it is read and put to IPv4 config + * But if IPv4 is disabled or the config fails for some reason, we read + * DOMAIN and put the values into IPv6 config instead. + */ + check_dns_search_domains (parsed, s_ip4, s_ip6); + + s_proxy = make_proxy_setting (parsed, error); + if (s_proxy) + nm_connection_add_setting (connection, s_proxy); + + /* Bridge port? */ + s_port = make_bridge_port_setting (parsed); + if (s_port) + nm_connection_add_setting (connection, s_port); + + /* Team port? */ + s_port = make_team_port_setting (parsed); + if (s_port) + nm_connection_add_setting (connection, s_port); + + if (!make_dcb_setting (parsed, network_file, &s_dcb, error)) { + g_object_unref (connection); + connection = NULL; + goto done; + } + if (s_dcb) + nm_connection_add_setting (connection, s_dcb); + + if (!nm_connection_normalize (connection, NULL, NULL, error)) { + g_object_unref (connection); + connection = NULL; + } + +done: + svCloseFile (parsed); + return connection; +} + +NMConnection * +connection_from_file (const char *filename, + char **out_unhandled, + GError **error, + gboolean *out_ignore_error) +{ + return connection_from_file_full (filename, NULL, NULL, + out_unhandled, + error, + out_ignore_error); +} + +NMConnection * +connection_from_file_test (const char *filename, + const char *network_file, + const char *test_type, + char **out_unhandled, + GError **error) +{ + return connection_from_file_full (filename, + network_file, + test_type, + out_unhandled, + error, + NULL); +} + +guint +devtimeout_from_file (const char *filename) +{ + shvarFile *ifcfg; + char *devtimeout_str; + guint devtimeout; + + g_return_val_if_fail (filename != NULL, 0); + + ifcfg = svOpenFile (filename, NULL); + if (!ifcfg) + return 0; + + devtimeout_str = svGetValueString (ifcfg, "DEVTIMEOUT"); + if (devtimeout_str) { + devtimeout = _nm_utils_ascii_str_to_int64 (devtimeout_str, 10, 0, G_MAXUINT, 0); + g_free (devtimeout_str); + } else + devtimeout = 0; + + svCloseFile (ifcfg); + + return devtimeout; +} diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h new file mode 100644 index 00000000..35464474 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Red Hat, Inc. + */ + +#ifndef __READER_H__ +#define __READER_H__ + +#include "nm-connection.h" + +NMConnection *connection_from_file (const char *filename, + char **out_unhandled, + GError **error, + gboolean *out_ignore_error); + +char *uuid_from_file (const char *filename); + +guint devtimeout_from_file (const char *filename); + +/* for test-ifcfg-rh */ +NMConnection *connection_from_file_test (const char *filename, + const char *network_file, + const char *test_type, + char **out_unhandled, + GError **error); + +#endif /* __READER_H__ */ diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c new file mode 100644 index 00000000..d1c00976 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c @@ -0,0 +1,365 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2008 - 2012 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifcfg-rh-utils.h" + +#include +#include + +#include "nm-core-internal.h" +#include "NetworkManagerUtils.h" + +#include "nms-ifcfg-rh-common.h" + +/* + * Check ';[a-fA-F0-9]{8}' file suffix used for temporary files by rpm when + * installing packages. + * + * Implementation taken from upstart. + */ +static gboolean +check_rpm_temp_suffix (const char *path) +{ + const char *ptr; + + g_return_val_if_fail (path != NULL, FALSE); + + /* Matches *;[a-fA-F0-9]{8}; used by rpm */ + ptr = strrchr (path, ';'); + if (ptr && (strspn (ptr + 1, "abcdefABCDEF0123456789") == 8) + && (! ptr[9])) + return TRUE; + return FALSE; +} + +static gboolean +check_suffix (const char *base, const char *tag) +{ + int len, tag_len; + + g_return_val_if_fail (base != NULL, TRUE); + g_return_val_if_fail (tag != NULL, TRUE); + + len = strlen (base); + tag_len = strlen (tag); + if ((len > tag_len) && !strcasecmp (base + len - tag_len, tag)) + return TRUE; + return FALSE; +} + +gboolean +utils_should_ignore_file (const char *filename, gboolean only_ifcfg) +{ + gs_free char *base = NULL; + + g_return_val_if_fail (filename != NULL, TRUE); + + base = g_path_get_basename (filename); + + /* Only handle ifcfg, keys, and routes files */ + if (strncmp (base, IFCFG_TAG, strlen (IFCFG_TAG)) != 0) { + if (only_ifcfg) + return TRUE; + else if ( strncmp (base, KEYS_TAG, strlen (KEYS_TAG)) != 0 + && strncmp (base, ROUTE_TAG, strlen (ROUTE_TAG)) != 0 + && strncmp (base, ROUTE6_TAG, strlen (ROUTE6_TAG)) != 0) + return TRUE; + } + + /* But not those that have certain suffixes */ + if ( check_suffix (base, BAK_TAG) + || check_suffix (base, TILDE_TAG) + || check_suffix (base, ORIG_TAG) + || check_suffix (base, REJ_TAG) + || check_suffix (base, RPMNEW_TAG) + || check_suffix (base, AUGNEW_TAG) + || check_suffix (base, AUGTMP_TAG) + || check_rpm_temp_suffix (base)) + return TRUE; + + return FALSE; +} + +char * +utils_cert_path (const char *parent, const char *suffix) +{ + const char *name; + char *dir, *path; + + g_return_val_if_fail (parent != NULL, NULL); + g_return_val_if_fail (suffix != NULL, NULL); + + name = utils_get_ifcfg_name (parent, FALSE); + dir = g_path_get_dirname (parent); + path = g_strdup_printf ("%s/%s-%s", dir, name, suffix); + g_free (dir); + return path; +} + +const char * +utils_get_ifcfg_name (const char *file, gboolean only_ifcfg) +{ + const char *name; + + g_return_val_if_fail (file != NULL, NULL); + + name = strrchr (file, '/'); + if (!name) + name = file; + else + name++; + if (!*name) + return NULL; + +#define MATCH_TAG_AND_RETURN(name, TAG) \ + G_STMT_START { \ + if (strncmp (name, TAG, NM_STRLEN (TAG)) == 0) { \ + name += NM_STRLEN (TAG); \ + if (name[0] == '\0') \ + return NULL; \ + else \ + return name; \ + } \ + } G_STMT_END + + /* Do not detect alias files and return 'eth0:0' instead of 'eth0'. + * Unfortunately, we cannot be sure that our files don't contain colons, + * so we cannot reject files with colons. + * + * Instead, you must not call utils_get_ifcfg_name() with an alias file + * or files that are ignored. */ + MATCH_TAG_AND_RETURN (name, IFCFG_TAG); + if (!only_ifcfg) { + MATCH_TAG_AND_RETURN (name, KEYS_TAG); + MATCH_TAG_AND_RETURN (name, ROUTE_TAG); + MATCH_TAG_AND_RETURN (name, ROUTE6_TAG); + } + + return NULL; +} + +/* Used to get any ifcfg/extra file path from any other ifcfg/extra path + * in the form . + */ +static char * +utils_get_extra_path (const char *parent, const char *tag) +{ + char *item_path = NULL, *dirname; + const char *name; + + g_return_val_if_fail (parent != NULL, NULL); + g_return_val_if_fail (tag != NULL, NULL); + + dirname = g_path_get_dirname (parent); + if (!dirname) + return NULL; + + name = utils_get_ifcfg_name (parent, FALSE); + if (name) { + if (!strcmp (dirname, ".")) + item_path = g_strdup_printf ("%s%s", tag, name); + else + item_path = g_strdup_printf ("%s/%s%s", dirname, tag, name); + } + g_free (dirname); + + return item_path; +} + +char * +utils_get_ifcfg_path (const char *parent) +{ + return utils_get_extra_path (parent, IFCFG_TAG); +} + +char * +utils_get_keys_path (const char *parent) +{ + return utils_get_extra_path (parent, KEYS_TAG); +} + +char * +utils_get_route_path (const char *parent) +{ + return utils_get_extra_path (parent, ROUTE_TAG); +} + +char * +utils_get_route6_path (const char *parent) +{ + return utils_get_extra_path (parent, ROUTE6_TAG); +} + +shvarFile * +utils_get_extra_ifcfg (const char *parent, const char *tag, gboolean should_create) +{ + shvarFile *ifcfg = NULL; + char *path; + + path = utils_get_extra_path (parent, tag); + if (!path) + return NULL; + + if (should_create && !g_file_test (path, G_FILE_TEST_EXISTS)) + ifcfg = svCreateFile (path); + + if (!ifcfg) + ifcfg = svOpenFile (path, NULL); + + g_free (path); + return ifcfg; +} + +shvarFile * +utils_get_keys_ifcfg (const char *parent, gboolean should_create) +{ + return utils_get_extra_ifcfg (parent, KEYS_TAG, should_create); +} + +shvarFile * +utils_get_route_ifcfg (const char *parent, gboolean should_create) +{ + return utils_get_extra_ifcfg (parent, ROUTE_TAG, should_create); +} + +shvarFile * +utils_get_route6_ifcfg (const char *parent, gboolean should_create) +{ + return utils_get_extra_ifcfg (parent, ROUTE6_TAG, should_create); +} + +/* Finds out if route file has new or older format + * Returns TRUE - new syntax (ADDRESS=a.b.c.d ...), error opening file or empty + * FALSE - older syntax, i.e. argument to 'ip route add' (1.2.3.0/24 via 11.22.33.44) + */ +gboolean +utils_has_route_file_new_syntax (const char *filename) +{ + char *contents = NULL; + gsize len = 0; + gboolean ret = FALSE; + const char *pattern = "^[[:space:]]*ADDRESS[0-9]+="; + + g_return_val_if_fail (filename != NULL, TRUE); + + if (!g_file_get_contents (filename, &contents, &len, NULL)) + return TRUE; + + if (len <= 0) { + ret = TRUE; + goto gone; + } + + if (g_regex_match_simple (pattern, contents, G_REGEX_MULTILINE, 0)) + ret = TRUE; + +gone: + g_free (contents); + return ret; +} + +gboolean +utils_has_complex_routes (const char *filename) +{ + char *rules; + + g_return_val_if_fail (filename != NULL, TRUE); + + rules = utils_get_extra_path (filename, RULE_TAG); + if (g_file_test (rules, G_FILE_TEST_EXISTS)) { + g_free (rules); + return TRUE; + } + g_free (rules); + + rules = utils_get_extra_path (filename, RULE6_TAG); + if (g_file_test (rules, G_FILE_TEST_EXISTS)) { + g_free (rules); + return TRUE; + } + g_free (rules); + + return FALSE; +} + +/* Find out if the 'alias' file name might be an alias file for 'ifcfg' file name, + * or any alias when 'ifcfg' is NULL. Does not check that it's actually a valid + * alias name; that happens in reader.c + */ +gboolean +utils_is_ifcfg_alias_file (const char *alias, const char *ifcfg) +{ + g_return_val_if_fail (alias != NULL, FALSE); + + if (strncmp (alias, IFCFG_TAG, strlen (IFCFG_TAG))) + return FALSE; + + if (ifcfg) { + size_t len = strlen (ifcfg); + + return (strncmp (alias, ifcfg, len) == 0 && alias[len] == ':'); + } else { + return (strchr (alias, ':') != NULL); + } +} + +char * +utils_detect_ifcfg_path (const char *path, gboolean only_ifcfg) +{ + gs_free char *base = NULL; + char *ptr, *ifcfg = NULL; + + g_return_val_if_fail (path != NULL, NULL); + + if (utils_should_ignore_file (path, only_ifcfg)) + return NULL; + + base = g_path_get_basename (path); + + if (strncmp (base, IFCFG_TAG, NM_STRLEN (IFCFG_TAG)) == 0) { + if (base[NM_STRLEN (IFCFG_TAG)] == '\0') + return NULL; + if (utils_is_ifcfg_alias_file (base, NULL)) { + ifcfg = g_strdup (path); + ptr = strrchr (ifcfg, ':'); + if (ptr && ptr > ifcfg) { + *ptr = '\0'; + if (g_file_test (ifcfg, G_FILE_TEST_EXISTS)) { + /* the file has a colon, so it is probably an alias. + * To be ~more~ certain that this is an alias file, + * check whether a corresponding base file exists. */ + if (only_ifcfg) { + g_free (ifcfg); + return NULL; + } + return ifcfg; + } + } + g_free (ifcfg); + } + return g_strdup (path); + } + + if (only_ifcfg) + return NULL; + return utils_get_ifcfg_path (path); +} diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h new file mode 100644 index 00000000..af0469e6 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h @@ -0,0 +1,58 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2008 - 2012 Red Hat, Inc. + */ + +#ifndef _UTILS_H_ +#define _UTILS_H_ + +#include "nm-connection.h" + +#include "shvar.h" + +#define NM_IFCFG_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") +#define NM_IFCFG_CONNECTION_LOG_FMT "%s (%s,\"%s\")" +#define NM_IFCFG_CONNECTION_LOG_ARG(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) +#define NM_IFCFG_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" +#define NM_IFCFG_CONNECTION_LOG_ARGD(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con) + +char *utils_cert_path (const char *parent, const char *suffix); + +const char *utils_get_ifcfg_name (const char *file, gboolean only_ifcfg); + +gboolean utils_should_ignore_file (const char *filename, gboolean only_ifcfg); + +char *utils_get_ifcfg_path (const char *parent); +char *utils_get_keys_path (const char *parent); +char *utils_get_route_path (const char *parent); +char *utils_get_route6_path (const char *parent); + +shvarFile *utils_get_extra_ifcfg (const char *parent, const char *tag, gboolean should_create); +shvarFile *utils_get_keys_ifcfg (const char *parent, gboolean should_create); +shvarFile *utils_get_route_ifcfg (const char *parent, gboolean should_create); +shvarFile *utils_get_route6_ifcfg (const char *parent, gboolean should_create); + +gboolean utils_has_route_file_new_syntax (const char *filename); +gboolean utils_has_complex_routes (const char *filename); + +gboolean utils_is_ifcfg_alias_file (const char *alias, const char *ifcfg); + +char *utils_detect_ifcfg_path (const char *path, gboolean only_ifcfg); + +#endif /* _UTILS_H_ */ + diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c new file mode 100644 index 00000000..90a8e7ac --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -0,0 +1,2965 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2009 - 2015 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifcfg-rh-writer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-manager.h" +#include "nm-setting-connection.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-8021x.h" +#include "nm-setting-proxy.h" +#include "nm-setting-ip4-config.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-vlan.h" +#include "nm-setting-team.h" +#include "nm-setting-team-port.h" +#include "nm-utils.h" +#include "nm-core-internal.h" +#include "NetworkManagerUtils.h" + +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-reader.h" +#include "nms-ifcfg-rh-utils.h" +#include "shvar.h" + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG_PREFIX_NAME "ifcfg-rh" +#define _NMLOG(level, ...) \ + G_STMT_START { \ + nm_log ((level), (_NMLOG_DOMAIN), \ + "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + _NMLOG_PREFIX_NAME": " \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + +/*****************************************************************************/ + +static void +save_secret_flags (shvarFile *ifcfg, + const char *key, + NMSettingSecretFlags flags) +{ + GString *str; + + g_return_if_fail (ifcfg != NULL); + g_return_if_fail (key != NULL); + + if (flags == NM_SETTING_SECRET_FLAG_NONE) { + svUnsetValue (ifcfg, key); + return; + } + + /* Convert flags bitfield into string representation */ + str = g_string_sized_new (20); + if (flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED) + g_string_append (str, SECRET_FLAG_AGENT); + + if (flags & NM_SETTING_SECRET_FLAG_NOT_SAVED) { + if (str->len) + g_string_append_c (str, ' '); + g_string_append (str, SECRET_FLAG_NOT_SAVED); + } + + if (flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) { + if (str->len) + g_string_append_c (str, ' '); + g_string_append (str, SECRET_FLAG_NOT_REQUIRED); + } + + svSetValueString (ifcfg, key, str->len ? str->str : NULL); + g_string_free (str, TRUE); +} + +static void +set_secret (shvarFile *ifcfg, + const char *key, + const char *value, + const char *flags_key, + NMSettingSecretFlags flags) +{ + shvarFile *keyfile; + GError *error = NULL; + + /* Clear the secret from the ifcfg and the associated "keys" file */ + svUnsetValue (ifcfg, key); + + /* Save secret flags */ + save_secret_flags (ifcfg, flags_key, flags); + + keyfile = utils_get_keys_ifcfg (svFileGetName (ifcfg), TRUE); + if (!keyfile) { + _LOGW ("could not create ifcfg file for '%s'", svFileGetName (ifcfg)); + goto error; + } + + /* Only write the secret if it's system owned and supposed to be saved */ + if (flags == NM_SETTING_SECRET_FLAG_NONE) + svSetValueString (keyfile, key, value); + else + svUnsetValue (keyfile, key); + + if (!svWriteFile (keyfile, 0600, &error)) { + _LOGW ("could not update ifcfg file '%s': %s", + svFileGetName (keyfile), error->message); + g_clear_error (&error); + svCloseFile (keyfile); + goto error; + } + svCloseFile (keyfile); + return; + +error: + /* Try setting the secret in the actual ifcfg */ + svSetValueString (ifcfg, key, value); +} + +typedef struct ObjectType { + const char *setting_key; + NMSetting8021xCKScheme (*scheme_func)(NMSetting8021x *setting); + const char * (*path_func) (NMSetting8021x *setting); + GBytes * (*blob_func) (NMSetting8021x *setting); + const char *ifcfg_key; + const char *suffix; +} ObjectType; + +static const ObjectType ca_type = { + NM_SETTING_802_1X_CA_CERT, + nm_setting_802_1x_get_ca_cert_scheme, + nm_setting_802_1x_get_ca_cert_path, + nm_setting_802_1x_get_ca_cert_blob, + "IEEE_8021X_CA_CERT", + "ca-cert.der" +}; + +static const ObjectType phase2_ca_type = { + NM_SETTING_802_1X_PHASE2_CA_CERT, + nm_setting_802_1x_get_phase2_ca_cert_scheme, + nm_setting_802_1x_get_phase2_ca_cert_path, + nm_setting_802_1x_get_phase2_ca_cert_blob, + "IEEE_8021X_INNER_CA_CERT", + "inner-ca-cert.der" +}; + +static const ObjectType client_type = { + NM_SETTING_802_1X_CLIENT_CERT, + nm_setting_802_1x_get_client_cert_scheme, + nm_setting_802_1x_get_client_cert_path, + nm_setting_802_1x_get_client_cert_blob, + "IEEE_8021X_CLIENT_CERT", + "client-cert.der" +}; + +static const ObjectType phase2_client_type = { + NM_SETTING_802_1X_PHASE2_CLIENT_CERT, + nm_setting_802_1x_get_phase2_client_cert_scheme, + nm_setting_802_1x_get_phase2_client_cert_path, + nm_setting_802_1x_get_phase2_client_cert_blob, + "IEEE_8021X_INNER_CLIENT_CERT", + "inner-client-cert.der" +}; + +static const ObjectType pk_type = { + NM_SETTING_802_1X_PRIVATE_KEY, + nm_setting_802_1x_get_private_key_scheme, + nm_setting_802_1x_get_private_key_path, + nm_setting_802_1x_get_private_key_blob, + "IEEE_8021X_PRIVATE_KEY", + "private-key.pem" +}; + +static const ObjectType phase2_pk_type = { + NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, + nm_setting_802_1x_get_phase2_private_key_scheme, + nm_setting_802_1x_get_phase2_private_key_path, + nm_setting_802_1x_get_phase2_private_key_blob, + "IEEE_8021X_INNER_PRIVATE_KEY", + "inner-private-key.pem" +}; + +static const ObjectType p12_type = { + NM_SETTING_802_1X_PRIVATE_KEY, + nm_setting_802_1x_get_private_key_scheme, + nm_setting_802_1x_get_private_key_path, + nm_setting_802_1x_get_private_key_blob, + "IEEE_8021X_PRIVATE_KEY", + "private-key.p12" +}; + +static const ObjectType phase2_p12_type = { + NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, + nm_setting_802_1x_get_phase2_private_key_scheme, + nm_setting_802_1x_get_phase2_private_key_path, + nm_setting_802_1x_get_phase2_private_key_blob, + "IEEE_8021X_INNER_PRIVATE_KEY", + "inner-private-key.p12" +}; + +static gboolean +write_object (NMSetting8021x *s_8021x, + shvarFile *ifcfg, + const ObjectType *objtype, + GError **error) +{ + NMSetting8021xCKScheme scheme; + const char *path = NULL; + GBytes *blob = NULL; + + g_return_val_if_fail (ifcfg != NULL, FALSE); + g_return_val_if_fail (objtype != NULL, FALSE); + + scheme = (*(objtype->scheme_func))(s_8021x); + switch (scheme) { + case NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: + break; + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + blob = (*(objtype->blob_func))(s_8021x); + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = (*(objtype->path_func))(s_8021x); + break; + default: + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Unhandled certificate object scheme"); + return FALSE; + } + + /* If certificate/private key wasn't sent, the connection may no longer be + * 802.1x and thus we clear out the paths and certs. + */ + if (!path && !blob) { + char *standard_file; + int ignored; + + /* Since no cert/private key is now being used, delete any standard file + * that was created for this connection, but leave other files alone. + * Thus, for example, + * /etc/sysconfig/network-scripts/ca-cert-Test_Write_Wifi_WPA_EAP-TLS.der + * will be deleted, but /etc/pki/tls/cert.pem will not. + */ + standard_file = utils_cert_path (svFileGetName (ifcfg), objtype->suffix); + if (g_file_test (standard_file, G_FILE_TEST_EXISTS)) + ignored = unlink (standard_file); + g_free (standard_file); + + svUnsetValue (ifcfg, objtype->ifcfg_key); + return TRUE; + } + + /* If the object path was specified, prefer that over any raw cert data that + * may have been sent. + */ + if (path) { + svSetValueString (ifcfg, objtype->ifcfg_key, path); + return TRUE; + } + + /* If it's raw certificate data, write the data out to the standard file */ + if (blob) { + gboolean success; + char *new_file; + GError *write_error = NULL; + + new_file = utils_cert_path (svFileGetName (ifcfg), objtype->suffix); + if (!new_file) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Could not create file path for %s / %s", + NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key); + return FALSE; + } + + /* Write the raw certificate data out to the standard file so that we + * can use paths from now on instead of pushing around the certificate + * data itself. + */ + success = nm_utils_file_set_contents (new_file, + (const char *) g_bytes_get_data (blob, NULL), + g_bytes_get_size (blob), + 0600, + &write_error); + if (success) { + svSetValueString (ifcfg, objtype->ifcfg_key, new_file); + g_free (new_file); + return TRUE; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Could not write certificate/key for %s / %s: %s", + NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key, + (write_error && write_error->message) ? write_error->message : "(unknown)"); + g_clear_error (&write_error); + } + g_free (new_file); + } + + return FALSE; +} + +static gboolean +write_8021x_certs (NMSetting8021x *s_8021x, + gboolean phase2, + shvarFile *ifcfg, + GError **error) +{ + const char *password = NULL; + gboolean success = FALSE, is_pkcs12 = FALSE; + const ObjectType *otype = NULL; + NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; + + /* CA certificate */ + if (!write_object (s_8021x, ifcfg, phase2 ? &phase2_ca_type : &ca_type, error)) + return FALSE; + + /* Private key */ + if (phase2) { + otype = &phase2_pk_type; + if (nm_setting_802_1x_get_phase2_private_key_format (s_8021x) == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { + otype = &phase2_p12_type; + is_pkcs12 = TRUE; + } + password = nm_setting_802_1x_get_phase2_private_key_password (s_8021x); + flags = nm_setting_802_1x_get_phase2_private_key_password_flags (s_8021x); + } else { + otype = &pk_type; + if (nm_setting_802_1x_get_private_key_format (s_8021x) == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { + otype = &p12_type; + is_pkcs12 = TRUE; + } + password = nm_setting_802_1x_get_private_key_password (s_8021x); + flags = nm_setting_802_1x_get_private_key_password_flags (s_8021x); + } + + /* Save the private key */ + if (!write_object (s_8021x, ifcfg, otype, error)) + goto out; + + /* Private key password */ + if (phase2) { + set_secret (ifcfg, + "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD", + password, + "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD_FLAGS", + flags); + } else { + set_secret (ifcfg, + "IEEE_8021X_PRIVATE_KEY_PASSWORD", + password, + "IEEE_8021X_PRIVATE_KEY_PASSWORD_FLAGS", + flags); + } + + /* Client certificate */ + if (is_pkcs12) { + /* Don't need a client certificate with PKCS#12 since the file is both + * the client certificate and the private key in one file. + */ + svSetValueString (ifcfg, + phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT", + NULL); + } else { + /* Save the client certificate */ + if (!write_object (s_8021x, ifcfg, phase2 ? &phase2_client_type : &client_type, error)) + goto out; + } + + success = TRUE; + +out: + return success; +} + +static gboolean +write_8021x_setting (NMConnection *connection, + shvarFile *ifcfg, + gboolean wired, + GError **error) +{ + NMSetting8021x *s_8021x; + const char *value, *match; + char *tmp = NULL; + gboolean success = FALSE; + GString *phase2_auth; + GString *str; + guint32 i, num; + + s_8021x = nm_connection_get_setting_802_1x (connection); + if (!s_8021x) { + /* If wired, clear KEY_MGMT */ + if (wired) + svUnsetValue (ifcfg, "KEY_MGMT"); + return TRUE; + } + + /* If wired, write KEY_MGMT */ + if (wired) + svSetValueString (ifcfg, "KEY_MGMT", "IEEE8021X"); + + /* EAP method */ + if (nm_setting_802_1x_get_num_eap_methods (s_8021x)) { + value = nm_setting_802_1x_get_eap_method (s_8021x, 0); + if (value) + tmp = g_ascii_strup (value, -1); + } + svSetValueString (ifcfg, "IEEE_8021X_EAP_METHODS", tmp); + g_free (tmp); + + svSetValueString (ifcfg, "IEEE_8021X_IDENTITY", + nm_setting_802_1x_get_identity (s_8021x)); + + svSetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY", + nm_setting_802_1x_get_anonymous_identity (s_8021x)); + + set_secret (ifcfg, + "IEEE_8021X_PASSWORD", + nm_setting_802_1x_get_password (s_8021x), + "IEEE_8021X_PASSWORD_FLAGS", + nm_setting_802_1x_get_password_flags (s_8021x)); + + /* PEAP version */ + value = nm_setting_802_1x_get_phase1_peapver (s_8021x); + svUnsetValue (ifcfg, "IEEE_8021X_PEAP_VERSION"); + if (value && (!strcmp (value, "0") || !strcmp (value, "1"))) + svSetValueString (ifcfg, "IEEE_8021X_PEAP_VERSION", value); + + /* Force new PEAP label */ + value = nm_setting_802_1x_get_phase1_peaplabel (s_8021x); + svUnsetValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL"); + if (value && !strcmp (value, "1")) + svSetValueString (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", "yes"); + + /* PAC file */ + value = nm_setting_802_1x_get_pac_file (s_8021x); + svUnsetValue (ifcfg, "IEEE_8021X_PAC_FILE"); + if (value) + svSetValueString (ifcfg, "IEEE_8021X_PAC_FILE", value); + + /* FAST PAC provisioning */ + value = nm_setting_802_1x_get_phase1_fast_provisioning (s_8021x); + svUnsetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING"); + if (value) { + if (strcmp (value, "1") == 0) + svSetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth"); + else if (strcmp (value, "2") == 0) + svSetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-auth"); + else if (strcmp (value, "3") == 0) + svSetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth allow-auth"); + } + + /* Phase2 auth methods */ + svUnsetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); + phase2_auth = g_string_new (NULL); + + value = nm_setting_802_1x_get_phase2_auth (s_8021x); + if (value) { + tmp = g_ascii_strup (value, -1); + g_string_append (phase2_auth, tmp); + g_free (tmp); + } + + value = nm_setting_802_1x_get_phase2_autheap (s_8021x); + if (value) { + if (phase2_auth->len) + g_string_append_c (phase2_auth, ' '); + + tmp = g_ascii_strup (value, -1); + g_string_append_printf (phase2_auth, "EAP-%s", tmp); + g_free (tmp); + } + + svSetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", + phase2_auth->len ? phase2_auth->str : NULL); + + g_string_free (phase2_auth, TRUE); + + svSetValueString (ifcfg, "IEEE_8021X_SUBJECT_MATCH", + nm_setting_802_1x_get_subject_match (s_8021x)); + + svSetValueString (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH", + nm_setting_802_1x_get_phase2_subject_match (s_8021x)); + + svUnsetValue (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES"); + str = g_string_new (NULL); + num = nm_setting_802_1x_get_num_altsubject_matches (s_8021x); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (str, ' '); + match = nm_setting_802_1x_get_altsubject_match (s_8021x, i); + g_string_append (str, match); + } + if (str->len > 0) + svSetValueString (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", str->str); + g_string_free (str, TRUE); + + svUnsetValue (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES"); + str = g_string_new (NULL); + num = nm_setting_802_1x_get_num_phase2_altsubject_matches (s_8021x); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (str, ' '); + match = nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, i); + g_string_append (str, match); + } + if (str->len > 0) + svSetValueString (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", str->str); + g_string_free (str, TRUE); + + svSetValueString (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", + nm_setting_802_1x_get_domain_suffix_match (s_8021x)); + svSetValueString (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", + nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x)); + + success = write_8021x_certs (s_8021x, FALSE, ifcfg, error); + if (success) { + /* phase2/inner certs */ + success = write_8021x_certs (s_8021x, TRUE, ifcfg, error); + } + + return success; +} + +static gboolean +write_wireless_security_setting (NMConnection *connection, + shvarFile *ifcfg, + gboolean adhoc, + gboolean *no_8021x, + GError **error) +{ + NMSettingWirelessSecurity *s_wsec; + const char *key_mgmt, *auth_alg, *key, *proto, *cipher; + const char *psk = NULL; + gboolean wep = FALSE, wpa = FALSE, dynamic_wep = FALSE; + char *tmp; + guint32 i, num; + GString *str; + + s_wsec = nm_connection_get_setting_wireless_security (connection); + if (!s_wsec) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing '%s' setting", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + return FALSE; + } + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + g_assert (key_mgmt); + + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + + svUnsetValue (ifcfg, "DEFAULTKEY"); + + if (!strcmp (key_mgmt, "none")) { + svUnsetValue (ifcfg, "KEY_MGMT"); + wep = TRUE; + *no_8021x = TRUE; + } else if (!strcmp (key_mgmt, "wpa-none") || !strcmp (key_mgmt, "wpa-psk")) { + svSetValueString (ifcfg, "KEY_MGMT", "WPA-PSK"); + wpa = TRUE; + *no_8021x = TRUE; + } else if (!strcmp (key_mgmt, "ieee8021x")) { + svSetValueString (ifcfg, "KEY_MGMT", "IEEE8021X"); + dynamic_wep = TRUE; + } else if (!strcmp (key_mgmt, "wpa-eap")) { + svSetValueString (ifcfg, "KEY_MGMT", "WPA-EAP"); + wpa = TRUE; + } + + svUnsetValue (ifcfg, "SECURITYMODE"); + if (auth_alg) { + if (!strcmp (auth_alg, "shared")) + svSetValueString (ifcfg, "SECURITYMODE", "restricted"); + else if (!strcmp (auth_alg, "open")) + svSetValueString (ifcfg, "SECURITYMODE", "open"); + else if (!strcmp (auth_alg, "leap")) { + svSetValueString (ifcfg, "SECURITYMODE", "leap"); + svSetValueString (ifcfg, "IEEE_8021X_IDENTITY", + nm_setting_wireless_security_get_leap_username (s_wsec)); + set_secret (ifcfg, + "IEEE_8021X_PASSWORD", + nm_setting_wireless_security_get_leap_password (s_wsec), + "IEEE_8021X_PASSWORD_FLAGS", + nm_setting_wireless_security_get_leap_password_flags (s_wsec)); + *no_8021x = TRUE; + } + } + + /* WEP keys */ + + /* Clear any default key */ + set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + + /* Clear existing keys */ + for (i = 0; i < 4; i++) { + tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + g_free (tmp); + + tmp = g_strdup_printf ("KEY%d", i + 1); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + g_free (tmp); + } + + /* And write the new ones out */ + if (wep) { + /* Default WEP TX key index */ + tmp = g_strdup_printf ("%d", nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec) + 1); + svSetValueString (ifcfg, "DEFAULTKEY", tmp); + g_free (tmp); + + for (i = 0; i < 4; i++) { + NMWepKeyType key_type; + + key = nm_setting_wireless_security_get_wep_key (s_wsec, i); + if (key) { + char *ascii_key = NULL; + + /* Passphrase needs a different ifcfg key since with WEP, there + * are some passphrases that are indistinguishable from WEP hex + * keys. + */ + key_type = nm_setting_wireless_security_get_wep_key_type (s_wsec); + if (key_type == NM_WEP_KEY_TYPE_UNKNOWN) { + if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_KEY)) + key_type = NM_WEP_KEY_TYPE_KEY; + else if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_PASSPHRASE)) + key_type = NM_WEP_KEY_TYPE_PASSPHRASE; + } + if (key_type == NM_WEP_KEY_TYPE_PASSPHRASE) + tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); + else if (key_type == NM_WEP_KEY_TYPE_KEY) { + tmp = g_strdup_printf ("KEY%d", i + 1); + + /* Add 's:' prefix for ASCII keys */ + if (strlen (key) == 5 || strlen (key) == 13) { + ascii_key = g_strdup_printf ("s:%s", key); + key = ascii_key; + } + } else { + _LOGW ("invalid WEP key '%s'", key); + tmp = NULL; + } + + if (tmp) { + set_secret (ifcfg, + tmp, + key, + "WEP_KEY_FLAGS", + nm_setting_wireless_security_get_wep_key_flags (s_wsec)); + } + g_free (tmp); + g_free (ascii_key); + } + } + } + + /* WPA protos */ + svUnsetValue (ifcfg, "WPA_ALLOW_WPA"); + svUnsetValue (ifcfg, "WPA_ALLOW_WPA2"); + num = nm_setting_wireless_security_get_num_protos (s_wsec); + for (i = 0; i < num; i++) { + proto = nm_setting_wireless_security_get_proto (s_wsec, i); + if (proto && !strcmp (proto, "wpa")) + svSetValueString (ifcfg, "WPA_ALLOW_WPA", "yes"); + else if (proto && !strcmp (proto, "rsn")) + svSetValueString (ifcfg, "WPA_ALLOW_WPA2", "yes"); + } + + /* WPA Pairwise ciphers */ + svUnsetValue (ifcfg, "CIPHER_PAIRWISE"); + str = g_string_new (NULL); + num = nm_setting_wireless_security_get_num_pairwise (s_wsec); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (str, ' '); + cipher = nm_setting_wireless_security_get_pairwise (s_wsec, i); + + /* Don't write out WEP40 or WEP104 if for some reason they are set; they + * are not valid pairwise ciphers. + */ + if (strcmp (cipher, "wep40") && strcmp (cipher, "wep104")) { + tmp = g_ascii_strup (cipher, -1); + g_string_append (str, tmp); + g_free (tmp); + } + } + if (strlen (str->str) && (dynamic_wep == FALSE)) + svSetValueString (ifcfg, "CIPHER_PAIRWISE", str->str); + g_string_free (str, TRUE); + + /* WPA Group ciphers */ + svUnsetValue (ifcfg, "CIPHER_GROUP"); + str = g_string_new (NULL); + num = nm_setting_wireless_security_get_num_groups (s_wsec); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (str, ' '); + cipher = nm_setting_wireless_security_get_group (s_wsec, i); + tmp = g_ascii_strup (cipher, -1); + g_string_append (str, tmp); + g_free (tmp); + } + if (strlen (str->str) && (dynamic_wep == FALSE)) + svSetValueString (ifcfg, "CIPHER_GROUP", str->str); + g_string_free (str, TRUE); + + if (wpa) + psk = nm_setting_wireless_security_get_psk (s_wsec); + + set_secret (ifcfg, + "WPA_PSK", + psk, + "WPA_PSK_FLAGS", + wpa ? nm_setting_wireless_security_get_psk_flags (s_wsec) : NM_SETTING_SECRET_FLAG_NONE); + + return TRUE; +} + +static gboolean +write_wireless_setting (NMConnection *connection, + shvarFile *ifcfg, + gboolean *no_8021x, + GError **error) +{ + NMSettingWireless *s_wireless; + char *tmp; + GBytes *ssid; + const guint8 *ssid_data; + gsize ssid_len; + const char *mode, *bssid; + const char *device_mac, *cloned_mac; + guint32 mtu, chan, i; + gboolean adhoc = FALSE, hex_ssid = FALSE; + const char * const *macaddr_blacklist; + + s_wireless = nm_connection_get_setting_wireless (connection); + if (!s_wireless) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + + device_mac = nm_setting_wireless_get_mac_address (s_wireless); + svSetValueString (ifcfg, "HWADDR", device_mac); + + cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless); + svSetValueString (ifcfg, "MACADDR", cloned_mac); + + svSetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK", + nm_setting_wireless_get_generate_mac_address_mask (s_wireless)); + + svUnsetValue (ifcfg, "HWADDR_BLACKLIST"); + macaddr_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless); + if (macaddr_blacklist[0]) { + char *blacklist_str; + + blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); + svSetValueString (ifcfg, "HWADDR_BLACKLIST", blacklist_str); + g_free (blacklist_str); + } + + svUnsetValue (ifcfg, "MTU"); + mtu = nm_setting_wireless_get_mtu (s_wireless); + if (mtu) { + tmp = g_strdup_printf ("%u", mtu); + svSetValueString (ifcfg, "MTU", tmp); + g_free (tmp); + } + + ssid = nm_setting_wireless_get_ssid (s_wireless); + if (!ssid) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + ssid_data = g_bytes_get_data (ssid, &ssid_len); + if (!ssid_len || ssid_len > 32) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + + /* If the SSID contains any non-printable characters, we need to use the + * hex notation of the SSID instead. + */ + if ( ssid_len > 2 + && ssid_data[0] == '0' + && ssid_data[1] == 'x') { + hex_ssid = TRUE; + for (i = 2; i < ssid_len; i++) { + if (!g_ascii_isxdigit (ssid_data[i])) { + hex_ssid = FALSE; + break; + } + } + } + if (!hex_ssid) { + for (i = 0; i < ssid_len; i++) { + if (!g_ascii_isprint (ssid_data[i])) { + hex_ssid = TRUE; + break; + } + } + } + + if (hex_ssid) { + GString *str; + + /* Hex SSIDs don't get quoted */ + str = g_string_sized_new (ssid_len * 2 + 3); + g_string_append (str, "0x"); + for (i = 0; i < ssid_len; i++) + g_string_append_printf (str, "%02X", ssid_data[i]); + svSetValueString (ifcfg, "ESSID", str->str); + g_string_free (str, TRUE); + } else { + char buf[33]; + + nm_assert (ssid_len <= 32); + memcpy (buf, ssid_data, ssid_len); + buf[ssid_len] = '\0'; + svSetValueString (ifcfg, "ESSID", buf); + } + + mode = nm_setting_wireless_get_mode (s_wireless); + if (!mode || !strcmp (mode, "infrastructure")) { + svSetValueString (ifcfg, "MODE", "Managed"); + } else if (!strcmp (mode, "adhoc")) { + svSetValueString (ifcfg, "MODE", "Ad-Hoc"); + adhoc = TRUE; + } else if (!strcmp (mode, "ap")) { + svSetValueString (ifcfg, "MODE", "Ap"); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Invalid mode '%s' in '%s' setting", + mode, NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + + svUnsetValue (ifcfg, "CHANNEL"); + svUnsetValue (ifcfg, "BAND"); + chan = nm_setting_wireless_get_channel (s_wireless); + if (chan) { + tmp = g_strdup_printf ("%u", chan); + svSetValueString (ifcfg, "CHANNEL", tmp); + g_free (tmp); + } else { + /* Band only set if channel is not, since channel implies band */ + svSetValueString (ifcfg, "BAND", nm_setting_wireless_get_band (s_wireless)); + } + + bssid = nm_setting_wireless_get_bssid (s_wireless); + svSetValueString (ifcfg, "BSSID", bssid); + + /* Ensure DEFAULTKEY and SECURITYMODE are cleared unless there's security; + * otherwise there's no way to detect WEP vs. open when WEP keys aren't + * saved. + */ + svUnsetValue (ifcfg, "DEFAULTKEY"); + svUnsetValue (ifcfg, "SECURITYMODE"); + + if (nm_connection_get_setting_wireless_security (connection)) { + if (!write_wireless_security_setting (connection, ifcfg, adhoc, no_8021x, error)) + return FALSE; + } else { + char *keys_path; + + /* Clear out wifi security keys */ + svUnsetValue (ifcfg, "KEY_MGMT"); + svUnsetValue (ifcfg, "IEEE_8021X_IDENTITY"); + set_secret (ifcfg, "IEEE_8021X_PASSWORD", NULL, "IEEE_8021X_PASSWORD_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + svUnsetValue (ifcfg, "SECURITYMODE"); + + /* Clear existing keys */ + set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + for (i = 0; i < 4; i++) { + tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + g_free (tmp); + + tmp = g_strdup_printf ("KEY%d", i + 1); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + g_free (tmp); + } + + svUnsetValue (ifcfg, "DEFAULTKEY"); + svUnsetValue (ifcfg, "WPA_ALLOW_WPA"); + svUnsetValue (ifcfg, "WPA_ALLOW_WPA2"); + svUnsetValue (ifcfg, "CIPHER_PAIRWISE"); + svUnsetValue (ifcfg, "CIPHER_GROUP"); + set_secret (ifcfg, "WPA_PSK", NULL, "WPA_PSK_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + + /* Kill any old keys file */ + keys_path = utils_get_keys_path (svFileGetName (ifcfg)); + (void) unlink (keys_path); + g_free (keys_path); + } + + svSetValueString (ifcfg, "SSID_HIDDEN", nm_setting_wireless_get_hidden (s_wireless) ? "yes" : NULL); + + switch (nm_setting_wireless_get_powersave (s_wireless)) { + case NM_SETTING_WIRELESS_POWERSAVE_IGNORE: + svSetValueString (ifcfg, "POWERSAVE", "ignore"); + break; + case NM_SETTING_WIRELESS_POWERSAVE_DISABLE: + svSetValueString (ifcfg, "POWERSAVE", "disable"); + break; + case NM_SETTING_WIRELESS_POWERSAVE_ENABLE: + svSetValueString (ifcfg, "POWERSAVE", "enable"); + break; + default: + case NM_SETTING_WIRELESS_POWERSAVE_DEFAULT: + svUnsetValue (ifcfg, "POWERSAVE"); + break; + } + + svUnsetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION"); + switch (nm_setting_wireless_get_mac_address_randomization (s_wireless)) { + case NM_SETTING_MAC_RANDOMIZATION_DEFAULT: + svSetValueString (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "default"); + break; + case NM_SETTING_MAC_RANDOMIZATION_ALWAYS: + svSetValueString (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "always"); + break; + default: + case NM_SETTING_MAC_RANDOMIZATION_NEVER: + svSetValueString (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "never"); + break; + } + + svSetValueString (ifcfg, "TYPE", TYPE_WIRELESS); + + return TRUE; +} + +static gboolean +write_infiniband_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingInfiniband *s_infiniband; + char *tmp; + const char *mac, *transport_mode, *parent; + guint32 mtu; + int p_key; + + s_infiniband = nm_connection_get_setting_infiniband (connection); + if (!s_infiniband) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing '%s' setting", NM_SETTING_INFINIBAND_SETTING_NAME); + return FALSE; + } + + mac = nm_setting_infiniband_get_mac_address (s_infiniband); + svSetValueString (ifcfg, "HWADDR", mac); + + svUnsetValue (ifcfg, "MTU"); + mtu = nm_setting_infiniband_get_mtu (s_infiniband); + if (mtu) { + tmp = g_strdup_printf ("%u", mtu); + svSetValueString (ifcfg, "MTU", tmp); + g_free (tmp); + } + + transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband); + svSetValueBoolean (ifcfg, "CONNECTED_MODE", nm_streq (transport_mode, "connected")); + + p_key = nm_setting_infiniband_get_p_key (s_infiniband); + if (p_key != -1) { + svSetValueString (ifcfg, "PKEY", "yes"); + tmp = g_strdup_printf ("%u", p_key); + svSetValueString (ifcfg, "PKEY_ID", tmp); + g_free (tmp); + + parent = nm_setting_infiniband_get_parent (s_infiniband); + if (parent) + svSetValueString (ifcfg, "PHYSDEV", parent); + } + + svSetValueString (ifcfg, "TYPE", TYPE_INFINIBAND); + + return TRUE; +} + +static gboolean +write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingWired *s_wired; + const char *device_mac, *cloned_mac; + char *tmp; + const char *nettype, *portname, *ctcprot, *s390_key, *s390_val, *duplex; + guint32 mtu, num_opts, speed, i; + const char *const *s390_subchannels; + GString *str = NULL; + const char * const *macaddr_blacklist; + gboolean auto_negotiate; + NMSettingWiredWakeOnLan wol; + const char *wol_password; + + s_wired = nm_connection_get_setting_wired (connection); + if (!s_wired) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing '%s' setting", NM_SETTING_WIRED_SETTING_NAME); + return FALSE; + } + + device_mac = nm_setting_wired_get_mac_address (s_wired); + svSetValueString (ifcfg, "HWADDR", device_mac); + + cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); + svSetValueString (ifcfg, "MACADDR", cloned_mac); + + svSetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK", + nm_setting_wired_get_generate_mac_address_mask (s_wired)); + + svUnsetValue (ifcfg, "HWADDR_BLACKLIST"); + macaddr_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired); + if (macaddr_blacklist[0]) { + char *blacklist_str; + + blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); + svSetValueString (ifcfg, "HWADDR_BLACKLIST", blacklist_str); + g_free (blacklist_str); + } + + svUnsetValue (ifcfg, "MTU"); + mtu = nm_setting_wired_get_mtu (s_wired); + if (mtu) { + tmp = g_strdup_printf ("%u", mtu); + svSetValueString (ifcfg, "MTU", tmp); + g_free (tmp); + } + + svUnsetValue (ifcfg, "SUBCHANNELS"); + s390_subchannels = nm_setting_wired_get_s390_subchannels (s_wired); + if (s390_subchannels) { + int len = g_strv_length ((char **)s390_subchannels); + + tmp = NULL; + if (len == 2) { + tmp = g_strdup_printf ("%s,%s", s390_subchannels[0], s390_subchannels[1]); + } else if (len == 3) { + tmp = g_strdup_printf ("%s,%s,%s", s390_subchannels[0], s390_subchannels[1], + s390_subchannels[2]); + } + svSetValueString (ifcfg, "SUBCHANNELS", tmp); + g_free (tmp); + } + + svUnsetValue (ifcfg, "NETTYPE"); + nettype = nm_setting_wired_get_s390_nettype (s_wired); + if (nettype) + svSetValueString (ifcfg, "NETTYPE", nettype); + + svUnsetValue (ifcfg, "PORTNAME"); + portname = nm_setting_wired_get_s390_option_by_key (s_wired, "portname"); + if (portname) + svSetValueString (ifcfg, "PORTNAME", portname); + + svUnsetValue (ifcfg, "CTCPROT"); + ctcprot = nm_setting_wired_get_s390_option_by_key (s_wired, "ctcprot"); + if (ctcprot) + svSetValueString (ifcfg, "CTCPROT", ctcprot); + + svUnsetValue (ifcfg, "OPTIONS"); + num_opts = nm_setting_wired_get_num_s390_options (s_wired); + if (s390_subchannels && num_opts) { + str = g_string_sized_new (30); + for (i = 0; i < num_opts; i++) { + nm_setting_wired_get_s390_option (s_wired, i, &s390_key, &s390_val); + + /* portname is handled separately */ + if (!strcmp (s390_key, "portname") || !strcmp (s390_key, "ctcprot")) + continue; + + if (str->len) + g_string_append_c (str, ' '); + g_string_append_printf (str, "%s=%s", s390_key, s390_val); + } + if (str->len) + svSetValueString (ifcfg, "OPTIONS", str->str); + g_string_free (str, TRUE); + } + + /* Stuff ETHTOOL_OPT with required options */ + str = NULL; + auto_negotiate = nm_setting_wired_get_auto_negotiate (s_wired); + /* autoneg off + speed 0 + duplex NULL, means we want NM + * to skip link configuration which is default. So write + * down link config only if we have auto-negotiate true or + * a valid value for one among speed and duplex. + */ + if (auto_negotiate) { + str = g_string_sized_new (64); + g_string_printf (str, "autoneg on"); + } else { + speed = nm_setting_wired_get_speed (s_wired); + duplex = nm_setting_wired_get_duplex (s_wired); + if (speed || duplex) { + str = g_string_sized_new (64); + g_string_printf (str, "autoneg off"); + if (speed) + g_string_append_printf (str, " speed %u", speed); + if (duplex) + g_string_append_printf (str, " duplex %s", duplex); + } + } + + wol = nm_setting_wired_get_wake_on_lan (s_wired); + wol_password = nm_setting_wired_get_wake_on_lan_password (s_wired); + + if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE) + svSetValue (ifcfg, "ETHTOOL_WAKE_ON_LAN", "ignore"); + else if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) { + if (!str) + svUnsetValue (ifcfg, "ETHTOOL_OPTS"); + } else { + if (!str) + str = g_string_sized_new (30); + else + g_string_append (str, " "); + + g_string_append (str, "wol "); + + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_PHY)) + g_string_append (str, "p"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST)) + g_string_append (str, "u"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST)) + g_string_append (str, "m"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST)) + g_string_append (str, "b"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ARP)) + g_string_append (str, "a"); + if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) + g_string_append (str, "g"); + + if (!NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ALL)) + g_string_append (str, "d"); + + if (wol_password && NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) + g_string_append_printf (str, "s sopass %s", wol_password); + } + if (str) { + svSetValueString (ifcfg, "ETHTOOL_OPTS", str->str); + g_string_free (str, TRUE); + } + /* End ETHTOOL_OPT stuffing */ + + svSetValueString (ifcfg, "TYPE", TYPE_ETHERNET); + + return TRUE; +} + +static char * +vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap map) +{ + char **strlist; + char *value; + + if (map == NM_VLAN_INGRESS_MAP) + g_object_get (G_OBJECT (s_vlan), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, &strlist, NULL); + else if (map == NM_VLAN_EGRESS_MAP) + g_object_get (G_OBJECT (s_vlan), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, &strlist, NULL); + else + return NULL; + + if (strlist[0]) + value = g_strjoinv (",", strlist); + else + value = NULL; + g_strfreev (strlist); + + return value; +} + +static gboolean +write_wired_for_virtual (NMConnection *connection, shvarFile *ifcfg) +{ + NMSettingWired *s_wired; + gboolean has_wired = FALSE; + + s_wired = nm_connection_get_setting_wired (connection); + if (s_wired) { + const char *device_mac, *cloned_mac; + char *tmp; + guint32 mtu; + + has_wired = TRUE; + + device_mac = nm_setting_wired_get_mac_address (s_wired); + svSetValueString (ifcfg, "HWADDR", device_mac); + + cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); + svSetValueString (ifcfg, "MACADDR", cloned_mac); + + svSetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK", + nm_setting_wired_get_generate_mac_address_mask (s_wired)); + + mtu = nm_setting_wired_get_mtu (s_wired); + if (mtu) { + tmp = g_strdup_printf ("%u", mtu); + svSetValueString (ifcfg, "MTU", tmp); + g_free (tmp); + } else + svUnsetValue (ifcfg, "MTU"); + } + return has_wired; +} + +static gboolean +write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) +{ + NMSettingVlan *s_vlan; + NMSettingConnection *s_con; + char *tmp; + guint32 vlan_flags = 0; + gsize s_buf_len; + char s_buf[50], *s_buf_ptr; + + s_con = nm_connection_get_setting_connection (connection); + if (!s_con) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing connection setting"); + return FALSE; + } + + s_vlan = nm_connection_get_setting_vlan (connection); + if (!s_vlan) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing VLAN setting"); + return FALSE; + } + + svSetValueString (ifcfg, "VLAN", "yes"); + svSetValueString (ifcfg, "TYPE", TYPE_VLAN); + svSetValueString (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con)); + svSetValueString (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan)); + + tmp = g_strdup_printf ("%d", nm_setting_vlan_get_id (s_vlan)); + svSetValueString (ifcfg, "VLAN_ID", tmp); + g_free (tmp); + + vlan_flags = nm_setting_vlan_get_flags (s_vlan); + svSetValueBoolean (ifcfg, "REORDER_HDR", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)); + svSetValueBoolean (ifcfg, "GVRP", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_GVRP)); + + nm_utils_strbuf_init (s_buf, &s_buf_ptr, &s_buf_len); + + if (NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_LOOSE_BINDING)) + nm_utils_strbuf_append_str (&s_buf_ptr, &s_buf_len, "LOOSE_BINDING"); + if (!NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)) + nm_utils_strbuf_append (&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : ""); + + svSetValueString (ifcfg, "VLAN_FLAGS", s_buf); + + svSetValueBoolean (ifcfg, "MVRP", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_MVRP)); + + tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_INGRESS_MAP); + svSetValueString (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", tmp); + g_free (tmp); + + tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_EGRESS_MAP); + svSetValueString (ifcfg, "VLAN_EGRESS_PRIORITY_MAP", tmp); + g_free (tmp); + + svUnsetValue (ifcfg, "HWADDR"); + svUnsetValue (ifcfg, "MACADDR"); + svUnsetValue (ifcfg, "MTU"); + + *wired = write_wired_for_virtual (connection, ifcfg); + + return TRUE; +} + +static gboolean +write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) +{ + NMSettingBond *s_bond; + const char *iface; + guint32 i, num_opts; + + s_bond = nm_connection_get_setting_bond (connection); + if (!s_bond) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing '%s' setting", NM_SETTING_BOND_SETTING_NAME); + return FALSE; + } + + iface = nm_connection_get_interface_name (connection); + if (!iface) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); + return FALSE; + } + + svSetValueString (ifcfg, "DEVICE", iface); + svUnsetValue (ifcfg, "BONDING_OPTS"); + + num_opts = nm_setting_bond_get_num_options (s_bond); + if (num_opts > 0) { + GString *str = g_string_sized_new (64); + + for (i = 0; i < nm_setting_bond_get_num_options (s_bond); i++) { + const char *key, *value; + + if (!nm_setting_bond_get_option (s_bond, i, &key, &value)) + continue; + + if (str->len) + g_string_append_c (str, ' '); + + g_string_append_printf (str, "%s=%s", key, value); + } + + if (str->len) + svSetValueString (ifcfg, "BONDING_OPTS", str->str); + + g_string_free (str, TRUE); + } + + svSetValueString (ifcfg, "TYPE", TYPE_BOND); + svSetValueString (ifcfg, "BONDING_MASTER", "yes"); + + *wired = write_wired_for_virtual (connection, ifcfg); + + return TRUE; +} + +static gboolean +write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) +{ + NMSettingTeam *s_team; + const char *iface; + const char *config; + + s_team = nm_connection_get_setting_team (connection); + if (!s_team) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing '%s' setting", NM_SETTING_TEAM_SETTING_NAME); + return FALSE; + } + + iface = nm_connection_get_interface_name (connection); + if (!iface) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); + return FALSE; + } + + svSetValueString (ifcfg, "DEVICE", iface); + config = nm_setting_team_get_config (s_team); + svSetValueString (ifcfg, "TEAM_CONFIG", config); + + *wired = write_wired_for_virtual (connection, ifcfg); + + return TRUE; +} + +static guint32 +get_setting_default_uint (NMSetting *setting, const char *prop) +{ + GParamSpec *pspec; + GValue val = G_VALUE_INIT; + guint32 ret = 0; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), prop); + g_assert (pspec); + g_value_init (&val, pspec->value_type); + g_param_value_set_default (pspec, &val); + g_assert (G_VALUE_HOLDS_UINT (&val)); + ret = g_value_get_uint (&val); + g_value_unset (&val); + return ret; +} + +static gboolean +get_setting_default_boolean (NMSetting *setting, const char *prop) +{ + GParamSpec *pspec; + GValue val = G_VALUE_INIT; + gboolean ret = 0; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), prop); + g_assert (pspec); + g_value_init (&val, pspec->value_type); + g_param_value_set_default (pspec, &val); + g_assert (G_VALUE_HOLDS_BOOLEAN (&val)); + ret = g_value_get_boolean (&val); + g_value_unset (&val); + return ret; +} + +static gboolean +write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingBridge *s_bridge; + const char *iface; + guint32 i; + gboolean b; + GString *opts; + const char *mac; + char *s; + + s_bridge = nm_connection_get_setting_bridge (connection); + if (!s_bridge) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing '%s' setting", NM_SETTING_BRIDGE_SETTING_NAME); + return FALSE; + } + + iface = nm_connection_get_interface_name (connection); + if (!iface) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); + return FALSE; + } + + svSetValueString (ifcfg, "DEVICE", iface); + svUnsetValue (ifcfg, "BRIDGING_OPTS"); + svSetValueBoolean (ifcfg, "STP", FALSE); + svUnsetValue (ifcfg, "DELAY"); + + mac = nm_setting_bridge_get_mac_address (s_bridge); + svSetValueString (ifcfg, "MACADDR", mac); + + /* Bridge options */ + opts = g_string_sized_new (32); + + if (nm_setting_bridge_get_stp (s_bridge)) { + svSetValueString (ifcfg, "STP", "yes"); + + i = nm_setting_bridge_get_forward_delay (s_bridge); + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_FORWARD_DELAY)) { + s = g_strdup_printf ("%u", i); + svSetValueString (ifcfg, "DELAY", s); + g_free (s); + } + + g_string_append_printf (opts, "priority=%u", nm_setting_bridge_get_priority (s_bridge)); + + i = nm_setting_bridge_get_hello_time (s_bridge); + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_HELLO_TIME)) { + if (opts->len) + g_string_append_c (opts, ' '); + g_string_append_printf (opts, "hello_time=%u", i); + } + + i = nm_setting_bridge_get_max_age (s_bridge); + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MAX_AGE)) { + if (opts->len) + g_string_append_c (opts, ' '); + g_string_append_printf (opts, "max_age=%u", i); + } + } + + i = nm_setting_bridge_get_ageing_time (s_bridge); + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_AGEING_TIME)) { + if (opts->len) + g_string_append_c (opts, ' '); + g_string_append_printf (opts, "ageing_time=%u", i); + } + + b = nm_setting_bridge_get_multicast_snooping (s_bridge); + if (b != get_setting_default_boolean (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MULTICAST_SNOOPING)) { + if (opts->len) + g_string_append_c (opts, ' '); + g_string_append_printf (opts, "multicast_snooping=%u", (guint32) b); + } + + if (opts->len) + svSetValueString (ifcfg, "BRIDGING_OPTS", opts->str); + g_string_free (opts, TRUE); + + svSetValueString (ifcfg, "TYPE", TYPE_BRIDGE); + + return TRUE; +} + +static gboolean +write_bridge_port_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingBridgePort *s_port; + guint32 i; + GString *opts; + + s_port = nm_connection_get_setting_bridge_port (connection); + if (!s_port) + return TRUE; + + svUnsetValue (ifcfg, "BRIDGING_OPTS"); + + /* Bridge options */ + opts = g_string_sized_new (32); + + i = nm_setting_bridge_port_get_priority (s_port); + if (i != get_setting_default_uint (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PRIORITY)) + g_string_append_printf (opts, "priority=%u", i); + + i = nm_setting_bridge_port_get_path_cost (s_port); + if (i != get_setting_default_uint (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PATH_COST)) { + if (opts->len) + g_string_append_c (opts, ' '); + g_string_append_printf (opts, "path_cost=%u", i); + } + + if (nm_setting_bridge_port_get_hairpin_mode (s_port)) { + if (opts->len) + g_string_append_c (opts, ' '); + g_string_append_printf (opts, "hairpin_mode=1"); + } + + if (opts->len) + svSetValueString (ifcfg, "BRIDGING_OPTS", opts->str); + g_string_free (opts, TRUE); + + return TRUE; +} + +static gboolean +write_team_port_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingTeamPort *s_port; + const char *config; + + s_port = nm_connection_get_setting_team_port (connection); + if (!s_port) + return TRUE; + + config = nm_setting_team_port_get_config (s_port); + svSetValueString (ifcfg, "TEAM_PORT_CONFIG", config); + + return TRUE; +} + +static void +write_dcb_flags (shvarFile *ifcfg, const char *tag, NMSettingDcbFlags flags) +{ + char prop[NM_STRLEN ("DCB_xxxxxxxxxxxxxxxxxxxxxxx_yyyyyyyyyyyyyyyyyyyy")]; + + nm_sprintf_buf (prop, "DCB_%s_ENABLE", tag); + svSetValueString (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ENABLE) ? "yes" : NULL); + + nm_sprintf_buf (prop, "DCB_%s_ADVERTISE", tag); + svSetValueString (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ADVERTISE) ? "yes" : NULL); + + nm_sprintf_buf (prop, "DCB_%s_WILLING", tag); + svSetValueString (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_WILLING) ? "yes" : NULL); +} + +static void +write_dcb_app (shvarFile *ifcfg, + const char *tag, + NMSettingDcbFlags flags, + gint priority) +{ + char prop[NM_STRLEN ("DCB_xxxxxxxxxxxxxxxxxxxxxxx_yyyyyyyyyyyyyyyyyyyy")]; + + write_dcb_flags (ifcfg, tag, flags); + + nm_sprintf_buf (prop, "DCB_%s_PRIORITY", tag); + if ((flags & NM_SETTING_DCB_FLAG_ENABLE) && (priority >= 0)) + svSetValueInt64 (ifcfg, prop, priority); + else + svUnsetValue (ifcfg, prop); +} + +typedef gboolean (*DcbGetBoolFunc) (NMSettingDcb *, guint); + +static void +write_dcb_bool_array (shvarFile *ifcfg, + const char *key, + NMSettingDcb *s_dcb, + NMSettingDcbFlags flags, + DcbGetBoolFunc get_func) +{ + char str[9]; + guint i; + + if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { + svUnsetValue (ifcfg, key); + return; + } + + str[8] = 0; + for (i = 0; i < 8; i++) + str[i] = get_func (s_dcb, i) ? '1' : '0'; + svSetValueString (ifcfg, key, str); +} + +typedef guint (*DcbGetUintFunc) (NMSettingDcb *, guint); + +static void +write_dcb_uint_array (shvarFile *ifcfg, + const char *key, + NMSettingDcb *s_dcb, + NMSettingDcbFlags flags, + DcbGetUintFunc get_func) +{ + char str[9]; + guint i, num; + + if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { + svUnsetValue (ifcfg, key); + return; + } + + str[8] = 0; + for (i = 0; i < 8; i++) { + num = get_func (s_dcb, i); + if (num < 10) + str[i] = '0' + num; + else if (num == 15) + str[i] = 'f'; + else + g_assert_not_reached (); + } + svSetValueString (ifcfg, key, str); +} + +static void +write_dcb_percent_array (shvarFile *ifcfg, + const char *key, + NMSettingDcb *s_dcb, + NMSettingDcbFlags flags, + DcbGetUintFunc get_func) +{ + GString *str; + guint i; + + if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { + svUnsetValue (ifcfg, key); + return; + } + + str = g_string_sized_new (30); + for (i = 0; i < 8; i++) { + if (str->len) + g_string_append_c (str, ','); + g_string_append_printf (str, "%d", get_func (s_dcb, i)); + } + svSetValueString (ifcfg, key, str->str); + g_string_free (str, TRUE); +} + +static gboolean +write_dcb_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingDcb *s_dcb; + NMSettingDcbFlags flags; + + s_dcb = nm_connection_get_setting_dcb (connection); + if (!s_dcb) { + static const char *clear_keys[] = { + "DCB", + KEY_DCB_APP_FCOE_ENABLE, + KEY_DCB_APP_FCOE_ADVERTISE, + KEY_DCB_APP_FCOE_WILLING, + KEY_DCB_APP_FCOE_MODE, + KEY_DCB_APP_ISCSI_ENABLE, + KEY_DCB_APP_ISCSI_ADVERTISE, + KEY_DCB_APP_ISCSI_WILLING, + KEY_DCB_APP_FIP_ENABLE, + KEY_DCB_APP_FIP_ADVERTISE, + KEY_DCB_APP_FIP_WILLING, + KEY_DCB_PFC_ENABLE, + KEY_DCB_PFC_ADVERTISE, + KEY_DCB_PFC_WILLING, + KEY_DCB_PFC_UP, + KEY_DCB_PG_ENABLE, + KEY_DCB_PG_ADVERTISE, + KEY_DCB_PG_WILLING, + KEY_DCB_PG_ID, + KEY_DCB_PG_PCT, + KEY_DCB_PG_UPPCT, + KEY_DCB_PG_STRICT, + KEY_DCB_PG_UP2TC, + NULL }; + const char **iter; + + for (iter = clear_keys; *iter; iter++) + svUnsetValue (ifcfg, *iter); + return TRUE; + } + + svSetValueString (ifcfg, "DCB", "yes"); + + write_dcb_app (ifcfg, "APP_FCOE", + nm_setting_dcb_get_app_fcoe_flags (s_dcb), + nm_setting_dcb_get_app_fcoe_priority (s_dcb)); + if (nm_setting_dcb_get_app_fcoe_flags (s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) + svSetValueString (ifcfg, KEY_DCB_APP_FCOE_MODE, nm_setting_dcb_get_app_fcoe_mode (s_dcb)); + else + svUnsetValue (ifcfg, KEY_DCB_APP_FCOE_MODE); + + write_dcb_app (ifcfg, "APP_ISCSI", + nm_setting_dcb_get_app_iscsi_flags (s_dcb), + nm_setting_dcb_get_app_iscsi_priority (s_dcb)); + write_dcb_app (ifcfg, "APP_FIP", + nm_setting_dcb_get_app_fip_flags (s_dcb), + nm_setting_dcb_get_app_fip_priority (s_dcb)); + + write_dcb_flags (ifcfg, "PFC", nm_setting_dcb_get_priority_flow_control_flags (s_dcb)); + write_dcb_bool_array (ifcfg, KEY_DCB_PFC_UP, s_dcb, + nm_setting_dcb_get_priority_flow_control_flags (s_dcb), + nm_setting_dcb_get_priority_flow_control); + + flags = nm_setting_dcb_get_priority_group_flags (s_dcb); + write_dcb_flags (ifcfg, "PG", flags); + write_dcb_uint_array (ifcfg, KEY_DCB_PG_ID, s_dcb, flags, nm_setting_dcb_get_priority_group_id); + write_dcb_percent_array (ifcfg, KEY_DCB_PG_PCT, s_dcb, flags, nm_setting_dcb_get_priority_group_bandwidth); + write_dcb_percent_array (ifcfg, KEY_DCB_PG_UPPCT, s_dcb, flags, nm_setting_dcb_get_priority_bandwidth); + write_dcb_bool_array (ifcfg, KEY_DCB_PG_STRICT, s_dcb, flags, nm_setting_dcb_get_priority_strict_bandwidth); + write_dcb_uint_array (ifcfg, KEY_DCB_PG_UP2TC, s_dcb, flags, nm_setting_dcb_get_priority_traffic_class); + + return TRUE; +} + +static void +write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) +{ + guint32 n, i; + GString *str; + const char *master, *master_iface = NULL, *type; + char *tmp; + gint i_int; + + svSetValueString (ifcfg, "NAME", nm_setting_connection_get_id (s_con)); + svSetValueString (ifcfg, "UUID", nm_setting_connection_get_uuid (s_con)); + svSetValueString (ifcfg, "STABLE_ID", nm_setting_connection_get_stable_id (s_con)); + svSetValueString (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con)); + svSetValueBoolean (ifcfg, "ONBOOT", nm_setting_connection_get_autoconnect (s_con)); + + i_int = nm_setting_connection_get_autoconnect_priority (s_con); + tmp = i_int != NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT + ? g_strdup_printf ("%d", i_int) : NULL; + svSetValueString (ifcfg, "AUTOCONNECT_PRIORITY", tmp); + g_free (tmp); + + i_int = nm_setting_connection_get_autoconnect_retries (s_con); + tmp = i_int != -1 ? g_strdup_printf ("%d", i_int) : NULL; + svSetValueString (ifcfg, "AUTOCONNECT_RETRIES", tmp); + g_free (tmp); + + /* Only save the value for master connections */ + type = nm_setting_connection_get_connection_type (s_con); + if ( !g_strcmp0 (type, NM_SETTING_BOND_SETTING_NAME) + || !g_strcmp0 (type, NM_SETTING_TEAM_SETTING_NAME) + || !g_strcmp0 (type, NM_SETTING_BRIDGE_SETTING_NAME)) { + NMSettingConnectionAutoconnectSlaves autoconnect_slaves; + autoconnect_slaves = nm_setting_connection_get_autoconnect_slaves (s_con); + svSetValueString (ifcfg, "AUTOCONNECT_SLAVES", + autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES ? "yes" : + autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO ? "no" : NULL); + } else + svUnsetValue (ifcfg, "AUTOCONNECT_SLAVES"); + + switch (nm_setting_connection_get_lldp (s_con)) { + case NM_SETTING_CONNECTION_LLDP_ENABLE_RX: + tmp = "rx"; + break; + case NM_SETTING_CONNECTION_LLDP_DISABLE: + tmp = "no"; + break; + default: + tmp = NULL; + } + svSetValueString (ifcfg, "LLDP", tmp); + + /* Permissions */ + svUnsetValue (ifcfg, "USERS"); + n = nm_setting_connection_get_num_permissions (s_con); + if (n > 0) { + str = g_string_sized_new (n * 20); + + for (i = 0; i < n; i++) { + const char *puser = NULL; + + /* Items separated by space for consistency with eg + * IPV6ADDR_SECONDARIES and DOMAIN. + */ + if (str->len) + g_string_append_c (str, ' '); + + if (nm_setting_connection_get_permission (s_con, i, NULL, &puser, NULL)) + g_string_append (str, puser); + } + svSetValueString (ifcfg, "USERS", str->str); + g_string_free (str, TRUE); + } + + svSetValueString (ifcfg, "ZONE", nm_setting_connection_get_zone(s_con)); + + svSetValueString (ifcfg, "MASTER_UUID", NULL); + svSetValueString (ifcfg, "MASTER", NULL); + svSetValueString (ifcfg, "SLAVE", NULL); + svSetValueString (ifcfg, "BRIDGE_UUID", NULL); + svSetValueString (ifcfg, "BRIDGE", NULL); + svSetValueString (ifcfg, "TEAM_MASTER_UUID", NULL); + svSetValueString (ifcfg, "TEAM_MASTER", NULL); + + master = nm_setting_connection_get_master (s_con); + if (master) { + /* The reader prefers the *_UUID variants, however we still try to resolve + * it into an interface name, so that legacy tooling is not confused. */ + if (!nm_utils_get_testing ()) { + /* This is conditional for easier testing. */ + master_iface = nm_manager_iface_for_uuid (nm_manager_get (), master); + } + if (!master_iface) { + master_iface = master; + master = NULL; + + } + + if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BOND_SETTING_NAME)) { + svSetValueString (ifcfg, "MASTER_UUID", master); + svSetValueString (ifcfg, "MASTER", master_iface); + svSetValueString (ifcfg, "SLAVE", "yes"); + } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BRIDGE_SETTING_NAME)) { + svSetValueString (ifcfg, "BRIDGE_UUID", master); + svSetValueString (ifcfg, "BRIDGE", master_iface); + } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) { + svSetValueString (ifcfg, "TEAM_MASTER_UUID", master); + svSetValueString (ifcfg, "TEAM_MASTER", master_iface); + svUnsetValue (ifcfg, "TYPE"); + } + } + + if (nm_streq0 (type, NM_SETTING_TEAM_SETTING_NAME)) + svSetValueString (ifcfg, "DEVICETYPE", TYPE_TEAM); + else if (master_iface && nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) + svSetValueString (ifcfg, "DEVICETYPE", TYPE_TEAM_PORT); + else + svUnsetValue (ifcfg, "DEVICETYPE"); + + /* secondary connection UUIDs */ + svUnsetValue (ifcfg, "SECONDARY_UUIDS"); + n = nm_setting_connection_get_num_secondaries (s_con); + if (n > 0) { + str = g_string_sized_new (n * 37); + + for (i = 0; i < n; i++) { + const char *uuid; + + /* Items separated by space for consistency with eg + * IPV6ADDR_SECONDARIES and DOMAIN. + */ + if (str->len) + g_string_append_c (str, ' '); + + if ((uuid = nm_setting_connection_get_secondary (s_con, i)) != NULL) + g_string_append (str, uuid); + } + svSetValueString (ifcfg, "SECONDARY_UUIDS", str->str); + g_string_free (str, TRUE); + } + + svUnsetValue (ifcfg, "GATEWAY_PING_TIMEOUT"); + if (nm_setting_connection_get_gateway_ping_timeout (s_con)) { + tmp = g_strdup_printf ("%" G_GUINT32_FORMAT, nm_setting_connection_get_gateway_ping_timeout (s_con)); + svSetValueString (ifcfg, "GATEWAY_PING_TIMEOUT", tmp); + g_free (tmp); + } + + switch (nm_setting_connection_get_metered (s_con)) { + case NM_METERED_YES: + svSetValueString (ifcfg, "CONNECTION_METERED", "yes"); + break; + case NM_METERED_NO: + svSetValueString (ifcfg, "CONNECTION_METERED", "no"); + break; + default: + svUnsetValue (ifcfg, "CONNECTION_METERED"); + } +} + +static gboolean +write_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError **error) +{ + const char *dest, *next_hop; + char **route_items; + char *route_contents; + NMIPRoute *route; + guint32 prefix; + gint64 metric; + guint32 i, num; + gboolean success = FALSE; + + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (s_ip4 != NULL, FALSE); + g_return_val_if_fail (error != NULL, FALSE); + g_return_val_if_fail (*error == NULL, FALSE); + + num = nm_setting_ip_config_get_num_routes (s_ip4); + if (num == 0) { + unlink (filename); + return TRUE; + } + + route_items = g_malloc0 (sizeof (char*) * (num + 1)); + for (i = 0; i < num; i++) { + route = nm_setting_ip_config_get_route (s_ip4, i); + + dest = nm_ip_route_get_dest (route); + prefix = nm_ip_route_get_prefix (route); + next_hop = nm_ip_route_get_next_hop (route); + metric = nm_ip_route_get_metric (route); + + if (metric == -1) + route_items[i] = g_strdup_printf ("%s/%u via %s\n", dest, prefix, next_hop); + else + route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", dest, prefix, next_hop, (guint32) metric); + } + route_items[num] = NULL; + route_contents = g_strjoinv (NULL, route_items); + g_strfreev (route_items); + + if (!g_file_set_contents (filename, route_contents, -1, NULL)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Writing route file '%s' failed", filename); + goto error; + } + + success = TRUE; + +error: + g_free (route_contents); + + return success; +} + +static gboolean +write_proxy_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingProxy *s_proxy; + NMSettingProxyMethod method; + const char *pac_url, *pac_script; + + s_proxy = nm_connection_get_setting_proxy (connection); + if (!s_proxy) + return TRUE; + + svUnsetValue (ifcfg, "BROWSER_ONLY"); + svUnsetValue (ifcfg, "PAC_URL"); + svUnsetValue (ifcfg, "PAC_SCRIPT"); + + method = nm_setting_proxy_get_method (s_proxy); + switch (method) { + case NM_SETTING_PROXY_METHOD_AUTO: + svSetValueString (ifcfg, "PROXY_METHOD", "auto"); + + pac_url = nm_setting_proxy_get_pac_url (s_proxy); + if (pac_url) + svSetValueString (ifcfg, "PAC_URL", pac_url); + + pac_script = nm_setting_proxy_get_pac_script (s_proxy); + if (pac_script) + svSetValueString (ifcfg, "PAC_SCRIPT", pac_script); + + break; + case NM_SETTING_PROXY_METHOD_NONE: + svSetValueString (ifcfg, "PROXY_METHOD", "none"); + break; + } + + svSetValueBoolean (ifcfg, "BROWSER_ONLY", nm_setting_proxy_get_browser_only (s_proxy)); + + return TRUE; +} + +static gboolean +write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingIPConfig *s_ip4; + const char *value; + char *addr_key, *prefix_key, *netmask_key, *gw_key, *metric_key, *tmp; + char *route_path = NULL; + gint32 j; + guint32 i, n, num; + gint64 route_metric; + gint priority; + int timeout; + GString *searches; + const char *method = NULL; + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + if (!s_ip4) { + /* slave-type: clear IPv4 settings. + * + * Some IPv4 setting related options are not cleared, + * for no strong reason. */ + svUnsetValue (ifcfg, "BOOTPROTO"); + + svUnsetValue (ifcfg, "IPADDR"); + svUnsetValue (ifcfg, "PREFIX"); + svUnsetValue (ifcfg, "NETMASK"); + svUnsetValue (ifcfg, "GATEWAY"); + + svUnsetValue (ifcfg, "IPADDR0"); + svUnsetValue (ifcfg, "PREFIX0"); + svUnsetValue (ifcfg, "NETMASK0"); + svUnsetValue (ifcfg, "GATEWAY0"); + return TRUE; + } + + method = nm_setting_ip_config_get_method (s_ip4); + + /* Missing IP4 setting is assumed to be DHCP */ + if (!method) + method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; + + if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { + int result; + + /* IPv4 disabled, clear IPv4 related parameters */ + svUnsetValue (ifcfg, "BOOTPROTO"); + for (j = -1; j < 256; j++) { + if (j == -1) { + addr_key = g_strdup ("IPADDR"); + prefix_key = g_strdup ("PREFIX"); + netmask_key = g_strdup ("NETMASK"); + gw_key = g_strdup ("GATEWAY"); + } else { + addr_key = g_strdup_printf ("IPADDR%d", j); + prefix_key = g_strdup_printf ("PREFIX%d", j); + netmask_key = g_strdup_printf ("NETMASK%d", j); + gw_key = g_strdup_printf ("GATEWAY%d", j); + } + + svUnsetValue (ifcfg, addr_key); + svUnsetValue (ifcfg, prefix_key); + svUnsetValue (ifcfg, netmask_key); + svUnsetValue (ifcfg, gw_key); + + g_free (addr_key); + g_free (prefix_key); + g_free (netmask_key); + g_free (gw_key); + } + + route_path = utils_get_route_path (svFileGetName (ifcfg)); + result = unlink (route_path); + g_free (route_path); + return TRUE; + } + + if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) + svSetValueString (ifcfg, "BOOTPROTO", "dhcp"); + else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) + svSetValueString (ifcfg, "BOOTPROTO", "none"); + else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) + svSetValueString (ifcfg, "BOOTPROTO", "autoip"); + else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) + svSetValueString (ifcfg, "BOOTPROTO", "shared"); + + /* Clear out un-numbered IP address fields */ + svUnsetValue (ifcfg, "IPADDR"); + svUnsetValue (ifcfg, "PREFIX"); + svUnsetValue (ifcfg, "NETMASK"); + svUnsetValue (ifcfg, "GATEWAY"); + /* Clear out zero-indexed IP address fields */ + svUnsetValue (ifcfg, "IPADDR0"); + svUnsetValue (ifcfg, "PREFIX0"); + svUnsetValue (ifcfg, "NETMASK0"); + svUnsetValue (ifcfg, "GATEWAY0"); + + /* Write out IPADDR, PREFIX, GATEWAY for current IP addresses + * without labels. Unset obsolete NETMASK. + */ + num = nm_setting_ip_config_get_num_addresses (s_ip4); + for (i = n = 0; i < num; i++) { + NMIPAddress *addr; + + addr = nm_setting_ip_config_get_address (s_ip4, i); + + if (i > 0) { + GVariant *label; + + label = nm_ip_address_get_attribute (addr, "label"); + if (label) + continue; + } + + if (n == 0) { + /* Instead of index 0 use un-numbered variables. + * It's needed for compatibility with ifup that only recognizes 'GATEAWAY' + * See https://bugzilla.redhat.com/show_bug.cgi?id=771673 + * and https://bugzilla.redhat.com/show_bug.cgi?id=1105770 + */ + addr_key = g_strdup ("IPADDR"); + prefix_key = g_strdup ("PREFIX"); + netmask_key = g_strdup ("NETMASK"); + gw_key = g_strdup ("GATEWAY"); + } else { + addr_key = g_strdup_printf ("IPADDR%d", n); + prefix_key = g_strdup_printf ("PREFIX%d", n); + netmask_key = g_strdup_printf ("NETMASK%d", n); + gw_key = g_strdup_printf ("GATEWAY%d", n); + } + + svSetValueString (ifcfg, addr_key, nm_ip_address_get_address (addr)); + + tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); + svSetValueString (ifcfg, prefix_key, tmp); + g_free (tmp); + + svUnsetValue (ifcfg, netmask_key); + svUnsetValue (ifcfg, gw_key); + + g_free (addr_key); + g_free (prefix_key); + g_free (netmask_key); + g_free (gw_key); + n++; + } + + /* Clear remaining IPADDR, etc */ + for (; n < 256; n++) { + addr_key = g_strdup_printf ("IPADDR%d", n); + prefix_key = g_strdup_printf ("PREFIX%d", n); + netmask_key = g_strdup_printf ("NETMASK%d", n); + gw_key = g_strdup_printf ("GATEWAY%d", n); + + svUnsetValue (ifcfg, addr_key); + svUnsetValue (ifcfg, prefix_key); + svUnsetValue (ifcfg, netmask_key); + svUnsetValue (ifcfg, gw_key); + + g_free (addr_key); + g_free (prefix_key); + g_free (netmask_key); + g_free (gw_key); + } + + svSetValueString (ifcfg, "GATEWAY", nm_setting_ip_config_get_gateway (s_ip4)); + + num = nm_setting_ip_config_get_num_dns (s_ip4); + for (i = 0; i < 254; i++) { + const char *dns; + + addr_key = g_strdup_printf ("DNS%d", i + 1); + + if (i >= num) + svUnsetValue (ifcfg, addr_key); + else { + dns = nm_setting_ip_config_get_dns (s_ip4, i); + svSetValueString (ifcfg, addr_key, dns); + } + g_free (addr_key); + } + + num = nm_setting_ip_config_get_num_dns_searches (s_ip4); + if (num > 0) { + searches = g_string_new (NULL); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (searches, ' '); + g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip4, i)); + } + svSetValueString (ifcfg, "DOMAIN", searches->str); + g_string_free (searches, TRUE); + } else + svUnsetValue (ifcfg, "DOMAIN"); + + /* DEFROUTE; remember that it has the opposite meaning from never-default */ + svSetValueBoolean (ifcfg, "DEFROUTE", !nm_setting_ip_config_get_never_default (s_ip4)); + + /* Missing PEERDNS means TRUE, so write it only when is FALSE */ + svSetValueString (ifcfg, "PEERDNS", + nm_setting_ip_config_get_ignore_auto_dns (s_ip4) ? "no" : NULL); + /* Missing PEERROUTES means TRUE, so write it only when is FALSE */ + svSetValueString (ifcfg, "PEERROUTES", + nm_setting_ip_config_get_ignore_auto_routes (s_ip4) ? "no" : NULL); + + value = nm_setting_ip_config_get_dhcp_hostname (s_ip4); + svSetValueString (ifcfg, "DHCP_HOSTNAME", value); + + value = nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)); + svSetValueString (ifcfg, "DHCP_FQDN", value); + + /* Missing DHCP_SEND_HOSTNAME means TRUE, and we prefer not write it explicitly + * in that case, because it is NM-specific variable + */ + svSetValueString (ifcfg, "DHCP_SEND_HOSTNAME", + nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) ? NULL : "no"); + + value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)); + svSetValueString (ifcfg, "DHCP_CLIENT_ID", value); + + timeout = nm_setting_ip_config_get_dhcp_timeout (s_ip4); + tmp = timeout ? g_strdup_printf ("%d", timeout) : NULL; + svSetValueString (ifcfg, "IPV4_DHCP_TIMEOUT", tmp); + g_free (tmp); + + svSetValueBoolean (ifcfg, "IPV4_FAILURE_FATAL", !nm_setting_ip_config_get_may_fail (s_ip4)); + + route_metric = nm_setting_ip_config_get_route_metric (s_ip4); + tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL; + svSetValueString (ifcfg, "IPV4_ROUTE_METRIC", tmp); + g_free (tmp); + + /* Static routes - route- file */ + route_path = utils_get_route_path (svFileGetName (ifcfg)); + if (!route_path) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Could not get route file path for '%s'", svFileGetName (ifcfg)); + return FALSE; + } + + if (utils_has_route_file_new_syntax (route_path)) { + shvarFile *routefile; + + routefile = utils_get_route_ifcfg (svFileGetName (ifcfg), TRUE); + if (!routefile) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Could not create route file '%s'", route_path); + g_free (route_path); + return FALSE; + } + g_free (route_path); + + num = nm_setting_ip_config_get_num_routes (s_ip4); + for (i = 0; i < 256; i++) { + char buf[INET_ADDRSTRLEN]; + NMIPRoute *route; + guint32 netmask; + gint64 metric; + + addr_key = g_strdup_printf ("ADDRESS%d", i); + netmask_key = g_strdup_printf ("NETMASK%d", i); + gw_key = g_strdup_printf ("GATEWAY%d", i); + metric_key = g_strdup_printf ("METRIC%d", i); + + if (i >= num) { + svUnsetValue (routefile, addr_key); + svUnsetValue (routefile, netmask_key); + svUnsetValue (routefile, gw_key); + svUnsetValue (routefile, metric_key); + } else { + route = nm_setting_ip_config_get_route (s_ip4, i); + + svSetValueString (routefile, addr_key, nm_ip_route_get_dest (route)); + + memset (buf, 0, sizeof (buf)); + netmask = nm_utils_ip4_prefix_to_netmask (nm_ip_route_get_prefix (route)); + inet_ntop (AF_INET, (const void *) &netmask, &buf[0], sizeof (buf)); + svSetValueString (routefile, netmask_key, &buf[0]); + + svSetValueString (routefile, gw_key, nm_ip_route_get_next_hop (route)); + + memset (buf, 0, sizeof (buf)); + metric = nm_ip_route_get_metric (route); + if (metric == -1) + svUnsetValue (routefile, metric_key); + else { + tmp = g_strdup_printf ("%u", (guint32) metric); + svSetValueString (routefile, metric_key, tmp); + g_free (tmp); + } + } + + g_free (addr_key); + g_free (netmask_key); + g_free (gw_key); + g_free (metric_key); + } + if (!svWriteFile (routefile, 0644, error)) { + svCloseFile (routefile); + return FALSE; + } + svCloseFile (routefile); + } else { + write_route_file_legacy (route_path, s_ip4, error); + g_free (route_path); + if (error && *error) + return FALSE; + } + + timeout = nm_setting_ip_config_get_dad_timeout (s_ip4); + if (timeout < 0) + svUnsetValue (ifcfg, "ARPING_WAIT"); + else if (timeout == 0) + svSetValueString (ifcfg, "ARPING_WAIT", "0"); + else { + /* Round the value up to next integer */ + svSetValueInt64 (ifcfg, "ARPING_WAIT", (timeout - 1) / 1000 + 1); + } + + priority = nm_setting_ip_config_get_dns_priority (s_ip4); + if (priority) + svSetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", priority); + else + svUnsetValue (ifcfg, "IPV4_DNS_PRIORITY"); + + return TRUE; +} + +static void +write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) +{ + NMSettingIPConfig *s_ip4; + gs_free char *base_ifcfg_dir = NULL, *base_ifcfg_name = NULL; + const char*base_name; + int i, num, base_ifcfg_name_len, base_name_len; + GDir *dir; + + base_ifcfg_dir = g_path_get_dirname (base_ifcfg_path); + base_ifcfg_name = g_path_get_basename (base_ifcfg_path); + base_ifcfg_name_len = strlen (base_ifcfg_name); + if (!g_str_has_prefix (base_ifcfg_name, IFCFG_TAG)) + g_return_if_reached (); + base_name = base_ifcfg_name + strlen (IFCFG_TAG); + base_name_len = strlen (base_name); + + /* Remove all existing aliases for this file first */ + dir = g_dir_open (base_ifcfg_dir, 0, NULL); + if (dir) { + const char *item; + + while ((item = g_dir_read_name (dir))) { + char *full_path; + + if ( strncmp (item, base_ifcfg_name, base_ifcfg_name_len) != 0 + || item[base_ifcfg_name_len] != ':') + continue; + + full_path = g_build_filename (base_ifcfg_dir, item, NULL); + unlink (full_path); + g_free (full_path); + } + + g_dir_close (dir); + } + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + if (!s_ip4) { + /* slave-type: no alias files */ + return; + } + + num = nm_setting_ip_config_get_num_addresses (s_ip4); + for (i = 0; i < num; i++) { + GVariant *label_var; + const char *label, *p; + char *path, *tmp; + NMIPAddress *addr; + shvarFile *ifcfg; + + addr = nm_setting_ip_config_get_address (s_ip4, i); + + label_var = nm_ip_address_get_attribute (addr, "label"); + if (!label_var) + continue; + label = g_variant_get_string (label_var, NULL); + if ( strncmp (label, base_name, base_name_len) != 0 + || label[base_name_len] != ':') + continue; + + for (p = label; *p; p++) { + if (!g_ascii_isalnum (*p) && *p != '_' && *p != ':') + break; + } + if (*p) + continue; + + path = g_strdup_printf ("%s%s", base_ifcfg_path, label + base_name_len); + ifcfg = svCreateFile (path); + g_free (path); + + svSetValueString (ifcfg, "DEVICE", label); + + addr = nm_setting_ip_config_get_address (s_ip4, i); + svSetValueString (ifcfg, "IPADDR", nm_ip_address_get_address (addr)); + + tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); + svSetValueString (ifcfg, "PREFIX", tmp); + g_free (tmp); + + svWriteFile (ifcfg, 0644, NULL); + svCloseFile (ifcfg); + } +} + +static gboolean +write_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error) +{ + char **route_items; + char *route_contents; + NMIPRoute *route; + guint32 i, num; + gboolean success = FALSE; + + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (s_ip6 != NULL, FALSE); + g_return_val_if_fail (error != NULL, FALSE); + g_return_val_if_fail (*error == NULL, FALSE); + + num = nm_setting_ip_config_get_num_routes (s_ip6); + if (num == 0) { + unlink (filename); + return TRUE; + } + + route_items = g_malloc0 (sizeof (char*) * (num + 1)); + for (i = 0; i < num; i++) { + route = nm_setting_ip_config_get_route (s_ip6, i); + + if (nm_ip_route_get_metric (route) == -1) { + route_items[i] = g_strdup_printf ("%s/%u via %s\n", + nm_ip_route_get_dest (route), + nm_ip_route_get_prefix (route), + nm_ip_route_get_next_hop (route)); + } else { + route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", + nm_ip_route_get_dest (route), + nm_ip_route_get_prefix (route), + nm_ip_route_get_next_hop (route), + (guint32) nm_ip_route_get_metric (route)); + } + } + route_items[num] = NULL; + route_contents = g_strjoinv (NULL, route_items); + g_strfreev (route_items); + + if (!g_file_set_contents (filename, route_contents, -1, NULL)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Writing route6 file '%s' failed", filename); + goto error; + } + + success = TRUE; + +error: + g_free (route_contents); + return success; +} + +static void +write_ip6_setting_dhcp_hostname (NMSettingIPConfig *s_ip6, shvarFile *ifcfg) +{ + const char *hostname; + + hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6); + svSetValueString (ifcfg, "DHCPV6_HOSTNAME", hostname); + + /* Missing DHCPV6_SEND_HOSTNAME means TRUE, and we prefer not write it + * explicitly in that case, because it is NM-specific variable + */ + if (nm_setting_ip_config_get_dhcp_send_hostname (s_ip6)) + svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME"); + else + svSetValueString (ifcfg, "DHCPV6_SEND_HOSTNAME", "no"); +} + +static gboolean +write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingIPConfig *s_ip6; + NMSettingIPConfig *s_ip4; + const char *value; + char *addr_key; + char *tmp; + guint32 i, num, num4; + gint priority; + GString *searches; + NMIPAddress *addr; + const char *dns; + gint64 route_metric; + GString *ip_str1, *ip_str2, *ip_ptr; + char *route6_path; + NMSettingIP6ConfigAddrGenMode addr_gen_mode; + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + if (!s_ip6) { + /* slave-type: clear IPv6 settings + * + * Some IPv6 setting related options are not cleared, + * for no strong reason. */ + svUnsetValue (ifcfg, "IPV6INIT"); + svUnsetValue (ifcfg, "IPV6_AUTOCONF"); + svUnsetValue (ifcfg, "DHCPV6C"); + svUnsetValue (ifcfg, "DHCPV6_HOSTNAME"); + svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME"); + svUnsetValue (ifcfg, "IPV6_DEFROUTE"); + svUnsetValue (ifcfg, "IPV6_PEERDNS"); + svUnsetValue (ifcfg, "IPV6_PEERROUTES"); + svUnsetValue (ifcfg, "IPV6_FAILURE_FATAL"); + svUnsetValue (ifcfg, "IPV6_ROUTE_METRIC"); + svUnsetValue (ifcfg, "IPV6_ADDR_GEN_MODE"); + return TRUE; + } + + value = nm_setting_ip_config_get_method (s_ip6); + g_assert (value); + if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + svSetValueString (ifcfg, "IPV6INIT", "no"); + svUnsetValue (ifcfg, "DHCPV6C"); + return TRUE; + } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "yes"); + svUnsetValue (ifcfg, "DHCPV6C"); + } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "no"); + svSetValueString (ifcfg, "DHCPV6C", "yes"); + } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "no"); + svUnsetValue (ifcfg, "DHCPV6C"); + } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) { + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "no"); + svUnsetValue (ifcfg, "DHCPV6C"); + } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "shared"); + svUnsetValue (ifcfg, "DHCPV6C"); + } + + write_ip6_setting_dhcp_hostname (s_ip6, ifcfg); + + /* Write out IP addresses */ + num = nm_setting_ip_config_get_num_addresses (s_ip6); + ip_str1 = g_string_new (NULL); + ip_str2 = g_string_new (NULL); + for (i = 0; i < num; i++) { + if (i == 0) + ip_ptr = ip_str1; + else + ip_ptr = ip_str2; + + addr = nm_setting_ip_config_get_address (s_ip6, i); + + if (i > 1) + g_string_append_c (ip_ptr, ' '); /* separate addresses in IPV6ADDR_SECONDARIES */ + g_string_append_printf (ip_ptr, "%s/%u", + nm_ip_address_get_address (addr), + nm_ip_address_get_prefix (addr)); + } + svSetValueString (ifcfg, "IPV6ADDR", ip_str1->str); + svSetValueString (ifcfg, "IPV6ADDR_SECONDARIES", ip_str2->str); + svSetValueString (ifcfg, "IPV6_DEFAULTGW", nm_setting_ip_config_get_gateway (s_ip6)); + g_string_free (ip_str1, TRUE); + g_string_free (ip_str2, TRUE); + + /* Write out DNS - 'DNS' key is used both for IPv4 and IPv6 */ + s_ip4 = nm_connection_get_setting_ip4_config (connection); + num4 = s_ip4 ? nm_setting_ip_config_get_num_dns (s_ip4) : 0; /* from where to start with IPv6 entries */ + num = nm_setting_ip_config_get_num_dns (s_ip6); + for (i = 0; i < 254; i++) { + addr_key = g_strdup_printf ("DNS%d", i + num4 + 1); + + if (i >= num) + svUnsetValue (ifcfg, addr_key); + else { + dns = nm_setting_ip_config_get_dns (s_ip6, i); + svSetValueString (ifcfg, addr_key, dns); + } + g_free (addr_key); + } + + /* Write out DNS domains - 'DOMAIN' key is shared for both IPv4 and IPv6 domains */ + num = nm_setting_ip_config_get_num_dns_searches (s_ip6); + if (num > 0) { + char *ip4_domains; + ip4_domains = svGetValueString (ifcfg, "DOMAIN"); + searches = g_string_new (ip4_domains); + for (i = 0; i < num; i++) { + if (searches->len > 0) + g_string_append_c (searches, ' '); + g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip6, i)); + } + svSetValueString (ifcfg, "DOMAIN", searches->str); + g_string_free (searches, TRUE); + g_free (ip4_domains); + } + + + /* handle IPV6_DEFROUTE */ + /* IPV6_DEFROUTE has the opposite meaning from 'never-default' */ + if (nm_setting_ip_config_get_never_default(s_ip6)) + svSetValueString (ifcfg, "IPV6_DEFROUTE", "no"); + else + svSetValueString (ifcfg, "IPV6_DEFROUTE", "yes"); + + svSetValueString (ifcfg, "IPV6_PEERDNS", + nm_setting_ip_config_get_ignore_auto_dns (s_ip6) ? "no" : NULL); + + svSetValueString (ifcfg, "IPV6_PEERROUTES", + nm_setting_ip_config_get_ignore_auto_routes (s_ip6) ? "no" : NULL); + + svSetValueString (ifcfg, "IPV6_FAILURE_FATAL", + nm_setting_ip_config_get_may_fail (s_ip6) ? "no" : "yes"); + + route_metric = nm_setting_ip_config_get_route_metric (s_ip6); + tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL; + svSetValueString (ifcfg, "IPV6_ROUTE_METRIC", tmp); + g_free (tmp); + + /* IPv6 Privacy Extensions */ + svUnsetValue (ifcfg, "IPV6_PRIVACY"); + svUnsetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP"); + switch (nm_setting_ip6_config_get_ip6_privacy (NM_SETTING_IP6_CONFIG (s_ip6))){ + case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: + svSetValueString (ifcfg, "IPV6_PRIVACY", "no"); + break; + case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: + svSetValueString (ifcfg, "IPV6_PRIVACY", "rfc3041"); + svSetValueString (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", "yes"); + break; + case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: + svSetValueString (ifcfg, "IPV6_PRIVACY", "rfc3041"); + break; + default: + break; + } + + /* IPv6 Address generation mode */ + addr_gen_mode = nm_setting_ip6_config_get_addr_gen_mode (NM_SETTING_IP6_CONFIG (s_ip6)); + if (addr_gen_mode != NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) { + tmp = nm_utils_enum_to_str (nm_setting_ip6_config_addr_gen_mode_get_type (), + addr_gen_mode); + svSetValueString (ifcfg, "IPV6_ADDR_GEN_MODE", tmp); + g_free (tmp); + } else { + svUnsetValue (ifcfg, "IPV6_ADDR_GEN_MODE"); + } + + /* IPv6 tokenized interface identifier */ + value = nm_setting_ip6_config_get_token (NM_SETTING_IP6_CONFIG (s_ip6)); + svSetValueString (ifcfg, "IPV6_TOKEN", value); + + priority = nm_setting_ip_config_get_dns_priority (s_ip6); + if (priority) + svSetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", priority); + else + svUnsetValue (ifcfg, "IPV6_DNS_PRIORITY"); + + /* Static routes go to route6- file */ + route6_path = utils_get_route6_path (svFileGetName (ifcfg)); + if (!route6_path) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Could not get route6 file path for '%s'", svFileGetName (ifcfg)); + goto error; + } + write_route6_file (route6_path, s_ip6, error); + g_free (route6_path); + if (error && *error) + goto error; + + return TRUE; + +error: + return FALSE; +} + +static void +add_dns_option (GPtrArray *array, const char *option) +{ + if (_nm_utils_dns_option_find_idx (array, option) < 0) + g_ptr_array_add (array, (gpointer) option); +} + +static gboolean +write_res_options (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingIPConfig *s_ip6; + NMSettingIPConfig *s_ip4; + const char *method; + int i, num_options; + gs_unref_ptrarray GPtrArray *array = NULL; + GString *value; + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + + if (!s_ip4) { + /* slave-type: clear res-options */ + svUnsetValue (ifcfg, "RES_OPTIONS"); + return TRUE; + } + + array = g_ptr_array_new (); + + method = nm_setting_ip_config_get_method (s_ip4); + if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { + num_options = nm_setting_ip_config_get_num_dns_options (s_ip4); + for (i = 0; i < num_options; i++) + add_dns_option (array, nm_setting_ip_config_get_dns_option (s_ip4, i)); + } + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + method = nm_setting_ip_config_get_method (s_ip6); + if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + num_options = nm_setting_ip_config_get_num_dns_options (s_ip6); + for (i = 0; i < num_options; i++) + add_dns_option (array, nm_setting_ip_config_get_dns_option (s_ip6, i)); + } + + if ( array->len > 0 + || nm_setting_ip_config_has_dns_options (s_ip4) + || nm_setting_ip_config_has_dns_options (s_ip6)) { + value = g_string_new (NULL); + for (i = 0; i < array->len; i++) { + if (i > 0) + g_string_append_c (value, ' '); + g_string_append (value, array->pdata[i]); + } + svSetValue (ifcfg, "RES_OPTIONS", value->str); + g_string_free (value, TRUE); + } else + svUnsetValue (ifcfg, "RES_OPTIONS"); + + return TRUE; +} + +static char * +escape_id (const char *id) +{ + char *escaped = g_strdup (id); + char *p = escaped; + + /* Escape random stuff */ + while (*p) { + if (*p == ' ') + *p = '_'; + else if (strchr ("\\][|/=()!:", *p)) + *p = '-'; + p++; + } + + return escaped; +} + +static gboolean +write_connection (NMConnection *connection, + const char *ifcfg_dir, + const char *filename, + char **out_filename, + GError **error) +{ + NMSettingConnection *s_con; + gboolean success = FALSE; + shvarFile *ifcfg = NULL; + char *ifcfg_name = NULL; + const char *type; + gboolean no_8021x = FALSE; + gboolean wired = FALSE; + + nm_assert (NM_IS_CONNECTION (connection)); + nm_assert (nm_connection_verify (connection, NULL)); + + if (!writer_can_write_connection (connection, error)) + return FALSE; + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + if (filename) { + /* For existing connections, 'filename' should be full path to ifcfg file */ + ifcfg = svOpenFile (filename, error); + if (!ifcfg) + return FALSE; + + ifcfg_name = g_strdup (filename); + } else { + char *escaped; + + escaped = escape_id (nm_setting_connection_get_id (s_con)); + ifcfg_name = g_strdup_printf ("%s/ifcfg-%s", ifcfg_dir, escaped); + + /* If a file with this path already exists then we need another name. + * Multiple connections can have the same ID (ie if two connections with + * the same ID are visible to different users) but of course can't have + * the same path. + */ + if (g_file_test (ifcfg_name, G_FILE_TEST_EXISTS)) { + guint32 idx = 0; + + g_free (ifcfg_name); + while (idx++ < 500) { + ifcfg_name = g_strdup_printf ("%s/ifcfg-%s-%u", ifcfg_dir, escaped, idx); + if (g_file_test (ifcfg_name, G_FILE_TEST_EXISTS) == FALSE) + break; + g_free (ifcfg_name); + ifcfg_name = NULL; + } + } + g_free (escaped); + + if (ifcfg_name == NULL) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Failed to find usable ifcfg file name"); + return FALSE; + } + + ifcfg = svCreateFile (ifcfg_name); + } + + type = nm_setting_connection_get_connection_type (s_con); + if (!type) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing connection type!"); + goto out; + } + + if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { + // FIXME: can't write PPPoE at this time + if (nm_connection_get_setting_pppoe (connection)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Can't write connection type '%s'", + NM_SETTING_PPPOE_SETTING_NAME); + goto out; + } + + if (!write_wired_setting (connection, ifcfg, error)) + goto out; + wired = TRUE; + } else if (!strcmp (type, NM_SETTING_VLAN_SETTING_NAME)) { + if (!write_vlan_setting (connection, ifcfg, &wired, error)) + goto out; + } else if (!strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME)) { + if (!write_wireless_setting (connection, ifcfg, &no_8021x, error)) + goto out; + } else if (!strcmp (type, NM_SETTING_INFINIBAND_SETTING_NAME)) { + if (!write_infiniband_setting (connection, ifcfg, error)) + goto out; + } else if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME)) { + if (!write_bonding_setting (connection, ifcfg, &wired, error)) + goto out; + } else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME)) { + if (!write_team_setting (connection, ifcfg, &wired, error)) + goto out; + } else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)) { + if (!write_bridge_setting (connection, ifcfg, error)) + goto out; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Can't write connection type '%s'", type); + goto out; + } + + if (!no_8021x) { + if (!write_8021x_setting (connection, ifcfg, wired, error)) + goto out; + } + + if (!write_bridge_port_setting (connection, ifcfg, error)) + goto out; + + if (!write_team_port_setting (connection, ifcfg, error)) + goto out; + + if (!write_dcb_setting (connection, ifcfg, error)) + goto out; + + if (!write_proxy_setting (connection, ifcfg, error)) + goto out; + + svUnsetValue (ifcfg, "DHCP_HOSTNAME"); + svUnsetValue (ifcfg, "DHCP_FQDN"); + + if (!write_ip4_setting (connection, ifcfg, error)) + goto out; + write_ip4_aliases (connection, ifcfg_name); + + if (!write_ip6_setting (connection, ifcfg, error)) + goto out; + + if (!write_res_options (connection, ifcfg, error)) + goto out; + + write_connection_setting (s_con, ifcfg); + + if (!svWriteFile (ifcfg, 0644, error)) + goto out; + + /* Only return the filename if this was a newly written ifcfg */ + if (out_filename && !filename) + *out_filename = g_strdup (ifcfg_name); + + success = TRUE; + +out: + if (ifcfg) + svCloseFile (ifcfg); + g_free (ifcfg_name); + return success; +} + +gboolean +writer_can_write_connection (NMConnection *connection, GError **error) +{ + NMSettingConnection *s_con; + + if ( ( nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME) + && !nm_connection_get_setting_pppoe (connection)) + || nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME) + || nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME) + || nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME) + || nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME) + || nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME) + || nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) + return TRUE; + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "The ifcfg-rh plugin cannot write the connection '%s' (type '%s' pppoe %d)", + nm_connection_get_id (connection), + nm_setting_connection_get_connection_type (s_con), + !!nm_connection_get_setting_pppoe (connection)); + return FALSE; +} + +gboolean +writer_new_connection (NMConnection *connection, + const char *ifcfg_dir, + char **out_filename, + GError **error) +{ + return write_connection (connection, ifcfg_dir, NULL, out_filename, error); +} + +gboolean +writer_update_connection (NMConnection *connection, + const char *ifcfg_dir, + const char *filename, + GError **error) +{ + if (utils_has_complex_routes (filename)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Cannot modify a connection that has an associated 'rule-' or 'rule6-' file"); + return FALSE; + } + + return write_connection (connection, ifcfg_dir, filename, NULL, error); +} + diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h new file mode 100644 index 00000000..2662f79b --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2009 Red Hat, Inc. + */ + +#ifndef _WRITER_H_ +#define _WRITER_H_ + +#include "nm-connection.h" + +gboolean writer_can_write_connection (NMConnection *connection, + GError **error); + +gboolean writer_new_connection (NMConnection *connection, + const char *ifcfg_dir, + char **out_filename, + GError **error); + +gboolean writer_update_connection (NMConnection *connection, + const char *ifcfg_dir, + const char *filename, + GError **error); + +#endif /* _WRITER_H_ */ diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c deleted file mode 100644 index c2956d22..00000000 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ /dev/null @@ -1,1080 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * Dan Williams - * Søren Sandmann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "plugin.h" - -#include -#include -#include -#include -#include - -#include - -#include "nm-dbus-compat.h" -#include "nm-setting-connection.h" - -#include "nm-settings-plugin.h" -#include "nm-config.h" -#include "NetworkManagerUtils.h" - -#include "nm-ifcfg-connection.h" -#include "shvar.h" -#include "common.h" -#include "reader.h" -#include "writer.h" -#include "utils.h" -#include "nm-exported-object.h" - -#include "nmdbus-ifcfg-rh.h" - -#define IFCFGRH1_DBUS_SERVICE_NAME "com.redhat.ifcfgrh1" -#define IFCFGRH1_DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1" - -#define _NMLOG_DOMAIN LOGD_SETTINGS -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), (_NMLOG_DOMAIN), \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - "ifcfg-rh: " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - - -static NMIfcfgConnection *update_connection (SettingsPluginIfcfg *plugin, - NMConnection *source, - const char *full_path, - NMIfcfgConnection *connection, - gboolean protect_existing_connection, - GHashTable *protected_connections, - GError **error); - -static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); - -G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_interface_init)) - -#define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgPrivate)) - - -typedef struct { - NMConfig *config; - - struct { - GDBusConnection *connection; - GDBusInterfaceSkeleton *interface; - GCancellable *cancellable; - gulong signal_id; - } dbus; - - GHashTable *connections; /* uuid::connection */ - gboolean initialized; - - GFileMonitor *ifcfg_monitor; - gulong ifcfg_monitor_id; -} SettingsPluginIfcfgPrivate; - -static SettingsPluginIfcfg *settings_plugin_ifcfg_get (void); -NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfcfg, settings_plugin_ifcfg_get, SETTINGS_TYPE_PLUGIN_IFCFG); - -static void -connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) -{ - SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (user_data); - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - const char *path; - - path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)); - g_return_if_fail (path != NULL); - - - if (!priv->ifcfg_monitor) { - _LOGD ("connection_ifcfg_changed("NM_IFCFG_CONNECTION_LOG_FMTD"): %s", NM_IFCFG_CONNECTION_LOG_ARGD (connection), "ignore event"); - return; - } - - _LOGD ("connection_ifcfg_changed("NM_IFCFG_CONNECTION_LOG_FMTD"): %s", NM_IFCFG_CONNECTION_LOG_ARGD (connection), "reload"); - - update_connection (self, NULL, path, connection, TRUE, NULL, NULL); -} - -static void -connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) -{ - g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (user_data)->connections, - nm_connection_get_uuid (NM_CONNECTION (obj))); -} - -static void -remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - gboolean unmanaged, unrecognized; - - g_return_if_fail (self != NULL); - g_return_if_fail (connection != NULL); - - _LOGI ("remove "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection)); - - unmanaged = !!nm_ifcfg_connection_get_unmanaged_spec (connection); - unrecognized = !!nm_ifcfg_connection_get_unrecognized_spec (connection); - - g_object_ref (connection); - g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection))); - if (!unmanaged && !unrecognized) - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); - g_object_unref (connection); - - /* Emit changes _after_ removing the connection */ - if (unmanaged) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); - if (unrecognized) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); -} - -static NMIfcfgConnection * -find_by_path (SettingsPluginIfcfg *self, const char *path) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - GHashTableIter iter; - NMSettingsConnection *candidate = NULL; - - g_return_val_if_fail (path != NULL, NULL); - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { - if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0) - return NM_IFCFG_CONNECTION (candidate); - } - return NULL; -} - -static NMIfcfgConnection * -update_connection (SettingsPluginIfcfg *self, - NMConnection *source, - const char *full_path, - NMIfcfgConnection *connection, - gboolean protect_existing_connection, - GHashTable *protected_connections, - GError **error) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - NMIfcfgConnection *connection_new; - NMIfcfgConnection *connection_by_uuid; - GError *local = NULL; - const char *new_unmanaged = NULL, *old_unmanaged = NULL; - const char *new_unrecognized = NULL, *old_unrecognized = NULL; - gboolean unmanaged_changed = FALSE, unrecognized_changed = FALSE; - const char *uuid; - gboolean ignore_error = FALSE; - - g_return_val_if_fail (!source || NM_IS_CONNECTION (source), NULL); - g_return_val_if_fail (full_path || source, NULL); - - if (full_path) - _LOGD ("loading from file \"%s\"...", full_path); - - /* Create a NMIfcfgConnection instance, either by reading from @full_path or - * based on @source. */ - connection_new = nm_ifcfg_connection_new (source, full_path, &local, &ignore_error); - if (!connection_new) { - /* Unexpected failure. Probably the file is invalid? */ - if ( connection - && !protect_existing_connection - && (!protected_connections || !g_hash_table_contains (protected_connections, connection))) - remove_connection (self, connection); - if (!source) { - _NMLOG (ignore_error ? LOGL_DEBUG : LOGL_WARN, - "loading \"%s\" fails: %s", full_path, local ? local->message : "(unknown reason)"); - } - g_propagate_error (error, local); - return NULL; - } - - uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new)); - connection_by_uuid = g_hash_table_lookup (priv->connections, uuid); - - if ( connection - && connection != connection_by_uuid) { - - if ( (protect_existing_connection && connection_by_uuid != NULL) - || (protected_connections && g_hash_table_contains (protected_connections, connection))) { - NMIfcfgConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection; - - if (source) - _LOGW ("cannot update protected connection "NM_IFCFG_CONNECTION_LOG_FMT" due to conflicting UUID %s", NM_IFCFG_CONNECTION_LOG_ARG (conflicting), uuid); - else - _LOGW ("cannot load %s due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, full_path, NM_IFCFG_CONNECTION_LOG_ARG (conflicting)); - g_object_unref (connection_new); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Cannot update protected connection due to conflicting UUID"); - return NULL; - } - - /* The new connection has a different UUID then the original one that we - * are about to update. Remove @connection. */ - remove_connection (self, connection); - } - - /* Check if the found connection with the same UUID is not protected from updating. */ - if ( connection_by_uuid - && ( (!connection && protect_existing_connection) - || (protected_connections && g_hash_table_contains (protected_connections, connection_by_uuid)))) { - if (source) - _LOGW ("cannot update connection due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_by_uuid)); - else - _LOGW ("cannot load %s due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, full_path, NM_IFCFG_CONNECTION_LOG_ARG (connection_by_uuid)); - g_object_unref (connection_new); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Skip updating protected connection during reload"); - return NULL; - } - - /* Evaluate unmanaged/unrecognized flags. */ - if (connection_by_uuid) - old_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (connection_by_uuid); - new_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (connection_new); - unmanaged_changed = g_strcmp0 (old_unmanaged, new_unmanaged); - - if (connection_by_uuid) - old_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (connection_by_uuid); - new_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (connection_new); - unrecognized_changed = g_strcmp0 (old_unrecognized, new_unrecognized); - - if (connection_by_uuid) { - const char *old_path; - - old_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)); - - if ( !unmanaged_changed - && !unrecognized_changed - && nm_connection_compare (NM_CONNECTION (connection_by_uuid), - NM_CONNECTION (connection_new), - NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | - NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { - if (old_path && g_strcmp0 (old_path, full_path) != 0) - _LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT" without other changes", nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)), NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - } else { - - /******************************************************* - * UPDATE - *******************************************************/ - - if (source) - _LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT" from %s", NM_IFCFG_CONNECTION_LOG_ARG (connection_new), NM_IFCFG_CONNECTION_LOG_PATH (old_path)); - else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new)))) - _LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - else if (old_path) - _LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT, old_path, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - else - _LOGI ("update and persist "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - - g_object_set (connection_by_uuid, - NM_IFCFG_CONNECTION_UNMANAGED_SPEC, new_unmanaged, - NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, new_unrecognized, - NULL); - - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid), - NM_CONNECTION (connection_new), - FALSE, /* don't set Unsaved */ - "ifcfg-update", - &local)) { - /* Shouldn't ever get here as 'connection_new' was verified by the reader already - * and the UUID did not change. */ - g_assert_not_reached (); - } - g_assert_no_error (local); - - if (new_unmanaged || new_unrecognized) { - if (!old_unmanaged && !old_unrecognized) { - g_object_ref (connection_by_uuid); - /* Unexport the connection by telling the settings service it's - * been removed. - */ - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid)); - /* Remove the path so that claim_connection() doesn't complain later when - * interface gets managed and connection is re-added. */ - nm_connection_set_path (NM_CONNECTION (connection_by_uuid), NULL); - - /* signal_remove() will end up removing the connection from our hash, - * so add it back now. - */ - g_hash_table_insert (priv->connections, - g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection_by_uuid))), - connection_by_uuid); - } - } else { - if (old_unmanaged /* && !new_unmanaged */) { - _LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" and its device because NM_CONTROLLED was true.", - NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid); - } else if (old_unrecognized /* && !new_unrecognized */) { - _LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" because it is now a recognized type.", - NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid); - } - } - - if (unmanaged_changed) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); - if (unrecognized_changed) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); - } - nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (connection_by_uuid), full_path); - g_object_unref (connection_new); - return connection_by_uuid; - } else { - - /******************************************************* - * ADD - *******************************************************/ - - if (source) - _LOGI ("add connection "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - else - _LOGI ("new connection "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - g_hash_table_insert (priv->connections, g_strdup (uuid), connection_new); - - g_signal_connect (connection_new, NM_SETTINGS_CONNECTION_REMOVED, - G_CALLBACK (connection_removed_cb), - self); - - if (nm_ifcfg_connection_get_unmanaged_spec (connection_new)) { - _LOGI ("Ignoring connection "NM_IFCFG_CONNECTION_LOG_FMT" due to NM_CONTROLLED=no. Unmanaged: %s.", - NM_IFCFG_CONNECTION_LOG_ARG (connection_new), - nm_ifcfg_connection_get_unmanaged_spec (connection_new)); - } else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new)) - _LOGW ("Ignoring connection "NM_IFCFG_CONNECTION_LOG_FMT" of unrecognized type.", NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - - /* watch changes of ifcfg hardlinks */ - g_signal_connect (G_OBJECT (connection_new), "ifcfg-changed", - G_CALLBACK (connection_ifcfg_changed), self); - - if (!source) { - /* Only raise the signal if we were called without source, i.e. if we read the connection from file. - * Otherwise, we were called by add_connection() which does not expect the signal. */ - if (nm_ifcfg_connection_get_unmanaged_spec (connection_new)) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); - else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new)) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); - else - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); - } - return connection_new; - } -} - -static void -ifcfg_dir_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) -{ - SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (user_data); - char *path, *ifcfg_path; - NMIfcfgConnection *connection; - - path = g_file_get_path (file); - - ifcfg_path = utils_detect_ifcfg_path (path, FALSE); - _LOGD ("ifcfg_dir_changed(%s) = %d // %s", path, event_type, ifcfg_path ? ifcfg_path : "(none)"); - if (ifcfg_path) { - connection = find_by_path (plugin, ifcfg_path); - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - if (connection) - remove_connection (plugin, connection); - break; - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - /* Update or new */ - update_connection (plugin, NULL, ifcfg_path, connection, TRUE, NULL, NULL); - break; - default: - break; - } - g_free (ifcfg_path); - } - g_free (path); -} - -static void -setup_ifcfg_monitoring (SettingsPluginIfcfg *plugin) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); - GFile *file; - GFileMonitor *monitor; - - file = g_file_new_for_path (IFCFG_DIR "/"); - monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - - if (monitor) { - priv->ifcfg_monitor_id = g_signal_connect (monitor, "changed", - G_CALLBACK (ifcfg_dir_changed), plugin); - priv->ifcfg_monitor = monitor; - } -} - -static GHashTable * -_paths_from_connections (GHashTable *connections) -{ - GHashTableIter iter; - NMIfcfgConnection *connection; - GHashTable *paths = g_hash_table_new (g_str_hash, g_str_equal); - - g_hash_table_iter_init (&iter, connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { - const char *path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)); - - if (path) - g_hash_table_add (paths, (void *) path); - } - return paths; -} - -static int -_sort_paths (const char **f1, const char **f2, GHashTable *paths) -{ - struct stat st; - gboolean c1, c2; - gint64 m1, m2; - - c1 = !!g_hash_table_contains (paths, *f1); - c2 = !!g_hash_table_contains (paths, *f2); - if (c1 != c2) - return c1 ? -1 : 1; - - m1 = stat (*f1, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; - m2 = stat (*f2, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; - if (m1 != m2) - return m1 > m2 ? -1 : 1; - - return strcmp (*f1, *f2); -} - -static void -read_connections (SettingsPluginIfcfg *plugin) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); - GDir *dir; - GError *err = NULL; - const char *item; - GHashTable *alive_connections; - GHashTableIter iter; - NMIfcfgConnection *connection; - GPtrArray *dead_connections = NULL; - guint i; - GPtrArray *filenames; - GHashTable *paths; - - dir = g_dir_open (IFCFG_DIR, 0, &err); - if (!dir) { - _LOGW ("Could not read directory '%s': %s", IFCFG_DIR, err->message); - g_error_free (err); - return; - } - - alive_connections = g_hash_table_new (NULL, NULL); - - filenames = g_ptr_array_new_with_free_func (g_free); - while ((item = g_dir_read_name (dir))) { - char *full_path, *real_path; - - full_path = g_build_filename (IFCFG_DIR, item, NULL); - real_path = utils_detect_ifcfg_path (full_path, TRUE); - - if (real_path) - g_ptr_array_add (filenames, real_path); - g_free (full_path); - } - g_dir_close (dir); - - /* While reloading, we don't replace connections that we already loaded while - * iterating over the files. - * - * To have sensible, reproducible behavior, sort the paths by last modification - * time prefering older files. - */ - paths = _paths_from_connections (priv->connections); - g_ptr_array_sort_with_data (filenames, (GCompareDataFunc) _sort_paths, paths); - g_hash_table_destroy (paths); - - for (i = 0; i < filenames->len; i++) { - connection = update_connection (plugin, NULL, filenames->pdata[i], NULL, FALSE, alive_connections, NULL); - if (connection) - g_hash_table_add (alive_connections, connection); - } - g_ptr_array_free (filenames, TRUE); - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { - if ( !g_hash_table_contains (alive_connections, connection) - && nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection))) { - if (!dead_connections) - dead_connections = g_ptr_array_new (); - g_ptr_array_add (dead_connections, connection); - } - } - g_hash_table_destroy (alive_connections); - - if (dead_connections) { - for (i = 0; i < dead_connections->len; i++) - remove_connection (plugin, dead_connections->pdata[i]); - g_ptr_array_free (dead_connections, TRUE); - } -} - -static GSList * -get_connections (NMSettingsPlugin *config) -{ - SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); - GSList *list = NULL; - GHashTableIter iter; - NMIfcfgConnection *connection; - - if (!priv->initialized) { - if (nm_config_get_monitor_connection_files (nm_config_get ())) - setup_ifcfg_monitoring (plugin); - read_connections (plugin); - priv->initialized = TRUE; - } - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) { - if ( !nm_ifcfg_connection_get_unmanaged_spec (connection) - && !nm_ifcfg_connection_get_unrecognized_spec (connection)) - list = g_slist_prepend (list, connection); - } - - return list; -} - -static gboolean -load_connection (NMSettingsPlugin *config, - const char *filename) -{ - SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); - NMIfcfgConnection *connection; - int dir_len = strlen (IFCFG_DIR); - char *ifcfg_path; - - if ( strncmp (filename, IFCFG_DIR, dir_len) != 0 - || filename[dir_len] != '/' - || strchr (filename + dir_len + 1, '/') != NULL) - return FALSE; - - /* get the real ifcfg-path. This allows us to properly - * handle load command using a route-* file etc. */ - ifcfg_path = utils_detect_ifcfg_path (filename, FALSE); - if (!ifcfg_path) - return FALSE; - - connection = find_by_path (plugin, ifcfg_path); - update_connection (plugin, NULL, ifcfg_path, connection, TRUE, NULL, NULL); - if (!connection) - connection = find_by_path (plugin, ifcfg_path); - - g_free (ifcfg_path); - return (connection != NULL); -} - -static void -reload_connections (NMSettingsPlugin *config) -{ - SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); - - read_connections (plugin); -} - -static GSList * -get_unhandled_specs (NMSettingsPlugin *config, - const char *property) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (config); - GSList *list = NULL, *list_iter; - GHashTableIter iter; - gpointer connection; - char *spec; - gboolean found; - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, &connection)) { - g_object_get (connection, property, &spec, NULL); - if (spec) { - /* Ignore duplicates */ - for (list_iter = list, found = FALSE; list_iter; list_iter = g_slist_next (list_iter)) { - if (g_str_equal (list_iter->data, spec)) { - found = TRUE; - break; - } - } - if (found) - g_free (spec); - else - list = g_slist_prepend (list, spec); - } - } - return list; -} - -static GSList * -get_unmanaged_specs (NMSettingsPlugin *config) -{ - return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNMANAGED_SPEC); -} - -static GSList * -get_unrecognized_specs (NMSettingsPlugin *config) -{ - return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC); -} - -static NMSettingsConnection * -add_connection (NMSettingsPlugin *config, - NMConnection *connection, - gboolean save_to_disk, - GError **error) -{ - SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (config); - gs_free char *path = NULL; - - /* Ensure we reject attempts to add the connection long before we're - * asked to write it to disk. - */ - if (!writer_can_write_connection (connection, error)) - return NULL; - - if (save_to_disk) { - if (!writer_new_connection (connection, IFCFG_DIR, &path, error)) - return NULL; - } - return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); -} - -static void -impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin, - GDBusMethodInvocation *context, - const char *in_ifcfg) -{ - NMIfcfgConnection *connection; - NMSettingConnection *s_con; - const char *uuid; - const char *path; - gs_free char *ifcfg_path = NULL; - - if (!g_path_is_absolute (in_ifcfg)) { - g_dbus_method_invocation_return_error (context, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "ifcfg path '%s' is not absolute", in_ifcfg); - return; - } - - ifcfg_path = utils_detect_ifcfg_path (in_ifcfg, TRUE); - if (!ifcfg_path) { - g_dbus_method_invocation_return_error (context, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "ifcfg path '%s' is not an ifcfg base file", in_ifcfg); - return; - } - - connection = find_by_path (plugin, ifcfg_path); - if ( !connection - || nm_ifcfg_connection_get_unmanaged_spec (connection) - || nm_ifcfg_connection_get_unrecognized_spec (connection)) { - 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_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_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_dbus_method_invocation_return_error (context, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_FAILED, - "unable to get the connection D-Bus path"); - return; - } - - g_dbus_method_invocation_return_value (context, - g_variant_new ("(so)", uuid, path)); -} - -/*****************************************************************************/ - -static void -_dbus_clear (SettingsPluginIfcfg *self) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - - nm_clear_g_signal_handler (priv->dbus.connection, &priv->dbus.signal_id); - - nm_clear_g_cancellable (&priv->dbus.cancellable); - - if (priv->dbus.interface) { - g_dbus_interface_skeleton_unexport (priv->dbus.interface); - nm_exported_object_skeleton_release (priv->dbus.interface); - priv->dbus.interface = NULL; - } - - g_clear_object (&priv->dbus.connection); -} - -static void -_dbus_connection_closed (GDBusConnection *connection, - gboolean remote_peer_vanished, - GError *error, - gpointer user_data) -{ - _LOGW ("dbus: %s bus closed", IFCFGRH1_DBUS_SERVICE_NAME); - _dbus_clear (SETTINGS_PLUGIN_IFCFG (user_data)); - - /* Retry or recover? */ -} - -static void -_dbus_request_name_done (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - GDBusConnection *connection = G_DBUS_CONNECTION (source_object); - SettingsPluginIfcfg *self; - SettingsPluginIfcfgPrivate *priv; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *ret = NULL; - guint32 result; - - ret = g_dbus_connection_call_finish (connection, res, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = SETTINGS_PLUGIN_IFCFG (user_data); - priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - - g_clear_object (&priv->dbus.cancellable); - - if (!ret) { - _LOGW ("dbus: couldn't acquire D-Bus service: %s", error->message); - _dbus_clear (self); - return; - } - - g_variant_get (ret, "(u)", &result); - - if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - _LOGW ("dbus: couldn't acquire ifcfgrh1 D-Bus service (already taken)"); - _dbus_clear (self); - return; - } - - { - GType skeleton_type = NMDBUS_TYPE_IFCFGRH1_SKELETON; - gs_free char *method_name_get_ifcfg_details = NULL; - NMExportedObjectDBusMethodImpl methods[] = { - { - .method_name = (method_name_get_ifcfg_details = nm_exported_object_skeletonify_method_name ("GetIfcfgDetails")), - .impl = G_CALLBACK (impl_ifcfgrh_get_ifcfg_details), - }, - }; - - priv->dbus.interface = nm_exported_object_skeleton_create (skeleton_type, - g_type_class_peek (SETTINGS_TYPE_PLUGIN_IFCFG), - methods, - G_N_ELEMENTS (methods), - (GObject *) self); - - if (!g_dbus_interface_skeleton_export (priv->dbus.interface, - priv->dbus.connection, - IFCFGRH1_DBUS_OBJECT_PATH, - &error)) { - nm_exported_object_skeleton_release (priv->dbus.interface); - priv->dbus.interface = NULL; - _LOGW ("dbus: failed exporting interface: %s", error->message); - _dbus_clear (self); - return; - } - } - - _LOGD ("dbus: aquired D-Bus service %s and exported %s object", - IFCFGRH1_DBUS_SERVICE_NAME, - IFCFGRH1_DBUS_OBJECT_PATH); -} - -static void -_dbus_create_done (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - SettingsPluginIfcfg *self; - SettingsPluginIfcfgPrivate *priv; - gs_free_error GError *error = NULL; - GDBusConnection *connection; - - connection = g_dbus_connection_new_for_address_finish (res, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = SETTINGS_PLUGIN_IFCFG (user_data); - priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - - g_clear_object (&priv->dbus.cancellable); - - if (!connection) { - _LOGW ("dbus: couldn't initialize system bus: %s", error->message); - return; - } - - priv->dbus.connection = connection; - priv->dbus.cancellable = g_cancellable_new (); - - priv->dbus.signal_id = g_signal_connect (priv->dbus.connection, - "closed", - G_CALLBACK (_dbus_connection_closed), - self); - - g_dbus_connection_call (priv->dbus.connection, - 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, - priv->dbus.cancellable, - _dbus_request_name_done, - self); -} - -static void -_dbus_setup (SettingsPluginIfcfg *self) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - gs_free char *address = NULL; - gs_free_error GError *error = NULL; - - g_return_if_fail (!priv->dbus.connection); - - address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, &error); - if (address == NULL) { - _LOGW ("dbus: failed getting address for system bus: %s", error->message); - return; - } - - priv->dbus.cancellable = g_cancellable_new (); - - g_dbus_connection_new_for_address (address, - G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT - | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, - NULL, - priv->dbus.cancellable, - _dbus_create_done, - self); -} - -static void -config_changed_cb (NMConfig *config, - NMConfigData *config_data, - NMConfigChangeFlags changes, - NMConfigData *old_data, - SettingsPluginIfcfg *self) -{ - /* If the dbus connection for some reason is borked the D-Bus service - * won't be offered. - * - * On SIGHUP and SIGUSR1 try to re-connect to D-Bus. So in the unlikely - * event that the D-Bus conneciton is broken, that allows for recovery - * without need for restarting NetworkManager. */ - if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP - | NM_CONFIG_CHANGE_CAUSE_SIGUSR1)) { - if (!SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self)->dbus.connection) - _dbus_setup (self); - } -} - -/*****************************************************************************/ - -static void -init (NMSettingsPlugin *config) -{ -} - -static void -settings_plugin_ifcfg_init (SettingsPluginIfcfg *plugin) -{ - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); - - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); -} - -static void -constructed (GObject *object) -{ - SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - - G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->constructed (object); - - priv->config = nm_config_get (); - g_object_add_weak_pointer ((GObject *) priv->config, (gpointer *) &priv->config); - g_signal_connect (priv->config, - NM_CONFIG_SIGNAL_CONFIG_CHANGED, - G_CALLBACK (config_changed_cb), - self); - - _dbus_setup (self); -} - -static void -dispose (GObject *object) -{ - SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - - if (priv->config) { - g_object_remove_weak_pointer ((GObject *) priv->config, (gpointer *) &priv->config); - g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, self); - priv->config = NULL; - } - - _dbus_clear (self); - - if (priv->connections) { - g_hash_table_destroy (priv->connections); - priv->connections = NULL; - } - - if (priv->ifcfg_monitor) { - if (priv->ifcfg_monitor_id) - g_signal_handler_disconnect (priv->ifcfg_monitor, priv->ifcfg_monitor_id); - - g_file_monitor_cancel (priv->ifcfg_monitor); - g_object_unref (priv->ifcfg_monitor); - } - - G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->dispose (object); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, IFCFG_PLUGIN_NAME); - break; - case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, IFCFG_PLUGIN_INFO); - break; - case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (SettingsPluginIfcfgPrivate)); - - object_class->constructed = constructed; - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_NAME, - NM_SETTINGS_PLUGIN_NAME); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_INFO, - NM_SETTINGS_PLUGIN_INFO); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, - NM_SETTINGS_PLUGIN_CAPABILITIES); -} - -static void -settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) -{ - /* interface implementation */ - plugin_iface->get_connections = get_connections; - plugin_iface->add_connection = add_connection; - plugin_iface->load_connection = load_connection; - plugin_iface->reload_connections = reload_connections; - plugin_iface->get_unmanaged_specs = get_unmanaged_specs; - plugin_iface->get_unrecognized_specs = get_unrecognized_specs; - plugin_iface->init = init; -} - -G_MODULE_EXPORT GObject * -nm_settings_plugin_factory (void) -{ - return g_object_ref (settings_plugin_ifcfg_get ()); -} diff --git a/src/settings/plugins/ifcfg-rh/plugin.h b/src/settings/plugins/ifcfg-rh/plugin.h deleted file mode 100644 index 74c4b00a..00000000 --- a/src/settings/plugins/ifcfg-rh/plugin.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * Dan Williams - * Søren Sandmann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Red Hat, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#define SETTINGS_TYPE_PLUGIN_IFCFG (settings_plugin_ifcfg_get_type ()) -#define SETTINGS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfg)) -#define SETTINGS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgClass)) -#define SETTINGS_IS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFCFG)) -#define SETTINGS_IS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFCFG)) -#define SETTINGS_PLUGIN_IFCFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgClass)) - -typedef struct _SettingsPluginIfcfg SettingsPluginIfcfg; -typedef struct _SettingsPluginIfcfgClass SettingsPluginIfcfgClass; - -struct _SettingsPluginIfcfg { - GObject parent; -}; - -struct _SettingsPluginIfcfgClass { - GObjectClass parent; -}; - -GType settings_plugin_ifcfg_get_type (void); - -#endif /* _PLUGIN_H_ */ - diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c deleted file mode 100644 index 5a351cfa..00000000 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ /dev/null @@ -1,5260 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2008 - 2015 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "reader.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-connection.h" -#include "nm-dbus-interface.h" -#include "nm-setting-connection.h" -#include "nm-setting-ip4-config.h" -#include "nm-setting-vlan.h" -#include "nm-setting-ip6-config.h" -#include "nm-setting-wired.h" -#include "nm-setting-wireless.h" -#include "nm-setting-8021x.h" -#include "nm-setting-bond.h" -#include "nm-setting-team.h" -#include "nm-setting-team-port.h" -#include "nm-setting-bridge.h" -#include "nm-setting-bridge-port.h" -#include "nm-setting-dcb.h" -#include "nm-setting-generic.h" -#include "nm-core-internal.h" -#include "nm-utils.h" - -#include "nm-platform.h" -#include "NetworkManagerUtils.h" - -#include "common.h" -#include "shvar.h" -#include "utils.h" - -/*****************************************************************************/ - -#define _NMLOG_DOMAIN LOGD_SETTINGS -#define _NMLOG_PREFIX_NAME "ifcfg-rh" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), (_NMLOG_DOMAIN), \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -#define PARSE_WARNING(...) _LOGW ("%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), " " _NM_UTILS_MACRO_REST(__VA_ARGS__)) - -/*****************************************************************************/ - -static gboolean -get_uint (const char *str, guint32 *value) -{ - gint64 tmp; - - tmp = _nm_utils_ascii_str_to_int64 (str, 0, 0, G_MAXUINT32, -1); - if (tmp == -1) - return FALSE; - *value = tmp; - return TRUE; -} - -static char * -make_connection_name (shvarFile *ifcfg, - const char *ifcfg_name, - const char *suggested, - const char *prefix) -{ - char *full_name = NULL, *name; - - /* If the ifcfg file already has a NAME, always use that */ - name = svGetValue (ifcfg, "NAME", FALSE); - if (name && strlen (name)) - return name; - - /* Otherwise construct a new NAME */ - g_free (name); - if (!prefix) - prefix = _("System"); - - /* For cosmetic reasons, if the suggested name is the same as - * the ifcfg files name, don't use it. Mainly for wifi so that - * the SSID is shown in the connection ID instead of just "wlan0". - */ - if (suggested && strcmp (ifcfg_name, suggested)) - full_name = g_strdup_printf ("%s %s (%s)", prefix, suggested, ifcfg_name); - else - full_name = g_strdup_printf ("%s %s", prefix, ifcfg_name); - - return full_name; -} - -static NMSetting * -make_connection_setting (const char *file, - shvarFile *ifcfg, - const char *type, - const char *suggested, - const char *prefix) -{ - NMSettingConnection *s_con; - NMSettingConnectionLldp lldp; - const char *ifcfg_name = NULL; - char *new_id, *uuid = NULL, *zone = NULL, *value; - gs_free char *stable_id = NULL; - - ifcfg_name = utils_get_ifcfg_name (file, TRUE); - if (!ifcfg_name) - return NULL; - - s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - - new_id = make_connection_name (ifcfg, ifcfg_name, suggested, prefix); - g_object_set (s_con, NM_SETTING_CONNECTION_ID, new_id, NULL); - g_free (new_id); - - /* Try for a UUID key before falling back to hashing the file name */ - uuid = svGetValue (ifcfg, "UUID", FALSE); - if (!uuid || !strlen (uuid)) { - g_free (uuid); - uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); - } - - stable_id = svGetValue (ifcfg, "STABLE_ID", FALSE); - - g_object_set (s_con, - NM_SETTING_CONNECTION_TYPE, type, - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_STABLE_ID, stable_id, - NULL); - g_free (uuid); - - value = svGetValue (ifcfg, "DEVICE", FALSE); - if (value) { - if (nm_utils_iface_valid_name (value)) { - g_object_set (s_con, - NM_SETTING_CONNECTION_INTERFACE_NAME, value, - NULL); - } else - PARSE_WARNING ("invalid DEVICE name '%s'", value); - g_free (value); - } - - value = svGetValue (ifcfg, "LLDP", FALSE); - if (!g_strcmp0 (value, "rx")) - lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX; - else - lldp = svParseBoolean (value, NM_SETTING_CONNECTION_LLDP_DEFAULT); - g_free (value); - - /* Missing ONBOOT is treated as "ONBOOT=true" by the old network service */ - g_object_set (s_con, - NM_SETTING_CONNECTION_AUTOCONNECT, - svGetValueBoolean (ifcfg, "ONBOOT", TRUE), - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, - (gint) svGetValueInt64 (ifcfg, "AUTOCONNECT_PRIORITY", 10, - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT), - NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, - svGetValueBoolean (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), - NM_SETTING_CONNECTION_LLDP, lldp, - NULL); - - value = svGetValue (ifcfg, "USERS", FALSE); - if (value) { - char **items, **iter; - - items = g_strsplit_set (value, " ", -1); - for (iter = items; iter && *iter; iter++) { - if (strlen (*iter)) { - if (!nm_setting_connection_add_permission (s_con, "user", *iter, NULL)) - PARSE_WARNING ("invalid USERS item '%s'", *iter); - } - } - g_free (value); - g_strfreev (items); - } - - - zone = svGetValue(ifcfg, "ZONE", FALSE); - if (!zone || !strlen (zone)) { - g_free (zone); - zone = NULL; - } - g_object_set (s_con, NM_SETTING_CONNECTION_ZONE, zone, NULL); - g_free (zone); - - value = svGetValue (ifcfg, "SECONDARY_UUIDS", FALSE); - if (value) { - char **items, **iter; - - items = g_strsplit_set (value, " \t", -1); - for (iter = items; iter && *iter; iter++) { - if (strlen (*iter)) { - if (!nm_setting_connection_add_secondary (s_con, *iter)) - PARSE_WARNING ("secondary connection UUID '%s' already added", *iter); - } - } - g_free (value); - g_strfreev (items); - } - - value = svGetValue (ifcfg, "BRIDGE", FALSE); - if (value) { - const char *old_value; - - if ((old_value = nm_setting_connection_get_master (s_con))) { - PARSE_WARNING ("Already configured as slave of %s. Ignoring BRIDGE=\"%s\"", - old_value, value); - } else { - g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); - g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, - NM_SETTING_BRIDGE_SETTING_NAME, NULL); - } - g_free (value); - } - - value = svGetValue (ifcfg, "GATEWAY_PING_TIMEOUT", FALSE); - if (value) { - gint64 tmp; - - tmp = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT32 - 1, -1); - if (tmp >= 0) - g_object_set (s_con, NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, (guint) tmp, NULL); - else - PARSE_WARNING ("invalid GATEWAY_PING_TIMEOUT time"); - g_free (value); - } - - switch (svGetValueBoolean (ifcfg, "CONNECTION_METERED", -1)) { - case TRUE: - g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_YES, NULL); - break; - case FALSE: - g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_NO, NULL); - break; - } - - return NM_SETTING (s_con); -} - -/* Returns TRUE on missing address or valid address */ -static gboolean -read_ip4_address (shvarFile *ifcfg, - const char *tag, - char **out_addr, - GError **error) -{ - char *value = NULL; - - g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (tag != NULL, FALSE); - g_return_val_if_fail (out_addr != NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - *out_addr = NULL; - - value = svGetValue (ifcfg, tag, FALSE); - if (!value) - return TRUE; - - if (nm_utils_ipaddr_valid (AF_INET, value)) { - *out_addr = value; - return TRUE; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid %s IP4 address '%s'", tag, value); - g_free (value); - return FALSE; - } -} - -static char * -get_numbered_tag (char *tag_name, int which) -{ - if (which == -1) - return g_strdup (tag_name); - return g_strdup_printf ("%s%u", tag_name, which); -} - -static gboolean -is_any_ip4_address_defined (shvarFile *ifcfg, int *idx) -{ - int i, ignore, *ret_idx;; - - ret_idx = idx ? idx : &ignore; - - for (i = -1; i <= 2; i++) { - char *tag; - char *value; - - tag = get_numbered_tag ("IPADDR", i); - value = svGetValue (ifcfg, tag, FALSE); - g_free (tag); - if (value) { - g_free (value); - *ret_idx = i; - return TRUE; - } - - tag = get_numbered_tag ("PREFIX", i); - value = svGetValue (ifcfg, tag, FALSE); - g_free(tag); - if (value) { - g_free (value); - *ret_idx = i; - return TRUE; - } - - tag = get_numbered_tag ("NETMASK", i); - value = svGetValue (ifcfg, tag, FALSE); - g_free(tag); - if (value) { - g_free (value); - *ret_idx = i; - return TRUE; - } - } - return FALSE; -} - -/* Returns TRUE on missing address or valid address */ -static gboolean -read_full_ip4_address (shvarFile *ifcfg, - gint32 which, - NMIPAddress *base_addr, - NMIPAddress **out_address, - char **out_gateway, - GError **error) -{ - char *ip_tag, *prefix_tag, *netmask_tag, *gw_tag; - char *ip = NULL; - int prefix = 0; - gboolean success = FALSE; - char *value; - guint32 tmp; - - g_return_val_if_fail (which >= -1, FALSE); - g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (out_address != NULL, FALSE); - g_return_val_if_fail (*out_address == NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - ip_tag = get_numbered_tag ("IPADDR", which); - prefix_tag = get_numbered_tag ("PREFIX", which); - netmask_tag = get_numbered_tag ("NETMASK", which); - gw_tag = get_numbered_tag ("GATEWAY", which); - - /* IP address */ - if (!read_ip4_address (ifcfg, ip_tag, &ip, error)) - goto done; - if (!ip) { - if (base_addr) - ip = g_strdup (nm_ip_address_get_address (base_addr)); - else { - success = TRUE; - goto done; - } - } - - /* Gateway */ - if (out_gateway && !*out_gateway) { - if (!read_ip4_address (ifcfg, gw_tag, out_gateway, error)) - goto done; - } - - /* Prefix */ - value = svGetValue (ifcfg, prefix_tag, FALSE); - if (value) { - prefix = _nm_utils_ascii_str_to_int64 (value, 10, 0, 32, -1); - if (prefix < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP4 prefix '%s'", value); - g_free (value); - goto done; - } - g_free (value); - } else { - /* Fall back to NETMASK if no PREFIX was specified */ - if (!read_ip4_address (ifcfg, netmask_tag, &value, error)) - goto done; - if (value) { - inet_pton (AF_INET, value, &tmp); - prefix = nm_utils_ip4_netmask_to_prefix (tmp); - g_free (value); - } else { - if (base_addr) - prefix = nm_ip_address_get_prefix (base_addr); - else { - /* Try to autodetermine the prefix for the address' class */ - if (inet_pton (AF_INET, ip, &tmp) == 1) { - prefix = nm_utils_ip4_get_default_prefix (tmp); - - PARSE_WARNING ("missing %s, assuming %s/%d", prefix_tag, ip, prefix); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IP4 prefix"); - goto done; - } - } - } - } - - *out_address = nm_ip_address_new (AF_INET, ip, prefix, error); - if (*out_address) - success = TRUE; - -done: - g_free (ip); - g_free (ip_tag); - g_free (prefix_tag); - g_free (netmask_tag); - g_free (gw_tag); - - return success; -} - -/* Returns TRUE on missing route or valid route */ -static gboolean -read_one_ip4_route (shvarFile *ifcfg, - guint32 which, - NMIPRoute **out_route, - GError **error) -{ - char *ip_tag, *netmask_tag, *gw_tag, *metric_tag, *value; - char *dest = NULL, *next_hop = NULL; - gint64 prefix, metric; - gboolean success = FALSE; - - g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (out_route != NULL, FALSE); - g_return_val_if_fail (*out_route == NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - ip_tag = g_strdup_printf ("ADDRESS%u", which); - netmask_tag = g_strdup_printf ("NETMASK%u", which); - gw_tag = g_strdup_printf ("GATEWAY%u", which); - metric_tag = g_strdup_printf ("METRIC%u", which); - - /* Destination */ - if (!read_ip4_address (ifcfg, ip_tag, &dest, error)) - goto out; - if (!dest) { - /* Check whether IP is missing or 0.0.0.0 */ - char *val; - val = svGetValue (ifcfg, ip_tag, FALSE); - if (!val) { - *out_route = NULL; - success = TRUE; /* missing route = success */ - goto out; - } - g_free (val); - } - - /* Next hop */ - if (!read_ip4_address (ifcfg, gw_tag, &next_hop, error)) - goto out; - /* We don't make distinction between missing GATEWAY IP and 0.0.0.0 */ - - /* Prefix */ - if (!read_ip4_address (ifcfg, netmask_tag, &value, error)) - goto out; - if (value) { - guint32 netmask; - - inet_pton (AF_INET, value, &netmask); - prefix = nm_utils_ip4_netmask_to_prefix (netmask); - g_free (value); - if (prefix == 0 || netmask != nm_utils_ip4_prefix_to_netmask (prefix)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP4 netmask '%s' \"%s\"", netmask_tag, nm_utils_inet4_ntop (netmask, NULL)); - goto out; - } - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IP4 route element '%s'", netmask_tag); - goto out; - } - - /* Metric */ - value = svGetValue (ifcfg, metric_tag, FALSE); - if (value) { - metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1); - if (metric < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP4 route metric '%s'", value); - g_free (value); - goto out; - } - g_free (value); - } else - metric = -1; - - *out_route = nm_ip_route_new (AF_INET, dest, prefix, next_hop, metric, error); - if (*out_route) - success = TRUE; - -out: - g_free (dest); - g_free (next_hop); - g_free (ip_tag); - g_free (netmask_tag); - g_free (gw_tag); - g_free (metric_tag); - return success; -} - -static gboolean -read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError **error) -{ - char *contents = NULL; - gsize len = 0; - char **lines = NULL, **iter; - GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric; - GMatchInfo *match_info; - int prefix_int; - gint64 metric_int; - gboolean success = FALSE; - - const char *pattern_empty = "^\\s*(\\#.*)?$"; - const char *pattern_to1 = "^\\s*(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|default)" /* IP or 'default' keyword */ - "(?:/(\\d{1,2}))?"; /* optional prefix */ - const char *pattern_to2 = "to\\s+(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|default)" /* IP or 'default' keyword */ - "(?:/(\\d{1,2}))?"; /* optional prefix */ - const char *pattern_via = "via\\s+(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})"; /* IP of gateway */ - const char *pattern_metric = "metric\\s+(\\d+)"; /* metric */ - - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (s_ip4 != NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - /* Read the route file */ - if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { - g_free (contents); - return TRUE; /* missing/empty = success */ - } - - /* Create regexes for pieces to be matched */ - regex_to1 = g_regex_new (pattern_to1, 0, 0, NULL); - regex_to2 = g_regex_new (pattern_to2, 0, 0, NULL); - regex_via = g_regex_new (pattern_via, 0, 0, NULL); - regex_metric = g_regex_new (pattern_metric, 0, 0, NULL); - - /* Iterate through file lines */ - lines = g_strsplit_set (contents, "\n\r", -1); - for (iter = lines; iter && *iter; iter++) { - gs_free char *next_hop = NULL, *dest = NULL; - char *prefix, *metric; - NMIPRoute *route; - - /* Skip empty lines */ - if (g_regex_match_simple (pattern_empty, *iter, 0, 0)) - continue; - - /* Destination */ - g_regex_match (regex_to1, *iter, 0, &match_info); - if (!g_match_info_matches (match_info)) { - g_match_info_free (match_info); - g_regex_match (regex_to2, *iter, 0, &match_info); - if (!g_match_info_matches (match_info)) { - g_match_info_free (match_info); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IP4 route destination address in record: '%s'", *iter); - goto error; - } - } - dest = g_match_info_fetch (match_info, 1); - if (!strcmp (dest, "default")) { - g_match_info_free (match_info); - PARSE_WARNING ("ignoring manual default route: '%s' (%s)", *iter, filename); - continue; - } - if (!nm_utils_ipaddr_valid (AF_INET, dest)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP4 route destination address '%s'", dest); - g_match_info_free (match_info); - goto error; - } - - /* Prefix - is optional; 32 if missing */ - prefix = g_match_info_fetch (match_info, 2); - g_match_info_free (match_info); - prefix_int = 32; - if (prefix) { - prefix_int = _nm_utils_ascii_str_to_int64 (prefix, 10, 1, 32, -1); - if (prefix_int == -1) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP4 route destination prefix '%s'", prefix); - g_free (prefix); - goto error; - } - } - g_free (prefix); - - /* Next hop */ - g_regex_match (regex_via, *iter, 0, &match_info); - if (g_match_info_matches (match_info)) { - next_hop = g_match_info_fetch (match_info, 1); - if (!nm_utils_ipaddr_valid (AF_INET, next_hop)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP4 route gateway address '%s'", - next_hop); - g_match_info_free (match_info); - goto error; - } - } else { - /* we don't make distinction between missing GATEWAY IP and 0.0.0.0 */ - } - g_match_info_free (match_info); - - /* Metric */ - g_regex_match (regex_metric, *iter, 0, &match_info); - metric_int = -1; - if (g_match_info_matches (match_info)) { - metric = g_match_info_fetch (match_info, 1); - metric_int = _nm_utils_ascii_str_to_int64 (metric, 10, 0, G_MAXUINT32, -1); - if (metric_int == -1) { - g_match_info_free (match_info); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP4 route metric '%s'", metric); - g_free (metric); - goto error; - } - g_free (metric); - } - g_match_info_free (match_info); - - route = nm_ip_route_new (AF_INET, dest, prefix_int, next_hop, metric_int, error); - if (!route) - goto error; - if (!nm_setting_ip_config_add_route (s_ip4, route)) - PARSE_WARNING ("duplicate IP4 route"); - nm_ip_route_unref (route); - } - - success = TRUE; - -error: - g_free (contents); - g_strfreev (lines); - g_regex_unref (regex_to1); - g_regex_unref (regex_to2); - g_regex_unref (regex_via); - g_regex_unref (regex_metric); - - return success; -} - -static void -parse_dns_options (NMSettingIPConfig *ip_config, char *value) -{ - char **options = NULL; - - g_return_if_fail (ip_config); - - if (!value) - return; - - if (!nm_setting_ip_config_has_dns_options (ip_config)) - nm_setting_ip_config_clear_dns_options (ip_config, TRUE); - - options = g_strsplit (value, " ", 0); - if (options) { - char **item; - for (item = options; *item; item++) { - if (strlen (*item)) { - if (!nm_setting_ip_config_add_dns_option (ip_config, *item)) - PARSE_WARNING ("can't add DNS option '%s'", *item); - } - } - g_strfreev (options); - } -} - -static gboolean -parse_full_ip6_address (shvarFile *ifcfg, - const char *addr_str, - int i, - NMIPAddress **out_address, - GError **error) -{ - char **list; - char *ip_val, *prefix_val; - int prefix; - gboolean success = FALSE; - - g_return_val_if_fail (addr_str != NULL, FALSE); - g_return_val_if_fail (out_address != NULL, FALSE); - g_return_val_if_fail (*out_address == NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - /* Split the address and prefix */ - list = g_strsplit_set (addr_str, "/", 2); - if (g_strv_length (list) < 1) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP6 address '%s'", addr_str); - goto error; - } - - ip_val = list[0]; - - prefix_val = list[1]; - if (prefix_val) { - prefix = _nm_utils_ascii_str_to_int64 (prefix_val, 10, 0, 128, -1); - if (prefix < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP6 prefix '%s'", prefix_val); - goto error; - } - } else { - /* Missing prefix is treated as prefix of 64 */ - prefix = 64; - } - - *out_address = nm_ip_address_new (AF_INET6, ip_val, prefix, error); - if (*out_address) - success = TRUE; - -error: - g_strfreev (list); - return success; -} - -/* IPv6 address is very complex to describe completely by a regular expression, - * so don't try to, rather use looser syntax to comprise all possibilities - * NOTE: The regexes below don't describe all variants allowed by 'ip route add', - * namely destination IP without 'to' keyword is recognized just at line start. - */ -#define IPV6_ADDR_REGEX "[0-9A-Fa-f:.]+" - -static gboolean -read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error) -{ - char *contents = NULL; - gsize len = 0; - char **lines = NULL, **iter; - GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric; - GMatchInfo *match_info; - char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL; - int prefix_int; - gint64 metric_int; - gboolean success = FALSE; - - const char *pattern_empty = "^\\s*(\\#.*)?$"; - const char *pattern_to1 = "^\\s*(default|" IPV6_ADDR_REGEX ")" /* IPv6 or 'default' keyword */ - "(?:/(\\d{1,3}))?"; /* optional prefix */ - const char *pattern_to2 = "to\\s+(default|" IPV6_ADDR_REGEX ")" /* IPv6 or 'default' keyword */ - "(?:/(\\d{1,3}))?"; /* optional prefix */ - const char *pattern_via = "via\\s+(" IPV6_ADDR_REGEX ")"; /* IPv6 of gateway */ - const char *pattern_metric = "metric\\s+(\\d+)"; /* metric */ - - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (s_ip6 != NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - /* Read the route file */ - if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { - g_free (contents); - return TRUE; /* missing/empty = success */ - } - - /* Create regexes for pieces to be matched */ - regex_to1 = g_regex_new (pattern_to1, 0, 0, NULL); - regex_to2 = g_regex_new (pattern_to2, 0, 0, NULL); - regex_via = g_regex_new (pattern_via, 0, 0, NULL); - regex_metric = g_regex_new (pattern_metric, 0, 0, NULL); - - /* Iterate through file lines */ - lines = g_strsplit_set (contents, "\n\r", -1); - for (iter = lines; iter && *iter; iter++) { - NMIPRoute *route; - - /* Skip empty lines */ - if (g_regex_match_simple (pattern_empty, *iter, 0, 0)) - continue; - - /* Destination */ - g_regex_match (regex_to1, *iter, 0, &match_info); - if (!g_match_info_matches (match_info)) { - g_match_info_free (match_info); - g_regex_match (regex_to2, *iter, 0, &match_info); - if (!g_match_info_matches (match_info)) { - g_match_info_free (match_info); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IP6 route destination address in record: '%s'", *iter); - goto error; - } - } - dest = g_match_info_fetch (match_info, 1); - if (!g_strcmp0 (dest, "default")) { - /* Ignore default route - NM handles it internally */ - g_clear_pointer (&dest, g_free); - g_match_info_free (match_info); - PARSE_WARNING ("ignoring manual default route: '%s' (%s)", *iter, filename); - continue; - } - - /* Prefix - is optional; 128 if missing */ - prefix = g_match_info_fetch (match_info, 2); - g_match_info_free (match_info); - prefix_int = 128; - if (prefix) { - prefix_int = _nm_utils_ascii_str_to_int64 (prefix, 10, 1, 128, -1); - if (prefix_int == -1) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP6 route destination prefix '%s'", prefix); - g_free (dest); - g_free (prefix); - goto error; - } - } - g_free (prefix); - - /* Next hop */ - g_regex_match (regex_via, *iter, 0, &match_info); - if (g_match_info_matches (match_info)) { - next_hop = g_match_info_fetch (match_info, 1); - if (!nm_utils_ipaddr_valid (AF_INET6, next_hop)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IPv6 route nexthop address '%s'", - next_hop); - g_match_info_free (match_info); - g_free (dest); - g_free (next_hop); - goto error; - } - } else { - /* Missing "via" is taken as :: */ - next_hop = NULL; - } - g_match_info_free (match_info); - - /* Metric */ - g_regex_match (regex_metric, *iter, 0, &match_info); - metric_int = -1; - if (g_match_info_matches (match_info)) { - metric = g_match_info_fetch (match_info, 1); - metric_int = _nm_utils_ascii_str_to_int64 (metric, 10, 0, G_MAXUINT32, -1); - if (metric_int == -1) { - g_match_info_free (match_info); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP6 route metric '%s'", metric); - g_free (dest); - g_free (next_hop); - g_free (metric); - goto error; - } - g_free (metric); - } - g_match_info_free (match_info); - - route = nm_ip_route_new (AF_INET6, dest, prefix_int, next_hop, metric_int, error); - g_free (dest); - g_free (next_hop); - if (!route) - goto error; - if (!nm_setting_ip_config_add_route (s_ip6, route)) - PARSE_WARNING ("duplicate IP6 route"); - nm_ip_route_unref (route); - } - - success = TRUE; - -error: - g_free (contents); - g_strfreev (lines); - g_regex_unref (regex_to1); - g_regex_unref (regex_to2); - g_regex_unref (regex_via); - g_regex_unref (regex_metric); - - return success; -} - - -static NMSetting * -make_ip4_setting (shvarFile *ifcfg, - const char *network_file, - GError **error) -{ - NMSettingIPConfig *s_ip4 = NULL; - char *value = NULL; - char *route_path = NULL; - char *method; - char *dns_options = NULL; - gs_free char *gateway = NULL; - gint32 i; - shvarFile *network_ifcfg; - shvarFile *route_ifcfg; - gboolean never_default = FALSE; - gint64 timeout; - gint priority; - - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - - /* First check if DEFROUTE is set for this device; DEFROUTE has the - * opposite meaning from never-default. The default if DEFROUTE is not - * specified is DEFROUTE=yes which means that this connection can be used - * as a default route - */ - never_default = !svGetValueBoolean (ifcfg, "DEFROUTE", TRUE); - - /* Then check if GATEWAYDEV; it's global and overrides DEFROUTE */ - network_ifcfg = svOpenFile (network_file, NULL); - if (network_ifcfg) { - char *gatewaydev; - - /* Get the connection ifcfg device name and the global gateway device */ - value = svGetValue (ifcfg, "DEVICE", FALSE); - gatewaydev = svGetValue (network_ifcfg, "GATEWAYDEV", FALSE); - dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE); - - /* If there was a global gateway device specified, then only connections - * for that device can be the default connection. - */ - if (gatewaydev && value) - never_default = !!strcmp (value, gatewaydev); - - g_free (gatewaydev); - g_free (value); - svCloseFile (network_ifcfg); - } - - value = svGetValue (ifcfg, "BOOTPROTO", FALSE); - - if (!value || !*value || !g_ascii_strcasecmp (value, "none")) { - if (is_any_ip4_address_defined (ifcfg, NULL)) - method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; - else - method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; - } else if (!g_ascii_strcasecmp (value, "bootp") || !g_ascii_strcasecmp (value, "dhcp")) { - method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; - } else if (!g_ascii_strcasecmp (value, "static")) { - if (is_any_ip4_address_defined (ifcfg, NULL)) - method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; - else - method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; - } else if (!g_ascii_strcasecmp (value, "autoip")) { - method = NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL; - } else if (!g_ascii_strcasecmp (value, "shared")) { - int idx; - - g_free (value); - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED, - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, - NULL); - /* 1 IP address is allowed for shared connections. Read it. */ - if (is_any_ip4_address_defined (ifcfg, &idx)) { - NMIPAddress *addr = NULL; - - if (!read_full_ip4_address (ifcfg, idx, NULL, &addr, NULL, error)) - goto done; - if (!read_ip4_address (ifcfg, "GATEWAY", &gateway, error)) - goto done; - (void) nm_setting_ip_config_add_address (s_ip4, addr); - nm_ip_address_unref (addr); - if (never_default) - PARSE_WARNING ("GATEWAY will be ignored when DEFROUTE is disabled"); - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL); - } - return NM_SETTING (s_ip4); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown BOOTPROTO '%s'", value); - g_free (value); - goto done; - } - g_free (value); - - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svGetValueBoolean (ifcfg, "PEERDNS", TRUE), - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svGetValueBoolean (ifcfg, "PEERROUTES", TRUE), - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, - NM_SETTING_IP_CONFIG_MAY_FAIL, !svGetValueBoolean (ifcfg, "IPV4_FAILURE_FATAL", FALSE), - NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV4_ROUTE_METRIC", 10, - -1, G_MAXUINT32, -1), - NULL); - - if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) - return NM_SETTING (s_ip4); - - /* Handle DHCP settings */ - if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); - if (value && *value) - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); - g_free (value); - - value = svGetValue (ifcfg, "DHCP_FQDN", FALSE); - if (value && *value) { - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NULL, - NM_SETTING_IP4_CONFIG_DHCP_FQDN, value, - NULL); - } - g_free (value); - - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), - NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXINT32, 0), - NULL); - - value = svGetValue (ifcfg, "DHCP_CLIENT_ID", FALSE); - if (value && strlen (value)) - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, value, NULL); - g_free (value); - } - - /* Read static IP addresses. - * Read them even for AUTO method - in this case the addresses are - * added to the automatic ones. Note that this is not currently supported by - * the legacy 'network' service (ifup-eth). - */ - for (i = -1; i < 256; i++) { - NMIPAddress *addr = NULL; - - /* gateway will only be set if still unset. Hence, we don't leak gateway - * here by calling read_full_ip4_address() repeatedly */ - if (!read_full_ip4_address (ifcfg, i, NULL, &addr, &gateway, error)) - goto done; - - if (!addr) { - /* The first mandatory variable is 2-indexed (IPADDR2) - * Variables IPADDR, IPADDR0 and IPADDR1 are optional */ - if (i > 1) - break; - continue; - } - - if (!nm_setting_ip_config_add_address (s_ip4, addr)) - PARSE_WARNING ("duplicate IP4 address"); - nm_ip_address_unref (addr); - } - - /* Gateway */ - if (!gateway) { - network_ifcfg = svOpenFile (network_file, NULL); - if (network_ifcfg) { - gboolean read_success; - - read_success = read_ip4_address (network_ifcfg, "GATEWAY", &gateway, error); - svCloseFile (network_ifcfg); - if (!read_success) - goto done; - - if (gateway && nm_setting_ip_config_get_num_addresses (s_ip4) == 0) { - gs_free char *f = g_path_get_basename (ifcfg->fileName); - PARSE_WARNING ("ignoring GATEWAY (/etc/sysconfig/network) for %s " - "because the connection has no static addresses", f); - g_clear_pointer (&gateway, g_free); - } - } - } - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL); - - if (gateway && never_default) - PARSE_WARNING ("GATEWAY will be ignored when DEFROUTE is disabled"); - - /* DNS servers - * Pick up just IPv4 addresses (IPv6 addresses are taken by make_ip6_setting()) - */ - for (i = 1; i <= 10; i++) { - char *tag; - - tag = g_strdup_printf ("DNS%u", i); - value = svGetValue (ifcfg, tag, FALSE); - if (value) { - if (nm_utils_ipaddr_valid (AF_INET, value)) { - if (!nm_setting_ip_config_add_dns (s_ip4, value)) - PARSE_WARNING ("duplicate DNS server %s", tag); - } else if (nm_utils_ipaddr_valid (AF_INET6, value)) { - /* Ignore IPv6 addresses */ - } else { - PARSE_WARNING ("invalid DNS server address %s", value); - g_free (tag); - g_free (value); - goto done; - } - - g_free (value); - } - - g_free (tag); - } - - /* DNS searches */ - value = svGetValue (ifcfg, "DOMAIN", FALSE); - if (value) { - char **searches = NULL; - - searches = g_strsplit (value, " ", 0); - if (searches) { - char **item; - for (item = searches; *item; item++) { - if (strlen (*item)) { - if (!nm_setting_ip_config_add_dns_search (s_ip4, *item)) - PARSE_WARNING ("duplicate DNS domain '%s'", *item); - } - } - g_strfreev (searches); - } - g_free (value); - } - - /* DNS options */ - value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE); - parse_dns_options (s_ip4, value); - parse_dns_options (s_ip4, dns_options); - g_free (value); - g_free (dns_options); - dns_options = NULL; - - /* DNS priority */ - priority = svGetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0); - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_DNS_PRIORITY, - priority, - NULL); - - /* Static routes - route- file */ - route_path = utils_get_route_path (ifcfg->fileName); - - if (utils_has_complex_routes (route_path)) { - PARSE_WARNING ("'rule-' or 'rule6-' file is present; you will need to use a dispatcher script to apply these routes"); - } else if (utils_has_route_file_new_syntax (route_path)) { - /* Parse route file in new syntax */ - route_ifcfg = utils_get_route_ifcfg (ifcfg->fileName, FALSE); - if (route_ifcfg) { - for (i = 0; i < 256; i++) { - NMIPRoute *route = NULL; - - if (!read_one_ip4_route (route_ifcfg, i, &route, error)) { - svCloseFile (route_ifcfg); - goto done; - } - - if (!route) - break; - - if (!nm_setting_ip_config_add_route (s_ip4, route)) - PARSE_WARNING ("duplicate IP4 route"); - nm_ip_route_unref (route); - } - svCloseFile (route_ifcfg); - } - } else { - if (!read_route_file_legacy (route_path, s_ip4, error)) - goto done; - } - g_free (route_path); - - /* Legacy value NM used for a while but is incorrect (rh #459370) */ - if (!nm_setting_ip_config_get_num_dns_searches (s_ip4)) { - value = svGetValue (ifcfg, "SEARCH", FALSE); - if (value) { - char **searches = NULL; - - searches = g_strsplit (value, " ", 0); - if (searches) { - char **item; - for (item = searches; *item; item++) { - if (strlen (*item)) { - if (!nm_setting_ip_config_add_dns_search (s_ip4, *item)) - PARSE_WARNING ("duplicate DNS search '%s'", *item); - } - } - g_strfreev (searches); - } - g_free (value); - } - } - - timeout = svGetValueInt64 (ifcfg, "ARPING_WAIT", 10, -1, - NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX / 1000, -1); - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DAD_TIMEOUT, - (gint) (timeout <= 0 ? timeout : timeout * 1000), NULL); - - return NM_SETTING (s_ip4); - -done: - g_free (dns_options); - g_free (route_path); - g_object_unref (s_ip4); - return NULL; -} - -static void -read_aliases (NMSettingIPConfig *s_ip4, const char *filename) -{ - GDir *dir; - char *dirname, *base; - shvarFile *parsed; - NMIPAddress *base_addr = NULL; - GError *err = NULL; - - g_return_if_fail (s_ip4 != NULL); - g_return_if_fail (filename != NULL); - - if (nm_setting_ip_config_get_num_addresses (s_ip4) > 0) - base_addr = nm_setting_ip_config_get_address (s_ip4, 0); - - dirname = g_path_get_dirname (filename); - g_return_if_fail (dirname != NULL); - base = g_path_get_basename (filename); - g_return_if_fail (base != NULL); - - dir = g_dir_open (dirname, 0, &err); - if (dir) { - const char *item; - NMIPAddress *addr; - gboolean ok; - - while ((item = g_dir_read_name (dir))) { - char *full_path, *device; - const char *p; - - if (!utils_is_ifcfg_alias_file (item, base)) - continue; - - full_path = g_build_filename (dirname, item, NULL); - - p = strchr (item, ':'); - g_assert (p != NULL); /* we know this is true from utils_is_ifcfg_alias_file() */ - for (p++; *p; p++) { - if (!g_ascii_isalnum (*p) && *p != '_') - break; - } - if (*p) { - PARSE_WARNING ("ignoring alias file '%s' with invalid name", full_path); - g_free (full_path); - continue; - } - - parsed = svOpenFile (full_path, &err); - if (!parsed) { - PARSE_WARNING ("couldn't parse alias file '%s': %s", full_path, err->message); - g_free (full_path); - g_clear_error (&err); - continue; - } - - device = svGetValue (parsed, "DEVICE", FALSE); - if (!device) { - PARSE_WARNING ("alias file '%s' has no DEVICE", full_path); - svCloseFile (parsed); - g_free (full_path); - continue; - } - /* We know that item starts with IFCFG_TAG from utils_is_ifcfg_alias_file() */ - if (strcmp (device, item + strlen (IFCFG_TAG)) != 0) { - PARSE_WARNING ("alias file '%s' has invalid DEVICE (%s) for filename", - full_path, device); - g_free (device); - svCloseFile (parsed); - g_free (full_path); - continue; - } - - addr = NULL; - ok = read_full_ip4_address (parsed, -1, base_addr, &addr, NULL, &err); - svCloseFile (parsed); - if (ok) { - nm_ip_address_set_attribute (addr, "label", g_variant_new_string (device)); - if (!nm_setting_ip_config_add_address (s_ip4, addr)) - PARSE_WARNING ("duplicate IP4 address in alias file %s", item); - } else { - PARSE_WARNING ("error reading IP4 address from alias file '%s': %s", - full_path, err ? err->message : "no address"); - g_clear_error (&err); - } - nm_ip_address_unref (addr); - - g_free (device); - g_free (full_path); - } - - g_dir_close (dir); - } else { - PARSE_WARNING ("can not read directory '%s': %s", dirname, err->message); - g_error_free (err); - } - - g_free (base); - g_free (dirname); -} - -static NMSetting * -make_ip6_setting (shvarFile *ifcfg, - const char *network_file, - GError **error) -{ - NMSettingIPConfig *s_ip6 = NULL; - char *value = NULL; - char *str_value; - char *route6_path = NULL; - char *dns_options = NULL; - gboolean ipv6init, ipv6forwarding, ipv6_autoconf, dhcp6 = FALSE; - char *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; - char *ipv6addr, *ipv6addr_secondaries; - char **list = NULL, **iter; - guint32 i; - gint priority; - shvarFile *network_ifcfg; - gboolean never_default = FALSE; - gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip; - NMSettingIP6ConfigPrivacy ip6_privacy_val; - NMSettingIP6ConfigAddrGenMode addr_gen_mode; - char *tmp; - - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - - /* First check if IPV6_DEFROUTE is set for this device; IPV6_DEFROUTE has the - * opposite meaning from never-default. The default if IPV6_DEFROUTE is not - * specified is IPV6_DEFROUTE=yes which means that this connection can be used - * as a default route - */ - never_default = !svGetValueBoolean (ifcfg, "IPV6_DEFROUTE", TRUE); - - /* Then check if IPV6_DEFAULTGW or IPV6_DEFAULTDEV is specified; - * they are global and override IPV6_DEFROUTE - * When both are set, the device specified in IPV6_DEFAULTGW takes preference. - */ - network_ifcfg = svOpenFile (network_file, NULL); - if (network_ifcfg) { - char *ipv6_defaultgw, *ipv6_defaultdev; - char *default_dev = NULL; - - /* Get the connection ifcfg device name and the global default route device */ - value = svGetValue (ifcfg, "DEVICE", FALSE); - ipv6_defaultgw = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); - ipv6_defaultdev = svGetValue (network_ifcfg, "IPV6_DEFAULTDEV", FALSE); - dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE); - - if (ipv6_defaultgw) { - default_dev = strchr (ipv6_defaultgw, '%'); - if (default_dev) - default_dev++; - } - if (!default_dev) - default_dev = ipv6_defaultdev; - - /* If there was a global default route device specified, then only connections - * for that device can be the default connection. - */ - if (default_dev && value) - never_default = !!strcmp (value, default_dev); - - g_free (ipv6_defaultgw); - g_free (ipv6_defaultdev); - g_free (value); - svCloseFile (network_ifcfg); - } - - /* Find out method property */ - /* Is IPV6 enabled? Set method to "ignored", when not enabled */ - str_value = svGetValue (ifcfg, "IPV6INIT", FALSE); - ipv6init = svGetValueBoolean (ifcfg, "IPV6INIT", FALSE); - if (!str_value) { - network_ifcfg = svOpenFile (network_file, NULL); - if (network_ifcfg) { - ipv6init = svGetValueBoolean (network_ifcfg, "IPV6INIT", FALSE); - svCloseFile (network_ifcfg); - } - } - g_free (str_value); - - if (!ipv6init) - method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; /* IPv6 is disabled */ - else { - ipv6forwarding = svGetValueBoolean (ifcfg, "IPV6FORWARDING", FALSE); - ipv6_autoconf = svGetValueBoolean (ifcfg, "IPV6_AUTOCONF", !ipv6forwarding); - dhcp6 = svGetValueBoolean (ifcfg, "DHCPV6C", FALSE); - - if (ipv6_autoconf) - method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; - else if (dhcp6) - method = NM_SETTING_IP6_CONFIG_METHOD_DHCP; - else { - /* IPV6_AUTOCONF=no and no IPv6 address -> method 'link-local' */ - str_value = svGetValue (ifcfg, "IPV6ADDR", FALSE); - if (!str_value) - str_value = svGetValue (ifcfg, "IPV6ADDR_SECONDARIES", FALSE); - - if (!str_value) - method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; - g_free (str_value); - } - } - /* TODO - handle other methods */ - - /* Read IPv6 Privacy Extensions configuration */ - tmp = svGetValue (ifcfg, "IPV6_PRIVACY", FALSE); - if (tmp) { - ip6_privacy = svGetValueBoolean (ifcfg, "IPV6_PRIVACY", FALSE); - if (!ip6_privacy) - ip6_privacy = g_strcmp0 (tmp, "rfc4941") == 0 || - g_strcmp0 (tmp, "rfc3041") == 0; - } - ip6_privacy_prefer_public_ip = svGetValueBoolean (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", FALSE); - ip6_privacy_val = tmp ? - (ip6_privacy ? - (ip6_privacy_prefer_public_ip ? NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR : NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) : - NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED) : - NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; - g_free (tmp); - - g_object_set (s_ip6, - NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svGetValueBoolean (ifcfg, "IPV6_PEERDNS", TRUE), - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svGetValueBoolean (ifcfg, "IPV6_PEERROUTES", TRUE), - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, - NM_SETTING_IP_CONFIG_MAY_FAIL, !svGetValueBoolean (ifcfg, "IPV6_FAILURE_FATAL", FALSE), - NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV6_ROUTE_METRIC", 10, - -1, G_MAXUINT32, -1), - NM_SETTING_IP6_CONFIG_IP6_PRIVACY, ip6_privacy_val, - NULL); - - /* Don't bother to read IP, DNS and routes when IPv6 is disabled */ - if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) - return NM_SETTING (s_ip6); - - if ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) - || !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { - /* METHOD_AUTO may trigger DHCPv6, so save the hostname to send to DHCP */ - value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); - if (value && value[0]) - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); - g_free (value); - } - - /* Read static IP addresses. - * Read them even for AUTO and DHCP methods - in this case the addresses are - * added to the automatic ones. Note that this is not currently supported by - * the legacy 'network' service (ifup-eth). - */ - ipv6addr = svGetValue (ifcfg, "IPV6ADDR", FALSE); - ipv6addr_secondaries = svGetValue (ifcfg, "IPV6ADDR_SECONDARIES", FALSE); - - value = g_strjoin (ipv6addr && ipv6addr_secondaries ? " " : NULL, - ipv6addr ? ipv6addr : "", - ipv6addr_secondaries ? ipv6addr_secondaries : "", - NULL); - g_free (ipv6addr); - g_free (ipv6addr_secondaries); - - list = g_strsplit_set (value, " ", 0); - g_free (value); - for (iter = list, i = 0; iter && *iter; iter++, i++) { - NMIPAddress *addr = NULL; - - if (!parse_full_ip6_address (ifcfg, *iter, i, &addr, error)) { - g_strfreev (list); - goto error; - } - - if (!nm_setting_ip_config_add_address (s_ip6, addr)) - PARSE_WARNING ("duplicate IP6 address"); - nm_ip_address_unref (addr); - } - g_strfreev (list); - - /* Gateway */ - if (nm_setting_ip_config_get_num_addresses (s_ip6)) { - value = svGetValue (ifcfg, "IPV6_DEFAULTGW", FALSE); - if (!value) { - /* If no gateway in the ifcfg, try global /etc/sysconfig/network instead */ - network_ifcfg = svOpenFile (network_file, NULL); - if (network_ifcfg) { - value = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); - svCloseFile (network_ifcfg); - } - } - if (value) { - char *ptr; - if ((ptr = strchr (value, '%')) != NULL) - *ptr = '\0'; /* remove %interface prefix if present */ - if (!nm_utils_ipaddr_valid (AF_INET6, value)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP6 address '%s'", value); - g_free (value); - goto error; - } - - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, value, NULL); - g_free (value); - } - } - - /* IPv6 addressing mode configuration */ - tmp = svGetValue (ifcfg, "IPV6_ADDR_GEN_MODE", FALSE); - if (tmp) { - if (nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), tmp, - (int *) &addr_gen_mode, NULL)) - g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, addr_gen_mode, NULL); - else - PARSE_WARNING ("Invalid IPV6_ADDR_GEN_MODE"); - g_free (tmp); - } else { - g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, - NULL); - } - - /* IPv6 tokenized interface identifier */ - tmp = svGetValue (ifcfg, "IPV6_TOKEN", FALSE); - if (tmp) { - g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, tmp, NULL); - g_free (tmp); - } - - /* DNS servers - * Pick up just IPv6 addresses (IPv4 addresses are taken by make_ip4_setting()) - */ - for (i = 1; i <= 10; i++) { - char *tag; - - tag = g_strdup_printf ("DNS%u", i); - value = svGetValue (ifcfg, tag, FALSE); - if (!value) { - g_free (tag); - break; /* all done */ - } - - if (nm_utils_ipaddr_valid (AF_INET6, value)) { - if (!nm_setting_ip_config_add_dns (s_ip6, value)) - PARSE_WARNING ("duplicate DNS server %s", tag); - } else if (nm_utils_ipaddr_valid (AF_INET, value)) { - /* Ignore IPv4 addresses */ - } else { - PARSE_WARNING ("invalid DNS server address %s", value); - g_free (tag); - g_free (value); - goto error; - } - - g_free (tag); - g_free (value); - } - - /* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */ - - if (!utils_has_complex_routes (ifcfg->fileName)) { - /* Read static routes from route6- file */ - route6_path = utils_get_route6_path (ifcfg->fileName); - if (!read_route6_file (route6_path, s_ip6, error)) - goto error; - - g_free (route6_path); - } - - /* DNS options */ - value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE); - parse_dns_options (s_ip6, value); - parse_dns_options (s_ip6, dns_options); - g_free (value); - g_free (dns_options); - - /* DNS priority */ - priority = svGetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0); - g_object_set (s_ip6, - NM_SETTING_IP_CONFIG_DNS_PRIORITY, - priority, - NULL); - - return NM_SETTING (s_ip6); - -error: - g_free (dns_options); - g_free (route6_path); - g_object_unref (s_ip6); - return NULL; -} - -static void -check_if_bond_slave (shvarFile *ifcfg, - NMSettingConnection *s_con) -{ - char *value; - - value = svGetValue (ifcfg, "MASTER", FALSE); - if (value) { - g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); - g_object_set (s_con, - NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME, - NULL); - g_free (value); - } - - /* We should be checking for SLAVE=yes as well, but NM used to not set that, - * so for backward-compatibility, we don't check. - */ -} - -static gboolean -check_if_team_slave (shvarFile *ifcfg, - NMSettingConnection *s_con) -{ - gs_free char *value = NULL; - - value = svGetValue (ifcfg, "TEAM_MASTER", FALSE); - if (!value) - return FALSE; - g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); - g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); - return TRUE; -} - -static void -check_if_slave (shvarFile *ifcfg, - NMSettingConnection *s_con) -{ - g_return_if_fail (NM_IS_SETTING_CONNECTION (s_con)); - - if (check_if_team_slave (ifcfg, s_con)) - return; - check_if_bond_slave (ifcfg, s_con); -} - -typedef struct { - const char *enable_key; - const char *advertise_key; - const char *willing_key; - const char *flags_prop; -} DcbFlagsProperty; - -enum { - DCB_APP_FCOE_FLAGS = 0, - DCB_APP_ISCSI_FLAGS = 1, - DCB_APP_FIP_FLAGS = 2, - DCB_PFC_FLAGS = 3, - DCB_PG_FLAGS = 4, -}; - -static DcbFlagsProperty dcb_flags_props[] = { - { KEY_DCB_APP_FCOE_ENABLE, KEY_DCB_APP_FCOE_ADVERTISE, KEY_DCB_APP_FCOE_WILLING, NM_SETTING_DCB_APP_FCOE_FLAGS }, - { KEY_DCB_APP_ISCSI_ENABLE, KEY_DCB_APP_ISCSI_ADVERTISE, KEY_DCB_APP_ISCSI_WILLING, NM_SETTING_DCB_APP_ISCSI_FLAGS }, - { KEY_DCB_APP_FIP_ENABLE, KEY_DCB_APP_FIP_ADVERTISE, KEY_DCB_APP_FIP_WILLING, NM_SETTING_DCB_APP_FIP_FLAGS }, - { KEY_DCB_PFC_ENABLE, KEY_DCB_PFC_ADVERTISE, KEY_DCB_PFC_WILLING, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS }, - { KEY_DCB_PG_ENABLE, KEY_DCB_PG_ADVERTISE, KEY_DCB_PG_WILLING, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS }, - { NULL }, -}; - -static NMSettingDcbFlags -read_dcb_flags (shvarFile *ifcfg, DcbFlagsProperty *property) -{ - NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; - - if (svGetValueBoolean (ifcfg, property->enable_key, FALSE)) - flags |= NM_SETTING_DCB_FLAG_ENABLE; - if (svGetValueBoolean (ifcfg, property->advertise_key, FALSE)) - flags |= NM_SETTING_DCB_FLAG_ADVERTISE; - if (svGetValueBoolean (ifcfg, property->willing_key, FALSE)) - flags |= NM_SETTING_DCB_FLAG_WILLING; - - return flags; -} - -static gboolean -read_dcb_app (shvarFile *ifcfg, - NMSettingDcb *s_dcb, - const char *app, - DcbFlagsProperty *flags_prop, - const char *priority_prop, - GError **error) -{ - NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; - char *tmp, *val; - gboolean success = TRUE; - int priority = -1; - - flags = read_dcb_flags (ifcfg, flags_prop); - - /* Priority */ - tmp = g_strdup_printf ("DCB_APP_%s_PRIORITY", app); - val = svGetValue (ifcfg, tmp, FALSE); - if (val) { - priority = _nm_utils_ascii_str_to_int64 (val, 0, 0, 7, -1); - if (priority < 0) { - success = FALSE; - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid %s value '%s' (expected 0 - 7)", - tmp, val); - } - g_free (val); - - if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) - PARSE_WARNING ("ignoring DCB %s priority; app not enabled", app); - } - g_free (tmp); - - if (success) { - g_object_set (G_OBJECT (s_dcb), - flags_prop->flags_prop, flags, - priority_prop, (guint) priority, - NULL); - } - - return success; -} - -typedef void (*DcbSetBoolFunc) (NMSettingDcb *, guint, gboolean); - -static gboolean -read_dcb_bool_array (shvarFile *ifcfg, - NMSettingDcb *s_dcb, - NMSettingDcbFlags flags, - const char *prop, - const char *desc, - DcbSetBoolFunc set_func, - GError **error) -{ - char *val; - gboolean success = FALSE; - guint i; - - val = svGetValue (ifcfg, prop, FALSE); - if (!val) - return TRUE; - - if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - PARSE_WARNING ("ignoring %s; %s is not enabled", prop, desc); - success = TRUE; - goto out; - } - - val = g_strstrip (val); - if (strlen (val) != 8) { - PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "boolean array must be 8 characters"); - goto out; - } - - /* All characters must be either 0 or 1 */ - for (i = 0; i < 8; i++) { - if (val[i] != '0' && val[i] != '1') { - PARSE_WARNING ("invalid %s value '%s': not all 0s and 1s", prop, val); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "invalid boolean digit"); - goto out; - } - set_func (s_dcb, i, (val[i] == '1')); - } - success = TRUE; - -out: - g_free (val); - return success; -} - -typedef void (*DcbSetUintFunc) (NMSettingDcb *, guint, guint); - -static gboolean -read_dcb_uint_array (shvarFile *ifcfg, - NMSettingDcb *s_dcb, - NMSettingDcbFlags flags, - const char *prop, - const char *desc, - gboolean f_allowed, - DcbSetUintFunc set_func, - GError **error) -{ - char *val; - gboolean success = FALSE; - guint i; - - val = svGetValue (ifcfg, prop, FALSE); - if (!val) - return TRUE; - - if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - PARSE_WARNING ("ignoring %s; %s is not enabled", prop, desc); - success = TRUE; - goto out; - } - - val = g_strstrip (val); - if (strlen (val) != 8) { - PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "uint array must be 8 characters"); - goto out; - } - - /* All characters must be either 0 - 7 or (optionally) f */ - for (i = 0; i < 8; i++) { - if (val[i] >= '0' && val[i] <= '7') - set_func (s_dcb, i, val[i] - '0'); - else if (f_allowed && (val[i] == 'f' || val[i] == 'F')) - set_func (s_dcb, i, 15); - else { - PARSE_WARNING ("invalid %s value '%s': not 0 - 7%s", - prop, val, f_allowed ? " or 'f'" : ""); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "invalid uint digit"); - goto out; - } - } - success = TRUE; - -out: - g_free (val); - return success; -} - -static gboolean -read_dcb_percent_array (shvarFile *ifcfg, - NMSettingDcb *s_dcb, - NMSettingDcbFlags flags, - const char *prop, - const char *desc, - gboolean sum_pct, - DcbSetUintFunc set_func, - GError **error) -{ - char *val; - gboolean success = FALSE; - char **split = NULL, **iter; - guint i, sum = 0; - - val = svGetValue (ifcfg, prop, FALSE); - if (!val) - return TRUE; - - if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - PARSE_WARNING ("ignoring %s; %s is not enabled", prop, desc); - success = TRUE; - goto out; - } - - val = g_strstrip (val); - split = g_strsplit_set (val, ",", 0); - if (!split || (g_strv_length (split) != 8)) { - PARSE_WARNING ("invalid %s percentage list value '%s'", prop, val); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "percent array must be 8 elements"); - goto out; - } - - for (iter = split, i = 0; iter && *iter; iter++, i++) { - int tmp; - - tmp = _nm_utils_ascii_str_to_int64 (*iter, 0, 0, 100, -1); - if (tmp < 0) { - PARSE_WARNING ("invalid %s percentage value '%s'", prop, *iter); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "invalid percent element"); - goto out; - } - set_func (s_dcb, i, (guint) tmp); - sum += (guint) tmp; - } - - if (sum_pct && (sum != 100)) { - PARSE_WARNING ("%s percentages do not equal 100%%", prop); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "invalid percentage sum"); - goto out; - } - - success = TRUE; - -out: - if (split) - g_strfreev (split); - g_free (val); - return success; -} - -static gboolean -make_dcb_setting (shvarFile *ifcfg, - const char *network_file, - NMSetting **out_setting, - GError **error) -{ - NMSettingDcb *s_dcb = NULL; - gboolean dcb_on; - NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; - char *val; - - g_return_val_if_fail (out_setting != NULL, FALSE); - - dcb_on = !!svGetValueBoolean (ifcfg, "DCB", FALSE); - if (!dcb_on) - return TRUE; - - s_dcb = (NMSettingDcb *) nm_setting_dcb_new (); - g_assert (s_dcb); - - /* FCOE */ - if (!read_dcb_app (ifcfg, s_dcb, "FCOE", - &dcb_flags_props[DCB_APP_FCOE_FLAGS], - NM_SETTING_DCB_APP_FCOE_PRIORITY, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - if (nm_setting_dcb_get_app_fcoe_flags (s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) { - val = svGetValue (ifcfg, KEY_DCB_APP_FCOE_MODE, FALSE); - if (val) { - if (strcmp (val, NM_SETTING_DCB_FCOE_MODE_FABRIC) == 0 || - strcmp (val, NM_SETTING_DCB_FCOE_MODE_VN2VN) == 0) - g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_FCOE_MODE, val, NULL); - else { - PARSE_WARNING ("invalid FCoE mode '%s'", val); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "invalid FCoE mode"); - g_free (val); - g_object_unref (s_dcb); - return FALSE; - } - g_free (val); - } - } - - /* iSCSI */ - if (!read_dcb_app (ifcfg, s_dcb, "ISCSI", - &dcb_flags_props[DCB_APP_ISCSI_FLAGS], - NM_SETTING_DCB_APP_ISCSI_PRIORITY, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - /* FIP */ - if (!read_dcb_app (ifcfg, s_dcb, "FIP", - &dcb_flags_props[DCB_APP_FIP_FLAGS], - NM_SETTING_DCB_APP_FIP_PRIORITY, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - /* Priority Flow Control */ - flags = read_dcb_flags (ifcfg, &dcb_flags_props[DCB_PFC_FLAGS]); - g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, flags, NULL); - - if (!read_dcb_bool_array (ifcfg, - s_dcb, - flags, - KEY_DCB_PFC_UP, - "PFC", - nm_setting_dcb_set_priority_flow_control, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - /* Priority Groups */ - flags = read_dcb_flags (ifcfg, &dcb_flags_props[DCB_PG_FLAGS]); - g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, flags, NULL); - - if (!read_dcb_uint_array (ifcfg, - s_dcb, - flags, - KEY_DCB_PG_ID, - "PGID", - TRUE, - nm_setting_dcb_set_priority_group_id, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - /* Group bandwidth */ - if (!read_dcb_percent_array (ifcfg, - s_dcb, - flags, - KEY_DCB_PG_PCT, - "PGPCT", - TRUE, - nm_setting_dcb_set_priority_group_bandwidth, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - /* Priority bandwidth */ - if (!read_dcb_percent_array (ifcfg, - s_dcb, - flags, - KEY_DCB_PG_UPPCT, - "UPPCT", - FALSE, - nm_setting_dcb_set_priority_bandwidth, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - /* Strict Bandwidth */ - if (!read_dcb_bool_array (ifcfg, - s_dcb, - flags, - KEY_DCB_PG_STRICT, - "STRICT", - nm_setting_dcb_set_priority_strict_bandwidth, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - if (!read_dcb_uint_array (ifcfg, - s_dcb, - flags, - KEY_DCB_PG_UP2TC, - "UP2TC", - FALSE, - nm_setting_dcb_set_priority_traffic_class, - error)) { - g_object_unref (s_dcb); - return FALSE; - } - - *out_setting = NM_SETTING (s_dcb); - return TRUE; -} - -static gboolean -add_one_wep_key (shvarFile *ifcfg, - const char *shvar_key, - guint8 key_idx, - gboolean passphrase, - NMSettingWirelessSecurity *s_wsec, - GError **error) -{ - char *key = NULL; - char *value = NULL; - gboolean success = FALSE; - - g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (shvar_key != NULL, FALSE); - g_return_val_if_fail (key_idx <= 3, FALSE); - g_return_val_if_fail (s_wsec != NULL, FALSE); - - value = svGetValue (ifcfg, shvar_key, FALSE); - if (!value || !strlen (value)) { - g_free (value); - return TRUE; - } - - /* Validate keys */ - if (passphrase) { - if (strlen (value) && strlen (value) < 64) { - key = g_strdup (value); - g_object_set (G_OBJECT (s_wsec), - NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, - NM_WEP_KEY_TYPE_PASSPHRASE, - NULL); - } - } else { - if (strlen (value) == 10 || strlen (value) == 26) { - /* Hexadecimal WEP key */ - char *p = value; - - while (*p) { - if (!g_ascii_isxdigit (*p)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid hexadecimal WEP key."); - goto out; - } - p++; - } - key = g_strdup (value); - } else if ( !strncmp (value, "s:", 2) - && (strlen (value) == 7 || strlen (value) == 15)) { - /* ASCII key */ - char *p = value + 2; - - while (*p) { - if (!g_ascii_isprint ((int) (*p))) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid ASCII WEP key."); - goto out; - } - p++; - } - - /* Remove 's:' prefix. - * Don't convert to hex string. wpa_supplicant takes 'wep_key0' option over D-Bus as byte array - * and converts it to hex string itself. Even though we convert hex string keys into a bin string - * before passing to wpa_supplicant, this prevents two unnecessary conversions. And mainly, - * ASCII WEP key doesn't change to HEX WEP key in UI, which could confuse users. - */ - key = g_strdup (value + 2); - } - } - - if (key) { - nm_setting_wireless_security_set_wep_key (s_wsec, key_idx, key); - g_free (key); - success = TRUE; - } else - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WEP key length."); - -out: - g_free (value); - return success; -} - -static gboolean -read_wep_keys (shvarFile *ifcfg, - guint8 def_idx, - NMSettingWirelessSecurity *s_wsec, - GError **error) -{ - /* Try hex/ascii keys first */ - if (!add_one_wep_key (ifcfg, "KEY1", 0, FALSE, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ifcfg, "KEY2", 1, FALSE, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ifcfg, "KEY3", 2, FALSE, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ifcfg, "KEY4", 3, FALSE, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ifcfg, "KEY", def_idx, FALSE, s_wsec, error)) - return FALSE; - - /* And then passphrases */ - if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE1", 0, TRUE, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE2", 1, TRUE, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE3", 2, TRUE, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE4", 3, TRUE, s_wsec, error)) - return FALSE; - - return TRUE; -} - -static NMSettingSecretFlags -read_secret_flags (shvarFile *ifcfg, const char *flags_key) -{ - NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - char *val; - - g_return_val_if_fail (flags_key != NULL, NM_SETTING_SECRET_FLAG_NONE); - g_return_val_if_fail (flags_key[0] != '\0', NM_SETTING_SECRET_FLAG_NONE); - g_return_val_if_fail (g_str_has_suffix (flags_key, "_FLAGS"), NM_SETTING_SECRET_FLAG_NONE); - - val = svGetValue (ifcfg, flags_key, FALSE); - if (val) { - if (strstr (val, SECRET_FLAG_AGENT)) - flags |= NM_SETTING_SECRET_FLAG_AGENT_OWNED; - if (strstr (val, SECRET_FLAG_NOT_SAVED)) - flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED; - if (strstr (val, SECRET_FLAG_NOT_REQUIRED)) - flags |= NM_SETTING_SECRET_FLAG_NOT_REQUIRED; - - g_free (val); - } - return flags; -} - -static NMSetting * -make_wep_setting (shvarFile *ifcfg, - const char *file, - GError **error) -{ - NMSettingWirelessSecurity *s_wsec; - char *value; - shvarFile *keys_ifcfg = NULL; - int default_key_idx = 0; - gboolean has_default_key = FALSE; - NMSettingSecretFlags key_flags; - - s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NULL); - - value = svGetValue (ifcfg, "DEFAULTKEY", FALSE); - if (value) { - default_key_idx = _nm_utils_ascii_str_to_int64 (value, 0, 1, 4, 0); - if (default_key_idx == 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid default WEP key '%s'", value); - g_free (value); - goto error; - } - has_default_key = TRUE; - default_key_idx--; /* convert to [0...3] */ - g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, (guint) default_key_idx, NULL); - g_free (value); - } - - /* Read WEP key flags */ - key_flags = read_secret_flags (ifcfg, "WEP_KEY_FLAGS"); - g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, key_flags, NULL); - - /* Read keys in the ifcfg file if they are system-owned */ - if (key_flags == NM_SETTING_SECRET_FLAG_NONE) { - if (!read_wep_keys (ifcfg, default_key_idx, s_wsec, error)) - goto error; - - /* Try to get keys from the "shadow" key file */ - keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); - if (keys_ifcfg) { - if (!read_wep_keys (keys_ifcfg, default_key_idx, s_wsec, error)) { - svCloseFile (keys_ifcfg); - goto error; - } - svCloseFile (keys_ifcfg); - g_assert (error == NULL || *error == NULL); - } - } - - value = svGetValue (ifcfg, "SECURITYMODE", FALSE); - if (value) { - char *lcase; - - lcase = g_ascii_strdown (value, -1); - g_free (value); - - if (!strcmp (lcase, "open")) { - g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", NULL); - } else if (!strcmp (lcase, "restricted")) { - g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", NULL); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WEP authentication algorithm '%s'", - lcase); - g_free (lcase); - goto error; - } - g_free (lcase); - } - - /* If no WEP keys were given, and the keys are not agent-owned, and no - * default WEP key index was given, then the connection is unencrypted. - */ - if ( !nm_setting_wireless_security_get_wep_key (s_wsec, 0) - && !nm_setting_wireless_security_get_wep_key (s_wsec, 1) - && !nm_setting_wireless_security_get_wep_key (s_wsec, 2) - && !nm_setting_wireless_security_get_wep_key (s_wsec, 3) - && (has_default_key == FALSE) - && (key_flags == NM_SETTING_SECRET_FLAG_NONE)) { - const char *auth_alg; - - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - if (auth_alg && !strcmp (auth_alg, "shared")) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "WEP Shared Key authentication is invalid for " - "unencrypted connections."); - goto error; - } - - /* Unencrypted */ - g_object_unref (s_wsec); - s_wsec = NULL; - } - - return (NMSetting *) s_wsec; - -error: - if (s_wsec) - g_object_unref (s_wsec); - return NULL; -} - -static gboolean -fill_wpa_ciphers (shvarFile *ifcfg, - NMSettingWirelessSecurity *wsec, - gboolean group, - gboolean adhoc) -{ - char *value = NULL, *p; - char **list = NULL, **iter; - int i = 0; - - p = value = svGetValue (ifcfg, group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", TRUE); - if (!value) - return TRUE; - - /* Strip quotes */ - if (p[0] == '"') - p++; - if (p[strlen (p) - 1] == '"') - p[strlen (p) - 1] = '\0'; - - list = g_strsplit_set (p, " ", 0); - for (iter = list; iter && *iter; iter++, i++) { - /* Ad-Hoc configurations cannot have pairwise ciphers, and can only - * have one group cipher. Ignore any additional group ciphers and - * any pairwise ciphers specified. - */ - if (adhoc) { - if (group && (i > 0)) { - PARSE_WARNING ("ignoring group cipher '%s' (only one group cipher allowed " - "in Ad-Hoc mode)", *iter); - continue; - } else if (!group) { - PARSE_WARNING ("ignoring pairwise cipher '%s' (pairwise not used " - "in Ad-Hoc mode)", *iter); - continue; - } - } - - if (!strcmp (*iter, "CCMP")) { - if (group) - nm_setting_wireless_security_add_group (wsec, "ccmp"); - else - nm_setting_wireless_security_add_pairwise (wsec, "ccmp"); - } else if (!strcmp (*iter, "TKIP")) { - if (group) - nm_setting_wireless_security_add_group (wsec, "tkip"); - else - nm_setting_wireless_security_add_pairwise (wsec, "tkip"); - } else if (group && !strcmp (*iter, "WEP104")) - nm_setting_wireless_security_add_group (wsec, "wep104"); - else if (group && !strcmp (*iter, "WEP40")) - nm_setting_wireless_security_add_group (wsec, "wep40"); - else { - PARSE_WARNING ("ignoring invalid %s cipher '%s'", - group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", - *iter); - } - } - - if (list) - g_strfreev (list); - g_free (value); - return TRUE; -} - -#define WPA_PMK_LEN 32 - -static char * -parse_wpa_psk (shvarFile *ifcfg, - const char *file, - GBytes *ssid, - GError **error) -{ - shvarFile *keys_ifcfg; - char *psk = NULL, *p, *hashed = NULL; - size_t plen; - gboolean quoted = FALSE; - - /* Passphrase must be between 10 and 66 characters in length because WPA - * hex keys are exactly 64 characters (no quoting), and WPA passphrases - * are between 8 and 63 characters (inclusive), plus optional quoting if - * the passphrase contains spaces. - */ - - /* Try to get keys from the "shadow" key file */ - keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); - if (keys_ifcfg) { - psk = svGetValue (keys_ifcfg, "WPA_PSK", TRUE); - svCloseFile (keys_ifcfg); - } - - /* Fall back to the original ifcfg */ - if (!psk) - psk = svGetValue (ifcfg, "WPA_PSK", TRUE); - - if (!psk) - return NULL; - - p = psk; - plen = strlen (p); - - if ( (plen >= 2 && (p[0] == '"' || p[0] == '\'') && p[0] == p[plen - 1]) - || (plen >= 3 && p[0] == '$' && p[1] == '\'' && p[1] == p[plen - 1])) - quoted = TRUE; - - if (!quoted && (strlen (psk) == 64)) { - /* Verify the hex PSK; 64 digits */ - while (*p) { - if (!g_ascii_isxdigit (*p++)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (contains non-hexadecimal characters)"); - goto out; - } - } - hashed = g_strdup (psk); - } else { - /* Prior to 4f6eef9e77265484555663cf666cde4fa8323469 and - * 28e2e446868b94b92edc4a82aa0bf1e3eda8ec54 the writer may not have - * properly quoted passphrases, so just handle anything that's unquoted - * and between 8 and 63 characters as a passphrase. - */ - - /* Get rid of the quotes */ - hashed = utils_single_unquote_string (p); - - /* Length check */ - if (strlen (hashed) < 8 || strlen (hashed) > 63) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (passphrases must be between " - "8 and 63 characters long (inclusive))"); - g_free (hashed); - hashed = NULL; - goto out; - } - } - - if (!hashed) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (doesn't look like a passphrase or hex key)"); - goto out; - } - -out: - g_free (psk); - return hashed; -} - -static gboolean -eap_simple_reader (const char *eap_method, - shvarFile *ifcfg, - shvarFile *keys, - NMSetting8021x *s_8021x, - gboolean phase2, - GError **error) -{ - NMSettingSecretFlags flags; - char *value; - - value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", - eap_method); - return FALSE; - } - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); - g_free (value); - - flags = read_secret_flags (ifcfg, "IEEE_8021X_PASSWORD_FLAGS"); - g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD_FLAGS, flags, NULL); - - /* Only read the password if it's system-owned */ - if (flags == NM_SETTING_SECRET_FLAG_NONE) { - value = svGetValue (ifcfg, "IEEE_8021X_PASSWORD", FALSE); - if (!value && keys) { - /* Try the lookaside keys file */ - value = svGetValue (keys, "IEEE_8021X_PASSWORD", FALSE); - } - - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_PASSWORD for EAP method '%s'.", - eap_method); - return FALSE; - } - - g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, value, NULL); - g_free (value); - } - - return TRUE; -} - -static char * -get_full_file_path (const char *ifcfg_path, const char *file_path) -{ - const char *base = file_path; - char *p, *ret, *dirname; - - g_return_val_if_fail (ifcfg_path != NULL, NULL); - g_return_val_if_fail (file_path != NULL, NULL); - - if (file_path[0] == '/') - return g_strdup (file_path); - - p = strrchr (file_path, '/'); - if (p) - base = p + 1; - - dirname = g_path_get_dirname (ifcfg_path); - ret = g_build_path ("/", dirname, base, NULL); - g_free (dirname); - return ret; -} - -static gboolean -eap_tls_reader (const char *eap_method, - shvarFile *ifcfg, - shvarFile *keys, - NMSetting8021x *s_8021x, - gboolean phase2, - GError **error) -{ - char *value; - char *ca_cert = NULL; - char *real_path = NULL; - char *client_cert = NULL; - char *privkey = NULL; - char *privkey_password = NULL; - gboolean success = FALSE; - NMSetting8021xCKFormat privkey_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - const char *ca_cert_key = phase2 ? "IEEE_8021X_INNER_CA_CERT" : "IEEE_8021X_CA_CERT"; - const char *pk_pw_key = phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD": "IEEE_8021X_PRIVATE_KEY_PASSWORD"; - const char *pk_key = phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" : "IEEE_8021X_PRIVATE_KEY"; - const char *cli_cert_key = phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT"; - const char *pk_pw_flags_key = phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD_FLAGS": "IEEE_8021X_PRIVATE_KEY_PASSWORD_FLAGS"; - const char *pk_pw_flags_prop = phase2 ? NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS : NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS; - NMSettingSecretFlags flags; - - value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", - eap_method); - return FALSE; - } - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); - g_free (value); - - ca_cert = svGetValue (ifcfg, ca_cert_key, FALSE); - if (ca_cert) { - real_path = get_full_file_path (ifcfg->fileName, ca_cert); - if (phase2) { - if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, - real_path, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, - error)) - goto done; - } else { - if (!nm_setting_802_1x_set_ca_cert (s_8021x, - real_path, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, - error)) - goto done; - } - g_free (real_path); - real_path = NULL; - } else { - PARSE_WARNING ("missing %s for EAP method '%s'; this is insecure!", - ca_cert_key, eap_method); - } - - /* Read and set private key password flags */ - flags = read_secret_flags (ifcfg, pk_pw_flags_key); - g_object_set (s_8021x, pk_pw_flags_prop, flags, NULL); - - /* Read the private key password if it's system-owned */ - if (flags == NM_SETTING_SECRET_FLAG_NONE) { - /* Private key password */ - privkey_password = svGetValue (ifcfg, pk_pw_key, FALSE); - if (!privkey_password && keys) { - /* Try the lookaside keys file */ - privkey_password = svGetValue (keys, pk_pw_key, FALSE); - } - - if (!privkey_password) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing %s for EAP method '%s'.", - pk_pw_key, - eap_method); - goto done; - } - } - - /* The private key itself */ - privkey = svGetValue (ifcfg, pk_key, FALSE); - if (!privkey) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing %s for EAP method '%s'.", - pk_key, - eap_method); - goto done; - } - - real_path = get_full_file_path (ifcfg->fileName, privkey); - if (phase2) { - if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, - real_path, - privkey_password, - NM_SETTING_802_1X_CK_SCHEME_PATH, - &privkey_format, - error)) - goto done; - } else { - if (!nm_setting_802_1x_set_private_key (s_8021x, - real_path, - privkey_password, - NM_SETTING_802_1X_CK_SCHEME_PATH, - &privkey_format, - error)) - goto done; - } - g_free (real_path); - real_path = NULL; - - /* Only set the client certificate if the private key is not PKCS#12 format, - * as NM (due to supplicant restrictions) requires. If the key was PKCS#12, - * then nm_setting_802_1x_set_private_key() already set the client certificate - * to the same value as the private key. - */ - if ( privkey_format == NM_SETTING_802_1X_CK_FORMAT_RAW_KEY - || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { - client_cert = svGetValue (ifcfg, cli_cert_key, FALSE); - if (!client_cert) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing %s for EAP method '%s'.", - cli_cert_key, - eap_method); - goto done; - } - - real_path = get_full_file_path (ifcfg->fileName, client_cert); - if (phase2) { - if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, - real_path, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, - error)) - goto done; - } else { - if (!nm_setting_802_1x_set_client_cert (s_8021x, - real_path, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, - error)) - goto done; - } - g_free (real_path); - real_path = NULL; - } - - success = TRUE; - -done: - g_free (real_path); - g_free (ca_cert); - g_free (client_cert); - g_free (privkey); - g_free (privkey_password); - return success; -} - -static gboolean -eap_peap_reader (const char *eap_method, - shvarFile *ifcfg, - shvarFile *keys, - NMSetting8021x *s_8021x, - gboolean phase2, - GError **error) -{ - char *anon_ident = NULL; - char *ca_cert = NULL; - char *real_cert_path = NULL; - char *inner_auth = NULL; - char *peapver = NULL; - char *lower; - char **list = NULL, **iter; - gboolean success = FALSE; - - ca_cert = svGetValue (ifcfg, "IEEE_8021X_CA_CERT", FALSE); - if (ca_cert) { - real_cert_path = get_full_file_path (ifcfg->fileName, ca_cert); - if (!nm_setting_802_1x_set_ca_cert (s_8021x, - real_cert_path, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, - error)) - goto done; - } else { - PARSE_WARNING ("missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", - eap_method); - } - - peapver = svGetValue (ifcfg, "IEEE_8021X_PEAP_VERSION", FALSE); - if (peapver) { - if (!strcmp (peapver, "0")) - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "0", NULL); - else if (!strcmp (peapver, "1")) - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "1", NULL); - else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown IEEE_8021X_PEAP_VERSION value '%s'", - peapver); - goto done; - } - } - - if (svGetValueBoolean (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", FALSE)) - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPLABEL, "1", NULL); - - anon_ident = svGetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", FALSE); - if (anon_ident && strlen (anon_ident)) - g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); - - inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); - if (!inner_auth) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_INNER_AUTH_METHODS."); - goto done; - } - - /* Handle options for the inner auth method */ - list = g_strsplit (inner_auth, " ", 0); - for (iter = list; iter && *iter; iter++) { - if (!strlen (*iter)) - continue; - - if ( !strcmp (*iter, "MSCHAPV2") - || !strcmp (*iter, "MD5") - || !strcmp (*iter, "GTC")) { - if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) - goto done; - } else if (!strcmp (*iter, "TLS")) { - if (!eap_tls_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) - goto done; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", - *iter); - goto done; - } - - lower = g_ascii_strdown (*iter, -1); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, lower, NULL); - g_free (lower); - break; - } - - if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "No valid IEEE_8021X_INNER_AUTH_METHODS found."); - goto done; - } - - success = TRUE; - -done: - if (list) - g_strfreev (list); - g_free (inner_auth); - g_free (peapver); - g_free (real_cert_path); - g_free (ca_cert); - g_free (anon_ident); - return success; -} - -static gboolean -eap_ttls_reader (const char *eap_method, - shvarFile *ifcfg, - shvarFile *keys, - NMSetting8021x *s_8021x, - gboolean phase2, - GError **error) -{ - gboolean success = FALSE; - char *anon_ident = NULL; - char *ca_cert = NULL; - char *real_cert_path = NULL; - char *inner_auth = NULL; - char *tmp; - char **list = NULL, **iter; - - ca_cert = svGetValue (ifcfg, "IEEE_8021X_CA_CERT", FALSE); - if (ca_cert) { - real_cert_path = get_full_file_path (ifcfg->fileName, ca_cert); - if (!nm_setting_802_1x_set_ca_cert (s_8021x, - real_cert_path, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, - error)) - goto done; - } else { - PARSE_WARNING ("missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", - eap_method); - } - - anon_ident = svGetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", FALSE); - if (anon_ident && strlen (anon_ident)) - g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); - - tmp = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); - if (!tmp) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_INNER_AUTH_METHODS."); - goto done; - } - - inner_auth = g_ascii_strdown (tmp, -1); - g_free (tmp); - - /* Handle options for the inner auth method */ - list = g_strsplit (inner_auth, " ", 0); - for (iter = list; iter && *iter; iter++) { - if (!strlen (*iter)) - continue; - - if ( !strcmp (*iter, "mschapv2") - || !strcmp (*iter, "mschap") - || !strcmp (*iter, "pap") - || !strcmp (*iter, "chap")) { - if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) - goto done; - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, *iter, NULL); - } else if (!strcmp (*iter, "eap-tls")) { - if (!eap_tls_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) - goto done; - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, "tls", NULL); - } else if ( !strcmp (*iter, "eap-mschapv2") - || !strcmp (*iter, "eap-md5") - || !strcmp (*iter, "eap-gtc")) { - if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) - goto done; - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, (*iter + NM_STRLEN ("eap-")), NULL); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", - *iter); - goto done; - } - break; - } - - success = TRUE; - -done: - if (list) - g_strfreev (list); - g_free (inner_auth); - g_free (real_cert_path); - g_free (ca_cert); - g_free (anon_ident); - return success; -} - -static gboolean -eap_fast_reader (const char *eap_method, - shvarFile *ifcfg, - shvarFile *keys, - NMSetting8021x *s_8021x, - gboolean phase2, - GError **error) -{ - char *anon_ident = NULL; - char *pac_file = NULL; - char *real_pac_path = NULL; - char *inner_auth = NULL; - char *fast_provisioning = NULL; - char *lower; - char **list = NULL, **iter; - const char* pac_prov_str; - gboolean allow_unauth = FALSE, allow_auth = FALSE; - gboolean success = FALSE; - - pac_file = svGetValue (ifcfg, "IEEE_8021X_PAC_FILE", FALSE); - if (pac_file) { - real_pac_path = get_full_file_path (ifcfg->fileName, pac_file); - g_object_set (s_8021x, NM_SETTING_802_1X_PAC_FILE, real_pac_path, NULL); - } - - fast_provisioning = svGetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", FALSE); - if (fast_provisioning) { - list = g_strsplit_set (fast_provisioning, " \t", 0); - for (iter = list; iter && *iter; iter++) { - if (**iter == '\0') - continue; - if (strcmp (*iter, "allow-unauth") == 0) - allow_unauth = TRUE; - else if (strcmp (*iter, "allow-auth") == 0) - allow_auth = TRUE; - else { - PARSE_WARNING ("invalid IEEE_8021X_FAST_PROVISIONING '%s' " - "(space-separated list of these values [allow-auth, allow-unauth] expected)", - *iter); - } - } - g_strfreev (list); - list = NULL; - } - pac_prov_str = allow_unauth ? (allow_auth ? "3" : "1") : (allow_auth ? "2" : "0"); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, pac_prov_str, NULL); - - if (!pac_file && !(allow_unauth || allow_auth)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "IEEE_8021X_PAC_FILE not provided and EAP-FAST automatic PAC provisioning disabled."); - goto done; - } - - anon_ident = svGetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", FALSE); - if (anon_ident && strlen (anon_ident)) - g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); - - inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); - if (!inner_auth) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_INNER_AUTH_METHODS."); - goto done; - } - - /* Handle options for the inner auth method */ - list = g_strsplit (inner_auth, " ", 0); - for (iter = list; iter && *iter; iter++) { - if (!strlen (*iter)) - continue; - - if ( !strcmp (*iter, "MSCHAPV2") - || !strcmp (*iter, "GTC")) { - if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) - goto done; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", - *iter); - goto done; - } - - lower = g_ascii_strdown (*iter, -1); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, lower, NULL); - g_free (lower); - break; - } - - if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "No valid IEEE_8021X_INNER_AUTH_METHODS found."); - goto done; - } - - success = TRUE; - -done: - g_strfreev (list); - g_free (inner_auth); - g_free (fast_provisioning); - g_free (real_pac_path); - g_free (pac_file); - g_free (anon_ident); - return success; -} - -typedef struct { - const char *method; - gboolean (*reader)(const char *eap_method, - shvarFile *ifcfg, - shvarFile *keys, - NMSetting8021x *s_8021x, - gboolean phase2, - GError **error); - gboolean wifi_phase2_only; -} EAPReader; - -static EAPReader eap_readers[] = { - { "md5", eap_simple_reader, TRUE }, - { "pap", eap_simple_reader, TRUE }, - { "chap", eap_simple_reader, TRUE }, - { "mschap", eap_simple_reader, TRUE }, - { "mschapv2", eap_simple_reader, TRUE }, - { "leap", eap_simple_reader, FALSE }, - { "pwd", eap_simple_reader, FALSE }, - { "tls", eap_tls_reader, FALSE }, - { "peap", eap_peap_reader, FALSE }, - { "ttls", eap_ttls_reader, FALSE }, - { "fast", eap_fast_reader, FALSE }, - { NULL, NULL } -}; - -static void -read_8021x_list_value (shvarFile *ifcfg, - const char *ifcfg_var_name, - NMSetting8021x *setting, - const char *prop_name) -{ - char *value; - char **strv; - - g_return_if_fail (ifcfg != NULL); - g_return_if_fail (ifcfg_var_name != NULL); - g_return_if_fail (prop_name != NULL); - - value = svGetValue (ifcfg, ifcfg_var_name, FALSE); - if (!value) - return; - - strv = g_strsplit_set (value, " \t", 0); - if (strv && strv[0]) - g_object_set (setting, prop_name, strv, NULL); - g_strfreev (strv); - g_free (value); -} - -static NMSetting8021x * -fill_8021x (shvarFile *ifcfg, - const char *file, - const char *key_mgmt, - gboolean wifi, - GError **error) -{ - NMSetting8021x *s_8021x; - shvarFile *keys = NULL; - char *value; - char **list = NULL, **iter; - - value = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_EAP_METHODS for key management '%s'", - key_mgmt); - return NULL; - } - - list = g_strsplit (value, " ", 0); - g_free (value); - - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - - /* Read in the lookaside keys file, if present */ - keys = utils_get_keys_ifcfg (file, FALSE); - - /* Validate and handle each EAP method */ - for (iter = list; iter && *iter; iter++) { - EAPReader *eap = &eap_readers[0]; - gboolean found = FALSE; - char *lower = NULL; - - lower = g_ascii_strdown (*iter, -1); - while (eap->method) { - if (strcmp (eap->method, lower)) - goto next; - - /* Some EAP methods don't provide keying material, thus they - * cannot be used with WiFi unless they are an inner method - * used with TTLS or PEAP or whatever. - */ - if (wifi && eap->wifi_phase2_only) { - PARSE_WARNING ("ignored invalid IEEE_8021X_EAP_METHOD '%s'; not allowed for wifi.", - lower); - goto next; - } - - /* Parse EAP method specific options */ - if (!(*eap->reader)(lower, ifcfg, keys, s_8021x, FALSE, error)) { - g_free (lower); - goto error; - } - nm_setting_802_1x_add_eap_method (s_8021x, lower); - found = TRUE; - break; - - next: - eap++; - } - - if (!found) - PARSE_WARNING ("ignored unknown IEEE_8021X_EAP_METHOD '%s'.", lower); - g_free (lower); - } - - if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "No valid EAP methods found in IEEE_8021X_EAP_METHODS."); - goto error; - } - - value = svGetValue (ifcfg, "IEEE_8021X_SUBJECT_MATCH", FALSE); - g_object_set (s_8021x, NM_SETTING_802_1X_SUBJECT_MATCH, value, NULL); - g_free (value); - - value = svGetValue (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH", FALSE); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, value, NULL); - g_free (value); - - read_8021x_list_value (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", - s_8021x, NM_SETTING_802_1X_ALTSUBJECT_MATCHES); - read_8021x_list_value (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", - s_8021x, NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES); - - value = svGetValue (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", FALSE); - g_object_set (s_8021x, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, value, NULL); - g_free (value); - value = svGetValue (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", FALSE); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, value, NULL); - g_free (value); - - if (list) - g_strfreev (list); - if (keys) - svCloseFile (keys); - return s_8021x; - -error: - if (list) - g_strfreev (list); - if (keys) - svCloseFile (keys); - g_object_unref (s_8021x); - return NULL; -} - -static NMSetting * -make_wpa_setting (shvarFile *ifcfg, - const char *file, - GBytes *ssid, - gboolean adhoc, - NMSetting8021x **s_8021x, - GError **error) -{ - NMSettingWirelessSecurity *wsec; - char *value, *psk, *lower; - gboolean wpa_psk = FALSE, wpa_eap = FALSE, ieee8021x = FALSE; - - wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - - value = svGetValue (ifcfg, "KEY_MGMT", FALSE); - wpa_psk = !g_strcmp0 (value, "WPA-PSK"); - wpa_eap = !g_strcmp0 (value, "WPA-EAP"); - ieee8021x = !g_strcmp0 (value, "IEEE8021X"); - if (!wpa_psk && !wpa_eap && !ieee8021x) - goto error; /* Not WPA or Dynamic WEP */ - - /* Pairwise and Group ciphers (only relevant for WPA/RSN) */ - if (wpa_psk || wpa_eap) { - fill_wpa_ciphers (ifcfg, wsec, FALSE, adhoc); - fill_wpa_ciphers (ifcfg, wsec, TRUE, adhoc); - } - - /* WPA and/or RSN */ - if (adhoc) { - /* Ad-Hoc mode only supports WPA proto for now */ - nm_setting_wireless_security_add_proto (wsec, "wpa"); - } else { - char *allow_wpa, *allow_rsn; - - allow_wpa = svGetValue (ifcfg, "WPA_ALLOW_WPA", FALSE); - allow_rsn = svGetValue (ifcfg, "WPA_ALLOW_WPA2", FALSE); - - if (allow_wpa && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA", TRUE)) - nm_setting_wireless_security_add_proto (wsec, "wpa"); - if (allow_rsn && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA2", TRUE)) - nm_setting_wireless_security_add_proto (wsec, "rsn"); - - g_free (allow_wpa); - g_free (allow_rsn); - } - - if (wpa_psk) { - NMSettingSecretFlags psk_flags; - - psk_flags = read_secret_flags (ifcfg, "WPA_PSK_FLAGS"); - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, psk_flags, NULL); - - /* Read PSK if it's system-owned */ - if (psk_flags == NM_SETTING_SECRET_FLAG_NONE) { - psk = parse_wpa_psk (ifcfg, file, ssid, error); - if (psk) { - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_PSK, psk, NULL); - g_free (psk); - } else if (error) - goto error; - } - - if (adhoc) - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL); - else - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL); - } else if (wpa_eap || ieee8021x) { - /* Adhoc mode is mutually exclusive with any 802.1x-based authentication */ - if (adhoc) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", value); - goto error; - } - - *s_8021x = fill_8021x (ifcfg, file, value, TRUE, error); - if (!*s_8021x) - goto error; - - lower = g_ascii_strdown (value, -1); - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, lower, NULL); - g_free (lower); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown wireless KEY_MGMT type '%s'", value); - goto error; - } - - g_free (value); - - value = svGetValue (ifcfg, "SECURITYMODE", FALSE); - if (NM_IN_STRSET (value, NULL, "open")) - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, value, NULL); - - g_free (value); - return (NMSetting *) wsec; - -error: - g_free (value); - if (wsec) - g_object_unref (wsec); - return NULL; -} - -static NMSetting * -make_leap_setting (shvarFile *ifcfg, - const char *file, - GError **error) -{ - NMSettingWirelessSecurity *wsec; - shvarFile *keys_ifcfg; - char *value; - NMSettingSecretFlags flags; - - wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - - value = svGetValue (ifcfg, "KEY_MGMT", FALSE); - if (!value || strcmp (value, "IEEE8021X")) - goto error; /* Not LEAP */ - - g_free (value); - value = svGetValue (ifcfg, "SECURITYMODE", FALSE); - if (!value || strcasecmp (value, "leap")) - goto error; /* Not LEAP */ - - g_free (value); - - flags = read_secret_flags (ifcfg, "IEEE_8021X_PASSWORD_FLAGS"); - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, flags, NULL); - - /* Read LEAP password if it's system-owned */ - if (flags == NM_SETTING_SECRET_FLAG_NONE) { - value = svGetValue (ifcfg, "IEEE_8021X_PASSWORD", FALSE); - if (!value) { - /* Try to get keys from the "shadow" key file */ - keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); - if (keys_ifcfg) { - value = svGetValue (keys_ifcfg, "IEEE_8021X_PASSWORD", FALSE); - svCloseFile (keys_ifcfg); - } - } - if (value && strlen (value)) - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, value, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); - if (!value || !strlen (value)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing LEAP identity"); - goto error; - } - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, value, NULL); - g_free (value); - - g_object_set (wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", - NULL); - - return (NMSetting *) wsec; - -error: - g_free (value); - if (wsec) - g_object_unref (wsec); - return NULL; -} - -static NMSetting * -make_wireless_security_setting (shvarFile *ifcfg, - const char *file, - GBytes *ssid, - gboolean adhoc, - NMSetting8021x **s_8021x, - GError **error) -{ - NMSetting *wsec; - - g_return_val_if_fail (error && !*error, NULL); - - if (!adhoc) { - wsec = make_leap_setting (ifcfg, file, error); - if (wsec) - return wsec; - else if (*error) - return NULL; - } - - wsec = make_wpa_setting (ifcfg, file, ssid, adhoc, s_8021x, error); - if (wsec) - return wsec; - else if (*error) - return NULL; - - wsec = make_wep_setting (ifcfg, file, error); - if (wsec) - return wsec; - else if (*error) - return NULL; - - return NULL; /* unencrypted */ -} - -static char ** -transform_hwaddr_blacklist (const char *blacklist) -{ - char **strv, **iter; - int shift = 0; - - strv = _nm_utils_strsplit_set (blacklist, " \t", 0); - for (iter = strv; iter && *iter; iter++) { - if (shift) { - *(iter - shift) = *iter; - *iter = NULL; - } - if (!nm_utils_hwaddr_valid (*(iter - shift), ETH_ALEN)) { - PARSE_WARNING ("invalid MAC in HWADDR_BLACKLIST '%s'", *(iter - shift)); - g_free (*(iter - shift)); - *(iter - shift) = NULL; - shift++; - } - } - return strv; -} - -static NMSetting * -make_wireless_setting (shvarFile *ifcfg, - GError **error) -{ - NMSettingWireless *s_wireless; - char *value = NULL; - gint64 chan = 0; - NMSettingMacRandomization mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; - NMSettingWirelessPowersave powersave = NM_SETTING_WIRELESS_POWERSAVE_DEFAULT; - - s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); - - value = svGetValue (ifcfg, "HWADDR", FALSE); - if (value) { - value = g_strstrip (value); - g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS, value, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "MACADDR", FALSE); - if (value) { - value = g_strstrip (value); - g_object_set (s_wireless, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, value, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", FALSE); - g_object_set (s_wireless, NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK, value, NULL); - g_free (value); - - value = svGetValue (ifcfg, "HWADDR_BLACKLIST", FALSE); - if (value) { - char **strv; - - strv = transform_hwaddr_blacklist (value); - g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, strv, NULL); - g_strfreev (strv); - g_free (value); - } - - value = svGetValue (ifcfg, "ESSID", TRUE); - if (value) { - GBytes *bytes = NULL; - gsize ssid_len = 0; - gsize value_len = strlen (value); - - if ( (value_len >= 2) - && (value[0] == '"') - && (value[value_len - 1] == '"')) { - /* Strip the quotes and unescape */ - char *p = value + 1; - - value[value_len - 1] = '\0'; - svUnescape (p); - bytes = g_bytes_new (p, strlen (p)); - } else if ((value_len > 2) && (strncmp (value, "0x", 2) == 0)) { - /* Hex representation */ - if (value_len % 2) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' size (looks like hex but length not multiple of 2)", - value); - g_free (value); - goto error; - } - - bytes = nm_utils_hexstr2bin (value); - if (!bytes) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' (looks like hex SSID but isn't)", - value); - g_free (value); - goto error; - } - } else - bytes = g_bytes_new (value, value_len); - - ssid_len = g_bytes_get_size (bytes); - if (ssid_len > 32 || ssid_len == 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", - value, ssid_len); - g_bytes_unref (bytes); - g_free (value); - goto error; - } - - g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, bytes, NULL); - g_bytes_unref (bytes); - g_free (value); - } - - value = svGetValue (ifcfg, "MODE", FALSE); - if (value) { - char *lcase; - const char *mode = NULL; - - lcase = g_ascii_strdown (value, -1); - g_free (value); - - if (!strcmp (lcase, "ad-hoc")) { - mode = "adhoc"; - } else if (!strcmp (lcase, "ap")) { - mode = "ap"; - } else if (!strcmp (lcase, "managed") || !strcmp (lcase, "auto")) { - mode = "infrastructure"; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid mode '%s' (not 'Ad-Hoc', 'Ap', 'Managed', or 'Auto')", - lcase); - g_free (lcase); - goto error; - } - g_free (lcase); - - g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, mode, NULL); - } - - value = svGetValue (ifcfg, "BSSID", FALSE); - if (value) { - value = g_strstrip (value); - g_object_set (s_wireless, NM_SETTING_WIRELESS_BSSID, value, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "CHANNEL", FALSE); - if (value) { - errno = 0; - chan = _nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0); - if (errno || (chan == 0)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid wireless channel '%s'", value); - g_free (value); - goto error; - } - g_object_set (s_wireless, NM_SETTING_WIRELESS_CHANNEL, (guint32) chan, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "BAND", FALSE); - if (value) { - if (!strcmp (value, "a")) { - if (chan && chan <= 14) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Band '%s' invalid for channel %u", value, (guint32) chan); - g_free (value); - goto error; - } - } else if (!strcmp (value, "bg")) { - if (chan && chan > 14) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Band '%s' invalid for channel %u", value, (guint32) chan); - g_free (value); - goto error; - } - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid wireless band '%s'", value); - g_free (value); - goto error; - } - g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, value, NULL); - g_free (value); - } else if (chan > 0) { - if (chan > 14) - g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "a", NULL); - else - g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "bg", NULL); - } - - value = svGetValue (ifcfg, "MTU", FALSE); - if (value) { - int mtu; - - mtu = _nm_utils_ascii_str_to_int64 (value, 10, 0, 50000, -1); - if (mtu == -1) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid wireless MTU '%s'", value); - g_free (value); - goto error; - } - g_object_set (s_wireless, NM_SETTING_WIRELESS_MTU, (guint) mtu, NULL); - g_free (value); - } - - g_object_set (s_wireless, - NM_SETTING_WIRELESS_HIDDEN, - svGetValueBoolean (ifcfg, "SSID_HIDDEN", FALSE), - NULL); - - value = svGetValueFull (ifcfg, "POWERSAVE", FALSE); - if (value) { - if (!strcmp (value, "default")) - powersave = NM_SETTING_WIRELESS_POWERSAVE_DEFAULT; - else if (!strcmp (value, "ignore")) - powersave = NM_SETTING_WIRELESS_POWERSAVE_IGNORE; - else if (!strcmp (value, "disable") || !strcmp (value, "no")) - powersave = NM_SETTING_WIRELESS_POWERSAVE_DISABLE; - else if (!strcmp (value, "enable") || !strcmp (value, "yes")) - powersave = NM_SETTING_WIRELESS_POWERSAVE_ENABLE; - else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid POWERSAVE value '%s'", value); - g_free (value); - goto error; - } - g_free (value); - } - - g_object_set (s_wireless, - NM_SETTING_WIRELESS_POWERSAVE, - powersave, - NULL); - - value = svGetValueFull (ifcfg, "MAC_ADDRESS_RANDOMIZATION", FALSE); - if (value) { - if (strcmp (value, "default") == 0) - mac_randomization = NM_SETTING_MAC_RANDOMIZATION_DEFAULT; - else if (strcmp (value, "never") == 0) - mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; - else if (strcmp (value, "always") == 0) - mac_randomization = NM_SETTING_MAC_RANDOMIZATION_ALWAYS; - else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid MAC_ADDRESS_RANDOMIZATION value '%s'", value); - g_free (value); - goto error; - } - g_free (value); - } else - mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; - - g_object_set (s_wireless, - NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, - mac_randomization, - NULL); - - return NM_SETTING (s_wireless); - -error: - if (s_wireless) - g_object_unref (s_wireless); - return NULL; -} - -static NMConnection * -wireless_connection_from_ifcfg (const char *file, - shvarFile *ifcfg, - GError **error) -{ - NMConnection *connection = NULL; - NMSetting *con_setting = NULL; - NMSetting *wireless_setting = NULL; - NMSetting8021x *s_8021x = NULL; - GBytes *ssid; - NMSetting *security_setting = NULL; - char *printable_ssid = NULL; - const char *mode; - gboolean adhoc = FALSE; - GError *local = NULL; - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (ifcfg != NULL, NULL); - g_return_val_if_fail (!error || !*error, NULL); - - connection = nm_simple_connection_new (); - - /* Wireless */ - wireless_setting = make_wireless_setting (ifcfg, error); - if (!wireless_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, wireless_setting); - - ssid = nm_setting_wireless_get_ssid (NM_SETTING_WIRELESS (wireless_setting)); - if (ssid) { - printable_ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), - g_bytes_get_size (ssid)); - } else - printable_ssid = g_strdup_printf ("unmanaged"); - - mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (wireless_setting)); - if (mode && !strcmp (mode, "adhoc")) - adhoc = TRUE; - - /* Wireless security */ - security_setting = make_wireless_security_setting (ifcfg, file, ssid, adhoc, &s_8021x, &local); - if (local) { - g_free (printable_ssid); - g_object_unref (connection); - g_propagate_error (error, local); - return NULL; - } - if (security_setting) { - nm_connection_add_setting (connection, security_setting); - if (s_8021x) - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - } - - /* Connection */ - con_setting = make_connection_setting (file, ifcfg, - NM_SETTING_WIRELESS_SETTING_NAME, - printable_ssid, NULL); - g_free (printable_ssid); - if (!con_setting) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create connection setting."); - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, con_setting); - - return connection; -} - -static void -parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, char **out_password) -{ - gs_strfreev char **words = NULL; - const char **iter = NULL, *flag; - - if (!value || !value[0]) - return; - - words = g_strsplit_set (value, "\t ", 0); - iter = (const char **) words; - - while (iter[0]) { - gboolean is_wol; - - if (g_str_equal (iter[0], "wol")) - is_wol = TRUE; - else if (g_str_equal (iter[0], "sopass")) - is_wol = FALSE; - else { - /* Silently skip unknown options */ - iter++; - continue; - } - - iter++; - - /* g_strsplit_set() returns empty tokens, meaning that we must skip over repeated - * space characters like to parse "wol d". */ - while (iter[0] && !*iter[0]) - iter++; - - if (is_wol) { - NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; - - if (!iter[0]) { - PARSE_WARNING ("Wake-on-LAN options missing"); - break; - } - - for (flag = iter[0]; *flag; flag++) { - switch (*flag) { - case 'p': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY; - break; - case 'u': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST; - break; - case 'm': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST; - break; - case 'b': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST; - break; - case 'a': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_ARP; - break; - case 'g': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; - break; - case 's': - break; - case 'd': - wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; - break; - default: - PARSE_WARNING ("unrecognized Wake-on-LAN option '%c'", *flag); - } - } - - *out_flags = wol_flags; - } else { - if (!iter[0]) { - PARSE_WARNING ("Wake-on-LAN password missing"); - break; - } - - g_clear_pointer (out_password, g_free); - if (nm_utils_hwaddr_valid (iter[0], ETH_ALEN)) - *out_password = g_strdup (iter[0]); - else - PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", iter[0]); - } - iter++; - } -} - -static void -parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, const char *value) -{ - NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; - gs_free char *wol_password = NULL; - gboolean ignore_wol_password = FALSE; - - if (value) { - gs_strfreev char **opts = NULL; - const char **iter; - - wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; - - opts = g_strsplit_set (value, ";", 0); - for (iter = (const char **) opts; iter[0]; iter++) { - /* in case of repeated wol_passwords, parse_ethtool_option() - * will do the right thing and clear wol_password before resetting. */ - parse_ethtool_option (iter[0], &wol_flags, &wol_password); - } - } - - if ( wol_password - && !NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { - PARSE_WARNING ("Wake-on-LAN password not expected"); - ignore_wol_password = TRUE; - } - g_object_set (s_wired, - NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, - NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, ignore_wol_password ? NULL : wol_password, - NULL); -} - -static NMSetting * -make_wired_setting (shvarFile *ifcfg, - const char *file, - NMSetting8021x **s_8021x, - GError **error) -{ - NMSettingWired *s_wired; - char *value = NULL; - char *nettype; - - s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); - - value = svGetValue (ifcfg, "MTU", FALSE); - if (value) { - int mtu; - - mtu = _nm_utils_ascii_str_to_int64 (value, 0, 0, 65535, -1); - if (mtu >= 0) - g_object_set (s_wired, NM_SETTING_WIRED_MTU, (guint) mtu, NULL); - else - PARSE_WARNING ("invalid MTU '%s'", value); - g_free (value); - } - - value = svGetValue (ifcfg, "HWADDR", FALSE); - if (value) { - value = g_strstrip (value); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, value, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "SUBCHANNELS", FALSE); - if (value) { - const char *p = value; - gboolean success = TRUE; - char **chans = NULL; - - /* basic sanity checks */ - while (*p) { - if (!g_ascii_isxdigit (*p) && (*p != ',') && (*p != '.')) { - PARSE_WARNING ("invalid SUBCHANNELS '%s'", value); - success = FALSE; - break; - } - p++; - } - - if (success) { - guint32 num_chans; - - chans = g_strsplit_set (value, ",", 0); - num_chans = g_strv_length (chans); - if (num_chans < 2 || num_chans > 3) { - PARSE_WARNING ("invalid SUBCHANNELS '%s' (%d channels, 2 or 3 expected)", - value, g_strv_length (chans)); - } else - g_object_set (s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, chans, NULL); - g_strfreev (chans); - } - g_free (value); - } - - value = svGetValue (ifcfg, "PORTNAME", FALSE); - if (value && strlen (value)) { - nm_setting_wired_add_s390_option (s_wired, "portname", value); - } - g_free (value); - - value = svGetValue (ifcfg, "CTCPROT", FALSE); - if (value && strlen (value)) - nm_setting_wired_add_s390_option (s_wired, "ctcprot", value); - g_free (value); - - nettype = svGetValue (ifcfg, "NETTYPE", FALSE); - if (nettype && strlen (nettype)) { - if (!strcmp (nettype, "qeth") || !strcmp (nettype, "lcs") || !strcmp (nettype, "ctc")) - g_object_set (s_wired, NM_SETTING_WIRED_S390_NETTYPE, nettype, NULL); - else - PARSE_WARNING ("unknown s390 NETTYPE '%s'", nettype); - } - g_free (nettype); - - value = svGetValue (ifcfg, "OPTIONS", FALSE); - if (value && strlen (value)) { - char **options, **iter; - - iter = options = g_strsplit_set (value, " ", 0); - while (iter && *iter) { - char *equals = strchr (*iter, '='); - gboolean valid = FALSE; - - if (equals) { - *equals = '\0'; - valid = nm_setting_wired_add_s390_option (s_wired, *iter, equals + 1); - } - if (!valid) - PARSE_WARNING ("invalid s390 OPTION '%s'", *iter); - iter++; - } - g_strfreev (options); - } - g_free (value); - - value = svGetValue (ifcfg, "MACADDR", FALSE); - if (value) { - value = g_strstrip (value); - g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, value, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", FALSE); - g_object_set (s_wired, NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, value, NULL); - g_free (value); - - value = svGetValue (ifcfg, "HWADDR_BLACKLIST", FALSE); - if (value) { - char **strv; - - strv = transform_hwaddr_blacklist (value); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, strv, NULL); - g_strfreev (strv); - g_free (value); - } - - value = svGetValue (ifcfg, "KEY_MGMT", FALSE); - if (value) { - if (!strcmp (value, "IEEE8021X")) { - *s_8021x = fill_8021x (ifcfg, file, value, FALSE, error); - if (!*s_8021x) - goto error; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown wired KEY_MGMT type '%s'", value); - goto error; - } - g_free (value); - } - - value = svGetValueFull (ifcfg, "ETHTOOL_OPTS", FALSE); - parse_ethtool_options (ifcfg, s_wired, value); - g_free (value); - - return (NMSetting *) s_wired; - -error: - g_free (value); - g_object_unref (s_wired); - return NULL; -} - -static NMConnection * -wired_connection_from_ifcfg (const char *file, - shvarFile *ifcfg, - GError **error) -{ - NMConnection *connection = NULL; - NMSetting *con_setting = NULL; - NMSetting *wired_setting = NULL; - NMSetting8021x *s_8021x = NULL; - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (ifcfg != NULL, NULL); - - connection = nm_simple_connection_new (); - - con_setting = make_connection_setting (file, ifcfg, NM_SETTING_WIRED_SETTING_NAME, NULL, NULL); - if (!con_setting) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create connection setting."); - g_object_unref (connection); - return NULL; - } - check_if_slave (ifcfg, (NMSettingConnection *) con_setting); - nm_connection_add_setting (connection, con_setting); - - wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); - if (!wired_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, wired_setting); - - if (s_8021x) - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - - return connection; -} - -static gboolean -parse_infiniband_p_key (shvarFile *ifcfg, - int *out_p_key, - char **out_parent, - GError **error) -{ - char *device = NULL, *physdev = NULL, *pkey_id = NULL; - char *ifname = NULL; - int id; - gboolean ret = FALSE; - - device = svGetValue (ifcfg, "DEVICE", FALSE); - if (!device) { - PARSE_WARNING ("InfiniBand connection specified PKEY but not DEVICE"); - goto done; - } - - physdev = svGetValue (ifcfg, "PHYSDEV", FALSE); - if (!physdev) { - PARSE_WARNING ("InfiniBand connection specified PKEY but not PHYSDEV"); - goto done; - } - - pkey_id = svGetValue (ifcfg, "PKEY_ID", FALSE); - if (!pkey_id) { - PARSE_WARNING ("InfiniBand connection specified PKEY but not PKEY_ID"); - goto done; - } - - id = _nm_utils_ascii_str_to_int64 (pkey_id, 0, 0, 0xFFFF, -1); - if (id == -1) { - PARSE_WARNING ("invalid InfiniBand PKEY_ID '%s'", pkey_id); - goto done; - } - id = (id | 0x8000); - - ifname = g_strdup_printf ("%s.%04x", physdev, (unsigned) id); - if (strcmp (device, ifname) != 0) { - PARSE_WARNING ("InfiniBand DEVICE (%s) does not match PHYSDEV+PKEY_ID (%s)", - device, ifname); - goto done; - } - - *out_p_key = id; - *out_parent = g_strdup (physdev); - ret = TRUE; - - done: - g_free (device); - g_free (physdev); - g_free (pkey_id); - g_free (ifname); - - if (!ret) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create InfiniBand setting."); - } - return ret; -} - - -static NMSetting * -make_infiniband_setting (shvarFile *ifcfg, - const char *file, - GError **error) -{ - NMSettingInfiniband *s_infiniband; - char *value = NULL; - - s_infiniband = NM_SETTING_INFINIBAND (nm_setting_infiniband_new ()); - - value = svGetValue (ifcfg, "MTU", FALSE); - if (value) { - int mtu; - - mtu = _nm_utils_ascii_str_to_int64 (value, 0, 0, 65535, -1); - if (mtu >= 0) - g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MTU, (guint) mtu, NULL); - else - PARSE_WARNING ("invalid MTU '%s'", value); - g_free (value); - } - - value = svGetValue (ifcfg, "HWADDR", FALSE); - if (value) { - value = g_strstrip (value); - g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, value, NULL); - g_free (value); - } - - if (svGetValueBoolean (ifcfg, "CONNECTED_MODE", FALSE)) - g_object_set (s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", NULL); - else - g_object_set (s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); - - if (svGetValueBoolean (ifcfg, "PKEY", FALSE)) { - int p_key; - char *parent; - - if (!parse_infiniband_p_key (ifcfg, &p_key, &parent, error)) { - g_object_unref (s_infiniband); - return NULL; - } - - g_object_set (s_infiniband, - NM_SETTING_INFINIBAND_P_KEY, p_key, - NM_SETTING_INFINIBAND_PARENT, parent, - NULL); - } - - return (NMSetting *) s_infiniband; -} - -static NMConnection * -infiniband_connection_from_ifcfg (const char *file, - shvarFile *ifcfg, - GError **error) -{ - NMConnection *connection = NULL; - NMSetting *con_setting = NULL; - NMSetting *infiniband_setting = NULL; - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (ifcfg != NULL, NULL); - - connection = nm_simple_connection_new (); - - con_setting = make_connection_setting (file, ifcfg, NM_SETTING_INFINIBAND_SETTING_NAME, NULL, NULL); - if (!con_setting) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create connection setting."); - g_object_unref (connection); - return NULL; - } - check_if_slave (ifcfg, (NMSettingConnection *) con_setting); - nm_connection_add_setting (connection, con_setting); - - infiniband_setting = make_infiniband_setting (ifcfg, file, error); - if (!infiniband_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, infiniband_setting); - - return connection; -} - -static void -handle_bond_option (NMSettingBond *s_bond, - const char *key, - const char *value) -{ - char *sanitized = NULL, *j; - const char *p = value; - - /* Remove any quotes or +/- from arp_ip_target */ - if (!g_strcmp0 (key, NM_SETTING_BOND_OPTION_ARP_IP_TARGET) && value && value[0]) { - if (*p == '\'' || *p == '"') - p++; - j = sanitized = g_malloc0 (strlen (p) + 1); - while (*p) { - if (*p != '+' && *p != '-' && *p != '\'' && *p != '"') - *j++ = *p; - p++; - } - } - - if (!nm_setting_bond_add_option (s_bond, key, sanitized ? sanitized : value)) - PARSE_WARNING ("invalid bonding option '%s' = %s", - key, sanitized ? sanitized : value); - g_free (sanitized); -} - -static NMSetting * -make_bond_setting (shvarFile *ifcfg, - const char *file, - GError **error) -{ - NMSettingBond *s_bond; - char *value; - - s_bond = NM_SETTING_BOND (nm_setting_bond_new ()); - - value = svGetValue (ifcfg, "DEVICE", FALSE); - if (!value || !strlen (value)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "mandatory DEVICE keyword missing"); - goto error; - } - g_free (value); - - value = svGetValue (ifcfg, "BONDING_OPTS", FALSE); - if (value) { - char **items, **iter; - - items = g_strsplit_set (value, " ", -1); - for (iter = items; iter && *iter; iter++) { - if (strlen (*iter)) { - char **keys, *key, *val; - - keys = g_strsplit_set (*iter, "=", 2); - if (keys && *keys) { - key = *keys; - val = *(keys + 1); - if (val && strlen(key) && strlen(val)) - handle_bond_option (s_bond, key, val); - } - - g_strfreev (keys); - } - } - g_free (value); - g_strfreev (items); - } - - return (NMSetting *) s_bond; - -error: - g_object_unref (s_bond); - return NULL; -} - -static NMConnection * -bond_connection_from_ifcfg (const char *file, - shvarFile *ifcfg, - GError **error) -{ - NMConnection *connection = NULL; - NMSetting *con_setting = NULL; - NMSetting *bond_setting = NULL; - NMSetting *wired_setting = NULL; - NMSetting8021x *s_8021x = NULL; - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (ifcfg != NULL, NULL); - - connection = nm_simple_connection_new (); - - con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BOND_SETTING_NAME, NULL, _("Bond")); - if (!con_setting) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create connection setting."); - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, con_setting); - - bond_setting = make_bond_setting (ifcfg, file, error); - if (!bond_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, bond_setting); - - wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); - if (!wired_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, wired_setting); - - if (s_8021x) - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - - return connection; -} - -/* Check 'error' for errors. Missing config (NULL return value) is a valid case. */ -static char * -read_team_config (shvarFile *ifcfg, const char *key, GError **error) -{ - gs_free_error GError *local_error = NULL; - char *value; - size_t l; - - /* FIXME: validate the JSON at some point */ - value = svGetValue (ifcfg, key, TRUE); - if (!value) - return NULL; - - /* No reason Team config should be over 20k. The config is read - * verbatim, length-checked, then unescaped. svUnescape() does not - * deal well with extremely long strings. - */ - l = strlen (value); - if (l > 20000) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "%s too long (size %zd)", key, l); - g_free (value); - return NULL; - } - svUnescape (value); - - if (value && value[0] && !_nm_utils_check_valid_json (value, &local_error)) { - PARSE_WARNING ("ignoring invalid team configuration: %s", local_error->message); - g_clear_pointer (&value, g_free); - } - - return value; -} - -static NMSetting * -make_team_setting (shvarFile *ifcfg, - const char *file, - GError **error) -{ - NMSettingTeam *s_team; - char *value; - GError *local_err = NULL; - - s_team = NM_SETTING_TEAM (nm_setting_team_new ()); - - value = svGetValue (ifcfg, "DEVICE", FALSE); - if (!value || !strlen (value)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "mandatory DEVICE keyword missing"); - goto error; - } - g_free (value); - - value = read_team_config (ifcfg, "TEAM_CONFIG", &local_err); - if (local_err) { - g_propagate_error (error, local_err); - goto error; - } - g_object_set (s_team, NM_SETTING_TEAM_CONFIG, value, NULL); - g_free (value); - - return (NMSetting *) s_team; - -error: - g_object_unref (s_team); - return NULL; -} - -static NMConnection * -team_connection_from_ifcfg (const char *file, - shvarFile *ifcfg, - GError **error) -{ - NMConnection *connection = NULL; - NMSetting *con_setting = NULL; - NMSetting *team_setting = NULL; - NMSetting *wired_setting = NULL; - NMSetting8021x *s_8021x = NULL; - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (ifcfg != NULL, NULL); - - connection = nm_simple_connection_new (); - - con_setting = make_connection_setting (file, ifcfg, NM_SETTING_TEAM_SETTING_NAME, NULL, _("Team")); - if (!con_setting) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create connection setting."); - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, con_setting); - - team_setting = make_team_setting (ifcfg, file, error); - if (!team_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, team_setting); - - wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); - if (!wired_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, wired_setting); - - if (s_8021x) - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - - return connection; -} - -typedef void (*BridgeOptFunc) (NMSetting *setting, - gboolean stp, - const char *key, - const char *value); - -static void -handle_bridge_option (NMSetting *setting, - gboolean stp, - const char *key, - const char *value) -{ - guint32 u = 0; - - if (!strcmp (key, "priority")) { - if (stp == FALSE) { - PARSE_WARNING ("'priority' invalid when STP is disabled"); - } else if (get_uint (value, &u)) - g_object_set (setting, NM_SETTING_BRIDGE_PRIORITY, u, NULL); - else - PARSE_WARNING ("invalid priority value '%s'", value); - } else if (!strcmp (key, "hello_time")) { - if (stp == FALSE) { - PARSE_WARNING ("'hello_time' invalid when STP is disabled"); - } else if (get_uint (value, &u)) - g_object_set (setting, NM_SETTING_BRIDGE_HELLO_TIME, u, NULL); - else - PARSE_WARNING ("invalid hello_time value '%s'", value); - } else if (!strcmp (key, "max_age")) { - if (stp == FALSE) { - PARSE_WARNING ("'max_age' invalid when STP is disabled"); - } else if (get_uint (value, &u)) - g_object_set (setting, NM_SETTING_BRIDGE_MAX_AGE, u, NULL); - else - PARSE_WARNING ("invalid max_age value '%s'", value); - } else if (!strcmp (key, "ageing_time")) { - if (get_uint (value, &u)) - g_object_set (setting, NM_SETTING_BRIDGE_AGEING_TIME, u, NULL); - else - PARSE_WARNING ("invalid ageing_time value '%s'", value); - } else if (!strcmp (key, "multicast_snooping")) { - if (get_uint (value, &u)) - g_object_set (setting, NM_SETTING_BRIDGE_MULTICAST_SNOOPING, - (gboolean) u, NULL); - else - PARSE_WARNING ("invalid multicast_snooping value '%s'", value); - } else - PARSE_WARNING ("unhandled bridge option '%s'", key); -} - -static void -handle_bridging_opts (NMSetting *setting, - gboolean stp, - const char *value, - BridgeOptFunc func) -{ - char **items, **iter; - - items = g_strsplit_set (value, " ", -1); - for (iter = items; iter && *iter; iter++) { - if (strlen (*iter)) { - char **keys, *key, *val; - - keys = g_strsplit_set (*iter, "=", 2); - if (keys && *keys) { - key = *keys; - val = *(keys + 1); - if (val && strlen(key) && strlen(val)) - func (setting, stp, key, val); - } - - g_strfreev (keys); - } - } - g_strfreev (items); -} - -static NMSetting * -make_bridge_setting (shvarFile *ifcfg, - const char *file, - GError **error) -{ - NMSettingBridge *s_bridge; - char *value; - guint32 u; - gboolean stp = FALSE; - gboolean stp_set = FALSE; - - s_bridge = NM_SETTING_BRIDGE (nm_setting_bridge_new ()); - - value = svGetValue (ifcfg, "DEVICE", FALSE); - if (!value || !strlen (value)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "mandatory DEVICE keyword missing"); - goto error; - } - g_free (value); - - value = svGetValue (ifcfg, "MACADDR", FALSE); - if (value) { - value = g_strstrip (value); - g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, value, NULL); - g_free (value); - } - - value = svGetValue (ifcfg, "STP", FALSE); - if (value) { - if (!strcasecmp (value, "on") || !strcasecmp (value, "yes")) { - g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, TRUE, NULL); - stp = TRUE; - stp_set = TRUE; - } else if (!strcasecmp (value, "off") || !strcasecmp (value, "no")) { - g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL); - stp_set = TRUE; - } else - PARSE_WARNING ("invalid STP value '%s'", value); - g_free (value); - } - - if (!stp_set) { - /* Missing or invalid STP property means "no" */ - g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL); - } - - value = svGetValue (ifcfg, "DELAY", FALSE); - if (value) { - if (stp) { - if (get_uint (value, &u)) - g_object_set (s_bridge, NM_SETTING_BRIDGE_FORWARD_DELAY, u, NULL); - else - PARSE_WARNING ("invalid forward delay value '%s'", value); - } else - PARSE_WARNING ("DELAY invalid when STP is disabled"); - g_free (value); - } - - value = svGetValue (ifcfg, "BRIDGING_OPTS", FALSE); - if (value) { - handle_bridging_opts (NM_SETTING (s_bridge), stp, value, handle_bridge_option); - g_free (value); - } - - return (NMSetting *) s_bridge; - -error: - g_object_unref (s_bridge); - return NULL; -} - -static NMConnection * -bridge_connection_from_ifcfg (const char *file, - shvarFile *ifcfg, - GError **error) -{ - NMConnection *connection = NULL; - NMSetting *con_setting = NULL; - NMSetting *bridge_setting = NULL; - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (ifcfg != NULL, NULL); - - connection = nm_simple_connection_new (); - - con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BRIDGE_SETTING_NAME, NULL, _("Bridge")); - if (!con_setting) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create connection setting."); - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, con_setting); - - bridge_setting = make_bridge_setting (ifcfg, file, error); - if (!bridge_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, bridge_setting); - - return connection; -} - -static void -handle_bridge_port_option (NMSetting *setting, - gboolean stp, - const char *key, - const char *value) -{ - guint32 u = 0; - - if (!strcmp (key, "priority")) { - if (get_uint (value, &u)) - g_object_set (setting, NM_SETTING_BRIDGE_PORT_PRIORITY, u, NULL); - else - PARSE_WARNING ("invalid priority value '%s'", value); - } else if (!strcmp (key, "path_cost")) { - if (get_uint (value, &u)) - g_object_set (setting, NM_SETTING_BRIDGE_PORT_PATH_COST, u, NULL); - else - PARSE_WARNING ("invalid path_cost value '%s'", value); - } else if (!strcmp (key, "hairpin_mode")) { - if (!strcasecmp (value, "on") || !strcasecmp (value, "yes") || !strcmp (value, "1")) - g_object_set (setting, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, TRUE, NULL); - else if (!strcasecmp (value, "off") || !strcasecmp (value, "no")) - g_object_set (setting, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, FALSE, NULL); - else - PARSE_WARNING ("invalid hairpin_mode value '%s'", value); - } else - PARSE_WARNING ("unhandled bridge port option '%s'", key); -} - -static NMSetting * -make_bridge_port_setting (shvarFile *ifcfg) -{ - NMSetting *s_port = NULL; - char *value; - - g_return_val_if_fail (ifcfg != NULL, FALSE); - - value = svGetValue (ifcfg, "BRIDGE", FALSE); - if (value) { - g_free (value); - - s_port = nm_setting_bridge_port_new (); - value = svGetValue (ifcfg, "BRIDGING_OPTS", FALSE); - if (value) - handle_bridging_opts (s_port, FALSE, value, handle_bridge_port_option); - g_free (value); - } - - return s_port; -} - -static NMSetting * -make_team_port_setting (shvarFile *ifcfg) -{ - NMSetting *s_port = NULL; - char *value; - GError *error = NULL; - - value = read_team_config (ifcfg, "TEAM_PORT_CONFIG", &error); - if (value) { - s_port = nm_setting_team_port_new (); - g_object_set (s_port, NM_SETTING_TEAM_PORT_CONFIG, value, NULL); - g_free (value); - } else if (error) { - PARSE_WARNING ("%s", error->message); - g_error_free (error); - } - - return s_port; -} - -static gboolean -is_bond_device (const char *name, shvarFile *parsed) -{ - g_return_val_if_fail (name != NULL, FALSE); - g_return_val_if_fail (parsed != NULL, FALSE); - - if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE)) - return TRUE; - - return FALSE; -} - -static gboolean -is_vlan_device (const char *name, shvarFile *parsed) -{ - g_return_val_if_fail (name != NULL, FALSE); - g_return_val_if_fail (parsed != NULL, FALSE); - - if (svGetValueBoolean (parsed, "VLAN", FALSE)) - return TRUE; - - return FALSE; -} - -static gboolean -is_wifi_device (const char *name, shvarFile *parsed) -{ - int ifindex; - - g_return_val_if_fail (name != NULL, FALSE); - g_return_val_if_fail (parsed != NULL, FALSE); - - ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, name); - if (ifindex == 0) - return FALSE; - - return nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) == NM_LINK_TYPE_WIFI; -} - -static void -parse_prio_map_list (NMSettingVlan *s_vlan, - shvarFile *ifcfg, - const char *key, - NMVlanPriorityMap map) -{ - char *value; - gchar **list = NULL, **iter; - - value = svGetValue (ifcfg, key, FALSE); - if (!value) - return; - - list = g_strsplit_set (value, ",", -1); - g_free (value); - - for (iter = list; iter && *iter; iter++) { - if (!*iter || !strchr (*iter, ':')) - continue; - - if (!nm_setting_vlan_add_priority_str (s_vlan, map, *iter)) - PARSE_WARNING ("invalid %s priority map item '%s'", key, *iter); - } - g_strfreev (list); -} - -static NMSetting * -make_vlan_setting (shvarFile *ifcfg, - const char *file, - GError **error) -{ - NMSettingVlan *s_vlan = NULL; - char *value = NULL; - char *iface_name = NULL; - char *parent = NULL; - const char *p = NULL; - int vlan_id = -1; - guint32 vlan_flags = 0; - gint gvrp, reorder_hdr; - - value = svGetValue (ifcfg, "VLAN_ID", FALSE); - if (value) { - vlan_id = _nm_utils_ascii_str_to_int64 (value, 10, 0, 4095, -1); - if (vlan_id == -1) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid VLAN_ID '%s'", value); - g_free (value); - return NULL; - } - g_free (value); - } - - /* Need DEVICE if we don't have a separate VLAN_ID property */ - iface_name = svGetValue (ifcfg, "DEVICE", FALSE); - if (!iface_name && vlan_id < 0) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing DEVICE property; cannot determine VLAN ID."); - return NULL; - } - - s_vlan = NM_SETTING_VLAN (nm_setting_vlan_new ()); - - /* Parent interface from PHYSDEV takes precedence if it exists */ - parent = svGetValue (ifcfg, "PHYSDEV", FALSE); - - if (iface_name) { - p = strchr (iface_name, '.'); - if (p) { - /* eth0.43; PHYSDEV is assumed from it if unknown */ - if (!parent) { - parent = g_strndup (iface_name, p - iface_name); - if (g_str_has_prefix (parent, "vlan")) { - /* Like initscripts, if no PHYSDEV and we get an obviously - * invalid parent interface from DEVICE, fail. - */ - g_free (parent); - parent = NULL; - } - } - p++; - } else { - /* format like vlan43; PHYSDEV must be set */ - if (g_str_has_prefix (iface_name, "vlan")) - p = iface_name + 4; - } - - if (p) { - int device_vlan_id; - - /* Grab VLAN ID from interface name; this takes precedence over the - * separate VLAN_ID property for backwards compat. - */ - device_vlan_id = _nm_utils_ascii_str_to_int64 (p, 10, 0, 4095, -1); - if (device_vlan_id != -1) - vlan_id = device_vlan_id; - } - } - - if (vlan_id < 0) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to determine VLAN ID from DEVICE or VLAN_ID."); - goto error; - } - g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL); - - if (parent == NULL) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to determine VLAN parent from DEVICE or PHYSDEV"); - goto error; - } - g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, parent, NULL); - g_clear_pointer (&parent, g_free); - - vlan_flags |= NM_VLAN_FLAG_REORDER_HEADERS; - - gvrp = svGetValueBoolean (ifcfg, "GVRP", -1); - if (gvrp > 0) - vlan_flags |= NM_VLAN_FLAG_GVRP; - - value = svGetValue (ifcfg, "VLAN_FLAGS", FALSE); - if (value) { - gs_strfreev char **strv = NULL; - char **ptr; - - strv = g_strsplit_set (value, ", ", 0); - - for (ptr = strv; ptr && *ptr; ptr++) { - if (nm_streq (*ptr, "GVRP") && gvrp == -1) - vlan_flags |= NM_VLAN_FLAG_GVRP; - if (nm_streq (*ptr, "LOOSE_BINDING")) - vlan_flags |= NM_VLAN_FLAG_LOOSE_BINDING; - if (nm_streq (*ptr, "NO_REORDER_HDR")) - vlan_flags &= ~NM_VLAN_FLAG_REORDER_HEADERS; - } - } - - reorder_hdr = svGetValueBoolean (ifcfg, "REORDER_HDR", -1); - if ( reorder_hdr != -1 - && reorder_hdr != NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)) - PARSE_WARNING ("REORDER_HDR key is deprecated, use VLAN_FLAGS"); - - if (svGetValueBoolean (ifcfg, "MVRP", FALSE)) - vlan_flags |= NM_VLAN_FLAG_MVRP; - - g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, vlan_flags, NULL); - g_free (value); - - parse_prio_map_list (s_vlan, ifcfg, "VLAN_INGRESS_PRIORITY_MAP", NM_VLAN_INGRESS_MAP); - parse_prio_map_list (s_vlan, ifcfg, "VLAN_EGRESS_PRIORITY_MAP", NM_VLAN_EGRESS_MAP); - - g_free (iface_name); - - return (NMSetting *) s_vlan; - -error: - g_free (parent); - g_free (iface_name); - g_object_unref (s_vlan); - return NULL; -} - -static NMConnection * -vlan_connection_from_ifcfg (const char *file, - shvarFile *ifcfg, - GError **error) -{ - NMConnection *connection = NULL; - NMSetting *con_setting = NULL; - NMSetting *wired_setting = NULL; - NMSetting *vlan_setting = NULL; - NMSetting8021x *s_8021x = NULL; - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (ifcfg != NULL, NULL); - - connection = nm_simple_connection_new (); - - con_setting = make_connection_setting (file, ifcfg, NM_SETTING_VLAN_SETTING_NAME, NULL, "Vlan"); - if (!con_setting) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create connection setting."); - g_object_unref (connection); - return NULL; - } - check_if_slave (ifcfg, (NMSettingConnection *) con_setting); - nm_connection_add_setting (connection, con_setting); - - vlan_setting = make_vlan_setting (ifcfg, file, error); - if (!vlan_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, vlan_setting); - - wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error); - if (!wired_setting) { - g_object_unref (connection); - return NULL; - } - nm_connection_add_setting (connection, wired_setting); - - if (s_8021x) - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - - return connection; -} - -static NMConnection * -create_unhandled_connection (const char *filename, shvarFile *ifcfg, - const char *type, char **out_spec) -{ - NMConnection *connection; - NMSetting *s_con; - char *value; - - nm_assert (out_spec && !*out_spec); - - connection = nm_simple_connection_new (); - - /* Get NAME, UUID, etc. We need to set a connection type (generic) and add - * an empty type-specific setting as well, to make sure it passes - * nm_connection_verify() later. - */ - s_con = make_connection_setting (filename, ifcfg, NM_SETTING_GENERIC_SETTING_NAME, - NULL, NULL); - nm_connection_add_setting (connection, s_con); - - nm_connection_add_setting (connection, nm_setting_generic_new ()); - - /* Get a spec */ - value = svGetValue (ifcfg, "HWADDR", FALSE); - if (value) { - char *lower = g_ascii_strdown (value, -1); - *out_spec = g_strdup_printf ("%s:mac:%s", type, lower); - g_free (lower); - g_free (value); - return connection; - } - - value = svGetValue (ifcfg, "SUBCHANNELS", FALSE); - if (value) { - *out_spec = g_strdup_printf ("%s:s390-subchannels:%s", type, value); - g_free (value); - return connection; - } - - value = svGetValue (ifcfg, "DEVICE", FALSE); - if (value) { - *out_spec = g_strdup_printf ("%s:interface-name:%s", type, value); - g_free (value); - return connection; - } - - g_object_unref (connection); - return NULL; -} - -char * -uuid_from_file (const char *filename) -{ - const char *ifcfg_name = NULL; - shvarFile *ifcfg; - char *uuid; - - g_return_val_if_fail (filename != NULL, NULL); - - ifcfg_name = utils_get_ifcfg_name (filename, TRUE); - if (!ifcfg_name) - return NULL; - - ifcfg = svOpenFile (filename, NULL); - if (!ifcfg) - return NULL; - - /* Try for a UUID key before falling back to hashing the file name */ - uuid = svGetValue (ifcfg, "UUID", FALSE); - if (!uuid || !strlen (uuid)) { - g_free (uuid); - uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); - } - - svCloseFile (ifcfg); - return uuid; -} - -static void -check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) -{ - if (!s_ip6) - return; - - /* If there is no IPv4 config or it doesn't contain DNS searches, - * read DOMAIN and put the domains into IPv6. - */ - if (!s_ip4 || nm_setting_ip_config_get_num_dns_searches (NM_SETTING_IP_CONFIG (s_ip4)) == 0) { - /* DNS searches */ - char *value = svGetValue (ifcfg, "DOMAIN", FALSE); - if (value) { - char **searches = g_strsplit (value, " ", 0); - if (searches) { - char **item; - for (item = searches; *item; item++) { - if (strlen (*item)) { - if (!nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (s_ip6), *item)) - PARSE_WARNING ("duplicate DNS domain '%s'", *item); - } - } - g_strfreev (searches); - } - g_free (value); - } - } -} - -static NMConnection * -connection_from_file_full (const char *filename, - const char *network_file, /* for unit tests only */ - const char *test_type, /* for unit tests only */ - char **out_unhandled, - GError **error, - gboolean *out_ignore_error) -{ - NMConnection *connection = NULL; - shvarFile *parsed; - gs_free char *type = NULL; - char *devtype, *bootproto; - NMSetting *s_ip4, *s_ip6, *s_port, *s_dcb = NULL; - const char *ifcfg_name = NULL; - - g_return_val_if_fail (filename != NULL, NULL); - g_return_val_if_fail (out_unhandled && !*out_unhandled, NULL); - - /* Non-NULL only for unit tests; normally use /etc/sysconfig/network */ - if (!network_file) - network_file = SYSCONFDIR "/sysconfig/network"; - - ifcfg_name = utils_get_ifcfg_name (filename, TRUE); - if (!ifcfg_name) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ignoring connection '%s' because it's not an ifcfg file.", filename); - return NULL; - } - - parsed = svOpenFile (filename, error); - if (!parsed) - return NULL; - - if (!svGetValueBoolean (parsed, "NM_CONTROLLED", TRUE)) { - connection = create_unhandled_connection (filename, parsed, "unmanaged", out_unhandled); - if (!connection) - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "NM_CONTROLLED was false but device was not uniquely identified; device will be managed"); - goto done; - } - - /* iBFT is handled by the iBFT settings plugin */ - bootproto = svGetValue (parsed, "BOOTPROTO", FALSE); - if (bootproto && !g_ascii_strcasecmp (bootproto, "ibft")) { - if (out_ignore_error) - *out_ignore_error = TRUE; - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ignoring iBFT configuration"); - g_free (bootproto); - goto done; - } - g_free (bootproto); - - devtype = svGetValue (parsed, "DEVICETYPE", FALSE); - if (devtype) { - if (!strcasecmp (devtype, TYPE_TEAM)) - type = g_strdup (TYPE_TEAM); - else if (!strcasecmp (devtype, TYPE_TEAM_PORT)) - type = g_strdup (TYPE_ETHERNET); - g_free (devtype); - } - if (!type) { - gs_free char *t = NULL; - - /* Team and TeamPort types are also accepted by the mere - * presense of TEAM_CONFIG/TEAM_MASTER. They don't require - * DEVICETYPE. */ - t = svGetValue (parsed, "TEAM_CONFIG", FALSE); - if (t) - type = g_strdup (TYPE_TEAM); - } - - if (!type) - type = svGetValue (parsed, "TYPE", FALSE); - - if (!type) { - gs_free char *tmp = NULL; - char *device; - - if ((tmp = svGetValue (parsed, "IPV6TUNNELIPV4", FALSE))) { - if (out_ignore_error) - *out_ignore_error = TRUE; - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ignoring unsupported connection due to IPV6TUNNELIPV4"); - goto done; - } - - device = svGetValue (parsed, "DEVICE", FALSE); - if (!device) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "File '%s' had neither TYPE nor DEVICE keys.", filename); - goto done; - } - g_assert (device[0]); - - if (!strcmp (device, "lo")) { - if (out_ignore_error) - *out_ignore_error = TRUE; - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ignoring loopback device config."); - g_free (device); - goto done; - } - - if (!test_type) { - if (is_bond_device (device, parsed)) - type = g_strdup (TYPE_BOND); - else if (is_vlan_device (device, parsed)) - type = g_strdup (TYPE_VLAN); - else if (is_wifi_device (device, parsed)) - type = g_strdup (TYPE_WIRELESS); - else { - gs_free char *p_path = NULL; - char *p_device; - gsize i; - - /* network-functions detects DEVICETYPE based on the ifcfg-* name and the existence - * of a ifup script: - * [ -z "$DEVICETYPE" ] && DEVICETYPE=$(echo ${DEVICE} | sed "s/[0-9]*$//") - * later... - * OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" - * */ -#define IFUP_PATH_PREFIX "/etc/sysconfig/network-scripts/ifup-" - i = strlen (device); - p_path = g_malloc (NM_STRLEN (IFUP_PATH_PREFIX) + i + 1); - p_device = &p_path[NM_STRLEN (IFUP_PATH_PREFIX)]; - memcpy (p_device, device, i + 1); - - /* strip trailing numbers */ - while (i >= 1) { - i--; - if (p_device[i] < '0' || p_device[i] > '9') - break; - p_device[i] = '\0'; - } - - if (nm_streq (p_device, "eth")) - type = g_strdup (TYPE_ETHERNET); - else if (nm_streq (p_device, "wireless")) - type = g_strdup (TYPE_WIRELESS); - else if (p_device[0]) { - memcpy (p_path, IFUP_PATH_PREFIX, NM_STRLEN (IFUP_PATH_PREFIX)); - if (access (p_path, X_OK) == 0) { - /* for all other types, this is not something we want to handle. */ - if (out_ignore_error) - *out_ignore_error = TRUE; - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ignore script for unknown device type which has a matching %s script", - p_path); - goto done; - } - } - - if (!type) - type = g_strdup (TYPE_ETHERNET); - } - } else { - /* For the unit tests, there won't necessarily be any - * adapters of the connection's type in the system so the - * type can't be tested with ioctls. - */ - type = g_strdup (test_type); - } - - g_free (device); - } else { - /* Check for IBM s390 CTC devices and call them Ethernet */ - if (g_strcmp0 (type, "CTC") == 0) { - g_free (type); - type = g_strdup (TYPE_ETHERNET); - } - } - - if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE) && - strcasecmp (type, TYPE_BOND)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "BONDING_MASTER=yes key only allowed in TYPE=bond connections"); - goto done; - } - - /* Construct the connection */ - if (!strcasecmp (type, TYPE_ETHERNET)) - connection = wired_connection_from_ifcfg (filename, parsed, error); - else if (!strcasecmp (type, TYPE_WIRELESS)) - connection = wireless_connection_from_ifcfg (filename, parsed, error); - else if (!strcasecmp (type, TYPE_INFINIBAND)) - connection = infiniband_connection_from_ifcfg (filename, parsed, error); - else if (!strcasecmp (type, TYPE_BOND)) - connection = bond_connection_from_ifcfg (filename, parsed, error); - else if (!strcasecmp (type, TYPE_TEAM)) - connection = team_connection_from_ifcfg (filename, parsed, error); - else if (!strcasecmp (type, TYPE_VLAN)) - connection = vlan_connection_from_ifcfg (filename, parsed, error); - else if (!strcasecmp (type, TYPE_BRIDGE)) - connection = bridge_connection_from_ifcfg (filename, parsed, error); - else { - connection = create_unhandled_connection (filename, parsed, "unrecognized", out_unhandled); - if (!connection) - PARSE_WARNING ("connection type was unrecognized but device was not uniquely identified; device may be managed"); - goto done; - } - - if (!connection) - goto done; - - s_ip6 = make_ip6_setting (parsed, network_file, error); - if (!s_ip6) { - g_object_unref (connection); - connection = NULL; - goto done; - } else - nm_connection_add_setting (connection, s_ip6); - - s_ip4 = make_ip4_setting (parsed, network_file, error); - if (!s_ip4) { - g_object_unref (connection); - connection = NULL; - goto done; - } else { - read_aliases (NM_SETTING_IP_CONFIG (s_ip4), filename); - nm_connection_add_setting (connection, s_ip4); - } - - /* There is only one DOMAIN variable and it is read and put to IPv4 config - * But if IPv4 is disabled or the config fails for some reason, we read - * DOMAIN and put the values into IPv6 config instead. - */ - check_dns_search_domains (parsed, s_ip4, s_ip6); - - /* Bridge port? */ - s_port = make_bridge_port_setting (parsed); - if (s_port) - nm_connection_add_setting (connection, s_port); - - /* Team port? */ - s_port = make_team_port_setting (parsed); - if (s_port) - nm_connection_add_setting (connection, s_port); - - if (!make_dcb_setting (parsed, network_file, &s_dcb, error)) { - g_object_unref (connection); - connection = NULL; - goto done; - } - if (s_dcb) - nm_connection_add_setting (connection, s_dcb); - - if (!nm_connection_normalize (connection, NULL, NULL, error)) { - g_object_unref (connection); - connection = NULL; - } - -done: - svCloseFile (parsed); - return connection; -} - -NMConnection * -connection_from_file (const char *filename, - char **out_unhandled, - GError **error, - gboolean *out_ignore_error) -{ - return connection_from_file_full (filename, NULL, NULL, - out_unhandled, - error, - out_ignore_error); -} - -NMConnection * -connection_from_file_test (const char *filename, - const char *network_file, - const char *test_type, - char **out_unhandled, - GError **error) -{ - return connection_from_file_full (filename, - network_file, - test_type, - out_unhandled, - error, - NULL); -} - -guint -devtimeout_from_file (const char *filename) -{ - shvarFile *ifcfg; - char *devtimeout_str; - guint devtimeout; - - g_return_val_if_fail (filename != NULL, 0); - - ifcfg = svOpenFile (filename, NULL); - if (!ifcfg) - return 0; - - devtimeout_str = svGetValue (ifcfg, "DEVTIMEOUT", FALSE); - if (devtimeout_str) { - devtimeout = _nm_utils_ascii_str_to_int64 (devtimeout_str, 10, 0, G_MAXUINT, 0); - g_free (devtimeout_str); - } else - devtimeout = 0; - - svCloseFile (ifcfg); - - return devtimeout; -} diff --git a/src/settings/plugins/ifcfg-rh/reader.h b/src/settings/plugins/ifcfg-rh/reader.h deleted file mode 100644 index 35464474..00000000 --- a/src/settings/plugins/ifcfg-rh/reader.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Red Hat, Inc. - */ - -#ifndef __READER_H__ -#define __READER_H__ - -#include "nm-connection.h" - -NMConnection *connection_from_file (const char *filename, - char **out_unhandled, - GError **error, - gboolean *out_ignore_error); - -char *uuid_from_file (const char *filename); - -guint devtimeout_from_file (const char *filename); - -/* for test-ifcfg-rh */ -NMConnection *connection_from_file_test (const char *filename, - const char *network_file, - const char *test_type, - char **out_unhandled, - GError **error); - -#endif /* __READER_H__ */ diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index a865c7df..65bcc0d9 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -37,292 +37,901 @@ #include #include "nm-core-internal.h" +#include "nm-core-utils.h" + +/*****************************************************************************/ + +typedef struct { + /* There are three cases: + * + * 1) the line is not a valid variable assignment (that is, it doesn't + * start with a "FOO=" with possible whitespace prefix). + * In that case, @key and @key_with_prefix are %NULL, and the entire + * original line is in @line. Such entries are ignored for the most part. + * + * 2) if the line can be parsed with a "FOO=" assignment, then @line contains + * the part after '=', @key_with_prefix contains the key "FOO" with possible + * whitespace prefix, and @key points into @key_with_prefix skipping over the + * whitespace. + * + * 3) like 2, but if the value was deleted via svSetValue(), the entry is not removed, + * but only marked for deletion. That is done by clearing @line but preserving + * @key/@key_with_prefix. + * */ + char *line; + const char *key; + char *key_with_prefix; +} shvarLine; -/* Open the file , returning a shvarFile on success and NULL on failure. - * Add a wrinkle to let the caller specify whether or not to create the file - * (actually, return a structure anyway) if it doesn't exist. +struct _shvarFile { + char *fileName; + int fd; + GList *lineList; + gboolean modified; +}; + +/*****************************************************************************/ + +/** + * svParseBoolean: + * @value: the input string + * @fallback: the fallback value + * + * Parses a string and returns the boolean value it contains or, + * in case no valid value is found, the fallback value. Valid values + * are: "yes", "true", "t", "y", "1" and "no", "false", "f", "n", "0". + * + * Returns: the parsed boolean value or @fallback. */ -static shvarFile * -svOpenFileInternal (const char *name, gboolean create, GError **error) +gint +svParseBoolean (const char *value, gint fallback) { - shvarFile *s = NULL; - gboolean closefd = FALSE; - int errsv = 0; + if (!value) + return fallback; - s = g_slice_new0 (shvarFile); + if ( !g_ascii_strcasecmp ("yes", value) + || !g_ascii_strcasecmp ("true", value) + || !g_ascii_strcasecmp ("t", value) + || !g_ascii_strcasecmp ("y", value) + || !g_ascii_strcasecmp ("1", value)) + return TRUE; + else if ( !g_ascii_strcasecmp ("no", value) + || !g_ascii_strcasecmp ("false", value) + || !g_ascii_strcasecmp ("f", value) + || !g_ascii_strcasecmp ("n", value) + || !g_ascii_strcasecmp ("0", value)) + return FALSE; - s->fd = -1; - if (create) - s->fd = open (name, O_RDWR | O_CLOEXEC); /* NOT O_CREAT */ + return fallback; +} - if (!create || s->fd == -1) { - /* try read-only */ - s->fd = open (name, O_RDONLY | O_CLOEXEC); /* NOT O_CREAT */ - if (s->fd == -1) - errsv = errno; - else - closefd = TRUE; - } - s->fileName = g_strdup (name); +/*****************************************************************************/ - if (s->fd != -1) { - struct stat buf; - char *arena, *p, *q; - ssize_t nread, total = 0; +static gboolean +_shell_is_name (const char *key, gssize len) +{ + gssize i; - if (fstat (s->fd, &buf) < 0) { - errsv = errno; - goto bail; + /* whether @key is a valid identifier (name). */ + if (!key || len == 0) + return FALSE; + if ( !g_ascii_isalpha (key[0]) + && key[0] != '_') + return FALSE; + for (i = 1; TRUE; i++) { + if (len < 0) { + if (!key[i]) + return TRUE; + } else { + if (i >= len) + return TRUE; } - arena = g_malloc (buf.st_size + 1); - arena[buf.st_size] = '\0'; + if ( !g_ascii_isalnum (key[i]) + && key[i] != '_') + return FALSE; + } +} - while (total < buf.st_size) { - nread = read (s->fd, arena + total, buf.st_size - total); - if (nread == -1 && errno == EINTR) - continue; - if (nread <= 0) { - errsv = errno; - g_free (arena); - goto bail; - } - total += nread; - } +/*****************************************************************************/ + +/* like g_strescape(), except that it also escapes '\''' *sigh*. + * + * While at it, add $''. */ +static char * +_escape_ansic (const char *source) +{ + const char *p; + gchar *dest; + gchar *q; + + nm_assert (source); - /* we'd use g_strsplit() here, but we want a list, not an array */ - for (p = arena; (q = strchr (p, '\n')) != NULL; p = q + 1) - s->lineList = g_list_append (s->lineList, g_strndup (p, q - p)); - g_free (arena); - - /* closefd is set if we opened the file read-only, so go ahead and - * close it, because we can't write to it anyway - */ - if (closefd) { - close (s->fd); - s->fd = -1; + p = (const char *) source; + /* Each source byte needs maximally four destination chars (\777) */ + q = dest = g_malloc (strlen (source) * 4 + 1 + 3); + + *q++ = '$'; + *q++ = '\''; + + while (*p) { + switch (*p) { + case '\b': + *q++ = '\\'; + *q++ = 'b'; + break; + case '\f': + *q++ = '\\'; + *q++ = 'f'; + break; + case '\n': + *q++ = '\\'; + *q++ = 'n'; + break; + case '\r': + *q++ = '\\'; + *q++ = 'r'; + break; + case '\t': + *q++ = '\\'; + *q++ = 't'; + break; + case '\v': + *q++ = '\\'; + *q++ = 'v'; + break; + case '\\': + case '"': + case '\'': + *q++ = '\\'; + *q++ = *p; + break; + default: + if ((*p < ' ') || (*p >= 0177)) { + *q++ = '\\'; + *q++ = '0' + (((*p) >> 6) & 07); + *q++ = '0' + (((*p) >> 3) & 07); + *q++ = '0' + ((*p) & 07); + } else + *q++ = *p; + break; } + p++; + } + *q++ = '\''; + *q++ = '\0'; + + nm_assert (q - dest <= strlen (source) * 4 + 1 + 3); + + return dest; +} + +/*****************************************************************************/ + +#define _char_req_escape(ch) NM_IN_SET (ch, '\"', '\\', '$', '`') +#define _char_req_escape_old(ch) NM_IN_SET (ch, '\"', '\\', '\'', '$', '`', '~') +#define _char_req_quotes(ch) NM_IN_SET (ch, ' ', '\'', '~', '\t', '|', '&', ';', '(', ')', '<', '>') + +const char * +svEscape (const char *s, char **to_free) +{ + char *new; + gsize mangle = 0; + gboolean requires_quotes = FALSE; + int newlen; + size_t i, j, slen; + slen = strlen (s); + + for (i = 0; i < slen; i++) { + if (_char_req_escape (s[i])) + mangle++; + else if (_char_req_quotes (s[i])) + requires_quotes = TRUE; + else if (s[i] < ' ') { + /* if the string contains newline we can only express it using ANSI C quotation + * (as we don't support line continuation). + * Additionally, ANSI control characters look odd with regular quotation, so handle + * them too. */ + return (*to_free = _escape_ansic (s)); + } + } + if (!mangle && !requires_quotes) { + *to_free = NULL; return s; } - if (create) - return s; + newlen = slen + mangle + 3; /* 3 is extra ""\0 */ + new = g_malloc (newlen); - bail: - if (s->fd != -1) - close (s->fd); - g_free (s->fileName); - g_slice_free (shvarFile, s); + j = 0; + new[j++] = '"'; + for (i = 0; i < slen; i++) { + if (_char_req_escape (s[i])) + new[j++] = '\\'; + new[j++] = s[i]; + } + new[j++] = '"'; + new[j++] = '\0'; - g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), - "Could not read file '%s': %s", - name, errsv ? strerror (errsv) : "Unknown error"); - return NULL; + nm_assert (j == slen + mangle + 3); + + *to_free = new; + return new; } -/* Open the file , return shvarFile on success, NULL on failure */ -shvarFile * -svOpenFile (const char *name, GError **error) +static gboolean +_looks_like_old_svescaped (const char *value) { - return svOpenFileInternal (name, FALSE, error); + gsize k; + + if (value[0] != '"') + return FALSE; + + for (k = 1; ; k++) { + if (value[k] == '\0') + return FALSE; + if (!_char_req_escape_old (value[k])) + continue; + + if (value[k] == '"') + return (value[k + 1] == '\0'); + else if (value[k] == '\\') { + k++; + if (!_char_req_escape_old (value[k])) + return FALSE; + } else + return FALSE; + } } -/* Create a new file structure, returning actual data if the file exists, - * and a suitable starting point if it doesn't. - */ -shvarFile * -svCreateFile (const char *name) +static gboolean +_ch_octal_is (char ch) { - return svOpenFileInternal (name, TRUE, NULL); + return ch >= '0' && ch < '8'; } -/* remove escaped characters in place */ -void -svUnescape (char *s) +static guint8 +_ch_octal_get (char ch) { - size_t len, idx_rd = 0, idx_wr = 0; - char c; + nm_assert (_ch_octal_is (ch)); + return (ch - '0'); +} - len = strlen (s); - if (len < 2) { - if (s[0] == '\\') - s[0] = '\0'; - return; +static gboolean +_ch_hex_is (char ch) +{ + return g_ascii_isxdigit (ch); +} + +static guint8 +_ch_hex_get (char ch) +{ + nm_assert (_ch_hex_is (ch)); + return ch <= '9' ? ch - '0' : (ch & 0x4F) - 'A' + 10; +} + +static void +_gstr_init (GString **str, const char *value, gsize i) +{ + nm_assert (str); + nm_assert (value); + + if (!(*str)) { + /* if @str is not yet initialized, it allocates + * a new GString and copies @i characters from + * @value over. + * + * Unescaping usually does not extend the length of a string, + * so we might be tempted to allocate a fixed buffer of length + * (strlen(value)+CONST). + * However, due to $'\Ux' escapes, the maxium length is some + * (FACTOR*strlen(value) + CONST), which is non trivial to get + * right in all cases. Also, we would have to provision for the + * very unlikely extreme case. + * Instead, use a GString buffer which can grow as needed. But for an + * initial guess, strlen(value) is a good start */ + *str = g_string_new_len (NULL, strlen (value) + 3); + if (i) + g_string_append_len (*str, value, i); } +} + +const char * +svUnescape (const char *value, char **to_free) +{ + gsize i, j; + GString *str = NULL; + int looks_like_old_svescaped = -1; + + /* we handle bash syntax here (note that ifup has #!/bin/bash. + * Thus, see https://www.gnu.org/software/bash/manual/html_node/Quoting.html#Quoting */ + + /* @value shall start with the first character after "FOO=" */ + + nm_assert (value); + nm_assert (to_free); + + /* we don't expect any newlines. They must be filtered out before-hand. + * We also don't support line continuation. */ + nm_assert (!NM_STRCHAR_ANY (value, ch, ch == '\n')); + + i = 0; + while (TRUE) { + + if (value[i] == '\0') + goto out_value; + + if ( g_ascii_isspace (value[i]) + || value[i] == ';') { + gboolean has_semicolon = (value[i] == ';'); + + /* starting with space is only allowed, if the entire + * string consists of spaces (possibly terminated by a comment). + * This disallows for example + * LANG=C ls -1 + * LANG= ls -1 + * but allows + * LANG= #comment + * + * As a special case, we also allow one trailing semicolon, as long + * it is only followed by whitespace or a #-comment. + * FOO=; + * FOO=a; + * FOO=b ; #hallo + */ + j = i + 1; + while ( g_ascii_isspace (value[j]) + || ( !has_semicolon + && (has_semicolon = (value[j] == ';')))) + j++; + if (!NM_IN_SET (value[j], '\0', '#')) + goto out_error; + goto out_value; + } - if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) { - if (len == 2) { - s[0] = '\0'; - return; + if (value[i] == '\\') { + /* backslash escape */ + _gstr_init (&str, value, i); + i++; + if (G_UNLIKELY (value[i] == '\0')) { + /* we don't support line continuation */ + goto out_error; + } + g_string_append_c (str, value[i]); + i++; + goto loop1_next; } - if (len == 3) { - if (s[1] == '\\') { - s[0] = '\0'; - } else { - s[0] = s[1]; - s[1] = '\0'; + + if (value[i] == '\'') { + /* single quotes */ + _gstr_init (&str, value, i); + i++; + j = i; + while (TRUE) { + if (value[j] == '\0') { + /* unterminated single quote. We don't support line continuation */ + goto out_error; + } + if (value[j] == '\'') + break; + j++; } - return; + g_string_append_len (str, &value[i], j - i); + i = j + 1; + goto loop1_next; } - s[--len] = '\0'; - idx_rd = 1; - } else { - /* seek for the first escape... */ - char *p = strchr (s, '\\'); - - if (!p) - return; - if (p[1] == '\0') { - p[0] = '\0'; - return; + + if (value[i] == '"') { + /* double quotes */ + _gstr_init (&str, value, i); + i++; + while (TRUE) { + if (value[i] == '"') { + i++; + break; + } + if (value[i] == '\0') { + /* unterminated double quote. We don't support line continuation. */ + goto out_error; + } + if (NM_IN_SET (value[i], '`', '$')) { + /* we don't support shell expansion. */ + goto out_error; + } + if (value[i] == '\\') { + i++; + if (value[i] == '\0') { + /* we don't support line continuation */ + goto out_error; + } + if (NM_IN_SET (value[i], '$', '`', '"', '\\')) { + /* Drop the backslash. */ + } else if (NM_IN_SET (value[i], '\'', '~')) { + /* '\'' and '~' in double qoutes are not handled special by shell. + * However, old versions of svEscape() would wrongly use double-quoting + * with backslash escaping for these characters (expecting svUnescape() + * to remove the backslash). + * + * In order to preserve previous behavior, we continue to read such + * strings different then shell does. */ + + /* Actually, we can relax this. Old svEscape() escaped the entire value + * in a particular way with double quotes. + * If the value doesn't exactly look like something as created by svEscape(), + * don't do the compat hack and preserve the backslash. */ + if (looks_like_old_svescaped < 0) + looks_like_old_svescaped = _looks_like_old_svescaped (value); + if (!looks_like_old_svescaped) + g_string_append_c (str, '\\'); + } else + g_string_append_c (str, '\\'); + } + g_string_append_c (str, value[i]); + i++; + } + goto loop1_next; } - idx_wr = idx_rd = (p - s); - } - /* idx_rd points to the first escape. Walk the string and shift the - * characters from idx_rd to idx_wr. - */ - while ((c = s[idx_rd++])) { - if (c == '\\') { - if (s[idx_rd] == '\0') { - s[idx_wr] = '\0'; - return; + if ( value[i] == '$' + && value[i + 1] == '\'') { + /* ANSI-C Quoting */ + _gstr_init (&str, value, i); + i += 2; + while (TRUE) { + char ch; + + if (value[i] == '\'') { + i++; + break; + } + if (value[i] == '\0') { + /* unterminated double quote. We don't support line continuation. */ + goto out_error; + } + if (value[i] == '\\') { + + i++; + if (value[i] == '\0') { + /* we don't support line continuation */ + goto out_error; + } + switch (value[i]) { + case 'a': ch = '\a'; break; + case 'b': ch = '\b'; break; + case 'e': ch = '\e'; break; + case 'E': ch = '\E'; break; + case 'f': ch = '\f'; break; + case 'n': ch = '\n'; break; + case 'r': ch = '\r'; break; + case 't': ch = '\t'; break; + case 'v': ch = '\v'; break; + case '?': ch = '\?'; break; + case '"': ch = '"'; break; + case '\\': ch = '\\'; break; + case '\'': ch = '\''; break; + default: + if (_ch_octal_is (value[i])) { + guint v; + + v = _ch_octal_get (value[i]); + i++; + if (_ch_octal_is (value[i])) { + v = (v * 8) + _ch_octal_get (value[i]); + i++; + if (_ch_octal_is (value[i])) { + v = (v * 8) + _ch_octal_get (value[i]); + i++; + } + } + /* like bash, we cut too large numbers off. E.g. A=$'\772' becomes 0xfa */ + g_string_append_c (str, (guint8) v); + } else if (NM_IN_SET (value[i], 'x', 'u', 'U')) { + const char escape_type = value[i]; + int max_digits = escape_type == 'x' ? 2 : escape_type == 'u' ? 4 : 8; + guint64 v; + + i++; + if (!_ch_hex_is (value[i])) { + /* missing hex value after "\x" escape. This is treated like no escaping. */ + g_string_append_c (str, '\\'); + g_string_append_c (str, escape_type); + } else { + v = _ch_hex_get (value[i]); + i++; + + while (--max_digits > 0) { + if (!_ch_hex_is (value[i])) + break; + v = v * 16 + _ch_hex_get (value[i]); + i++; + } + if (escape_type == 'x') + g_string_append_c (str, v); + else { + /* we treat the unicode escapes as utf-8 encoded values. */ + g_string_append_unichar (str, v); + } + } + } else { + g_string_append_c (str, '\\'); + g_string_append_c (str, value[i]); + i++; + } + goto loop_ansic_next; + } + } else + ch = value[i]; + g_string_append_c (str, ch); + i++; +loop_ansic_next: ; } - s[idx_wr++] = s[idx_rd++]; - continue; + goto loop1_next; + } + + if (NM_IN_SET (value[i], '|', '&', '(', ')', '<', '>')) { + /* shell metacharacters are not supported without quoting. + * Note that ';' is already handled above. */ + goto out_error; + } + + /* an unquoted, regular character. Just consume it directly. */ + if (str) + g_string_append_c (str, value[i]); + i++; + +loop1_next: ; + } + + nm_assert_not_reached (); + +out_value: + if (i == 0) { + nm_assert (!str); + *to_free = NULL; + return ""; + } + + if (str) { + if (str->len == 0 || str->str[0] == '\0') { + g_string_free (str, TRUE); + *to_free = NULL; + return ""; + } else { + *to_free = g_string_free (str, FALSE); + return *to_free; } - s[idx_wr++] = c; } - s[idx_wr] = '\0'; + + if (value[i] != '\0') { + *to_free = g_strndup (value, i); + return *to_free; + } + + *to_free = NULL; + return value; + +out_error: + if (str) + g_string_free (str, TRUE); + *to_free = NULL; + return NULL; } -/* create a new string with all necessary characters escaped. - * caller must free returned string - */ -static const char escapees[] = "\"'\\$~`"; /* must be escaped */ -static const char spaces[] = " \t|&;()<>"; /* only require "" */ -static const char newlines[] = "\n\r"; /* will be removed */ +/*****************************************************************************/ + +static shvarFile * +svFile_new (const char *name) +{ + shvarFile *s; + + s = g_slice_new0 (shvarFile); + s->fd = -1; + s->fileName = g_strdup (name); + return s; +} const char * -svEscape (const char *s, char **to_free) +svFileGetName (const shvarFile *s) { - char *new; - int i, j, mangle = 0, space = 0, newline = 0; - int newlen, slen; + nm_assert (s); - slen = strlen (s); + return s->fileName; +} - for (i = 0; i < slen; i++) { - if (strchr (escapees, s[i])) - mangle++; - if (strchr (spaces, s[i])) - space++; - if (strchr (newlines, s[i])) - newline++; - } - if (!mangle && !space && !newline) { - *to_free = NULL; - return s; +void +svFileSetName (shvarFile *s, const char *fileName) +{ + g_free (s->fileName); + s->fileName = g_strdup (fileName); +} + +void +svFileSetModified (shvarFile *s) +{ + s->modified = TRUE; +} + +/*****************************************************************************/ + +static void +ASSERT_shvarLine (const shvarLine *line) +{ +#if NM_MORE_ASSERTS > 5 + const char *s, *s2; + + nm_assert (line); + if (!line->key) { + nm_assert (line->line); + nm_assert (!line->key_with_prefix); + s = nm_str_skip_leading_spaces (line->line); + s2 = strchr (s, '='); + nm_assert (!s2 || !_shell_is_name (s, s2 - s)); + } else { + nm_assert (line->key_with_prefix); + nm_assert (line->key == nm_str_skip_leading_spaces (line->key_with_prefix)); + nm_assert (_shell_is_name (line->key, -1)); } +#endif +} - newlen = slen + mangle - newline + 3; /* 3 is extra ""\0 */ - new = g_malloc (newlen); +static shvarLine * +line_new_parse (const char *value, gsize len) +{ + shvarLine *line; + gsize k, e; - j = 0; - new[j++] = '"'; - for (i = 0; i < slen; i++) { - if (strchr (newlines, s[i])) + nm_assert (value); + + line = g_slice_new0 (shvarLine); + + for (k = 0; k < len; k++) { + if (g_ascii_isspace (value[k])) continue; - if (strchr (escapees, s[i])) { - new[j++] = '\\'; + + if ( g_ascii_isalpha (value[k]) + || value[k] == '_') { + for (e = k + 1; e < len; e++) { + if (value[e] == '=') { + nm_assert (_shell_is_name (&value[k], e - k)); + line->line = g_strndup (&value[e + 1], len - e - 1); + line->key_with_prefix = g_strndup (value, e); + line->key = &line->key_with_prefix[k]; + ASSERT_shvarLine (line); + return line; + } + if ( !g_ascii_isalnum (value[e]) + && value[e] != '_') + break; + } } - new[j++] = s[i]; + break; } - new[j++] = '"'; - new[j++] = '\0'; - g_assert (j == slen + mangle - newline + 3); + line->line = g_strndup (value, len); + ASSERT_shvarLine (line); + return line; +} - *to_free = new; - return new; +static shvarLine * +line_new_build (const char *key, const char *value) +{ + char *value_escaped = NULL; + shvarLine *line; + + value = svEscape (value, &value_escaped); + + line = g_slice_new (shvarLine); + line->line = value_escaped ?: g_strdup (value); + line->key_with_prefix = g_strdup (key); + line->key = line->key_with_prefix; + ASSERT_shvarLine (line); + return line; } -/* Get the value associated with the key, and leave the current pointer - * pointing at the line containing the value. The char* returned MUST - * be freed by the caller. +static gboolean +line_set (shvarLine *line, const char *value) +{ + char *value_escaped = NULL; + gboolean changed = FALSE; + + ASSERT_shvarLine (line); + nm_assert (line->key); + + if (line->key != line->key_with_prefix) { + memmove (line->key_with_prefix, line->key, strlen (line->key) + 1); + line->key = line->key_with_prefix; + changed = TRUE; + ASSERT_shvarLine (line); + } + + value = svEscape (value, &value_escaped); + + if (line->line) { + if (nm_streq (value, line->line)) { + g_free (value_escaped); + return changed; + } + g_free (line->line); + } + + line->line = value_escaped ?: g_strdup (value); + ASSERT_shvarLine (line); + return TRUE; +} + +static void +line_free (shvarLine *line) +{ + ASSERT_shvarLine (line); + g_free (line->line); + g_free (line->key_with_prefix); + g_slice_free (shvarLine, line); +} + +/*****************************************************************************/ + +/* Open the file , returning a shvarFile on success and NULL on failure. + * Add a wrinkle to let the caller specify whether or not to create the file + * (actually, return a structure anyway) if it doesn't exist. */ -char * -svGetValue (shvarFile *s, const char *key, gboolean verbatim) +static shvarFile * +svOpenFileInternal (const char *name, gboolean create, GError **error) { - char *value; + shvarFile *s; + gboolean closefd = FALSE; + int errsv = 0; + char *arena; + const char *p, *q; + GError *local = NULL; + nm_auto_close int fd = -1; + GList *lineList = NULL; + + if (create) + fd = open (name, O_RDWR | O_CLOEXEC); /* NOT O_CREAT */ + if (fd < 0) { + /* try read-only */ + fd = open (name, O_RDONLY | O_CLOEXEC); /* NOT O_CREAT */ + if (fd < 0) + errsv = errno; + else + closefd = TRUE; + } - value = svGetValueFull (s, key, verbatim); - if (value && !*value) { - g_free (value); + if (fd < 0) { + if (create) + return svFile_new (name); + + g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), + "Could not read file '%s': %s", + name, strerror (errsv)); return NULL; } - return value; + + if (nm_utils_fd_get_contents (fd, + 10 * 1024 * 1024, + &arena, + NULL, + &local) < 0) { + g_set_error (error, G_FILE_ERROR, + local->domain == G_FILE_ERROR ? local->code : G_FILE_ERROR_FAILED, + "Could not read file '%s': %s", + name, local->message); + g_error_free (local); + return NULL; + } + + for (p = arena; (q = strchr (p, '\n')) != NULL; p = q + 1) + lineList = g_list_prepend (lineList, line_new_parse (p, q - p)); + if (p[0]) + lineList = g_list_prepend (lineList, line_new_parse (p, strlen (p))); + g_free (arena); + lineList = g_list_reverse (lineList); + + s = svFile_new (name); + s->lineList = lineList; + + /* closefd is set if we opened the file read-only, so go ahead and + * close it, because we can't write to it anyway */ + if (!closefd) { + s->fd = fd; + fd = -1; + } + + return s; } -/* svGetValueFull() is identical to svGetValue() except that - * svGetValue() will never return an empty value (but %NULL instead). - * svGetValueFull() will return empty values if that is the value for the @key. */ -char * -svGetValueFull (shvarFile *s, const char *key, gboolean verbatim) +/* Open the file , return shvarFile on success, NULL on failure */ +shvarFile * +svOpenFile (const char *name, GError **error) { - char *value = NULL; - char *line; - guint len; + return svOpenFileInternal (name, FALSE, error); +} - g_return_val_if_fail (s != NULL, NULL); - g_return_val_if_fail (key != NULL, NULL); +/* Create a new file structure, returning actual data if the file exists, + * and a suitable starting point if it doesn't. + */ +shvarFile * +svCreateFile (const char *name) +{ + return svOpenFileInternal (name, TRUE, NULL); +} - len = strlen (key); +/*****************************************************************************/ - for (s->current = s->lineList; s->current; s->current = s->current->next) { - line = s->current->data; - if (!strncmp (key, line, len) && line[len] == '=') { - /* Strip trailing spaces before unescaping to preserve spaces quoted whitespace */ - value = g_strchomp (g_strdup (line + len + 1)); - if (!verbatim) - svUnescape (value); - break; - } +static const GList * +shlist_find (const GList *current, const char *key) +{ + nm_assert (_shell_is_name (key, -1)); + + if (current) { + do { + shvarLine *line = current->data; + + ASSERT_shvarLine (line); + if (line->key && nm_streq (line->key, key)) + return current; + current = current->next; + } while (current); + } + return NULL; +} + +/*****************************************************************************/ + +static const char * +_svGetValue (shvarFile *s, const char *key, char **to_free) +{ + const GList *current, *last; + const shvarLine *line; + + nm_assert (s); + nm_assert (_shell_is_name (key, -1)); + nm_assert (to_free); + + last = NULL; + current = s->lineList; + while ((current = shlist_find (current, key))) { + last = current; + current = current->next; + } + if (last) { + line = last->data; + if (line->line) + return svUnescape (line->line, to_free); } + *to_free = NULL; + return NULL; +} - return value; +const char * +svGetValue (shvarFile *s, const char *key, char **to_free) +{ + g_return_val_if_fail (s != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (to_free, NULL); + + return _svGetValue (s, key, to_free); } -/** - * svParseBoolean: - * @value: the input string - * @fallback: the fallback value - * - * Parses a string and returns the boolean value it contains or, - * in case no valid value is found, the fallback value. Valid values - * are: "yes", "true", "t", "y", "1" and "no", "false", "f", "n", "0". - * - * Returns: the parsed boolean value or @fallback. +/* Get the value associated with the key, and leave the current pointer + * pointing at the line containing the value. The char* returned MUST + * be freed by the caller. */ -gint -svParseBoolean (const char *value, gint fallback) +char * +svGetValueString (shvarFile *s, const char *key) { - if (!value) - return fallback; + char *to_free; + const char *value; - if ( !g_ascii_strcasecmp ("yes", value) - || !g_ascii_strcasecmp ("true", value) - || !g_ascii_strcasecmp ("t", value) - || !g_ascii_strcasecmp ("y", value) - || !g_ascii_strcasecmp ("1", value)) - return TRUE; - else if ( !g_ascii_strcasecmp ("no", value) - || !g_ascii_strcasecmp ("false", value) - || !g_ascii_strcasecmp ("f", value) - || !g_ascii_strcasecmp ("n", value) - || !g_ascii_strcasecmp ("0", value)) - return FALSE; - - return fallback; + value = _svGetValue (s, key, &to_free); + if (!value) { + nm_assert (!to_free); + return NULL; + } + if (!value[0]) { + nm_assert (!to_free); + return NULL; + } + return to_free ?: g_strdup (value); } /* svGetValueBoolean: @@ -337,10 +946,11 @@ svParseBoolean (const char *value, gint fallback) gint svGetValueBoolean (shvarFile *s, const char *key, gint fallback) { - gs_free char *tmp = NULL; + gs_free char *to_free = NULL; + const char *value; - tmp = svGetValue (s, key, FALSE); - return svParseBoolean (tmp, fallback); + value = _svGetValue (s, key, &to_free); + return svParseBoolean (value, fallback); } /* svGetValueInt64: @@ -356,97 +966,108 @@ svGetValueBoolean (shvarFile *s, const char *key, gint fallback) gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback) { - char *tmp; + char *to_free; + const char *value; gint64 result; int errsv; - tmp = svGetValueFull (s, key, FALSE); - if (!tmp) { - errno = 0; + value = _svGetValue (s, key, &to_free); + if (!value) { + nm_assert (!to_free); + /* indicate that the key does not exist (or has a syntax error + * and svUnescape() failed). */ + errno = ENOKEY; return fallback; } - result = _nm_utils_ascii_str_to_int64 (tmp, base, min, max, fallback); - errsv = errno; - - g_free (tmp); - - errno = errsv; + result = _nm_utils_ascii_str_to_int64 (value, base, min, max, fallback); + if (to_free) { + errsv = errno; + g_free (to_free); + errno = errsv; + } return result; } -/* Set the variable equal to the value . - * If does not exist, and the pointer is set, append - * the key=value pair after that line. Otherwise, append the pair - * to the bottom of the file. - */ -void -svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim) -{ - svSetValueFull (s, key, value && value[0] ? value : NULL, verbatim); -} +/*****************************************************************************/ -/* Same as svSetValue() but it preserves empty @value -- contrary to - * svSetValue() for which "" effectively means to remove the value. */ +/* Same as svSetValueString() but it preserves empty @value -- contrary to + * svSetValueString() for which "" effectively means to remove the value. */ void -svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim) +svSetValue (shvarFile *s, const char *key, const char *value) { - gs_free char *newval_free = NULL; - gs_free char *oldval = NULL; - const char *newval; - char *keyValue; + GList *current, *last; g_return_if_fail (s != NULL); g_return_if_fail (key != NULL); - /* value may be NULL */ - - if (!value || verbatim) - newval = value; - else - newval = svEscape (value, &newval_free); - oldval = svGetValueFull (s, key, FALSE); - - if (!newval) { - /* delete value */ - if (oldval) { - /* delete line */ - s->lineList = g_list_remove_link (s->lineList, s->current); - g_free (s->current->data); - g_list_free_1 (s->current); + + nm_assert (_shell_is_name (key, -1)); + + last = NULL; + current = s->lineList; + while ((current = (GList *) shlist_find (current, key))) { + if (last) { + /* if we find multiple entries for the same key, we can + * delete all but the last. */ + line_free (last->data); + s->lineList = g_list_delete_link (s->lineList, last); s->modified = TRUE; } - return; + last = current; + current = current->next; } - keyValue = g_strdup_printf ("%s=%s", key, newval); - if (!oldval) { - /* append line */ - s->lineList = g_list_append (s->lineList, keyValue); - s->modified = TRUE; - return; + if (!value) { + if (last) { + shvarLine *line = last->data; + + if (nm_clear_g_free (&line->line)) + s->modified = TRUE; + } + } else { + if (!last) { + s->lineList = g_list_append (s->lineList, line_new_build (key, value)); + s->modified = TRUE; + } else { + if (line_set (last->data, value)) + s->modified = TRUE; + } } +} - if (strcmp (oldval, newval) != 0) { - /* change line */ - if (s->current) { - g_free (s->current->data); - s->current->data = keyValue; - } else - s->lineList = g_list_append (s->lineList, keyValue); - s->modified = TRUE; - } else - g_free (keyValue); +/* Set the variable equal to the value . + * If does not exist, and the pointer is set, append + * the key=value pair after that line. Otherwise, append the pair + * to the bottom of the file. + */ +void +svSetValueString (shvarFile *s, const char *key, const char *value) +{ + svSetValue (s, key, value && value[0] ? value : NULL); } void svSetValueInt64 (shvarFile *s, const char *key, gint64 value) { - gs_free char *v = NULL; + char buf[NM_DECIMAL_STR_MAX (value)]; + + svSetValue (s, key, nm_sprintf_buf (buf, "%"G_GINT64_FORMAT, value)); +} - v = g_strdup_printf ("%"G_GINT64_FORMAT, value); - svSetValueFull (s, key, v, TRUE); +void +svSetValueBoolean (shvarFile *s, const char *key, gboolean value) +{ + svSetValue (s, key, value ? "yes" : "no"); } +void +svUnsetValue (shvarFile *s, const char *key) +{ + svSetValue (s, key, NULL); +} + +/*****************************************************************************/ + /* Write the current contents iff modified. Returns FALSE on error * and TRUE on success. Do not write if no values have been modified. * The mode argument is only used if creating the file, not if @@ -458,6 +1079,7 @@ svWriteFile (shvarFile *s, int mode, GError **error) { FILE *f; int tmpfd; + const GList *current; if (s->modified) { if (s->fd == -1) @@ -490,9 +1112,36 @@ svWriteFile (shvarFile *s, int mode, GError **error) } f = fdopen (tmpfd, "w"); fseek (f, 0, SEEK_SET); - for (s->current = s->lineList; s->current; s->current = s->current->next) { - char *line = s->current->data; - fprintf (f, "%s\n", line); + for (current = s->lineList; current; current = current->next) { + const shvarLine *line = current->data; + const char *str; + char *s_tmp; + gboolean valid_value; + + ASSERT_shvarLine (line); + + if (!line->key) { + str = nm_str_skip_leading_spaces (line->line); + if (NM_IN_SET (str[0], '\0', '#')) + fprintf (f, "%s\n", line->line); + else + fprintf (f, "#NM: %s\n", line->line); + continue; + } + + if (!line->line) + continue; + + /* we check that the assignment can be properly unescaped. */ + valid_value = !!svUnescape (line->line, &s_tmp); + g_free (s_tmp); + + if (valid_value) + fprintf (f, "%s=%s\n", line->key_with_prefix, line->line); + else { + fprintf (f, "%s=\n", line->key); + fprintf (f, "#NM: %s=%s\n", line->key_with_prefix, line->line); + } } fclose (f); } @@ -500,8 +1149,6 @@ svWriteFile (shvarFile *s, int mode, GError **error) return TRUE; } - -/* Close the file descriptor (if open) and free the shvarFile. */ void svCloseFile (shvarFile *s) { @@ -509,8 +1156,7 @@ svCloseFile (shvarFile *s) if (s->fd != -1) close (s->fd); - g_free (s->fileName); - g_list_free_full (s->lineList, g_free); /* implicitly frees s->current */ + g_list_free_full (s->lineList, (GDestroyNotify) line_free); g_slice_free (shvarFile, s); } diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index 97df8128..a6498fce 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -32,14 +32,11 @@ #define _SHVAR_H typedef struct _shvarFile shvarFile; -struct _shvarFile { - char *fileName; /* read-only */ - int fd; /* read-only */ - GList *lineList; /* read-only */ - GList *current; /* set implicitly or explicitly, points to element of lineList */ - gboolean modified; /* ignore */ -}; +const char *svFileGetName (const shvarFile *s); +void svFileSetName (shvarFile *s, const char *fileName); + +void svFileSetModified (shvarFile *s); /* Create the file , return a shvarFile (never fails) */ shvarFile *svCreateFile (const char *name); @@ -51,8 +48,8 @@ shvarFile *svOpenFile (const char *name, GError **error); * pointing at the line containing the value. The char* returned MUST * be freed by the caller. */ -char *svGetValue (shvarFile *s, const char *key, gboolean verbatim); -char *svGetValueFull (shvarFile *s, const char *key, gboolean verbatim); +const char *svGetValue (shvarFile *s, const char *key, char **to_free); +char *svGetValueString (shvarFile *s, const char *key); gint svParseBoolean (const char *value, gint def); @@ -69,10 +66,12 @@ gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, g * the key=value pair after that line. Otherwise, prepend the pair * to the top of the file. */ -void svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim); -void svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim); +void svSetValueString (shvarFile *s, const char *key, const char *value); +void svSetValue (shvarFile *s, const char *key, const char *value); +void svSetValueBoolean (shvarFile *s, const char *key, gboolean value); void svSetValueInt64 (shvarFile *s, const char *key, gint64 value); +void svUnsetValue (shvarFile *s, const char *key); /* Write the current contents iff modified. Returns FALSE on error * and TRUE on success. Do not write if no values have been modified. @@ -85,10 +84,7 @@ gboolean svWriteFile (shvarFile *s, int mode, GError **error); /* Close the file descriptor (if open) and free the shvarFile. */ void svCloseFile (shvarFile *s); -/* Return @s unmodified or an escaped string */ const char *svEscape (const char *s, char **to_free); - -/* Unescape a string in-place */ -void svUnescape (char *s); +const char *svUnescape (const char *s, char **to_free); #endif /* _SHVAR_H */ diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am deleted file mode 100644 index fedbd93f..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -if ENABLE_TESTS - -SUBDIRS=network-scripts - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(srcdir)/../ \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ - -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ - -DSYSCONFDIR=\"nonexistent\" \ - -DSBINDIR=\"nonexistent\" - -AM_LDFLAGS = \ - $(GLIB_LIBS) \ - $(CODE_COVERAGE_LDFLAGS) - -noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils - -test_ifcfg_rh_SOURCES = \ - test-ifcfg-rh.c \ - ../reader.c \ - ../shvar.c \ - ../utils.c \ - ../writer.c - -test_ifcfg_rh_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -test_ifcfg_rh_utils_SOURCES = \ - test-ifcfg-rh-utils.c \ - ../utils.c \ - ../shvar.c - -test_ifcfg_rh_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-ifcfg-rh-utils test-ifcfg-rh - -check-local: - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifcfg-rh.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in deleted file mode 100644 index f2ce157b..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in +++ /dev/null @@ -1,1371 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-ifcfg-rh$(EXEEXT) \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh-utils$(EXEEXT) -@ENABLE_TESTS_TRUE@TESTS = test-ifcfg-rh-utils$(EXEEXT) \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh$(EXEEXT) -subdir = src/settings/plugins/ifcfg-rh/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am__test_ifcfg_rh_SOURCES_DIST = test-ifcfg-rh.c ../reader.c \ - ../shvar.c ../utils.c ../writer.c -@ENABLE_TESTS_TRUE@am_test_ifcfg_rh_OBJECTS = test-ifcfg-rh.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ reader.$(OBJEXT) shvar.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ utils.$(OBJEXT) writer.$(OBJEXT) -test_ifcfg_rh_OBJECTS = $(am_test_ifcfg_rh_OBJECTS) -@ENABLE_TESTS_TRUE@test_ifcfg_rh_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -am__test_ifcfg_rh_utils_SOURCES_DIST = test-ifcfg-rh-utils.c \ - ../utils.c ../shvar.c -@ENABLE_TESTS_TRUE@am_test_ifcfg_rh_utils_OBJECTS = \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh-utils.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ utils.$(OBJEXT) shvar.$(OBJEXT) -test_ifcfg_rh_utils_OBJECTS = $(am_test_ifcfg_rh_utils_OBJECTS) -@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_ifcfg_rh_SOURCES) $(test_ifcfg_rh_utils_SOURCES) -DIST_SOURCES = $(am__test_ifcfg_rh_SOURCES_DIST) \ - $(am__test_ifcfg_rh_utils_SOURCES_DIST) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - check recheck distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -DIST_SUBDIRS = network-scripts -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@ENABLE_TESTS_TRUE@SUBDIRS = network-scripts -@ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/platform \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ -@ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -@ENABLE_TESTS_TRUE@ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ -@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ -@ENABLE_TESTS_TRUE@ -DSYSCONFDIR=\"nonexistent\" \ -@ENABLE_TESTS_TRUE@ -DSBINDIR=\"nonexistent\" - -@ENABLE_TESTS_TRUE@AM_LDFLAGS = \ -@ENABLE_TESTS_TRUE@ $(GLIB_LIBS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh.c \ -@ENABLE_TESTS_TRUE@ ../reader.c \ -@ENABLE_TESTS_TRUE@ ../shvar.c \ -@ENABLE_TESTS_TRUE@ ../utils.c \ -@ENABLE_TESTS_TRUE@ ../writer.c - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh-utils.c \ -@ENABLE_TESTS_TRUE@ ../utils.c \ -@ENABLE_TESTS_TRUE@ ../shvar.c - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la - -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-ifcfg-rh$(EXEEXT): $(test_ifcfg_rh_OBJECTS) $(test_ifcfg_rh_DEPENDENCIES) $(EXTRA_test_ifcfg_rh_DEPENDENCIES) - @rm -f test-ifcfg-rh$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ifcfg_rh_OBJECTS) $(test_ifcfg_rh_LDADD) $(LIBS) - -test-ifcfg-rh-utils$(EXEEXT): $(test_ifcfg_rh_utils_OBJECTS) $(test_ifcfg_rh_utils_DEPENDENCIES) $(EXTRA_test_ifcfg_rh_utils_DEPENDENCIES) - @rm -f test-ifcfg-rh-utils$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ifcfg_rh_utils_OBJECTS) $(test_ifcfg_rh_utils_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shvar.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifcfg-rh-utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifcfg-rh.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -reader.o: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.o -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c - -reader.obj: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.obj -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` - -shvar.o: ../shvar.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shvar.o -MD -MP -MF $(DEPDIR)/shvar.Tpo -c -o shvar.o `test -f '../shvar.c' || echo '$(srcdir)/'`../shvar.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/shvar.Tpo $(DEPDIR)/shvar.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../shvar.c' object='shvar.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o shvar.o `test -f '../shvar.c' || echo '$(srcdir)/'`../shvar.c - -shvar.obj: ../shvar.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shvar.obj -MD -MP -MF $(DEPDIR)/shvar.Tpo -c -o shvar.obj `if test -f '../shvar.c'; then $(CYGPATH_W) '../shvar.c'; else $(CYGPATH_W) '$(srcdir)/../shvar.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/shvar.Tpo $(DEPDIR)/shvar.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../shvar.c' object='shvar.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o shvar.obj `if test -f '../shvar.c'; then $(CYGPATH_W) '../shvar.c'; else $(CYGPATH_W) '$(srcdir)/../shvar.c'; fi` - -utils.o: ../utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.o -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c - -utils.obj: ../utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.obj -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` - -writer.o: ../writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.o -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c - -writer.obj: ../writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.obj -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-ifcfg-rh-utils.log: test-ifcfg-rh-utils$(EXEEXT) - @p='test-ifcfg-rh-utils$(EXEEXT)'; \ - b='test-ifcfg-rh-utils'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-ifcfg-rh.log: test-ifcfg-rh$(EXEEXT) - @p='test-ifcfg-rh$(EXEEXT)'; \ - b='test-ifcfg-rh'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local -check: check-recursive -all-am: Makefile $(PROGRAMS) -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) check-am install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-TESTS check-am check-local clean clean-generic \ - clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@@VALGRIND_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifcfg-rh.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am deleted file mode 100644 index de9c1ed7..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ /dev/null @@ -1,170 +0,0 @@ -EXTRA_DIST = \ - ifcfg-test-minimal \ - ifcfg-test-misc-variables \ - ifcfg-test-variables-corner-cases-1 \ - ifcfg-test-nm-controlled \ - ifcfg-test-nm-controlled-unrecognized \ - ifcfg-test-unrecognized \ - ifcfg-test-wired-static \ - ifcfg-test-wired-static-bootproto \ - ifcfg-test-wired-dhcp \ - ifcfg-test-wired-dhcp-plus-ip \ - ifcfg-test-wired-shared-plus-ip \ - ifcfg-test-wired-dhcp-send-hostname \ - ifcfg-test-wired-dhcp6-only \ - ifcfg-test-wired-autoip \ - ifcfg-test-wired-global-gateway \ - network-test-wired-global-gateway \ - ifcfg-test-wired-global-gateway-ignore \ - network-test-wired-global-gateway-ignore \ - ifcfg-test-wired-obsolete-gateway-n \ - ifcfg-test-wired-never-default \ - network-test-wired-never-default \ - ifcfg-test-wired-defroute-no \ - ifcfg-test-wired-defroute-no-gatewaydev-yes \ - network-test-wired-defroute-no-gatewaydev-yes \ - ifcfg-test-wired-8021x-peap-mschapv2 \ - keys-test-wired-8021x-peap-mschapv2 \ - ifcfg-test-wired-8021x-tls-agent \ - ifcfg-test-wired-8021x-tls-always \ - ifcfg-test-wired-802-1X-subj-matches \ - ifcfg-test-wired-802-1x-ttls-eapgtc \ - ifcfg-test-onboot-no \ - ifcfg-test-noip \ - ifcfg-test-wifi-open \ - ifcfg-test-wifi-open-auto \ - ifcfg-test-wifi-open-ssid-quoted \ - ifcfg-test-wifi-open-ssid-long-quoted \ - ifcfg-test-wifi-open-ssid-hex \ - ifcfg-test-wifi-open-ssid-long-hex \ - ifcfg-test-wifi-open-ssid-bad-hex \ - ifcfg-test-wifi-wep \ - keys-test-wifi-wep \ - ifcfg-test-wifi-wep-adhoc \ - keys-test-wifi-wep-adhoc \ - ifcfg-test-wifi-wep-eap-ttls-chap \ - keys-test-wifi-wep-eap-ttls-chap \ - ifcfg-test-wifi-leap \ - keys-test-wifi-leap \ - ifcfg-test-wifi-leap-agent \ - ifcfg-test-wifi-leap-always-ask \ - ifcfg-test-wifi-wpa-psk \ - keys-test-wifi-wpa-psk \ - ifcfg-test-wifi-wpa-psk-2 \ - keys-test-wifi-wpa-psk-2 \ - ifcfg-test-wifi-wpa-psk-unquoted \ - keys-test-wifi-wpa-psk-unquoted \ - ifcfg-test-wifi-wpa-psk-unquoted2 \ - keys-test-wifi-wpa-psk-unquoted2 \ - ifcfg-test-wifi-wpa-psk-adhoc \ - keys-test-wifi-wpa-psk-adhoc \ - ifcfg-test-wifi-wpa-psk-hex \ - keys-test-wifi-wpa-psk-hex \ - ifcfg-test-wifi-wpa-eap-tls \ - keys-test-wifi-wpa-eap-tls \ - ifcfg-test-wifi-wpa-eap-ttls-tls \ - keys-test-wifi-wpa-eap-ttls-tls \ - ifcfg-test-wifi-hidden \ - ifcfg-test-wifi-band-a \ - ifcfg-test-wifi-band-a-channel-mismatch \ - ifcfg-test-wifi-band-bg-channel-mismatch \ - ifcfg-test-wifi-mac-random-always \ - ifcfg-test-wifi-mac-random-never \ - ifcfg-test-wifi-mac-random-default \ - ifcfg-test-wifi-mac-random-missing \ - test_ca_cert.pem \ - test1_key_and_cert.pem \ - ifcfg-test-ibft \ - ifcfg-test-static-routes-legacy \ - route-test-static-routes-legacy \ - ifcfg-test-sit-ignore \ - ifcfg-test-wired-static-routes \ - route-test-wired-static-routes \ - ifcfg-test-wired-static-routes-legacy \ - route-test-wired-static-routes-legacy \ - ifcfg-test-wired-ipv4-manual-1 \ - ifcfg-test-wired-ipv4-manual-2 \ - ifcfg-test-wired-ipv4-manual-3 \ - ifcfg-test-wired-ipv4-manual-4 \ - ifcfg-test-wired-ipv6-manual \ - route6-test-wired-ipv6-manual \ - ifcfg-test-wired-static-no-prefix-8 \ - ifcfg-test-wired-static-no-prefix-16 \ - ifcfg-test-wired-static-no-prefix-24 \ - ifcfg-test-wired-ipv6-only \ - ifcfg-test-wifi-wep-passphrase \ - keys-test-wifi-wep-passphrase \ - ifcfg-test-wifi-wep-40-ascii \ - keys-test-wifi-wep-40-ascii \ - ifcfg-test-wifi-wep-104-ascii \ - keys-test-wifi-wep-104-ascii \ - ifcfg-test-wired-qeth-static \ - ifcfg-test-wired-ctc-static \ - ifcfg-test-bridge-main \ - ifcfg-test-bridge-component \ - ifcfg-test-bridge-missing-stp \ - ifcfg-test-vlan-interface \ - ifcfg-test-vlan-only-vlanid \ - ifcfg-test-vlan-only-device \ - ifcfg-test-vlan-physdev \ - ifcfg-test-vlan-reorder-hdr-1 \ - ifcfg-test-vlan-reorder-hdr-2 \ - ifcfg-test-vlan-flags-1 \ - ifcfg-test-vlan-flags-2 \ - ifcfg-test-wifi-wep-no-keys \ - ifcfg-test-permissions \ - ifcfg-test-wifi-wep-agent-keys \ - ifcfg-test-wifi-dynamic-wep-leap \ - keys-test-wifi-dynamic-wep-leap \ - ifcfg-test-infiniband \ - ifcfg-test-bond-main \ - ifcfg-test-bond-slave \ - ifcfg-test-bond-slave-ib \ - ifcfg-test-bond-mode-numeric \ - ifcfg-test-dcb \ - ifcfg-test-dcb-default-app-priorities \ - ifcfg-test-dcb-bad-booleans \ - ifcfg-test-dcb-short-booleans \ - ifcfg-test-dcb-bad-uints \ - ifcfg-test-dcb-short-uints \ - ifcfg-test-dcb-bad-percent \ - ifcfg-test-dcb-short-percent \ - ifcfg-test-dcb-pgpct-not-100 \ - ifcfg-test-fcoe-fabric \ - ifcfg-test-fcoe-vn2vn \ - ifcfg-test-team-master-1 \ - ifcfg-test-team-master-2 \ - ifcfg-test-team-master-invalid \ - ifcfg-test-team-port-1 \ - ifcfg-test-team-port-2 \ - ifcfg-test-team-port-empty-config \ - ifcfg-test-vlan-trailing-spaces \ - ifcfg-test-dns-options \ - ifcfg-test-wired-wake-on-lan \ - ifcfg-test-wired-ipv6-only-1 - -# make target dependencies can't have colons in their names, which ends up -# meaning that we can't add the alias files to EXTRA_DIST -ALIAS_FILES = \ - ifcfg-aliasem0 \ - ifcfg-aliasem0:1 \ - ifcfg-aliasem0:2 \ - ifcfg-aliasem0:99 \ - ifcfg-aliasem1 \ - ifcfg-aliasem1:1 \ - ifcfg-aliasem2 \ - ifcfg-aliasem2:1 - -dist-hook: - @for f in $(ALIAS_FILES); do \ - cp $(abs_srcdir)/$$f $(distdir)/; \ - done - -check-local: - @for f in $(EXTRA_DIST) $(ALIAS_FILES); do \ - chmod 0600 $(abs_srcdir)/$$f; \ - done - -# Make the special temp dir for some written connections - mkdir -p $(abs_builddir)/tmp - diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in deleted file mode 100644 index 583f0809..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ /dev/null @@ -1,776 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ifcfg-rh/tests/network-scripts -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -EXTRA_DIST = \ - ifcfg-test-minimal \ - ifcfg-test-misc-variables \ - ifcfg-test-variables-corner-cases-1 \ - ifcfg-test-nm-controlled \ - ifcfg-test-nm-controlled-unrecognized \ - ifcfg-test-unrecognized \ - ifcfg-test-wired-static \ - ifcfg-test-wired-static-bootproto \ - ifcfg-test-wired-dhcp \ - ifcfg-test-wired-dhcp-plus-ip \ - ifcfg-test-wired-shared-plus-ip \ - ifcfg-test-wired-dhcp-send-hostname \ - ifcfg-test-wired-dhcp6-only \ - ifcfg-test-wired-autoip \ - ifcfg-test-wired-global-gateway \ - network-test-wired-global-gateway \ - ifcfg-test-wired-global-gateway-ignore \ - network-test-wired-global-gateway-ignore \ - ifcfg-test-wired-obsolete-gateway-n \ - ifcfg-test-wired-never-default \ - network-test-wired-never-default \ - ifcfg-test-wired-defroute-no \ - ifcfg-test-wired-defroute-no-gatewaydev-yes \ - network-test-wired-defroute-no-gatewaydev-yes \ - ifcfg-test-wired-8021x-peap-mschapv2 \ - keys-test-wired-8021x-peap-mschapv2 \ - ifcfg-test-wired-8021x-tls-agent \ - ifcfg-test-wired-8021x-tls-always \ - ifcfg-test-wired-802-1X-subj-matches \ - ifcfg-test-wired-802-1x-ttls-eapgtc \ - ifcfg-test-onboot-no \ - ifcfg-test-noip \ - ifcfg-test-wifi-open \ - ifcfg-test-wifi-open-auto \ - ifcfg-test-wifi-open-ssid-quoted \ - ifcfg-test-wifi-open-ssid-long-quoted \ - ifcfg-test-wifi-open-ssid-hex \ - ifcfg-test-wifi-open-ssid-long-hex \ - ifcfg-test-wifi-open-ssid-bad-hex \ - ifcfg-test-wifi-wep \ - keys-test-wifi-wep \ - ifcfg-test-wifi-wep-adhoc \ - keys-test-wifi-wep-adhoc \ - ifcfg-test-wifi-wep-eap-ttls-chap \ - keys-test-wifi-wep-eap-ttls-chap \ - ifcfg-test-wifi-leap \ - keys-test-wifi-leap \ - ifcfg-test-wifi-leap-agent \ - ifcfg-test-wifi-leap-always-ask \ - ifcfg-test-wifi-wpa-psk \ - keys-test-wifi-wpa-psk \ - ifcfg-test-wifi-wpa-psk-2 \ - keys-test-wifi-wpa-psk-2 \ - ifcfg-test-wifi-wpa-psk-unquoted \ - keys-test-wifi-wpa-psk-unquoted \ - ifcfg-test-wifi-wpa-psk-unquoted2 \ - keys-test-wifi-wpa-psk-unquoted2 \ - ifcfg-test-wifi-wpa-psk-adhoc \ - keys-test-wifi-wpa-psk-adhoc \ - ifcfg-test-wifi-wpa-psk-hex \ - keys-test-wifi-wpa-psk-hex \ - ifcfg-test-wifi-wpa-eap-tls \ - keys-test-wifi-wpa-eap-tls \ - ifcfg-test-wifi-wpa-eap-ttls-tls \ - keys-test-wifi-wpa-eap-ttls-tls \ - ifcfg-test-wifi-hidden \ - ifcfg-test-wifi-band-a \ - ifcfg-test-wifi-band-a-channel-mismatch \ - ifcfg-test-wifi-band-bg-channel-mismatch \ - ifcfg-test-wifi-mac-random-always \ - ifcfg-test-wifi-mac-random-never \ - ifcfg-test-wifi-mac-random-default \ - ifcfg-test-wifi-mac-random-missing \ - test_ca_cert.pem \ - test1_key_and_cert.pem \ - ifcfg-test-ibft \ - ifcfg-test-static-routes-legacy \ - route-test-static-routes-legacy \ - ifcfg-test-sit-ignore \ - ifcfg-test-wired-static-routes \ - route-test-wired-static-routes \ - ifcfg-test-wired-static-routes-legacy \ - route-test-wired-static-routes-legacy \ - ifcfg-test-wired-ipv4-manual-1 \ - ifcfg-test-wired-ipv4-manual-2 \ - ifcfg-test-wired-ipv4-manual-3 \ - ifcfg-test-wired-ipv4-manual-4 \ - ifcfg-test-wired-ipv6-manual \ - route6-test-wired-ipv6-manual \ - ifcfg-test-wired-static-no-prefix-8 \ - ifcfg-test-wired-static-no-prefix-16 \ - ifcfg-test-wired-static-no-prefix-24 \ - ifcfg-test-wired-ipv6-only \ - ifcfg-test-wifi-wep-passphrase \ - keys-test-wifi-wep-passphrase \ - ifcfg-test-wifi-wep-40-ascii \ - keys-test-wifi-wep-40-ascii \ - ifcfg-test-wifi-wep-104-ascii \ - keys-test-wifi-wep-104-ascii \ - ifcfg-test-wired-qeth-static \ - ifcfg-test-wired-ctc-static \ - ifcfg-test-bridge-main \ - ifcfg-test-bridge-component \ - ifcfg-test-bridge-missing-stp \ - ifcfg-test-vlan-interface \ - ifcfg-test-vlan-only-vlanid \ - ifcfg-test-vlan-only-device \ - ifcfg-test-vlan-physdev \ - ifcfg-test-vlan-reorder-hdr-1 \ - ifcfg-test-vlan-reorder-hdr-2 \ - ifcfg-test-vlan-flags-1 \ - ifcfg-test-vlan-flags-2 \ - ifcfg-test-wifi-wep-no-keys \ - ifcfg-test-permissions \ - ifcfg-test-wifi-wep-agent-keys \ - ifcfg-test-wifi-dynamic-wep-leap \ - keys-test-wifi-dynamic-wep-leap \ - ifcfg-test-infiniband \ - ifcfg-test-bond-main \ - ifcfg-test-bond-slave \ - ifcfg-test-bond-slave-ib \ - ifcfg-test-bond-mode-numeric \ - ifcfg-test-dcb \ - ifcfg-test-dcb-default-app-priorities \ - ifcfg-test-dcb-bad-booleans \ - ifcfg-test-dcb-short-booleans \ - ifcfg-test-dcb-bad-uints \ - ifcfg-test-dcb-short-uints \ - ifcfg-test-dcb-bad-percent \ - ifcfg-test-dcb-short-percent \ - ifcfg-test-dcb-pgpct-not-100 \ - ifcfg-test-fcoe-fabric \ - ifcfg-test-fcoe-vn2vn \ - ifcfg-test-team-master-1 \ - ifcfg-test-team-master-2 \ - ifcfg-test-team-master-invalid \ - ifcfg-test-team-port-1 \ - ifcfg-test-team-port-2 \ - ifcfg-test-team-port-empty-config \ - ifcfg-test-vlan-trailing-spaces \ - ifcfg-test-dns-options \ - ifcfg-test-wired-wake-on-lan \ - ifcfg-test-wired-ipv6-only-1 - - -# make target dependencies can't have colons in their names, which ends up -# meaning that we can't add the alias files to EXTRA_DIST -ALIAS_FILES = \ - ifcfg-aliasem0 \ - ifcfg-aliasem0:1 \ - ifcfg-aliasem0:2 \ - ifcfg-aliasem0:99 \ - ifcfg-aliasem1 \ - ifcfg-aliasem1:1 \ - ifcfg-aliasem2 \ - ifcfg-aliasem2:1 - -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: all all-am check check-am check-local clean clean-generic \ - clean-libtool cscopelist-am ctags-am dist-hook distclean \ - distclean-generic distclean-libtool distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ - uninstall-am - -.PRECIOUS: Makefile - - -dist-hook: - @for f in $(ALIAS_FILES); do \ - cp $(abs_srcdir)/$$f $(distdir)/; \ - done - -check-local: - @for f in $(EXTRA_DIST) $(ALIAS_FILES); do \ - chmod 0600 $(abs_srcdir)/$$f; \ - done - -# Make the special temp dir for some written connections - mkdir -p $(abs_builddir)/tmp - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables index c7892a21..1b10cddb 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables @@ -1,3 +1,4 @@ DEVICE=eth0 HWADDR_BLACKLIST="00:16:41:11:22:88 00:16:41:11:22:99 XX:aa:invalid 6A:5D:5A:FA:DD:F0" +AUTOCONNECT_RETRIES=100 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic new file mode 100644 index 00000000..e2cf6c21 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic @@ -0,0 +1,15 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=dhcp +ONBOOT=yes +USERCTL=yes +IPV6INIT=no +NM_CONTROLLED=yes +PEERDNS=no + +# proxy configuration +PROXY_METHOD=auto +PAC_URL=http://wpad.mycompany.com/wpad.dat +BROWSER_ONLY=yes diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk index 2119ba8e..a78051aa 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk @@ -16,4 +16,4 @@ CIPHER_GROUP="TKIP CCMP WEP40 WEP104" KEY_MGMT=WPA-PSK WPA_ALLOW_WPA=yes WPA_ALLOW_WPA2=yes - +LAST_ENTRY=no-newline \ No newline at end of file diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-auto-negotiate-on b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-auto-negotiate-on new file mode 100644 index 00000000..d0b50775 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-auto-negotiate-on @@ -0,0 +1,22 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +ONBOOT=yes +USERCTL=yes +MTU=1492 +NM_CONTROLLED=yes +DNS1=4.2.2.1 +DNS2=4.2.2.2 +IPADDR=192.168.1.5 +NETMASK=255.255.255.0 +GATEWAY=192.168.1.1 +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR=dead:beaf::1 +IPV6ADDR_SECONDARIES="dead:beaf::2/56" +DNS3=1:2:3:4::a +DNS4=1:2:3:4::b +RES_OPTIONS= +ETHTOOL_OPTS="wol apgs sopass 00:11:22:33:44:55 autoneg on speed 100" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback new file mode 100644 index 00000000..d38e762e --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback @@ -0,0 +1,12 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=dhcp +ONBOOT=yes +IPV6INIT=yes +IPV6_AUTOCONF=yes +USERCTL=yes +NM_CONTROLLED=yes +PEERDNS=no +DHCP_HOSTNAME="fully.qualified.domain" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-unknown-ethtool-opt b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-unknown-ethtool-opt new file mode 100644 index 00000000..861dd41f --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-unknown-ethtool-opt @@ -0,0 +1,22 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +ONBOOT=yes +USERCTL=yes +MTU=1492 +NM_CONTROLLED=yes +DNS1=4.2.2.1 +DNS2=4.2.2.2 +IPADDR=192.168.1.5 +NETMASK=255.255.255.0 +GATEWAY=192.168.1.1 +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR=dead:beaf::1 +IPV6ADDR_SECONDARIES="dead:beaf::2/56" +DNS3=1:2:3:4::a +DNS4=1:2:3:4::b +RES_OPTIONS= +ETHTOOL_OPTS="unknown1 wol apgs sopass 00:11:22:33:44:55 unkwnown2 opt2 unknown3" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1 new file mode 100644 index 00000000..c927389e --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1 @@ -0,0 +1,8 @@ +FOO='val + bar=3' +wrong line + F2=b + F3='b +XXX=adf' + XXX2=val2 +' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1.expected new file mode 100644 index 00000000..568b2efc --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1.expected @@ -0,0 +1,12 @@ +FOO= +#NM: FOO='val +bar= +#NM: bar=3' +#NM: wrong line + F2=b +F3= +#NM: F3='b +XXX= +#NM: XXX=adf' + XXX2=val2 +#NM: ' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2 new file mode 100644 index 00000000..850149b2 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2 @@ -0,0 +1,3 @@ +FOO=' +BAR=a +' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2.expected new file mode 100644 index 00000000..6ec53c17 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2.expected @@ -0,0 +1,4 @@ +FOO= +#NM: FOO=' +BAR=a +#NM: ' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3 new file mode 100644 index 00000000..3d198e00 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3 @@ -0,0 +1,3 @@ +FOO=' +BAR=" +' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3.expected new file mode 100644 index 00000000..d2b27eb3 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3.expected @@ -0,0 +1,5 @@ +FOO= +#NM: FOO=' +BAR= +#NM: BAR=" +#NM: ' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4 new file mode 100644 index 00000000..a7156e33 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4 @@ -0,0 +1,36 @@ +# test what happens with multiple defines of a name. +# +# Note that svGetValue() will return "l4x", which +# isn't correct in terms of shell-parsing. But we +# don't consider only line-by-line, thus this is +# expected. +# +# Also note that setting NAME will replace the last +# occurance, and delete all previous once. + +#L1 +NAME=l2 + +#L2 +NAME=l3 + +some_key1='' +some_key2=$'\U0x' +some_key3=$'x\U0' + +#L4 +NAME=' +NAME=l4x +' + +#Lx-1 +NAME2=not-visible +#Lx-2 +NAME2='invalid +#Lx-3 + +#Ly-1 +NAME3='invalid +#Ly-2 +NAME3=name3-value +#Ly-3 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4.expected new file mode 100644 index 00000000..674df840 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4.expected @@ -0,0 +1,31 @@ +# test what happens with multiple defines of a name. +# +# Note that svGetValue() will return "l4x", which +# isn't correct in terms of shell-parsing. But we +# don't consider only line-by-line, thus this is +# expected. +# +# Also note that setting NAME will replace the last +# occurance, and delete all previous once. + +#L1 + +#L2 + +some_key1='' +some_key2=$'\U0x' +some_key3=$'x\U0' + +#L4 +NAME=set-by-test1 +#NM: ' + +#Lx-1 +#Lx-2 +NAME2=set-by-test2 +#Lx-3 + +#Ly-1 +#Ly-2 +NAME3=set-by-test3 +#Ly-3 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 index 6a63e817..995721dd 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 @@ -1,2 +1,2 @@ -WPA_PSK=$'They\'re really saying I love you. >>`<< \' +WPA_PSK="They're really saying I love you. >>\`<< '" diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c deleted file mode 100644 index d2a348bb..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "common.h" -#include "utils.h" - -#include "nm-test-utils-core.h" - -static void -test_get_ifcfg_name (const char *desc, - const char *path, - gboolean only_ifcfg, - const char *expected) -{ - const char *result; - - result = utils_get_ifcfg_name (path, only_ifcfg); - g_assert_cmpstr (result, ==, expected); -} - -static void -test_get_ifcfg_path (const char *desc, - const char *path, - const char *expected) -{ - char *result; - - result = utils_get_ifcfg_path (path); - g_assert_cmpstr (result, ==, expected); - g_free (result); -} - -static void -test_get_keys_path (const char *desc, - const char *path, - const char *expected) -{ - char *result; - - result = utils_get_keys_path (path); - g_assert_cmpstr (result, ==, expected); - g_free (result); -} - -static void -test_get_route_path (const char *desc, - const char *path, - const char *expected) -{ - char *result; - - result = utils_get_route_path (path); - g_assert_cmpstr (result, ==, expected); - g_free (result); -} - -static void -test_ignored (const char *desc, const char *path, gboolean expected_ignored) -{ - gboolean result; - - result = utils_should_ignore_file (path, FALSE); - g_assert (result == expected_ignored); -} - -static void -test_name (void) -{ - test_get_ifcfg_name ("get-ifcfg-name-bad", "/foo/bar/adfasdfadf", FALSE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-good", "/foo/bar/ifcfg-FooBar", FALSE, "FooBar"); - test_get_ifcfg_name ("get-ifcfg-name-keys", "/foo/bar/keys-BlahLbah", FALSE, "BlahLbah"); - test_get_ifcfg_name ("get-ifcfg-name-route", "/foo/bar/route-Lalalala", FALSE, "Lalalala"); - test_get_ifcfg_name ("get-ifcfg-name-only-ifcfg-route", "/foo/bar/route-Lalalala", TRUE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-only-ifcfg-keys", "/foo/bar/keys-Lalalala", TRUE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-no-path-ifcfg", "ifcfg-Lalalala", FALSE, "Lalalala"); - test_get_ifcfg_name ("get-ifcfg-name-no-path-keys", "keys-Lalalala", FALSE, "Lalalala"); - test_get_ifcfg_name ("get-ifcfg-name-no-path-route", "route-Lalalala", FALSE, "Lalalala"); - - test_get_ifcfg_name ("get-ifcfg-name-bad2-ifcfg", "/foo/bar/asdfasifcfg-Foobar", FALSE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-bad2-keys", "/foo/bar/asdfaskeys-Foobar", FALSE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-bad2-route", "/foo/bar/asdfasroute-Foobar", FALSE, NULL); -} - -static void -test_path (void) -{ - test_get_ifcfg_path ("ifcfg-path-bad", "/foo/bar/adfasdfasdf", NULL); - test_get_ifcfg_path ("ifcfg-path-from-keys-no-path", "keys-BlahBlah", "ifcfg-BlahBlah"); - test_get_ifcfg_path ("ifcfg-path-from-keys", "/foo/bar/keys-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); - test_get_ifcfg_path ("ifcfg-path-from-route", "/foo/bar/route-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); - - test_get_keys_path ("keys-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); - test_get_keys_path ("keys-path-from-ifcfg-no-path", "ifcfg-FooBar", "keys-FooBar"); - test_get_keys_path ("keys-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/keys-FooBar"); - test_get_keys_path ("keys-path-from-route", "/foo/bar/route-FooBar", "/foo/bar/keys-FooBar"); - - test_get_route_path ("route-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); - test_get_route_path ("route-path-from-ifcfg-no-path", "ifcfg-FooBar", "route-FooBar"); - test_get_route_path ("route-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/route-FooBar"); - test_get_route_path ("route-path-from-keys", "/foo/bar/keys-FooBar", "/foo/bar/route-FooBar"); -} - -static void -test_ignore (void) -{ - test_ignored ("ignored-ifcfg", "ifcfg-FooBar", FALSE); - test_ignored ("ignored-keys", "keys-FooBar", FALSE); - test_ignored ("ignored-route", "route-FooBar", FALSE); - test_ignored ("ignored-bak", "ifcfg-FooBar" BAK_TAG, TRUE); - test_ignored ("ignored-tilde", "ifcfg-FooBar" TILDE_TAG, TRUE); - test_ignored ("ignored-orig", "ifcfg-FooBar" ORIG_TAG, TRUE); - test_ignored ("ignored-rej", "ifcfg-FooBar" REJ_TAG, TRUE); - test_ignored ("ignored-rpmnew", "ifcfg-FooBar" RPMNEW_TAG, TRUE); - test_ignored ("ignored-augnew", "ifcfg-FooBar" AUGNEW_TAG, TRUE); - test_ignored ("ignored-augtmp", "ifcfg-FooBar" AUGTMP_TAG, TRUE); -} - -NMTST_DEFINE (); - -int main (int argc, char **argv) -{ - nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); - - /* The tests */ - g_test_add_func ("/settings/plugins/ifcfg-rh/name", test_name); - g_test_add_func ("/settings/plugins/ifcfg-rh/path", test_path); - g_test_add_func ("/settings/plugins/ifcfg-rh/ignore", test_ignore); - - return g_test_run (); -} - diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 9ed48beb..1a8439f6 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -50,15 +50,60 @@ #include "NetworkManagerUtils.h" -#include "common.h" -#include "reader.h" -#include "writer.h" -#include "utils.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h" #include "nm-test-utils-core.h" +#define TEST_SCRATCH_DIR_TMP TEST_SCRATCH_DIR"/network-scripts/tmp" + /*****************************************************************************/ +#define _svOpenFile(testfile) \ + ({ \ + shvarFile *_f; \ + GError *_error = NULL; \ + const char *_testfile = (testfile); \ + \ + g_assert (_testfile); \ + _f = svOpenFile (_testfile, &_error); \ + nmtst_assert_success (_f, _error); \ + _f; \ + }) + +#define _svGetValue_check(f, key, expected_value) \ + G_STMT_START { \ + const char *_val; \ + gs_free char *_to_free = NULL; \ + gs_free char *_val_string = NULL; \ + shvarFile *const _f = (f); \ + const char *const _key = (key); \ + \ + _val_string = svGetValueString (_f, _key); \ + _val = svGetValue (_f, _key, &_to_free); \ + g_assert_cmpstr (_val, ==, (expected_value)); \ + g_assert ( (!_val_string && (!_val || !_val[0])) \ + || ( _val_string && nm_streq0 (_val, _val_string))); \ + } G_STMT_END + +#define _writer_update_connection(connection, ifcfg_dir, filename) \ + G_STMT_START { \ + NMConnection *_connection = (connection); \ + const char *_ifcfg_dir = (ifcfg_dir); \ + const char *_filename = (filename); \ + GError *_error = NULL; \ + gboolean _success; \ + \ + g_assert (NM_IS_CONNECTION (connection)); \ + g_assert (_ifcfg_dir && _ifcfg_dir[0]); \ + g_assert (_filename && _filename[0]); \ + \ + _success = writer_update_connection (_connection, _ifcfg_dir, _filename, &_error); \ + nmtst_assert_success (_success, _error); \ + } G_STMT_END + static NMConnection * _connection_from_file (const char *filename, const char *network_file, @@ -273,6 +318,7 @@ test_read_basic (void) g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-minimal"); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, 0); g_assert (nm_setting_connection_get_autoconnect (s_con)); + g_assert_cmpint (nm_setting_connection_get_autoconnect_retries (s_con), ==, -1); /* UUID can't be tested if the ifcfg does not contain the UUID key, because * the UUID is generated on the full path of the ifcfg file, which can change @@ -326,6 +372,7 @@ test_read_miscellaneous_variables (void) g_assert (s_con); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, expected_timestamp); g_assert (nm_setting_connection_get_autoconnect (s_con)); + g_assert_cmpint (nm_setting_connection_get_autoconnect_retries (s_con), ==, 100); /* ===== WIRED SETTING ===== */ s_wired = nm_connection_get_setting_wired (connection); @@ -363,8 +410,8 @@ test_read_variables_corner_cases (void) /* ===== CONNECTION SETTING ===== */ s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); - g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "\""); - g_assert_cmpstr (nm_setting_connection_get_zone (s_con), ==, "'"); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-variables-corner-cases-1"); + g_assert_cmpstr (nm_setting_connection_get_zone (s_con), ==, NULL); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, 0); g_assert (nm_setting_connection_get_autoconnect (s_con)); @@ -449,7 +496,7 @@ test_read_unrecognized (void) /* ===== CONNECTION SETTING ===== */ s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); - g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "U Can't Touch This"); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-unrecognized"); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, expected_timestamp); g_object_unref (connection); @@ -1493,9 +1540,10 @@ test_read_wired_8021x_tls_secret_flags (gconstpointer test_data) static void test_read_write_802_1X_subj_matches (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSetting8021x *s_8021x; - char *written = NULL; g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*missing IEEE_8021X_CA_CERT*peap*"); @@ -1521,14 +1569,12 @@ test_read_write_802_1X_subj_matches (void) _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*missing IEEE_8021X_CA_CERT*peap*"); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); g_test_assert_expected_messages (); - unlink (written); - g_free (written); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -1547,9 +1593,6 @@ test_read_write_802_1X_subj_matches (void) g_assert_cmpint (nm_setting_802_1x_get_num_phase2_altsubject_matches (s_8021x), ==, 2); g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 0), ==, "x.yourdomain.tld"); g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 1), ==, "y.yourdomain.tld"); - - g_object_unref (connection); - g_object_unref (reread); } static void @@ -1741,14 +1784,12 @@ test_read_dns_options (void) static void test_clear_master (void) { + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; - NMConnection *connection; char *unmanaged = NULL; - char *testfile = NULL, *keyfile; - GError *error = NULL; - gboolean success; shvarFile *f; - char *val; /* 1. load the bridge slave connection from disk */ connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-bridge-component", @@ -1776,47 +1817,33 @@ test_clear_master (void) g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NULL); /* 4. update the connection on disk */ + _writer_update_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + testfile); keyfile = utils_get_keys_path (testfile); - success = writer_update_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/", - testfile, - keyfile, - &error); - g_assert_no_error (error); - g_assert (success); - unlink (keyfile); - g_free (keyfile); + g_assert (!g_file_test (keyfile, G_FILE_TEST_EXISTS)); /* 5. check that BRIDGE variable has been removed */ - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - val = svGetValue (f, "BRIDGE", FALSE); - g_assert (!val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "BRIDGE", NULL); svCloseFile (f); - - unlink (testfile); - g_free (testfile); - g_object_unref (connection); } static void test_write_dns_options (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; - char *uuid; NMIPAddress *addr; NMIPAddress *addr6; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -1824,14 +1851,12 @@ test_write_dns_options (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test DNS options", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -1882,7 +1907,6 @@ test_write_dns_options (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); /* RES_OPTIONS is copied to both IPv4 and IPv6 settings */ nm_setting_ip_config_clear_dns_options (s_ip4, TRUE); @@ -1894,10 +1918,6 @@ test_write_dns_options (void) nm_setting_ip_config_add_dns_option (s_ip6, "timeout:3"); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -2022,6 +2042,30 @@ test_read_wifi_open_ssid_hex (void) g_object_unref (connection); } +static void +test_read_wifi_open_ssid_hex_bad (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wireless; + GBytes *ssid; + const char *expected_ssid = "0x626cxx"; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-bad-hex", + NULL, TYPE_WIRELESS, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System 0x626cxx (test-wifi-open-ssid-bad-hex)"); + + s_wireless = nm_connection_get_setting_wireless (connection); + g_assert (s_wireless); + + ssid = nm_setting_wireless_get_ssid (s_wireless); + g_assert (ssid); + g_assert_cmpmem (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid), expected_ssid, strlen (expected_ssid)); +} + static void test_read_wifi_open_ssid_bad (gconstpointer data) { @@ -2386,6 +2430,16 @@ test_read_wifi_leap_secret_flags (gconstpointer test_data) g_object_unref (connection); } +static void +test_ifcfg_no_trailing_newline (void) +{ + shvarFile *sv; + + sv = _svOpenFile (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wifi-wpa-psk"); + _svGetValue_check (sv, "LAST_ENTRY", "no-newline"); + svCloseFile (sv); +} + static void test_read_wifi_wpa_psk (void) { @@ -2535,7 +2589,7 @@ test_read_wifi_wpa_psk_2 (void) s_wsec = nm_connection_get_setting_wireless_security (connection); g_assert (s_wsec); - g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "They're really saying I love you. >>`<< \\"); + g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "They're really saying I love you. >>`<< '"); g_object_unref (connection); } @@ -2574,12 +2628,10 @@ test_read_wifi_wpa_psk_unquoted (void) static void test_read_wifi_wpa_psk_unquoted2 (void) { - /* Ensure a quoted 64-character WPA passphrase will fail since passphrases - * must be between 8 and 63 ASCII characters inclusive per the WPA spec. - */ + gs_unref_object NMConnection *connection = NULL; - _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wifi-wpa-psk-unquoted2", - NULL, TYPE_WIRELESS, NULL); + connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wifi-wpa-psk-unquoted2", + NULL, TYPE_WIRELESS, NULL); } static void @@ -2932,6 +2984,81 @@ test_read_wired_wake_on_lan (void) g_object_unref (connection); } +static void +test_read_wired_auto_negotiate_off (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-wake-on-lan", + NULL, TYPE_ETHERNET, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + g_assert (!nm_setting_wired_get_auto_negotiate (s_wired)); + g_assert_cmpint (nm_setting_wired_get_speed (s_wired), ==, 100); + g_assert_cmpstr (nm_setting_wired_get_duplex (s_wired), ==, "full"); +} + +static void +test_read_wired_auto_negotiate_on (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-auto-negotiate-on", + NULL, TYPE_ETHERNET, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + g_assert (nm_setting_wired_get_auto_negotiate (s_wired)); + g_assert_cmpint (nm_setting_wired_get_speed (s_wired), ==, 0); + g_assert_cmpstr (nm_setting_wired_get_duplex (s_wired), ==, NULL); +} + +static void +test_read_wired_unknown_ethtool_opt (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-unknown-ethtool-opt", + NULL, TYPE_ETHERNET, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + g_assert (!nm_setting_wired_get_auto_negotiate (s_wired)); + g_assert (!nm_setting_wired_get_speed (s_wired)); + g_assert (!nm_setting_wired_get_duplex (s_wired)); + + g_assert_cmpint (nm_setting_wired_get_wake_on_lan (s_wired), + ==, + NM_SETTING_WIRED_WAKE_ON_LAN_ARP | + NM_SETTING_WIRED_WAKE_ON_LAN_PHY | + NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC); + g_assert_cmpstr (nm_setting_wired_get_wake_on_lan_password (s_wired), + ==, + "00:11:22:33:44:55"); +} + static void test_read_wifi_hidden (void) { @@ -2956,11 +3083,11 @@ test_read_wifi_hidden (void) static void test_write_wifi_hidden (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; shvarFile *f; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; @@ -2971,13 +3098,11 @@ test_write_wifi_hidden (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write WiFi Hidden", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -2999,33 +3124,21 @@ test_write_wifi_hidden (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "SSID_HIDDEN", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "yes"); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "SSID_HIDDEN", "yes"); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_read_wifi_mac_random (gconstpointer user_data) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; + gs_free char *path = NULL; NMSettingWireless *s_wifi; - char *path; const char *name; gpointer value_p; NMSettingMacRandomization value; @@ -3035,23 +3148,21 @@ test_read_wifi_mac_random (gconstpointer user_data) path = g_strdup_printf (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-mac-random-%s", name); connection = _connection_from_file (path, NULL, TYPE_WIRELESS, NULL); - g_free (path); s_wifi = nm_connection_get_setting_wireless (connection); g_assert (s_wifi); g_assert_cmpint (nm_setting_wireless_get_mac_address_randomization (s_wifi), ==, value); - - g_object_unref (connection); } static void test_write_wifi_mac_random (gconstpointer user_data) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; + char *val; shvarFile *f; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; @@ -3070,14 +3181,12 @@ test_write_wifi_mac_random (gconstpointer user_data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); val = g_strdup_printf ("Test Write WiFi MAC %s", name); g_object_set (s_con, NM_SETTING_CONNECTION_ID, val, - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); g_free (val); /* Wifi setting */ @@ -3098,35 +3207,25 @@ test_write_wifi_mac_random (gconstpointer user_data) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "MAC_ADDRESS_RANDOMIZATION", FALSE); - g_assert_cmpstr (val, ==, write_expected); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "MAC_ADDRESS_RANDOMIZATION", write_expected); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_wake_on_lan (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingWiredWakeOnLan wol; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; + char *val; shvarFile *f; connection = nm_simple_connection_new (); @@ -3135,13 +3234,11 @@ test_write_wired_wake_on_lan (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Wake-on-LAN", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3162,12 +3259,8 @@ test_write_wired_wake_on_lan (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that the key was written. */ - val = svGetValue (f, "ETHTOOL_OPTS", FALSE); + f = _svOpenFile (testfile); + val = svGetValueString (f, "ETHTOOL_OPTS"); g_assert (val); g_assert (strstr (val, "wol")); g_assert (strstr (val, "sopass 00:00:00:11:22:33")); @@ -3175,13 +3268,78 @@ test_write_wired_wake_on_lan (void) svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); +} - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); +static void +test_write_wired_auto_negotiate_off (void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingWired *s_wired; + char *val; + shvarFile *f; + + connection = nmtst_create_minimal_connection ("Test Write Wired Auto-Negotiate", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); + s_wired = nm_connection_get_setting_wired (connection); + g_object_set (s_wired, + NM_SETTING_WIRED_AUTO_NEGOTIATE, FALSE, + NM_SETTING_WIRED_DUPLEX, "half", + NM_SETTING_WIRED_SPEED, 10, + NULL); + + _writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile); + + f = _svOpenFile (testfile); + val = svGetValueString (f, "ETHTOOL_OPTS"); + g_assert (val); + g_assert (strstr (val, "autoneg off")); + g_assert (strstr (val, "speed 10")); + g_assert (strstr (val, "duplex half")); + g_free (val); + svCloseFile (f); + + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); + + nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); +} + +static void +test_write_wired_auto_negotiate_on (void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingWired *s_wired; + char *val; + shvarFile *f; + + connection = nmtst_create_minimal_connection ("Test Write Wired Auto-Negotiate", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); + s_wired = nm_connection_get_setting_wired (connection); + g_object_set (s_wired, + NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, + NULL); + + _writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile); + + f = _svOpenFile (testfile); + val = svGetValueString (f, "ETHTOOL_OPTS"); + g_assert (val); + g_assert (strstr (val, "autoneg on")); + g_assert (!strstr (val, "speed")); + g_assert (!strstr (val, "duplex")); + g_free (val); + svCloseFile (f); + + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); + + nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); } static void @@ -3208,11 +3366,11 @@ test_read_wifi_band_a (void) static void test_write_wifi_band_a (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; shvarFile *f; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; @@ -3223,13 +3381,11 @@ test_write_wifi_band_a (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write WiFi Band A", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -3251,25 +3407,13 @@ test_write_wifi_band_a (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "BAND", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "a"); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "BAND", "a"); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -3510,19 +3654,18 @@ test_read_wifi_wep_agent_keys (void) static void test_write_wired_static (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *route6file = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4, *reread_s_ip4; NMSettingIPConfig *s_ip6, *reread_s_ip6; - char *uuid; NMIPAddress *addr; NMIPAddress *addr6; NMIPRoute *route6; GError *error = NULL; - char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -3530,14 +3673,13 @@ test_write_wired_static (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, 1, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3627,9 +3769,9 @@ test_write_wired_static (void) _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", &testfile); + route6file = utils_get_route6_path (testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); /* FIXME: currently DNS domains from IPv6 setting are stored in 'DOMAIN' key in ifcfg-file * However after re-reading they are dropped into IPv4 setting. @@ -3645,28 +3787,21 @@ test_write_wired_static (void) g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip4), ==, 204); g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip6), ==, 206); - nmtst_assert_connection_equals (connection, FALSE, reread, FALSE); - - route6file = utils_get_route6_path (testfile); - unlink (route6file); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); - g_free (testfile); - g_free (route6file); - g_object_unref (connection); - g_object_unref (reread); + nmtst_assert_connection_equals (connection, FALSE, reread, FALSE); } static void test_write_wired_dhcp (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -3674,14 +3809,12 @@ test_write_wired_dhcp (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired DHCP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3715,46 +3848,38 @@ test_write_wired_dhcp (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_dhcp_plus_ip (void) { - NMConnection *connection, *reread; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip", NULL, TYPE_ETHERNET, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); } static void test_read_write_wired_dhcp_send_hostname (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; const char * dhcp_hostname = "kamil-patka"; - char *written = NULL; connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-send-hostname", NULL, TYPE_ETHERNET, NULL); @@ -3766,7 +3891,7 @@ test_read_write_wired_dhcp_send_hostname (void) g_assert (s_ip6); g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == TRUE); g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, "svata-pulec"); - g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, "svata-pulec"); + g_assert (!nm_setting_ip_config_get_dhcp_hostname (s_ip6)); /* Set dhcp-send-hostname=false dhcp-hostname="kamil-patka" and write the connection. */ g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, FALSE, NULL); @@ -3775,11 +3900,9 @@ test_read_write_wired_dhcp_send_hostname (void) _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -3791,24 +3914,35 @@ test_read_write_wired_dhcp_send_hostname (void) g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == FALSE); g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, dhcp_hostname); g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, dhcp_hostname); +} - g_object_unref (connection); - g_object_unref (reread); +static void +test_read_wired_dhcpv6_hostname_fallback (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig *s_ip6; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback", + NULL, TYPE_ETHERNET, NULL); + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + g_assert (s_ip6); + g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip6) == TRUE); + g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, "fully.qualified.domain"); } static void test_write_wired_static_ip6_only (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr6; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -3816,14 +3950,12 @@ test_write_wired_static_ip6_only (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static IP6 Only", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3863,13 +3995,8 @@ test_write_wired_static_ip6_only (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } /* Test writing an IPv6 config with varying gateway address. @@ -3883,19 +4010,19 @@ test_write_wired_static_ip6_only (void) static void test_write_wired_static_ip6_only_gw (gconstpointer user_data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr6; GError *error = NULL; - char *testfile = NULL; char *id = NULL; - char *written_ifcfg_gateway; + gs_free char *written_ifcfg_gateway = NULL; const char *gateway6 = user_data; + shvarFile *ifcfg; connection = nm_simple_connection_new (); @@ -3903,15 +4030,13 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); id = g_strdup_printf ("Test Write Wired Static IP6 Only With Gateway %s", gateway6 ? gateway6 : "NULL"); g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); g_free (id); /* Wired setting */ @@ -3956,17 +4081,9 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - { - /* re-read the file to check that what key was written. */ - shvarFile *ifcfg = svOpenFile (testfile, &error); - - g_assert_no_error (error); - g_assert (ifcfg); - written_ifcfg_gateway = svGetValue (ifcfg, "IPV6_DEFAULTGW", FALSE); - svCloseFile (ifcfg); - } - - unlink (testfile); + ifcfg = _svOpenFile (testfile); + written_ifcfg_gateway = svGetValueString (ifcfg, "IPV6_DEFAULTGW"); + svCloseFile (ifcfg); /* access the gateway from the loaded connection. */ s_ip6 = nm_connection_get_setting_ip6_config (reread); @@ -3983,23 +4100,19 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip6), ==, gateway6); g_assert_cmpstr (written_ifcfg_gateway, ==, gateway6); } - - g_free (testfile); - g_free (written_ifcfg_gateway); - g_object_unref (connection); - g_object_unref (reread); } static void test_read_write_static_routes_legacy (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *routefile = NULL; + gs_free char *route6file = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *testfile = NULL; - char *routefile = NULL; - char *route6file = NULL; const char *tmp; connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-static-routes-legacy", @@ -4035,40 +4148,31 @@ test_read_write_static_routes_legacy (void) * source tree and for 'make distcheck'. */ _writer_new_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/tmp", + TEST_SCRATCH_DIR_TMP, &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); routefile = utils_get_route_path (testfile); - unlink (routefile); route6file = utils_get_route6_path (testfile); - unlink (route6file); + g_assert (!g_file_test (route6file, G_FILE_TEST_EXISTS)); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (routefile); - g_free (route6file); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_static_routes (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *routefile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr; NMIPRoute *route; GError *error = NULL; - char *testfile = NULL; - char *routefile = NULL; connection = nm_simple_connection_new (); @@ -4076,14 +4180,12 @@ test_write_wired_static_routes (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static Routes", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -4146,34 +4248,26 @@ test_write_wired_static_routes (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); routefile = utils_get_route_path (testfile); - unlink (routefile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (routefile); - g_object_unref (connection); - g_object_unref (reread); -} +} static void test_write_wired_dhcp_8021x_peap_mschapv2 (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; NMSetting8021x *s_8021x; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; connection = nm_simple_connection_new (); @@ -4181,14 +4275,12 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired DHCP 802.1x PEAP MSCHAPv2", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -4238,34 +4330,26 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); - - keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); + keyfile = utils_get_keys_path (testfile); } static void test_write_wired_8021x_tls (gconstpointer test_data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; NMSetting8021x *s_8021x; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; const char *pw; char *tmp; @@ -4278,36 +4362,29 @@ test_write_wired_8021x_tls (gconstpointer test_data) flags = GPOINTER_TO_INT (flags_p); connection = nm_simple_connection_new (); - g_assert (connection != NULL); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired 802.1x TLS Blobs", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, @@ -4316,7 +4393,6 @@ test_write_wired_8021x_tls (gconstpointer test_data) /* 802.1x setting */ s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - g_assert (s_8021x); nm_connection_add_setting (connection, NM_SETTING (s_8021x)); g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL); @@ -4365,9 +4441,9 @@ test_write_wired_8021x_tls (gconstpointer test_data) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); + keyfile = utils_get_keys_path (testfile); - unlink (keyfile); + nmtst_file_unlink_if_exists (keyfile); /* Ensure the reread connection's certificates and private key are paths; no * matter what scheme was used in the original connection they will be read @@ -4411,21 +4487,16 @@ test_write_wired_8021x_tls (gconstpointer test_data) /* Clean up created certs and keys */ tmp = utils_cert_path (testfile, "ca-cert.der"); - unlink (tmp); + nmtst_file_unlink_if_exists (tmp); g_free (tmp); tmp = utils_cert_path (testfile, "client-cert.der"); - unlink (tmp); + nmtst_file_unlink_if_exists (tmp); g_free (tmp); tmp = utils_cert_path (testfile, "private-key.pem"); - unlink (tmp); + nmtst_file_unlink_if_exists (tmp); g_free (tmp); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } #define TEST_SCRATCH_ALIAS_BASE TEST_SCRATCH_DIR "/network-scripts/ifcfg-alias0" @@ -4433,45 +4504,43 @@ test_write_wired_8021x_tls (gconstpointer test_data) static void test_write_wired_aliases (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *uuid; int num_addresses = 4; const char *ip[] = { "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" }; const char *label[] = { NULL, "alias0:2", NULL, "alias0:3" }; NMIPAddress *addr; GError *error = NULL; - char *testfile = NULL; shvarFile *ifcfg; int i, j; + nmtst_file_unlink_if_exists (TEST_SCRATCH_ALIAS_BASE ":2"); + nmtst_file_unlink_if_exists (TEST_SCRATCH_ALIAS_BASE ":3"); + nmtst_file_unlink_if_exists (TEST_SCRATCH_ALIAS_BASE ":5"); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "alias0", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -4493,15 +4562,15 @@ test_write_wired_aliases (void) /* Create some pre-existing alias files, to make sure they get overwritten / deleted. */ ifcfg = svCreateFile (TEST_SCRATCH_ALIAS_BASE ":2"); - svSetValue (ifcfg, "DEVICE", "alias0:2", FALSE); - svSetValue (ifcfg, "IPADDR", "192.168.1.2", FALSE); + svSetValueString (ifcfg, "DEVICE", "alias0:2"); + svSetValueString (ifcfg, "IPADDR", "192.168.1.2"); svWriteFile (ifcfg, 0644, NULL); svCloseFile (ifcfg); g_assert (g_file_test (TEST_SCRATCH_ALIAS_BASE ":2", G_FILE_TEST_EXISTS)); ifcfg = svCreateFile (TEST_SCRATCH_ALIAS_BASE ":5"); - svSetValue (ifcfg, "DEVICE", "alias0:5", FALSE); - svSetValue (ifcfg, "IPADDR", "192.168.1.5", FALSE); + svSetValueString (ifcfg, "DEVICE", "alias0:5"); + svSetValueString (ifcfg, "IPADDR", "192.168.1.5"); svWriteFile (ifcfg, 0644, NULL); svCloseFile (ifcfg); g_assert (g_file_test (TEST_SCRATCH_ALIAS_BASE ":5", G_FILE_TEST_EXISTS)); @@ -4516,9 +4585,8 @@ test_write_wired_aliases (void) g_assert (!g_file_test (TEST_SCRATCH_ALIAS_BASE ":5", G_FILE_TEST_EXISTS)); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); - unlink (TEST_SCRATCH_ALIAS_BASE ":2"); - unlink (TEST_SCRATCH_ALIAS_BASE ":3"); + nmtst_file_unlink (TEST_SCRATCH_ALIAS_BASE ":2"); + nmtst_file_unlink (TEST_SCRATCH_ALIAS_BASE ":3"); /* nm_connection_compare() is not guaranteed to succeed, because the * aliases get read back in essentially random order. So just @@ -4555,20 +4623,17 @@ test_write_wired_aliases (void) /* Gateway */ g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1"); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_gateway (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *uuid, *testfile = NULL, *val; GError *error = NULL; shvarFile *f; NMIPAddress *addr; @@ -4579,13 +4644,11 @@ test_write_gateway (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Static Addresses Gateway", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -4617,77 +4680,37 @@ test_write_gateway (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that the keys was written as IPADDR, GATEWAY and IPADDR1, GATEWAY1 */ - val = svGetValue (f, "IPADDR", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "1.1.1.3"); - g_free (val); - - val = svGetValue (f, "IPADDR1", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "2.2.2.5"); - g_free (val); - - val = svGetValue (f, "IPADDR0", FALSE); - g_assert (val == NULL); - - val = svGetValue (f, "PREFIX", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "24"); - g_free (val); - - val = svGetValue (f, "PREFIX1", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "24"); - g_free (val); - - val = svGetValue (f, "PREFIX0", FALSE); - g_assert (val == NULL); - - val = svGetValue (f, "GATEWAY", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "1.1.1.254"); - g_free (val); - - val = svGetValue (f, "GATEWAY0", FALSE); - g_assert (val == NULL); - - val = svGetValue (f, "GATEWAY1", FALSE); - g_assert (val == NULL); - + f = _svOpenFile (testfile); + _svGetValue_check (f, "IPADDR", "1.1.1.3"); + _svGetValue_check (f, "IPADDR1", "2.2.2.5"); + _svGetValue_check (f, "IPADDR0", NULL); + _svGetValue_check (f, "PREFIX", "24"); + _svGetValue_check (f, "PREFIX1", "24"); + _svGetValue_check (f, "PREFIX0", NULL); + _svGetValue_check (f, "GATEWAY", "1.1.1.254"); + _svGetValue_check (f, "GATEWAY0", NULL); + _svGetValue_check (f, "GATEWAY1", NULL); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_open (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - GError *error = NULL; - char *testfile = NULL; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; shvarFile *ifcfg; - char *tmp; connection = nm_simple_connection_new (); @@ -4695,14 +4718,12 @@ test_write_wifi_open (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Open", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -4745,39 +4766,23 @@ test_write_wifi_open (void) reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - /* Now make sure that the ESSID item isn't double-quoted (rh #606518) */ - ifcfg = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (ifcfg != NULL); - - tmp = svGetValue (ifcfg, "ESSID", TRUE); - g_assert (tmp); - - g_assert (strncmp (tmp, "\"\"", 2) != 0); - - g_free (tmp); + ifcfg = _svOpenFile (testfile); + _svGetValue_check (ifcfg, "ESSID", "Test SSID"); svCloseFile (ifcfg); - unlink (testfile); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_open_hex_ssid (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; GBytes *ssid; const unsigned char ssid_data[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd }; @@ -4787,14 +4792,12 @@ test_write_wifi_open_hex_ssid (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Open Hex SSID", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -4831,28 +4834,22 @@ test_write_wifi_open_hex_ssid (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -4863,14 +4860,12 @@ test_write_wifi_wep (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -4921,36 +4916,28 @@ test_write_wifi_wep (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_adhoc (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -4962,14 +4949,12 @@ test_write_wifi_wep_adhoc (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP AdHoc", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5024,35 +5009,27 @@ test_write_wifi_wep_adhoc (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_passphrase (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -5063,14 +5040,12 @@ test_write_wifi_wep_passphrase (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP Passphrase", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5119,35 +5094,27 @@ test_write_wifi_wep_passphrase (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_40_ascii (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah40"; struct stat statbuf; @@ -5158,14 +5125,12 @@ test_write_wifi_wep_40_ascii (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP 40 ASCII", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5216,35 +5181,27 @@ test_write_wifi_wep_40_ascii (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_104_ascii (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah104"; struct stat statbuf; @@ -5255,14 +5212,12 @@ test_write_wifi_wep_104_ascii (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP 104 ASCII", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5313,36 +5268,27 @@ test_write_wifi_wep_104_ascii (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_leap (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -5353,14 +5299,12 @@ test_write_wifi_leap (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi LEAP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5408,35 +5352,27 @@ test_write_wifi_leap (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_leap_secret_flags (gconstpointer data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; NMSettingSecretFlags flags = GPOINTER_TO_UINT (data); @@ -5446,20 +5382,16 @@ test_write_wifi_leap_secret_flags (gconstpointer data) /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi LEAP Secret Flags", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -5471,7 +5403,6 @@ test_write_wifi_leap_secret_flags (gconstpointer data) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -5484,13 +5415,11 @@ test_write_wifi_leap_secret_flags (gconstpointer data) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -5505,7 +5434,6 @@ test_write_wifi_leap_secret_flags (gconstpointer data) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); /* No key should be written out since the secret is not system owned */ keyfile = utils_get_keys_path (testfile); @@ -5516,26 +5444,20 @@ test_write_wifi_leap_secret_flags (gconstpointer data) */ g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, NULL, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_psk (gconstpointer test_data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct { @@ -5553,14 +5475,12 @@ test_write_wifi_wpa_psk (gconstpointer test_data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, args.name, - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5621,33 +5541,25 @@ test_write_wifi_wpa_psk (gconstpointer test_data) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_psk_adhoc (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; NMIPAddress *addr; @@ -5658,14 +5570,12 @@ test_write_wifi_wpa_psk_adhoc (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA PSK", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5727,35 +5637,27 @@ test_write_wifi_wpa_psk_adhoc (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_eap_tls (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -5765,14 +5667,12 @@ test_write_wifi_wpa_eap_tls (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TLS", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5848,35 +5748,27 @@ test_write_wifi_wpa_eap_tls (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_eap_ttls_tls (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -5886,14 +5778,12 @@ test_write_wifi_wpa_eap_ttls_tls (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TTLS (TLS)", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5985,35 +5875,27 @@ test_write_wifi_wpa_eap_ttls_tls (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_eap_ttls_mschapv2 (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -6023,14 +5905,12 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TTLS (MSCHAPv2)", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -6099,34 +5979,24 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); - - keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); + keyfile = utils_get_keys_path (testfile); } static void test_write_wifi_wpa_then_open (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - gboolean success; - GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -6135,25 +6005,20 @@ test_write_wifi_wpa_then_open (void) */ connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "random wifi connection", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -6167,7 +6032,6 @@ test_write_wifi_wpa_then_open (void) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6185,16 +6049,12 @@ test_write_wifi_wpa_then_open (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, @@ -6218,51 +6078,30 @@ test_write_wifi_wpa_then_open (void) nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); /* Write it back out */ + _writer_update_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + testfile); keyfile = utils_get_keys_path (testfile); - success = writer_update_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/", - testfile, - keyfile, - &error); - g_assert_no_error (error); - g_assert (success); - - unlink (keyfile); - g_free (keyfile); - keyfile = NULL; + g_assert (!g_file_test (keyfile, G_FILE_TEST_EXISTS)); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); - - /* No keyfile since it's an open connection this time */ - keyfile = utils_get_keys_path (testfile); - g_assert (g_file_test (keyfile, G_FILE_TEST_EXISTS) == FALSE); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - unlink (testfile); - g_free (testfile); - g_free (keyfile); - g_object_unref (reread); - - g_object_unref (connection); } static void test_write_wifi_wpa_then_wep_with_perms (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; - GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; char **perms; const char *ssid_data = "SomeSSID"; @@ -6276,25 +6115,21 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); perms = g_strsplit ("user:superman:", ",", -1); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "random wifi connection 2", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_PERMISSIONS, perms, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); g_strfreev (perms); g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 1); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -6308,7 +6143,6 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6326,14 +6160,12 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6357,7 +6189,6 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* Now change the connection to WEP and recheck */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6366,17 +6197,9 @@ test_write_wifi_wpa_then_wep_with_perms (void) nm_setting_wireless_security_set_wep_key (s_wsec, 0, "abraka dabra"); /* Write it back out */ - keyfile = utils_get_keys_path (testfile); - success = writer_update_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/", - testfile, - keyfile, - &error); - g_assert_no_error (error); - g_assert (success); - - g_free (keyfile); - keyfile = NULL; + _writer_update_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); @@ -6387,55 +6210,38 @@ test_write_wifi_wpa_then_wep_with_perms (void) g_assert (success); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); - unlink (testfile); - g_free (keyfile); - - g_free (testfile); - g_object_unref (reread); - - g_object_unref (connection); } static void test_write_wifi_dynamic_wep_leap (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; shvarFile *ifcfg; - char *tmp; connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Dynamic WEP LEAP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -6449,14 +6255,12 @@ test_write_wifi_dynamic_wep_leap (void) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL); /* Wireless security setting */ s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - g_assert (s_8021x); nm_connection_add_setting (connection, NM_SETTING (s_8021x)); nm_setting_802_1x_add_eap_method (s_8021x, "leap"); @@ -6468,13 +6272,11 @@ test_write_wifi_dynamic_wep_leap (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6491,7 +6293,6 @@ test_write_wifi_dynamic_wep_leap (void) reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -6499,38 +6300,23 @@ test_write_wifi_dynamic_wep_leap (void) * did not get written. Check first that the auth alg is not set to "LEAP" * and next that the only IEEE 802.1x EAP method is "LEAP". */ - ifcfg = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (ifcfg); - tmp = svGetValue (ifcfg, "SECURITYMODE", FALSE); - g_assert_cmpstr (tmp, ==, NULL); - g_free (tmp); - - tmp = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE); - g_assert_cmpstr (tmp, ==, "LEAP"); - g_free (tmp); - + ifcfg = _svOpenFile (testfile); + _svGetValue_check (ifcfg, "SECURITYMODE", NULL); + _svGetValue_check (ifcfg, "IEEE_8021X_EAP_METHODS", "LEAP"); svCloseFile (ifcfg); - unlink (testfile); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_qeth_dhcp (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; char **subchans; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -6538,14 +6324,12 @@ test_write_wired_qeth_dhcp (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired qeth Static", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -6587,50 +6371,37 @@ test_write_wired_qeth_dhcp (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_ctc_dhcp (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; char **subchans; - GError *error = NULL; - char *testfile = NULL; shvarFile *ifcfg; - char *tmp; connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired ctc Static", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); subchans = g_strsplit ("0.0.600,0.0.601", ",", -1); @@ -6643,13 +6414,11 @@ test_write_wired_ctc_dhcp (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6664,43 +6433,30 @@ test_write_wired_ctc_dhcp (void) &testfile); /* Ensure the CTCPROT item gets written out as it's own option */ - ifcfg = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (ifcfg); + ifcfg = _svOpenFile (testfile); - tmp = svGetValue (ifcfg, "CTCPROT", TRUE); - g_assert (tmp); - g_assert_cmpstr (tmp, ==, "0"); - g_free (tmp); + _svGetValue_check (ifcfg, "CTCPROT", "0"); /* And that it's not in the generic OPTIONS string */ - tmp = svGetValue (ifcfg, "OPTIONS", TRUE); - g_assert (tmp == NULL); - g_free (tmp); + _svGetValue_check (ifcfg, "OPTIONS", NULL); svCloseFile (ifcfg); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_permissions (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -6708,14 +6464,12 @@ test_write_permissions (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Permissions", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); nm_setting_connection_add_permission (s_con, "user", "blahblah", NULL); nm_setting_connection_add_permission (s_con, "user", "foobar", NULL); @@ -6749,55 +6503,44 @@ test_write_permissions (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_agent_keys (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; const char *str_ssid = "foobarbaz"; GBytes *ssid; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection != NULL); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP Agent Owned", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6807,7 +6550,6 @@ test_write_wifi_wep_agent_keys (void) /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (str_ssid, strlen (str_ssid)); @@ -6819,7 +6561,6 @@ test_write_wifi_wep_agent_keys (void) /* Wifi security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6836,7 +6577,6 @@ test_write_wifi_wep_agent_keys (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); /* Remove the WEP key from the original, because it should not have been * written out to disk as it was agent-owned. The new connection should @@ -6849,10 +6589,6 @@ test_write_wifi_wep_agent_keys (void) NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -6864,7 +6600,6 @@ test_write_wired_pppoe (void) NMSettingIPConfig *s_ip4; NMSettingPppoe *s_pppoe; NMSettingPpp *s_ppp; - char *uuid; GError *error = NULL; connection = nm_simple_connection_new (); @@ -6873,14 +6608,12 @@ test_write_wired_pppoe (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired PPPoE", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -6925,7 +6658,6 @@ test_write_vpn (void) NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; NMSettingVpn *s_vpn; - char *uuid; GError *error = NULL; connection = nm_simple_connection_new (); @@ -6934,14 +6666,12 @@ test_write_vpn (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write VPN", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_VPN_SETTING_NAME, NULL); - g_free (uuid); /* VPN setting */ s_vpn = (NMSettingVpn *) nm_setting_vpn_new (); @@ -6983,7 +6713,6 @@ test_write_mobile_broadband (gconstpointer data) NMSettingCdma *s_cdma; NMSettingPpp *s_ppp; NMSettingSerial *s_serial; - char *uuid; GError *error = NULL; gboolean gsm = GPOINTER_TO_UINT (data); @@ -6993,14 +6722,12 @@ test_write_mobile_broadband (gconstpointer data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, gsm ? "Test Write GSM" : "Test Write CDMA", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, gsm ? NM_SETTING_GSM_SETTING_NAME : NM_SETTING_CDMA_SETTING_NAME, NULL); - g_free (uuid); if (gsm) { /* GSM setting */ @@ -7085,39 +6812,34 @@ test_read_bridge_main (void) static void test_write_bridge_main (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingBridge *s_bridge; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr; static const char *mac = "31:33:33:37:be:cd"; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Main", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_INTERFACE_NAME, "br0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, NULL); - g_free (uuid); /* bridge setting */ s_bridge = (NMSettingBridge *) nm_setting_bridge_new (); - g_assert (s_bridge); nm_connection_add_setting (connection, NM_SETTING (s_bridge)); g_object_set (s_bridge, @@ -7126,7 +6848,6 @@ test_write_bridge_main (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -7142,13 +6863,14 @@ test_write_bridge_main (void) /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); + nmtst_assert_connection_verifies_without_normalization (connection); _writer_new_connection (connection, @@ -7156,13 +6878,8 @@ test_write_bridge_main (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_BRIDGE, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7192,38 +6909,33 @@ test_read_bridge_component (void) static void test_write_bridge_component (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSetting *s_port; static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Component", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "br0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); g_object_set (s_wired, @@ -7246,13 +6958,8 @@ test_write_bridge_component (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7485,78 +7192,64 @@ test_read_vlan_flags_2 (void) static void test_write_vlan (void) { - NMConnection *connection; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; connection = _connection_from_file (TEST_IFCFG_VLAN_INTERFACE, NULL, TYPE_VLAN, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); - - unlink (written); - g_free (written); - - g_object_unref (connection); + &testfile); } static void test_write_vlan_flags (void) { - NMConnection *connection, *reread; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-2", NULL, TYPE_VLAN, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); - - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); + &testfile); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); } static void test_write_vlan_only_vlanid (void) { - NMConnection *connection, *reread; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; connection = _connection_from_file (TEST_IFCFG_VLAN_ONLY_VLANID, NULL, TYPE_VLAN, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); } static void test_write_vlan_reorder_hdr (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingVlan *s_vlan; NMSettingWired *s_wired; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7564,14 +7257,12 @@ test_write_vlan_reorder_hdr (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write VLAN reorder_hdr", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_VLAN_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -7592,51 +7283,40 @@ test_write_vlan_reorder_hdr (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); - g_free (testfile); } static void test_write_ethernet_missing_ipv6 (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Ethernet Without IPv6 Setting", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, @@ -7658,13 +7338,8 @@ test_write_ethernet_missing_ipv6 (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7701,17 +7376,16 @@ test_read_bond_main (void) static void test_write_bond_main (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingBond *s_bond; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; NMSettingWired *s_wired; - char *uuid; NMIPAddress *addr; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7719,15 +7393,13 @@ test_write_bond_main (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Main", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_INTERFACE_NAME, "bond0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_BOND_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -7760,6 +7432,8 @@ test_write_bond_main (void) NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); + nmtst_assert_connection_verifies_without_normalization (connection); _writer_new_connection (connection, @@ -7767,13 +7441,8 @@ test_write_bond_main (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_BOND, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7799,14 +7468,13 @@ test_read_bond_slave (void) static void test_write_bond_slave (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7814,16 +7482,14 @@ test_write_bond_slave (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Slave", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "bond0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -7841,13 +7507,8 @@ test_write_bond_slave (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7885,18 +7546,17 @@ test_read_infiniband (void) static void test_write_infiniband (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingInfiniband *s_infiniband; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; guint32 mtu = 65520; - char *uuid; NMIPAddress *addr; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7904,14 +7564,12 @@ test_write_infiniband (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write InfiniBand", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_INFINIBAND_SETTING_NAME, NULL); - g_free (uuid); /* InfiniBand setting */ s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new (); @@ -7953,19 +7611,14 @@ test_write_infiniband (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_INFINIBAND, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_read_bond_slave_ib (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-bond-slave-ib", @@ -7975,22 +7628,18 @@ test_read_bond_slave_ib (void) g_assert (s_con); g_assert_cmpstr (nm_setting_connection_get_master (s_con), ==, "bond0"); - g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NM_SETTING_BOND_SETTING_NAME); - - g_object_unref (connection); } static void test_write_bond_slave_ib (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingInfiniband *s_infiniband; static const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7998,16 +7647,14 @@ test_write_bond_slave_ib (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Slave InfiniBand", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "bond0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME, NULL); - g_free (uuid); /* InfiniBand setting */ s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new (); @@ -8026,13 +7673,8 @@ test_write_bond_slave_ib (void) &testfile); reread = _connection_from_file (testfile, NULL, NULL, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -8122,14 +7764,15 @@ test_read_dcb_basic (void) static void test_write_dcb_basic (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingDcb *s_dcb; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; guint i; - char *uuid, *testfile; const guint group_ids[8] = { 4, 0xF, 6, 0xF, 1, 7, 3, 0xF }; const guint group_bandwidths[8] = { 10, 20, 15, 10, 2, 3, 35, 5 }; const guint bandwidths[8] = { 10, 20, 30, 40, 50, 10, 0, 25 }; @@ -8141,14 +7784,12 @@ test_write_dcb_basic (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, "dcb-test", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME, "eth0", NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -8194,19 +7835,14 @@ test_write_dcb_basic (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); - g_free (testfile); } static void test_read_dcb_default_app_priorities (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingDcb *s_dcb; connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-default-app-priorities", @@ -8223,8 +7859,6 @@ test_read_dcb_default_app_priorities (void) g_assert_cmpint (nm_setting_dcb_get_app_fip_flags (s_dcb), ==, NM_SETTING_DCB_FLAG_ENABLE); g_assert_cmpint (nm_setting_dcb_get_app_fip_priority (s_dcb), ==, -1); - - g_object_unref (connection); } static void @@ -8335,49 +7969,45 @@ test_read_dcb_pgpct_not_100 (void) static void test_read_fcoe_mode (gconstpointer user_data) { + gs_unref_object NMConnection *connection = NULL; + gs_free char *file = NULL; const char *expected_mode = user_data; - NMConnection *connection; NMSettingDcb *s_dcb; - char *file; file = g_strdup_printf (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-fcoe-%s", expected_mode); connection = _connection_from_file (file, NULL, TYPE_ETHERNET, NULL); - g_free (file); s_dcb = nm_connection_get_setting_dcb (connection); g_assert (s_dcb); g_assert_cmpint (nm_setting_dcb_get_app_fcoe_flags (s_dcb), ==, NM_SETTING_DCB_FLAG_ENABLE); g_assert_cmpstr (nm_setting_dcb_get_app_fcoe_mode (s_dcb), ==, expected_mode); - - g_object_unref (connection); } static void test_write_fcoe_mode (gconstpointer user_data) { + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; const char *expected_mode = user_data; - NMConnection *connection, *reread; - GError *error = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingDcb *s_dcb; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid, *testfile; + shvarFile *ifcfg; connection = nm_simple_connection_new (); s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, "fcoe-test", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME, "eth0", NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -8407,26 +8037,13 @@ test_write_fcoe_mode (gconstpointer user_data) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - { - shvarFile *ifcfg = svOpenFile (testfile, &error); - char *written_mode; - - g_assert_no_error (error); - g_assert (ifcfg); - written_mode = svGetValue (ifcfg, "DCB_APP_FCOE_MODE", FALSE); - svCloseFile (ifcfg); - g_assert_cmpstr (written_mode, ==, expected_mode); - g_free (written_mode); - } + ifcfg = _svOpenFile (testfile); + _svGetValue_check (ifcfg, "DCB_APP_FCOE_MODE", expected_mode); + svCloseFile (ifcfg); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); - g_free (testfile); } static void @@ -8481,16 +8098,15 @@ test_read_team_master_invalid (gconstpointer user_data) static void test_write_team_master (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingTeam *s_team; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; const char *expected_config = "{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"; - const char *escaped_expected_config = "\"{ \\\"device\\\": \\\"team0\\\", \\\"link_watch\\\": { \\\"name\\\": \\\"ethtool\\\" } }\""; shvarFile *f; connection = nm_simple_connection_new (); @@ -8499,14 +8115,12 @@ test_write_team_master (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Master", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_INTERFACE_NAME, "team0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); - g_free (uuid); /* Team setting */ s_team = (NMSettingTeam *) nm_setting_team_new (); @@ -8522,7 +8136,6 @@ test_write_team_master (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -8531,43 +8144,28 @@ test_write_team_master (void) /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); + nmtst_assert_connection_verifies_without_normalization (connection); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "DEVICETYPE", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "Team"); - g_free (val); - val = svGetValue (f, "TEAM_CONFIG", TRUE); - g_assert (val); - g_assert_cmpstr (val, ==, escaped_expected_config); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "DEVICETYPE", "Team"); + _svGetValue_check (f, "TEAM_CONFIG", expected_config); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -8596,14 +8194,13 @@ test_read_team_port (gconstpointer user_data) static void test_write_team_port (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingTeamPort *s_team_port; NMSettingWired *s_wired; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; const char *expected_config = "{ \"p4p1\": { \"prio\": -10, \"sticky\": true } }"; - const char *escaped_expected_config = "\"{ \\\"p4p1\\\": { \\\"prio\\\": -10, \\\"sticky\\\": true } }\""; shvarFile *f; connection = nm_simple_connection_new (); @@ -8612,15 +8209,13 @@ test_write_team_port (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Port", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "team0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); - g_free (uuid); /* Team setting */ s_team_port = (NMSettingTeamPort *) nm_setting_team_port_new (); @@ -8637,36 +8232,17 @@ test_write_team_port (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "TYPE", FALSE); - g_assert (!val); - val = svGetValue (f, "DEVICETYPE", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "TeamPort"); - g_free (val); - val = svGetValue (f, "TEAM_PORT_CONFIG", TRUE); - g_assert (val); - g_assert_cmpstr (val, ==, escaped_expected_config); - g_free (val); - val = svGetValue (f, "TEAM_MASTER", TRUE); - g_assert (val); - g_assert_cmpstr (val, ==, "team0"); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "TYPE", NULL); + _svGetValue_check (f, "DEVICETYPE", "TeamPort"); + _svGetValue_check (f, "TEAM_PORT_CONFIG", expected_config); + _svGetValue_check (f, "TEAM_MASTER", "team0"); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -8692,108 +8268,456 @@ test_read_team_port_empty_config (void) g_object_unref (connection); } -/* Old algorithm for "remove escaped characters in place". - * - * This function is obsolete because it has O(n^2) runtime - * complexity and got replaced. Keep it here for testing, - * that both functions behave identical. - **/ -static void -svUnescape_On2 (char *s) -{ - int len, i; - - len = strlen(s); - if (len >= 2 && (s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) { - i = len - 2; - if (i == 0) - s[0] = '\0'; - else { - memmove(s, s+1, i); - s[i+1] = '\0'; - len = i; - } +static void +test_read_proxy_basic (void) +{ + NMConnection *connection; + NMSettingProxy *s_proxy; + + /* Test basic proxy configuration */ + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-read-proxy-basic", + NULL, TYPE_ETHERNET, NULL); + + /* ===== Proxy setting ===== */ + s_proxy = nm_connection_get_setting_proxy (connection); + g_assert (s_proxy); + + /* Proxy method */ + g_assert_cmpint (nm_setting_proxy_get_method (s_proxy), ==, NM_SETTING_PROXY_METHOD_AUTO); + g_assert (nm_setting_proxy_get_browser_only (s_proxy)); + g_assert_cmpstr (nm_setting_proxy_get_pac_url (s_proxy), ==, "http://wpad.mycompany.com/wpad.dat"); + + g_object_unref (connection); +} + +static void +test_write_proxy_basic (void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingProxy *s_proxy; + const char *expected_url = "https://wpad.neverland.org/wpad.dat"; + shvarFile *f; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Write Proxy Basic", + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, + NULL); + + /* Proxy setting */ + s_proxy = (NMSettingProxy *) nm_setting_proxy_new (); + nm_connection_add_setting (connection, NM_SETTING (s_proxy)); + g_object_set (s_proxy, NM_SETTING_PROXY_METHOD, NM_SETTING_PROXY_METHOD_AUTO, NULL); + g_object_set (s_proxy, NM_SETTING_PROXY_PAC_URL, expected_url, NULL); + + /* Wired setting */ + s_wired = (NMSettingWired *) nm_setting_wired_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + nmtst_assert_connection_verifies (connection); + + _writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile); + + f = _svOpenFile (testfile); + _svGetValue_check (f, "TYPE", "Ethernet"); + _svGetValue_check (f, "PROXY_METHOD", "auto"); + _svGetValue_check (f, "PAC_URL", expected_url); + svCloseFile (f); + + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, + NULL); + + nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); +} + +/*****************************************************************************/ + +static const char * +_svUnescape (const char *str, char **to_free) +{ + const char *s; + gs_free char *str_free = NULL; + + g_assert (str); + g_assert (to_free); + + if (str[0] == '\0') { + /* avoid static string "" */ + str = (str_free = g_strdup (str)); } - for (i = 0; i < len; i++) { - if (s[i] == '\\') { - memmove(s+i, s+i+1, len-(i+1)); - len--; - } - s[len] = '\0'; + + s = svUnescape (str, to_free); + if (*to_free) { + g_assert (s == *to_free); + g_assert (s[0]); + } else { + g_assert ( s == NULL + || (!s[0] && (s < str || s > strchr (str, '\0'))) + || ( s[0] && s >= str && s <= strchr (str, '\0') )); } + return s; } +typedef struct { + const char *val; + const char *exp; + bool can_concat:1; + bool needs_ascii_separator:1; +} UnescapeTestData; + static void -test_svUnescape_assert (const char *str) +do_svUnescape_assert (const char *str, const char *expected) { - char *s1 = g_strdup (str); - char *s2 = g_strdup (str); + gs_free char *to_free = NULL; + const char *s; + + s = _svUnescape (str, &to_free); + g_assert_cmpstr (s, ==, expected); - svUnescape (s1); - svUnescape_On2 (s2); + /* check we can make a round-trip */ + if (expected) { + gs_free char *s1_free = NULL; + gs_free char *s2_free = NULL; + const char *s1, *s2; - g_assert_cmpstr (s1, ==, s2); + s1 = svEscape (expected, &s1_free); + g_assert (s1); - g_free (s1); - g_free (s2); + s2 = _svUnescape (s1, &s2_free); + g_assert (s2); + + g_assert_cmpstr (s2, ==, expected); + } +} + +static void +do_svUnescape_combine_ansi_append (GString *str_val, GString *str_exp, const UnescapeTestData *data, gboolean honor_needs_ascii_separator) +{ + g_string_append (str_val, data->val); + g_string_append (str_exp, data->exp); + if (honor_needs_ascii_separator && data->needs_ascii_separator) { + /* the string has an open escape sequence. We must ensure that when + * combining it with another sequence, that they don't merge into + * something diffent. for example "\xa" + "a" must not result in + * "\xaa". Instead, we add a space in between to get "\xa a". */ + g_string_append (str_val, " "); + g_string_append (str_exp, " "); + } +} + +static void +do_svUnescape_combine_ansi (GString *str_val, GString *str_exp, const UnescapeTestData *data_ansi, gsize data_len, gssize idx) +{ + gsize i, j; + + g_string_set_size (str_val, 0); + g_string_set_size (str_exp, 0); + g_string_append (str_val, "$'"); + if (idx < 0) { + for (i = -idx; i > 0; i--) { + j = nmtst_get_rand_int () % data_len; + if (!data_ansi[j].can_concat) { + i++; + continue; + } + do_svUnescape_combine_ansi_append (str_val, str_exp, &data_ansi[j], i > 1); + } + } else { + g_assert_cmpint (idx, <, data_len); + do_svUnescape_combine_ansi_append (str_val, str_exp, &data_ansi[idx], FALSE); + } + g_string_append (str_val, "'"); } static void test_svUnescape (void) { - int len, repeat, i, k; - GRand *r = g_rand_new (); - guint32 seed = g_random_int (); - - g_rand_set_seed (r, seed); - - test_svUnescape_assert (""); - test_svUnescape_assert ("'"); - test_svUnescape_assert ("\""); - test_svUnescape_assert ("\\"); - test_svUnescape_assert ("x"); - test_svUnescape_assert (" "); - test_svUnescape_assert ("' '"); - test_svUnescape_assert ("'x'"); - test_svUnescape_assert ("\'some string\'"); - test_svUnescape_assert ("Bob outside LAN"); - test_svUnescape_assert ("{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"); - - for (len = 1; len < 25; len++) { - char *s = g_new0 (char, len+1); - - for (repeat = 0; repeat < MAX (4*len, 20); repeat++) { - - /* fill the entire string with random. */ - for (i = 0; i < len; i++) - s[i] = g_rand_int (r); - - /* randomly place escape characters into the string */ - k = g_rand_int (r) % (len); - while (k-- > 0) - s[g_rand_int (r) % len] = '\\'; - - if (len > 1) { - /* quote the string. */ - k = g_rand_int (r) % (10); - if (k < 4) { - char quote = k < 2 ? '"' : '\''; - - s[0] = quote; - s[len-1] = quote; - } +#define V0(v_value, v_expected) { .val = ""v_value"", .exp = v_expected, .can_concat = FALSE, } +#define V1(v_value, v_expected) { .val = ""v_value"", .exp = v_expected, .can_concat = !!v_expected, } +#define V2(v_value, v_expected) { .val = ""v_value"", .exp = v_expected, .can_concat = TRUE, .needs_ascii_separator = TRUE, } + const UnescapeTestData data_full[] = { + V1 ("", ""), + V0 ("'", NULL), + V1 ("'x'", "x"), + V1 ("' '", " "), + V1 ("'x'", "x"), + V0 ("\"", NULL), + V0 ("\\", NULL), + V0 (" ", ""), + V0 (" ", ""), + V0 ("a; #", "a"), + V0 (" ; #", ""), + V0 ("; ", ""), + V0 ("; ;", NULL), + V0 (" ; a #", NULL), + V0 (" ; a;; #", NULL), + V0 ("a; ; #", NULL), + V0 ("\t # ", ""), + V0 ("\t #a", ""), + V0 ("\t #a\r", ""), + V0 ("\r", ""), + V1 ("\\\"", "\""), + V1 ("\\`", "`"), + V1 ("\\$", "$"), + V1 ("\\\\", "\\"), + V1 ("\\a", "a"), + V1 ("\\b", "b"), + V1 ("\\'", "'"), + V1 ("\\~", "~"), + V1 ("\\\t", "\t"), + V1 ("\"\\\"\"", "\""), + V1 ("\"\\`\"", "`"), + V1 ("\"\\$\"", "$"), + V1 ("\"\\\\\"", "\\"), + V1 ("\"\\a\"", "\\a"), + V1 ("\"\\b\"", "\\b"), + V1 ("\"\\\t\"", "\\\t"), + V0 ("ab\r", "ab"), + V0 ("a'b'\r ", "ab"), + V0 ("a'b' \r", "ab"), + V0 ("a#b", "a#b"), + V0 ("#b", "#b"), + V1 ("\'some string\'", "some string"), + V0 ("Bob outside LAN", NULL), + V1 ("x", "x"), + V1 ("'{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }'", + "{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"), + V1 ("x\"\"b", "xb"), + V1 ("x\"c\"b", "xcb"), + V1 ("\"c\"b", "cb"), + V1 ("\"c\"\\'b", "c'b"), + V1 ("$''", ""), + V1 ("$'\\n'", "\n"), + V0 ("$'\\'", NULL), + V1 ("$'\\x'", "\\x"), + V1 ("$'\\xa'", "\xa"), + V0 ("$'\\x0'", ""), + V1 ("$'\\x12'", "\x12"), + V1 ("$'\\x12A'", "\x12""A"), + V1 ("$'\\x12t'", "\x12t"), + V1 ("\"aa\\\"\"", "aa\""), + V1 ("\"aa\\\"b\"c", "aa\"bc"), + V1 ("\"aa\\\"\"b", "aa\"b"), + + /* the following is not shell behavior, but kept for backward compatibility + * with old svEscape(). */ + V0 ("\"\\'\"", "'"), + V0 ("\"\\~\"", "~"), + V0 ("\"b\\~b\"", "b~b"), + V0 ("\"\\~\\~\"", "~~"), + V0 ("\"\\~\\'\"", "~'"), + + /* the following is shell-behavior, because it doesn't look like written + * by old svEscape(). */ + V1 ("\"\\~~\"", "\\~~"), + V1 ("\"\\a\\'\"", "\\a\\'"), + V1 ("x\"\\~\"", "x\\~"), + V1 ("\"\\'\"''", "\\'"), + V0 ("\"b\\~b\" ", "b\\~b"), + V1 ("\"b\\~b\"x", "b\\~bx"), + }; + const UnescapeTestData data_ansi[] = { + /* strings inside $''. They cannot be compared directly, but must + * be wrapped by do_svUnescape_combine_ansi(). */ + V1 ("", ""), + V1 ("a", "a"), + V1 ("b", "b"), + V1 ("x", "x"), + V1 (" ", " "), + V1 ("\\a", "\a"), + V1 ("\\b", "\b"), + V1 ("\\e", "\e"), + V1 ("\\E", "\E"), + V1 ("\\f", "\f"), + V1 ("\\n", "\n"), + V1 ("\\r", "\r"), + V1 ("\\t", "\t"), + V1 ("\\v", "\v"), + V1 ("\\\\", "\\"), + V1 ("\\'", "'"), + V1 ("\\\"", "\""), + V1 ("\\?", "\?"), + V1 ("\\?", "?"), + V2 ("\\8", "\\8"), + V2 ("\\1", "\1"), + V1 ("\\1A", "\1A"), + V1 ("\\18", "\18"), + V2 ("\\01", "\1"), + V1 ("\\001", "\1"), + V0 ("\\008", ""), + V1 ("\\018", "\0018"), + V0 ("\\08", ""), + V1 ("\\18", "\0018"), + V1 ("\\x", "\\x"), + V2 ("\\xa", "\xa"), + V1 ("\\x12", "\x12"), + V1 ("\\x12A", "\x12""A"), + V1 ("\\x12a", "\x12""a"), + V1 ("\\x12t", "\x12t"), + V1 ("\\x1a", "\x1a"), + V1 ("\\x1A", "\x1A"), + V1 ("\\ut", "\\ut"), + V2 ("\\ua", "\xa"), + V1 ("\\uat", "\xat"), + V2 ("\\uab", "\xc2\xab"), + V1 ("\\uabt", "\xc2\xabt"), + V2 ("\\uabc", "\xe0\xaa\xbc"), + V1 ("\\uabct", "\xe0\xaa\xbct"), + V2 ("\\uabcd", "\xea\xaf\x8d"), + V1 ("\\uabcdt", "\xea\xaf\x8dt"), + V2 ("\\uabcde", "\xea\xaf\x8d""e"), + V1 ("\\uabcdet", "\xea\xaf\x8d""et"), + V1 ("\\Ut", "\\Ut"), + V2 ("\\Ua", "\xa"), + V1 ("\\Uat", "\xat"), + V2 ("\\Uab", "\xc2\xab"), + V1 ("\\Uabt", "\xc2\xabt"), + V2 ("\\Uabc", "\xe0\xaa\xbc"), + V1 ("\\Uabct", "\xe0\xaa\xbct"), + V2 ("\\Uabcd", "\xea\xaf\x8d"), + V1 ("\\Uabcdt", "\xea\xaf\x8dt"), + V2 ("\\Uabcde", "\xf2\xab\xb3\x9e"), + V1 ("\\Uabcdet", "\xf2\xab\xb3\x9et"), + V2 ("\\Uabcde0", "\xf8\xaa\xbc\xb7\xa0"), + V1 ("\\Uabcde0t", "\xf8\xaa\xbc\xb7\xa0t"), + V2 ("\\Uabcde01", "\xfc\x8a\xaf\x8d\xb8\x81"), + V1 ("\\Uabcde01t", "\xfc\x8a\xaf\x8d\xb8\x81t"), + V2 ("\\U0abcde01", "\xfc\x8a\xaf\x8d\xb8\x81"), + V1 ("\\U0abcde01t", "\xfc\x8a\xaf\x8d\xb8\x81t"), + V1 ("\\U00abcde01", "\xf8\xaa\xbc\xb7\xa0""1"), + V1 ("\\U00abcde01t", "\xf8\xaa\xbc\xb7\xa0""1t"), + + /* control-x sequence is not supported */ + V1 ("\\c", "\\c"), + V1 ("\\c1", "\\c1"), + }; +#undef V0 +#undef V1 +#undef V2 + gsize i; + nm_auto_free_gstring GString *str_val = g_string_new (NULL); + nm_auto_free_gstring GString *str_val2 = g_string_new (NULL); + nm_auto_free_gstring GString *str_exp = g_string_new (NULL); + nm_auto_free_gstring GString *str_exp2 = g_string_new (NULL); + + do_svUnescape_assert ( "' '' '", " "); + + for (i = 0; i < G_N_ELEMENTS (data_full); i++) + do_svUnescape_assert (data_full[i].val, data_full[i].exp); + + for (i = 0; i < G_N_ELEMENTS (data_ansi); i++) { + do_svUnescape_combine_ansi (str_val, str_exp, data_ansi, G_N_ELEMENTS (data_ansi), i); + do_svUnescape_assert (str_val->str, str_exp->str); + } + + /* different values can be just concatenated... */ + for (i = 0; i < 200; i++) { + gsize num_concat = (nmtst_get_rand_int () % 5) + 2; + + g_string_set_size (str_val, 0); + g_string_set_size (str_exp, 0); + + while (num_concat > 0) { + gsize idx; + + if ((nmtst_get_rand_int () % 3 == 0)) { + do_svUnescape_combine_ansi (str_val2, str_exp2, data_ansi, G_N_ELEMENTS (data_ansi), -((int) ((nmtst_get_rand_int () % 5) + 1))); + continue; } - /*g_message (">>%s<<", s);*/ - test_svUnescape_assert (s); + idx = nmtst_get_rand_int () % G_N_ELEMENTS (data_full); + if (!data_full[idx].can_concat) + continue; + g_string_append (str_val, data_full[idx].val); + g_string_append (str_exp, data_full[idx].exp); + num_concat--; + } + + switch (nmtst_get_rand_int () % 3) { + case 0: + g_string_append (str_val, " "); + break; + case 1: + g_string_append (str_val, " "); + break; + } + switch (nmtst_get_rand_int () % 3) { + case 0: + g_string_append (str_val, " #"); + break; + case 1: + g_string_append (str_val, " #foo"); + break; } + do_svUnescape_assert (str_val->str, str_exp->str); + } +} + +/*****************************************************************************/ + +static void +test_write_unknown (gconstpointer test_data) +{ + nmtst_auto_unlinkfile char *filename_tmp_1 = g_strdup (TEST_SCRATCH_DIR_TMP"/tmp-1"); + const char *testfile = test_data; + gs_free char *testfile_expected = g_strconcat (testfile, ".expected", NULL); + shvarFile *sv; + gs_free_error GError *error = NULL; + gboolean success; + gs_free char *file_contents_out = NULL; + gs_free char *file_contents_exp = NULL; + + sv = _svOpenFile (testfile); + + svFileSetName (sv, filename_tmp_1); + svFileSetModified (sv); - g_free (s); + if (g_str_has_suffix (testfile, "ifcfg-test-write-unknown-4")) { + _svGetValue_check (sv, "NAME", "l4x"); + _svGetValue_check (sv, "NAME2", NULL); + _svGetValue_check (sv, "NAME3", "name3-value"); + + svSetValue (sv, "NAME", "set-by-test1"); + svSetValue (sv, "NAME2", NULL); + svSetValue (sv, "NAME2", "set-by-test2"); + svSetValue (sv, "NAME3", "set-by-test3"); + + _svGetValue_check (sv, "some_key", NULL); + _svGetValue_check (sv, "some_key1", ""); + _svGetValue_check (sv, "some_key2", ""); + _svGetValue_check (sv, "some_key3", "x"); + + _svGetValue_check (sv, "NAME", "set-by-test1"); + _svGetValue_check (sv, "NAME2", "set-by-test2"); + _svGetValue_check (sv, "NAME3", "set-by-test3"); } - g_rand_free (r); + success = svWriteFile (sv, 0644, &error); + nmtst_assert_success (success, error); + + file_contents_out = nmtst_file_get_contents (filename_tmp_1); + file_contents_exp = nmtst_file_get_contents (testfile_expected); + + g_assert_cmpstr (file_contents_out, ==, file_contents_exp); + + svCloseFile (sv); } +/*****************************************************************************/ + static void test_read_vlan_trailing_spaces (void) { @@ -8842,10 +8766,123 @@ test_sit_read_ignore (void) /*****************************************************************************/ +static void +do_test_utils_name (const char *desc, + const char *path, + gboolean only_ifcfg, + const char *expected) +{ + const char *result; + + result = utils_get_ifcfg_name (path, only_ifcfg); + g_assert_cmpstr (result, ==, expected); +} + +static void +test_utils_name (void) +{ + do_test_utils_name ("get-ifcfg-name-bad", "/foo/bar/adfasdfadf", FALSE, NULL); + do_test_utils_name ("get-ifcfg-name-good", "/foo/bar/ifcfg-FooBar", FALSE, "FooBar"); + do_test_utils_name ("get-ifcfg-name-keys", "/foo/bar/keys-BlahLbah", FALSE, "BlahLbah"); + do_test_utils_name ("get-ifcfg-name-route", "/foo/bar/route-Lalalala", FALSE, "Lalalala"); + do_test_utils_name ("get-ifcfg-name-only-ifcfg-route", "/foo/bar/route-Lalalala", TRUE, NULL); + do_test_utils_name ("get-ifcfg-name-only-ifcfg-keys", "/foo/bar/keys-Lalalala", TRUE, NULL); + do_test_utils_name ("get-ifcfg-name-no-path-ifcfg", "ifcfg-Lalalala", FALSE, "Lalalala"); + do_test_utils_name ("get-ifcfg-name-no-path-keys", "keys-Lalalala", FALSE, "Lalalala"); + do_test_utils_name ("get-ifcfg-name-no-path-route", "route-Lalalala", FALSE, "Lalalala"); + + do_test_utils_name ("get-ifcfg-name-bad2-ifcfg", "/foo/bar/asdfasifcfg-Foobar", FALSE, NULL); + do_test_utils_name ("get-ifcfg-name-bad2-keys", "/foo/bar/asdfaskeys-Foobar", FALSE, NULL); + do_test_utils_name ("get-ifcfg-name-bad2-route", "/foo/bar/asdfasroute-Foobar", FALSE, NULL); +} + +/*****************************************************************************/ + +static void +do_test_utils_path_ifcfg (const char *desc, + const char *path, + const char *expected) +{ + char *result; + + result = utils_get_ifcfg_path (path); + g_assert_cmpstr (result, ==, expected); + g_free (result); +} + +static void +do_test_utils_path_keys (const char *desc, + const char *path, + const char *expected) +{ + char *result; + + result = utils_get_keys_path (path); + g_assert_cmpstr (result, ==, expected); + g_free (result); +} + +static void +do_test_utils_path_route (const char *desc, + const char *path, + const char *expected) +{ + char *result; + + result = utils_get_route_path (path); + g_assert_cmpstr (result, ==, expected); + g_free (result); +} + +static void +test_utils_path (void) +{ + do_test_utils_path_ifcfg ("ifcfg-path-bad", "/foo/bar/adfasdfasdf", NULL); + do_test_utils_path_ifcfg ("ifcfg-path-from-keys-no-path", "keys-BlahBlah", "ifcfg-BlahBlah"); + do_test_utils_path_ifcfg ("ifcfg-path-from-keys", "/foo/bar/keys-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); + do_test_utils_path_ifcfg ("ifcfg-path-from-route", "/foo/bar/route-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); + + do_test_utils_path_keys ("keys-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); + do_test_utils_path_keys ("keys-path-from-ifcfg-no-path", "ifcfg-FooBar", "keys-FooBar"); + do_test_utils_path_keys ("keys-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/keys-FooBar"); + do_test_utils_path_keys ("keys-path-from-route", "/foo/bar/route-FooBar", "/foo/bar/keys-FooBar"); + + do_test_utils_path_route ("route-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); + do_test_utils_path_route ("route-path-from-ifcfg-no-path", "ifcfg-FooBar", "route-FooBar"); + do_test_utils_path_route ("route-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/route-FooBar"); + do_test_utils_path_route ("route-path-from-keys", "/foo/bar/keys-FooBar", "/foo/bar/route-FooBar"); +} + +/*****************************************************************************/ + +static void +do_test_utils_ignored (const char *desc, const char *path, gboolean expected_ignored) +{ + gboolean result; + + result = utils_should_ignore_file (path, FALSE); + g_assert (result == expected_ignored); +} + +static void +test_utils_ignore (void) +{ + do_test_utils_ignored ("ignored-ifcfg", "ifcfg-FooBar", FALSE); + do_test_utils_ignored ("ignored-keys", "keys-FooBar", FALSE); + do_test_utils_ignored ("ignored-route", "route-FooBar", FALSE); + do_test_utils_ignored ("ignored-bak", "ifcfg-FooBar" BAK_TAG, TRUE); + do_test_utils_ignored ("ignored-tilde", "ifcfg-FooBar" TILDE_TAG, TRUE); + do_test_utils_ignored ("ignored-orig", "ifcfg-FooBar" ORIG_TAG, TRUE); + do_test_utils_ignored ("ignored-rej", "ifcfg-FooBar" REJ_TAG, TRUE); + do_test_utils_ignored ("ignored-rpmnew", "ifcfg-FooBar" RPMNEW_TAG, TRUE); + do_test_utils_ignored ("ignored-augnew", "ifcfg-FooBar" AUGNEW_TAG, TRUE); + do_test_utils_ignored ("ignored-augtmp", "ifcfg-FooBar" AUGTMP_TAG, TRUE); +} + +/*****************************************************************************/ #define TPATH "/settings/plugins/ifcfg-rh/" -#define TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-bad-hex" #define TEST_IFCFG_WIFI_OPEN_SSID_LONG_QUOTED TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-quoted" #define TEST_IFCFG_WIFI_OPEN_SSID_LONG_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-hex" @@ -8857,7 +8894,16 @@ int main (int argc, char **argv) { nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); + if (g_mkdir_with_parents (TEST_SCRATCH_DIR_TMP, 0755) != 0) + g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR_TMP, g_strerror (errno)); + g_test_add_func (TPATH "svUnescape", test_svUnescape); + + g_test_add_data_func (TPATH "write-unknown/1", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-1", test_write_unknown); + g_test_add_data_func (TPATH "write-unknown/2", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-2", test_write_unknown); + g_test_add_data_func (TPATH "write-unknown/3", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-3", test_write_unknown); + g_test_add_data_func (TPATH "write-unknown/4", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-4", test_write_unknown); + g_test_add_func (TPATH "vlan-trailing-spaces", test_read_vlan_trailing_spaces); g_test_add_func (TPATH "unmanaged", test_read_unmanaged); @@ -8883,6 +8929,7 @@ int main (int argc, char **argv) g_test_add_func (TPATH "read-dhcp-plus-ip", test_read_wired_dhcp_plus_ip); g_test_add_func (TPATH "read-shared-plus-ip", test_read_wired_shared_plus_ip); g_test_add_func (TPATH "read-dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname); + g_test_add_func (TPATH "read-dhcpv6-hostname-fallback", test_read_wired_dhcpv6_hostname_fallback); g_test_add_func (TPATH "read-global-gateway", test_read_wired_global_gateway); g_test_add_func (TPATH "read-global-gateway-ignore", test_read_wired_global_gateway_ignore); g_test_add_func (TPATH "read-obsolete-gateway-n", test_read_wired_obsolete_gateway_n); @@ -8919,7 +8966,7 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wifi/read/open", test_read_wifi_open); g_test_add_func (TPATH "wifi/read/open/auto", test_read_wifi_open_auto); g_test_add_func (TPATH "wifi/read/open/hex-ssid", test_read_wifi_open_ssid_hex); - g_test_add_data_func (TPATH "wifi/read/open-ssid/bad-hex", TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX, test_read_wifi_open_ssid_bad); + g_test_add_func (TPATH "wifi/read/open-ssid/bad-hex", test_read_wifi_open_ssid_hex_bad); g_test_add_data_func (TPATH "wifi/read/open-ssid/long-hex", TEST_IFCFG_WIFI_OPEN_SSID_LONG_HEX, test_read_wifi_open_ssid_bad); g_test_add_data_func (TPATH "wifi/read/open-ssid/long-quoted", TEST_IFCFG_WIFI_OPEN_SSID_LONG_QUOTED, test_read_wifi_open_ssid_bad); g_test_add_func (TPATH "wifi/read/open/quoted-ssid", test_read_wifi_open_ssid_quoted); @@ -8970,6 +9017,9 @@ int main (int argc, char **argv) g_test_add_func (TPATH "vlan/read/reorder-hdr-1", test_read_vlan_reorder_hdr_1); g_test_add_func (TPATH "vlan/read/reorder-hdr-2", test_read_vlan_reorder_hdr_2); g_test_add_func (TPATH "wired/read/read-wake-on-lan", test_read_wired_wake_on_lan); + g_test_add_func (TPATH "wired/read/read-auto-negotiate-off", test_read_wired_auto_negotiate_off); + g_test_add_func (TPATH "wired/read/read-auto-negotiate-on", test_read_wired_auto_negotiate_on); + g_test_add_func (TPATH "wired/read/unkwnown-ethtool-opt", test_read_wired_unknown_ethtool_opt); g_test_add_func (TPATH "wired/write/static", test_write_wired_static); g_test_add_func (TPATH "wired/write/static-ip6-only", test_write_wired_static_ip6_only); @@ -8989,6 +9039,8 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wired/write-aliases", test_write_wired_aliases); g_test_add_func (TPATH "ipv4/write-static-addresses-GATEWAY", test_write_gateway); g_test_add_func (TPATH "wired/write-wake-on-lan", test_write_wired_wake_on_lan); + g_test_add_func (TPATH "wired/write-auto-negotiate-off", test_write_wired_auto_negotiate_off); + g_test_add_func (TPATH "wired/write-auto-negotiate-on", test_write_wired_auto_negotiate_on); g_test_add_func (TPATH "wifi/write/open", test_write_wifi_open); g_test_add_func (TPATH "wifi/write/open/hex-ssid", test_write_wifi_open_hex_ssid); g_test_add_func (TPATH "wifi/write/wep", test_write_wifi_wep); @@ -9082,6 +9134,9 @@ int main (int argc, char **argv) g_test_add_func (TPATH "team/write-port", test_write_team_port); g_test_add_func (TPATH "team/read-port-empty-config", test_read_team_port_empty_config); + g_test_add_func (TPATH "proxy/read-proxy-basic", test_read_proxy_basic); + g_test_add_func (TPATH "proxy/write-proxy-basic", test_write_proxy_basic); + g_test_add_func (TPATH "sit/read/ignore", test_sit_read_ignore); /* Stuff we expect to fail for now */ @@ -9090,6 +9145,11 @@ int main (int argc, char **argv) g_test_add_data_func (TPATH "wwan/write-gsm", GUINT_TO_POINTER (TRUE), test_write_mobile_broadband); g_test_add_data_func (TPATH "wwan/write-cdma", GUINT_TO_POINTER (FALSE), test_write_mobile_broadband); + g_test_add_func (TPATH "no-trailing-newline", test_ifcfg_no_trailing_newline); + + g_test_add_func (TPATH "utils/name", test_utils_name); + g_test_add_func (TPATH "utils/path", test_utils_path); + g_test_add_func (TPATH "utils/ignore", test_utils_ignore); + return g_test_run (); } - diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c deleted file mode 100644 index b9d52b7f..00000000 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ /dev/null @@ -1,446 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 - 2012 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "utils.h" - -#include -#include - -#include "nm-core-internal.h" -#include "NetworkManagerUtils.h" - -#include "common.h" - -/* - * utils_single_quote_string - * - * Put string inside single quotes and remove CR, LF characters. If single quote - * is present, escape it with a backslash and prepend the whole string with $ - * in order to have $'string'. That allows us to use single quote inside - * single quotes without breaking bash syntax. (man bash, section QUOTING). - * - * Caller is responsible for freeing the returned string. - */ -char * -utils_single_quote_string (const char *str) -{ - static const char *drop_chars = "\r\n"; /* drop CR and LF */ - static const char escape_char = '\\'; /* escape char is backslash */ - static const char quote_char = '\''; /* quote char is single quote */ - size_t i, slen, j = 0; - size_t drop = 0, extra = 0; - char *new_str; - - slen = strlen (str); - for (i = 0; i < slen; i++) { - if (str[i] == quote_char) - extra++; - if (strchr (drop_chars, str[i])) - drop++; - } - new_str = g_malloc0 (slen + extra - drop + 4); /* 4 is for $''\0*/ - - if (extra > 0) - new_str[j++] = '$'; - new_str[j++] = quote_char; - for (i = 0; i < slen; i++) { - if (strchr (drop_chars, str[i])) - continue; - if (str[i] == quote_char) - new_str[j++] = escape_char; - new_str[j++] = str[i]; - } - new_str[j] = quote_char; - - return new_str; -} - -/* - * utils_single_unquote_string - * - * Remove string from single (or double) quotes, and remove escaping of '. - * Also remove first $ if the string is in the form of $'string'. - * - * Caller is responsible for freeing the returned string. - */ -char * -utils_single_unquote_string (const char *str) -{ - static const char escape_char = '\\'; /* escape char is backslash */ - static const char q_char = '\''; /* quote char is single quote */ - static const char dq_char = '"'; /* double quote char */ - size_t i, slen, j = 0, quote = 0, dollar = 0; - char *new_str; - - slen = strlen (str); - new_str = g_malloc0 (slen + 1); - - if ( (slen >= 2 && (str[0] == dq_char || str[0] == q_char) && str[0] == str[slen-1]) - || (slen >= 3 && str[0] == '$' && str[1] == q_char && str[1] == str[slen-1])) { - quote = 1; - if (str[0] == '$') dollar = 1; - } - - i = quote + dollar; - while (i < slen - quote) { - if (str[i] == escape_char && str[i+1] == q_char && i+1 < slen-quote) - i++; - new_str[j++] = str[i++]; - } - new_str[j] = '\0'; - - return new_str; -} - -/* - * Check ';[a-fA-F0-9]{8}' file suffix used for temporary files by rpm when - * installing packages. - * - * Implementation taken from upstart. - */ -static gboolean -check_rpm_temp_suffix (const char *path) -{ - const char *ptr; - - g_return_val_if_fail (path != NULL, FALSE); - - /* Matches *;[a-fA-F0-9]{8}; used by rpm */ - ptr = strrchr (path, ';'); - if (ptr && (strspn (ptr + 1, "abcdefABCDEF0123456789") == 8) - && (! ptr[9])) - return TRUE; - return FALSE; -} - -static gboolean -check_suffix (const char *base, const char *tag) -{ - int len, tag_len; - - g_return_val_if_fail (base != NULL, TRUE); - g_return_val_if_fail (tag != NULL, TRUE); - - len = strlen (base); - tag_len = strlen (tag); - if ((len > tag_len) && !strcasecmp (base + len - tag_len, tag)) - return TRUE; - return FALSE; -} - -gboolean -utils_should_ignore_file (const char *filename, gboolean only_ifcfg) -{ - gs_free char *base = NULL; - - g_return_val_if_fail (filename != NULL, TRUE); - - base = g_path_get_basename (filename); - - /* Only handle ifcfg, keys, and routes files */ - if (strncmp (base, IFCFG_TAG, strlen (IFCFG_TAG)) != 0) { - if (only_ifcfg) - return TRUE; - else if ( strncmp (base, KEYS_TAG, strlen (KEYS_TAG)) != 0 - && strncmp (base, ROUTE_TAG, strlen (ROUTE_TAG)) != 0 - && strncmp (base, ROUTE6_TAG, strlen (ROUTE6_TAG)) != 0) - return TRUE; - } - - /* But not those that have certain suffixes */ - if ( check_suffix (base, BAK_TAG) - || check_suffix (base, TILDE_TAG) - || check_suffix (base, ORIG_TAG) - || check_suffix (base, REJ_TAG) - || check_suffix (base, RPMNEW_TAG) - || check_suffix (base, AUGNEW_TAG) - || check_suffix (base, AUGTMP_TAG) - || check_rpm_temp_suffix (base)) - return TRUE; - - return FALSE; -} - -char * -utils_cert_path (const char *parent, const char *suffix) -{ - const char *name; - char *dir, *path; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (suffix != NULL, NULL); - - name = utils_get_ifcfg_name (parent, FALSE); - dir = g_path_get_dirname (parent); - path = g_strdup_printf ("%s/%s-%s", dir, name, suffix); - g_free (dir); - return path; -} - -const char * -utils_get_ifcfg_name (const char *file, gboolean only_ifcfg) -{ - const char *name; - - g_return_val_if_fail (file != NULL, NULL); - - name = strrchr (file, '/'); - if (!name) - name = file; - else - name++; - if (!*name) - return NULL; - -#define MATCH_TAG_AND_RETURN(name, TAG) \ - G_STMT_START { \ - if (strncmp (name, TAG, NM_STRLEN (TAG)) == 0) { \ - name += NM_STRLEN (TAG); \ - if (name[0] == '\0') \ - return NULL; \ - else \ - return name; \ - } \ - } G_STMT_END - - /* Do not detect alias files and return 'eth0:0' instead of 'eth0'. - * Unfortunately, we cannot be sure that our files don't contain colons, - * so we cannot reject files with colons. - * - * Instead, you must not call utils_get_ifcfg_name() with an alias file - * or files that are ignored. */ - MATCH_TAG_AND_RETURN (name, IFCFG_TAG); - if (!only_ifcfg) { - MATCH_TAG_AND_RETURN (name, KEYS_TAG); - MATCH_TAG_AND_RETURN (name, ROUTE_TAG); - MATCH_TAG_AND_RETURN (name, ROUTE6_TAG); - } - - return NULL; -} - -/* Used to get any ifcfg/extra file path from any other ifcfg/extra path - * in the form . - */ -static char * -utils_get_extra_path (const char *parent, const char *tag) -{ - char *item_path = NULL, *dirname; - const char *name; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (tag != NULL, NULL); - - dirname = g_path_get_dirname (parent); - if (!dirname) - return NULL; - - name = utils_get_ifcfg_name (parent, FALSE); - if (name) { - if (!strcmp (dirname, ".")) - item_path = g_strdup_printf ("%s%s", tag, name); - else - item_path = g_strdup_printf ("%s/%s%s", dirname, tag, name); - } - g_free (dirname); - - return item_path; -} - -char * -utils_get_ifcfg_path (const char *parent) -{ - return utils_get_extra_path (parent, IFCFG_TAG); -} - -char * -utils_get_keys_path (const char *parent) -{ - return utils_get_extra_path (parent, KEYS_TAG); -} - -char * -utils_get_route_path (const char *parent) -{ - return utils_get_extra_path (parent, ROUTE_TAG); -} - -char * -utils_get_route6_path (const char *parent) -{ - return utils_get_extra_path (parent, ROUTE6_TAG); -} - -shvarFile * -utils_get_extra_ifcfg (const char *parent, const char *tag, gboolean should_create) -{ - shvarFile *ifcfg = NULL; - char *path; - - path = utils_get_extra_path (parent, tag); - if (!path) - return NULL; - - if (should_create && !g_file_test (path, G_FILE_TEST_EXISTS)) - ifcfg = svCreateFile (path); - - if (!ifcfg) - ifcfg = svOpenFile (path, NULL); - - g_free (path); - return ifcfg; -} - -shvarFile * -utils_get_keys_ifcfg (const char *parent, gboolean should_create) -{ - return utils_get_extra_ifcfg (parent, KEYS_TAG, should_create); -} - -shvarFile * -utils_get_route_ifcfg (const char *parent, gboolean should_create) -{ - return utils_get_extra_ifcfg (parent, ROUTE_TAG, should_create); -} - -shvarFile * -utils_get_route6_ifcfg (const char *parent, gboolean should_create) -{ - return utils_get_extra_ifcfg (parent, ROUTE6_TAG, should_create); -} - -/* Finds out if route file has new or older format - * Returns TRUE - new syntax (ADDRESS=a.b.c.d ...), error opening file or empty - * FALSE - older syntax, i.e. argument to 'ip route add' (1.2.3.0/24 via 11.22.33.44) - */ -gboolean -utils_has_route_file_new_syntax (const char *filename) -{ - char *contents = NULL; - gsize len = 0; - gboolean ret = FALSE; - const char *pattern = "^[[:space:]]*ADDRESS[0-9]+="; - - g_return_val_if_fail (filename != NULL, TRUE); - - if (!g_file_get_contents (filename, &contents, &len, NULL)) - return TRUE; - - if (len <= 0) { - ret = TRUE; - goto gone; - } - - if (g_regex_match_simple (pattern, contents, G_REGEX_MULTILINE, 0)) - ret = TRUE; - -gone: - g_free (contents); - return ret; -} - -gboolean -utils_has_complex_routes (const char *filename) -{ - char *rules; - - g_return_val_if_fail (filename != NULL, TRUE); - - rules = utils_get_extra_path (filename, RULE_TAG); - if (g_file_test (rules, G_FILE_TEST_EXISTS)) { - g_free (rules); - return TRUE; - } - g_free (rules); - - rules = utils_get_extra_path (filename, RULE6_TAG); - if (g_file_test (rules, G_FILE_TEST_EXISTS)) { - g_free (rules); - return TRUE; - } - g_free (rules); - - return FALSE; -} - -/* Find out if the 'alias' file name might be an alias file for 'ifcfg' file name, - * or any alias when 'ifcfg' is NULL. Does not check that it's actually a valid - * alias name; that happens in reader.c - */ -gboolean -utils_is_ifcfg_alias_file (const char *alias, const char *ifcfg) -{ - g_return_val_if_fail (alias != NULL, FALSE); - - if (strncmp (alias, IFCFG_TAG, strlen (IFCFG_TAG))) - return FALSE; - - if (ifcfg) { - size_t len = strlen (ifcfg); - - return (strncmp (alias, ifcfg, len) == 0 && alias[len] == ':'); - } else { - return (strchr (alias, ':') != NULL); - } -} - -char * -utils_detect_ifcfg_path (const char *path, gboolean only_ifcfg) -{ - gs_free char *base = NULL; - char *ptr, *ifcfg = NULL; - - g_return_val_if_fail (path != NULL, NULL); - - if (utils_should_ignore_file (path, only_ifcfg)) - return NULL; - - base = g_path_get_basename (path); - - if (strncmp (base, IFCFG_TAG, NM_STRLEN (IFCFG_TAG)) == 0) { - if (base[NM_STRLEN (IFCFG_TAG)] == '\0') - return NULL; - if (utils_is_ifcfg_alias_file (base, NULL)) { - ifcfg = g_strdup (path); - ptr = strrchr (ifcfg, ':'); - if (ptr && ptr > ifcfg) { - *ptr = '\0'; - if (g_file_test (ifcfg, G_FILE_TEST_EXISTS)) { - /* the file has a colon, so it is probably an alias. - * To be ~more~ certain that this is an alias file, - * check whether a corresponding base file exists. */ - if (only_ifcfg) { - g_free (ifcfg); - return NULL; - } - return ifcfg; - } - } - g_free (ifcfg); - } - return g_strdup (path); - } - - if (only_ifcfg) - return NULL; - return utils_get_ifcfg_path (path); -} diff --git a/src/settings/plugins/ifcfg-rh/utils.h b/src/settings/plugins/ifcfg-rh/utils.h deleted file mode 100644 index c105487a..00000000 --- a/src/settings/plugins/ifcfg-rh/utils.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 - 2012 Red Hat, Inc. - */ - -#ifndef _UTILS_H_ -#define _UTILS_H_ - -#include "nm-connection.h" - -#include "shvar.h" - -#define NM_IFCFG_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") -#define NM_IFCFG_CONNECTION_LOG_FMT "%s (%s,\"%s\")" -#define NM_IFCFG_CONNECTION_LOG_ARG(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) -#define NM_IFCFG_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" -#define NM_IFCFG_CONNECTION_LOG_ARGD(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con) - -char *utils_single_quote_string (const char *str); - -char *utils_single_unquote_string (const char *str); - -char *utils_cert_path (const char *parent, const char *suffix); - -const char *utils_get_ifcfg_name (const char *file, gboolean only_ifcfg); - -gboolean utils_should_ignore_file (const char *filename, gboolean only_ifcfg); - -char *utils_get_ifcfg_path (const char *parent); -char *utils_get_keys_path (const char *parent); -char *utils_get_route_path (const char *parent); -char *utils_get_route6_path (const char *parent); - -shvarFile *utils_get_extra_ifcfg (const char *parent, const char *tag, gboolean should_create); -shvarFile *utils_get_keys_ifcfg (const char *parent, gboolean should_create); -shvarFile *utils_get_route_ifcfg (const char *parent, gboolean should_create); -shvarFile *utils_get_route6_ifcfg (const char *parent, gboolean should_create); - -gboolean utils_has_route_file_new_syntax (const char *filename); -gboolean utils_has_complex_routes (const char *filename); - -gboolean utils_is_ifcfg_alias_file (const char *alias, const char *ifcfg); - -char *utils_detect_ifcfg_path (const char *path, gboolean only_ifcfg); - -#endif /* _UTILS_H_ */ - diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c deleted file mode 100644 index dcc48f2a..00000000 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ /dev/null @@ -1,2970 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2009 - 2015 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include "writer.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-setting-connection.h" -#include "nm-setting-wired.h" -#include "nm-setting-wireless.h" -#include "nm-setting-8021x.h" -#include "nm-setting-ip4-config.h" -#include "nm-setting-ip6-config.h" -#include "nm-setting-pppoe.h" -#include "nm-setting-vlan.h" -#include "nm-setting-team.h" -#include "nm-setting-team-port.h" -#include "nm-utils.h" -#include "nm-core-internal.h" -#include "NetworkManagerUtils.h" - -#include "common.h" -#include "shvar.h" -#include "reader.h" -#include "utils.h" - -/*****************************************************************************/ - -#define _NMLOG_DOMAIN LOGD_SETTINGS -#define _NMLOG_PREFIX_NAME "ifcfg-rh" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), (_NMLOG_DOMAIN), \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -/*****************************************************************************/ - -static void -save_secret_flags (shvarFile *ifcfg, - const char *key, - NMSettingSecretFlags flags) -{ - GString *str; - - g_return_if_fail (ifcfg != NULL); - g_return_if_fail (key != NULL); - - if (flags == NM_SETTING_SECRET_FLAG_NONE) { - svSetValue (ifcfg, key, NULL, FALSE); - return; - } - - /* Convert flags bitfield into string representation */ - str = g_string_sized_new (20); - if (flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED) - g_string_append (str, SECRET_FLAG_AGENT); - - if (flags & NM_SETTING_SECRET_FLAG_NOT_SAVED) { - if (str->len) - g_string_append_c (str, ' '); - g_string_append (str, SECRET_FLAG_NOT_SAVED); - } - - if (flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) { - if (str->len) - g_string_append_c (str, ' '); - g_string_append (str, SECRET_FLAG_NOT_REQUIRED); - } - - svSetValue (ifcfg, key, str->len ? str->str : NULL, FALSE); - g_string_free (str, TRUE); -} - -static void -set_secret (shvarFile *ifcfg, - const char *key, - const char *value, - const char *flags_key, - NMSettingSecretFlags flags, - gboolean verbatim) -{ - shvarFile *keyfile; - GError *error = NULL; - - /* Clear the secret from the ifcfg and the associated "keys" file */ - svSetValue (ifcfg, key, NULL, FALSE); - - /* Save secret flags */ - save_secret_flags (ifcfg, flags_key, flags); - - keyfile = utils_get_keys_ifcfg (ifcfg->fileName, TRUE); - if (!keyfile) { - _LOGW ("could not create ifcfg file for '%s'", ifcfg->fileName); - goto error; - } - - /* Clear the secret from the associated "keys" file */ - svSetValue (keyfile, key, NULL, FALSE); - - /* Only write the secret if it's system owned and supposed to be saved */ - if (flags == NM_SETTING_SECRET_FLAG_NONE) - svSetValue (keyfile, key, value, verbatim); - - if (!svWriteFile (keyfile, 0600, &error)) { - _LOGW ("could not update ifcfg file '%s': %s", - keyfile->fileName, error->message); - g_clear_error (&error); - svCloseFile (keyfile); - goto error; - } - svCloseFile (keyfile); - return; - -error: - /* Try setting the secret in the actual ifcfg */ - svSetValue (ifcfg, key, value, FALSE); -} - -static gboolean -write_secret_file (const char *path, - const char *data, - gsize len, - GError **error) -{ - char *tmppath; - int fd = -1, written; - gboolean success = FALSE; - mode_t saved_umask; - - tmppath = g_malloc0 (strlen (path) + 10); - memcpy (tmppath, path, strlen (path)); - strcat (tmppath, ".XXXXXX"); - - /* Only readable by root */ - saved_umask = umask (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); - - errno = 0; - fd = mkstemp (tmppath); - if (fd < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not create temporary file for '%s': %d", - path, errno); - goto out; - } - - errno = 0; - written = write (fd, data, len); - if (written != len) { - close (fd); - unlink (tmppath); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not write temporary file for '%s': %d", - path, errno); - goto out; - } - close (fd); - - /* Try to rename */ - errno = 0; - if (rename (tmppath, path)) { - unlink (tmppath); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not rename temporary file to '%s': %d", - path, errno); - goto out; - } - success = TRUE; - -out: - umask (saved_umask); - g_free (tmppath); - return success; -} - -typedef struct ObjectType { - const char *setting_key; - NMSetting8021xCKScheme (*scheme_func)(NMSetting8021x *setting); - const char * (*path_func) (NMSetting8021x *setting); - GBytes * (*blob_func) (NMSetting8021x *setting); - const char *ifcfg_key; - const char *suffix; -} ObjectType; - -static const ObjectType ca_type = { - NM_SETTING_802_1X_CA_CERT, - nm_setting_802_1x_get_ca_cert_scheme, - nm_setting_802_1x_get_ca_cert_path, - nm_setting_802_1x_get_ca_cert_blob, - "IEEE_8021X_CA_CERT", - "ca-cert.der" -}; - -static const ObjectType phase2_ca_type = { - NM_SETTING_802_1X_PHASE2_CA_CERT, - nm_setting_802_1x_get_phase2_ca_cert_scheme, - nm_setting_802_1x_get_phase2_ca_cert_path, - nm_setting_802_1x_get_phase2_ca_cert_blob, - "IEEE_8021X_INNER_CA_CERT", - "inner-ca-cert.der" -}; - -static const ObjectType client_type = { - NM_SETTING_802_1X_CLIENT_CERT, - nm_setting_802_1x_get_client_cert_scheme, - nm_setting_802_1x_get_client_cert_path, - nm_setting_802_1x_get_client_cert_blob, - "IEEE_8021X_CLIENT_CERT", - "client-cert.der" -}; - -static const ObjectType phase2_client_type = { - NM_SETTING_802_1X_PHASE2_CLIENT_CERT, - nm_setting_802_1x_get_phase2_client_cert_scheme, - nm_setting_802_1x_get_phase2_client_cert_path, - nm_setting_802_1x_get_phase2_client_cert_blob, - "IEEE_8021X_INNER_CLIENT_CERT", - "inner-client-cert.der" -}; - -static const ObjectType pk_type = { - NM_SETTING_802_1X_PRIVATE_KEY, - nm_setting_802_1x_get_private_key_scheme, - nm_setting_802_1x_get_private_key_path, - nm_setting_802_1x_get_private_key_blob, - "IEEE_8021X_PRIVATE_KEY", - "private-key.pem" -}; - -static const ObjectType phase2_pk_type = { - NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, - nm_setting_802_1x_get_phase2_private_key_scheme, - nm_setting_802_1x_get_phase2_private_key_path, - nm_setting_802_1x_get_phase2_private_key_blob, - "IEEE_8021X_INNER_PRIVATE_KEY", - "inner-private-key.pem" -}; - -static const ObjectType p12_type = { - NM_SETTING_802_1X_PRIVATE_KEY, - nm_setting_802_1x_get_private_key_scheme, - nm_setting_802_1x_get_private_key_path, - nm_setting_802_1x_get_private_key_blob, - "IEEE_8021X_PRIVATE_KEY", - "private-key.p12" -}; - -static const ObjectType phase2_p12_type = { - NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, - nm_setting_802_1x_get_phase2_private_key_scheme, - nm_setting_802_1x_get_phase2_private_key_path, - nm_setting_802_1x_get_phase2_private_key_blob, - "IEEE_8021X_INNER_PRIVATE_KEY", - "inner-private-key.p12" -}; - -static gboolean -write_object (NMSetting8021x *s_8021x, - shvarFile *ifcfg, - const ObjectType *objtype, - GError **error) -{ - NMSetting8021xCKScheme scheme; - const char *path = NULL; - GBytes *blob = NULL; - - g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (objtype != NULL, FALSE); - - scheme = (*(objtype->scheme_func))(s_8021x); - switch (scheme) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - blob = (*(objtype->blob_func))(s_8021x); - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = (*(objtype->path_func))(s_8021x); - break; - default: - break; - } - - /* If certificate/private key wasn't sent, the connection may no longer be - * 802.1x and thus we clear out the paths and certs. - */ - if (!path && !blob) { - char *standard_file; - int ignored; - - /* Since no cert/private key is now being used, delete any standard file - * that was created for this connection, but leave other files alone. - * Thus, for example, - * /etc/sysconfig/network-scripts/ca-cert-Test_Write_Wifi_WPA_EAP-TLS.der - * will be deleted, but /etc/pki/tls/cert.pem will not. - */ - standard_file = utils_cert_path (ifcfg->fileName, objtype->suffix); - if (g_file_test (standard_file, G_FILE_TEST_EXISTS)) - ignored = unlink (standard_file); - g_free (standard_file); - - svSetValue (ifcfg, objtype->ifcfg_key, NULL, FALSE); - return TRUE; - } - - /* If the object path was specified, prefer that over any raw cert data that - * may have been sent. - */ - if (path) { - svSetValue (ifcfg, objtype->ifcfg_key, path, FALSE); - return TRUE; - } - - /* If it's raw certificate data, write the data out to the standard file */ - if (blob) { - gboolean success; - char *new_file; - GError *write_error = NULL; - - new_file = utils_cert_path (ifcfg->fileName, objtype->suffix); - if (!new_file) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not create file path for %s / %s", - NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key); - return FALSE; - } - - /* Write the raw certificate data out to the standard file so that we - * can use paths from now on instead of pushing around the certificate - * data itself. - */ - success = write_secret_file (new_file, - (const char *) g_bytes_get_data (blob, NULL), - g_bytes_get_size (blob), - &write_error); - if (success) { - svSetValue (ifcfg, objtype->ifcfg_key, new_file, FALSE); - g_free (new_file); - return TRUE; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not write certificate/key for %s / %s: %s", - NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key, - (write_error && write_error->message) ? write_error->message : "(unknown)"); - g_clear_error (&write_error); - } - g_free (new_file); - } - - return FALSE; -} - -static gboolean -write_8021x_certs (NMSetting8021x *s_8021x, - gboolean phase2, - shvarFile *ifcfg, - GError **error) -{ - const char *password = NULL; - gboolean success = FALSE, is_pkcs12 = FALSE; - const ObjectType *otype = NULL; - NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - - /* CA certificate */ - if (!write_object (s_8021x, ifcfg, phase2 ? &phase2_ca_type : &ca_type, error)) - return FALSE; - - /* Private key */ - if (phase2) { - otype = &phase2_pk_type; - if (nm_setting_802_1x_get_phase2_private_key_format (s_8021x) == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { - otype = &phase2_p12_type; - is_pkcs12 = TRUE; - } - password = nm_setting_802_1x_get_phase2_private_key_password (s_8021x); - flags = nm_setting_802_1x_get_phase2_private_key_password_flags (s_8021x); - } else { - otype = &pk_type; - if (nm_setting_802_1x_get_private_key_format (s_8021x) == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { - otype = &p12_type; - is_pkcs12 = TRUE; - } - password = nm_setting_802_1x_get_private_key_password (s_8021x); - flags = nm_setting_802_1x_get_private_key_password_flags (s_8021x); - } - - /* Save the private key */ - if (!write_object (s_8021x, ifcfg, otype, error)) - goto out; - - /* Private key password */ - if (phase2) { - set_secret (ifcfg, - "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD", - password, - "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD_FLAGS", - flags, - FALSE); - } else { - set_secret (ifcfg, - "IEEE_8021X_PRIVATE_KEY_PASSWORD", - password, - "IEEE_8021X_PRIVATE_KEY_PASSWORD_FLAGS", - flags, - FALSE); - } - - /* Client certificate */ - if (is_pkcs12) { - /* Don't need a client certificate with PKCS#12 since the file is both - * the client certificate and the private key in one file. - */ - svSetValue (ifcfg, - phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT", - NULL, FALSE); - } else { - /* Save the client certificate */ - if (!write_object (s_8021x, ifcfg, phase2 ? &phase2_client_type : &client_type, error)) - goto out; - } - - success = TRUE; - -out: - return success; -} - -static gboolean -write_8021x_setting (NMConnection *connection, - shvarFile *ifcfg, - gboolean wired, - GError **error) -{ - NMSetting8021x *s_8021x; - const char *value, *match; - char *tmp = NULL; - gboolean success = FALSE; - GString *phase2_auth; - GString *str; - guint32 i, num; - - s_8021x = nm_connection_get_setting_802_1x (connection); - if (!s_8021x) { - /* If wired, clear KEY_MGMT */ - if (wired) - svSetValue (ifcfg, "KEY_MGMT", NULL, FALSE); - return TRUE; - } - - /* If wired, write KEY_MGMT */ - if (wired) - svSetValue (ifcfg, "KEY_MGMT", "IEEE8021X", FALSE); - - /* EAP method */ - if (nm_setting_802_1x_get_num_eap_methods (s_8021x)) { - value = nm_setting_802_1x_get_eap_method (s_8021x, 0); - if (value) - tmp = g_ascii_strup (value, -1); - } - svSetValue (ifcfg, "IEEE_8021X_EAP_METHODS", tmp ? tmp : NULL, FALSE); - g_free (tmp); - - svSetValue (ifcfg, "IEEE_8021X_IDENTITY", - nm_setting_802_1x_get_identity (s_8021x), - FALSE); - - svSetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", - nm_setting_802_1x_get_anonymous_identity (s_8021x), - FALSE); - - set_secret (ifcfg, - "IEEE_8021X_PASSWORD", - nm_setting_802_1x_get_password (s_8021x), - "IEEE_8021X_PASSWORD_FLAGS", - nm_setting_802_1x_get_password_flags (s_8021x), - FALSE); - - /* PEAP version */ - value = nm_setting_802_1x_get_phase1_peapver (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_PEAP_VERSION", NULL, FALSE); - if (value && (!strcmp (value, "0") || !strcmp (value, "1"))) - svSetValue (ifcfg, "IEEE_8021X_PEAP_VERSION", value, FALSE); - - /* Force new PEAP label */ - value = nm_setting_802_1x_get_phase1_peaplabel (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", NULL, FALSE); - if (value && !strcmp (value, "1")) - svSetValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", "yes", FALSE); - - /* PAC file */ - value = nm_setting_802_1x_get_pac_file (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_PAC_FILE", NULL, FALSE); - if (value) - svSetValue (ifcfg, "IEEE_8021X_PAC_FILE", value, FALSE); - - /* FAST PAC provisioning */ - value = nm_setting_802_1x_get_phase1_fast_provisioning (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", NULL, FALSE); - if (value) { - if (strcmp (value, "1") == 0) - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth", FALSE); - else if (strcmp (value, "2") == 0) - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-auth", FALSE); - else if (strcmp (value, "3") == 0) - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth allow-auth", FALSE); - } - - /* Phase2 auth methods */ - svSetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", NULL, FALSE); - phase2_auth = g_string_new (NULL); - - value = nm_setting_802_1x_get_phase2_auth (s_8021x); - if (value) { - tmp = g_ascii_strup (value, -1); - g_string_append (phase2_auth, tmp); - g_free (tmp); - } - - value = nm_setting_802_1x_get_phase2_autheap (s_8021x); - if (value) { - if (phase2_auth->len) - g_string_append_c (phase2_auth, ' '); - - tmp = g_ascii_strup (value, -1); - g_string_append_printf (phase2_auth, "EAP-%s", tmp); - g_free (tmp); - } - - svSetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", - phase2_auth->len ? phase2_auth->str : NULL, - FALSE); - - g_string_free (phase2_auth, TRUE); - - svSetValue (ifcfg, "IEEE_8021X_SUBJECT_MATCH", - nm_setting_802_1x_get_subject_match (s_8021x), - FALSE); - - svSetValue (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH", - nm_setting_802_1x_get_phase2_subject_match (s_8021x), - FALSE); - - svSetValue (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", NULL, FALSE); - str = g_string_new (NULL); - num = nm_setting_802_1x_get_num_altsubject_matches (s_8021x); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (str, ' '); - match = nm_setting_802_1x_get_altsubject_match (s_8021x, i); - g_string_append (str, match); - } - if (str->len > 0) - svSetValue (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", str->str, FALSE); - g_string_free (str, TRUE); - - svSetValue (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", NULL, FALSE); - str = g_string_new (NULL); - num = nm_setting_802_1x_get_num_phase2_altsubject_matches (s_8021x); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (str, ' '); - match = nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, i); - g_string_append (str, match); - } - if (str->len > 0) - svSetValue (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", str->str, FALSE); - g_string_free (str, TRUE); - - svSetValue (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", - nm_setting_802_1x_get_domain_suffix_match (s_8021x), - FALSE); - svSetValue (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", - nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x), - FALSE); - - success = write_8021x_certs (s_8021x, FALSE, ifcfg, error); - if (success) { - /* phase2/inner certs */ - success = write_8021x_certs (s_8021x, TRUE, ifcfg, error); - } - - return success; -} - -static gboolean -write_wireless_security_setting (NMConnection *connection, - shvarFile *ifcfg, - gboolean adhoc, - gboolean *no_8021x, - GError **error) -{ - NMSettingWirelessSecurity *s_wsec; - const char *key_mgmt, *auth_alg, *key, *proto, *cipher, *psk; - gboolean wep = FALSE, wpa = FALSE, dynamic_wep = FALSE; - char *tmp; - guint32 i, num; - GString *str; - - s_wsec = nm_connection_get_setting_wireless_security (connection); - if (!s_wsec) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing '%s' setting", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); - return FALSE; - } - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - g_assert (key_mgmt); - - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - - svSetValue (ifcfg, "DEFAULTKEY", NULL, FALSE); - - if (!strcmp (key_mgmt, "none")) { - svSetValue (ifcfg, "KEY_MGMT", NULL, FALSE); - wep = TRUE; - *no_8021x = TRUE; - } else if (!strcmp (key_mgmt, "wpa-none") || !strcmp (key_mgmt, "wpa-psk")) { - svSetValue (ifcfg, "KEY_MGMT", "WPA-PSK", FALSE); - wpa = TRUE; - *no_8021x = TRUE; - } else if (!strcmp (key_mgmt, "ieee8021x")) { - svSetValue (ifcfg, "KEY_MGMT", "IEEE8021X", FALSE); - dynamic_wep = TRUE; - } else if (!strcmp (key_mgmt, "wpa-eap")) { - svSetValue (ifcfg, "KEY_MGMT", "WPA-EAP", FALSE); - wpa = TRUE; - } - - svSetValue (ifcfg, "SECURITYMODE", NULL, FALSE); - if (auth_alg) { - if (!strcmp (auth_alg, "shared")) - svSetValue (ifcfg, "SECURITYMODE", "restricted", FALSE); - else if (!strcmp (auth_alg, "open")) - svSetValue (ifcfg, "SECURITYMODE", "open", FALSE); - else if (!strcmp (auth_alg, "leap")) { - svSetValue (ifcfg, "SECURITYMODE", "leap", FALSE); - svSetValue (ifcfg, "IEEE_8021X_IDENTITY", - nm_setting_wireless_security_get_leap_username (s_wsec), - FALSE); - set_secret (ifcfg, - "IEEE_8021X_PASSWORD", - nm_setting_wireless_security_get_leap_password (s_wsec), - "IEEE_8021X_PASSWORD_FLAGS", - nm_setting_wireless_security_get_leap_password_flags (s_wsec), - FALSE); - *no_8021x = TRUE; - } - } - - /* WEP keys */ - - /* Clear any default key */ - set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - - /* Clear existing keys */ - for (i = 0; i < 4; i++) { - tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - g_free (tmp); - - tmp = g_strdup_printf ("KEY%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - g_free (tmp); - } - - /* And write the new ones out */ - if (wep) { - /* Default WEP TX key index */ - tmp = g_strdup_printf ("%d", nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec) + 1); - svSetValue (ifcfg, "DEFAULTKEY", tmp, FALSE); - g_free (tmp); - - for (i = 0; i < 4; i++) { - NMWepKeyType key_type; - - key = nm_setting_wireless_security_get_wep_key (s_wsec, i); - if (key) { - char *ascii_key = NULL; - - /* Passphrase needs a different ifcfg key since with WEP, there - * are some passphrases that are indistinguishable from WEP hex - * keys. - */ - key_type = nm_setting_wireless_security_get_wep_key_type (s_wsec); - if (key_type == NM_WEP_KEY_TYPE_UNKNOWN) { - if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_KEY)) - key_type = NM_WEP_KEY_TYPE_KEY; - else if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_PASSPHRASE)) - key_type = NM_WEP_KEY_TYPE_PASSPHRASE; - } - if (key_type == NM_WEP_KEY_TYPE_PASSPHRASE) - tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); - else if (key_type == NM_WEP_KEY_TYPE_KEY) { - tmp = g_strdup_printf ("KEY%d", i + 1); - - /* Add 's:' prefix for ASCII keys */ - if (strlen (key) == 5 || strlen (key) == 13) { - ascii_key = g_strdup_printf ("s:%s", key); - key = ascii_key; - } - } else { - _LOGW ("invalid WEP key '%s'", key); - tmp = NULL; - } - - if (tmp) { - set_secret (ifcfg, - tmp, - key, - "WEP_KEY_FLAGS", - nm_setting_wireless_security_get_wep_key_flags (s_wsec), - FALSE); - } - g_free (tmp); - g_free (ascii_key); - } - } - } - - /* WPA protos */ - svSetValue (ifcfg, "WPA_ALLOW_WPA", NULL, FALSE); - svSetValue (ifcfg, "WPA_ALLOW_WPA2", NULL, FALSE); - num = nm_setting_wireless_security_get_num_protos (s_wsec); - for (i = 0; i < num; i++) { - proto = nm_setting_wireless_security_get_proto (s_wsec, i); - if (proto && !strcmp (proto, "wpa")) - svSetValue (ifcfg, "WPA_ALLOW_WPA", "yes", FALSE); - else if (proto && !strcmp (proto, "rsn")) - svSetValue (ifcfg, "WPA_ALLOW_WPA2", "yes", FALSE); - } - - /* WPA Pairwise ciphers */ - svSetValue (ifcfg, "CIPHER_PAIRWISE", NULL, FALSE); - str = g_string_new (NULL); - num = nm_setting_wireless_security_get_num_pairwise (s_wsec); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (str, ' '); - cipher = nm_setting_wireless_security_get_pairwise (s_wsec, i); - - /* Don't write out WEP40 or WEP104 if for some reason they are set; they - * are not valid pairwise ciphers. - */ - if (strcmp (cipher, "wep40") && strcmp (cipher, "wep104")) { - tmp = g_ascii_strup (cipher, -1); - g_string_append (str, tmp); - g_free (tmp); - } - } - if (strlen (str->str) && (dynamic_wep == FALSE)) - svSetValue (ifcfg, "CIPHER_PAIRWISE", str->str, FALSE); - g_string_free (str, TRUE); - - /* WPA Group ciphers */ - svSetValue (ifcfg, "CIPHER_GROUP", NULL, FALSE); - str = g_string_new (NULL); - num = nm_setting_wireless_security_get_num_groups (s_wsec); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (str, ' '); - cipher = nm_setting_wireless_security_get_group (s_wsec, i); - tmp = g_ascii_strup (cipher, -1); - g_string_append (str, tmp); - g_free (tmp); - } - if (strlen (str->str) && (dynamic_wep == FALSE)) - svSetValue (ifcfg, "CIPHER_GROUP", str->str, FALSE); - g_string_free (str, TRUE); - - /* WPA Passphrase */ - if (wpa) { - char *quoted = NULL; - - psk = nm_setting_wireless_security_get_psk (s_wsec); - if (psk && (strlen (psk) != 64)) { - /* Quote the PSK since it's a passphrase */ - quoted = utils_single_quote_string (psk); - } - set_secret (ifcfg, - "WPA_PSK", - quoted ? quoted : psk, - "WPA_PSK_FLAGS", - nm_setting_wireless_security_get_psk_flags (s_wsec), - TRUE); - g_free (quoted); - } else { - set_secret (ifcfg, - "WPA_PSK", - NULL, - "WPA_PSK_FLAGS", - NM_SETTING_SECRET_FLAG_NONE, - FALSE); - } - - return TRUE; -} - -static gboolean -write_wireless_setting (NMConnection *connection, - shvarFile *ifcfg, - gboolean *no_8021x, - GError **error) -{ - NMSettingWireless *s_wireless; - char *tmp, *tmp2; - GBytes *ssid; - const guint8 *ssid_data; - gsize ssid_len; - const char *mode, *bssid; - const char *device_mac, *cloned_mac; - char buf[33]; - guint32 mtu, chan, i; - gboolean adhoc = FALSE, hex_ssid = FALSE; - const char * const *macaddr_blacklist; - - s_wireless = nm_connection_get_setting_wireless (connection); - if (!s_wireless) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - - device_mac = nm_setting_wireless_get_mac_address (s_wireless); - svSetValue (ifcfg, "HWADDR", device_mac, FALSE); - - cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless); - svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); - - svSetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", - nm_setting_wireless_get_generate_mac_address_mask (s_wireless), - FALSE); - - svSetValue (ifcfg, "HWADDR_BLACKLIST", NULL, FALSE); - macaddr_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless); - if (macaddr_blacklist[0]) { - char *blacklist_str; - - blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); - svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str, FALSE); - g_free (blacklist_str); - } - - svSetValue (ifcfg, "MTU", NULL, FALSE); - mtu = nm_setting_wireless_get_mtu (s_wireless); - if (mtu) { - tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); - g_free (tmp); - } - - ssid = nm_setting_wireless_get_ssid (s_wireless); - if (!ssid) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - ssid_data = g_bytes_get_data (ssid, &ssid_len); - if (!ssid_len || ssid_len > 32) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - - /* If the SSID contains any non-printable characters, we need to use the - * hex notation of the SSID instead. - */ - for (i = 0; i < ssid_len; i++) { - if (!g_ascii_isprint (ssid_data[i])) { - hex_ssid = TRUE; - break; - } - } - - if (hex_ssid) { - GString *str; - - /* Hex SSIDs don't get quoted */ - str = g_string_sized_new (ssid_len * 2 + 3); - g_string_append (str, "0x"); - for (i = 0; i < ssid_len; i++) - g_string_append_printf (str, "%02X", ssid_data[i]); - svSetValue (ifcfg, "ESSID", str->str, TRUE); - g_string_free (str, TRUE); - } else { - const char *tmp_escaped; - - /* Printable SSIDs always get quoted */ - memset (buf, 0, sizeof (buf)); - memcpy (buf, ssid_data, ssid_len); - tmp_escaped = svEscape (buf, &tmp); - - /* svEscape will usually quote the string, but just for consistency, - * if svEscape doesn't quote the ESSID, we quote it ourselves. - */ - if (tmp_escaped[0] != '"' && tmp_escaped[strlen (tmp_escaped) - 1] != '"') { - tmp2 = g_strdup_printf ("\"%s\"", tmp_escaped); - svSetValue (ifcfg, "ESSID", tmp2, TRUE); - g_free (tmp2); - } else - svSetValue (ifcfg, "ESSID", tmp_escaped, TRUE); - g_free (tmp); - } - - mode = nm_setting_wireless_get_mode (s_wireless); - if (!mode || !strcmp (mode, "infrastructure")) { - svSetValue (ifcfg, "MODE", "Managed", FALSE); - } else if (!strcmp (mode, "adhoc")) { - svSetValue (ifcfg, "MODE", "Ad-Hoc", FALSE); - adhoc = TRUE; - } else if (!strcmp (mode, "ap")) { - svSetValue (ifcfg, "MODE", "Ap", FALSE); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Invalid mode '%s' in '%s' setting", - mode, NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - - svSetValue (ifcfg, "CHANNEL", NULL, FALSE); - svSetValue (ifcfg, "BAND", NULL, FALSE); - chan = nm_setting_wireless_get_channel (s_wireless); - if (chan) { - tmp = g_strdup_printf ("%u", chan); - svSetValue (ifcfg, "CHANNEL", tmp, FALSE); - g_free (tmp); - } else { - /* Band only set if channel is not, since channel implies band */ - svSetValue (ifcfg, "BAND", nm_setting_wireless_get_band (s_wireless), FALSE); - } - - bssid = nm_setting_wireless_get_bssid (s_wireless); - svSetValue (ifcfg, "BSSID", bssid, FALSE); - - /* Ensure DEFAULTKEY and SECURITYMODE are cleared unless there's security; - * otherwise there's no way to detect WEP vs. open when WEP keys aren't - * saved. - */ - svSetValue (ifcfg, "DEFAULTKEY", NULL, FALSE); - svSetValue (ifcfg, "SECURITYMODE", NULL, FALSE); - - if (nm_connection_get_setting_wireless_security (connection)) { - if (!write_wireless_security_setting (connection, ifcfg, adhoc, no_8021x, error)) - return FALSE; - } else { - char *keys_path; - - /* Clear out wifi security keys */ - svSetValue (ifcfg, "KEY_MGMT", NULL, FALSE); - svSetValue (ifcfg, "IEEE_8021X_IDENTITY", NULL, FALSE); - set_secret (ifcfg, "IEEE_8021X_PASSWORD", NULL, "IEEE_8021X_PASSWORD_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - svSetValue (ifcfg, "SECURITYMODE", NULL, FALSE); - - /* Clear existing keys */ - set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - for (i = 0; i < 4; i++) { - tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - g_free (tmp); - - tmp = g_strdup_printf ("KEY%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - g_free (tmp); - } - - svSetValue (ifcfg, "DEFAULTKEY", NULL, FALSE); - svSetValue (ifcfg, "WPA_ALLOW_WPA", NULL, FALSE); - svSetValue (ifcfg, "WPA_ALLOW_WPA2", NULL, FALSE); - svSetValue (ifcfg, "CIPHER_PAIRWISE", NULL, FALSE); - svSetValue (ifcfg, "CIPHER_GROUP", NULL, FALSE); - set_secret (ifcfg, "WPA_PSK", NULL, "WPA_PSK_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - - /* Kill any old keys file */ - keys_path = utils_get_keys_path (ifcfg->fileName); - (void) unlink (keys_path); - g_free (keys_path); - } - - svSetValue (ifcfg, "SSID_HIDDEN", nm_setting_wireless_get_hidden (s_wireless) ? "yes" : NULL, TRUE); - - switch (nm_setting_wireless_get_powersave (s_wireless)) { - case NM_SETTING_WIRELESS_POWERSAVE_IGNORE: - svSetValue (ifcfg, "POWERSAVE", "ignore", TRUE); - break; - case NM_SETTING_WIRELESS_POWERSAVE_DISABLE: - svSetValue (ifcfg, "POWERSAVE", "disable", TRUE); - break; - case NM_SETTING_WIRELESS_POWERSAVE_ENABLE: - svSetValue (ifcfg, "POWERSAVE", "enable", TRUE); - break; - default: - case NM_SETTING_WIRELESS_POWERSAVE_DEFAULT: - svSetValue (ifcfg, "POWERSAVE", NULL, TRUE); - break; - } - - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", NULL, TRUE); - switch (nm_setting_wireless_get_mac_address_randomization (s_wireless)) { - case NM_SETTING_MAC_RANDOMIZATION_DEFAULT: - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "default", TRUE); - break; - case NM_SETTING_MAC_RANDOMIZATION_ALWAYS: - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "always", TRUE); - break; - default: - case NM_SETTING_MAC_RANDOMIZATION_NEVER: - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "never", TRUE); - break; - } - - svSetValue (ifcfg, "TYPE", TYPE_WIRELESS, FALSE); - - return TRUE; -} - -static gboolean -write_infiniband_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingInfiniband *s_infiniband; - char *tmp; - const char *mac, *transport_mode, *parent; - guint32 mtu; - int p_key; - - s_infiniband = nm_connection_get_setting_infiniband (connection); - if (!s_infiniband) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing '%s' setting", NM_SETTING_INFINIBAND_SETTING_NAME); - return FALSE; - } - - mac = nm_setting_infiniband_get_mac_address (s_infiniband); - svSetValue (ifcfg, "HWADDR", mac, FALSE); - - svSetValue (ifcfg, "MTU", NULL, FALSE); - mtu = nm_setting_infiniband_get_mtu (s_infiniband); - if (mtu) { - tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); - g_free (tmp); - } - - transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband); - svSetValue (ifcfg, "CONNECTED_MODE", - strcmp (transport_mode, "connected") == 0 ? "yes" : "no", - FALSE); - - p_key = nm_setting_infiniband_get_p_key (s_infiniband); - if (p_key != -1) { - svSetValue (ifcfg, "PKEY", "yes", FALSE); - tmp = g_strdup_printf ("%u", p_key); - svSetValue (ifcfg, "PKEY_ID", tmp, FALSE); - g_free (tmp); - - parent = nm_setting_infiniband_get_parent (s_infiniband); - if (parent) - svSetValue (ifcfg, "PHYSDEV", parent, FALSE); - } - - svSetValue (ifcfg, "TYPE", TYPE_INFINIBAND, FALSE); - - return TRUE; -} - -static gboolean -write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingWired *s_wired; - const char *device_mac, *cloned_mac; - char *tmp; - const char *nettype, *portname, *ctcprot, *s390_key, *s390_val; - guint32 mtu, num_opts, i; - const char *const *s390_subchannels; - GString *str; - const char * const *macaddr_blacklist; - NMSettingWiredWakeOnLan wol; - const char *wol_password; - - s_wired = nm_connection_get_setting_wired (connection); - if (!s_wired) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing '%s' setting", NM_SETTING_WIRED_SETTING_NAME); - return FALSE; - } - - device_mac = nm_setting_wired_get_mac_address (s_wired); - svSetValue (ifcfg, "HWADDR", device_mac, FALSE); - - cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); - - svSetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", - nm_setting_wired_get_generate_mac_address_mask (s_wired), - FALSE); - - svSetValue (ifcfg, "HWADDR_BLACKLIST", NULL, FALSE); - macaddr_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired); - if (macaddr_blacklist[0]) { - char *blacklist_str; - - blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); - svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str, FALSE); - g_free (blacklist_str); - } - - svSetValue (ifcfg, "MTU", NULL, FALSE); - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) { - tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); - g_free (tmp); - } - - svSetValue (ifcfg, "SUBCHANNELS", NULL, FALSE); - s390_subchannels = nm_setting_wired_get_s390_subchannels (s_wired); - if (s390_subchannels) { - int len = g_strv_length ((char **)s390_subchannels); - - tmp = NULL; - if (len == 2) { - tmp = g_strdup_printf ("%s,%s", s390_subchannels[0], s390_subchannels[1]); - } else if (len == 3) { - tmp = g_strdup_printf ("%s,%s,%s", s390_subchannels[0], s390_subchannels[1], - s390_subchannels[2]); - } - svSetValue (ifcfg, "SUBCHANNELS", tmp, FALSE); - g_free (tmp); - } - - svSetValue (ifcfg, "NETTYPE", NULL, FALSE); - nettype = nm_setting_wired_get_s390_nettype (s_wired); - if (nettype) - svSetValue (ifcfg, "NETTYPE", nettype, FALSE); - - svSetValue (ifcfg, "PORTNAME", NULL, FALSE); - portname = nm_setting_wired_get_s390_option_by_key (s_wired, "portname"); - if (portname) - svSetValue (ifcfg, "PORTNAME", portname, FALSE); - - svSetValue (ifcfg, "CTCPROT", NULL, FALSE); - ctcprot = nm_setting_wired_get_s390_option_by_key (s_wired, "ctcprot"); - if (ctcprot) - svSetValue (ifcfg, "CTCPROT", ctcprot, FALSE); - - svSetValue (ifcfg, "OPTIONS", NULL, FALSE); - num_opts = nm_setting_wired_get_num_s390_options (s_wired); - if (s390_subchannels && num_opts) { - str = g_string_sized_new (30); - for (i = 0; i < num_opts; i++) { - nm_setting_wired_get_s390_option (s_wired, i, &s390_key, &s390_val); - - /* portname is handled separately */ - if (!strcmp (s390_key, "portname") || !strcmp (s390_key, "ctcprot")) - continue; - - if (str->len) - g_string_append_c (str, ' '); - g_string_append_printf (str, "%s=%s", s390_key, s390_val); - } - if (str->len) - svSetValue (ifcfg, "OPTIONS", str->str, FALSE); - g_string_free (str, TRUE); - } - - wol = nm_setting_wired_get_wake_on_lan (s_wired); - wol_password = nm_setting_wired_get_wake_on_lan_password (s_wired); - if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE) - svSetValueFull (ifcfg, "ETHTOOL_OPTS", "", FALSE); - else if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) - svSetValue (ifcfg, "ETHTOOL_OPTS", NULL, FALSE); - else { - str = g_string_sized_new (30); - g_string_append (str, "wol "); - - if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_PHY)) - g_string_append (str, "p"); - if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST)) - g_string_append (str, "u"); - if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST)) - g_string_append (str, "m"); - if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST)) - g_string_append (str, "b"); - if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ARP)) - g_string_append (str, "a"); - if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) - g_string_append (str, "g"); - - if (!NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ALL)) - g_string_append (str, "d"); - - if (wol_password && NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) - g_string_append_printf (str, "s sopass %s", wol_password); - - svSetValue (ifcfg, "ETHTOOL_OPTS", str->str, FALSE); - g_string_free (str, TRUE); - } - - svSetValue (ifcfg, "TYPE", TYPE_ETHERNET, FALSE); - - return TRUE; -} - -static char * -vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap map) -{ - char **strlist; - char *value; - - if (map == NM_VLAN_INGRESS_MAP) - g_object_get (G_OBJECT (s_vlan), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, &strlist, NULL); - else if (map == NM_VLAN_EGRESS_MAP) - g_object_get (G_OBJECT (s_vlan), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, &strlist, NULL); - else - return NULL; - - if (strlist[0]) - value = g_strjoinv (",", strlist); - else - value = NULL; - g_strfreev (strlist); - - return value; -} - -static gboolean -write_wired_for_virtual (NMConnection *connection, shvarFile *ifcfg) -{ - NMSettingWired *s_wired; - gboolean has_wired = FALSE; - - s_wired = nm_connection_get_setting_wired (connection); - if (s_wired) { - const char *device_mac, *cloned_mac; - char *tmp; - guint32 mtu; - - has_wired = TRUE; - - device_mac = nm_setting_wired_get_mac_address (s_wired); - svSetValue (ifcfg, "HWADDR", device_mac, FALSE); - - cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); - - svSetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", - nm_setting_wired_get_generate_mac_address_mask (s_wired), - FALSE); - - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) { - tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); - g_free (tmp); - } else - svSetValue (ifcfg, "MTU", NULL, FALSE); - } - return has_wired; -} - -static gboolean -write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) -{ - NMSettingVlan *s_vlan; - NMSettingConnection *s_con; - char *tmp; - guint32 vlan_flags = 0; - gsize s_buf_len; - char s_buf[50], *s_buf_ptr; - - s_con = nm_connection_get_setting_connection (connection); - if (!s_con) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing connection setting"); - return FALSE; - } - - s_vlan = nm_connection_get_setting_vlan (connection); - if (!s_vlan) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing VLAN setting"); - return FALSE; - } - - svSetValue (ifcfg, "VLAN", "yes", FALSE); - svSetValue (ifcfg, "TYPE", TYPE_VLAN, FALSE); - svSetValue (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con), FALSE); - svSetValue (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan), FALSE); - - tmp = g_strdup_printf ("%d", nm_setting_vlan_get_id (s_vlan)); - svSetValue (ifcfg, "VLAN_ID", tmp, FALSE); - g_free (tmp); - - vlan_flags = nm_setting_vlan_get_flags (s_vlan); - if (vlan_flags & NM_VLAN_FLAG_REORDER_HEADERS) - svSetValue (ifcfg, "REORDER_HDR", "yes", FALSE); - else - svSetValue (ifcfg, "REORDER_HDR", "no", FALSE); - - svSetValue (ifcfg, "GVRP", vlan_flags & NM_VLAN_FLAG_GVRP ? "yes" : "no", FALSE); - - nm_utils_strbuf_init (s_buf, &s_buf_ptr, &s_buf_len); - - if (NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_LOOSE_BINDING)) - nm_utils_strbuf_append_str (&s_buf_ptr, &s_buf_len, "LOOSE_BINDING"); - if (!NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)) - nm_utils_strbuf_append (&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : ""); - - svSetValue (ifcfg, "VLAN_FLAGS", s_buf, FALSE); - - svSetValue (ifcfg, "MVRP", vlan_flags & NM_VLAN_FLAG_MVRP ? "yes" : "no", FALSE); - - tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_INGRESS_MAP); - svSetValue (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", tmp, FALSE); - g_free (tmp); - - tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_EGRESS_MAP); - svSetValue (ifcfg, "VLAN_EGRESS_PRIORITY_MAP", tmp, FALSE); - g_free (tmp); - - svSetValue (ifcfg, "HWADDR", NULL, FALSE); - svSetValue (ifcfg, "MACADDR", NULL, FALSE); - svSetValue (ifcfg, "MTU", NULL, FALSE); - - *wired = write_wired_for_virtual (connection, ifcfg); - - return TRUE; -} - -static gboolean -write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) -{ - NMSettingBond *s_bond; - const char *iface; - guint32 i, num_opts; - - s_bond = nm_connection_get_setting_bond (connection); - if (!s_bond) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing '%s' setting", NM_SETTING_BOND_SETTING_NAME); - return FALSE; - } - - iface = nm_connection_get_interface_name (connection); - if (!iface) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing interface name"); - return FALSE; - } - - svSetValue (ifcfg, "DEVICE", iface, FALSE); - svSetValue (ifcfg, "BONDING_OPTS", NULL, FALSE); - - num_opts = nm_setting_bond_get_num_options (s_bond); - if (num_opts > 0) { - GString *str = g_string_sized_new (64); - - for (i = 0; i < nm_setting_bond_get_num_options (s_bond); i++) { - const char *key, *value; - - if (!nm_setting_bond_get_option (s_bond, i, &key, &value)) - continue; - - if (str->len) - g_string_append_c (str, ' '); - - g_string_append_printf (str, "%s=%s", key, value); - } - - if (str->len) - svSetValue (ifcfg, "BONDING_OPTS", str->str, FALSE); - - g_string_free (str, TRUE); - } - - svSetValue (ifcfg, "TYPE", TYPE_BOND, FALSE); - svSetValue (ifcfg, "BONDING_MASTER", "yes", FALSE); - - *wired = write_wired_for_virtual (connection, ifcfg); - - return TRUE; -} - -static gboolean -write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) -{ - NMSettingTeam *s_team; - const char *iface; - const char *config; - - s_team = nm_connection_get_setting_team (connection); - if (!s_team) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing '%s' setting", NM_SETTING_TEAM_SETTING_NAME); - return FALSE; - } - - iface = nm_connection_get_interface_name (connection); - if (!iface) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing interface name"); - return FALSE; - } - - svSetValue (ifcfg, "DEVICE", iface, FALSE); - config = nm_setting_team_get_config (s_team); - svSetValue (ifcfg, "TEAM_CONFIG", config, FALSE); - - *wired = write_wired_for_virtual (connection, ifcfg); - - return TRUE; -} - -static guint32 -get_setting_default_uint (NMSetting *setting, const char *prop) -{ - GParamSpec *pspec; - GValue val = G_VALUE_INIT; - guint32 ret = 0; - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), prop); - g_assert (pspec); - g_value_init (&val, pspec->value_type); - g_param_value_set_default (pspec, &val); - g_assert (G_VALUE_HOLDS_UINT (&val)); - ret = g_value_get_uint (&val); - g_value_unset (&val); - return ret; -} - -static gboolean -get_setting_default_boolean (NMSetting *setting, const char *prop) -{ - GParamSpec *pspec; - GValue val = G_VALUE_INIT; - gboolean ret = 0; - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), prop); - g_assert (pspec); - g_value_init (&val, pspec->value_type); - g_param_value_set_default (pspec, &val); - g_assert (G_VALUE_HOLDS_BOOLEAN (&val)); - ret = g_value_get_boolean (&val); - g_value_unset (&val); - return ret; -} - -static gboolean -write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingBridge *s_bridge; - const char *iface; - guint32 i; - gboolean b; - GString *opts; - const char *mac; - char *s; - - s_bridge = nm_connection_get_setting_bridge (connection); - if (!s_bridge) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing '%s' setting", NM_SETTING_BRIDGE_SETTING_NAME); - return FALSE; - } - - iface = nm_connection_get_interface_name (connection); - if (!iface) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing interface name"); - return FALSE; - } - - svSetValue (ifcfg, "DEVICE", iface, FALSE); - svSetValue (ifcfg, "BRIDGING_OPTS", NULL, FALSE); - svSetValue (ifcfg, "STP", "no", FALSE); - svSetValue (ifcfg, "DELAY", NULL, FALSE); - - mac = nm_setting_bridge_get_mac_address (s_bridge); - svSetValue (ifcfg, "MACADDR", mac, FALSE); - - /* Bridge options */ - opts = g_string_sized_new (32); - - if (nm_setting_bridge_get_stp (s_bridge)) { - svSetValue (ifcfg, "STP", "yes", FALSE); - - i = nm_setting_bridge_get_forward_delay (s_bridge); - if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_FORWARD_DELAY)) { - s = g_strdup_printf ("%u", i); - svSetValue (ifcfg, "DELAY", s, FALSE); - g_free (s); - } - - g_string_append_printf (opts, "priority=%u", nm_setting_bridge_get_priority (s_bridge)); - - i = nm_setting_bridge_get_hello_time (s_bridge); - if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_HELLO_TIME)) { - if (opts->len) - g_string_append_c (opts, ' '); - g_string_append_printf (opts, "hello_time=%u", i); - } - - i = nm_setting_bridge_get_max_age (s_bridge); - if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MAX_AGE)) { - if (opts->len) - g_string_append_c (opts, ' '); - g_string_append_printf (opts, "max_age=%u", i); - } - } - - i = nm_setting_bridge_get_ageing_time (s_bridge); - if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_AGEING_TIME)) { - if (opts->len) - g_string_append_c (opts, ' '); - g_string_append_printf (opts, "ageing_time=%u", i); - } - - b = nm_setting_bridge_get_multicast_snooping (s_bridge); - if (b != get_setting_default_boolean (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MULTICAST_SNOOPING)) { - if (opts->len) - g_string_append_c (opts, ' '); - g_string_append_printf (opts, "multicast_snooping=%u", (guint32) b); - } - - if (opts->len) - svSetValue (ifcfg, "BRIDGING_OPTS", opts->str, FALSE); - g_string_free (opts, TRUE); - - svSetValue (ifcfg, "TYPE", TYPE_BRIDGE, FALSE); - - return TRUE; -} - -static gboolean -write_bridge_port_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingBridgePort *s_port; - guint32 i; - GString *opts; - - s_port = nm_connection_get_setting_bridge_port (connection); - if (!s_port) - return TRUE; - - svSetValue (ifcfg, "BRIDGING_OPTS", NULL, FALSE); - - /* Bridge options */ - opts = g_string_sized_new (32); - - i = nm_setting_bridge_port_get_priority (s_port); - if (i != get_setting_default_uint (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PRIORITY)) - g_string_append_printf (opts, "priority=%u", i); - - i = nm_setting_bridge_port_get_path_cost (s_port); - if (i != get_setting_default_uint (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PATH_COST)) { - if (opts->len) - g_string_append_c (opts, ' '); - g_string_append_printf (opts, "path_cost=%u", i); - } - - if (nm_setting_bridge_port_get_hairpin_mode (s_port)) { - if (opts->len) - g_string_append_c (opts, ' '); - g_string_append_printf (opts, "hairpin_mode=1"); - } - - if (opts->len) - svSetValue (ifcfg, "BRIDGING_OPTS", opts->str, FALSE); - g_string_free (opts, TRUE); - - return TRUE; -} - -static gboolean -write_team_port_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingTeamPort *s_port; - const char *config; - - s_port = nm_connection_get_setting_team_port (connection); - if (!s_port) - return TRUE; - - config = nm_setting_team_port_get_config (s_port); - svSetValue (ifcfg, "TEAM_PORT_CONFIG", config, FALSE); - - return TRUE; -} - -static void -write_dcb_flags (shvarFile *ifcfg, const char *tag, NMSettingDcbFlags flags) -{ - char *prop; - - prop = g_strdup_printf ("DCB_%s_ENABLE", tag); - svSetValue (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ENABLE) ? "yes" : NULL, FALSE); - g_free (prop); - - prop = g_strdup_printf ("DCB_%s_ADVERTISE", tag); - svSetValue (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ADVERTISE) ? "yes" : NULL, FALSE); - g_free (prop); - - prop = g_strdup_printf ("DCB_%s_WILLING", tag); - svSetValue (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_WILLING) ? "yes" : NULL, FALSE); - g_free (prop); -} - -static void -write_dcb_app (shvarFile *ifcfg, - const char *tag, - NMSettingDcbFlags flags, - gint priority) -{ - char *prop, *tmp = NULL; - - write_dcb_flags (ifcfg, tag, flags); - - if ((flags & NM_SETTING_DCB_FLAG_ENABLE) && (priority >= 0)) - tmp = g_strdup_printf ("%d", priority); - prop = g_strdup_printf ("DCB_%s_PRIORITY", tag); - svSetValue (ifcfg, prop, tmp, FALSE); - g_free (prop); - g_free (tmp); -} - -typedef gboolean (*DcbGetBoolFunc) (NMSettingDcb *, guint); - -static void -write_dcb_bool_array (shvarFile *ifcfg, - const char *key, - NMSettingDcb *s_dcb, - NMSettingDcbFlags flags, - DcbGetBoolFunc get_func) -{ - char str[9]; - guint i; - - if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - svSetValue (ifcfg, key, NULL, FALSE); - return; - } - - str[8] = 0; - for (i = 0; i < 8; i++) - str[i] = get_func (s_dcb, i) ? '1' : '0'; - svSetValue (ifcfg, key, str, FALSE); -} - -typedef guint (*DcbGetUintFunc) (NMSettingDcb *, guint); - -static void -write_dcb_uint_array (shvarFile *ifcfg, - const char *key, - NMSettingDcb *s_dcb, - NMSettingDcbFlags flags, - DcbGetUintFunc get_func) -{ - char str[9]; - guint i, num; - - if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - svSetValue (ifcfg, key, NULL, FALSE); - return; - } - - str[8] = 0; - for (i = 0; i < 8; i++) { - num = get_func (s_dcb, i); - if (num < 10) - str[i] = '0' + num; - else if (num == 15) - str[i] = 'f'; - else - g_assert_not_reached (); - } - svSetValue (ifcfg, key, str, FALSE); -} - -static void -write_dcb_percent_array (shvarFile *ifcfg, - const char *key, - NMSettingDcb *s_dcb, - NMSettingDcbFlags flags, - DcbGetUintFunc get_func) -{ - GString *str; - guint i; - - if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - svSetValue (ifcfg, key, NULL, FALSE); - return; - } - - str = g_string_sized_new (30); - for (i = 0; i < 8; i++) { - if (str->len) - g_string_append_c (str, ','); - g_string_append_printf (str, "%d", get_func (s_dcb, i)); - } - svSetValue (ifcfg, key, str->str, FALSE); - g_string_free (str, TRUE); -} - -static gboolean -write_dcb_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingDcb *s_dcb; - NMSettingDcbFlags flags; - - s_dcb = nm_connection_get_setting_dcb (connection); - if (!s_dcb) { - static const char *clear_keys[] = { - "DCB", - KEY_DCB_APP_FCOE_ENABLE, - KEY_DCB_APP_FCOE_ADVERTISE, - KEY_DCB_APP_FCOE_WILLING, - KEY_DCB_APP_FCOE_MODE, - KEY_DCB_APP_ISCSI_ENABLE, - KEY_DCB_APP_ISCSI_ADVERTISE, - KEY_DCB_APP_ISCSI_WILLING, - KEY_DCB_APP_FIP_ENABLE, - KEY_DCB_APP_FIP_ADVERTISE, - KEY_DCB_APP_FIP_WILLING, - KEY_DCB_PFC_ENABLE, - KEY_DCB_PFC_ADVERTISE, - KEY_DCB_PFC_WILLING, - KEY_DCB_PFC_UP, - KEY_DCB_PG_ENABLE, - KEY_DCB_PG_ADVERTISE, - KEY_DCB_PG_WILLING, - KEY_DCB_PG_ID, - KEY_DCB_PG_PCT, - KEY_DCB_PG_UPPCT, - KEY_DCB_PG_STRICT, - KEY_DCB_PG_UP2TC, - NULL }; - const char **iter; - - for (iter = clear_keys; *iter; iter++) - svSetValue (ifcfg, *iter, NULL, FALSE); - return TRUE; - } - - svSetValue (ifcfg, "DCB", "yes", FALSE); - - write_dcb_app (ifcfg, "APP_FCOE", - nm_setting_dcb_get_app_fcoe_flags (s_dcb), - nm_setting_dcb_get_app_fcoe_priority (s_dcb)); - if (nm_setting_dcb_get_app_fcoe_flags (s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) - svSetValue (ifcfg, KEY_DCB_APP_FCOE_MODE, nm_setting_dcb_get_app_fcoe_mode (s_dcb), FALSE); - else - svSetValue (ifcfg, KEY_DCB_APP_FCOE_MODE, NULL, FALSE); - - write_dcb_app (ifcfg, "APP_ISCSI", - nm_setting_dcb_get_app_iscsi_flags (s_dcb), - nm_setting_dcb_get_app_iscsi_priority (s_dcb)); - write_dcb_app (ifcfg, "APP_FIP", - nm_setting_dcb_get_app_fip_flags (s_dcb), - nm_setting_dcb_get_app_fip_priority (s_dcb)); - - write_dcb_flags (ifcfg, "PFC", nm_setting_dcb_get_priority_flow_control_flags (s_dcb)); - write_dcb_bool_array (ifcfg, KEY_DCB_PFC_UP, s_dcb, - nm_setting_dcb_get_priority_flow_control_flags (s_dcb), - nm_setting_dcb_get_priority_flow_control); - - flags = nm_setting_dcb_get_priority_group_flags (s_dcb); - write_dcb_flags (ifcfg, "PG", flags); - write_dcb_uint_array (ifcfg, KEY_DCB_PG_ID, s_dcb, flags, nm_setting_dcb_get_priority_group_id); - write_dcb_percent_array (ifcfg, KEY_DCB_PG_PCT, s_dcb, flags, nm_setting_dcb_get_priority_group_bandwidth); - write_dcb_percent_array (ifcfg, KEY_DCB_PG_UPPCT, s_dcb, flags, nm_setting_dcb_get_priority_bandwidth); - write_dcb_bool_array (ifcfg, KEY_DCB_PG_STRICT, s_dcb, flags, nm_setting_dcb_get_priority_strict_bandwidth); - write_dcb_uint_array (ifcfg, KEY_DCB_PG_UP2TC, s_dcb, flags, nm_setting_dcb_get_priority_traffic_class); - - return TRUE; -} - -static void -write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) -{ - guint32 n, i; - GString *str; - const char *master, *type; - char *tmp; - gint i_int; - const char *v_master = NULL; - const char *v_slave = NULL; - const char *v_bridge = NULL; - const char *v_team_master = NULL; - - svSetValue (ifcfg, "NAME", nm_setting_connection_get_id (s_con), FALSE); - svSetValue (ifcfg, "UUID", nm_setting_connection_get_uuid (s_con), FALSE); - svSetValue (ifcfg, "STABLE_ID", nm_setting_connection_get_stable_id (s_con), FALSE); - svSetValue (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con), FALSE); - svSetValue (ifcfg, "ONBOOT", - nm_setting_connection_get_autoconnect (s_con) ? "yes" : "no", - FALSE); - - i_int = nm_setting_connection_get_autoconnect_priority (s_con); - tmp = i_int != NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT - ? g_strdup_printf ("%d", i_int) : NULL; - svSetValue (ifcfg, "AUTOCONNECT_PRIORITY", tmp, FALSE); - g_free (tmp); - - /* Only save the value for master connections */ - svSetValue (ifcfg, "AUTOCONNECT_SLAVES", NULL, FALSE); - type = nm_setting_connection_get_connection_type (s_con); - if ( !g_strcmp0 (type, NM_SETTING_BOND_SETTING_NAME) - || !g_strcmp0 (type, NM_SETTING_TEAM_SETTING_NAME) - || !g_strcmp0 (type, NM_SETTING_BRIDGE_SETTING_NAME)) { - NMSettingConnectionAutoconnectSlaves autoconnect_slaves; - autoconnect_slaves = nm_setting_connection_get_autoconnect_slaves (s_con); - svSetValue (ifcfg, "AUTOCONNECT_SLAVES", - autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES ? "yes" : - autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO ? "no" : NULL, - FALSE); - } - - switch (nm_setting_connection_get_lldp (s_con)) { - case NM_SETTING_CONNECTION_LLDP_ENABLE_RX: - tmp = "rx"; - break; - case NM_SETTING_CONNECTION_LLDP_DISABLE: - tmp = "no"; - break; - default: - tmp = NULL; - } - svSetValue (ifcfg, "LLDP", tmp, FALSE); - - /* Permissions */ - svSetValue (ifcfg, "USERS", NULL, FALSE); - n = nm_setting_connection_get_num_permissions (s_con); - if (n > 0) { - str = g_string_sized_new (n * 20); - - for (i = 0; i < n; i++) { - const char *puser = NULL; - - /* Items separated by space for consistency with eg - * IPV6ADDR_SECONDARIES and DOMAIN. - */ - if (str->len) - g_string_append_c (str, ' '); - - if (nm_setting_connection_get_permission (s_con, i, NULL, &puser, NULL)) - g_string_append (str, puser); - } - svSetValue (ifcfg, "USERS", str->str, FALSE); - g_string_free (str, TRUE); - } - - svSetValue (ifcfg, "ZONE", nm_setting_connection_get_zone(s_con), FALSE); - - master = nm_setting_connection_get_master (s_con); - if (master) { - if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BOND_SETTING_NAME)) { - v_master = master; - v_slave = "yes"; - } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BRIDGE_SETTING_NAME)) - v_bridge = master; - else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) { - v_team_master = master; - svSetValue (ifcfg, "TYPE", NULL, FALSE); - } - } - - svSetValue (ifcfg, "MASTER", v_master, FALSE); - svSetValue (ifcfg, "SLAVE", v_slave, FALSE); - svSetValue (ifcfg, "BRIDGE", v_bridge, FALSE); - svSetValue (ifcfg, "TEAM_MASTER", v_team_master, FALSE); - - if (nm_streq0 (type, NM_SETTING_TEAM_SETTING_NAME)) - svSetValue (ifcfg, "DEVICETYPE", TYPE_TEAM, FALSE); - else if (master && nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) - svSetValue (ifcfg, "DEVICETYPE", TYPE_TEAM_PORT, FALSE); - else - svSetValue (ifcfg, "DEVICETYPE", NULL, FALSE); - - /* secondary connection UUIDs */ - svSetValue (ifcfg, "SECONDARY_UUIDS", NULL, FALSE); - n = nm_setting_connection_get_num_secondaries (s_con); - if (n > 0) { - str = g_string_sized_new (n * 37); - - for (i = 0; i < n; i++) { - const char *uuid; - - /* Items separated by space for consistency with eg - * IPV6ADDR_SECONDARIES and DOMAIN. - */ - if (str->len) - g_string_append_c (str, ' '); - - if ((uuid = nm_setting_connection_get_secondary (s_con, i)) != NULL) - g_string_append (str, uuid); - } - svSetValue (ifcfg, "SECONDARY_UUIDS", str->str, FALSE); - g_string_free (str, TRUE); - } - - svSetValue (ifcfg, "GATEWAY_PING_TIMEOUT", NULL, FALSE); - if (nm_setting_connection_get_gateway_ping_timeout (s_con)) { - tmp = g_strdup_printf ("%" G_GUINT32_FORMAT, nm_setting_connection_get_gateway_ping_timeout (s_con)); - svSetValue (ifcfg, "GATEWAY_PING_TIMEOUT", tmp, FALSE); - g_free (tmp); - } - - switch (nm_setting_connection_get_metered (s_con)) { - case NM_METERED_YES: - svSetValue (ifcfg, "CONNECTION_METERED", "yes", FALSE); - break; - case NM_METERED_NO: - svSetValue (ifcfg, "CONNECTION_METERED", "no", FALSE); - break; - default: - svSetValue (ifcfg, "CONNECTION_METERED", NULL, FALSE); - } -} - -static gboolean -write_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError **error) -{ - const char *dest, *next_hop; - char **route_items; - char *route_contents; - NMIPRoute *route; - guint32 prefix; - gint64 metric; - guint32 i, num; - gboolean success = FALSE; - - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (s_ip4 != NULL, FALSE); - g_return_val_if_fail (error != NULL, FALSE); - g_return_val_if_fail (*error == NULL, FALSE); - - num = nm_setting_ip_config_get_num_routes (s_ip4); - if (num == 0) { - unlink (filename); - return TRUE; - } - - route_items = g_malloc0 (sizeof (char*) * (num + 1)); - for (i = 0; i < num; i++) { - route = nm_setting_ip_config_get_route (s_ip4, i); - - dest = nm_ip_route_get_dest (route); - prefix = nm_ip_route_get_prefix (route); - next_hop = nm_ip_route_get_next_hop (route); - metric = nm_ip_route_get_metric (route); - - if (metric == -1) - route_items[i] = g_strdup_printf ("%s/%u via %s\n", dest, prefix, next_hop); - else - route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", dest, prefix, next_hop, (guint32) metric); - } - route_items[num] = NULL; - route_contents = g_strjoinv (NULL, route_items); - g_strfreev (route_items); - - if (!g_file_set_contents (filename, route_contents, -1, NULL)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Writing route file '%s' failed", filename); - goto error; - } - - success = TRUE; - -error: - g_free (route_contents); - - return success; -} - -static gboolean -write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingIPConfig *s_ip4; - const char *value; - char *addr_key, *prefix_key, *netmask_key, *gw_key, *metric_key, *tmp; - char *route_path = NULL; - gint32 j; - guint32 i, n, num; - gint64 route_metric; - gint priority; - int timeout; - GString *searches; - const char *method = NULL; - - s_ip4 = nm_connection_get_setting_ip4_config (connection); - if (!s_ip4) { - /* slave-type: clear IPv4 settings. - * - * Some IPv4 setting related options are not cleared, - * for no strong reason. */ - svSetValue (ifcfg, "BOOTPROTO", NULL, FALSE); - - svSetValue (ifcfg, "IPADDR", NULL, FALSE); - svSetValue (ifcfg, "PREFIX", NULL, FALSE); - svSetValue (ifcfg, "NETMASK", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY", NULL, FALSE); - - svSetValue (ifcfg, "IPADDR0", NULL, FALSE); - svSetValue (ifcfg, "PREFIX0", NULL, FALSE); - svSetValue (ifcfg, "NETMASK0", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY0", NULL, FALSE); - return TRUE; - } - - method = nm_setting_ip_config_get_method (s_ip4); - - /* Missing IP4 setting is assumed to be DHCP */ - if (!method) - method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; - - if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { - int result; - - /* IPv4 disabled, clear IPv4 related parameters */ - svSetValue (ifcfg, "BOOTPROTO", NULL, FALSE); - for (j = -1; j < 256; j++) { - if (j == -1) { - addr_key = g_strdup ("IPADDR"); - prefix_key = g_strdup ("PREFIX"); - netmask_key = g_strdup ("NETMASK"); - gw_key = g_strdup ("GATEWAY"); - } else { - addr_key = g_strdup_printf ("IPADDR%d", j); - prefix_key = g_strdup_printf ("PREFIX%d", j); - netmask_key = g_strdup_printf ("NETMASK%d", j); - gw_key = g_strdup_printf ("GATEWAY%d", j); - } - - svSetValue (ifcfg, addr_key, NULL, FALSE); - svSetValue (ifcfg, prefix_key, NULL, FALSE); - svSetValue (ifcfg, netmask_key, NULL, FALSE); - svSetValue (ifcfg, gw_key, NULL, FALSE); - - g_free (addr_key); - g_free (prefix_key); - g_free (netmask_key); - g_free (gw_key); - } - - route_path = utils_get_route_path (ifcfg->fileName); - result = unlink (route_path); - g_free (route_path); - return TRUE; - } - - if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) - svSetValue (ifcfg, "BOOTPROTO", "dhcp", FALSE); - else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) - svSetValue (ifcfg, "BOOTPROTO", "none", FALSE); - else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) - svSetValue (ifcfg, "BOOTPROTO", "autoip", FALSE); - else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) - svSetValue (ifcfg, "BOOTPROTO", "shared", FALSE); - - /* Clear out un-numbered IP address fields */ - svSetValue (ifcfg, "IPADDR", NULL, FALSE); - svSetValue (ifcfg, "PREFIX", NULL, FALSE); - svSetValue (ifcfg, "NETMASK", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY", NULL, FALSE); - /* Clear out zero-indexed IP address fields */ - svSetValue (ifcfg, "IPADDR0", NULL, FALSE); - svSetValue (ifcfg, "PREFIX0", NULL, FALSE); - svSetValue (ifcfg, "NETMASK0", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY0", NULL, FALSE); - - /* Write out IPADDR, PREFIX, GATEWAY for current IP addresses - * without labels. Unset obsolete NETMASK. - */ - num = nm_setting_ip_config_get_num_addresses (s_ip4); - for (i = n = 0; i < num; i++) { - NMIPAddress *addr; - - addr = nm_setting_ip_config_get_address (s_ip4, i); - - if (i > 0) { - GVariant *label; - - label = nm_ip_address_get_attribute (addr, "label"); - if (label) - continue; - } - - if (n == 0) { - /* Instead of index 0 use un-numbered variables. - * It's needed for compatibility with ifup that only recognizes 'GATEAWAY' - * See https://bugzilla.redhat.com/show_bug.cgi?id=771673 - * and https://bugzilla.redhat.com/show_bug.cgi?id=1105770 - */ - addr_key = g_strdup ("IPADDR"); - prefix_key = g_strdup ("PREFIX"); - netmask_key = g_strdup ("NETMASK"); - gw_key = g_strdup ("GATEWAY"); - } else { - addr_key = g_strdup_printf ("IPADDR%d", n); - prefix_key = g_strdup_printf ("PREFIX%d", n); - netmask_key = g_strdup_printf ("NETMASK%d", n); - gw_key = g_strdup_printf ("GATEWAY%d", n); - } - - svSetValue (ifcfg, addr_key, nm_ip_address_get_address (addr), FALSE); - - tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); - svSetValue (ifcfg, prefix_key, tmp, FALSE); - g_free (tmp); - - svSetValue (ifcfg, netmask_key, NULL, FALSE); - svSetValue (ifcfg, gw_key, NULL, FALSE); - - g_free (addr_key); - g_free (prefix_key); - g_free (netmask_key); - g_free (gw_key); - n++; - } - - /* Clear remaining IPADDR, etc */ - for (; n < 256; n++) { - addr_key = g_strdup_printf ("IPADDR%d", n); - prefix_key = g_strdup_printf ("PREFIX%d", n); - netmask_key = g_strdup_printf ("NETMASK%d", n); - gw_key = g_strdup_printf ("GATEWAY%d", n); - - svSetValue (ifcfg, addr_key, NULL, FALSE); - svSetValue (ifcfg, prefix_key, NULL, FALSE); - svSetValue (ifcfg, netmask_key, NULL, FALSE); - svSetValue (ifcfg, gw_key, NULL, FALSE); - - g_free (addr_key); - g_free (prefix_key); - g_free (netmask_key); - g_free (gw_key); - } - - svSetValue (ifcfg, "GATEWAY", nm_setting_ip_config_get_gateway (s_ip4), FALSE); - - num = nm_setting_ip_config_get_num_dns (s_ip4); - for (i = 0; i < 254; i++) { - const char *dns; - - addr_key = g_strdup_printf ("DNS%d", i + 1); - - if (i >= num) - svSetValue (ifcfg, addr_key, NULL, FALSE); - else { - dns = nm_setting_ip_config_get_dns (s_ip4, i); - svSetValue (ifcfg, addr_key, dns, FALSE); - } - g_free (addr_key); - } - - num = nm_setting_ip_config_get_num_dns_searches (s_ip4); - if (num > 0) { - searches = g_string_new (NULL); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (searches, ' '); - g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip4, i)); - } - svSetValue (ifcfg, "DOMAIN", searches->str, FALSE); - g_string_free (searches, TRUE); - } else - svSetValue (ifcfg, "DOMAIN", NULL, FALSE); - - /* DEFROUTE; remember that it has the opposite meaning from never-default */ - svSetValue (ifcfg, "DEFROUTE", - nm_setting_ip_config_get_never_default (s_ip4) ? "no" : "yes", - FALSE); - - svSetValue (ifcfg, "PEERDNS", NULL, FALSE); - svSetValue (ifcfg, "PEERROUTES", NULL, FALSE); - svSetValue (ifcfg, "DHCP_CLIENT_ID", NULL, FALSE); - if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - svSetValue (ifcfg, "PEERDNS", - nm_setting_ip_config_get_ignore_auto_dns (s_ip4) ? "no" : "yes", - FALSE); - - svSetValue (ifcfg, "PEERROUTES", - nm_setting_ip_config_get_ignore_auto_routes (s_ip4) ? "no" : "yes", - FALSE); - - value = nm_setting_ip_config_get_dhcp_hostname (s_ip4); - if (value) - svSetValue (ifcfg, "DHCP_HOSTNAME", value, FALSE); - - value = nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)); - if (value) - svSetValue (ifcfg, "DHCP_FQDN", value, FALSE); - - /* Missing DHCP_SEND_HOSTNAME means TRUE, and we prefer not write it explicitly - * in that case, because it is NM-specific variable - */ - svSetValue (ifcfg, "DHCP_SEND_HOSTNAME", - nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) ? NULL : "no", - FALSE); - - value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)); - if (value) - svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE); - - timeout = nm_setting_ip_config_get_dhcp_timeout (s_ip4); - tmp = timeout ? g_strdup_printf ("%d", timeout) : NULL; - svSetValue (ifcfg, "IPV4_DHCP_TIMEOUT", tmp, FALSE); - g_free (tmp); - } - - svSetValue (ifcfg, "IPV4_FAILURE_FATAL", - nm_setting_ip_config_get_may_fail (s_ip4) ? "no" : "yes", - FALSE); - - route_metric = nm_setting_ip_config_get_route_metric (s_ip4); - tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL; - svSetValue (ifcfg, "IPV4_ROUTE_METRIC", tmp, FALSE); - g_free (tmp); - - /* Static routes - route- file */ - route_path = utils_get_route_path (ifcfg->fileName); - if (!route_path) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not get route file path for '%s'", ifcfg->fileName); - return FALSE; - } - - if (utils_has_route_file_new_syntax (route_path)) { - shvarFile *routefile; - - routefile = utils_get_route_ifcfg (ifcfg->fileName, TRUE); - if (!routefile) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not create route file '%s'", route_path); - g_free (route_path); - return FALSE; - } - g_free (route_path); - - num = nm_setting_ip_config_get_num_routes (s_ip4); - for (i = 0; i < 256; i++) { - char buf[INET_ADDRSTRLEN]; - NMIPRoute *route; - guint32 netmask; - gint64 metric; - - addr_key = g_strdup_printf ("ADDRESS%d", i); - netmask_key = g_strdup_printf ("NETMASK%d", i); - gw_key = g_strdup_printf ("GATEWAY%d", i); - metric_key = g_strdup_printf ("METRIC%d", i); - - if (i >= num) { - svSetValue (routefile, addr_key, NULL, FALSE); - svSetValue (routefile, netmask_key, NULL, FALSE); - svSetValue (routefile, gw_key, NULL, FALSE); - svSetValue (routefile, metric_key, NULL, FALSE); - } else { - route = nm_setting_ip_config_get_route (s_ip4, i); - - svSetValue (routefile, addr_key, nm_ip_route_get_dest (route), FALSE); - - memset (buf, 0, sizeof (buf)); - netmask = nm_utils_ip4_prefix_to_netmask (nm_ip_route_get_prefix (route)); - inet_ntop (AF_INET, (const void *) &netmask, &buf[0], sizeof (buf)); - svSetValue (routefile, netmask_key, &buf[0], FALSE); - - svSetValue (routefile, gw_key, nm_ip_route_get_next_hop (route), FALSE); - - memset (buf, 0, sizeof (buf)); - metric = nm_ip_route_get_metric (route); - if (metric == -1) - svSetValue (routefile, metric_key, NULL, FALSE); - else { - tmp = g_strdup_printf ("%u", (guint32) metric); - svSetValue (routefile, metric_key, tmp, FALSE); - g_free (tmp); - } - } - - g_free (addr_key); - g_free (netmask_key); - g_free (gw_key); - g_free (metric_key); - } - if (!svWriteFile (routefile, 0644, error)) { - svCloseFile (routefile); - return FALSE; - } - svCloseFile (routefile); - } else { - write_route_file_legacy (route_path, s_ip4, error); - g_free (route_path); - if (error && *error) - return FALSE; - } - - timeout = nm_setting_ip_config_get_dad_timeout (s_ip4); - if (timeout < 0) - svSetValue (ifcfg, "ARPING_WAIT", NULL, FALSE); - else if (timeout == 0) - svSetValue (ifcfg, "ARPING_WAIT", "0", FALSE); - else { - /* Round the value up to next integer */ - svSetValueInt64 (ifcfg, "ARPING_WAIT", (timeout - 1) / 1000 + 1); - } - - priority = nm_setting_ip_config_get_dns_priority (s_ip4); - if (priority) - svSetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", priority); - else - svSetValue (ifcfg, "IPV4_DNS_PRIORITY", NULL, FALSE); - - return TRUE; -} - -static void -write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) -{ - NMSettingIPConfig *s_ip4; - gs_free char *base_ifcfg_dir = NULL, *base_ifcfg_name = NULL; - const char*base_name; - int i, num, base_ifcfg_name_len, base_name_len; - GDir *dir; - - base_ifcfg_dir = g_path_get_dirname (base_ifcfg_path); - base_ifcfg_name = g_path_get_basename (base_ifcfg_path); - base_ifcfg_name_len = strlen (base_ifcfg_name); - if (!g_str_has_prefix (base_ifcfg_name, IFCFG_TAG)) - g_return_if_reached (); - base_name = base_ifcfg_name + strlen (IFCFG_TAG); - base_name_len = strlen (base_name); - - /* Remove all existing aliases for this file first */ - dir = g_dir_open (base_ifcfg_dir, 0, NULL); - if (dir) { - const char *item; - - while ((item = g_dir_read_name (dir))) { - char *full_path; - - if ( strncmp (item, base_ifcfg_name, base_ifcfg_name_len) != 0 - || item[base_ifcfg_name_len] != ':') - continue; - - full_path = g_build_filename (base_ifcfg_dir, item, NULL); - unlink (full_path); - g_free (full_path); - } - - g_dir_close (dir); - } - - s_ip4 = nm_connection_get_setting_ip4_config (connection); - if (!s_ip4) { - /* slave-type: no alias files */ - return; - } - - num = nm_setting_ip_config_get_num_addresses (s_ip4); - for (i = 0; i < num; i++) { - GVariant *label_var; - const char *label, *p; - char *path, *tmp; - NMIPAddress *addr; - shvarFile *ifcfg; - - addr = nm_setting_ip_config_get_address (s_ip4, i); - - label_var = nm_ip_address_get_attribute (addr, "label"); - if (!label_var) - continue; - label = g_variant_get_string (label_var, NULL); - if ( strncmp (label, base_name, base_name_len) != 0 - || label[base_name_len] != ':') - continue; - - for (p = label; *p; p++) { - if (!g_ascii_isalnum (*p) && *p != '_' && *p != ':') - break; - } - if (*p) - continue; - - path = g_strdup_printf ("%s%s", base_ifcfg_path, label + base_name_len); - ifcfg = svCreateFile (path); - g_free (path); - - svSetValue (ifcfg, "DEVICE", label, FALSE); - - addr = nm_setting_ip_config_get_address (s_ip4, i); - svSetValue (ifcfg, "IPADDR", nm_ip_address_get_address (addr), FALSE); - - tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); - svSetValue (ifcfg, "PREFIX", tmp, FALSE); - g_free (tmp); - - svWriteFile (ifcfg, 0644, NULL); - svCloseFile (ifcfg); - } -} - -static gboolean -write_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error) -{ - char **route_items; - char *route_contents; - NMIPRoute *route; - guint32 i, num; - gboolean success = FALSE; - - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (s_ip6 != NULL, FALSE); - g_return_val_if_fail (error != NULL, FALSE); - g_return_val_if_fail (*error == NULL, FALSE); - - num = nm_setting_ip_config_get_num_routes (s_ip6); - if (num == 0) { - unlink (filename); - return TRUE; - } - - route_items = g_malloc0 (sizeof (char*) * (num + 1)); - for (i = 0; i < num; i++) { - route = nm_setting_ip_config_get_route (s_ip6, i); - - if (nm_ip_route_get_metric (route) == -1) { - route_items[i] = g_strdup_printf ("%s/%u via %s\n", - nm_ip_route_get_dest (route), - nm_ip_route_get_prefix (route), - nm_ip_route_get_next_hop (route)); - } else { - route_items[i] = g_strdup_printf ("%s/%u via %s metric %u\n", - nm_ip_route_get_dest (route), - nm_ip_route_get_prefix (route), - nm_ip_route_get_next_hop (route), - (guint32) nm_ip_route_get_metric (route)); - } - } - route_items[num] = NULL; - route_contents = g_strjoinv (NULL, route_items); - g_strfreev (route_items); - - if (!g_file_set_contents (filename, route_contents, -1, NULL)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Writing route6 file '%s' failed", filename); - goto error; - } - - success = TRUE; - -error: - g_free (route_contents); - return success; -} - -static gboolean -write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingIPConfig *s_ip6; - NMSettingIPConfig *s_ip4; - const char *value; - char *addr_key; - char *tmp; - guint32 i, num, num4; - gint priority; - GString *searches; - NMIPAddress *addr; - const char *dns; - gint64 route_metric; - GString *ip_str1, *ip_str2, *ip_ptr; - char *route6_path; - NMSettingIP6ConfigAddrGenMode addr_gen_mode; - - s_ip6 = nm_connection_get_setting_ip6_config (connection); - if (!s_ip6) { - /* slave-type: clear IPv6 settings - * - * Some IPv6 setting related options are not cleared, - * for no strong reason. */ - svSetValue (ifcfg, "IPV6INIT", NULL, FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", NULL, FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - svSetValue (ifcfg, "IPV6_DEFROUTE", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PEERDNS", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PEERROUTES", NULL, FALSE); - svSetValue (ifcfg, "IPV6_FAILURE_FATAL", NULL, FALSE); - svSetValue (ifcfg, "IPV6_ROUTE_METRIC", NULL, FALSE); - svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", NULL, FALSE); - return TRUE; - } - - value = nm_setting_ip_config_get_method (s_ip6); - g_assert (value); - if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { - svSetValue (ifcfg, "IPV6INIT", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - return TRUE; - } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "yes", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { - const char *hostname; - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", "yes", FALSE); - hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6); - if (hostname) - svSetValue (ifcfg, "DHCP_HOSTNAME", hostname, FALSE); - } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - /* TODO */ - } - - /* Write out IP addresses */ - num = nm_setting_ip_config_get_num_addresses (s_ip6); - ip_str1 = g_string_new (NULL); - ip_str2 = g_string_new (NULL); - for (i = 0; i < num; i++) { - if (i == 0) - ip_ptr = ip_str1; - else - ip_ptr = ip_str2; - - addr = nm_setting_ip_config_get_address (s_ip6, i); - - if (i > 1) - g_string_append_c (ip_ptr, ' '); /* separate addresses in IPV6ADDR_SECONDARIES */ - g_string_append_printf (ip_ptr, "%s/%u", - nm_ip_address_get_address (addr), - nm_ip_address_get_prefix (addr)); - } - svSetValue (ifcfg, "IPV6ADDR", ip_str1->str, FALSE); - svSetValue (ifcfg, "IPV6ADDR_SECONDARIES", ip_str2->str, FALSE); - svSetValue (ifcfg, "IPV6_DEFAULTGW", nm_setting_ip_config_get_gateway (s_ip6), FALSE); - g_string_free (ip_str1, TRUE); - g_string_free (ip_str2, TRUE); - - /* Write out DNS - 'DNS' key is used both for IPv4 and IPv6 */ - s_ip4 = nm_connection_get_setting_ip4_config (connection); - num4 = s_ip4 ? nm_setting_ip_config_get_num_dns (s_ip4) : 0; /* from where to start with IPv6 entries */ - num = nm_setting_ip_config_get_num_dns (s_ip6); - for (i = 0; i < 254; i++) { - addr_key = g_strdup_printf ("DNS%d", i + num4 + 1); - - if (i >= num) - svSetValue (ifcfg, addr_key, NULL, FALSE); - else { - dns = nm_setting_ip_config_get_dns (s_ip6, i); - svSetValue (ifcfg, addr_key, dns, FALSE); - } - g_free (addr_key); - } - - /* Write out DNS domains - 'DOMAIN' key is shared for both IPv4 and IPv6 domains */ - num = nm_setting_ip_config_get_num_dns_searches (s_ip6); - if (num > 0) { - char *ip4_domains; - ip4_domains = svGetValue (ifcfg, "DOMAIN", FALSE); - searches = g_string_new (ip4_domains); - for (i = 0; i < num; i++) { - if (searches->len > 0) - g_string_append_c (searches, ' '); - g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip6, i)); - } - svSetValue (ifcfg, "DOMAIN", searches->str, FALSE); - g_string_free (searches, TRUE); - g_free (ip4_domains); - } - - /* handle IPV6_DEFROUTE */ - /* IPV6_DEFROUTE has the opposite meaning from 'never-default' */ - if (nm_setting_ip_config_get_never_default(s_ip6)) - svSetValue (ifcfg, "IPV6_DEFROUTE", "no", FALSE); - else - svSetValue (ifcfg, "IPV6_DEFROUTE", "yes", FALSE); - - svSetValue (ifcfg, "IPV6_PEERDNS", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PEERROUTES", NULL, FALSE); - if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - svSetValue (ifcfg, "IPV6_PEERDNS", - nm_setting_ip_config_get_ignore_auto_dns (s_ip6) ? "no" : "yes", - FALSE); - - svSetValue (ifcfg, "IPV6_PEERROUTES", - nm_setting_ip_config_get_ignore_auto_routes (s_ip6) ? "no" : "yes", - FALSE); - } - - svSetValue (ifcfg, "IPV6_FAILURE_FATAL", - nm_setting_ip_config_get_may_fail (s_ip6) ? "no" : "yes", - FALSE); - - route_metric = nm_setting_ip_config_get_route_metric (s_ip6); - tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL; - svSetValue (ifcfg, "IPV6_ROUTE_METRIC", tmp, FALSE); - g_free (tmp); - - /* IPv6 Privacy Extensions */ - svSetValue (ifcfg, "IPV6_PRIVACY", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", NULL, FALSE); - switch (nm_setting_ip6_config_get_ip6_privacy (NM_SETTING_IP6_CONFIG (s_ip6))){ - case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: - svSetValue (ifcfg, "IPV6_PRIVACY", "no", FALSE); - break; - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: - svSetValue (ifcfg, "IPV6_PRIVACY", "rfc3041", FALSE); - svSetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", "yes", FALSE); - break; - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: - svSetValue (ifcfg, "IPV6_PRIVACY", "rfc3041", FALSE); - break; - default: - break; - } - - /* IPv6 Address generation mode */ - addr_gen_mode = nm_setting_ip6_config_get_addr_gen_mode (NM_SETTING_IP6_CONFIG (s_ip6)); - if (addr_gen_mode != NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) { - tmp = nm_utils_enum_to_str (nm_setting_ip6_config_addr_gen_mode_get_type (), - addr_gen_mode); - svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", tmp, FALSE); - g_free (tmp); - } else { - svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", NULL, FALSE); - } - - /* IPv6 tokenized interface identifier */ - value = nm_setting_ip6_config_get_token (NM_SETTING_IP6_CONFIG (s_ip6)); - svSetValue (ifcfg, "IPV6_TOKEN", value, FALSE); - - priority = nm_setting_ip_config_get_dns_priority (s_ip6); - if (priority) - svSetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", priority); - else - svSetValue (ifcfg, "IPV6_DNS_PRIORITY", NULL, FALSE); - - /* Static routes go to route6- file */ - route6_path = utils_get_route6_path (ifcfg->fileName); - if (!route6_path) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not get route6 file path for '%s'", ifcfg->fileName); - goto error; - } - write_route6_file (route6_path, s_ip6, error); - g_free (route6_path); - if (error && *error) - goto error; - - return TRUE; - -error: - return FALSE; -} - -static void -add_dns_option (GPtrArray *array, const char *option) -{ - if (_nm_utils_dns_option_find_idx (array, option) < 0) - g_ptr_array_add (array, (gpointer) option); -} - -static gboolean -write_res_options (NMConnection *connection, shvarFile *ifcfg, GError **error) -{ - NMSettingIPConfig *s_ip6; - NMSettingIPConfig *s_ip4; - const char *method; - int i, num_options; - gs_unref_ptrarray GPtrArray *array = NULL; - GString *value; - - s_ip4 = nm_connection_get_setting_ip4_config (connection); - - if (!s_ip4) { - /* slave-type: clear res-options */ - svSetValue (ifcfg, "RES_OPTIONS", NULL, FALSE); - return TRUE; - } - - array = g_ptr_array_new (); - - method = nm_setting_ip_config_get_method (s_ip4); - if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { - num_options = nm_setting_ip_config_get_num_dns_options (s_ip4); - for (i = 0; i < num_options; i++) - add_dns_option (array, nm_setting_ip_config_get_dns_option (s_ip4, i)); - } - - s_ip6 = nm_connection_get_setting_ip6_config (connection); - method = nm_setting_ip_config_get_method (s_ip6); - if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { - num_options = nm_setting_ip_config_get_num_dns_options (s_ip6); - for (i = 0; i < num_options; i++) - add_dns_option (array, nm_setting_ip_config_get_dns_option (s_ip6, i)); - } - - if ( array->len > 0 - || nm_setting_ip_config_has_dns_options (s_ip4) - || nm_setting_ip_config_has_dns_options (s_ip6)) { - value = g_string_new (NULL); - for (i = 0; i < array->len; i++) { - if (i > 0) - g_string_append_c (value, ' '); - g_string_append (value, array->pdata[i]); - } - svSetValueFull (ifcfg, "RES_OPTIONS", value->str, FALSE); - g_string_free (value, TRUE); - } else - svSetValue (ifcfg, "RES_OPTIONS", NULL, FALSE); - - return TRUE; -} - -static char * -escape_id (const char *id) -{ - char *escaped = g_strdup (id); - char *p = escaped; - - /* Escape random stuff */ - while (*p) { - if (*p == ' ') - *p = '_'; - else if (strchr ("\\][|/=()!:", *p)) - *p = '-'; - p++; - } - - return escaped; -} - -static gboolean -write_connection (NMConnection *connection, - const char *ifcfg_dir, - const char *filename, - const char *keyfile, - char **out_filename, - GError **error) -{ - NMSettingConnection *s_con; - gboolean success = FALSE; - shvarFile *ifcfg = NULL; - char *ifcfg_name = NULL; - const char *type; - gboolean no_8021x = FALSE; - gboolean wired = FALSE; - - nm_assert (NM_IS_CONNECTION (connection)); - nm_assert (nm_connection_verify (connection, NULL)); - - if (!writer_can_write_connection (connection, error)) - return FALSE; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - if (filename) { - /* For existing connections, 'filename' should be full path to ifcfg file */ - ifcfg = svOpenFile (filename, error); - if (!ifcfg) - return FALSE; - - ifcfg_name = g_strdup (filename); - } else { - char *escaped; - - escaped = escape_id (nm_setting_connection_get_id (s_con)); - ifcfg_name = g_strdup_printf ("%s/ifcfg-%s", ifcfg_dir, escaped); - - /* If a file with this path already exists then we need another name. - * Multiple connections can have the same ID (ie if two connections with - * the same ID are visible to different users) but of course can't have - * the same path. - */ - if (g_file_test (ifcfg_name, G_FILE_TEST_EXISTS)) { - guint32 idx = 0; - - g_free (ifcfg_name); - while (idx++ < 500) { - ifcfg_name = g_strdup_printf ("%s/ifcfg-%s-%u", ifcfg_dir, escaped, idx); - if (g_file_test (ifcfg_name, G_FILE_TEST_EXISTS) == FALSE) - break; - g_free (ifcfg_name); - ifcfg_name = NULL; - } - } - g_free (escaped); - - if (ifcfg_name == NULL) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Failed to find usable ifcfg file name"); - return FALSE; - } - - ifcfg = svCreateFile (ifcfg_name); - } - - type = nm_setting_connection_get_connection_type (s_con); - if (!type) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Missing connection type!"); - goto out; - } - - if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { - // FIXME: can't write PPPoE at this time - if (nm_connection_get_setting_pppoe (connection)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Can't write connection type '%s'", - NM_SETTING_PPPOE_SETTING_NAME); - goto out; - } - - if (!write_wired_setting (connection, ifcfg, error)) - goto out; - wired = TRUE; - } else if (!strcmp (type, NM_SETTING_VLAN_SETTING_NAME)) { - if (!write_vlan_setting (connection, ifcfg, &wired, error)) - goto out; - } else if (!strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME)) { - if (!write_wireless_setting (connection, ifcfg, &no_8021x, error)) - goto out; - } else if (!strcmp (type, NM_SETTING_INFINIBAND_SETTING_NAME)) { - if (!write_infiniband_setting (connection, ifcfg, error)) - goto out; - } else if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME)) { - if (!write_bonding_setting (connection, ifcfg, &wired, error)) - goto out; - } else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME)) { - if (!write_team_setting (connection, ifcfg, &wired, error)) - goto out; - } else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)) { - if (!write_bridge_setting (connection, ifcfg, error)) - goto out; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Can't write connection type '%s'", type); - goto out; - } - - if (!no_8021x) { - if (!write_8021x_setting (connection, ifcfg, wired, error)) - goto out; - } - - if (!write_bridge_port_setting (connection, ifcfg, error)) - goto out; - - if (!write_team_port_setting (connection, ifcfg, error)) - goto out; - - if (!write_dcb_setting (connection, ifcfg, error)) - goto out; - - svSetValue (ifcfg, "DHCP_HOSTNAME", NULL, FALSE); - svSetValue (ifcfg, "DHCP_FQDN", NULL, FALSE); - - if (!write_ip4_setting (connection, ifcfg, error)) - goto out; - write_ip4_aliases (connection, ifcfg_name); - - if (!write_ip6_setting (connection, ifcfg, error)) - goto out; - - if (!write_res_options (connection, ifcfg, error)) - goto out; - - write_connection_setting (s_con, ifcfg); - - if (!svWriteFile (ifcfg, 0644, error)) - goto out; - - /* Only return the filename if this was a newly written ifcfg */ - if (out_filename && !filename) - *out_filename = g_strdup (ifcfg_name); - - success = TRUE; - -out: - if (ifcfg) - svCloseFile (ifcfg); - g_free (ifcfg_name); - return success; -} - -gboolean -writer_can_write_connection (NMConnection *connection, GError **error) -{ - NMSettingConnection *s_con; - - if ( ( nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME) - && !nm_connection_get_setting_pppoe (connection)) - || nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME) - || nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME) - || nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME) - || nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME) - || nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME) - || nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) - return TRUE; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "The ifcfg-rh plugin cannot write the connection '%s' (type '%s' pppoe %d)", - nm_connection_get_id (connection), - nm_setting_connection_get_connection_type (s_con), - !!nm_connection_get_setting_pppoe (connection)); - return FALSE; -} - -gboolean -writer_new_connection (NMConnection *connection, - const char *ifcfg_dir, - char **out_filename, - GError **error) -{ - return write_connection (connection, ifcfg_dir, NULL, NULL, out_filename, error); -} - -gboolean -writer_update_connection (NMConnection *connection, - const char *ifcfg_dir, - const char *filename, - const char *keyfile, - GError **error) -{ - if (utils_has_complex_routes (filename)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Cannot modify a connection that has an associated 'rule-' or 'rule6-' file"); - return FALSE; - } - - return write_connection (connection, ifcfg_dir, filename, keyfile, NULL, error); -} - diff --git a/src/settings/plugins/ifcfg-rh/writer.h b/src/settings/plugins/ifcfg-rh/writer.h deleted file mode 100644 index 97a9f252..00000000 --- a/src/settings/plugins/ifcfg-rh/writer.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2009 Red Hat, Inc. - */ - -#ifndef _WRITER_H_ -#define _WRITER_H_ - -#include "nm-connection.h" - -gboolean writer_can_write_connection (NMConnection *connection, - GError **error); - -gboolean writer_new_connection (NMConnection *connection, - const char *ifcfg_dir, - char **out_filename, - GError **error); - -gboolean writer_update_connection (NMConnection *connection, - const char *ifcfg_dir, - const char *filename, - const char *keyfile, - GError **error); - -#endif /* _WRITER_H_ */ diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am deleted file mode 100644 index 68e80356..00000000 --- a/src/settings/plugins/ifnet/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -SUBDIRS = . tests - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -DSBINDIR=\"$(sbindir)\" - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifnet.la - -noinst_LTLIBRARIES = lib-ifnet-io.la - -libnm_settings_plugin_ifnet_la_SOURCES = \ - nm-ifnet-connection.c \ - nm-ifnet-connection.h \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifnet_la_LDFLAGS = -module -avoid-version - -libnm_settings_plugin_ifnet_la_LIBADD = lib-ifnet-io.la - -lib_ifnet_io_la_SOURCES = \ - net_parser.c\ - net_parser.h\ - connection_parser.c \ - connection_parser.h \ - net_utils.h\ - net_utils.c\ - wpa_parser.h\ - wpa_parser.c diff --git a/src/settings/plugins/ifnet/Makefile.in b/src/settings/plugins/ifnet/Makefile.in deleted file mode 100644 index a3b12364..00000000 --- a/src/settings/plugins/ifnet/Makefile.in +++ /dev/null @@ -1,987 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ifnet -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES) -lib_ifnet_io_la_LIBADD = -am_lib_ifnet_io_la_OBJECTS = net_parser.lo connection_parser.lo \ - net_utils.lo wpa_parser.lo -lib_ifnet_io_la_OBJECTS = $(am_lib_ifnet_io_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_ifnet_la_DEPENDENCIES = lib-ifnet-io.la -am_libnm_settings_plugin_ifnet_la_OBJECTS = nm-ifnet-connection.lo \ - plugin.lo -libnm_settings_plugin_ifnet_la_OBJECTS = \ - $(am_libnm_settings_plugin_ifnet_la_OBJECTS) -libnm_settings_plugin_ifnet_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_ifnet_la_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(lib_ifnet_io_la_SOURCES) \ - $(libnm_settings_plugin_ifnet_la_SOURCES) -DIST_SOURCES = $(lib_ifnet_io_la_SOURCES) \ - $(libnm_settings_plugin_ifnet_la_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = . tests -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifnet.la -noinst_LTLIBRARIES = lib-ifnet-io.la -libnm_settings_plugin_ifnet_la_SOURCES = \ - nm-ifnet-connection.c \ - nm-ifnet-connection.h \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifnet_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifnet_la_LIBADD = lib-ifnet-io.la -lib_ifnet_io_la_SOURCES = \ - net_parser.c\ - net_parser.h\ - connection_parser.c \ - connection_parser.h \ - net_utils.h\ - net_utils.c\ - wpa_parser.h\ - wpa_parser.c - -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifnet/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifnet/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -lib-ifnet-io.la: $(lib_ifnet_io_la_OBJECTS) $(lib_ifnet_io_la_DEPENDENCIES) $(EXTRA_lib_ifnet_io_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(lib_ifnet_io_la_OBJECTS) $(lib_ifnet_io_la_LIBADD) $(LIBS) - -libnm-settings-plugin-ifnet.la: $(libnm_settings_plugin_ifnet_la_OBJECTS) $(libnm_settings_plugin_ifnet_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ifnet_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_ifnet_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ifnet_la_OBJECTS) $(libnm_settings_plugin_ifnet_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_parser.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_parser.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ifnet-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpa_parser.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile $(LTLIBRARIES) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - clean-pkglibLTLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-pkglibLTLIBRARIES install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -DSBINDIR=\"$(sbindir)\" - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c deleted file mode 100644 index 9917463f..00000000 --- a/src/settings/plugins/ifnet/connection_parser.c +++ /dev/null @@ -1,2966 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-settings-plugin.h" -#include "nm-core-internal.h" -#include "NetworkManagerUtils.h" - -#include "net_utils.h" -#include "wpa_parser.h" -#include "connection_parser.h" -#include "nm-ifnet-connection.h" - -static char * -connection_id_from_ifnet_name (const char *conn_name) -{ - int name_len = strlen (conn_name); - - /* Convert a hex-encoded conn_name (only used for wifi SSIDs) to human-readable one */ - if ((name_len > 2) && (g_str_has_prefix (conn_name, "0x"))) { - GBytes *bytes = nm_utils_hexstr2bin (conn_name); - char *buf; - - if (bytes) { - buf = g_strndup (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes)); - g_bytes_unref (bytes); - return buf; - } - } - - return g_strdup (conn_name); -} - -static gboolean eap_simple_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error); - -static gboolean eap_tls_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error); - -static gboolean eap_peap_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error); - -static gboolean eap_ttls_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error); - -typedef struct { - const char *method; - gboolean (*reader) (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error); - gboolean wifi_phase2_only; -} EAPReader; - -static EAPReader eap_readers[] = { - {"md5", eap_simple_reader, TRUE}, - {"pwd", eap_simple_reader, TRUE}, - {"pap", eap_simple_reader, TRUE}, - {"chap", eap_simple_reader, TRUE}, - {"mschap", eap_simple_reader, TRUE}, - {"mschapv2", eap_simple_reader, TRUE}, - {"leap", eap_simple_reader, TRUE}, - {"tls", eap_tls_reader, FALSE}, - {"peap", eap_peap_reader, FALSE}, - {"ttls", eap_ttls_reader, FALSE}, - {NULL, NULL} -}; - -/* reading identity and password */ -static gboolean -eap_simple_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error) -{ - const char *value; - - /* identity */ - value = wpa_get_value (ssid, "identity"); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", - eap_method); - return FALSE; - } - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); - - /* password */ - value = wpa_get_value (ssid, "password"); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_PASSWORD for EAP method '%s'.", - eap_method); - return FALSE; - } - - g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, value, NULL); - - return TRUE; -} - -static char * -get_cert (const char *ssid, const char *key, const char *basepath) -{ - const char *orig; - - /* If it's a relative path, convert to absolute using 'basepath' */ - orig = wpa_get_value (ssid, key); - if (g_path_is_absolute (orig)) - return g_strdup (orig); - return g_strdup_printf ("%s/%s", basepath, orig); -} - -static gboolean -eap_tls_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error) -{ - const char *value; - char *ca_cert = NULL; - char *client_cert = NULL; - char *privkey = NULL; - const char *privkey_password = NULL; - gboolean success = FALSE; - NMSetting8021xCKFormat privkey_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - - /* identity */ - value = wpa_get_value (ssid, "identity"); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", - eap_method); - return FALSE; - } - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); - - /* ca cert */ - ca_cert = get_cert (ssid, phase2 ? "ca_cert2" : "ca_cert", basepath); - if (ca_cert) { - if (phase2) { - if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, - ca_cert, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, error)) - goto done; - } else { - if (!nm_setting_802_1x_set_ca_cert (s_8021x, - ca_cert, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, error)) - goto done; - } - } else { - nm_log_warn (LOGD_SETTINGS, " missing %s for EAP method '%s'; this is insecure!", - phase2 ? "IEEE_8021X_INNER_CA_CERT" : - "IEEE_8021X_CA_CERT", eap_method); - } - - /* Private key password */ - privkey_password = wpa_get_value (ssid, - phase2 ? "private_key2_passwd" : - "private_key_passwd"); - - if (!privkey_password) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing %s for EAP method '%s'.", - phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD" : - "IEEE_8021X_PRIVATE_KEY_PASSWORD", eap_method); - goto done; - } - - /* The private key itself */ - privkey = get_cert (ssid, phase2 ? "private_key2" : "private_key", basepath); - if (!privkey) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing %s for EAP method '%s'.", - phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" : - "IEEE_8021X_PRIVATE_KEY", eap_method); - goto done; - } - - if (phase2) { - if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, - privkey, - privkey_password, - NM_SETTING_802_1X_CK_SCHEME_PATH, - &privkey_format, - error)) - goto done; - } else { - if (!nm_setting_802_1x_set_private_key (s_8021x, - privkey, - privkey_password, - NM_SETTING_802_1X_CK_SCHEME_PATH, - &privkey_format, error)) - goto done; - } - - /* Only set the client certificate if the private key is not PKCS#12 format, - * as NM (due to supplicant restrictions) requires. If the key was PKCS#12, - * then nm_setting_802_1x_set_private_key() already set the client certificate - * to the same value as the private key. - */ - if (privkey_format == NM_SETTING_802_1X_CK_FORMAT_RAW_KEY - || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { - client_cert = get_cert (ssid, phase2 ? "client_cert2" : "client_cert", basepath); - if (!client_cert) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing %s for EAP method '%s'.", - phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : - "IEEE_8021X_CLIENT_CERT", eap_method); - goto done; - } - - if (phase2) { - if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, - client_cert, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, - error)) - goto done; - } else { - if (!nm_setting_802_1x_set_client_cert (s_8021x, - client_cert, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, error)) - goto done; - } - } - - success = TRUE; - -done: - g_free (ca_cert); - g_free (client_cert); - g_free (privkey); - return success; -} - -static gboolean -eap_peap_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error) -{ - char *ca_cert = NULL; - const char *inner_auth = NULL; - const char *peapver = NULL; - char **list = NULL, **iter, *lower; - gboolean success = FALSE; - - ca_cert = get_cert (ssid, "ca_cert", basepath); - if (ca_cert) { - if (!nm_setting_802_1x_set_ca_cert (s_8021x, - ca_cert, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, error)) - goto done; - } else { - nm_log_warn (LOGD_SETTINGS, " missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", - eap_method); - } - - peapver = wpa_get_value (ssid, "phase1"); - /* peap version, default is automatic */ - if (peapver && strstr (peapver, "peapver")) { - if (strstr (peapver, "peapver=0")) - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, - "0", NULL); - else if (strstr (peapver, "peapver=1")) - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, - "1", NULL); - else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown IEEE_8021X_PEAP_VERSION value '%s'", - peapver); - goto done; - } - } - - /* peaplabel */ - if (peapver && strstr (peapver, "peaplabel=1")) - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPLABEL, "1", - NULL); - - inner_auth = wpa_get_value (ssid, "phase2"); - if (!inner_auth) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_INNER_AUTH_METHODS."); - goto done; - } - /* Handle options for the inner auth method */ - list = g_strsplit (inner_auth, " ", 0); - for (iter = list; iter && *iter; iter++) { - gchar *pos = NULL; - - if (!strlen (*iter)) - continue; - - if (!(pos = strstr (*iter, "MSCHAPV2")) - || !(pos = strstr (*iter, "MD5")) - || !(pos = strstr (*iter, "GTC"))) { - if (!eap_simple_reader (pos, ssid, s_8021x, TRUE, basepath, error)) - goto done; - } else if (!(pos = strstr (*iter, "TLS"))) { - if (!eap_tls_reader (pos, ssid, s_8021x, TRUE, basepath, error)) - goto done; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", - *iter); - goto done; - } - - pos = strchr (*iter, '='); - if (pos && *pos) { - pos++; - lower = g_ascii_strdown (pos, -1); - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, lower, - NULL); - g_free (lower); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "No IEEE_8021X_INNER_AUTH_METHOD."); - goto done; - } - break; - } - - if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "No valid IEEE_8021X_INNER_AUTH_METHODS found."); - goto done; - } - - success = TRUE; - -done: - g_free (ca_cert); - if (list) - g_strfreev (list); - return success; -} - -static gboolean -eap_ttls_reader (const char *eap_method, - const char *ssid, - NMSetting8021x *s_8021x, - gboolean phase2, - const char *basepath, - GError **error) -{ - gboolean success = FALSE; - const char *anon_ident = NULL; - char *ca_cert = NULL; - const char *tmp; - char **list = NULL, **iter, *inner_auth = NULL; - - /* ca cert */ - ca_cert = get_cert (ssid, "ca_cert", basepath); - if (ca_cert) { - if (!nm_setting_802_1x_set_ca_cert (s_8021x, - ca_cert, - NM_SETTING_802_1X_CK_SCHEME_PATH, - NULL, error)) - goto done; - } else { - nm_log_warn (LOGD_SETTINGS, " missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", - eap_method); - } - - /* anonymous indentity for tls */ - anon_ident = wpa_get_value (ssid, "anonymous_identity"); - if (anon_ident && strlen (anon_ident)) - g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, - anon_ident, NULL); - - tmp = wpa_get_value (ssid, "phase2"); - if (!tmp) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_INNER_AUTH_METHODS."); - goto done; - } - - /* Handle options for the inner auth method */ - inner_auth = g_ascii_strdown (tmp, -1); - list = g_strsplit (inner_auth, " ", 0); - for (iter = list; iter && *iter; iter++) { - gchar *pos = NULL; - - if (!strlen (*iter)) - continue; - if ((pos = strstr (*iter, "mschapv2")) != NULL - || (pos = strstr (*iter, "mschap")) != NULL - || (pos = strstr (*iter, "pap")) != NULL - || (pos = strstr (*iter, "chap")) != NULL) { - if (!eap_simple_reader (pos, ssid, s_8021x, TRUE, basepath, error)) - goto done; - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, - pos, NULL); - } else if ((pos = strstr (*iter, "tls")) != NULL) { - if (!eap_tls_reader (pos, ssid, s_8021x, TRUE, basepath, error)) - goto done; - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, - "tls", NULL); - } else if ((pos = strstr (*iter, "mschapv2")) != NULL - || (pos = strstr (*iter, "md5")) != NULL) { - if (!eap_simple_reader (pos, ssid, s_8021x, TRUE, basepath, error)) { - nm_log_warn (LOGD_SETTINGS, "SIMPLE ERROR"); - goto done; - } - g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, - pos, NULL); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", - *iter); - goto done; - } - break; - } - - success = TRUE; -done: - g_free (ca_cert); - if (list) - g_strfreev (list); - g_free (inner_auth); - return success; -} - -/* type is already decided by net_parser, this function is just used to - * doing tansformation*/ -static const gchar * -guess_connection_type (const char *conn_name) -{ - const gchar *type = ifnet_get_data (conn_name, "type"); - const gchar *ret_type = NULL; - - if (!g_strcmp0 (type, "ppp")) - ret_type = NM_SETTING_PPPOE_SETTING_NAME; - - if (!g_strcmp0 (type, "wireless")) - ret_type = NM_SETTING_WIRELESS_SETTING_NAME; - - if (!ret_type) - ret_type = NM_SETTING_WIRED_SETTING_NAME; - - nm_log_info (LOGD_SETTINGS, "guessed connection type (%s) = %s", conn_name, ret_type); - return ret_type; -} - -/* Reading mac address for setting connection option. - * Unmanaged device mac address is required by NetworkManager*/ -static gboolean -read_mac_address (const char *conn_name, const char **mac, GError **error) -{ - const char *value = ifnet_get_data (conn_name, "mac"); - - if (!value || !strlen (value)) - return TRUE; - - if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "The MAC address '%s' was invalid.", value); - return FALSE; - } - - *mac = value; - return TRUE; -} - -static gboolean -make_wired_connection_setting (NMConnection *connection, - const char *conn_name, - GError **error) -{ - const char *mac = NULL; - NMSettingWired *s_wired = NULL; - const char *value = NULL; - - s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); - - /* mtu_xxx */ - value = ifnet_get_data (conn_name, "mtu"); - if (value) { - long int mtu; - - errno = 0; - mtu = strtol (value, NULL, 10); - if (errno || mtu < 0 || mtu > 65535) { - nm_log_warn (LOGD_SETTINGS, " invalid MTU '%s' for %s", value, conn_name); - } else - g_object_set (s_wired, NM_SETTING_WIRED_MTU, - (guint32) mtu, NULL); - } - - if (!read_mac_address (conn_name, &mac, error)) { - g_object_unref (s_wired); - return FALSE; - } - - if (mac) - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL); - nm_connection_add_setting (connection, NM_SETTING (s_wired)); - - return TRUE; -} - -/* add NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, - * NM_SETTING_IP_CONFIG_DHCP_CLIENT_ID in future*/ -static gboolean -make_ip4_setting (NMConnection *connection, - const char *conn_name, - GError **error) -{ - - NMSettingIPConfig *ip4_setting = - NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new ()); - const char *value, *method = NULL; - gboolean is_static_block = is_static_ip4 (conn_name); - ip_block *iblock = NULL; - - /* set dhcp options (dhcp_xxx) */ - value = ifnet_get_data (conn_name, "dhcp"); - g_object_set (ip4_setting, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, value - && strstr (value, "nodns") ? TRUE : FALSE, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, value - && strstr (value, "nogateway") ? TRUE : FALSE, NULL); - - if (!is_static_block) { - method = ifnet_get_data (conn_name, "config"); - if (!method){ - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown config for %s", conn_name); - g_object_unref (ip4_setting); - return FALSE; - } - if (strstr (method, "dhcp")) - g_object_set (ip4_setting, - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP4_CONFIG_METHOD_AUTO, - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL); - else if (strstr (method, "autoip")) { - g_object_set (ip4_setting, - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL, - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL); - nm_connection_add_setting (connection, NM_SETTING (ip4_setting)); - return TRUE; - } else if (strstr (method, "shared")) { - g_object_set (ip4_setting, - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP4_CONFIG_METHOD_SHARED, - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL); - nm_connection_add_setting (connection, NM_SETTING (ip4_setting)); - return TRUE; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown config for %s", conn_name); - g_object_unref (ip4_setting); - return FALSE; - } - nm_log_info (LOGD_SETTINGS, "Using %s method for %s", method, conn_name); - }else { - iblock = convert_ip4_config_block (conn_name); - if (!iblock) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ifnet plugin: can't aquire ip configuration for %s", - conn_name); - g_object_unref (ip4_setting); - return FALSE; - } - /************** add all ip settings to the connection**********/ - while (iblock) { - ip_block *current_iblock; - NMIPAddress *ip4_addr; - GError *local = NULL; - - ip4_addr = nm_ip_address_new (AF_INET, iblock->ip, iblock->prefix, &local); - if (iblock->next_hop) - g_object_set (ip4_setting, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, - TRUE, NULL); - - if (ip4_addr) { - if (!nm_setting_ip_config_add_address (ip4_setting, ip4_addr)) - nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP4 address"); - nm_ip_address_unref (ip4_addr); - } else { - nm_log_warn (LOGD_SETTINGS, " ignoring invalid address entry: %s", local->message); - g_clear_error (&local); - } - - current_iblock = iblock; - iblock = iblock->next; - destroy_ip_block (current_iblock); - - } - g_object_set (ip4_setting, - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, !has_default_ip4_route (conn_name), - NULL); - } - - /* add dhcp hostname and client id */ - if (!is_static_block && strstr (method, "dhcp")) { - gchar *dhcp_hostname, *client_id; - - get_dhcp_hostname_and_client_id (&dhcp_hostname, &client_id); - if (dhcp_hostname) { - g_object_set (ip4_setting, - NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, - dhcp_hostname, NULL); - nm_log_info (LOGD_SETTINGS, "DHCP hostname: %s", dhcp_hostname); - g_free (dhcp_hostname); - } - if (client_id) { - g_object_set (ip4_setting, - NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, - client_id, NULL); - nm_log_info (LOGD_SETTINGS, "DHCP client id: %s", client_id); - g_free (client_id); - } - } - - /* add all IPv4 dns servers, IPv6 servers will be ignored */ - set_ip4_dns_servers (ip4_setting, conn_name); - - /* DNS searches */ - value = ifnet_get_data (conn_name, "dns_search"); - if (value) { - gs_free char *stripped = g_strdup (value); - char **searches = NULL; - - strip_string (stripped, '"'); - - searches = g_strsplit (stripped, " ", 0); - if (searches) { - char **item; - - for (item = searches; *item; item++) { - if (strlen (*item)) { - if (!nm_setting_ip_config_add_dns_search (ip4_setting, *item)) - nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *item); - } - } - g_strfreev (searches); - } - } - - /* static routes */ - iblock = convert_ip4_routes_block (conn_name); - while (iblock) { - ip_block *current_iblock = iblock; - const char *metric_str; - char *stripped; - gint64 metric; - NMIPRoute *route; - GError *local = NULL; - - if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) { - metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); - } else { - metric_str = ifnet_get_global_data ("metric"); - if (metric_str) { - stripped = g_strdup (metric_str); - strip_string (stripped, '"'); - metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); - g_free (stripped); - } else - metric = -1; - } - - route = nm_ip_route_new (AF_INET, iblock->ip, iblock->prefix, iblock->next_hop, metric, &local); - if (route) { - if (nm_setting_ip_config_add_route (ip4_setting, route)) - nm_log_info (LOGD_SETTINGS, "new IP4 route:%s\n", iblock->ip); - else - nm_log_warn (LOGD_SETTINGS, "duplicate IP4 route"); - nm_ip_route_unref (route); - } else { - nm_log_warn (LOGD_SETTINGS, " ignoring invalid route entry: %s", local->message); - g_clear_error (&local); - } - - current_iblock = iblock; - iblock = iblock->next; - destroy_ip_block (current_iblock); - } - - /* Finally add setting to connection */ - nm_connection_add_setting (connection, NM_SETTING (ip4_setting)); - - return TRUE; -} - -static gboolean -make_ip6_setting (NMConnection *connection, - const char *conn_name, - GError **error) -{ - NMSettingIPConfig *s_ip6 = NULL; - gboolean is_static_block = is_static_ip6 (conn_name); - - // used to disable IPv6 - gboolean ipv6_enabled = FALSE; - gchar *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; - const char *value; - ip_block *iblock; - gboolean never_default = !has_default_ip6_route (conn_name); - - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - - value = ifnet_get_data (conn_name, "enable_ipv6"); - if (value && is_true (value)) - ipv6_enabled = TRUE; - - //FIXME Handle other methods that NM supports in future - // Currently only Manual and DHCP are supported - if (!ipv6_enabled) { - g_object_set (s_ip6, - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - goto done; - } else if (!is_static_block) { - // config_eth* contains "dhcp6" - method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; - never_default = FALSE; - } - // else if (!has_ip6_address(conn_name)) - // doesn't have "dhcp6" && doesn't have any ipv6 address - // method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; - else - // doesn't have "dhcp6" && has at least one ipv6 address - method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; - nm_log_info (LOGD_SETTINGS, "IPv6 for %s enabled, using %s", conn_name, method); - - g_object_set (s_ip6, - NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, FALSE, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, FALSE, - NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, NULL); - - /* Make manual settings */ - if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { - ip_block *current_iblock; - - iblock = convert_ip6_config_block (conn_name); - if (!iblock) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ifnet plugin: can't aquire ip6 configuration for %s", - conn_name); - goto error; - } - /* add all IPv6 addresses */ - while (iblock) { - NMIPAddress *ip6_addr; - GError *local = NULL; - - ip6_addr = nm_ip_address_new (AF_INET6, iblock->ip, iblock->prefix, &local); - if (ip6_addr) { - if (nm_setting_ip_config_add_address (s_ip6, ip6_addr)) { - nm_log_info (LOGD_SETTINGS, "ipv6 addresses count: %d", - nm_setting_ip_config_get_num_addresses (s_ip6)); - } else { - nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP6 address"); - } - nm_ip_address_unref (ip6_addr); - } else { - nm_log_warn (LOGD_SETTINGS, " ignoring invalid address entry: %s", local->message); - g_clear_error (&local); - } - - current_iblock = iblock; - iblock = iblock->next; - destroy_ip_block (current_iblock); - } - - } else if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - /* - autoconf or DHCPv6 stuff goes here */ - } - // DNS Servers, set NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS TRUE here - set_ip6_dns_servers (s_ip6, conn_name); - - /* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */ - - // Add routes - iblock = convert_ip6_routes_block (conn_name); - if (iblock) - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, - TRUE, NULL); - /* Add all IPv6 routes */ - while (iblock) { - ip_block *current_iblock = iblock; - const char *metric_str; - char *stripped; - gint64 metric; - NMIPRoute *route; - GError *local = NULL; - - /* metric is not per routes configuration right now - * global metric is also supported (metric="x") */ - if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) - metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); - else { - metric_str = ifnet_get_global_data ("metric"); - if (metric_str) { - stripped = g_strdup (metric_str); - strip_string (stripped, '"'); - metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); - g_free (stripped); - } else - metric = 1; - } - - route = nm_ip_route_new (AF_INET6, iblock->ip, iblock->prefix, iblock->next_hop, metric, &local); - if (route) { - if (nm_setting_ip_config_add_route (s_ip6, route)) - nm_log_info (LOGD_SETTINGS, " new IP6 route"); - else - nm_log_warn (LOGD_SETTINGS, " duplicate IP6 route"); - nm_ip_route_unref (route); - } else { - nm_log_warn (LOGD_SETTINGS, " ignoring invalid route entry: %s", local->message); - g_clear_error (&local); - } - - current_iblock = iblock; - iblock = iblock->next; - destroy_ip_block (current_iblock); - } - -done: - nm_connection_add_setting (connection, NM_SETTING (s_ip6)); - return TRUE; - -error: - g_object_unref (s_ip6); - nm_log_warn (LOGD_SETTINGS, " Ignore IPv6 for %s", conn_name); - return FALSE; -} - -static NMSetting * -make_wireless_connection_setting (const char *conn_name, - NMSetting8021x **s_8021x, - GError **error) -{ - const char *mac = NULL; - NMSettingWireless *wireless_setting = NULL; - gboolean adhoc = FALSE; - const char *value; - const char *type; - - /* PPP over WIFI is not supported yet */ - g_return_val_if_fail (conn_name != NULL - && strcmp (ifnet_get_data (conn_name, "type"), - "ppp") != 0, NULL); - type = ifnet_get_data (conn_name, "type"); - if (strcmp (type, "ppp") == 0) { - nm_log_warn (LOGD_SETTINGS, "PPP over WIFI is not supported yet"); - return NULL; - } - - wireless_setting = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); - if (read_mac_address (conn_name, &mac, error)) { - if (mac) { - g_object_set (wireless_setting, - NM_SETTING_WIRELESS_MAC_ADDRESS, mac, - NULL); - } - } else { - g_object_unref (wireless_setting); - return NULL; - } - - /* handle ssid (hex and ascii) */ - if (conn_name) { - GBytes *bytes; - gsize ssid_len = 0, value_len = strlen (conn_name); - - ssid_len = value_len; - if ((value_len > 2) && (g_str_has_prefix (conn_name, "0x"))) { - /* Hex representation */ - if (value_len % 2) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' size (looks like hex but length not multiple of 2)", - conn_name); - goto error; - } - - bytes = nm_utils_hexstr2bin (conn_name); - if (!bytes) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' (looks like hex SSID but isn't)", - conn_name); - goto error; - } - } else - bytes = g_bytes_new (conn_name, value_len); - - ssid_len = g_bytes_get_size (bytes); - if (ssid_len > 32 || ssid_len == 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", - conn_name, ssid_len); - goto error; - } - - g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, bytes, NULL); - g_bytes_unref (bytes); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing SSID"); - goto error; - } - - /* mode=0: infrastructure - * mode=1: adhoc */ - value = wpa_get_value (conn_name, "mode"); - if (value) - adhoc = strcmp (value, "1") == 0 ? TRUE : FALSE; - - if (exist_ssid (conn_name)) { - const char *mode = adhoc ? "adhoc" : "infrastructure"; - - g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, mode, - NULL); - nm_log_info (LOGD_SETTINGS, "Using mode: %s", mode); - } - - /* BSSID setting */ - value = wpa_get_value (conn_name, "bssid"); - if (value) { - if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid BSSID '%s'", value); - goto error; - } - - g_object_set (wireless_setting, NM_SETTING_WIRELESS_BSSID, - value, NULL); - - } - - /* mtu_ssid="xx" */ - value = ifnet_get_data (conn_name, "mtu"); - if (value) { - long int mtu; - - errno = 0; - mtu = strtol (value, NULL, 10); - if (errno || mtu < 0 || mtu > 50000) { - nm_log_warn (LOGD_SETTINGS, " invalid MTU '%s' for %s", value, conn_name); - } else - g_object_set (wireless_setting, NM_SETTING_WIRELESS_MTU, - (guint32) mtu, NULL); - - } - - nm_log_info (LOGD_SETTINGS, "wireless_setting added for %s", conn_name); - return NM_SETTING (wireless_setting); -error: - if (wireless_setting) - g_object_unref (wireless_setting); - return NULL; - -} - -static NMSettingWirelessSecurity * -make_leap_setting (const char *ssid, GError **error) -{ - NMSettingWirelessSecurity *wsec; - const char *value; - - wsec = - NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - - value = wpa_get_value (ssid, "password"); - if (value && strlen (value)) - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, - value, NULL); - - value = wpa_get_value (ssid, "identity"); - if (!value || !strlen (value)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing LEAP identity"); - goto error; - } - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, value, - NULL); - - g_object_set (wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", NULL); - - return wsec; -error: - if (wsec) - g_object_unref (wsec); - return NULL; -} - -static gboolean -add_one_wep_key (const char *ssid, - const char *key, - int key_idx, - NMSettingWirelessSecurity *s_wsec, - GError **error) -{ - const char *value; - char *converted = NULL; - gboolean success = FALSE; - - g_return_val_if_fail (ssid != NULL, FALSE); - g_return_val_if_fail (key != NULL, FALSE); - g_return_val_if_fail (key_idx >= 0 && key_idx <= 3, FALSE); - g_return_val_if_fail (s_wsec != NULL, FALSE); - - value = wpa_get_value (ssid, key); - if (!value) - return TRUE; - - /* Validate keys */ - if (strlen (value) == 10 || strlen (value) == 26) { - /* Hexadecimal WEP key */ - if (!is_hex (value)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid hexadecimal WEP key."); - goto out; - } - converted = g_strdup (value); - } else if (value[0] == '"' - && (strlen (value) == 7 || strlen (value) == 15)) { - /* ASCII passphrase */ - char *tmp = g_strdup (value); - char *p = strip_string (tmp, '"'); - - if (!is_ascii (p)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid ASCII WEP passphrase."); - g_free (tmp); - goto out; - - } - - converted = nm_utils_bin2hexstr (tmp, strlen (tmp), -1); - g_free (tmp); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WEP key length. Key: %s", value); - goto out; - } - - if (converted) { - nm_setting_wireless_security_set_wep_key (s_wsec, key_idx, converted); - g_free (converted); - success = TRUE; - } - -out: - return success; -} - -static gboolean -add_wep_keys (const char *ssid, - NMSettingWirelessSecurity *s_wsec, - GError **error) -{ - if (!add_one_wep_key (ssid, "wep_key0", 0, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ssid, "wep_key1", 1, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ssid, "wep_key2", 2, s_wsec, error)) - return FALSE; - if (!add_one_wep_key (ssid, "wep_key3", 3, s_wsec, error)) - return FALSE; - return TRUE; - -} - -static NMSettingWirelessSecurity * -make_wep_setting (const char *ssid, GError **error) -{ - const char *auth_alg, *value; - int default_key_idx = 0; - NMSettingWirelessSecurity *s_wireless_sec; - - s_wireless_sec = - NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - "none", NULL); - - /* default key index */ - value = wpa_get_value (ssid, "wep_tx_keyidx"); - if (value) { - default_key_idx = atoi (value); - if (default_key_idx >= 0 && default_key_idx <= 3) { - g_object_set (s_wireless_sec, - NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, - default_key_idx, NULL); - nm_log_info (LOGD_SETTINGS, "Default key index: %d", default_key_idx); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid default WEP key '%s'", value); - goto error; - } - } - - if (!add_wep_keys (ssid, s_wireless_sec, error)) - goto error; - - /* If there's a default key, ensure that key exists */ - if ((default_key_idx == 1) - && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Default WEP key index was 2, but no valid KEY2 exists."); - goto error; - } else if ((default_key_idx == 2) - && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, - 2)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Default WEP key index was 3, but no valid KEY3 exists."); - goto error; - } else if ((default_key_idx == 3) - && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, - 3)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Default WEP key index was 4, but no valid KEY4 exists."); - goto error; - } - - /* authentication algorithms */ - auth_alg = wpa_get_value (ssid, "auth_alg"); - if (auth_alg) { - if (strcmp (auth_alg, "OPEN") == 0) { - g_object_set (s_wireless_sec, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, - "open", NULL); - nm_log_info (LOGD_SETTINGS, "WEP: Use open system authentication"); - } else if (strcmp (auth_alg, "SHARED") == 0) { - g_object_set (s_wireless_sec, - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, - "shared", NULL); - nm_log_info (LOGD_SETTINGS, "WEP: Use shared system authentication"); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WEP authentication algorithm '%s'", - auth_alg); - goto error; - } - - } - - if (!nm_setting_wireless_security_get_wep_key (s_wireless_sec, 0) - && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1) - && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 2) - && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3) - && !nm_setting_wireless_security_get_wep_tx_keyidx (s_wireless_sec)) { - if (auth_alg && !strcmp (auth_alg, "shared")) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "WEP Shared Key authentication is invalid for " - "unencrypted connections."); - goto error; - } - /* Unencrypted */ - g_object_unref (s_wireless_sec); - s_wireless_sec = NULL; - } - return s_wireless_sec; - -error: - if (s_wireless_sec) - g_object_unref (s_wireless_sec); - return NULL; -} - -static char * -parse_wpa_psk (const char *psk, GError **error) -{ - char *hashed = NULL; - gboolean quoted = FALSE; - - if (!psk) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing WPA_PSK for WPA-PSK key management"); - return NULL; - } - - /* Passphrase must be between 10 and 66 characters in length because WPA - * hex keys are exactly 64 characters (no quoting), and WPA passphrases - * are between 8 and 63 characters (inclusive), plus optional quoting if - * the passphrase contains spaces. - */ - - if (psk[0] == '"' && psk[strlen (psk) - 1] == '"') - quoted = TRUE; - if (!quoted && (strlen (psk) == 64)) { - /* Verify the hex PSK; 64 digits */ - if (!is_hex (psk)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (contains non-hexadecimal characters)"); - goto out; - } - hashed = g_strdup (psk); - } else { - char *stripped = g_strdup (psk); - - strip_string (stripped, '"'); - - /* Length check */ - if (strlen (stripped) < 8 || strlen (stripped) > 63) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (passphrases must be between " - "8 and 63 characters long (inclusive))"); - g_free (stripped); - goto out; - } - - hashed = g_strdup (stripped); - g_free (stripped); - } - - if (!hashed) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (doesn't look like a passphrase or hex key)"); - goto out; - } - -out: - return hashed; -} - -static gboolean -fill_wpa_ciphers (const char *ssid, - NMSettingWirelessSecurity *wsec, - gboolean group, - gboolean adhoc) -{ - const char *value; - char **list = NULL, **iter; - int i = 0; - - value = wpa_get_value (ssid, group ? "group" : "pairwise"); - if (!value) - return TRUE; - - list = g_strsplit_set (value, " ", 0); - for (iter = list; iter && *iter; iter++, i++) { - /* Ad-Hoc configurations cannot have pairwise ciphers, and can only - * have one group cipher. Ignore any additional group ciphers and - * any pairwise ciphers specified. - */ - if (adhoc) { - if (group && (i > 0)) { - nm_log_warn (LOGD_SETTINGS, " ignoring group cipher '%s' (only one group cipher allowed in Ad-Hoc mode)", - *iter); - continue; - } else if (!group) { - nm_log_warn (LOGD_SETTINGS, " ignoring pairwise cipher '%s' (pairwise not used in Ad-Hoc mode)", - *iter); - continue; - } - } - - if (!strcmp (*iter, "CCMP")) { - if (group) - nm_setting_wireless_security_add_group (wsec, - "ccmp"); - else - nm_setting_wireless_security_add_pairwise (wsec, - "ccmp"); - } else if (!strcmp (*iter, "TKIP")) { - if (group) - nm_setting_wireless_security_add_group (wsec, - "tkip"); - else - nm_setting_wireless_security_add_pairwise (wsec, - "tkip"); - } else if (group && !strcmp (*iter, "WEP104")) - nm_setting_wireless_security_add_group (wsec, "wep104"); - else if (group && !strcmp (*iter, "WEP40")) - nm_setting_wireless_security_add_group (wsec, "wep40"); - else { - nm_log_warn (LOGD_SETTINGS, " ignoring invalid %s cipher '%s'", - group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", - *iter); - } - } - - if (list) - g_strfreev (list); - return TRUE; -} - -static NMSetting8021x * -fill_8021x (const char *ssid, - const char *key_mgmt, - gboolean wifi, - const char *basepath, - GError **error) -{ - NMSetting8021x *s_8021x; - const char *value; - char **list, **iter; - - value = wpa_get_value (ssid, "eap"); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_EAP_METHODS for key management '%s'", - key_mgmt); - return NULL; - } - - list = g_strsplit (value, " ", 0); - - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - /* Validate and handle each EAP method */ - for (iter = list; iter && *iter; iter++) { - EAPReader *eap = &eap_readers[0]; - gboolean found = FALSE; - char *lower = NULL; - - lower = g_ascii_strdown (*iter, -1); - while (eap->method) { - if (strcmp (eap->method, lower)) - goto next; - - /* Some EAP methods don't provide keying material, thus they - * cannot be used with WiFi unless they are an inner method - * used with TTLS or PEAP or whatever. - */ - if (wifi && eap->wifi_phase2_only) { - nm_log_warn (LOGD_SETTINGS, " ignored invalid IEEE_8021X_EAP_METHOD '%s'; not allowed for wifi.", - lower); - goto next; - } - - /* Parse EAP method specific options */ - if (!(*eap->reader) (lower, ssid, s_8021x, FALSE, basepath, error)) { - g_free (lower); - goto error; - } - nm_setting_802_1x_add_eap_method (s_8021x, lower); - found = TRUE; - break; - - next: - eap++; - } - - if (!found) { - nm_log_warn (LOGD_SETTINGS, " ignored unknown IEEE_8021X_EAP_METHOD '%s'.", lower); - } - g_free (lower); - } - g_strfreev (list); - - if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "No valid EAP methods found in IEEE_8021X_EAP_METHODS."); - goto error; - } - - return s_8021x; - -error: - g_object_unref (s_8021x); - return NULL; -} - -static NMSettingWirelessSecurity * -make_wpa_setting (const char *ssid, - const char *basepath, - NMSetting8021x **s_8021x, - GError **error) -{ - NMSettingWirelessSecurity *wsec; - const char *value; - char *lower; - gboolean adhoc = FALSE; - - if (!exist_ssid (ssid)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "No security info found for ssid: %s", ssid); - return NULL; - } - - wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - - /* mode=1: adhoc - * mode=0: infrastructure */ - value = wpa_get_value (ssid, "mode"); - if (value) - adhoc = strcmp (value, "1") == 0 ? TRUE : FALSE; - - /* Pairwise and Group ciphers */ - fill_wpa_ciphers (ssid, wsec, FALSE, adhoc); - fill_wpa_ciphers (ssid, wsec, TRUE, adhoc); - - /* WPA and/or RSN */ - if (adhoc) { - /* Ad-Hoc mode only supports WPA proto for now */ - nm_setting_wireless_security_add_proto (wsec, "wpa"); - } else { - nm_setting_wireless_security_add_proto (wsec, "wpa"); - nm_setting_wireless_security_add_proto (wsec, "rsn"); - - } - - value = wpa_get_value (ssid, "key_mgmt"); - if (!strcmp (value, "WPA-PSK")) { - char *psk = parse_wpa_psk (wpa_get_value (ssid, "psk"), error); - - if (!psk) - goto error; - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_PSK, psk, - NULL); - g_free (psk); - - if (adhoc) - g_object_set (wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - "wpa-none", NULL); - else - g_object_set (wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - "wpa-psk", NULL); - } else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) { - if (adhoc) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", - value); - goto error; - } - *s_8021x = fill_8021x (ssid, value, TRUE, basepath, error); - if (!*s_8021x) - goto error; - - lower = g_ascii_strdown (value, -1); - g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - lower, NULL); - g_free (lower); - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Unknown wireless KEY_MGMT type '%s'", value); - goto error; - } - return wsec; -error: - if (wsec) - g_object_unref (wsec); - return NULL; -} - -static NMSettingWirelessSecurity * -make_wireless_security_setting (const char *conn_name, - const char *basepath, - NMSetting8021x **s_8021x, - GError ** error) -{ - NMSettingWirelessSecurity *wsec = NULL; - const char *ssid; - gboolean adhoc = FALSE; - const char *value; - - g_return_val_if_fail (conn_name != NULL - && strcmp (ifnet_get_data (conn_name, "type"), - "ppp") != 0, NULL); - nm_log_info (LOGD_SETTINGS, "updating wireless security settings (%s).", conn_name); - - ssid = conn_name; - value = wpa_get_value (ssid, "mode"); - if (value) - adhoc = strcmp (value, "1") == 0 ? TRUE : FALSE; - - value = wpa_get_value (ssid, "key_mgmt"); - if (!adhoc && g_strcmp0 (value, "IEEE8021X") == 0) { - value = wpa_get_value (ssid, "eap"); - if (value && strcasecmp (value, "LEAP") == 0) { - wsec = make_leap_setting (ssid, error); - if (wsec == NULL) - goto error; - } - } else if (g_strcmp0 (value, "WPA-PSK") == 0 || g_strcmp0 (value, "WPA-EAP") == 0) { - wsec = make_wpa_setting (ssid, basepath, s_8021x, error); - if (wsec == NULL) - goto error; - } - if (!wsec) { - wsec = make_wep_setting (ssid, error); - if (wsec == NULL) - goto error; - } - return wsec; - -error: - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Can't handle security information for ssid: %s", - conn_name); - return NULL; -} - -/* Currently only support username and password */ -static gboolean -make_pppoe_connection_setting (NMConnection *connection, - const char *conn_name, - GError **error) -{ - NMSettingPppoe *s_pppoe; - NMSettingPpp *s_ppp; - const char *value; - - s_pppoe = NM_SETTING_PPPOE (nm_setting_pppoe_new ()); - - /* username */ - value = ifnet_get_data (conn_name, "username"); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "ppp requires at lease a username"); - return FALSE; - } - g_object_set (s_pppoe, NM_SETTING_PPPOE_USERNAME, value, NULL); - - /* password */ - value = ifnet_get_data (conn_name, "password"); - if (!value) { - value = ""; - } - - g_object_set (s_pppoe, NM_SETTING_PPPOE_PASSWORD, value, NULL); - nm_connection_add_setting (connection, NM_SETTING (s_pppoe)); - - /* PPP setting */ - s_ppp = (NMSettingPpp *) nm_setting_ppp_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ppp)); - - return TRUE; -} - -NMConnection * -ifnet_update_connection_from_config_block (const char *conn_name, - const char *basepath, - GError **error) -{ - const gchar *type = NULL; - NMConnection *connection = NULL; - NMSettingConnection *setting = NULL; - NMSetting8021x *s_8021x = NULL; - NMSettingWirelessSecurity *wsec = NULL; - gboolean auto_conn = TRUE; - const char *value = NULL; - gchar *id, *uuid; - gboolean success = FALSE; - - connection = nm_simple_connection_new (); - setting = nm_connection_get_setting_connection (connection); - if (!setting) { - setting = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - g_assert (setting); - nm_connection_add_setting (connection, NM_SETTING (setting)); - } - - type = guess_connection_type (conn_name); - value = ifnet_get_data (conn_name, "auto"); - if (value && !strcmp (value, "false")) - auto_conn = FALSE; - - /* Try to read UUID from the ifnet block, otherwise generate UUID from - * the connection ID. - */ - id = connection_id_from_ifnet_name (conn_name); - uuid = g_strdup (ifnet_get_data (conn_name, "uuid")); - if (!uuid) - uuid = nm_utils_uuid_generate_from_string (id, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); - - g_object_set (setting, - NM_SETTING_CONNECTION_TYPE, type, - NM_SETTING_CONNECTION_ID, id, - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_INTERFACE_NAME, conn_name, - NM_SETTING_CONNECTION_READ_ONLY, FALSE, - NM_SETTING_CONNECTION_AUTOCONNECT, auto_conn, - NULL); - nm_log_info (LOGD_SETTINGS, "name:%s, id:%s, uuid: %s", conn_name, id, uuid); - g_free (id); - g_free (uuid); - - if (!strcmp (NM_SETTING_WIRED_SETTING_NAME, type) - || !strcmp (NM_SETTING_PPPOE_SETTING_NAME, type)) { - /* wired setting */ - if (!make_wired_connection_setting (connection, conn_name, error)) - goto error; - - /* pppoe setting */ - if (!strcmp (NM_SETTING_PPPOE_SETTING_NAME, type)) { - if (!make_pppoe_connection_setting (connection, conn_name, error)) - goto error; - } - } else if (!strcmp (NM_SETTING_WIRELESS_SETTING_NAME, type)) { - /* wireless setting */ - NMSetting *wireless_setting; - - wireless_setting = make_wireless_connection_setting (conn_name, &s_8021x, error); - if (!wireless_setting) - goto error; - nm_connection_add_setting (connection, wireless_setting); - - /* wireless security setting */ - if (wpa_get_value (conn_name, "ssid")) { - wsec = make_wireless_security_setting (conn_name, basepath, &s_8021x, error); - if (!wsec) - goto error; - nm_connection_add_setting (connection, NM_SETTING (wsec)); - if (s_8021x) - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - } - } else - goto error; - - /* IPv4 setting */ - if (!make_ip4_setting (connection, conn_name, error)) - goto error; - - /* IPv6 setting */ - if (!make_ip6_setting (connection, conn_name, error)) - goto error; - - if (nm_connection_verify (connection, error)) { - nm_log_info (LOGD_SETTINGS, "Connection verified %s:%d", conn_name, success); - } else { - goto error; - } - - return connection; -error: - g_object_unref (connection); - return NULL; -} - -typedef NMSetting8021xCKScheme (*SchemeFunc) (NMSetting8021x * setting); -typedef const char *(*PathFunc) (NMSetting8021x * setting); -typedef GBytes *(*BlobFunc) (NMSetting8021x * setting); - -typedef struct ObjectType { - const char *setting_key; - SchemeFunc scheme_func; - PathFunc path_func; - BlobFunc blob_func; - const char *conn_name_key; - const char *suffix; -} ObjectType; - -static const ObjectType ca_type = { - NM_SETTING_802_1X_CA_CERT, - nm_setting_802_1x_get_ca_cert_scheme, - nm_setting_802_1x_get_ca_cert_path, - nm_setting_802_1x_get_ca_cert_blob, - "ca_cert", - "ca-cert.der" -}; - -static const ObjectType phase2_ca_type = { - NM_SETTING_802_1X_PHASE2_CA_CERT, - nm_setting_802_1x_get_phase2_ca_cert_scheme, - nm_setting_802_1x_get_phase2_ca_cert_path, - nm_setting_802_1x_get_phase2_ca_cert_blob, - "ca_cert2", - "inner-ca-cert.der" -}; - -static const ObjectType client_type = { - NM_SETTING_802_1X_CLIENT_CERT, - nm_setting_802_1x_get_client_cert_scheme, - nm_setting_802_1x_get_client_cert_path, - nm_setting_802_1x_get_client_cert_blob, - "client_cert", - "client-cert.der" -}; - -static const ObjectType phase2_client_type = { - NM_SETTING_802_1X_PHASE2_CLIENT_CERT, - nm_setting_802_1x_get_phase2_client_cert_scheme, - nm_setting_802_1x_get_phase2_client_cert_path, - nm_setting_802_1x_get_phase2_client_cert_blob, - "client_cert2", - "inner-client-cert.der" -}; - -static const ObjectType pk_type = { - NM_SETTING_802_1X_PRIVATE_KEY, - nm_setting_802_1x_get_private_key_scheme, - nm_setting_802_1x_get_private_key_path, - nm_setting_802_1x_get_private_key_blob, - "private_key", - "private-key.pem" -}; - -static const ObjectType phase2_pk_type = { - NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, - nm_setting_802_1x_get_phase2_private_key_scheme, - nm_setting_802_1x_get_phase2_private_key_path, - nm_setting_802_1x_get_phase2_private_key_blob, - "private_key2", - "inner-private-key.pem" -}; - -static const ObjectType p12_type = { - NM_SETTING_802_1X_PRIVATE_KEY, - nm_setting_802_1x_get_private_key_scheme, - nm_setting_802_1x_get_private_key_path, - nm_setting_802_1x_get_private_key_blob, - "private_key", - "private-key.p12" -}; - -static const ObjectType phase2_p12_type = { - NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, - nm_setting_802_1x_get_phase2_private_key_scheme, - nm_setting_802_1x_get_phase2_private_key_path, - nm_setting_802_1x_get_phase2_private_key_blob, - "private_key2", - "inner-private-key.p12" -}; - -static gboolean -write_object (NMSetting8021x *s_8021x, - const char *conn_name, - GBytes *override_data, - const ObjectType *objtype, - GError **error) -{ - NMSetting8021xCKScheme scheme; - const char *path = NULL; - GBytes *blob = NULL; - - g_return_val_if_fail (conn_name != NULL, FALSE); - g_return_val_if_fail (objtype != NULL, FALSE); - if (override_data) - /* if given explicit data to save, always use that instead of asking - * the setting what to do. - */ - blob = override_data; - else { - scheme = (*(objtype->scheme_func)) (s_8021x); - switch (scheme) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - blob = (*(objtype->blob_func)) (s_8021x); - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = (*(objtype->path_func)) (s_8021x); - break; - default: - break; - } - } - - /* If the object path was specified, prefer that over any raw cert data that - * may have been sent. - */ - if (path) { - wpa_set_data (conn_name, (gchar *) objtype->conn_name_key, - (gchar *) path); - return TRUE; - } - - /* does not support writing encryption data now */ - if (blob) - nm_log_warn (LOGD_SETTINGS, " Currently we do not support cert writing."); - - return TRUE; -} - -static gboolean -write_8021x_certs (NMSetting8021x *s_8021x, - gboolean phase2, - const char *conn_name, - GError **error) -{ - char *password = NULL; - const ObjectType *otype = NULL; - gboolean is_pkcs12 = FALSE, success = FALSE; - GBytes *blob = NULL; - GBytes *enc_key = NULL; - gchar *generated_pw = NULL; - - /* CA certificate */ - if (phase2) - otype = &phase2_ca_type; - else - otype = &ca_type; - - if (!write_object (s_8021x, conn_name, NULL, otype, error)) - return FALSE; - - /* Private key */ - if (phase2) { - if (nm_setting_802_1x_get_phase2_private_key_scheme (s_8021x) != - NM_SETTING_802_1X_CK_SCHEME_UNKNOWN) { - if (nm_setting_802_1x_get_phase2_private_key_format - (s_8021x) == NM_SETTING_802_1X_CK_FORMAT_PKCS12) - is_pkcs12 = TRUE; - } - password = (char *) - nm_setting_802_1x_get_phase2_private_key_password (s_8021x); - } else { - if (nm_setting_802_1x_get_private_key_scheme (s_8021x) != - NM_SETTING_802_1X_CK_SCHEME_UNKNOWN) { - if (nm_setting_802_1x_get_private_key_format (s_8021x) - == NM_SETTING_802_1X_CK_FORMAT_PKCS12) - is_pkcs12 = TRUE; - } - password = (char *) - nm_setting_802_1x_get_private_key_password (s_8021x); - } - - if (is_pkcs12) - otype = phase2 ? &phase2_p12_type : &p12_type; - else - otype = phase2 ? &phase2_pk_type : &pk_type; - - if ((*(otype->scheme_func)) (s_8021x) == - NM_SETTING_802_1X_CK_SCHEME_BLOB) - blob = (*(otype->blob_func)) (s_8021x); - - /* Only do the private key re-encrypt dance if we got the raw key data, which - * by definition will be unencrypted. If we're given a direct path to the - * private key file, it'll be encrypted, so we don't need to re-encrypt. - */ - if (blob && !is_pkcs12) { - GByteArray *tmp_enc_key; - - /* Encrypt the unencrypted private key with the fake password */ - tmp_enc_key = - nm_utils_rsa_key_encrypt (g_bytes_get_data (blob, NULL), g_bytes_get_size (blob), - password, &generated_pw, error); - if (!tmp_enc_key) - goto out; - - enc_key = g_byte_array_free_to_bytes (tmp_enc_key); - - if (generated_pw) - password = generated_pw; - } - - /* Save the private key */ - if (!write_object - (s_8021x, conn_name, enc_key ? enc_key : blob, otype, error)) - goto out; - - if (phase2) - wpa_set_data (conn_name, "private_key2_passwd", password); - else - wpa_set_data (conn_name, "private_key_passwd", password); - - /* Client certificate */ - if (is_pkcs12) { - wpa_set_data (conn_name, - phase2 ? "client_cert2" : "client_cert", NULL); - } else { - if (phase2) - otype = &phase2_client_type; - else - otype = &client_type; - - /* Save the client certificate */ - if (!write_object (s_8021x, conn_name, NULL, otype, error)) - goto out; - } - - success = TRUE; -out: - if (generated_pw) { - memset (generated_pw, 0, strlen (generated_pw)); - g_free (generated_pw); - } - if (enc_key) { - memset ((gpointer) g_bytes_get_data (enc_key, NULL), 0, g_bytes_get_size (enc_key)); - g_bytes_unref (enc_key); - } - return success; -} - -static gboolean -write_8021x_setting (NMConnection *connection, - const char *conn_name, - gboolean wired, - GError **error) -{ - NMSetting8021x *s_8021x; - const char *value; - char *tmp = NULL; - gboolean success = FALSE; - GString *phase2_auth; - GString *phase1; - - s_8021x = nm_connection_get_setting_802_1x (connection); - if (!s_8021x) { - return TRUE; - } - - nm_log_info (LOGD_SETTINGS, "Adding 8021x setting for %s", conn_name); - - /* If wired, write KEY_MGMT */ - if (wired) - wpa_set_data (conn_name, "key_mgmt", "IEEE8021X"); - - /* EAP method */ - if (nm_setting_802_1x_get_num_eap_methods (s_8021x)) { - value = nm_setting_802_1x_get_eap_method (s_8021x, 0); - if (value) - tmp = g_ascii_strup (value, -1); - } - wpa_set_data (conn_name, "eap", tmp ? tmp : NULL); - g_free (tmp); - - wpa_set_data (conn_name, "identity", - (gchar *) nm_setting_802_1x_get_identity (s_8021x)); - - wpa_set_data (conn_name, "anonymous_identity", (gchar *) - nm_setting_802_1x_get_anonymous_identity (s_8021x)); - - wpa_set_data (conn_name, "password", - (gchar *) nm_setting_802_1x_get_password (s_8021x)); - - phase1 = g_string_new (NULL); - - /* PEAP version */ - wpa_set_data (conn_name, "phase1", NULL); - value = nm_setting_802_1x_get_phase1_peapver (s_8021x); - if (value && (!strcmp (value, "0") || !strcmp (value, "1"))) - g_string_append_printf (phase1, "peapver=%s ", value); - - /* PEAP label */ - value = nm_setting_802_1x_get_phase1_peaplabel (s_8021x); - if (value && !strcmp (value, "1")) - g_string_append_printf (phase1, "peaplabel=%s ", value); - if (phase1->len) { - tmp = g_strstrip (g_strdup (phase1->str)); - wpa_set_data (conn_name, "phase1", tmp); - g_free (tmp); - } - - /* Phase2 auth methods */ - wpa_set_data (conn_name, "phase2", NULL); - phase2_auth = g_string_new (NULL); - - value = nm_setting_802_1x_get_phase2_auth (s_8021x); - if (value) { - tmp = g_ascii_strup (value, -1); - g_string_append_printf (phase2_auth, "auth=%s ", tmp); - g_free (tmp); - } - - /* Phase2 auth heap */ - value = nm_setting_802_1x_get_phase2_autheap (s_8021x); - if (value) { - tmp = g_ascii_strup (value, -1); - g_string_append_printf (phase2_auth, "autheap=%s ", tmp); - g_free (tmp); - } - tmp = g_strstrip (g_strdup (phase2_auth->str)); - wpa_set_data (conn_name, "phase2", phase2_auth->len ? tmp : NULL); - g_free (tmp); - - g_string_free (phase2_auth, TRUE); - g_string_free (phase1, TRUE); - - success = write_8021x_certs (s_8021x, FALSE, conn_name, error); - if (success) { - /* phase2/inner certs */ - success = write_8021x_certs (s_8021x, TRUE, conn_name, error); - } - - return success; -} - -static gboolean -write_wireless_security_setting (NMConnection * connection, - gchar * conn_name, - gboolean adhoc, - gboolean * no_8021x, GError ** error) -{ - NMSettingWirelessSecurity *s_wsec; - const char *key_mgmt, *auth_alg, *key, *cipher, *psk; - gboolean wep = FALSE, wpa = FALSE; - char *tmp; - guint32 i, num; - GString *str; - - s_wsec = nm_connection_get_setting_wireless_security (connection); - if (!s_wsec) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing '%s' setting", - NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); - return FALSE; - } - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - g_assert (key_mgmt); - - auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - - if (!strcmp (key_mgmt, "none")) { - wpa_set_data (conn_name, "key_mgmt", "NONE"); - wep = TRUE; - *no_8021x = TRUE; - } else if (!strcmp (key_mgmt, "wpa-none") - || !strcmp (key_mgmt, "wpa-psk")) { - wpa_set_data (conn_name, "key_mgmt", "WPA-PSK"); - wpa = TRUE; - *no_8021x = TRUE; - } else if (!strcmp (key_mgmt, "ieee8021x")) { - wpa_set_data (conn_name, "key_mgmt", "IEEE8021X"); - } else if (!strcmp (key_mgmt, "wpa-eap")) { - wpa_set_data (conn_name, "key_mgmt", "WPA-EAP"); - wpa = TRUE; - } else - nm_log_warn (LOGD_SETTINGS, "Unknown key_mgmt: %s", key_mgmt); - - if (auth_alg) { - if (!strcmp (auth_alg, "shared")) - wpa_set_data (conn_name, "auth_alg", "SHARED"); - else if (!strcmp (auth_alg, "open")) - wpa_set_data (conn_name, "auth_alg", "OPEN"); - else if (!strcmp (auth_alg, "leap")) { - wpa_set_data (conn_name, "auth_alg", "LEAP"); - wpa_set_data (conn_name, "eap", "LEAP"); - wpa_set_data (conn_name, "identity", (gchar *) - nm_setting_wireless_security_get_leap_username - (s_wsec)); - wpa_set_data (conn_name, "password", (gchar *) - nm_setting_wireless_security_get_leap_password - (s_wsec)); - *no_8021x = TRUE; - } - } else - wpa_set_data (conn_name, "auth_alg", NULL); - - /* Default WEP TX key index */ - if (wep) { - tmp = - g_strdup_printf ("%d", - nm_setting_wireless_security_get_wep_tx_keyidx - (s_wsec)); - wpa_set_data (conn_name, "wep_tx_keyidx", tmp); - g_free (tmp); - } else - wpa_set_data (conn_name, "wep_tx_keyidx", NULL); - - /* WEP keys */ - for (i = 0; i < 4; i++) { - int length; - - key = nm_setting_wireless_security_get_wep_key (s_wsec, i); - if (!key) - continue; - tmp = g_strdup_printf ("wep_key%d", i); - length = strlen (key); - if (length == 10 || length == 26 || length == 58) - wpa_set_data (conn_name, tmp, (gchar *) key); - else { - gchar *tmp_key = g_strdup_printf ("\"%s\"", key); - - wpa_set_data (conn_name, tmp, tmp_key); - g_free (tmp_key); - } - g_free (tmp); - } - - /* WPA Pairwise ciphers */ - wpa_set_data (conn_name, "pairwise", NULL); - str = g_string_new (NULL); - num = nm_setting_wireless_security_get_num_pairwise (s_wsec); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (str, ' '); - cipher = nm_setting_wireless_security_get_pairwise (s_wsec, i); - tmp = g_ascii_strup (cipher, -1); - g_string_append (str, tmp); - g_free (tmp); - } - if (strlen (str->str)) - wpa_set_data (conn_name, "pairwise", str->str); - g_string_free (str, TRUE); - - /* WPA Group ciphers */ - wpa_set_data (conn_name, "group", NULL); - str = g_string_new (NULL); - num = nm_setting_wireless_security_get_num_groups (s_wsec); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (str, ' '); - cipher = nm_setting_wireless_security_get_group (s_wsec, i); - tmp = g_ascii_strup (cipher, -1); - g_string_append (str, tmp); - g_free (tmp); - } - if (strlen (str->str)) - wpa_set_data (conn_name, "group", str->str); - g_string_free (str, TRUE); - - /* WPA Passphrase */ - if (wpa) { - GString *quoted = NULL; - - psk = nm_setting_wireless_security_get_psk (s_wsec); - if (psk && (strlen (psk) != 64)) { - quoted = g_string_sized_new (strlen (psk) + 2); - g_string_append_c (quoted, '"'); - g_string_append (quoted, psk); - g_string_append_c (quoted, '"'); - } - /* psk will be lost here if we don't check it for NULL */ - if (psk) - wpa_set_data (conn_name, "psk", - quoted ? quoted->str : (gchar *) psk); - if (quoted) - g_string_free (quoted, TRUE); - } else - wpa_set_data (conn_name, "psk", NULL); - - return TRUE; -} - -/* remove old ssid and add new one*/ -static void -update_wireless_ssid (NMConnection *connection, - const char *conn_name, - const char *ssid, - gboolean hex) -{ - if(strcmp (conn_name, ssid)){ - ifnet_delete_network (conn_name); - wpa_delete_security (conn_name); - } - - ifnet_add_network (ssid, "wireless"); - wpa_add_security (ssid); -} - -static gboolean -write_wireless_setting (NMConnection *connection, - const char *conn_name, - gboolean *no_8021x, - const char **out_new_name, - GError **error) -{ - NMSettingWireless *s_wireless; - GBytes *ssid; - const guint8 *ssid_data; - gsize ssid_len; - const char *mac, *bssid, *mode; - char buf[33]; - guint32 mtu, i; - gboolean adhoc = FALSE, hex_ssid = FALSE; - gchar *ssid_str, *tmp; - - s_wireless = nm_connection_get_setting_wireless (connection); - if (!s_wireless) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing '%s' setting", - NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - - ssid = nm_setting_wireless_get_ssid (s_wireless); - if (!ssid) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing SSID in '%s' setting", - NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - ssid_data = g_bytes_get_data (ssid, &ssid_len); - if (!ssid_len || ssid_len > 32) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID in '%s' setting", - NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - - /* If the SSID contains any non-alnum characters, we need to use - * the hex notation of the SSID instead. (Because openrc doesn't - * support these characters, see bug #356337) - */ - for (i = 0; i < ssid_len; i++) { - if (!g_ascii_isalnum (ssid_data[i])) { - hex_ssid = TRUE; - break; - } - } - - if (hex_ssid) { - GString *str; - - /* Hex SSIDs don't get quoted */ - str = g_string_sized_new (ssid_len * 2 + 3); - g_string_append (str, "0x"); - for (i = 0; i < ssid_len; i++) - g_string_append_printf (str, "%02X", ssid_data[i]); - update_wireless_ssid (connection, conn_name, str->str, hex_ssid); - ssid_str = g_string_free (str, FALSE); - } else { - /* Printable SSIDs get quoted */ - memset (buf, 0, sizeof (buf)); - memcpy (buf, ssid_data, ssid_len); - g_strstrip (buf); - update_wireless_ssid (connection, conn_name, buf, hex_ssid); - ssid_str = g_strdup (buf); - } - - ifnet_set_data (ssid_str, "mac", NULL); - mac = nm_setting_wireless_get_mac_address (s_wireless); - if (mac) - ifnet_set_data (ssid_str, "mac", mac); - - ifnet_set_data (ssid_str, "mtu", NULL); - mtu = nm_setting_wireless_get_mtu (s_wireless); - if (mtu) { - tmp = g_strdup_printf ("%u", mtu); - ifnet_set_data (ssid_str, "mtu", tmp); - g_free (tmp); - } - - ifnet_set_data (ssid_str, "mode", NULL); - mode = nm_setting_wireless_get_mode (s_wireless); - if (!mode || !strcmp (mode, "infrastructure")) { - wpa_set_data (ssid_str, "mode", "0"); - } else if (!strcmp (mode, "adhoc")) { - wpa_set_data (ssid_str, "mode", "1"); - adhoc = TRUE; - } else { - nm_log_warn (LOGD_SETTINGS, "Invalid mode '%s' in '%s' setting", - mode, NM_SETTING_WIRELESS_SETTING_NAME); - return FALSE; - } - - wpa_set_data (ssid_str, "bssid", NULL); - bssid = nm_setting_wireless_get_bssid (s_wireless); - if (bssid) - wpa_set_data (ssid_str, "bssid", bssid); - - if (nm_connection_get_setting_wireless_security (connection)) { - if (!write_wireless_security_setting - (connection, ssid_str, adhoc, no_8021x, error)) - return FALSE; - } else - wpa_delete_security (ssid_str); - - if (out_new_name) - *out_new_name = ifnet_get_data (ssid_str, "name"); - g_free (ssid_str); - return TRUE; -} - -static gboolean -write_wired_setting (NMConnection *connection, - const char *conn_name, - GError **error) -{ - NMSettingWired *s_wired; - const char *mac; - char *tmp; - guint32 mtu; - - s_wired = nm_connection_get_setting_wired (connection); - if (!s_wired) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing '%s' setting", - NM_SETTING_WIRED_SETTING_NAME); - return FALSE; - } - - ifnet_set_data (conn_name, "mac", NULL); - mac = nm_setting_wired_get_mac_address (s_wired); - if (mac) - ifnet_set_data (conn_name, "mac", mac); - - ifnet_set_data (conn_name, "mtu", NULL); - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) { - tmp = g_strdup_printf ("%u", mtu); - ifnet_set_data (conn_name, "mtu", tmp); - g_free (tmp); - } - //FIXME may add connection type in future - //ifnet_set_data (conn_name, "TYPE", TYPE_ETHERNET); - - return TRUE; -} - -static gboolean -write_ip4_setting (NMConnection *connection, const char *conn_name, GError **error) -{ - NMSettingIPConfig *s_ip4; - const char *value; - guint32 i, num; - GString *searches; - GString *ips; - GString *routes; - GString *dns; - gboolean success = FALSE; - - s_ip4 = nm_connection_get_setting_ip4_config (connection); - if (!s_ip4) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing '%s' setting", - NM_SETTING_IP4_CONFIG_SETTING_NAME); - return FALSE; - } - routes = g_string_new (NULL); - - value = nm_setting_ip_config_get_method (s_ip4); - g_assert (value); - if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { - - num = nm_setting_ip_config_get_num_addresses (s_ip4); - ips = g_string_new (NULL); - /* IPv4 addresses */ - for (i = 0; i < num; i++) { - NMIPAddress *addr; - - addr = nm_setting_ip_config_get_address (s_ip4, i); - - g_string_append_printf (ips, "\"%s/%u", - nm_ip_address_get_address (addr), - nm_ip_address_get_prefix (addr)); - - /* only the first gateway will be written */ - if (i == 0 && nm_setting_ip_config_get_gateway (s_ip4)) { - g_string_append_printf (routes, - "\"default via %s\" ", - nm_setting_ip_config_get_gateway (s_ip4)); - } - } - ifnet_set_data (conn_name, "config", ips->str); - g_string_free (ips, TRUE); - } else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) - ifnet_set_data (conn_name, "config", "shared"); - else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) - ifnet_set_data (conn_name, "config", "autoip"); - else - ifnet_set_data (conn_name, "config", "dhcp"); - - /* DNS Servers */ - num = nm_setting_ip_config_get_num_dns (s_ip4); - if (num > 0) { - dns = g_string_new (NULL); - for (i = 0; i < num; i++) { - const char *ip; - - ip = nm_setting_ip_config_get_dns (s_ip4, i); - g_string_append_printf (dns, " %s", ip); - } - ifnet_set_data (conn_name, "dns_servers", dns->str); - g_string_free (dns, TRUE); - } else - ifnet_set_data (conn_name, "dns_servers", NULL); - - /* DNS Searches */ - num = nm_setting_ip_config_get_num_dns_searches (s_ip4); - if (num > 0) { - searches = g_string_new (NULL); - for (i = 0; i < num; i++) { - if (i > 0) - g_string_append_c (searches, ' '); - g_string_append (searches, - nm_setting_ip_config_get_dns_search - (s_ip4, i)); - } - ifnet_set_data (conn_name, "dns_search", searches->str); - g_string_free (searches, TRUE); - } else - ifnet_set_data (conn_name, "dns_search", NULL); - /* FIXME Will be implemented when configuration supports it - if (!strcmp(value, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - value = nm_setting_ip_config_get_dhcp_hostname(s_ip4); - if (value) - ifnet_set_data(conn_name, "DHCP_HOSTNAME", value, - FALSE); - - value = nm_setting_ip_config_get_dhcp_client_id(s_ip4); - if (value) - ifnet_set_data(conn_name, "DHCP_CLIENT_ID", value, - FALSE); - } - */ - - /* Static routes */ - num = nm_setting_ip_config_get_num_routes (s_ip4); - if (num > 0) { - for (i = 0; i < num; i++) { - NMIPRoute *route; - const char *next_hop; - - route = nm_setting_ip_config_get_route (s_ip4, i); - - next_hop = nm_ip_route_get_next_hop (route); - if (!next_hop) - next_hop = "0.0.0.0"; - - g_string_append_printf (routes, "\"%s/%u via %s\" ", - nm_ip_route_get_dest (route), - nm_ip_route_get_prefix (route), - next_hop); - } - } - if (routes->len > 0) - ifnet_set_data (conn_name, "routes", routes->str); - else - ifnet_set_data (conn_name, "routes", NULL); - g_string_free (routes, TRUE); - - success = TRUE; - - return success; -} - -static void -write_route6_file (NMSettingIPConfig *s_ip6, const char *conn_name) -{ - NMIPRoute *route; - const char *next_hop; - guint32 i, num; - GString *routes_string; - const char *old_routes; - - g_return_if_fail (s_ip6 != NULL); - num = nm_setting_ip_config_get_num_routes (s_ip6); - if (num == 0) - return; - - old_routes = ifnet_get_data (conn_name, "routes"); - routes_string = g_string_new (old_routes); - if (old_routes) - g_string_append (routes_string, "\" "); - for (i = 0; i < num; i++) { - route = nm_setting_ip_config_get_route (s_ip6, i); - - next_hop = nm_ip_route_get_next_hop (route); - if (!next_hop) - next_hop = "::"; - - g_string_append_printf (routes_string, "\"%s/%u via %s\" ", - nm_ip_route_get_dest (route), - nm_ip_route_get_prefix (route), - next_hop); - } - if (num > 0) - ifnet_set_data (conn_name, "routes", routes_string->str); - g_string_free (routes_string, TRUE); -} - -static gboolean -write_ip6_setting (NMConnection *connection, const char *conn_name, GError **error) -{ - NMSettingIPConfig *s_ip6; - const char *value; - guint32 i, num; - GString *searches; - NMIPAddress *addr; - - s_ip6 = nm_connection_get_setting_ip6_config (connection); - if (!s_ip6) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing '%s' setting", - NM_SETTING_IP6_CONFIG_SETTING_NAME); - return FALSE; - } - - value = nm_setting_ip_config_get_method (s_ip6); - g_assert (value); - if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { - ifnet_set_data (conn_name, "enable_ipv6", "false"); - return TRUE; - } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { - /* nothing to do now */ - } else { - // if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - const char *config = ifnet_get_data (conn_name, "config"); - gchar *tmp; - - if (!config) - tmp = g_strdup_printf ("dhcp6"); - else - tmp = g_strdup_printf ("%s\" \"dhcp6\"", config); - ifnet_set_data (conn_name, "config", tmp); - g_free (tmp); - } - /* else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { - } else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) { - } else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { - } */ - - /* Remember to set IPv6 enabled */ - ifnet_set_data (conn_name, "enable_ipv6", "true"); - - if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { - const char *config = ifnet_get_data (conn_name, "config"); - gchar *tmp; - GString *ip_str; - - if (!config) - config = ""; - num = nm_setting_ip_config_get_num_addresses (s_ip6); - - /* IPv6 addresses */ - ip_str = g_string_new (NULL); - for (i = 0; i < num; i++) { - addr = nm_setting_ip_config_get_address (s_ip6, i); - - g_string_append_printf (ip_str, "\"%s/%u\"", - nm_ip_address_get_address (addr), - nm_ip_address_get_prefix (addr)); - } - tmp = g_strdup_printf ("%s\" %s", config, ip_str->str); - ifnet_set_data (conn_name, "config", tmp); - g_free (tmp); - g_string_free (ip_str, TRUE); - } - - /* DNS Servers */ - num = nm_setting_ip_config_get_num_dns (s_ip6); - if (num > 0) { - const char *dns_servers = ifnet_get_data (conn_name, "dns_servers"); - gchar *tmp; - GString *dns_string = g_string_new (NULL); - const char *dns; - - if (!dns_servers) - dns_servers = ""; - for (i = 0; i < num; i++) { - dns = nm_setting_ip_config_get_dns (s_ip6, i); - - if (!strstr (dns_servers, dns)) - g_string_append_printf (dns_string, "%s ", dns); - } - tmp = g_strdup_printf ("%s %s", dns_servers, dns_string->str); - ifnet_set_data (conn_name, "dns_servers", tmp); - g_free (tmp); - g_string_free (dns_string, TRUE); - - } else - /* DNS Searches */ - num = nm_setting_ip_config_get_num_dns_searches (s_ip6); - if (num > 0) { - const char *ip4_domains; - - ip4_domains = ifnet_get_data (conn_name, "dns_search"); - if (!ip4_domains) - ip4_domains = ""; - searches = g_string_new (ip4_domains); - for (i = 0; i < num; i++) { - const gchar *search = NULL; - - search = - nm_setting_ip_config_get_dns_search (s_ip6, i); - if (search && !strstr (searches->str, search)) { - if (searches->len > 0) - g_string_append_c (searches, ' '); - g_string_append (searches, search); - } - } - ifnet_set_data (conn_name, "dns_search", searches->str); - g_string_free (searches, TRUE); - } - - write_route6_file (s_ip6, conn_name); - return TRUE; -} - -static gboolean -write_pppoe_setting (const char *conn_name, NMSettingPppoe * s_pppoe) -{ - const gchar *value; - - value = nm_setting_pppoe_get_username (s_pppoe); - if (!value) { - return FALSE; - } - ifnet_set_data (conn_name, "username", (gchar *) value); - - value = nm_setting_pppoe_get_password (s_pppoe); - /* password could be NULL here */ - if (value) { - ifnet_set_data (conn_name, "password", (gchar *) value); - } - return TRUE; -} - -gboolean -ifnet_update_parsers_by_connection (NMConnection *connection, - const char *conn_name, - const char *config_file, - const char *wpa_file, - gchar **out_new_name, - gchar **out_backup, - GError **error) -{ - NMSettingConnection *s_con; - NMSettingIPConfig *s_ip6; - gboolean success = FALSE; - const char *type; - gboolean no_8021x = FALSE; - gboolean wired = FALSE, pppoe = TRUE; - const char *new_name = NULL; - - if (!ifnet_can_write_connection (connection, error)) - return FALSE; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - type = nm_setting_connection_get_connection_type (s_con); - if (!type) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing connection type!"); - goto out; - } - - if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { - /* Writing wired setting */ - if (!write_wired_setting (connection, conn_name, error)) - goto out; - wired = TRUE; - no_8021x = TRUE; - } else if (!strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME)) { - /* Writing wireless setting */ - if (!write_wireless_setting (connection, conn_name, &no_8021x, &new_name, error)) - goto out; - } else if (!strcmp (type, NM_SETTING_PPPOE_SETTING_NAME)) { - NMSettingPppoe *s_pppoe; - - /* Writing pppoe setting */ - s_pppoe = nm_connection_get_setting_pppoe (connection); - if (!write_pppoe_setting (conn_name, s_pppoe)) - goto out; - pppoe = TRUE; - wired = TRUE; - no_8021x = TRUE; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, - "Can't write connection type '%s'", type); - goto out; - } - - /* connection name may have been updated; use it when writing out - * the rest of the settings. - */ - if (new_name) - conn_name = new_name; - - //FIXME wired connection doesn't support 8021x now - if (!no_8021x) { - if (!write_8021x_setting (connection, conn_name, wired, error)) - goto out; - } - - /* IPv4 Setting */ - if (!write_ip4_setting (connection, conn_name, error)) - goto out; - - s_ip6 = nm_connection_get_setting_ip6_config (connection); - if (s_ip6) { - /* IPv6 Setting */ - if (!write_ip6_setting (connection, conn_name, error)) - goto out; - } - - /* Connection Setting */ - ifnet_set_data (conn_name, "auto", - nm_setting_connection_get_autoconnect (s_con) ? "true" : "false"); - ifnet_set_data (conn_name, "uuid", nm_connection_get_uuid (connection)); - - /* Write changes to disk */ - success = ifnet_flush_to_file (config_file, out_backup); - if (success) - wpa_flush_to_file (wpa_file); - - if (out_new_name) - *out_new_name = g_strdup (conn_name); - -out: - return success; -} - -gboolean -ifnet_delete_connection_in_parsers (const char *conn_name, - const char *config_file, - const char *wpa_file, - gchar **out_backup) -{ - gboolean result = FALSE; - - ifnet_delete_network (conn_name); - result = ifnet_flush_to_file (config_file, out_backup); - if (result) { - /* connection may not have security information - * so simply ignore the return value*/ - wpa_delete_security (conn_name); - wpa_flush_to_file (wpa_file); - } - - return result; -} - -static void -check_unsupported_secrets (NMSetting *setting, - const char *key, - const GValue *value, - GParamFlags flags, - gpointer user_data) -{ - gboolean *unsupported_secret = user_data; - - if (flags & NM_SETTING_PARAM_SECRET) { - NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; - - if (!nm_setting_get_secret_flags (setting, key, &secret_flags, NULL)) - g_return_if_reached (); - if (secret_flags != NM_SETTING_SECRET_FLAG_NONE) - *unsupported_secret = TRUE; - } -} - -gboolean -ifnet_can_write_connection (NMConnection *connection, GError **error) -{ - NMSettingConnection *s_con; - gboolean has_unsupported_secrets = FALSE; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - /* If the connection is not available for all users, ignore - * it as this plugin only deals with System Connections */ - if (nm_setting_connection_get_num_permissions (s_con)) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, - "The ifnet plugin does not support non-system-wide connections."); - return FALSE; - } - - /* Only support wired, wifi, and PPPoE */ - if ( !nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME) - && !nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME) - && !nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, - "The ifnet plugin cannot write the connection '%s' (type '%s')", - nm_connection_get_id (connection), - nm_setting_connection_get_connection_type (s_con)); - return FALSE; - } - - /* If the connection has flagged secrets, ignore - * it as this plugin does not deal with user agent service */ - nm_connection_for_each_setting_value (connection, - check_unsupported_secrets, - &has_unsupported_secrets); - if (has_unsupported_secrets) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, - "The ifnet plugin only supports persistent system secrets."); - return FALSE; - } - - return TRUE; -} - -/* get the available wired name(eth*). */ -static gchar * -get_wired_name (void) -{ - int i = 0; - - for (; i < 256; i++) { - gchar *conn_name = g_strdup_printf ("eth%d", i); - - if (!ifnet_has_network (conn_name)) { - return conn_name; - } else - g_free (conn_name); - } - return NULL; -} - -/* get the available pppoe name(ppp*). */ -static gchar * -get_ppp_name (void) -{ - int i = 0; - - for (; i < 256; i++) { - gchar *conn_name = g_strdup_printf ("ppp%d", i); - - if (!ifnet_has_network (conn_name)) { - return conn_name; - } else - g_free (conn_name); - } - return NULL; -} - -/* get wireless ssid */ -static gchar * -get_wireless_name (NMConnection * connection) -{ - NMSettingWireless *s_wireless; - GBytes *ssid; - const guint8 *ssid_data; - gsize ssid_len; - gboolean hex_ssid = FALSE; - gchar *result = NULL; - char buf[33]; - int i = 0; - - s_wireless = nm_connection_get_setting_wireless (connection); - if (!s_wireless) - return NULL; - - ssid = nm_setting_wireless_get_ssid (s_wireless); - ssid_data = g_bytes_get_data (ssid, &ssid_len); - if (!ssid_len || ssid_len > 32) { - return NULL; - } - - for (i = 0; i < ssid_len; i++) { - if (!g_ascii_isprint (ssid_data[i])) { - hex_ssid = TRUE; - break; - } - } - - if (hex_ssid) { - GString *str; - - str = g_string_sized_new (ssid_len * 2 + 3); - g_string_append (str, "0x"); - for (i = 0; i < ssid_len; i++) - g_string_append_printf (str, "%02X", ssid_data[i]); - result = g_strdup (str->str); - g_string_free (str, TRUE); - } else { - memset (buf, 0, sizeof (buf)); - memcpy (buf, ssid_data, ssid_len); - result = g_strdup_printf ("%s", buf); - g_strstrip (result); - } - - return result; -} - -gboolean -ifnet_add_new_connection (NMConnection *connection, - const char *config_file, - const char *wpa_file, - gchar **out_new_name, - gchar **out_backup, - GError **error) -{ - NMSettingConnection *s_con; - gboolean success = FALSE; - const char *type; - gchar *new_type, *new_name = NULL; - - if (!ifnet_can_write_connection (connection, error)) - return FALSE; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - type = nm_setting_connection_get_connection_type (s_con); - g_assert (type); - - nm_log_info (LOGD_SETTINGS, "Adding %s connection", type); - - /* get name and type - * Wireless type: wireless - * Wired type: wired - * PPPoE type: ppp*/ - if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { - new_name = get_wired_name (); - if (!new_name) - goto out; - new_type = "wired"; - } else if (!strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME)) { - new_name = get_wireless_name (connection); - new_type = "wireless"; - } else if (!strcmp (type, NM_SETTING_PPPOE_SETTING_NAME)) { - new_name = get_ppp_name (); - if (!new_name) - goto out; - new_type = "ppp"; - } else { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, - "Can't write connection type '%s'", type); - goto out; - } - - if (ifnet_add_network (new_name, new_type)) { - success = ifnet_update_parsers_by_connection (connection, - new_name, - config_file, - wpa_file, - NULL, - out_backup, - error); - } - - nm_log_info (LOGD_SETTINGS, "Added new connection: %s, result: %s", - new_name, success ? "success" : "fail"); - -out: - if (!success || !out_new_name) - g_free (new_name); - else if (out_new_name) - *out_new_name = new_name; - return success; -} - diff --git a/src/settings/plugins/ifnet/connection_parser.h b/src/settings/plugins/ifnet/connection_parser.h deleted file mode 100644 index 74213669..00000000 --- a/src/settings/plugins/ifnet/connection_parser.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#ifndef _CONNECTION_PARSER_H -#define _CONNECTION_PARSER_H -#include -#include "net_parser.h" - -gboolean ifnet_can_write_connection (NMConnection *connection, GError **error); - -NMConnection *ifnet_update_connection_from_config_block (const char *conn_name, - const char *basepath, - GError **error); - -/* nm_conn_name is used to update nm_ifnet_connection's priv data */ -gboolean ifnet_update_parsers_by_connection (NMConnection *connection, - const char *conn_name, - const char *config_file, - const char *wpa_file, - gchar **out_new_name, - gchar **out_backup, - GError **error); - -gboolean ifnet_delete_connection_in_parsers (const char *conn_name, - const char *config_file, - const char *wpa_file, - gchar **out_backup); - -gboolean ifnet_add_new_connection (NMConnection *connection, - const char *config_file, - const char *wpa_file, - gchar **out_new_name, - gchar **out_backup, - GError ** error); -#endif diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c deleted file mode 100644 index db5e7a13..00000000 --- a/src/settings/plugins/ifnet/net_parser.c +++ /dev/null @@ -1,734 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-settings-plugin.h" - -#include "plugin.h" -#include "nm-platform.h" - -#include "net_parser.h" -#include "net_utils.h" - -/* Save all the connection information */ -static GHashTable *conn_table; - -/* Save global settings which are used for writing*/ -static GHashTable *global_settings_table; - -/* Save functions */ -static GList *functions_list; - -/* Used to decide whether to write changes to file*/ -static gboolean net_parser_data_changed = FALSE; - -static GHashTable * -add_new_connection_config (const gchar * type, const gchar * name) -{ - GHashTable *new_conn; - gchar *new_name; - - if (!name) - return NULL; - - /* Return existing connection */ - if ((new_conn = g_hash_table_lookup (conn_table, name)) != NULL) - return new_conn; - new_conn = g_hash_table_new (g_str_hash, g_str_equal); - new_name = g_strdup (name); - g_hash_table_insert (new_conn, g_strdup ("name"), new_name); - g_hash_table_insert (new_conn, g_strdup ("type"), g_strdup (type)); - g_hash_table_insert (conn_table, new_name, new_conn); - return new_conn; -} - -gboolean -ifnet_add_network (const char *name, const char *type) -{ - if (ifnet_has_network (name)) - return TRUE; - if (add_new_connection_config (type, name)) { - nm_log_info (LOGD_SETTINGS, "Adding network for %s", name); - net_parser_data_changed = TRUE; - return TRUE; - } - return FALSE; -} - -gboolean -ifnet_has_network (const char *conn_name) -{ - return g_hash_table_lookup (conn_table, conn_name) != NULL; -} - -static GHashTable * -get_connection_config (const char *name) -{ - return g_hash_table_lookup (conn_table, name); -} - -/* Ignored name won't be treated as wireless ssid */ -static gchar *ignore_name[] = { - "vlan", "bond", "atm", "ath", "ippp", "vpn", "tap", "tun", "1", - "br", "nas", "6to4", "timeout", "kvm", "force", NULL -}; - -static gboolean -ignore_connection_name (const char *name) -{ - gboolean result = FALSE; - guint i = 0; - - /* check ignore_name list */ - while (ignore_name[i] != NULL) { - if (g_ascii_strncasecmp - (name, ignore_name[i], strlen (ignore_name[i])) == 0) { - return TRUE; - } - i++; - } - /* Ignore mac address based configuration */ - if (strlen (name) == 12 && is_hex (name)) - result = TRUE; - return result; -} - -static gboolean -is_global_setting (char *key) -{ - static gchar *global_settings[] = { "wpa_supplicant_", NULL }; - int i; - - for (i = 0; global_settings[i] != NULL; i++) { - if (strstr (key, global_settings[i])) - return 1; - } - return 0; -} - -/* Parse a complete line */ -/* Connection type is determined here */ -static void -init_block_by_line (gchar * buf) -{ - gchar **key_value; - gchar *pos; - gchar *data; - gchar *tmp; - GHashTable *conn; - - key_value = g_strsplit (buf, "=", 2); - if (g_strv_length (key_value) != 2) { - nm_log_warn (LOGD_SETTINGS, "Can't handle this line: %s\n", buf); - g_strfreev (key_value); - return; - } - pos = g_strrstr (key_value[0], "_"); - if (pos == NULL || is_global_setting (key_value[0])) { - /* global data */ - data = g_strdup (key_value[1]); - tmp = strip_string (data, '"'); - strip_string (tmp, '\''); - nm_log_info (LOGD_SETTINGS, "global:%s-%s\n", key_value[0], tmp); - g_hash_table_insert (global_settings_table, g_strdup (key_value[0]), g_strdup (tmp)); - g_strfreev (key_value); - g_free (data); - return; - } - *pos++ = '\0'; - if ((conn = get_connection_config (pos)) == NULL) { - if (g_ascii_strncasecmp (pos, "eth", 3) == 0 - && strlen (pos) == 4) - /* wired connection */ - conn = add_new_connection_config ("wired", pos); - else if (g_ascii_strncasecmp (pos, "ppp", 3) == 0 - && strlen (pos) == 4) - /* pppoe connection */ - conn = add_new_connection_config ("ppp", pos); - else if (ignore_connection_name (pos)) { - /* ignored connection */ - conn = add_new_connection_config ("ignore", pos); - } else { - int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, pos); - - if (ifindex && nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) != NM_LINK_TYPE_WIFI) - /* wired connection */ - conn = add_new_connection_config ("wired", pos); - else - /* wireless connection */ - conn = add_new_connection_config ("wireless", pos); - } - } - data = g_strdup (key_value[1]); - tmp = strip_string (data, '"'); - strip_string (tmp, '\''); - if (conn) - g_hash_table_insert (conn, strip_string (g_strdup (key_value[0]), ' '), - g_strdup (tmp)); - g_free (data); - g_strfreev (key_value); -} - -static void -destroy_connection_config (GHashTable * conn) -{ - gpointer key, value; - GHashTableIter iter; - - g_hash_table_iter_init (&iter, conn); - while (g_hash_table_iter_next (&iter, &key, &value)) { - g_free (key); - g_free (value); - } - - g_hash_table_destroy (conn); -} - -static void -strip_function (GIOChannel * channel, gchar * line) -{ - - int counter = 0; - gchar *p, *tmp; - gboolean begin = FALSE; - GString *function_str = g_string_new (line); - - g_string_append (function_str, "\n"); - while (1) { - p = line; - while (*p != '\0') { - if (*p == '{') { - counter++; - begin = TRUE; - } else if (*p == '}') - counter--; - p++; - } - if (begin && counter == 0) { - g_free (line); - goto done; - } - while (1) { - g_free (line); - if (g_io_channel_read_line - (channel, &line, NULL, NULL, - NULL) == G_IO_STATUS_EOF) - goto done; - g_string_append (function_str, line); - tmp = g_strdup (line); - g_strstrip (tmp); - if (tmp[0] != '#' && tmp[0] != '\0') { - g_free (tmp); - break; - } else - g_free (tmp); - } - } -done: - functions_list = - g_list_append (functions_list, g_strdup (function_str->str)); - g_string_free (function_str, TRUE); -} - -static gboolean -is_function (gchar * line) -{ - static gchar *func_names[] = - { "preup", "predown", "postup", "postdown", "failup", "faildown", - NULL, - }; - int i; - - for (i = 0; func_names[i]; i++) { - if (g_str_has_prefix (line, func_names[i])) { - nm_log_info (LOGD_SETTINGS, "Ignoring function: %s", func_names[i]); - return TRUE; - } - } - return FALSE; -} - -static void -append_line (GString *buf, gchar* line) -{ - gchar *pos = NULL; - - if ((pos = strchr (line, '#')) != NULL) - *pos = '\0'; - g_strstrip (line); - - if (line[0] != '\0') - g_string_append_printf (buf, " %s", line); - g_free (line); -} - -gboolean -ifnet_init (gchar * config_file) -{ - GIOChannel *channel = NULL; - gchar *line; - - /* Handle multiple lines with brackets */ - gboolean complete = TRUE; - - gboolean openrc_style = TRUE; - - /* line buffer */ - GString *buf; - - net_parser_data_changed = FALSE; - - conn_table = g_hash_table_new (g_str_hash, g_str_equal); - global_settings_table = g_hash_table_new (g_str_hash, g_str_equal); - functions_list = NULL; - - if (g_file_test (config_file, G_FILE_TEST_IS_REGULAR)) - channel = g_io_channel_new_file (config_file, "r", NULL); - if (channel == NULL) { - nm_log_warn (LOGD_SETTINGS, "Can't open %s", config_file); - return FALSE; - } - - buf = g_string_new (NULL); - while (g_io_channel_read_line - (channel, &line, NULL, NULL, NULL) != G_IO_STATUS_EOF) { - g_strstrip (line); - /* convert multiple lines to a complete line and - * pass it to init_block_by_line() */ - if (is_function (line)) { - strip_function (channel, line); - continue; - } - - // New openrc style, bash arrays are not allowed. We only care about '"' - if (openrc_style && line[0] != '#' && line[0] != '\0' - && !strchr (line, '(') && !strchr (line, ')')) { - gchar *tmp = line; - - while ((tmp = strchr (tmp, '"')) != NULL) { - complete = !complete; - ++tmp; - } - - append_line (buf, line); - // Add "(separator) for routes. It will be easier for later parsing - if (strstr (buf->str, "via")) - g_string_append_printf (buf, "\""); - - if (!complete) - continue; - - strip_string (buf->str, '"'); - - init_block_by_line (buf->str); - g_string_free (buf, TRUE); - buf = g_string_new (NULL); - } - // Old bash arrays for baselayout-1, to be deleted - else if (line[0] != '#' && line[0] != '\0') { - if (!complete) { - complete = - g_strrstr (line, - ")") == NULL ? FALSE : TRUE; - - append_line (buf, line); - if (!complete) { - openrc_style = FALSE; - continue; - } - else { - openrc_style = TRUE; - } - } else { - complete = - (g_strrstr (line, "(") != NULL - && g_strrstr (line, ")") != NULL) - || g_strrstr (line, "(") == NULL; - - append_line (buf, line); - if (!complete) - { - openrc_style = FALSE; - continue; - } else { - openrc_style = TRUE; - } - } - init_block_by_line (buf->str); - g_string_free (buf, TRUE); - buf = g_string_new (NULL); - } else - /* Blank line or comment line */ - g_free (line); - } - - g_string_free (buf, TRUE); - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - return TRUE; -} - -const char * -ifnet_get_data (const char *conn_name, const char *key) -{ - GHashTable *conn; - - g_return_val_if_fail (conn_name && key, NULL); - - conn = g_hash_table_lookup (conn_table, conn_name); - - if (conn) - return g_hash_table_lookup (conn, key); - return NULL; -} - -/* format ip values for comparison */ -static gchar* -format_ip_for_comparison (const gchar * value) -{ - gchar **ipset; - guint length, i; - GString *formated_string = g_string_new (NULL); - gchar *formatted = NULL; - - ipset = g_strsplit (value, "\"", 0); - length = g_strv_length (ipset); - - for (i = 0; i < length; i++) - { - strip_string (ipset[i], ' '); - if (ipset[i][0] != '\0') - g_string_append_printf (formated_string, - "%s ", ipset[i]); - } - formatted = g_strdup (formated_string->str); - formatted[formated_string->len - 1] = '\0'; - - g_string_free (formated_string, TRUE); - g_strfreev (ipset); - - return formatted; -} - -void -ifnet_set_data (const char *conn_name, const char *key, const char *value) -{ - gpointer old_key = NULL, old_value = NULL; - GHashTable *conn = g_hash_table_lookup (conn_table, conn_name); - gchar * stripped = NULL; - - if (!conn) { - nm_log_warn (LOGD_SETTINGS, "%s does not exist!", conn_name); - return; - } - if (value){ - stripped = g_strdup (value); - strip_string (stripped, '"'); - } - /* Remove existing key value pair */ - if (g_hash_table_lookup_extended (conn, key, &old_key, &old_value)) { - - /* This ugly hack is due to baselayout compatibility. We have to - * deal with different ip format. So sometimes we have the same ips - * but different strings. - */ - if (stripped && - (!strcmp (key, "config") - || !strcmp (key, "routes") - || !strcmp (key, "pppd") - || !strcmp (key, "chat"))) - { - gchar *old_ips = format_ip_for_comparison (old_value); - gchar *new_ips = format_ip_for_comparison (value); - if(!strcmp (old_ips, new_ips)) - { - g_free (stripped); - g_free (old_ips); - g_free (new_ips); - return; - } - g_free (old_ips); - g_free (new_ips); - } - - if (stripped && !strcmp (old_value, stripped)) { - g_free (stripped); - return; - } - g_hash_table_remove (conn, old_key); - g_free (old_key); - g_free (old_value); - } else if (!value) - return; - if (stripped) - g_hash_table_insert (conn, g_strdup (key), stripped); - net_parser_data_changed = TRUE; -} - -// Remember to free return value -const char * -ifnet_get_global_data (const gchar * key) -{ - return g_hash_table_lookup (global_settings_table, key); -} - -// Return names of legal connections -GList * -ifnet_get_connection_names (void) -{ - GList *names = g_hash_table_get_keys (conn_table); - GList *iter, *result = NULL; - - for (iter = names; iter; iter = iter->next) { - if (!ignore_connection_name (iter->data)) - result = g_list_prepend (result, iter->data); - } - - g_list_free (names); - return g_list_reverse (result); -} - -/* format IP and route for writing */ -static void -format_ips (gchar * value, gchar ** out_line, gchar * key, gchar * name) -{ - gchar **ipset; - guint length, i; - GString *formated_string = g_string_new (NULL); - - strip_string (value, '('); - strip_string (value, ')'); - strip_string (value, '"'); - ipset = g_strsplit (value, "\"", 0); - length = g_strv_length (ipset); - - //only one line - if (length < 2) { - *out_line = - g_strdup_printf ("%s_%s=\"%s\"\n", key, name, value); - goto done; - } - // Multiple lines - g_string_append_printf (formated_string, "%s_%s=\"\n", key, name); - for (i = 0; i < length; i++) - { - strip_string (ipset[i], ' '); - if (ipset[i][0] != '\0') - g_string_append_printf (formated_string, - "%s\n", ipset[i]); - } - g_string_append (formated_string, "\"\n"); - *out_line = g_strdup (formated_string->str); -done: - g_string_free (formated_string, TRUE); - g_strfreev (ipset); -} - -gboolean -ifnet_flush_to_file (const char *config_file, gchar **out_backup) -{ - GIOChannel *channel; - GError *error = NULL; - gpointer key, value, name, network; - GHashTableIter iter, iter_network; - GList *list_iter; - gchar *out_line = NULL; - gsize bytes_written; - gboolean result = FALSE; - gchar *backup; - - if (!net_parser_data_changed) - return TRUE; - if (!conn_table || !global_settings_table) - return FALSE; - - backup = backup_file (config_file); - - channel = g_io_channel_new_file (config_file, "w", NULL); - if (!channel) { - nm_log_warn (LOGD_SETTINGS, "Can't open file %s for writing", config_file); - g_free (backup); - return FALSE; - } - g_hash_table_iter_init (&iter, global_settings_table); - nm_log_info (LOGD_SETTINGS, "Writing to %s", config_file); - g_io_channel_write_chars (channel, - "#Generated by NetworkManager\n" - "###### Global Configuration ######\n", - -1, &bytes_written, &error); - if (error) - goto done; - - /* Writing global data */ - while (g_hash_table_iter_next (&iter, &key, &value)) { - out_line = - g_strdup_printf ("%s=\"%s\"\n", (gchar *) key, (gchar *) value); - g_io_channel_write_chars (channel, out_line, -1, - &bytes_written, &error); - if (bytes_written == 0 || error) - goto done; - g_free (out_line); - } - - /* Writing connection data */ - g_io_channel_write_chars (channel, - "\n###### Connection Configuration ######\n", - -1, &bytes_written, &error); - if (error) - goto done; - - g_hash_table_iter_init (&iter, conn_table); - while (g_hash_table_iter_next (&iter, &name, &network)) { - g_hash_table_iter_init (&iter_network, (GHashTable *) network); - g_io_channel_write_chars (channel, - "#----------------------------------\n", - -1, &bytes_written, &error); - if (error) - goto done; - - while (g_hash_table_iter_next (&iter_network, &key, &value)) { - if (!g_str_has_prefix ((gchar *) key, "name") - && !g_str_has_prefix ((gchar *) key, "type")) { - /* These keys contain brackets */ - if (strcmp - ((gchar *) key, - "config") == 0 - || strcmp ((gchar *) key, - "routes") == 0 - || strcmp ((gchar *) key, - "pppd") == 0 - || strcmp ((gchar *) key, "chat") == 0) - format_ips (value, &out_line, (gchar *) - key, (gchar *) - name); - else - out_line = - g_strdup_printf - ("%s_%s=\"%s\"\n", - (gchar *) key, - (gchar *) name, (gchar *) value); - g_io_channel_write_chars (channel, out_line, -1, &bytes_written, &error); - if (bytes_written == 0 || error) - goto done; - g_free (out_line); - } - } - } - - /* Writing reserved functions */ - if (functions_list) { - g_io_channel_write_chars (channel, - "\n###### Reserved Functions ######\n", - -1, &bytes_written, &error); - if (error) - goto done; - - /* Writing functions */ - for (list_iter = functions_list; list_iter; - list_iter = g_list_next (list_iter)) { - out_line = - g_strdup_printf ("%s\n", (gchar *) list_iter->data); - g_io_channel_write_chars (channel, out_line, -1, - &bytes_written, &error); - if (bytes_written == 0 || error) - goto done; - g_free (out_line); - } - } - - g_io_channel_flush (channel, &error); - if (error) - goto done; - result = TRUE; - net_parser_data_changed = FALSE; - -done: - if (error) { - nm_log_warn (LOGD_SETTINGS, "Error writing the configuration file: %s", error->message); - g_error_free (error); - } - - if (result && out_backup) - *out_backup = backup; - else - g_free (backup); - - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - return result; -} - -gboolean -ifnet_delete_network (const char *conn_name) -{ - GHashTable *network = NULL; - - g_return_val_if_fail (conn_table != NULL && conn_name != NULL, FALSE); - nm_log_info (LOGD_SETTINGS, "Deleting network for %s", conn_name); - network = g_hash_table_lookup (conn_table, conn_name); - if (!network) - return FALSE; - g_hash_table_remove (conn_table, conn_name); - destroy_connection_config (network); - net_parser_data_changed = TRUE; - return TRUE; -} - -void -ifnet_destroy (void) -{ - GHashTableIter iter; - gpointer key; - gpointer value; - GList *list_iter; - - /* Destroy connection setting */ - if (conn_table) { - g_hash_table_iter_init (&iter, conn_table); - while (g_hash_table_iter_next (&iter, &key, &value)) { - destroy_connection_config ((GHashTable *) - value); - } - g_hash_table_destroy (conn_table); - conn_table = NULL; - } - - /* Destroy global data */ - if (global_settings_table) { - g_hash_table_iter_init (&iter, global_settings_table); - while (g_hash_table_iter_next (&iter, &key, &value)) { - g_free (key); - g_free (value); - } - g_hash_table_destroy (global_settings_table); - global_settings_table = NULL; - } - for (list_iter = functions_list; list_iter; - list_iter = g_list_next (list_iter)) - g_free (list_iter->data); - g_list_free (functions_list); -} diff --git a/src/settings/plugins/ifnet/net_parser.h b/src/settings/plugins/ifnet/net_parser.h deleted file mode 100644 index 31fc9ead..00000000 --- a/src/settings/plugins/ifnet/net_parser.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#ifndef _NET_PARSER_H -#define _NET_PARSER_H - -#define CONF_NET_FILE SYSCONFDIR "/conf.d/net" - -gboolean ifnet_init (gchar * config_file); -void ifnet_destroy (void); - -/* Reader functions */ -GList *ifnet_get_connection_names (void); -const char *ifnet_get_data (const char *conn_name, const char *key); -const char *ifnet_get_global_data (const char *key); -gboolean ifnet_has_network (const char *conn_name); - -/* Writer functions */ -gboolean ifnet_flush_to_file (const char *config_file, gchar **out_backup); -void ifnet_set_data (const char *conn_name, const char *key, const char *value); -gboolean ifnet_add_network (const char *name, const char *type); -gboolean ifnet_delete_network (const char *conn_name); - -#endif diff --git a/src/settings/plugins/ifnet/net_utils.c b/src/settings/plugins/ifnet/net_utils.c deleted file mode 100644 index bd5d65d5..00000000 --- a/src/settings/plugins/ifnet/net_utils.c +++ /dev/null @@ -1,826 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-utils.h" -#include "NetworkManagerUtils.h" -#include "nm-settings-plugin.h" -#include "nm-config.h" -#include "net_utils.h" -#include "wpa_parser.h" -#include "net_parser.h" - -/* emit heading and tailing blank space, tab, character t */ -gchar * -strip_string (gchar * str, gchar t) -{ - gchar *ret = str; - gint length = 0; - guint i = 0; - - while (ret[i] != '\0' - && (ret[i] == '\t' || ret[i] == ' ' || ret[i] == t)) { - length++; - i++; - } - i = 0; - while (ret[i + length] != '\0') { - ret[i] = ret[i + length]; - i++; - } - ret[i] = '\0'; - length = strlen (ret); - while ((length - 1) >= 0 - && (ret[length - 1] == ' ' || ret[length - 1] == '\n' - || ret[length - 1] == '\t' || ret[length - 1] == t)) - length--; - ret[length] = '\0'; - return ret; -} - -gboolean -is_hex (const char *value) -{ - const char *p = value; - - if (!p) - return FALSE; - while (*p) { - if (!g_ascii_isxdigit (*p++)) - return FALSE; - } - return TRUE; -} - -gboolean -is_ascii (const char *value) -{ - const char *p = value; - - while (*p) { - if (!g_ascii_isprint (*p++)) - return FALSE; - } - return TRUE; - -} - -gboolean -is_true (const char *str) -{ - if (!g_ascii_strcasecmp (str, "yes") - || !g_ascii_strcasecmp (str, "true")) - return TRUE; - return FALSE; -} - -static char * -find_default_gateway_str (char *str) -{ - char *tmp; - - if ((tmp = strstr (str, "default via ")) != NULL) { - return tmp + strlen ("default via "); - } else if ((tmp = strstr (str, "default gw ")) != NULL) { - return tmp + strlen ("default gw "); - } - return NULL; -} - -static char * -find_gateway_str (char *str) -{ - char *tmp; - - if ((tmp = strstr (str, "via ")) != NULL) { - return tmp + strlen ("via "); - } else if ((tmp = strstr (str, "gw ")) != NULL) { - return tmp + strlen ("gw "); - } - return NULL; -} - -gboolean -reload_parsers (void) -{ - ifnet_destroy (); - wpa_parser_destroy (); - if (!ifnet_init (CONF_NET_FILE)) - return FALSE; - wpa_parser_init (WPA_SUPPLICANT_CONF); - return TRUE; -} - -gboolean -is_static_ip4 (const char *conn_name) -{ - const char *data = ifnet_get_data (conn_name, "config"); - const char *dhcp6; - - if (!data) - return FALSE; - if (!strcmp (data, "shared")) - return FALSE; - if (!strcmp (data, "autoip")) - return FALSE; - dhcp6 = strstr (data, "dhcp6"); - if (dhcp6) { - gchar *dhcp4; - - if (strstr (data, "dhcp ")) - return FALSE; - dhcp4 = strstr (data, "dhcp"); - if (!dhcp4) - return TRUE; - if (dhcp4[4] == '\0') - return FALSE; - return TRUE; - } - return strstr (data, "dhcp") == NULL ? TRUE : FALSE; -} - -gboolean -is_static_ip6 (const char *conn_name) -{ - const char *data = ifnet_get_data (conn_name, "config"); - - if (!data) - return TRUE; - return strstr (data, "dhcp6") == NULL ? TRUE : FALSE; -} - -gboolean -is_ip4_address (const char *in_address) -{ - const char *pattern = - "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.((\\{\\d{1,3}\\.\\.\\d{1,3}\\})|\\d{1,3})$"; - gchar *address = g_strdup (in_address); - gboolean result = FALSE; - gchar *tmp; - GRegex *regex = g_regex_new (pattern, 0, 0, NULL); - GMatchInfo *match_info = NULL; - - if (!address) - goto done; - g_strstrip (address); - if ((tmp = strstr (address, "/")) != NULL) - *tmp = '\0'; - if ((tmp = strstr (address, " ")) != NULL) - *tmp = '\0'; - g_regex_match (regex, address, 0, &match_info); - result = g_match_info_matches (match_info); -done: - if (match_info) - g_match_info_free (match_info); - g_regex_unref (regex); - g_free (address); - return result; -} - -gboolean -is_ip6_address (const char *in_address) -{ - struct in6_addr tmp_ip6_addr; - gchar *tmp, *address; - gboolean result = FALSE; - - if (!in_address) - return FALSE; - address = g_strdup (in_address); - g_strstrip (address); - if ((tmp = strchr (address, '/')) != NULL) - *tmp = '\0'; - if (inet_pton (AF_INET6, address, &tmp_ip6_addr)) - result = TRUE; - g_free (address); - return result; - -} - -// 'c' is only used for openrc style -static gchar ** -split_addresses_by_char (const gchar *addresses, const gchar *c) -{ - gchar **ipset; - - if (addresses == NULL) - return NULL; - - if (strchr (addresses, '(') != NULL) { // old baselayout style - gchar *tmp = g_strdup (addresses); - strip_string (tmp, '('); - strip_string (tmp, ')'); - strip_string (tmp, '"'); - strip_string (tmp, '\''); - ipset = g_strsplit (tmp, "\" \"", 0); - g_free(tmp); - } else { // openrc style - if (strstr (addresses, "netmask")) - // There is only one ip address if "netmask" is specified. - // '\n' is not used in config so there will be only one split. - ipset = g_strsplit (addresses, "\n", 0); - else - ipset = g_strsplit (addresses, c, 0); - } - - return ipset; -} - -static gchar ** -split_addresses (const gchar* addresses) -{ - // " " is only used by openrc style - return split_addresses_by_char (addresses, " "); -} - -static gchar ** -split_routes (const gchar* routes) -{ - // "\"" is only used by openrc style - return split_addresses_by_char (routes, "\""); -} - -gboolean -has_ip6_address (const char *conn_name) -{ - gchar **ipset; - guint length; - guint i; - - g_return_val_if_fail (conn_name != NULL, FALSE); - ipset = split_addresses (ifnet_get_data (conn_name, "config")); - length = ipset ? g_strv_length (ipset) : 0; - for (i = 0; i < length; i++) { - if (!is_ip6_address (ipset[i])) - continue; - else { - g_strfreev (ipset); - return TRUE; - } - - } - g_strfreev (ipset); - return FALSE; -} - -gboolean -has_default_route (const char *conn_name, gboolean (*check_fn) (const char *)) -{ - char *routes = NULL, *end, *tmp; - gboolean success = FALSE; - - g_return_val_if_fail (conn_name != NULL, FALSE); - - routes = g_strdup (ifnet_get_data (conn_name, "routes")); - if (!routes) - return FALSE; - tmp = find_default_gateway_str (routes); - if (tmp) { - g_strstrip (tmp); - if ((end = strstr (tmp, "\"")) != NULL) - *end = '\0'; - if (check_fn (tmp)) - success = TRUE; - } - - g_free (routes); - return success; -} - -static ip_block * -create_ip4_block (gchar * ip) -{ - ip_block *iblock = g_slice_new0 (ip_block); - guint32 tmp_ip4_addr; - int i; - guint length; - gchar **ip_mask; - - /* prefix format */ - if (strstr (ip, "/")) { - gchar *prefix; - - ip_mask = g_strsplit (ip, "/", 0); - length = g_strv_length (ip_mask); - if (!nm_utils_ipaddr_valid (AF_INET, ip_mask[0])) - goto error; - iblock->ip = g_strdup (ip_mask[0]); - prefix = ip_mask[1]; - i = 0; - while (i < length && g_ascii_isdigit (prefix[i])) - i++; - prefix[i] = '\0'; - iblock->prefix = (guint32) atoi (ip_mask[1]); - } else if (strstr (ip, "netmask")) { - ip_mask = g_strsplit (ip, " ", 0); - length = g_strv_length (ip_mask); - if (!nm_utils_ipaddr_valid (AF_INET, ip_mask[0])) - goto error; - iblock->ip = g_strdup (ip_mask[0]); - i = 0; - while (i < length && !strstr (ip_mask[++i], "netmask")) ; - while (i < length && ip_mask[++i][0] == '\0') ; - if (i >= length) - goto error; - if (!inet_pton (AF_INET, ip_mask[i], &tmp_ip4_addr)) - goto error; - iblock->prefix = nm_utils_ip4_netmask_to_prefix (tmp_ip4_addr); - } else { - g_slice_free (ip_block, iblock); - if (!is_ip6_address (ip) && !strstr (ip, "dhcp")) - nm_log_warn (LOGD_SETTINGS, "Can't handle ipv4 address: %s, missing netmask or prefix", ip); - return NULL; - } - if (iblock->prefix == 0 || iblock->prefix > 32) { - nm_log_warn (LOGD_SETTINGS, "Can't handle ipv4 address: %s, invalid prefix", ip); - goto error; - } - g_strfreev (ip_mask); - return iblock; -error: - if (!is_ip6_address (ip)) - nm_log_warn (LOGD_SETTINGS, "Can't handle IPv4 address: %s", ip); - g_strfreev (ip_mask); - g_free (iblock->ip); - g_slice_free (ip_block, iblock); - return NULL; -} - -static ip_block * -create_ip_block (gchar * ip) -{ - ip_block *iblock = g_slice_new0 (ip_block); - gchar *dup_ip = g_strdup (ip); - gchar *prefix = NULL; - - if ((prefix = strstr (dup_ip, "/")) != NULL) { - *prefix = '\0'; - prefix++; - } - if (!nm_utils_ipaddr_valid (AF_INET6, dup_ip)) - goto error; - iblock->ip = dup_ip; - if (prefix) { - errno = 0; - iblock->prefix = strtol (prefix, NULL, 10); - if (errno || iblock->prefix <= 0 || iblock->prefix > 128) { - goto error; - } - } else - iblock->prefix = 64; - return iblock; -error: - if (!is_ip4_address (ip)) - nm_log_warn (LOGD_SETTINGS, "Can't handle IPv6 address: %s", ip); - g_slice_free (ip_block, iblock); - g_free (dup_ip); - return NULL; -} - -static char * -get_ip4_gateway (gchar * gateway) -{ - gchar *tmp, *split; - - if (!gateway) - return NULL; - tmp = find_gateway_str (gateway); - if (!tmp) { - nm_log_warn (LOGD_SETTINGS, "Couldn't obtain gateway in \"%s\"", gateway); - return NULL; - } - tmp = g_strdup (tmp); - strip_string (tmp, ' '); - strip_string (tmp, '"'); - - // Only one gateway is selected - if ((split = strstr (tmp, "\"")) != NULL) - *split = '\0'; - - if (!nm_utils_ipaddr_valid (AF_INET, tmp)) - goto error; - return tmp; -error: - if (!is_ip6_address (tmp)) - nm_log_warn (LOGD_SETTINGS, "Can't handle IPv4 gateway: %s", tmp); - g_free (tmp); - return NULL; -} - -static char * -get_ip6_next_hop (gchar * next_hop) -{ - gchar *tmp; - - if (!next_hop) - return NULL; - tmp = find_gateway_str (next_hop); - if (!tmp) { - nm_log_warn (LOGD_SETTINGS, "Couldn't obtain next_hop in \"%s\"", next_hop); - return NULL; - } - tmp = g_strdup (tmp); - strip_string (tmp, ' '); - strip_string (tmp, '"'); - g_strstrip (tmp); - if (!nm_utils_ipaddr_valid (AF_INET6, tmp)) - goto error; - return tmp; -error: - if (!is_ip4_address (tmp)) - nm_log_warn (LOGD_SETTINGS, "Can't handle IPv6 next_hop: %s", tmp); - g_free (tmp); - - return NULL; -} - -ip_block * -convert_ip4_config_block (const char *conn_name) -{ - gchar **ipset; - guint length; - guint i; - gchar *ip; - char *def_gateway = NULL; - const char *routes; - ip_block *start = NULL, *current = NULL, *iblock = NULL; - - g_return_val_if_fail (conn_name != NULL, NULL); - - ipset = split_addresses (ifnet_get_data (conn_name, "config")); - length = ipset ? g_strv_length (ipset) : 0; - - routes = ifnet_get_data (conn_name, "routes"); - if (routes) - def_gateway = get_ip4_gateway (strstr (routes, "default")); - - for (i = 0; i < length; i++) { - ip = ipset[i]; - ip = strip_string (ip, '"'); - iblock = create_ip4_block (ip); - if (iblock == NULL) - continue; - if (!iblock->next_hop && def_gateway != NULL) - iblock->next_hop = g_strdup (def_gateway); - if (start == NULL) - start = current = iblock; - else { - current->next = iblock; - current = iblock; - } - } - g_strfreev (ipset); - g_free (def_gateway); - return start; -} - -ip_block * -convert_ip6_config_block (const char *conn_name) -{ - gchar **ipset; - guint length; - guint i; - gchar *ip; - ip_block *start = NULL, *current = NULL, *iblock = NULL; - - g_return_val_if_fail (conn_name != NULL, NULL); - ipset = split_addresses (ifnet_get_data (conn_name, "config")); - length = ipset ? g_strv_length (ipset) : 0; - for (i = 0; i < length; i++) { - ip = ipset[i]; - ip = strip_string (ip, '"'); - iblock = create_ip_block (ip); - if (iblock == NULL) - continue; - if (start == NULL) - start = current = iblock; - else { - current->next = iblock; - current = iblock; - } - } - g_strfreev (ipset); - return start; -} - -ip_block * -convert_ip4_routes_block (const char *conn_name) -{ - gchar **ipset; - guint length; - guint i; - gchar *ip; - ip_block *start = NULL, *current = NULL, *iblock = NULL; - - g_return_val_if_fail (conn_name != NULL, NULL); - - ipset = split_routes (ifnet_get_data (conn_name, "routes")); - length = ipset ? g_strv_length (ipset) : 0; - for (i = 0; i < length; i++) { - ip = ipset[i]; - if (find_default_gateway_str (ip) || strstr (ip, "::") - || !find_gateway_str (ip)) - continue; - ip = strip_string (ip, '"'); - iblock = create_ip4_block (ip); - if (iblock == NULL) - continue; - iblock->next_hop = get_ip4_gateway (ip); - if (start == NULL) - start = current = iblock; - else { - current->next = iblock; - current = iblock; - } - } - g_strfreev (ipset); - return start; -} - -ip_block * -convert_ip6_routes_block (const char *conn_name) -{ - gchar **ipset; - guint length; - guint i; - gchar *ip, *tmp_addr; - ip_block *start = NULL, *current = NULL, *iblock = NULL; - - g_return_val_if_fail (conn_name != NULL, NULL); - ipset = split_routes (ifnet_get_data (conn_name, "routes")); - length = ipset ? g_strv_length (ipset) : 0; - for (i = 0; i < length; i++) { - ip = ipset[i]; - ip = strip_string (ip, '"'); - if (ip[0] == '\0') - continue; - if ((tmp_addr = find_default_gateway_str (ip)) != NULL) { - if (!is_ip6_address (tmp_addr)) - continue; - else { - iblock = g_slice_new0 (ip_block); - iblock->ip = g_strdup ("::"); - iblock->prefix = 128; - } - } else - iblock = create_ip_block (ip); - if (iblock == NULL) - continue; - iblock->next_hop = get_ip6_next_hop (ip); - if (iblock->next_hop == NULL) { - destroy_ip_block (iblock); - continue; - } - if (start == NULL) - start = current = iblock; - else { - current->next = iblock; - current = iblock; - } - } - g_strfreev (ipset); - return start; -} - -void -destroy_ip_block (ip_block * iblock) -{ - g_free (iblock->ip); - g_free (iblock->next_hop); - g_slice_free (ip_block, iblock); -} - -void -set_ip4_dns_servers (NMSettingIPConfig *s_ip4, const char *conn_name) -{ - const char *dns_servers; - gchar **server_list, *stripped; - guint length, i; - guint32 tmp_ip4_addr; - - dns_servers = ifnet_get_data (conn_name, "dns_servers"); - if (!dns_servers) - return; - stripped = g_strdup (dns_servers); - strip_string (stripped, '"'); - server_list = g_strsplit (stripped, " ", 0); - g_free (stripped); - - length = g_strv_length (server_list); - if (length) - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, - TRUE, NULL); - for (i = 0; i < length; i++) { - g_strstrip (server_list[i]); - if (server_list[i][0] == '\0') - continue; - if (!inet_pton (AF_INET, server_list[i], &tmp_ip4_addr)) { - if (!is_ip6_address (server_list[i])) - nm_log_warn (LOGD_SETTINGS, "ignored dns: %s\n", server_list[i]); - continue; - } - if (!nm_setting_ip_config_add_dns (s_ip4, server_list[i])) - nm_log_warn (LOGD_SETTINGS, "warning: duplicate DNS server %s", server_list[i]); - } - g_strfreev (server_list); -} - -void -set_ip6_dns_servers (NMSettingIPConfig *s_ip6, const char *conn_name) -{ - const char *dns_servers; - gchar **server_list, *stripped; - guint length, i; - struct in6_addr tmp_ip6_addr; - - dns_servers = ifnet_get_data (conn_name, "dns_servers"); - if (!dns_servers) - return; - - stripped = g_strdup (dns_servers); - strip_string (stripped, '"'); - server_list = g_strsplit (stripped, " ", 0); - g_free (stripped); - - length = g_strv_length (server_list); - if (length) - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, - TRUE, NULL); - for (i = 0; i < length; i++) { - g_strstrip (server_list[i]); - if (server_list[i][0] == '\0') - continue; - if (!inet_pton (AF_INET6, server_list[i], &tmp_ip6_addr)) { - if (is_ip6_address (server_list[i])) - nm_log_warn (LOGD_SETTINGS, "ignored dns: %s\n", server_list[i]); - continue; - } - if (!nm_setting_ip_config_add_dns (s_ip6, server_list[i])) - nm_log_warn (LOGD_SETTINGS, "warning: duplicate DNS server %s", server_list[i]); - } - g_strfreev (server_list); -} - -gboolean -is_managed (const char *conn_name) -{ - gchar *config; - - g_return_val_if_fail (conn_name != NULL, FALSE); - config = (gchar *) ifnet_get_data (conn_name, "managed"); - if (!config) - return TRUE; - if (strcmp (config, "false") == 0) - return FALSE; - return TRUE; -} - -static char * -_has_prefix_impl (char *str, const char *prefix, gsize prefix_len) -{ - if (!g_str_has_prefix (str, prefix)) - return NULL; - str += prefix_len; - if (!g_ascii_isspace (str[0])) - return NULL; - do { - str++; - } while (g_ascii_isspace (str[0])); - return str; -} -#define _has_prefix(STR, PREFIX) _has_prefix_impl (STR, PREFIX, NM_STRLEN (PREFIX)) - -void -get_dhcp_hostname_and_client_id (char **hostname, char **client_id) -{ - const char *dhcp_client; - const gchar *dhcpcd_conf = SYSCONFDIR "/dhcpcd.conf"; - const gchar *dhclient_conf = SYSCONFDIR "/dhcp/dhclient.conf"; - gchar *line = NULL, *tmp = NULL, *contents = NULL, *tmp1; - gchar **all_lines; - guint line_num, i; - gboolean use_dhclient = FALSE; - - *hostname = NULL; - *client_id = NULL; - dhcp_client = nm_config_get_dhcp_client (nm_config_get ()); - if (dhcp_client) { - if (!strcmp (dhcp_client, "dhclient")) { - g_file_get_contents (dhclient_conf, &contents, NULL, - NULL); - use_dhclient = TRUE; - } else if (!strcmp (dhcp_client, "dhcpcd")) - g_file_get_contents (dhcpcd_conf, &contents, NULL, - NULL); - } else { - if (g_file_test (dhclient_conf, G_FILE_TEST_IS_REGULAR)) { - g_file_get_contents (dhclient_conf, &contents, NULL, - NULL); - use_dhclient = TRUE; - } - else if (g_file_test (dhcpcd_conf, G_FILE_TEST_IS_REGULAR)) - g_file_get_contents (dhcpcd_conf, &contents, NULL, - NULL); - } - if (!contents) - return; - all_lines = g_strsplit (contents, "\n", 0); - line_num = g_strv_length (all_lines); - for (i = 0; i < line_num; i++) { - line = all_lines[i]; - g_strstrip (line); - if (line[0] == '#' || line[0] == '\0') - continue; - if (!use_dhclient) { - // dhcpcd.conf - if ((tmp = _has_prefix (line, "hostname"))) { - if (tmp[0] != '\0') { - g_free (*hostname); - *hostname = g_strdup (tmp); - } else - nm_log_info (LOGD_SETTINGS, "dhcpcd hostname not defined, ignoring"); - } else if ((tmp = _has_prefix (line, "clientid"))) { - if (tmp[0] != '\0') { - g_free (*client_id); - *client_id = g_strdup (tmp); - } else - nm_log_info (LOGD_SETTINGS, "dhcpcd clientid not defined, ignoring"); - } - } else { - // dhclient.conf - if ((tmp1 = _has_prefix (line, "send"))) { - if ((tmp = _has_prefix (tmp1, "host-name"))) { - strip_string (tmp, ';'); - strip_string (tmp, '"'); - if (tmp[0] != '\0') { - g_free (*hostname); - *hostname = g_strdup (tmp); - } else - nm_log_info (LOGD_SETTINGS, "dhclient hostname not defined, ignoring"); - } else if ((tmp = _has_prefix (tmp1, "dhcp-client-identifier"))) { - strip_string (tmp, ';'); - if (tmp[0] != '\0') { - g_free (*client_id); - *client_id = g_strdup (tmp); - } else - nm_log_info (LOGD_SETTINGS, "dhclient clientid not defined, ignoring"); - } - } - } - } - g_strfreev (all_lines); - g_free (contents); -} - -gchar *backup_file (const gchar* target) -{ - GFile *source, *backup; - gchar* backup_path; - GError *error = NULL; - - source = g_file_new_for_path (target); - - if (!g_file_query_exists (source, NULL)) { - g_object_unref (source); - return NULL; - } - - backup_path = g_strdup_printf ("%s.bak", target); - backup = g_file_new_for_path (backup_path); - - if (!g_file_copy (source, backup, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error)) { - nm_log_warn (LOGD_SETTINGS, "Backup failed: %s", error->message); - g_free (backup_path); - backup_path = NULL; - g_error_free (error); - } - - g_object_unref (source); - g_object_unref (backup); - - return backup_path; -} diff --git a/src/settings/plugins/ifnet/net_utils.h b/src/settings/plugins/ifnet/net_utils.h deleted file mode 100644 index 85a5cb1c..00000000 --- a/src/settings/plugins/ifnet/net_utils.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#ifndef _IFNET_UTILS_H -#define _IFNET_UTILS_H - -#define IFNET_PLUGIN_NAME "SettingsPlugin-Ifnet" - -#include - -#include -#include -#include "net_parser.h" - -#define has_default_ip4_route(conn_name) has_default_route((conn_name), &is_ip4_address) -#define has_default_ip6_route(conn_name) has_default_route((conn_name), &is_ip6_address) - -typedef struct _ip_block { - char *ip; - guint32 prefix; - char *next_hop; - struct _ip_block *next; -} ip_block; - -gboolean is_static_ip4 (const char *conn_name); -gboolean is_static_ip6 (const char *conn_name); -gboolean is_ip4_address (const char *in_address); -gboolean is_ip6_address (const char *in_address); -gboolean has_ip6_address (const char *conn_name); -gboolean has_default_route (const char *conn_name, gboolean (*check_fn) (const char *)); -gboolean reload_parsers (void); - -ip_block *convert_ip4_config_block (const char *conn_name); -ip_block *convert_ip6_config_block (const char *conn_name); -ip_block *convert_ip4_routes_block (const char *conn_name); -ip_block *convert_ip6_routes_block (const char *conn_name); -void destroy_ip_block (ip_block * iblock); - -void set_ip4_dns_servers (NMSettingIPConfig * s_ip4, const char *conn_name); -void set_ip6_dns_servers (NMSettingIPConfig * s_ip6, const char *conn_name); - -gchar *strip_string (gchar *str, gchar t); -gboolean is_managed (const char *conn_name); - -gboolean is_hex (const char *value); -gboolean is_ascii (const char *value); -gboolean is_true (const char *str); - -void get_dhcp_hostname_and_client_id (char **hostname, char **client_id); - -gchar *backup_file (const gchar* target); -#endif diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.c b/src/settings/plugins/ifnet/nm-ifnet-connection.c deleted file mode 100644 index b661b03e..00000000 --- a/src/settings/plugins/ifnet/nm-ifnet-connection.c +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-dbus-interface.h" -#include "nm-utils.h" -#include "nm-setting-wireless-security.h" -#include "nm-settings-connection.h" -#include "nm-settings-plugin.h" -#include "nm-ifnet-connection.h" -#include "connection_parser.h" -#include "net_parser.h" -#include "net_utils.h" -#include "wpa_parser.h" -#include "plugin.h" - -G_DEFINE_TYPE (NMIfnetConnection, nm_ifnet_connection, NM_TYPE_SETTINGS_CONNECTION) - -#define NM_IFNET_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionPrivate)) - -enum { - IFNET_SETUP_MONITORS, - IFNET_CANCEL_MONITORS, - IFNET_LAST_SIGNAL -}; - -static guint signals[IFNET_LAST_SIGNAL] = { 0 }; - -typedef struct { - gchar *conn_name; - NMSettingsPlugin *config; -} NMIfnetConnectionPrivate; - -NMIfnetConnection * -nm_ifnet_connection_new (NMConnection *source, const char *conn_name) -{ - NMConnection *tmp; - GObject *object; - GError *error = NULL; - gboolean update_unsaved = TRUE; - - g_return_val_if_fail (source || conn_name, NULL); - - if (source) - tmp = g_object_ref (source); - else { - tmp = ifnet_update_connection_from_config_block (conn_name, NULL, &error); - if (!tmp) { - nm_log_warn (LOGD_SETTINGS, "Could not read connection '%s': %s", - conn_name, error->message); - g_error_free (error); - return NULL; - } - - /* If we just read the connection from disk, it's clearly not Unsaved */ - update_unsaved = FALSE; - } - - object = (GObject *) g_object_new (NM_TYPE_IFNET_CONNECTION, NULL); - g_assert (object); - NM_IFNET_CONNECTION_GET_PRIVATE (object)->conn_name = g_strdup (conn_name); - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - update_unsaved, - NULL, - NULL)) { - g_object_unref (object); - return NULL; - } - g_object_unref (tmp); - - return NM_IFNET_CONNECTION (object); -} - -static void -nm_ifnet_connection_init (NMIfnetConnection * connection) -{ -} - -const char * -nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection) -{ - return NM_IFNET_CONNECTION_GET_PRIVATE (connection)->conn_name; -} - -static void -commit_changes (NMSettingsConnection *connection, - NMSettingsConnectionCommitReason commit_reason, - NMSettingsConnectionCommitFunc callback, - gpointer user_data) -{ - GError *error = NULL; - NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE (connection); - gchar *new_name = NULL; - gboolean success = FALSE; - - g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0); - - if (priv->conn_name) { - /* Existing connection; update it */ - success = ifnet_update_parsers_by_connection (NM_CONNECTION (connection), - priv->conn_name, - CONF_NET_FILE, - WPA_SUPPLICANT_CONF, - &new_name, - NULL, - &error); - } else { - /* New connection, add it */ - success = ifnet_add_new_connection (NM_CONNECTION (connection), - CONF_NET_FILE, - WPA_SUPPLICANT_CONF, - &new_name, - NULL, - &error); - if (success) - reload_parsers (); - } - - if (success) { - /* update connection name */ - g_assert (new_name); - g_free (priv->conn_name); - priv->conn_name = new_name; - - NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); - nm_log_info (LOGD_SETTINGS, "Successfully updated %s", priv->conn_name); - } else { - nm_log_warn (LOGD_SETTINGS, "Failed to update %s", - priv->conn_name ? priv->conn_name : - nm_connection_get_id (NM_CONNECTION (connection))); - reload_parsers (); - callback (connection, error, user_data); - g_error_free (error); - } - - g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0); -} - -static void -do_delete (NMSettingsConnection *connection, - NMSettingsConnectionDeleteFunc callback, - gpointer user_data) -{ - GError *error = NULL; - NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE (connection); - - g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0); - - /* Only connections which exist in /etc/conf.d/net will have a conn_name */ - if (priv->conn_name) { - if (!ifnet_delete_connection_in_parsers (priv->conn_name, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL)) { - nm_log_warn (LOGD_SETTINGS, "Failed to delete %s", priv->conn_name); - reload_parsers (); - callback (connection, error, user_data); - g_error_free (error); - g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0); - return; - } - } - - NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->delete (connection, callback, user_data); - - g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0); - - nm_log_info (LOGD_SETTINGS, "Successfully deleted %s", - priv->conn_name ? priv->conn_name : - nm_connection_get_id (NM_CONNECTION (connection))); -} - -static void -finalize (GObject * object) -{ - g_free (NM_IFNET_CONNECTION_GET_PRIVATE (object)->conn_name); - G_OBJECT_CLASS (nm_ifnet_connection_parent_class)->finalize (object); -} - -static void -nm_ifnet_connection_class_init (NMIfnetConnectionClass * ifnet_connection_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (ifnet_connection_class); - NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (ifnet_connection_class); - - g_type_class_add_private (ifnet_connection_class, sizeof (NMIfnetConnectionPrivate)); - - object_class->finalize = finalize; - settings_class->delete = do_delete; - settings_class->commit_changes = commit_changes; - - signals[IFNET_SETUP_MONITORS] = - g_signal_new ("ifnet_setup_monitors", - G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[IFNET_CANCEL_MONITORS] = - g_signal_new ("ifnet_cancel_monitors", - G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.h b/src/settings/plugins/ifnet/nm-ifnet-connection.h deleted file mode 100644 index 856996e0..00000000 --- a/src/settings/plugins/ifnet/nm-ifnet-connection.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#ifndef __NETWORKMANAGER_IFNET_CONNECTION_H__ -#define __NETWORKMANAGER_IFNET_CONNECTION_H__ - -#include -#include "net_parser.h" - -#define NM_TYPE_IFNET_CONNECTION (nm_ifnet_connection_get_type ()) -#define NM_IFNET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFNET_CONNECTION, NMIfnetConnection)) -#define NM_IFNET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionClass)) -#define NM_IS_IFNET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFNET_CONNECTION)) -#define NM_IS_IFNET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFNET_CONNECTION)) -#define NM_IFNET_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionClass)) - -typedef struct { - NMSettingsConnection parent; -} NMIfnetConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMIfnetConnectionClass; - -GType nm_ifnet_connection_get_type (void); - -NMIfnetConnection *nm_ifnet_connection_new (NMConnection *source, - const char *conn_name); - -const char *nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection); - -#endif /* __NETWORKMANAGER_IFNET_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifnet/nms-ifnet-connection-parser.c b/src/settings/plugins/ifnet/nms-ifnet-connection-parser.c new file mode 100644 index 00000000..84f2d3f4 --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-connection-parser.c @@ -0,0 +1,2967 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifnet-connection-parser.h" + +#include +#include +#include +#include + +#include "settings/nm-settings-plugin.h" +#include "nm-core-internal.h" +#include "NetworkManagerUtils.h" + +#include "nms-ifnet-net-utils.h" +#include "nms-ifnet-wpa-parser.h" +#include "nms-ifnet-connection.h" + +static char * +connection_id_from_ifnet_name (const char *conn_name) +{ + int name_len = strlen (conn_name); + + /* Convert a hex-encoded conn_name (only used for wifi SSIDs) to human-readable one */ + if ((name_len > 2) && (g_str_has_prefix (conn_name, "0x"))) { + GBytes *bytes = nm_utils_hexstr2bin (conn_name); + char *buf; + + if (bytes) { + buf = g_strndup (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes)); + g_bytes_unref (bytes); + return buf; + } + } + + return g_strdup (conn_name); +} + +static gboolean eap_simple_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error); + +static gboolean eap_tls_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error); + +static gboolean eap_peap_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error); + +static gboolean eap_ttls_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error); + +typedef struct { + const char *method; + gboolean (*reader) (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error); + gboolean wifi_phase2_only; +} EAPReader; + +static EAPReader eap_readers[] = { + {"md5", eap_simple_reader, TRUE}, + {"pwd", eap_simple_reader, TRUE}, + {"pap", eap_simple_reader, TRUE}, + {"chap", eap_simple_reader, TRUE}, + {"mschap", eap_simple_reader, TRUE}, + {"mschapv2", eap_simple_reader, TRUE}, + {"leap", eap_simple_reader, TRUE}, + {"tls", eap_tls_reader, FALSE}, + {"peap", eap_peap_reader, FALSE}, + {"ttls", eap_ttls_reader, FALSE}, + {NULL, NULL} +}; + +/* reading identity and password */ +static gboolean +eap_simple_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error) +{ + const char *value; + + /* identity */ + value = wpa_get_value (ssid, "identity"); + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", + eap_method); + return FALSE; + } + g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); + + /* password */ + value = wpa_get_value (ssid, "password"); + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_PASSWORD for EAP method '%s'.", + eap_method); + return FALSE; + } + + g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, value, NULL); + + return TRUE; +} + +static char * +get_cert (const char *ssid, const char *key, const char *basepath) +{ + const char *orig; + + /* If it's a relative path, convert to absolute using 'basepath' */ + orig = wpa_get_value (ssid, key); + if (g_path_is_absolute (orig)) + return g_strdup (orig); + return g_strdup_printf ("%s/%s", basepath, orig); +} + +static gboolean +eap_tls_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error) +{ + const char *value; + char *ca_cert = NULL; + char *client_cert = NULL; + char *privkey = NULL; + const char *privkey_password = NULL; + gboolean success = FALSE; + NMSetting8021xCKFormat privkey_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; + + /* identity */ + value = wpa_get_value (ssid, "identity"); + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", + eap_method); + return FALSE; + } + g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); + + /* ca cert */ + ca_cert = get_cert (ssid, phase2 ? "ca_cert2" : "ca_cert", basepath); + if (ca_cert) { + if (phase2) { + if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, + ca_cert, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, error)) + goto done; + } else { + if (!nm_setting_802_1x_set_ca_cert (s_8021x, + ca_cert, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, error)) + goto done; + } + } else { + nm_log_warn (LOGD_SETTINGS, " missing %s for EAP method '%s'; this is insecure!", + phase2 ? "IEEE_8021X_INNER_CA_CERT" : + "IEEE_8021X_CA_CERT", eap_method); + } + + /* Private key password */ + privkey_password = wpa_get_value (ssid, + phase2 ? "private_key2_passwd" : + "private_key_passwd"); + + if (!privkey_password) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing %s for EAP method '%s'.", + phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD" : + "IEEE_8021X_PRIVATE_KEY_PASSWORD", eap_method); + goto done; + } + + /* The private key itself */ + privkey = get_cert (ssid, phase2 ? "private_key2" : "private_key", basepath); + if (!privkey) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing %s for EAP method '%s'.", + phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" : + "IEEE_8021X_PRIVATE_KEY", eap_method); + goto done; + } + + if (phase2) { + if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, + privkey, + privkey_password, + NM_SETTING_802_1X_CK_SCHEME_PATH, + &privkey_format, + error)) + goto done; + } else { + if (!nm_setting_802_1x_set_private_key (s_8021x, + privkey, + privkey_password, + NM_SETTING_802_1X_CK_SCHEME_PATH, + &privkey_format, error)) + goto done; + } + + /* Only set the client certificate if the private key is not PKCS#12 format, + * as NM (due to supplicant restrictions) requires. If the key was PKCS#12, + * then nm_setting_802_1x_set_private_key() already set the client certificate + * to the same value as the private key. + */ + if (privkey_format == NM_SETTING_802_1X_CK_FORMAT_RAW_KEY + || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { + client_cert = get_cert (ssid, phase2 ? "client_cert2" : "client_cert", basepath); + if (!client_cert) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing %s for EAP method '%s'.", + phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : + "IEEE_8021X_CLIENT_CERT", eap_method); + goto done; + } + + if (phase2) { + if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, + client_cert, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, + error)) + goto done; + } else { + if (!nm_setting_802_1x_set_client_cert (s_8021x, + client_cert, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, error)) + goto done; + } + } + + success = TRUE; + +done: + g_free (ca_cert); + g_free (client_cert); + g_free (privkey); + return success; +} + +static gboolean +eap_peap_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error) +{ + char *ca_cert = NULL; + const char *inner_auth = NULL; + const char *peapver = NULL; + char **list = NULL, **iter, *lower; + gboolean success = FALSE; + + ca_cert = get_cert (ssid, "ca_cert", basepath); + if (ca_cert) { + if (!nm_setting_802_1x_set_ca_cert (s_8021x, + ca_cert, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, error)) + goto done; + } else { + nm_log_warn (LOGD_SETTINGS, " missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", + eap_method); + } + + peapver = wpa_get_value (ssid, "phase1"); + /* peap version, default is automatic */ + if (peapver && strstr (peapver, "peapver")) { + if (strstr (peapver, "peapver=0")) + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, + "0", NULL); + else if (strstr (peapver, "peapver=1")) + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, + "1", NULL); + else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown IEEE_8021X_PEAP_VERSION value '%s'", + peapver); + goto done; + } + } + + /* peaplabel */ + if (peapver && strstr (peapver, "peaplabel=1")) + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPLABEL, "1", + NULL); + + inner_auth = wpa_get_value (ssid, "phase2"); + if (!inner_auth) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_INNER_AUTH_METHODS."); + goto done; + } + /* Handle options for the inner auth method */ + list = g_strsplit (inner_auth, " ", 0); + for (iter = list; iter && *iter; iter++) { + gchar *pos = NULL; + + if (!strlen (*iter)) + continue; + + if (!(pos = strstr (*iter, "MSCHAPV2")) + || !(pos = strstr (*iter, "MD5")) + || !(pos = strstr (*iter, "GTC"))) { + if (!eap_simple_reader (pos, ssid, s_8021x, TRUE, basepath, error)) + goto done; + } else if (!(pos = strstr (*iter, "TLS"))) { + if (!eap_tls_reader (pos, ssid, s_8021x, TRUE, basepath, error)) + goto done; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", + *iter); + goto done; + } + + pos = strchr (*iter, '='); + if (pos && *pos) { + pos++; + lower = g_ascii_strdown (pos, -1); + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, lower, + NULL); + g_free (lower); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No IEEE_8021X_INNER_AUTH_METHOD."); + goto done; + } + break; + } + + if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No valid IEEE_8021X_INNER_AUTH_METHODS found."); + goto done; + } + + success = TRUE; + +done: + g_free (ca_cert); + if (list) + g_strfreev (list); + return success; +} + +static gboolean +eap_ttls_reader (const char *eap_method, + const char *ssid, + NMSetting8021x *s_8021x, + gboolean phase2, + const char *basepath, + GError **error) +{ + gboolean success = FALSE; + const char *anon_ident = NULL; + char *ca_cert = NULL; + const char *tmp; + char **list = NULL, **iter, *inner_auth = NULL; + + /* ca cert */ + ca_cert = get_cert (ssid, "ca_cert", basepath); + if (ca_cert) { + if (!nm_setting_802_1x_set_ca_cert (s_8021x, + ca_cert, + NM_SETTING_802_1X_CK_SCHEME_PATH, + NULL, error)) + goto done; + } else { + nm_log_warn (LOGD_SETTINGS, " missing IEEE_8021X_CA_CERT for EAP method '%s'; this is insecure!", + eap_method); + } + + /* anonymous indentity for tls */ + anon_ident = wpa_get_value (ssid, "anonymous_identity"); + if (anon_ident && strlen (anon_ident)) + g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, + anon_ident, NULL); + + tmp = wpa_get_value (ssid, "phase2"); + if (!tmp) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_INNER_AUTH_METHODS."); + goto done; + } + + /* Handle options for the inner auth method */ + inner_auth = g_ascii_strdown (tmp, -1); + list = g_strsplit (inner_auth, " ", 0); + for (iter = list; iter && *iter; iter++) { + gchar *pos = NULL; + + if (!strlen (*iter)) + continue; + if ((pos = strstr (*iter, "mschapv2")) != NULL + || (pos = strstr (*iter, "mschap")) != NULL + || (pos = strstr (*iter, "pap")) != NULL + || (pos = strstr (*iter, "chap")) != NULL) { + if (!eap_simple_reader (pos, ssid, s_8021x, TRUE, basepath, error)) + goto done; + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, + pos, NULL); + } else if ((pos = strstr (*iter, "tls")) != NULL) { + if (!eap_tls_reader (pos, ssid, s_8021x, TRUE, basepath, error)) + goto done; + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, + "tls", NULL); + } else if ((pos = strstr (*iter, "mschapv2")) != NULL + || (pos = strstr (*iter, "md5")) != NULL) { + if (!eap_simple_reader (pos, ssid, s_8021x, TRUE, basepath, error)) { + nm_log_warn (LOGD_SETTINGS, "SIMPLE ERROR"); + goto done; + } + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, + pos, NULL); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", + *iter); + goto done; + } + break; + } + + success = TRUE; +done: + g_free (ca_cert); + if (list) + g_strfreev (list); + g_free (inner_auth); + return success; +} + +/* type is already decided by net_parser, this function is just used to + * doing tansformation*/ +static const gchar * +guess_connection_type (const char *conn_name) +{ + const gchar *type = ifnet_get_data (conn_name, "type"); + const gchar *ret_type = NULL; + + if (!g_strcmp0 (type, "ppp")) + ret_type = NM_SETTING_PPPOE_SETTING_NAME; + + if (!g_strcmp0 (type, "wireless")) + ret_type = NM_SETTING_WIRELESS_SETTING_NAME; + + if (!ret_type) + ret_type = NM_SETTING_WIRED_SETTING_NAME; + + nm_log_info (LOGD_SETTINGS, "guessed connection type (%s) = %s", conn_name, ret_type); + return ret_type; +} + +/* Reading mac address for setting connection option. + * Unmanaged device mac address is required by NetworkManager*/ +static gboolean +read_mac_address (const char *conn_name, const char **mac, GError **error) +{ + const char *value = ifnet_get_data (conn_name, "mac"); + + if (!value || !strlen (value)) + return TRUE; + + if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "The MAC address '%s' was invalid.", value); + return FALSE; + } + + *mac = value; + return TRUE; +} + +static gboolean +make_wired_connection_setting (NMConnection *connection, + const char *conn_name, + GError **error) +{ + const char *mac = NULL; + NMSettingWired *s_wired = NULL; + const char *value = NULL; + + s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); + + /* mtu_xxx */ + value = ifnet_get_data (conn_name, "mtu"); + if (value) { + long int mtu; + + errno = 0; + mtu = strtol (value, NULL, 10); + if (errno || mtu < 0 || mtu > 65535) { + nm_log_warn (LOGD_SETTINGS, " invalid MTU '%s' for %s", value, conn_name); + } else + g_object_set (s_wired, NM_SETTING_WIRED_MTU, + (guint32) mtu, NULL); + } + + if (!read_mac_address (conn_name, &mac, error)) { + g_object_unref (s_wired); + return FALSE; + } + + if (mac) + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + return TRUE; +} + +/* add NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, + * NM_SETTING_IP_CONFIG_DHCP_CLIENT_ID in future*/ +static gboolean +make_ip4_setting (NMConnection *connection, + const char *conn_name, + GError **error) +{ + + NMSettingIPConfig *ip4_setting = + NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new ()); + const char *value, *method = NULL; + gboolean is_static_block = is_static_ip4 (conn_name); + ip_block *iblock = NULL; + + /* set dhcp options (dhcp_xxx) */ + value = ifnet_get_data (conn_name, "dhcp"); + g_object_set (ip4_setting, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, value + && strstr (value, "nodns") ? TRUE : FALSE, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, value + && strstr (value, "nogateway") ? TRUE : FALSE, NULL); + + if (!is_static_block) { + method = ifnet_get_data (conn_name, "config"); + if (!method){ + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown config for %s", conn_name); + g_object_unref (ip4_setting); + return FALSE; + } + if (strstr (method, "dhcp")) + g_object_set (ip4_setting, + NM_SETTING_IP_CONFIG_METHOD, + NM_SETTING_IP4_CONFIG_METHOD_AUTO, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL); + else if (strstr (method, "autoip")) { + g_object_set (ip4_setting, + NM_SETTING_IP_CONFIG_METHOD, + NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL); + nm_connection_add_setting (connection, NM_SETTING (ip4_setting)); + return TRUE; + } else if (strstr (method, "shared")) { + g_object_set (ip4_setting, + NM_SETTING_IP_CONFIG_METHOD, + NM_SETTING_IP4_CONFIG_METHOD_SHARED, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, FALSE, NULL); + nm_connection_add_setting (connection, NM_SETTING (ip4_setting)); + return TRUE; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown config for %s", conn_name); + g_object_unref (ip4_setting); + return FALSE; + } + nm_log_info (LOGD_SETTINGS, "Using %s method for %s", method, conn_name); + }else { + iblock = convert_ip4_config_block (conn_name); + if (!iblock) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ifnet plugin: can't aquire ip configuration for %s", + conn_name); + g_object_unref (ip4_setting); + return FALSE; + } + /************** add all ip settings to the connection**********/ + while (iblock) { + ip_block *current_iblock; + NMIPAddress *ip4_addr; + GError *local = NULL; + + ip4_addr = nm_ip_address_new (AF_INET, iblock->ip, iblock->prefix, &local); + if (iblock->next_hop) + g_object_set (ip4_setting, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, + TRUE, NULL); + + if (ip4_addr) { + if (!nm_setting_ip_config_add_address (ip4_setting, ip4_addr)) + nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP4 address"); + nm_ip_address_unref (ip4_addr); + } else { + nm_log_warn (LOGD_SETTINGS, " ignoring invalid address entry: %s", local->message); + g_clear_error (&local); + } + + current_iblock = iblock; + iblock = iblock->next; + destroy_ip_block (current_iblock); + + } + g_object_set (ip4_setting, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, !has_default_ip4_route (conn_name), + NULL); + } + + /* add dhcp hostname and client id */ + if (!is_static_block && strstr (method, "dhcp")) { + gchar *dhcp_hostname, *client_id; + + get_dhcp_hostname_and_client_id (&dhcp_hostname, &client_id); + if (dhcp_hostname) { + g_object_set (ip4_setting, + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, + dhcp_hostname, NULL); + nm_log_info (LOGD_SETTINGS, "DHCP hostname: %s", dhcp_hostname); + g_free (dhcp_hostname); + } + if (client_id) { + g_object_set (ip4_setting, + NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, + client_id, NULL); + nm_log_info (LOGD_SETTINGS, "DHCP client id: %s", client_id); + g_free (client_id); + } + } + + /* add all IPv4 dns servers, IPv6 servers will be ignored */ + set_ip4_dns_servers (ip4_setting, conn_name); + + /* DNS searches */ + value = ifnet_get_data (conn_name, "dns_search"); + if (value) { + gs_free char *stripped = g_strdup (value); + char **searches = NULL; + + strip_string (stripped, '"'); + + searches = g_strsplit (stripped, " ", 0); + if (searches) { + char **item; + + for (item = searches; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_search (ip4_setting, *item)) + nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *item); + } + } + g_strfreev (searches); + } + } + + /* static routes */ + iblock = convert_ip4_routes_block (conn_name); + while (iblock) { + ip_block *current_iblock = iblock; + const char *metric_str; + char *stripped; + gint64 metric; + NMIPRoute *route; + GError *local = NULL; + + if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) { + metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); + } else { + metric_str = ifnet_get_global_data ("metric"); + if (metric_str) { + stripped = g_strdup (metric_str); + strip_string (stripped, '"'); + metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); + g_free (stripped); + } else + metric = -1; + } + + route = nm_ip_route_new (AF_INET, iblock->ip, iblock->prefix, iblock->next_hop, metric, &local); + if (route) { + if (nm_setting_ip_config_add_route (ip4_setting, route)) + nm_log_info (LOGD_SETTINGS, "new IP4 route:%s\n", iblock->ip); + else + nm_log_warn (LOGD_SETTINGS, "duplicate IP4 route"); + nm_ip_route_unref (route); + } else { + nm_log_warn (LOGD_SETTINGS, " ignoring invalid route entry: %s", local->message); + g_clear_error (&local); + } + + current_iblock = iblock; + iblock = iblock->next; + destroy_ip_block (current_iblock); + } + + /* Finally add setting to connection */ + nm_connection_add_setting (connection, NM_SETTING (ip4_setting)); + + return TRUE; +} + +static gboolean +make_ip6_setting (NMConnection *connection, + const char *conn_name, + GError **error) +{ + NMSettingIPConfig *s_ip6 = NULL; + gboolean is_static_block = is_static_ip6 (conn_name); + + // used to disable IPv6 + gboolean ipv6_enabled = FALSE; + gchar *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + const char *value; + ip_block *iblock; + gboolean never_default = !has_default_ip6_route (conn_name); + + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); + + value = ifnet_get_data (conn_name, "enable_ipv6"); + if (value && is_true (value)) + ipv6_enabled = TRUE; + + //FIXME Handle other methods that NM supports in future + // Currently only Manual and DHCP are supported + if (!ipv6_enabled) { + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, + NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + goto done; + } else if (!is_static_block) { + // config_eth* contains "dhcp6" + method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; + never_default = FALSE; + } + // else if (!has_ip6_address(conn_name)) + // doesn't have "dhcp6" && doesn't have any ipv6 address + // method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; + else + // doesn't have "dhcp6" && has at least one ipv6 address + method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + nm_log_info (LOGD_SETTINGS, "IPv6 for %s enabled, using %s", conn_name, method); + + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, method, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, FALSE, + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, FALSE, + NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, NULL); + + /* Make manual settings */ + if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { + ip_block *current_iblock; + + iblock = convert_ip6_config_block (conn_name); + if (!iblock) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ifnet plugin: can't aquire ip6 configuration for %s", + conn_name); + goto error; + } + /* add all IPv6 addresses */ + while (iblock) { + NMIPAddress *ip6_addr; + GError *local = NULL; + + ip6_addr = nm_ip_address_new (AF_INET6, iblock->ip, iblock->prefix, &local); + if (ip6_addr) { + if (nm_setting_ip_config_add_address (s_ip6, ip6_addr)) { + nm_log_info (LOGD_SETTINGS, "ipv6 addresses count: %d", + nm_setting_ip_config_get_num_addresses (s_ip6)); + } else { + nm_log_warn (LOGD_SETTINGS, "ignoring duplicate IP6 address"); + } + nm_ip_address_unref (ip6_addr); + } else { + nm_log_warn (LOGD_SETTINGS, " ignoring invalid address entry: %s", local->message); + g_clear_error (&local); + } + + current_iblock = iblock; + iblock = iblock->next; + destroy_ip_block (current_iblock); + } + + } else if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { + /* - autoconf or DHCPv6 stuff goes here */ + } + // DNS Servers, set NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS TRUE here + set_ip6_dns_servers (s_ip6, conn_name); + + /* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */ + + // Add routes + iblock = convert_ip6_routes_block (conn_name); + if (iblock) + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, + TRUE, NULL); + /* Add all IPv6 routes */ + while (iblock) { + ip_block *current_iblock = iblock; + const char *metric_str; + char *stripped; + gint64 metric; + NMIPRoute *route; + GError *local = NULL; + + /* metric is not per routes configuration right now + * global metric is also supported (metric="x") */ + if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) + metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); + else { + metric_str = ifnet_get_global_data ("metric"); + if (metric_str) { + stripped = g_strdup (metric_str); + strip_string (stripped, '"'); + metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1); + g_free (stripped); + } else + metric = 1; + } + + route = nm_ip_route_new (AF_INET6, iblock->ip, iblock->prefix, iblock->next_hop, metric, &local); + if (route) { + if (nm_setting_ip_config_add_route (s_ip6, route)) + nm_log_info (LOGD_SETTINGS, " new IP6 route"); + else + nm_log_warn (LOGD_SETTINGS, " duplicate IP6 route"); + nm_ip_route_unref (route); + } else { + nm_log_warn (LOGD_SETTINGS, " ignoring invalid route entry: %s", local->message); + g_clear_error (&local); + } + + current_iblock = iblock; + iblock = iblock->next; + destroy_ip_block (current_iblock); + } + +done: + nm_connection_add_setting (connection, NM_SETTING (s_ip6)); + return TRUE; + +error: + g_object_unref (s_ip6); + nm_log_warn (LOGD_SETTINGS, " Ignore IPv6 for %s", conn_name); + return FALSE; +} + +static NMSetting * +make_wireless_connection_setting (const char *conn_name, + NMSetting8021x **s_8021x, + GError **error) +{ + const char *mac = NULL; + NMSettingWireless *wireless_setting = NULL; + gboolean adhoc = FALSE; + const char *value; + const char *type; + + /* PPP over WIFI is not supported yet */ + g_return_val_if_fail (conn_name != NULL + && strcmp (ifnet_get_data (conn_name, "type"), + "ppp") != 0, NULL); + type = ifnet_get_data (conn_name, "type"); + if (strcmp (type, "ppp") == 0) { + nm_log_warn (LOGD_SETTINGS, "PPP over WIFI is not supported yet"); + return NULL; + } + + wireless_setting = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); + if (read_mac_address (conn_name, &mac, error)) { + if (mac) { + g_object_set (wireless_setting, + NM_SETTING_WIRELESS_MAC_ADDRESS, mac, + NULL); + } + } else { + g_object_unref (wireless_setting); + return NULL; + } + + /* handle ssid (hex and ascii) */ + if (conn_name) { + GBytes *bytes; + gsize ssid_len = 0, value_len = strlen (conn_name); + + ssid_len = value_len; + if ((value_len > 2) && (g_str_has_prefix (conn_name, "0x"))) { + /* Hex representation */ + if (value_len % 2) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid SSID '%s' size (looks like hex but length not multiple of 2)", + conn_name); + goto error; + } + + bytes = nm_utils_hexstr2bin (conn_name); + if (!bytes) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid SSID '%s' (looks like hex SSID but isn't)", + conn_name); + goto error; + } + } else + bytes = g_bytes_new (conn_name, value_len); + + ssid_len = g_bytes_get_size (bytes); + if (ssid_len > 32 || ssid_len == 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", + conn_name, ssid_len); + goto error; + } + + g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, bytes, NULL); + g_bytes_unref (bytes); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing SSID"); + goto error; + } + + /* mode=0: infrastructure + * mode=1: adhoc */ + value = wpa_get_value (conn_name, "mode"); + if (value) + adhoc = strcmp (value, "1") == 0 ? TRUE : FALSE; + + if (exist_ssid (conn_name)) { + const char *mode = adhoc ? "adhoc" : "infrastructure"; + + g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, mode, + NULL); + nm_log_info (LOGD_SETTINGS, "Using mode: %s", mode); + } + + /* BSSID setting */ + value = wpa_get_value (conn_name, "bssid"); + if (value) { + if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid BSSID '%s'", value); + goto error; + } + + g_object_set (wireless_setting, NM_SETTING_WIRELESS_BSSID, + value, NULL); + + } + + /* mtu_ssid="xx" */ + value = ifnet_get_data (conn_name, "mtu"); + if (value) { + long int mtu; + + errno = 0; + mtu = strtol (value, NULL, 10); + if (errno || mtu < 0 || mtu > 50000) { + nm_log_warn (LOGD_SETTINGS, " invalid MTU '%s' for %s", value, conn_name); + } else + g_object_set (wireless_setting, NM_SETTING_WIRELESS_MTU, + (guint32) mtu, NULL); + + } + + nm_log_info (LOGD_SETTINGS, "wireless_setting added for %s", conn_name); + return NM_SETTING (wireless_setting); +error: + if (wireless_setting) + g_object_unref (wireless_setting); + return NULL; + +} + +static NMSettingWirelessSecurity * +make_leap_setting (const char *ssid, GError **error) +{ + NMSettingWirelessSecurity *wsec; + const char *value; + + wsec = + NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); + + value = wpa_get_value (ssid, "password"); + if (value && strlen (value)) + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, + value, NULL); + + value = wpa_get_value (ssid, "identity"); + if (!value || !strlen (value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing LEAP identity"); + goto error; + } + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, value, + NULL); + + g_object_set (wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", NULL); + + return wsec; +error: + if (wsec) + g_object_unref (wsec); + return NULL; +} + +static gboolean +add_one_wep_key (const char *ssid, + const char *key, + int key_idx, + NMSettingWirelessSecurity *s_wsec, + GError **error) +{ + const char *value; + char *converted = NULL; + gboolean success = FALSE; + + g_return_val_if_fail (ssid != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (key_idx >= 0 && key_idx <= 3, FALSE); + g_return_val_if_fail (s_wsec != NULL, FALSE); + + value = wpa_get_value (ssid, key); + if (!value) + return TRUE; + + /* Validate keys */ + if (strlen (value) == 10 || strlen (value) == 26) { + /* Hexadecimal WEP key */ + if (!is_hex (value)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid hexadecimal WEP key."); + goto out; + } + converted = g_strdup (value); + } else if (value[0] == '"' + && (strlen (value) == 7 || strlen (value) == 15)) { + /* ASCII passphrase */ + char *tmp = g_strdup (value); + char *p = strip_string (tmp, '"'); + + if (!is_ascii (p)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid ASCII WEP passphrase."); + g_free (tmp); + goto out; + + } + + converted = nm_utils_bin2hexstr (tmp, strlen (tmp), -1); + g_free (tmp); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WEP key length. Key: %s", value); + goto out; + } + + if (converted) { + nm_setting_wireless_security_set_wep_key (s_wsec, key_idx, converted); + g_free (converted); + success = TRUE; + } + +out: + return success; +} + +static gboolean +add_wep_keys (const char *ssid, + NMSettingWirelessSecurity *s_wsec, + GError **error) +{ + if (!add_one_wep_key (ssid, "wep_key0", 0, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ssid, "wep_key1", 1, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ssid, "wep_key2", 2, s_wsec, error)) + return FALSE; + if (!add_one_wep_key (ssid, "wep_key3", 3, s_wsec, error)) + return FALSE; + return TRUE; + +} + +static NMSettingWirelessSecurity * +make_wep_setting (const char *ssid, GError **error) +{ + const char *auth_alg, *value; + int default_key_idx = 0; + NMSettingWirelessSecurity *s_wireless_sec; + + s_wireless_sec = + NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); + g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, + "none", NULL); + + /* default key index */ + value = wpa_get_value (ssid, "wep_tx_keyidx"); + if (value) { + default_key_idx = atoi (value); + if (default_key_idx >= 0 && default_key_idx <= 3) { + g_object_set (s_wireless_sec, + NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, + default_key_idx, NULL); + nm_log_info (LOGD_SETTINGS, "Default key index: %d", default_key_idx); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid default WEP key '%s'", value); + goto error; + } + } + + if (!add_wep_keys (ssid, s_wireless_sec, error)) + goto error; + + /* If there's a default key, ensure that key exists */ + if ((default_key_idx == 1) + && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Default WEP key index was 2, but no valid KEY2 exists."); + goto error; + } else if ((default_key_idx == 2) + && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, + 2)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Default WEP key index was 3, but no valid KEY3 exists."); + goto error; + } else if ((default_key_idx == 3) + && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, + 3)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Default WEP key index was 4, but no valid KEY4 exists."); + goto error; + } + + /* authentication algorithms */ + auth_alg = wpa_get_value (ssid, "auth_alg"); + if (auth_alg) { + if (strcmp (auth_alg, "OPEN") == 0) { + g_object_set (s_wireless_sec, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, + "open", NULL); + nm_log_info (LOGD_SETTINGS, "WEP: Use open system authentication"); + } else if (strcmp (auth_alg, "SHARED") == 0) { + g_object_set (s_wireless_sec, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, + "shared", NULL); + nm_log_info (LOGD_SETTINGS, "WEP: Use shared system authentication"); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WEP authentication algorithm '%s'", + auth_alg); + goto error; + } + + } + + if (!nm_setting_wireless_security_get_wep_key (s_wireless_sec, 0) + && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1) + && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 2) + && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3) + && !nm_setting_wireless_security_get_wep_tx_keyidx (s_wireless_sec)) { + if (auth_alg && !strcmp (auth_alg, "shared")) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "WEP Shared Key authentication is invalid for " + "unencrypted connections."); + goto error; + } + /* Unencrypted */ + g_object_unref (s_wireless_sec); + s_wireless_sec = NULL; + } + return s_wireless_sec; + +error: + if (s_wireless_sec) + g_object_unref (s_wireless_sec); + return NULL; +} + +static char * +parse_wpa_psk (const char *psk, GError **error) +{ + char *hashed = NULL; + gboolean quoted = FALSE; + + if (!psk) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing WPA_PSK for WPA-PSK key management"); + return NULL; + } + + /* Passphrase must be between 10 and 66 characters in length because WPA + * hex keys are exactly 64 characters (no quoting), and WPA passphrases + * are between 8 and 63 characters (inclusive), plus optional quoting if + * the passphrase contains spaces. + */ + + if (psk[0] == '"' && psk[strlen (psk) - 1] == '"') + quoted = TRUE; + if (!quoted && (strlen (psk) == 64)) { + /* Verify the hex PSK; 64 digits */ + if (!is_hex (psk)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WPA_PSK (contains non-hexadecimal characters)"); + goto out; + } + hashed = g_strdup (psk); + } else { + char *stripped = g_strdup (psk); + + strip_string (stripped, '"'); + + /* Length check */ + if (strlen (stripped) < 8 || strlen (stripped) > 63) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WPA_PSK (passphrases must be between " + "8 and 63 characters long (inclusive))"); + g_free (stripped); + goto out; + } + + hashed = g_strdup (stripped); + g_free (stripped); + } + + if (!hashed) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WPA_PSK (doesn't look like a passphrase or hex key)"); + goto out; + } + +out: + return hashed; +} + +static gboolean +fill_wpa_ciphers (const char *ssid, + NMSettingWirelessSecurity *wsec, + gboolean group, + gboolean adhoc) +{ + const char *value; + char **list = NULL, **iter; + int i = 0; + + value = wpa_get_value (ssid, group ? "group" : "pairwise"); + if (!value) + return TRUE; + + list = g_strsplit_set (value, " ", 0); + for (iter = list; iter && *iter; iter++, i++) { + /* Ad-Hoc configurations cannot have pairwise ciphers, and can only + * have one group cipher. Ignore any additional group ciphers and + * any pairwise ciphers specified. + */ + if (adhoc) { + if (group && (i > 0)) { + nm_log_warn (LOGD_SETTINGS, " ignoring group cipher '%s' (only one group cipher allowed in Ad-Hoc mode)", + *iter); + continue; + } else if (!group) { + nm_log_warn (LOGD_SETTINGS, " ignoring pairwise cipher '%s' (pairwise not used in Ad-Hoc mode)", + *iter); + continue; + } + } + + if (!strcmp (*iter, "CCMP")) { + if (group) + nm_setting_wireless_security_add_group (wsec, + "ccmp"); + else + nm_setting_wireless_security_add_pairwise (wsec, + "ccmp"); + } else if (!strcmp (*iter, "TKIP")) { + if (group) + nm_setting_wireless_security_add_group (wsec, + "tkip"); + else + nm_setting_wireless_security_add_pairwise (wsec, + "tkip"); + } else if (group && !strcmp (*iter, "WEP104")) + nm_setting_wireless_security_add_group (wsec, "wep104"); + else if (group && !strcmp (*iter, "WEP40")) + nm_setting_wireless_security_add_group (wsec, "wep40"); + else { + nm_log_warn (LOGD_SETTINGS, " ignoring invalid %s cipher '%s'", + group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", + *iter); + } + } + + if (list) + g_strfreev (list); + return TRUE; +} + +static NMSetting8021x * +fill_8021x (const char *ssid, + const char *key_mgmt, + gboolean wifi, + const char *basepath, + GError **error) +{ + NMSetting8021x *s_8021x; + const char *value; + char **list, **iter; + + value = wpa_get_value (ssid, "eap"); + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IEEE_8021X_EAP_METHODS for key management '%s'", + key_mgmt); + return NULL; + } + + list = g_strsplit (value, " ", 0); + + s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); + /* Validate and handle each EAP method */ + for (iter = list; iter && *iter; iter++) { + EAPReader *eap = &eap_readers[0]; + gboolean found = FALSE; + char *lower = NULL; + + lower = g_ascii_strdown (*iter, -1); + while (eap->method) { + if (strcmp (eap->method, lower)) + goto next; + + /* Some EAP methods don't provide keying material, thus they + * cannot be used with WiFi unless they are an inner method + * used with TTLS or PEAP or whatever. + */ + if (wifi && eap->wifi_phase2_only) { + nm_log_warn (LOGD_SETTINGS, " ignored invalid IEEE_8021X_EAP_METHOD '%s'; not allowed for wifi.", + lower); + goto next; + } + + /* Parse EAP method specific options */ + if (!(*eap->reader) (lower, ssid, s_8021x, FALSE, basepath, error)) { + g_free (lower); + goto error; + } + nm_setting_802_1x_add_eap_method (s_8021x, lower); + found = TRUE; + break; + + next: + eap++; + } + + if (!found) { + nm_log_warn (LOGD_SETTINGS, " ignored unknown IEEE_8021X_EAP_METHOD '%s'.", lower); + } + g_free (lower); + } + g_strfreev (list); + + if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No valid EAP methods found in IEEE_8021X_EAP_METHODS."); + goto error; + } + + return s_8021x; + +error: + g_object_unref (s_8021x); + return NULL; +} + +static NMSettingWirelessSecurity * +make_wpa_setting (const char *ssid, + const char *basepath, + NMSetting8021x **s_8021x, + GError **error) +{ + NMSettingWirelessSecurity *wsec; + const char *value; + char *lower; + gboolean adhoc = FALSE; + + if (!exist_ssid (ssid)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No security info found for ssid: %s", ssid); + return NULL; + } + + wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); + + /* mode=1: adhoc + * mode=0: infrastructure */ + value = wpa_get_value (ssid, "mode"); + if (value) + adhoc = strcmp (value, "1") == 0 ? TRUE : FALSE; + + /* Pairwise and Group ciphers */ + fill_wpa_ciphers (ssid, wsec, FALSE, adhoc); + fill_wpa_ciphers (ssid, wsec, TRUE, adhoc); + + /* WPA and/or RSN */ + if (adhoc) { + /* Ad-Hoc mode only supports WPA proto for now */ + nm_setting_wireless_security_add_proto (wsec, "wpa"); + } else { + nm_setting_wireless_security_add_proto (wsec, "wpa"); + nm_setting_wireless_security_add_proto (wsec, "rsn"); + + } + + value = wpa_get_value (ssid, "key_mgmt"); + if (!strcmp (value, "WPA-PSK")) { + char *psk = parse_wpa_psk (wpa_get_value (ssid, "psk"), error); + + if (!psk) + goto error; + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_PSK, psk, + NULL); + g_free (psk); + + if (adhoc) + g_object_set (wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, + "wpa-none", NULL); + else + g_object_set (wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, + "wpa-psk", NULL); + } else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) { + if (adhoc) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", + value); + goto error; + } + *s_8021x = fill_8021x (ssid, value, TRUE, basepath, error); + if (!*s_8021x) + goto error; + + lower = g_ascii_strdown (value, -1); + g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, + lower, NULL); + g_free (lower); + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Unknown wireless KEY_MGMT type '%s'", value); + goto error; + } + return wsec; +error: + if (wsec) + g_object_unref (wsec); + return NULL; +} + +static NMSettingWirelessSecurity * +make_wireless_security_setting (const char *conn_name, + const char *basepath, + NMSetting8021x **s_8021x, + GError ** error) +{ + NMSettingWirelessSecurity *wsec = NULL; + const char *ssid; + gboolean adhoc = FALSE; + const char *value; + + g_return_val_if_fail (conn_name != NULL + && strcmp (ifnet_get_data (conn_name, "type"), + "ppp") != 0, NULL); + nm_log_info (LOGD_SETTINGS, "updating wireless security settings (%s).", conn_name); + + ssid = conn_name; + value = wpa_get_value (ssid, "mode"); + if (value) + adhoc = strcmp (value, "1") == 0 ? TRUE : FALSE; + + value = wpa_get_value (ssid, "key_mgmt"); + if (!adhoc && g_strcmp0 (value, "IEEE8021X") == 0) { + value = wpa_get_value (ssid, "eap"); + if (value && strcasecmp (value, "LEAP") == 0) { + wsec = make_leap_setting (ssid, error); + if (wsec == NULL) + goto error; + } + } else if (g_strcmp0 (value, "WPA-PSK") == 0 || g_strcmp0 (value, "WPA-EAP") == 0) { + wsec = make_wpa_setting (ssid, basepath, s_8021x, error); + if (wsec == NULL) + goto error; + } + if (!wsec) { + wsec = make_wep_setting (ssid, error); + if (wsec == NULL) + goto error; + } + return wsec; + +error: + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Can't handle security information for ssid: %s", + conn_name); + return NULL; +} + +/* Currently only support username and password */ +static gboolean +make_pppoe_connection_setting (NMConnection *connection, + const char *conn_name, + GError **error) +{ + NMSettingPppoe *s_pppoe; + NMSettingPpp *s_ppp; + const char *value; + + s_pppoe = NM_SETTING_PPPOE (nm_setting_pppoe_new ()); + + /* username */ + value = ifnet_get_data (conn_name, "username"); + if (!value) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "ppp requires at lease a username"); + return FALSE; + } + g_object_set (s_pppoe, NM_SETTING_PPPOE_USERNAME, value, NULL); + + /* password */ + value = ifnet_get_data (conn_name, "password"); + if (!value) { + value = ""; + } + + g_object_set (s_pppoe, NM_SETTING_PPPOE_PASSWORD, value, NULL); + nm_connection_add_setting (connection, NM_SETTING (s_pppoe)); + + /* PPP setting */ + s_ppp = (NMSettingPpp *) nm_setting_ppp_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ppp)); + + return TRUE; +} + +NMConnection * +ifnet_update_connection_from_config_block (const char *conn_name, + const char *basepath, + GError **error) +{ + const gchar *type = NULL; + NMConnection *connection = NULL; + NMSettingConnection *setting = NULL; + NMSetting8021x *s_8021x = NULL; + NMSettingWirelessSecurity *wsec = NULL; + gboolean auto_conn = TRUE; + const char *value = NULL; + gchar *id, *uuid; + gboolean success = FALSE; + + connection = nm_simple_connection_new (); + setting = nm_connection_get_setting_connection (connection); + if (!setting) { + setting = NM_SETTING_CONNECTION (nm_setting_connection_new ()); + g_assert (setting); + nm_connection_add_setting (connection, NM_SETTING (setting)); + } + + type = guess_connection_type (conn_name); + value = ifnet_get_data (conn_name, "auto"); + if (value && !strcmp (value, "false")) + auto_conn = FALSE; + + /* Try to read UUID from the ifnet block, otherwise generate UUID from + * the connection ID. + */ + id = connection_id_from_ifnet_name (conn_name); + uuid = g_strdup (ifnet_get_data (conn_name, "uuid")); + if (!uuid) + uuid = nm_utils_uuid_generate_from_string (id, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); + + g_object_set (setting, + NM_SETTING_CONNECTION_TYPE, type, + NM_SETTING_CONNECTION_ID, id, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_INTERFACE_NAME, conn_name, + NM_SETTING_CONNECTION_READ_ONLY, FALSE, + NM_SETTING_CONNECTION_AUTOCONNECT, auto_conn, + NULL); + nm_log_info (LOGD_SETTINGS, "name:%s, id:%s, uuid: %s", conn_name, id, uuid); + g_free (id); + g_free (uuid); + + if (!strcmp (NM_SETTING_WIRED_SETTING_NAME, type) + || !strcmp (NM_SETTING_PPPOE_SETTING_NAME, type)) { + /* wired setting */ + if (!make_wired_connection_setting (connection, conn_name, error)) + goto error; + + /* pppoe setting */ + if (!strcmp (NM_SETTING_PPPOE_SETTING_NAME, type)) { + if (!make_pppoe_connection_setting (connection, conn_name, error)) + goto error; + } + } else if (!strcmp (NM_SETTING_WIRELESS_SETTING_NAME, type)) { + /* wireless setting */ + NMSetting *wireless_setting; + + wireless_setting = make_wireless_connection_setting (conn_name, &s_8021x, error); + if (!wireless_setting) + goto error; + nm_connection_add_setting (connection, wireless_setting); + + /* wireless security setting */ + if (wpa_get_value (conn_name, "ssid")) { + wsec = make_wireless_security_setting (conn_name, basepath, &s_8021x, error); + if (!wsec) + goto error; + nm_connection_add_setting (connection, NM_SETTING (wsec)); + if (s_8021x) + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + } + } else + goto error; + + /* IPv4 setting */ + if (!make_ip4_setting (connection, conn_name, error)) + goto error; + + /* IPv6 setting */ + if (!make_ip6_setting (connection, conn_name, error)) + goto error; + + if (nm_connection_verify (connection, error)) { + nm_log_info (LOGD_SETTINGS, "Connection verified %s:%d", conn_name, success); + } else { + goto error; + } + + return connection; +error: + g_object_unref (connection); + return NULL; +} + +typedef NMSetting8021xCKScheme (*SchemeFunc) (NMSetting8021x * setting); +typedef const char *(*PathFunc) (NMSetting8021x * setting); +typedef GBytes *(*BlobFunc) (NMSetting8021x * setting); + +typedef struct ObjectType { + const char *setting_key; + SchemeFunc scheme_func; + PathFunc path_func; + BlobFunc blob_func; + const char *conn_name_key; + const char *suffix; +} ObjectType; + +static const ObjectType ca_type = { + NM_SETTING_802_1X_CA_CERT, + nm_setting_802_1x_get_ca_cert_scheme, + nm_setting_802_1x_get_ca_cert_path, + nm_setting_802_1x_get_ca_cert_blob, + "ca_cert", + "ca-cert.der" +}; + +static const ObjectType phase2_ca_type = { + NM_SETTING_802_1X_PHASE2_CA_CERT, + nm_setting_802_1x_get_phase2_ca_cert_scheme, + nm_setting_802_1x_get_phase2_ca_cert_path, + nm_setting_802_1x_get_phase2_ca_cert_blob, + "ca_cert2", + "inner-ca-cert.der" +}; + +static const ObjectType client_type = { + NM_SETTING_802_1X_CLIENT_CERT, + nm_setting_802_1x_get_client_cert_scheme, + nm_setting_802_1x_get_client_cert_path, + nm_setting_802_1x_get_client_cert_blob, + "client_cert", + "client-cert.der" +}; + +static const ObjectType phase2_client_type = { + NM_SETTING_802_1X_PHASE2_CLIENT_CERT, + nm_setting_802_1x_get_phase2_client_cert_scheme, + nm_setting_802_1x_get_phase2_client_cert_path, + nm_setting_802_1x_get_phase2_client_cert_blob, + "client_cert2", + "inner-client-cert.der" +}; + +static const ObjectType pk_type = { + NM_SETTING_802_1X_PRIVATE_KEY, + nm_setting_802_1x_get_private_key_scheme, + nm_setting_802_1x_get_private_key_path, + nm_setting_802_1x_get_private_key_blob, + "private_key", + "private-key.pem" +}; + +static const ObjectType phase2_pk_type = { + NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, + nm_setting_802_1x_get_phase2_private_key_scheme, + nm_setting_802_1x_get_phase2_private_key_path, + nm_setting_802_1x_get_phase2_private_key_blob, + "private_key2", + "inner-private-key.pem" +}; + +static const ObjectType p12_type = { + NM_SETTING_802_1X_PRIVATE_KEY, + nm_setting_802_1x_get_private_key_scheme, + nm_setting_802_1x_get_private_key_path, + nm_setting_802_1x_get_private_key_blob, + "private_key", + "private-key.p12" +}; + +static const ObjectType phase2_p12_type = { + NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, + nm_setting_802_1x_get_phase2_private_key_scheme, + nm_setting_802_1x_get_phase2_private_key_path, + nm_setting_802_1x_get_phase2_private_key_blob, + "private_key2", + "inner-private-key.p12" +}; + +static gboolean +write_object (NMSetting8021x *s_8021x, + const char *conn_name, + GBytes *override_data, + const ObjectType *objtype, + GError **error) +{ + NMSetting8021xCKScheme scheme; + const char *path = NULL; + GBytes *blob = NULL; + + g_return_val_if_fail (conn_name != NULL, FALSE); + g_return_val_if_fail (objtype != NULL, FALSE); + if (override_data) + /* if given explicit data to save, always use that instead of asking + * the setting what to do. + */ + blob = override_data; + else { + scheme = (*(objtype->scheme_func)) (s_8021x); + switch (scheme) { + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + blob = (*(objtype->blob_func)) (s_8021x); + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = (*(objtype->path_func)) (s_8021x); + break; + default: + break; + } + } + + /* If the object path was specified, prefer that over any raw cert data that + * may have been sent. + */ + if (path) { + wpa_set_data (conn_name, (gchar *) objtype->conn_name_key, + (gchar *) path); + return TRUE; + } + + /* does not support writing encryption data now */ + if (blob) + nm_log_warn (LOGD_SETTINGS, " Currently we do not support cert writing."); + + return TRUE; +} + +static gboolean +write_8021x_certs (NMSetting8021x *s_8021x, + gboolean phase2, + const char *conn_name, + GError **error) +{ + char *password = NULL; + const ObjectType *otype = NULL; + gboolean is_pkcs12 = FALSE, success = FALSE; + GBytes *blob = NULL; + GBytes *enc_key = NULL; + gchar *generated_pw = NULL; + + /* CA certificate */ + if (phase2) + otype = &phase2_ca_type; + else + otype = &ca_type; + + if (!write_object (s_8021x, conn_name, NULL, otype, error)) + return FALSE; + + /* Private key */ + if (phase2) { + if (nm_setting_802_1x_get_phase2_private_key_scheme (s_8021x) != + NM_SETTING_802_1X_CK_SCHEME_UNKNOWN) { + if (nm_setting_802_1x_get_phase2_private_key_format + (s_8021x) == NM_SETTING_802_1X_CK_FORMAT_PKCS12) + is_pkcs12 = TRUE; + } + password = (char *) + nm_setting_802_1x_get_phase2_private_key_password (s_8021x); + } else { + if (nm_setting_802_1x_get_private_key_scheme (s_8021x) != + NM_SETTING_802_1X_CK_SCHEME_UNKNOWN) { + if (nm_setting_802_1x_get_private_key_format (s_8021x) + == NM_SETTING_802_1X_CK_FORMAT_PKCS12) + is_pkcs12 = TRUE; + } + password = (char *) + nm_setting_802_1x_get_private_key_password (s_8021x); + } + + if (is_pkcs12) + otype = phase2 ? &phase2_p12_type : &p12_type; + else + otype = phase2 ? &phase2_pk_type : &pk_type; + + if ((*(otype->scheme_func)) (s_8021x) == + NM_SETTING_802_1X_CK_SCHEME_BLOB) + blob = (*(otype->blob_func)) (s_8021x); + + /* Only do the private key re-encrypt dance if we got the raw key data, which + * by definition will be unencrypted. If we're given a direct path to the + * private key file, it'll be encrypted, so we don't need to re-encrypt. + */ + if (blob && !is_pkcs12) { + GByteArray *tmp_enc_key; + + /* Encrypt the unencrypted private key with the fake password */ + tmp_enc_key = + nm_utils_rsa_key_encrypt (g_bytes_get_data (blob, NULL), g_bytes_get_size (blob), + password, &generated_pw, error); + if (!tmp_enc_key) + goto out; + + enc_key = g_byte_array_free_to_bytes (tmp_enc_key); + + if (generated_pw) + password = generated_pw; + } + + /* Save the private key */ + if (!write_object + (s_8021x, conn_name, enc_key ? enc_key : blob, otype, error)) + goto out; + + if (phase2) + wpa_set_data (conn_name, "private_key2_passwd", password); + else + wpa_set_data (conn_name, "private_key_passwd", password); + + /* Client certificate */ + if (is_pkcs12) { + wpa_set_data (conn_name, + phase2 ? "client_cert2" : "client_cert", NULL); + } else { + if (phase2) + otype = &phase2_client_type; + else + otype = &client_type; + + /* Save the client certificate */ + if (!write_object (s_8021x, conn_name, NULL, otype, error)) + goto out; + } + + success = TRUE; +out: + if (generated_pw) { + memset (generated_pw, 0, strlen (generated_pw)); + g_free (generated_pw); + } + if (enc_key) { + memset ((gpointer) g_bytes_get_data (enc_key, NULL), 0, g_bytes_get_size (enc_key)); + g_bytes_unref (enc_key); + } + return success; +} + +static gboolean +write_8021x_setting (NMConnection *connection, + const char *conn_name, + gboolean wired, + GError **error) +{ + NMSetting8021x *s_8021x; + const char *value; + char *tmp = NULL; + gboolean success = FALSE; + GString *phase2_auth; + GString *phase1; + + s_8021x = nm_connection_get_setting_802_1x (connection); + if (!s_8021x) { + return TRUE; + } + + nm_log_info (LOGD_SETTINGS, "Adding 8021x setting for %s", conn_name); + + /* If wired, write KEY_MGMT */ + if (wired) + wpa_set_data (conn_name, "key_mgmt", "IEEE8021X"); + + /* EAP method */ + if (nm_setting_802_1x_get_num_eap_methods (s_8021x)) { + value = nm_setting_802_1x_get_eap_method (s_8021x, 0); + if (value) + tmp = g_ascii_strup (value, -1); + } + wpa_set_data (conn_name, "eap", tmp ? tmp : NULL); + g_free (tmp); + + wpa_set_data (conn_name, "identity", + (gchar *) nm_setting_802_1x_get_identity (s_8021x)); + + wpa_set_data (conn_name, "anonymous_identity", (gchar *) + nm_setting_802_1x_get_anonymous_identity (s_8021x)); + + wpa_set_data (conn_name, "password", + (gchar *) nm_setting_802_1x_get_password (s_8021x)); + + phase1 = g_string_new (NULL); + + /* PEAP version */ + wpa_set_data (conn_name, "phase1", NULL); + value = nm_setting_802_1x_get_phase1_peapver (s_8021x); + if (value && (!strcmp (value, "0") || !strcmp (value, "1"))) + g_string_append_printf (phase1, "peapver=%s ", value); + + /* PEAP label */ + value = nm_setting_802_1x_get_phase1_peaplabel (s_8021x); + if (value && !strcmp (value, "1")) + g_string_append_printf (phase1, "peaplabel=%s ", value); + if (phase1->len) { + tmp = g_strstrip (g_strdup (phase1->str)); + wpa_set_data (conn_name, "phase1", tmp); + g_free (tmp); + } + + /* Phase2 auth methods */ + wpa_set_data (conn_name, "phase2", NULL); + phase2_auth = g_string_new (NULL); + + value = nm_setting_802_1x_get_phase2_auth (s_8021x); + if (value) { + tmp = g_ascii_strup (value, -1); + g_string_append_printf (phase2_auth, "auth=%s ", tmp); + g_free (tmp); + } + + /* Phase2 auth heap */ + value = nm_setting_802_1x_get_phase2_autheap (s_8021x); + if (value) { + tmp = g_ascii_strup (value, -1); + g_string_append_printf (phase2_auth, "autheap=%s ", tmp); + g_free (tmp); + } + tmp = g_strstrip (g_strdup (phase2_auth->str)); + wpa_set_data (conn_name, "phase2", phase2_auth->len ? tmp : NULL); + g_free (tmp); + + g_string_free (phase2_auth, TRUE); + g_string_free (phase1, TRUE); + + success = write_8021x_certs (s_8021x, FALSE, conn_name, error); + if (success) { + /* phase2/inner certs */ + success = write_8021x_certs (s_8021x, TRUE, conn_name, error); + } + + return success; +} + +static gboolean +write_wireless_security_setting (NMConnection * connection, + gchar * conn_name, + gboolean adhoc, + gboolean * no_8021x, GError ** error) +{ + NMSettingWirelessSecurity *s_wsec; + const char *key_mgmt, *auth_alg, *key, *cipher, *psk; + gboolean wep = FALSE, wpa = FALSE; + char *tmp; + guint32 i, num; + GString *str; + + s_wsec = nm_connection_get_setting_wireless_security (connection); + if (!s_wsec) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing '%s' setting", + NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + return FALSE; + } + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); + g_assert (key_mgmt); + + auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); + + if (!strcmp (key_mgmt, "none")) { + wpa_set_data (conn_name, "key_mgmt", "NONE"); + wep = TRUE; + *no_8021x = TRUE; + } else if (!strcmp (key_mgmt, "wpa-none") + || !strcmp (key_mgmt, "wpa-psk")) { + wpa_set_data (conn_name, "key_mgmt", "WPA-PSK"); + wpa = TRUE; + *no_8021x = TRUE; + } else if (!strcmp (key_mgmt, "ieee8021x")) { + wpa_set_data (conn_name, "key_mgmt", "IEEE8021X"); + } else if (!strcmp (key_mgmt, "wpa-eap")) { + wpa_set_data (conn_name, "key_mgmt", "WPA-EAP"); + wpa = TRUE; + } else + nm_log_warn (LOGD_SETTINGS, "Unknown key_mgmt: %s", key_mgmt); + + if (auth_alg) { + if (!strcmp (auth_alg, "shared")) + wpa_set_data (conn_name, "auth_alg", "SHARED"); + else if (!strcmp (auth_alg, "open")) + wpa_set_data (conn_name, "auth_alg", "OPEN"); + else if (!strcmp (auth_alg, "leap")) { + wpa_set_data (conn_name, "auth_alg", "LEAP"); + wpa_set_data (conn_name, "eap", "LEAP"); + wpa_set_data (conn_name, "identity", (gchar *) + nm_setting_wireless_security_get_leap_username + (s_wsec)); + wpa_set_data (conn_name, "password", (gchar *) + nm_setting_wireless_security_get_leap_password + (s_wsec)); + *no_8021x = TRUE; + } + } else + wpa_set_data (conn_name, "auth_alg", NULL); + + /* Default WEP TX key index */ + if (wep) { + tmp = + g_strdup_printf ("%d", + nm_setting_wireless_security_get_wep_tx_keyidx + (s_wsec)); + wpa_set_data (conn_name, "wep_tx_keyidx", tmp); + g_free (tmp); + } else + wpa_set_data (conn_name, "wep_tx_keyidx", NULL); + + /* WEP keys */ + for (i = 0; i < 4; i++) { + int length; + + key = nm_setting_wireless_security_get_wep_key (s_wsec, i); + if (!key) + continue; + tmp = g_strdup_printf ("wep_key%d", i); + length = strlen (key); + if (length == 10 || length == 26 || length == 58) + wpa_set_data (conn_name, tmp, (gchar *) key); + else { + gchar *tmp_key = g_strdup_printf ("\"%s\"", key); + + wpa_set_data (conn_name, tmp, tmp_key); + g_free (tmp_key); + } + g_free (tmp); + } + + /* WPA Pairwise ciphers */ + wpa_set_data (conn_name, "pairwise", NULL); + str = g_string_new (NULL); + num = nm_setting_wireless_security_get_num_pairwise (s_wsec); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (str, ' '); + cipher = nm_setting_wireless_security_get_pairwise (s_wsec, i); + tmp = g_ascii_strup (cipher, -1); + g_string_append (str, tmp); + g_free (tmp); + } + if (strlen (str->str)) + wpa_set_data (conn_name, "pairwise", str->str); + g_string_free (str, TRUE); + + /* WPA Group ciphers */ + wpa_set_data (conn_name, "group", NULL); + str = g_string_new (NULL); + num = nm_setting_wireless_security_get_num_groups (s_wsec); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (str, ' '); + cipher = nm_setting_wireless_security_get_group (s_wsec, i); + tmp = g_ascii_strup (cipher, -1); + g_string_append (str, tmp); + g_free (tmp); + } + if (strlen (str->str)) + wpa_set_data (conn_name, "group", str->str); + g_string_free (str, TRUE); + + /* WPA Passphrase */ + if (wpa) { + GString *quoted = NULL; + + psk = nm_setting_wireless_security_get_psk (s_wsec); + if (psk && (strlen (psk) != 64)) { + quoted = g_string_sized_new (strlen (psk) + 2); + g_string_append_c (quoted, '"'); + g_string_append (quoted, psk); + g_string_append_c (quoted, '"'); + } + /* psk will be lost here if we don't check it for NULL */ + if (psk) + wpa_set_data (conn_name, "psk", + quoted ? quoted->str : (gchar *) psk); + if (quoted) + g_string_free (quoted, TRUE); + } else + wpa_set_data (conn_name, "psk", NULL); + + return TRUE; +} + +/* remove old ssid and add new one*/ +static void +update_wireless_ssid (NMConnection *connection, + const char *conn_name, + const char *ssid, + gboolean hex) +{ + if(strcmp (conn_name, ssid)){ + ifnet_delete_network (conn_name); + wpa_delete_security (conn_name); + } + + ifnet_add_network (ssid, "wireless"); + wpa_add_security (ssid); +} + +static gboolean +write_wireless_setting (NMConnection *connection, + const char *conn_name, + gboolean *no_8021x, + const char **out_new_name, + GError **error) +{ + NMSettingWireless *s_wireless; + GBytes *ssid; + const guint8 *ssid_data; + gsize ssid_len; + const char *mac, *bssid, *mode; + char buf[33]; + guint32 mtu, i; + gboolean adhoc = FALSE, hex_ssid = FALSE; + gchar *ssid_str, *tmp; + + s_wireless = nm_connection_get_setting_wireless (connection); + if (!s_wireless) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing '%s' setting", + NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + + ssid = nm_setting_wireless_get_ssid (s_wireless); + if (!ssid) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing SSID in '%s' setting", + NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + ssid_data = g_bytes_get_data (ssid, &ssid_len); + if (!ssid_len || ssid_len > 32) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid SSID in '%s' setting", + NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + + /* If the SSID contains any non-alnum characters, we need to use + * the hex notation of the SSID instead. (Because openrc doesn't + * support these characters, see bug #356337) + */ + for (i = 0; i < ssid_len; i++) { + if (!g_ascii_isalnum (ssid_data[i])) { + hex_ssid = TRUE; + break; + } + } + + if (hex_ssid) { + GString *str; + + /* Hex SSIDs don't get quoted */ + str = g_string_sized_new (ssid_len * 2 + 3); + g_string_append (str, "0x"); + for (i = 0; i < ssid_len; i++) + g_string_append_printf (str, "%02X", ssid_data[i]); + update_wireless_ssid (connection, conn_name, str->str, hex_ssid); + ssid_str = g_string_free (str, FALSE); + } else { + /* Printable SSIDs get quoted */ + memset (buf, 0, sizeof (buf)); + memcpy (buf, ssid_data, ssid_len); + g_strstrip (buf); + update_wireless_ssid (connection, conn_name, buf, hex_ssid); + ssid_str = g_strdup (buf); + } + + ifnet_set_data (ssid_str, "mac", NULL); + mac = nm_setting_wireless_get_mac_address (s_wireless); + if (mac) + ifnet_set_data (ssid_str, "mac", mac); + + ifnet_set_data (ssid_str, "mtu", NULL); + mtu = nm_setting_wireless_get_mtu (s_wireless); + if (mtu) { + tmp = g_strdup_printf ("%u", mtu); + ifnet_set_data (ssid_str, "mtu", tmp); + g_free (tmp); + } + + ifnet_set_data (ssid_str, "mode", NULL); + mode = nm_setting_wireless_get_mode (s_wireless); + if (!mode || !strcmp (mode, "infrastructure")) { + wpa_set_data (ssid_str, "mode", "0"); + } else if (!strcmp (mode, "adhoc")) { + wpa_set_data (ssid_str, "mode", "1"); + adhoc = TRUE; + } else { + nm_log_warn (LOGD_SETTINGS, "Invalid mode '%s' in '%s' setting", + mode, NM_SETTING_WIRELESS_SETTING_NAME); + return FALSE; + } + + wpa_set_data (ssid_str, "bssid", NULL); + bssid = nm_setting_wireless_get_bssid (s_wireless); + if (bssid) + wpa_set_data (ssid_str, "bssid", bssid); + + if (nm_connection_get_setting_wireless_security (connection)) { + if (!write_wireless_security_setting + (connection, ssid_str, adhoc, no_8021x, error)) + return FALSE; + } else + wpa_delete_security (ssid_str); + + if (out_new_name) + *out_new_name = ifnet_get_data (ssid_str, "name"); + g_free (ssid_str); + return TRUE; +} + +static gboolean +write_wired_setting (NMConnection *connection, + const char *conn_name, + GError **error) +{ + NMSettingWired *s_wired; + const char *mac; + char *tmp; + guint32 mtu; + + s_wired = nm_connection_get_setting_wired (connection); + if (!s_wired) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing '%s' setting", + NM_SETTING_WIRED_SETTING_NAME); + return FALSE; + } + + ifnet_set_data (conn_name, "mac", NULL); + mac = nm_setting_wired_get_mac_address (s_wired); + if (mac) + ifnet_set_data (conn_name, "mac", mac); + + ifnet_set_data (conn_name, "mtu", NULL); + mtu = nm_setting_wired_get_mtu (s_wired); + if (mtu) { + tmp = g_strdup_printf ("%u", mtu); + ifnet_set_data (conn_name, "mtu", tmp); + g_free (tmp); + } + //FIXME may add connection type in future + //ifnet_set_data (conn_name, "TYPE", TYPE_ETHERNET); + + return TRUE; +} + +static gboolean +write_ip4_setting (NMConnection *connection, const char *conn_name, GError **error) +{ + NMSettingIPConfig *s_ip4; + const char *value; + guint32 i, num; + GString *searches; + GString *ips; + GString *routes; + GString *dns; + gboolean success = FALSE; + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + if (!s_ip4) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing '%s' setting", + NM_SETTING_IP4_CONFIG_SETTING_NAME); + return FALSE; + } + routes = g_string_new (NULL); + + value = nm_setting_ip_config_get_method (s_ip4); + g_assert (value); + if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { + + num = nm_setting_ip_config_get_num_addresses (s_ip4); + ips = g_string_new (NULL); + /* IPv4 addresses */ + for (i = 0; i < num; i++) { + NMIPAddress *addr; + + addr = nm_setting_ip_config_get_address (s_ip4, i); + + g_string_append_printf (ips, "\"%s/%u", + nm_ip_address_get_address (addr), + nm_ip_address_get_prefix (addr)); + + /* only the first gateway will be written */ + if (i == 0 && nm_setting_ip_config_get_gateway (s_ip4)) { + g_string_append_printf (routes, + "\"default via %s\" ", + nm_setting_ip_config_get_gateway (s_ip4)); + } + } + ifnet_set_data (conn_name, "config", ips->str); + g_string_free (ips, TRUE); + } else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) + ifnet_set_data (conn_name, "config", "shared"); + else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) + ifnet_set_data (conn_name, "config", "autoip"); + else + ifnet_set_data (conn_name, "config", "dhcp"); + + /* DNS Servers */ + num = nm_setting_ip_config_get_num_dns (s_ip4); + if (num > 0) { + dns = g_string_new (NULL); + for (i = 0; i < num; i++) { + const char *ip; + + ip = nm_setting_ip_config_get_dns (s_ip4, i); + g_string_append_printf (dns, " %s", ip); + } + ifnet_set_data (conn_name, "dns_servers", dns->str); + g_string_free (dns, TRUE); + } else + ifnet_set_data (conn_name, "dns_servers", NULL); + + /* DNS Searches */ + num = nm_setting_ip_config_get_num_dns_searches (s_ip4); + if (num > 0) { + searches = g_string_new (NULL); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (searches, ' '); + g_string_append (searches, + nm_setting_ip_config_get_dns_search + (s_ip4, i)); + } + ifnet_set_data (conn_name, "dns_search", searches->str); + g_string_free (searches, TRUE); + } else + ifnet_set_data (conn_name, "dns_search", NULL); + /* FIXME Will be implemented when configuration supports it + if (!strcmp(value, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { + value = nm_setting_ip_config_get_dhcp_hostname(s_ip4); + if (value) + ifnet_set_data(conn_name, "DHCP_HOSTNAME", value, + FALSE); + + value = nm_setting_ip_config_get_dhcp_client_id(s_ip4); + if (value) + ifnet_set_data(conn_name, "DHCP_CLIENT_ID", value, + FALSE); + } + */ + + /* Static routes */ + num = nm_setting_ip_config_get_num_routes (s_ip4); + if (num > 0) { + for (i = 0; i < num; i++) { + NMIPRoute *route; + const char *next_hop; + + route = nm_setting_ip_config_get_route (s_ip4, i); + + next_hop = nm_ip_route_get_next_hop (route); + if (!next_hop) + next_hop = "0.0.0.0"; + + g_string_append_printf (routes, "\"%s/%u via %s\" ", + nm_ip_route_get_dest (route), + nm_ip_route_get_prefix (route), + next_hop); + } + } + if (routes->len > 0) + ifnet_set_data (conn_name, "routes", routes->str); + else + ifnet_set_data (conn_name, "routes", NULL); + g_string_free (routes, TRUE); + + success = TRUE; + + return success; +} + +static void +write_route6_file (NMSettingIPConfig *s_ip6, const char *conn_name) +{ + NMIPRoute *route; + const char *next_hop; + guint32 i, num; + GString *routes_string; + const char *old_routes; + + g_return_if_fail (s_ip6 != NULL); + num = nm_setting_ip_config_get_num_routes (s_ip6); + if (num == 0) + return; + + old_routes = ifnet_get_data (conn_name, "routes"); + routes_string = g_string_new (old_routes); + if (old_routes) + g_string_append (routes_string, "\" "); + for (i = 0; i < num; i++) { + route = nm_setting_ip_config_get_route (s_ip6, i); + + next_hop = nm_ip_route_get_next_hop (route); + if (!next_hop) + next_hop = "::"; + + g_string_append_printf (routes_string, "\"%s/%u via %s\" ", + nm_ip_route_get_dest (route), + nm_ip_route_get_prefix (route), + next_hop); + } + if (num > 0) + ifnet_set_data (conn_name, "routes", routes_string->str); + g_string_free (routes_string, TRUE); +} + +static gboolean +write_ip6_setting (NMConnection *connection, const char *conn_name, GError **error) +{ + NMSettingIPConfig *s_ip6; + const char *value; + guint32 i, num; + GString *searches; + NMIPAddress *addr; + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + if (!s_ip6) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing '%s' setting", + NM_SETTING_IP6_CONFIG_SETTING_NAME); + return FALSE; + } + + value = nm_setting_ip_config_get_method (s_ip6); + g_assert (value); + if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + ifnet_set_data (conn_name, "enable_ipv6", "false"); + return TRUE; + } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { + /* nothing to do now */ + } else { + // if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { + const char *config = ifnet_get_data (conn_name, "config"); + gchar *tmp; + + if (!config) + tmp = g_strdup_printf ("dhcp6"); + else + tmp = g_strdup_printf ("%s\" \"dhcp6\"", config); + ifnet_set_data (conn_name, "config", tmp); + g_free (tmp); + } + /* else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { + } else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) { + } else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { + } */ + + /* Remember to set IPv6 enabled */ + ifnet_set_data (conn_name, "enable_ipv6", "true"); + + if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { + const char *config = ifnet_get_data (conn_name, "config"); + gchar *tmp; + GString *ip_str; + + if (!config) + config = ""; + num = nm_setting_ip_config_get_num_addresses (s_ip6); + + /* IPv6 addresses */ + ip_str = g_string_new (NULL); + for (i = 0; i < num; i++) { + addr = nm_setting_ip_config_get_address (s_ip6, i); + + g_string_append_printf (ip_str, "\"%s/%u\"", + nm_ip_address_get_address (addr), + nm_ip_address_get_prefix (addr)); + } + tmp = g_strdup_printf ("%s\" %s", config, ip_str->str); + ifnet_set_data (conn_name, "config", tmp); + g_free (tmp); + g_string_free (ip_str, TRUE); + } + + /* DNS Servers */ + num = nm_setting_ip_config_get_num_dns (s_ip6); + if (num > 0) { + const char *dns_servers = ifnet_get_data (conn_name, "dns_servers"); + gchar *tmp; + GString *dns_string = g_string_new (NULL); + const char *dns; + + if (!dns_servers) + dns_servers = ""; + for (i = 0; i < num; i++) { + dns = nm_setting_ip_config_get_dns (s_ip6, i); + + if (!strstr (dns_servers, dns)) + g_string_append_printf (dns_string, "%s ", dns); + } + tmp = g_strdup_printf ("%s %s", dns_servers, dns_string->str); + ifnet_set_data (conn_name, "dns_servers", tmp); + g_free (tmp); + g_string_free (dns_string, TRUE); + + } else + /* DNS Searches */ + num = nm_setting_ip_config_get_num_dns_searches (s_ip6); + if (num > 0) { + const char *ip4_domains; + + ip4_domains = ifnet_get_data (conn_name, "dns_search"); + if (!ip4_domains) + ip4_domains = ""; + searches = g_string_new (ip4_domains); + for (i = 0; i < num; i++) { + const gchar *search = NULL; + + search = + nm_setting_ip_config_get_dns_search (s_ip6, i); + if (search && !strstr (searches->str, search)) { + if (searches->len > 0) + g_string_append_c (searches, ' '); + g_string_append (searches, search); + } + } + ifnet_set_data (conn_name, "dns_search", searches->str); + g_string_free (searches, TRUE); + } + + write_route6_file (s_ip6, conn_name); + return TRUE; +} + +static gboolean +write_pppoe_setting (const char *conn_name, NMSettingPppoe * s_pppoe) +{ + const gchar *value; + + value = nm_setting_pppoe_get_username (s_pppoe); + if (!value) { + return FALSE; + } + ifnet_set_data (conn_name, "username", (gchar *) value); + + value = nm_setting_pppoe_get_password (s_pppoe); + /* password could be NULL here */ + if (value) { + ifnet_set_data (conn_name, "password", (gchar *) value); + } + return TRUE; +} + +gboolean +ifnet_update_parsers_by_connection (NMConnection *connection, + const char *conn_name, + const char *config_file, + const char *wpa_file, + gchar **out_new_name, + gchar **out_backup, + GError **error) +{ + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip6; + gboolean success = FALSE; + const char *type; + gboolean no_8021x = FALSE; + gboolean wired = FALSE, pppoe = TRUE; + const char *new_name = NULL; + + if (!ifnet_can_write_connection (connection, error)) + return FALSE; + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + type = nm_setting_connection_get_connection_type (s_con); + if (!type) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing connection type!"); + goto out; + } + + if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { + /* Writing wired setting */ + if (!write_wired_setting (connection, conn_name, error)) + goto out; + wired = TRUE; + no_8021x = TRUE; + } else if (!strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME)) { + /* Writing wireless setting */ + if (!write_wireless_setting (connection, conn_name, &no_8021x, &new_name, error)) + goto out; + } else if (!strcmp (type, NM_SETTING_PPPOE_SETTING_NAME)) { + NMSettingPppoe *s_pppoe; + + /* Writing pppoe setting */ + s_pppoe = nm_connection_get_setting_pppoe (connection); + if (!write_pppoe_setting (conn_name, s_pppoe)) + goto out; + pppoe = TRUE; + wired = TRUE; + no_8021x = TRUE; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, + "Can't write connection type '%s'", type); + goto out; + } + + /* connection name may have been updated; use it when writing out + * the rest of the settings. + */ + if (new_name) + conn_name = new_name; + + //FIXME wired connection doesn't support 8021x now + if (!no_8021x) { + if (!write_8021x_setting (connection, conn_name, wired, error)) + goto out; + } + + /* IPv4 Setting */ + if (!write_ip4_setting (connection, conn_name, error)) + goto out; + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + if (s_ip6) { + /* IPv6 Setting */ + if (!write_ip6_setting (connection, conn_name, error)) + goto out; + } + + /* Connection Setting */ + ifnet_set_data (conn_name, "auto", + nm_setting_connection_get_autoconnect (s_con) ? "true" : "false"); + ifnet_set_data (conn_name, "uuid", nm_connection_get_uuid (connection)); + + /* Write changes to disk */ + success = ifnet_flush_to_file (config_file, out_backup); + if (success) + wpa_flush_to_file (wpa_file); + + if (out_new_name) + *out_new_name = g_strdup (conn_name); + +out: + return success; +} + +gboolean +ifnet_delete_connection_in_parsers (const char *conn_name, + const char *config_file, + const char *wpa_file, + gchar **out_backup) +{ + gboolean result = FALSE; + + ifnet_delete_network (conn_name); + result = ifnet_flush_to_file (config_file, out_backup); + if (result) { + /* connection may not have security information + * so simply ignore the return value*/ + wpa_delete_security (conn_name); + wpa_flush_to_file (wpa_file); + } + + return result; +} + +static void +check_unsupported_secrets (NMSetting *setting, + const char *key, + const GValue *value, + GParamFlags flags, + gpointer user_data) +{ + gboolean *unsupported_secret = user_data; + + if (flags & NM_SETTING_PARAM_SECRET) { + NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; + + if (!nm_setting_get_secret_flags (setting, key, &secret_flags, NULL)) + g_return_if_reached (); + if (secret_flags != NM_SETTING_SECRET_FLAG_NONE) + *unsupported_secret = TRUE; + } +} + +gboolean +ifnet_can_write_connection (NMConnection *connection, GError **error) +{ + NMSettingConnection *s_con; + gboolean has_unsupported_secrets = FALSE; + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + /* If the connection is not available for all users, ignore + * it as this plugin only deals with System Connections */ + if (nm_setting_connection_get_num_permissions (s_con)) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, + "The ifnet plugin does not support non-system-wide connections."); + return FALSE; + } + + /* Only support wired, wifi, and PPPoE */ + if ( !nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME) + && !nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME) + && !nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, + "The ifnet plugin cannot write the connection '%s' (type '%s')", + nm_connection_get_id (connection), + nm_setting_connection_get_connection_type (s_con)); + return FALSE; + } + + /* If the connection has flagged secrets, ignore + * it as this plugin does not deal with user agent service */ + nm_connection_for_each_setting_value (connection, + check_unsupported_secrets, + &has_unsupported_secrets); + if (has_unsupported_secrets) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, + "The ifnet plugin only supports persistent system secrets."); + return FALSE; + } + + return TRUE; +} + +/* get the available wired name(eth*). */ +static gchar * +get_wired_name (void) +{ + int i = 0; + + for (; i < 256; i++) { + gchar *conn_name = g_strdup_printf ("eth%d", i); + + if (!ifnet_has_network (conn_name)) { + return conn_name; + } else + g_free (conn_name); + } + return NULL; +} + +/* get the available pppoe name(ppp*). */ +static gchar * +get_ppp_name (void) +{ + int i = 0; + + for (; i < 256; i++) { + gchar *conn_name = g_strdup_printf ("ppp%d", i); + + if (!ifnet_has_network (conn_name)) { + return conn_name; + } else + g_free (conn_name); + } + return NULL; +} + +/* get wireless ssid */ +static gchar * +get_wireless_name (NMConnection * connection) +{ + NMSettingWireless *s_wireless; + GBytes *ssid; + const guint8 *ssid_data; + gsize ssid_len; + gboolean hex_ssid = FALSE; + gchar *result = NULL; + char buf[33]; + int i = 0; + + s_wireless = nm_connection_get_setting_wireless (connection); + if (!s_wireless) + return NULL; + + ssid = nm_setting_wireless_get_ssid (s_wireless); + ssid_data = g_bytes_get_data (ssid, &ssid_len); + if (!ssid_len || ssid_len > 32) { + return NULL; + } + + for (i = 0; i < ssid_len; i++) { + if (!g_ascii_isprint (ssid_data[i])) { + hex_ssid = TRUE; + break; + } + } + + if (hex_ssid) { + GString *str; + + str = g_string_sized_new (ssid_len * 2 + 3); + g_string_append (str, "0x"); + for (i = 0; i < ssid_len; i++) + g_string_append_printf (str, "%02X", ssid_data[i]); + result = g_strdup (str->str); + g_string_free (str, TRUE); + } else { + memset (buf, 0, sizeof (buf)); + memcpy (buf, ssid_data, ssid_len); + result = g_strdup_printf ("%s", buf); + g_strstrip (result); + } + + return result; +} + +gboolean +ifnet_add_new_connection (NMConnection *connection, + const char *config_file, + const char *wpa_file, + gchar **out_new_name, + gchar **out_backup, + GError **error) +{ + NMSettingConnection *s_con; + gboolean success = FALSE; + const char *type; + gchar *new_type, *new_name = NULL; + + if (!ifnet_can_write_connection (connection, error)) + return FALSE; + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + type = nm_setting_connection_get_connection_type (s_con); + g_assert (type); + + nm_log_info (LOGD_SETTINGS, "Adding %s connection", type); + + /* get name and type + * Wireless type: wireless + * Wired type: wired + * PPPoE type: ppp*/ + if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { + new_name = get_wired_name (); + if (!new_name) + goto out; + new_type = "wired"; + } else if (!strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME)) { + new_name = get_wireless_name (connection); + new_type = "wireless"; + } else if (!strcmp (type, NM_SETTING_PPPOE_SETTING_NAME)) { + new_name = get_ppp_name (); + if (!new_name) + goto out; + new_type = "ppp"; + } else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, + "Can't write connection type '%s'", type); + goto out; + } + + if (ifnet_add_network (new_name, new_type)) { + success = ifnet_update_parsers_by_connection (connection, + new_name, + config_file, + wpa_file, + NULL, + out_backup, + error); + } + + nm_log_info (LOGD_SETTINGS, "Added new connection: %s, result: %s", + new_name, success ? "success" : "fail"); + +out: + if (!success || !out_new_name) + g_free (new_name); + else if (out_new_name) + *out_new_name = new_name; + return success; +} + diff --git a/src/settings/plugins/ifnet/nms-ifnet-connection-parser.h b/src/settings/plugins/ifnet/nms-ifnet-connection-parser.h new file mode 100644 index 00000000..e6c0e88c --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-connection-parser.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#ifndef _CONNECTION_PARSER_H +#define _CONNECTION_PARSER_H + +#include + +#include "nms-ifnet-net-parser.h" + +gboolean ifnet_can_write_connection (NMConnection *connection, GError **error); + +NMConnection *ifnet_update_connection_from_config_block (const char *conn_name, + const char *basepath, + GError **error); + +/* nm_conn_name is used to update nm_ifnet_connection's priv data */ +gboolean ifnet_update_parsers_by_connection (NMConnection *connection, + const char *conn_name, + const char *config_file, + const char *wpa_file, + gchar **out_new_name, + gchar **out_backup, + GError **error); + +gboolean ifnet_delete_connection_in_parsers (const char *conn_name, + const char *config_file, + const char *wpa_file, + gchar **out_backup); + +gboolean ifnet_add_new_connection (NMConnection *connection, + const char *config_file, + const char *wpa_file, + gchar **out_new_name, + gchar **out_backup, + GError ** error); +#endif diff --git a/src/settings/plugins/ifnet/nms-ifnet-connection.c b/src/settings/plugins/ifnet/nms-ifnet-connection.c new file mode 100644 index 00000000..ba87d46c --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-connection.c @@ -0,0 +1,238 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifnet-connection.h" + +#include +#include + +#include "nm-dbus-interface.h" +#include "nm-utils.h" +#include "nm-setting-wireless-security.h" +#include "settings/nm-settings-connection.h" +#include "settings/nm-settings-plugin.h" + +#include "nms-ifnet-connection-parser.h" +#include "nms-ifnet-net-parser.h" +#include "nms-ifnet-net-utils.h" +#include "nms-ifnet-wpa-parser.h" +#include "nms-ifnet-plugin.h" + +/*****************************************************************************/ + +enum { + IFNET_SETUP_MONITORS, + IFNET_CANCEL_MONITORS, + IFNET_LAST_SIGNAL +}; + +static guint signals[IFNET_LAST_SIGNAL] = { 0 }; + +typedef struct { + gchar *conn_name; + NMSettingsPlugin *config; +} NMIfnetConnectionPrivate; + +struct _NMIfnetConnection { + NMSettingsConnection parent; + NMIfnetConnectionPrivate _priv; +}; + +struct _NMIfnetConnectionClass { + NMSettingsConnectionClass parent; +}; + +G_DEFINE_TYPE (NMIfnetConnection, nm_ifnet_connection, NM_TYPE_SETTINGS_CONNECTION) + +#define NM_IFNET_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMIfnetConnection, NM_IS_IFNET_CONNECTION) + +/*****************************************************************************/ + +const char * +nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection) +{ + return NM_IFNET_CONNECTION_GET_PRIVATE (connection)->conn_name; +} + +static void +commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, + NMSettingsConnectionCommitFunc callback, + gpointer user_data) +{ + GError *error = NULL; + NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) connection); + gchar *new_name = NULL; + gboolean success = FALSE; + + g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0); + + if (priv->conn_name) { + /* Existing connection; update it */ + success = ifnet_update_parsers_by_connection (NM_CONNECTION (connection), + priv->conn_name, + CONF_NET_FILE, + WPA_SUPPLICANT_CONF, + &new_name, + NULL, + &error); + } else { + /* New connection, add it */ + success = ifnet_add_new_connection (NM_CONNECTION (connection), + CONF_NET_FILE, + WPA_SUPPLICANT_CONF, + &new_name, + NULL, + &error); + if (success) + reload_parsers (); + } + + if (success) { + /* update connection name */ + g_assert (new_name); + g_free (priv->conn_name); + priv->conn_name = new_name; + + NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); + nm_log_info (LOGD_SETTINGS, "Successfully updated %s", priv->conn_name); + } else { + nm_log_warn (LOGD_SETTINGS, "Failed to update %s", + priv->conn_name ? priv->conn_name : + nm_connection_get_id (NM_CONNECTION (connection))); + reload_parsers (); + callback (connection, error, user_data); + g_error_free (error); + } + + g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0); +} + +static void +do_delete (NMSettingsConnection *connection, + NMSettingsConnectionDeleteFunc callback, + gpointer user_data) +{ + GError *error = NULL; + NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) connection); + + g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0); + + /* Only connections which exist in /etc/conf.d/net will have a conn_name */ + if (priv->conn_name) { + if (!ifnet_delete_connection_in_parsers (priv->conn_name, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL)) { + nm_log_warn (LOGD_SETTINGS, "Failed to delete %s", priv->conn_name); + reload_parsers (); + callback (connection, error, user_data); + g_error_free (error); + g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0); + return; + } + } + + NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->delete (connection, callback, user_data); + + g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0); + + nm_log_info (LOGD_SETTINGS, "Successfully deleted %s", + priv->conn_name ? priv->conn_name : + nm_connection_get_id (NM_CONNECTION (connection))); +} + +/*****************************************************************************/ + +static void +nm_ifnet_connection_init (NMIfnetConnection * connection) +{ +} + +NMIfnetConnection * +nm_ifnet_connection_new (NMConnection *source, const char *conn_name) +{ + NMConnection *tmp; + GObject *object; + GError *error = NULL; + gboolean update_unsaved = TRUE; + + g_return_val_if_fail (source || conn_name, NULL); + + if (source) + tmp = g_object_ref (source); + else { + tmp = ifnet_update_connection_from_config_block (conn_name, NULL, &error); + if (!tmp) { + nm_log_warn (LOGD_SETTINGS, "Could not read connection '%s': %s", + conn_name, error->message); + g_error_free (error); + return NULL; + } + + /* If we just read the connection from disk, it's clearly not Unsaved */ + update_unsaved = FALSE; + } + + object = (GObject *) g_object_new (NM_TYPE_IFNET_CONNECTION, NULL); + + NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) object)->conn_name = g_strdup (conn_name); + if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), + tmp, + update_unsaved, + NULL, + NULL)) { + g_object_unref (object); + return NULL; + } + g_object_unref (tmp); + + return NM_IFNET_CONNECTION (object); +} + +static void +finalize (GObject * object) +{ + g_free (NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) object)->conn_name); + G_OBJECT_CLASS (nm_ifnet_connection_parent_class)->finalize (object); +} + +static void +nm_ifnet_connection_class_init (NMIfnetConnectionClass * ifnet_connection_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (ifnet_connection_class); + NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (ifnet_connection_class); + + object_class->finalize = finalize; + + settings_class->delete = do_delete; + settings_class->commit_changes = commit_changes; + + signals[IFNET_SETUP_MONITORS] = + g_signal_new ("ifnet_setup_monitors", + G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, + 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + signals[IFNET_CANCEL_MONITORS] = + g_signal_new ("ifnet_cancel_monitors", + G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, + 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} diff --git a/src/settings/plugins/ifnet/nms-ifnet-connection.h b/src/settings/plugins/ifnet/nms-ifnet-connection.h new file mode 100644 index 00000000..1bc06644 --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-connection.h @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#ifndef __NETWORKMANAGER_IFNET_CONNECTION_H__ +#define __NETWORKMANAGER_IFNET_CONNECTION_H__ + +#include "settings/nm-settings-connection.h" + +#include "nms-ifnet-net-parser.h" + +#define NM_TYPE_IFNET_CONNECTION (nm_ifnet_connection_get_type ()) +#define NM_IFNET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFNET_CONNECTION, NMIfnetConnection)) +#define NM_IFNET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionClass)) +#define NM_IS_IFNET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFNET_CONNECTION)) +#define NM_IS_IFNET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFNET_CONNECTION)) +#define NM_IFNET_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionClass)) + +typedef struct _NMIfnetConnection NMIfnetConnection; +typedef struct _NMIfnetConnectionClass NMIfnetConnectionClass; + +GType nm_ifnet_connection_get_type (void); + +NMIfnetConnection *nm_ifnet_connection_new (NMConnection *source, + const char *conn_name); + +const char *nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection); + +#endif /* __NETWORKMANAGER_IFNET_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifnet/nms-ifnet-net-parser.c b/src/settings/plugins/ifnet/nms-ifnet-net-parser.c new file mode 100644 index 00000000..0007f9cd --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-net-parser.c @@ -0,0 +1,734 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifnet-net-parser.h" + +#include +#include +#include +#include + +#include "settings/nm-settings-plugin.h" +#include "platform/nm-platform.h" + +#include "nms-ifnet-plugin.h" +#include "nms-ifnet-net-utils.h" + +/* Save all the connection information */ +static GHashTable *conn_table; + +/* Save global settings which are used for writing*/ +static GHashTable *global_settings_table; + +/* Save functions */ +static GList *functions_list; + +/* Used to decide whether to write changes to file*/ +static gboolean net_parser_data_changed = FALSE; + +static GHashTable * +add_new_connection_config (const gchar * type, const gchar * name) +{ + GHashTable *new_conn; + gchar *new_name; + + if (!name) + return NULL; + + /* Return existing connection */ + if ((new_conn = g_hash_table_lookup (conn_table, name)) != NULL) + return new_conn; + new_conn = g_hash_table_new (g_str_hash, g_str_equal); + new_name = g_strdup (name); + g_hash_table_insert (new_conn, g_strdup ("name"), new_name); + g_hash_table_insert (new_conn, g_strdup ("type"), g_strdup (type)); + g_hash_table_insert (conn_table, new_name, new_conn); + return new_conn; +} + +gboolean +ifnet_add_network (const char *name, const char *type) +{ + if (ifnet_has_network (name)) + return TRUE; + if (add_new_connection_config (type, name)) { + nm_log_info (LOGD_SETTINGS, "Adding network for %s", name); + net_parser_data_changed = TRUE; + return TRUE; + } + return FALSE; +} + +gboolean +ifnet_has_network (const char *conn_name) +{ + return g_hash_table_lookup (conn_table, conn_name) != NULL; +} + +static GHashTable * +get_connection_config (const char *name) +{ + return g_hash_table_lookup (conn_table, name); +} + +/* Ignored name won't be treated as wireless ssid */ +static gchar *ignore_name[] = { + "vlan", "bond", "atm", "ath", "ippp", "vpn", "tap", "tun", "1", + "br", "nas", "6to4", "timeout", "kvm", "force", NULL +}; + +static gboolean +ignore_connection_name (const char *name) +{ + gboolean result = FALSE; + guint i = 0; + + /* check ignore_name list */ + while (ignore_name[i] != NULL) { + if (g_ascii_strncasecmp + (name, ignore_name[i], strlen (ignore_name[i])) == 0) { + return TRUE; + } + i++; + } + /* Ignore mac address based configuration */ + if (strlen (name) == 12 && is_hex (name)) + result = TRUE; + return result; +} + +static gboolean +is_global_setting (char *key) +{ + static gchar *global_settings[] = { "wpa_supplicant_", NULL }; + int i; + + for (i = 0; global_settings[i] != NULL; i++) { + if (strstr (key, global_settings[i])) + return 1; + } + return 0; +} + +/* Parse a complete line */ +/* Connection type is determined here */ +static void +init_block_by_line (gchar * buf) +{ + gchar **key_value; + gchar *pos; + gchar *data; + gchar *tmp; + GHashTable *conn; + + key_value = g_strsplit (buf, "=", 2); + if (g_strv_length (key_value) != 2) { + nm_log_warn (LOGD_SETTINGS, "Can't handle this line: %s\n", buf); + g_strfreev (key_value); + return; + } + pos = g_strrstr (key_value[0], "_"); + if (pos == NULL || is_global_setting (key_value[0])) { + /* global data */ + data = g_strdup (key_value[1]); + tmp = strip_string (data, '"'); + strip_string (tmp, '\''); + nm_log_info (LOGD_SETTINGS, "global:%s-%s\n", key_value[0], tmp); + g_hash_table_insert (global_settings_table, g_strdup (key_value[0]), g_strdup (tmp)); + g_strfreev (key_value); + g_free (data); + return; + } + *pos++ = '\0'; + if ((conn = get_connection_config (pos)) == NULL) { + if (g_ascii_strncasecmp (pos, "eth", 3) == 0 + && strlen (pos) == 4) + /* wired connection */ + conn = add_new_connection_config ("wired", pos); + else if (g_ascii_strncasecmp (pos, "ppp", 3) == 0 + && strlen (pos) == 4) + /* pppoe connection */ + conn = add_new_connection_config ("ppp", pos); + else if (ignore_connection_name (pos)) { + /* ignored connection */ + conn = add_new_connection_config ("ignore", pos); + } else { + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, pos); + + if (ifindex && nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) != NM_LINK_TYPE_WIFI) + /* wired connection */ + conn = add_new_connection_config ("wired", pos); + else + /* wireless connection */ + conn = add_new_connection_config ("wireless", pos); + } + } + data = g_strdup (key_value[1]); + tmp = strip_string (data, '"'); + strip_string (tmp, '\''); + if (conn) + g_hash_table_insert (conn, strip_string (g_strdup (key_value[0]), ' '), + g_strdup (tmp)); + g_free (data); + g_strfreev (key_value); +} + +static void +destroy_connection_config (GHashTable * conn) +{ + gpointer key, value; + GHashTableIter iter; + + g_hash_table_iter_init (&iter, conn); + while (g_hash_table_iter_next (&iter, &key, &value)) { + g_free (key); + g_free (value); + } + + g_hash_table_destroy (conn); +} + +static void +strip_function (GIOChannel * channel, gchar * line) +{ + + int counter = 0; + gchar *p, *tmp; + gboolean begin = FALSE; + GString *function_str = g_string_new (line); + + g_string_append (function_str, "\n"); + while (1) { + p = line; + while (*p != '\0') { + if (*p == '{') { + counter++; + begin = TRUE; + } else if (*p == '}') + counter--; + p++; + } + if (begin && counter == 0) { + g_free (line); + goto done; + } + while (1) { + g_free (line); + if (g_io_channel_read_line + (channel, &line, NULL, NULL, + NULL) == G_IO_STATUS_EOF) + goto done; + g_string_append (function_str, line); + tmp = g_strdup (line); + g_strstrip (tmp); + if (tmp[0] != '#' && tmp[0] != '\0') { + g_free (tmp); + break; + } else + g_free (tmp); + } + } +done: + functions_list = + g_list_append (functions_list, g_strdup (function_str->str)); + g_string_free (function_str, TRUE); +} + +static gboolean +is_function (gchar * line) +{ + static gchar *func_names[] = + { "preup", "predown", "postup", "postdown", "failup", "faildown", + NULL, + }; + int i; + + for (i = 0; func_names[i]; i++) { + if (g_str_has_prefix (line, func_names[i])) { + nm_log_info (LOGD_SETTINGS, "Ignoring function: %s", func_names[i]); + return TRUE; + } + } + return FALSE; +} + +static void +append_line (GString *buf, gchar* line) +{ + gchar *pos = NULL; + + if ((pos = strchr (line, '#')) != NULL) + *pos = '\0'; + g_strstrip (line); + + if (line[0] != '\0') + g_string_append_printf (buf, " %s", line); + g_free (line); +} + +gboolean +ifnet_init (gchar * config_file) +{ + GIOChannel *channel = NULL; + gchar *line; + + /* Handle multiple lines with brackets */ + gboolean complete = TRUE; + + gboolean openrc_style = TRUE; + + /* line buffer */ + GString *buf; + + net_parser_data_changed = FALSE; + + conn_table = g_hash_table_new (g_str_hash, g_str_equal); + global_settings_table = g_hash_table_new (g_str_hash, g_str_equal); + functions_list = NULL; + + if (g_file_test (config_file, G_FILE_TEST_IS_REGULAR)) + channel = g_io_channel_new_file (config_file, "r", NULL); + if (channel == NULL) { + nm_log_warn (LOGD_SETTINGS, "Can't open %s", config_file); + return FALSE; + } + + buf = g_string_new (NULL); + while (g_io_channel_read_line + (channel, &line, NULL, NULL, NULL) != G_IO_STATUS_EOF) { + g_strstrip (line); + /* convert multiple lines to a complete line and + * pass it to init_block_by_line() */ + if (is_function (line)) { + strip_function (channel, line); + continue; + } + + // New openrc style, bash arrays are not allowed. We only care about '"' + if (openrc_style && line[0] != '#' && line[0] != '\0' + && !strchr (line, '(') && !strchr (line, ')')) { + gchar *tmp = line; + + while ((tmp = strchr (tmp, '"')) != NULL) { + complete = !complete; + ++tmp; + } + + append_line (buf, line); + // Add "(separator) for routes. It will be easier for later parsing + if (strstr (buf->str, "via")) + g_string_append_printf (buf, "\""); + + if (!complete) + continue; + + strip_string (buf->str, '"'); + + init_block_by_line (buf->str); + g_string_free (buf, TRUE); + buf = g_string_new (NULL); + } + // Old bash arrays for baselayout-1, to be deleted + else if (line[0] != '#' && line[0] != '\0') { + if (!complete) { + complete = + g_strrstr (line, + ")") == NULL ? FALSE : TRUE; + + append_line (buf, line); + if (!complete) { + openrc_style = FALSE; + continue; + } + else { + openrc_style = TRUE; + } + } else { + complete = + (g_strrstr (line, "(") != NULL + && g_strrstr (line, ")") != NULL) + || g_strrstr (line, "(") == NULL; + + append_line (buf, line); + if (!complete) + { + openrc_style = FALSE; + continue; + } else { + openrc_style = TRUE; + } + } + init_block_by_line (buf->str); + g_string_free (buf, TRUE); + buf = g_string_new (NULL); + } else + /* Blank line or comment line */ + g_free (line); + } + + g_string_free (buf, TRUE); + g_io_channel_shutdown (channel, FALSE, NULL); + g_io_channel_unref (channel); + return TRUE; +} + +const char * +ifnet_get_data (const char *conn_name, const char *key) +{ + GHashTable *conn; + + g_return_val_if_fail (conn_name && key, NULL); + + conn = g_hash_table_lookup (conn_table, conn_name); + + if (conn) + return g_hash_table_lookup (conn, key); + return NULL; +} + +/* format ip values for comparison */ +static gchar* +format_ip_for_comparison (const gchar * value) +{ + gchar **ipset; + guint length, i; + GString *formated_string = g_string_new (NULL); + gchar *formatted = NULL; + + ipset = g_strsplit (value, "\"", 0); + length = g_strv_length (ipset); + + for (i = 0; i < length; i++) + { + strip_string (ipset[i], ' '); + if (ipset[i][0] != '\0') + g_string_append_printf (formated_string, + "%s ", ipset[i]); + } + formatted = g_strdup (formated_string->str); + formatted[formated_string->len - 1] = '\0'; + + g_string_free (formated_string, TRUE); + g_strfreev (ipset); + + return formatted; +} + +void +ifnet_set_data (const char *conn_name, const char *key, const char *value) +{ + gpointer old_key = NULL, old_value = NULL; + GHashTable *conn = g_hash_table_lookup (conn_table, conn_name); + gchar * stripped = NULL; + + if (!conn) { + nm_log_warn (LOGD_SETTINGS, "%s does not exist!", conn_name); + return; + } + if (value){ + stripped = g_strdup (value); + strip_string (stripped, '"'); + } + /* Remove existing key value pair */ + if (g_hash_table_lookup_extended (conn, key, &old_key, &old_value)) { + + /* This ugly hack is due to baselayout compatibility. We have to + * deal with different ip format. So sometimes we have the same ips + * but different strings. + */ + if (stripped && + (!strcmp (key, "config") + || !strcmp (key, "routes") + || !strcmp (key, "pppd") + || !strcmp (key, "chat"))) + { + gchar *old_ips = format_ip_for_comparison (old_value); + gchar *new_ips = format_ip_for_comparison (value); + if(!strcmp (old_ips, new_ips)) + { + g_free (stripped); + g_free (old_ips); + g_free (new_ips); + return; + } + g_free (old_ips); + g_free (new_ips); + } + + if (stripped && !strcmp (old_value, stripped)) { + g_free (stripped); + return; + } + g_hash_table_remove (conn, old_key); + g_free (old_key); + g_free (old_value); + } else if (!value) + return; + if (stripped) + g_hash_table_insert (conn, g_strdup (key), stripped); + net_parser_data_changed = TRUE; +} + +// Remember to free return value +const char * +ifnet_get_global_data (const gchar * key) +{ + return g_hash_table_lookup (global_settings_table, key); +} + +// Return names of legal connections +GList * +ifnet_get_connection_names (void) +{ + GList *names = g_hash_table_get_keys (conn_table); + GList *iter, *result = NULL; + + for (iter = names; iter; iter = iter->next) { + if (!ignore_connection_name (iter->data)) + result = g_list_prepend (result, iter->data); + } + + g_list_free (names); + return g_list_reverse (result); +} + +/* format IP and route for writing */ +static void +format_ips (gchar * value, gchar ** out_line, gchar * key, gchar * name) +{ + gchar **ipset; + guint length, i; + GString *formated_string = g_string_new (NULL); + + strip_string (value, '('); + strip_string (value, ')'); + strip_string (value, '"'); + ipset = g_strsplit (value, "\"", 0); + length = g_strv_length (ipset); + + //only one line + if (length < 2) { + *out_line = + g_strdup_printf ("%s_%s=\"%s\"\n", key, name, value); + goto done; + } + // Multiple lines + g_string_append_printf (formated_string, "%s_%s=\"\n", key, name); + for (i = 0; i < length; i++) + { + strip_string (ipset[i], ' '); + if (ipset[i][0] != '\0') + g_string_append_printf (formated_string, + "%s\n", ipset[i]); + } + g_string_append (formated_string, "\"\n"); + *out_line = g_strdup (formated_string->str); +done: + g_string_free (formated_string, TRUE); + g_strfreev (ipset); +} + +gboolean +ifnet_flush_to_file (const char *config_file, gchar **out_backup) +{ + GIOChannel *channel; + GError *error = NULL; + gpointer key, value, name, network; + GHashTableIter iter, iter_network; + GList *list_iter; + gchar *out_line = NULL; + gsize bytes_written; + gboolean result = FALSE; + gchar *backup; + + if (!net_parser_data_changed) + return TRUE; + if (!conn_table || !global_settings_table) + return FALSE; + + backup = backup_file (config_file); + + channel = g_io_channel_new_file (config_file, "w", NULL); + if (!channel) { + nm_log_warn (LOGD_SETTINGS, "Can't open file %s for writing", config_file); + g_free (backup); + return FALSE; + } + g_hash_table_iter_init (&iter, global_settings_table); + nm_log_info (LOGD_SETTINGS, "Writing to %s", config_file); + g_io_channel_write_chars (channel, + "#Generated by NetworkManager\n" + "###### Global Configuration ######\n", + -1, &bytes_written, &error); + if (error) + goto done; + + /* Writing global data */ + while (g_hash_table_iter_next (&iter, &key, &value)) { + out_line = + g_strdup_printf ("%s=\"%s\"\n", (gchar *) key, (gchar *) value); + g_io_channel_write_chars (channel, out_line, -1, + &bytes_written, &error); + if (bytes_written == 0 || error) + goto done; + g_free (out_line); + } + + /* Writing connection data */ + g_io_channel_write_chars (channel, + "\n###### Connection Configuration ######\n", + -1, &bytes_written, &error); + if (error) + goto done; + + g_hash_table_iter_init (&iter, conn_table); + while (g_hash_table_iter_next (&iter, &name, &network)) { + g_hash_table_iter_init (&iter_network, (GHashTable *) network); + g_io_channel_write_chars (channel, + "#----------------------------------\n", + -1, &bytes_written, &error); + if (error) + goto done; + + while (g_hash_table_iter_next (&iter_network, &key, &value)) { + if (!g_str_has_prefix ((gchar *) key, "name") + && !g_str_has_prefix ((gchar *) key, "type")) { + /* These keys contain brackets */ + if (strcmp + ((gchar *) key, + "config") == 0 + || strcmp ((gchar *) key, + "routes") == 0 + || strcmp ((gchar *) key, + "pppd") == 0 + || strcmp ((gchar *) key, "chat") == 0) + format_ips (value, &out_line, (gchar *) + key, (gchar *) + name); + else + out_line = + g_strdup_printf + ("%s_%s=\"%s\"\n", + (gchar *) key, + (gchar *) name, (gchar *) value); + g_io_channel_write_chars (channel, out_line, -1, &bytes_written, &error); + if (bytes_written == 0 || error) + goto done; + g_free (out_line); + } + } + } + + /* Writing reserved functions */ + if (functions_list) { + g_io_channel_write_chars (channel, + "\n###### Reserved Functions ######\n", + -1, &bytes_written, &error); + if (error) + goto done; + + /* Writing functions */ + for (list_iter = functions_list; list_iter; + list_iter = g_list_next (list_iter)) { + out_line = + g_strdup_printf ("%s\n", (gchar *) list_iter->data); + g_io_channel_write_chars (channel, out_line, -1, + &bytes_written, &error); + if (bytes_written == 0 || error) + goto done; + g_free (out_line); + } + } + + g_io_channel_flush (channel, &error); + if (error) + goto done; + result = TRUE; + net_parser_data_changed = FALSE; + +done: + if (error) { + nm_log_warn (LOGD_SETTINGS, "Error writing the configuration file: %s", error->message); + g_error_free (error); + } + + if (result && out_backup) + *out_backup = backup; + else + g_free (backup); + + g_io_channel_shutdown (channel, FALSE, NULL); + g_io_channel_unref (channel); + return result; +} + +gboolean +ifnet_delete_network (const char *conn_name) +{ + GHashTable *network = NULL; + + g_return_val_if_fail (conn_table != NULL && conn_name != NULL, FALSE); + nm_log_info (LOGD_SETTINGS, "Deleting network for %s", conn_name); + network = g_hash_table_lookup (conn_table, conn_name); + if (!network) + return FALSE; + g_hash_table_remove (conn_table, conn_name); + destroy_connection_config (network); + net_parser_data_changed = TRUE; + return TRUE; +} + +void +ifnet_destroy (void) +{ + GHashTableIter iter; + gpointer key; + gpointer value; + GList *list_iter; + + /* Destroy connection setting */ + if (conn_table) { + g_hash_table_iter_init (&iter, conn_table); + while (g_hash_table_iter_next (&iter, &key, &value)) { + destroy_connection_config ((GHashTable *) + value); + } + g_hash_table_destroy (conn_table); + conn_table = NULL; + } + + /* Destroy global data */ + if (global_settings_table) { + g_hash_table_iter_init (&iter, global_settings_table); + while (g_hash_table_iter_next (&iter, &key, &value)) { + g_free (key); + g_free (value); + } + g_hash_table_destroy (global_settings_table); + global_settings_table = NULL; + } + for (list_iter = functions_list; list_iter; + list_iter = g_list_next (list_iter)) + g_free (list_iter->data); + g_list_free (functions_list); +} diff --git a/src/settings/plugins/ifnet/nms-ifnet-net-parser.h b/src/settings/plugins/ifnet/nms-ifnet-net-parser.h new file mode 100644 index 00000000..31fc9ead --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-net-parser.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#ifndef _NET_PARSER_H +#define _NET_PARSER_H + +#define CONF_NET_FILE SYSCONFDIR "/conf.d/net" + +gboolean ifnet_init (gchar * config_file); +void ifnet_destroy (void); + +/* Reader functions */ +GList *ifnet_get_connection_names (void); +const char *ifnet_get_data (const char *conn_name, const char *key); +const char *ifnet_get_global_data (const char *key); +gboolean ifnet_has_network (const char *conn_name); + +/* Writer functions */ +gboolean ifnet_flush_to_file (const char *config_file, gchar **out_backup); +void ifnet_set_data (const char *conn_name, const char *key, const char *value); +gboolean ifnet_add_network (const char *name, const char *type); +gboolean ifnet_delete_network (const char *conn_name); + +#endif diff --git a/src/settings/plugins/ifnet/nms-ifnet-net-utils.c b/src/settings/plugins/ifnet/nms-ifnet-net-utils.c new file mode 100644 index 00000000..6531a238 --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-net-utils.c @@ -0,0 +1,830 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifnet-net-utils.h" + +#include +#include +#include +#include + +#include "nm-utils.h" +#include "NetworkManagerUtils.h" +#include "settings/nm-settings-plugin.h" +#include "nm-config.h" +#include "dhcp/nm-dhcp-manager.h" + +#include "nms-ifnet-wpa-parser.h" +#include "nms-ifnet-net-parser.h" + +/* emit heading and tailing blank space, tab, character t */ +gchar * +strip_string (gchar * str, gchar t) +{ + gchar *ret = str; + gint length = 0; + guint i = 0; + + while (ret[i] != '\0' + && (ret[i] == '\t' || ret[i] == ' ' || ret[i] == t)) { + length++; + i++; + } + i = 0; + while (ret[i + length] != '\0') { + ret[i] = ret[i + length]; + i++; + } + ret[i] = '\0'; + length = strlen (ret); + while ((length - 1) >= 0 + && (ret[length - 1] == ' ' || ret[length - 1] == '\n' + || ret[length - 1] == '\t' || ret[length - 1] == t)) + length--; + ret[length] = '\0'; + return ret; +} + +gboolean +is_hex (const char *value) +{ + const char *p = value; + + if (!p) + return FALSE; + while (*p) { + if (!g_ascii_isxdigit (*p++)) + return FALSE; + } + return TRUE; +} + +gboolean +is_ascii (const char *value) +{ + const char *p = value; + + while (*p) { + if (!g_ascii_isprint (*p++)) + return FALSE; + } + return TRUE; + +} + +gboolean +is_true (const char *str) +{ + if (!g_ascii_strcasecmp (str, "yes") + || !g_ascii_strcasecmp (str, "true")) + return TRUE; + return FALSE; +} + +static char * +find_default_gateway_str (char *str) +{ + char *tmp; + + if ((tmp = strstr (str, "default via ")) != NULL) { + return tmp + strlen ("default via "); + } else if ((tmp = strstr (str, "default gw ")) != NULL) { + return tmp + strlen ("default gw "); + } + return NULL; +} + +static char * +find_gateway_str (char *str) +{ + char *tmp; + + if ((tmp = strstr (str, "via ")) != NULL) { + return tmp + strlen ("via "); + } else if ((tmp = strstr (str, "gw ")) != NULL) { + return tmp + strlen ("gw "); + } + return NULL; +} + +gboolean +reload_parsers (void) +{ + ifnet_destroy (); + wpa_parser_destroy (); + if (!ifnet_init (CONF_NET_FILE)) + return FALSE; + wpa_parser_init (WPA_SUPPLICANT_CONF); + return TRUE; +} + +gboolean +is_static_ip4 (const char *conn_name) +{ + const char *data = ifnet_get_data (conn_name, "config"); + const char *dhcp6; + + if (!data) + return FALSE; + if (!strcmp (data, "shared")) + return FALSE; + if (!strcmp (data, "autoip")) + return FALSE; + dhcp6 = strstr (data, "dhcp6"); + if (dhcp6) { + gchar *dhcp4; + + if (strstr (data, "dhcp ")) + return FALSE; + dhcp4 = strstr (data, "dhcp"); + if (!dhcp4) + return TRUE; + if (dhcp4[4] == '\0') + return FALSE; + return TRUE; + } + return strstr (data, "dhcp") == NULL ? TRUE : FALSE; +} + +gboolean +is_static_ip6 (const char *conn_name) +{ + const char *data = ifnet_get_data (conn_name, "config"); + + if (!data) + return TRUE; + return strstr (data, "dhcp6") == NULL ? TRUE : FALSE; +} + +gboolean +is_ip4_address (const char *in_address) +{ + const char *pattern = + "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.((\\{\\d{1,3}\\.\\.\\d{1,3}\\})|\\d{1,3})$"; + gchar *address = g_strdup (in_address); + gboolean result = FALSE; + gchar *tmp; + GRegex *regex = g_regex_new (pattern, 0, 0, NULL); + GMatchInfo *match_info = NULL; + + if (!address) + goto done; + g_strstrip (address); + if ((tmp = strstr (address, "/")) != NULL) + *tmp = '\0'; + if ((tmp = strstr (address, " ")) != NULL) + *tmp = '\0'; + g_regex_match (regex, address, 0, &match_info); + result = g_match_info_matches (match_info); +done: + if (match_info) + g_match_info_free (match_info); + g_regex_unref (regex); + g_free (address); + return result; +} + +gboolean +is_ip6_address (const char *in_address) +{ + struct in6_addr tmp_ip6_addr; + gchar *tmp, *address; + gboolean result = FALSE; + + if (!in_address) + return FALSE; + address = g_strdup (in_address); + g_strstrip (address); + if ((tmp = strchr (address, '/')) != NULL) + *tmp = '\0'; + if (inet_pton (AF_INET6, address, &tmp_ip6_addr)) + result = TRUE; + g_free (address); + return result; + +} + +// 'c' is only used for openrc style +static gchar ** +split_addresses_by_char (const gchar *addresses, const gchar *c) +{ + gchar **ipset; + + if (addresses == NULL) + return NULL; + + if (strchr (addresses, '(') != NULL) { // old baselayout style + gchar *tmp = g_strdup (addresses); + strip_string (tmp, '('); + strip_string (tmp, ')'); + strip_string (tmp, '"'); + strip_string (tmp, '\''); + ipset = g_strsplit (tmp, "\" \"", 0); + g_free(tmp); + } else { // openrc style + if (strstr (addresses, "netmask")) + // There is only one ip address if "netmask" is specified. + // '\n' is not used in config so there will be only one split. + ipset = g_strsplit (addresses, "\n", 0); + else + ipset = g_strsplit (addresses, c, 0); + } + + return ipset; +} + +static gchar ** +split_addresses (const gchar* addresses) +{ + // " " is only used by openrc style + return split_addresses_by_char (addresses, " "); +} + +static gchar ** +split_routes (const gchar* routes) +{ + // "\"" is only used by openrc style + return split_addresses_by_char (routes, "\""); +} + +gboolean +has_ip6_address (const char *conn_name) +{ + gchar **ipset; + guint length; + guint i; + + g_return_val_if_fail (conn_name != NULL, FALSE); + ipset = split_addresses (ifnet_get_data (conn_name, "config")); + length = ipset ? g_strv_length (ipset) : 0; + for (i = 0; i < length; i++) { + if (!is_ip6_address (ipset[i])) + continue; + else { + g_strfreev (ipset); + return TRUE; + } + + } + g_strfreev (ipset); + return FALSE; +} + +gboolean +has_default_route (const char *conn_name, gboolean (*check_fn) (const char *)) +{ + char *routes = NULL, *end, *tmp; + gboolean success = FALSE; + + g_return_val_if_fail (conn_name != NULL, FALSE); + + routes = g_strdup (ifnet_get_data (conn_name, "routes")); + if (!routes) + return FALSE; + tmp = find_default_gateway_str (routes); + if (tmp) { + g_strstrip (tmp); + if ((end = strstr (tmp, "\"")) != NULL) + *end = '\0'; + if (check_fn (tmp)) + success = TRUE; + } + + g_free (routes); + return success; +} + +static ip_block * +create_ip4_block (gchar * ip) +{ + ip_block *iblock = g_slice_new0 (ip_block); + guint32 tmp_ip4_addr; + int i; + guint length; + gchar **ip_mask; + + /* prefix format */ + if (strstr (ip, "/")) { + gchar *prefix; + + ip_mask = g_strsplit (ip, "/", 0); + length = g_strv_length (ip_mask); + if (!nm_utils_ipaddr_valid (AF_INET, ip_mask[0])) + goto error; + iblock->ip = g_strdup (ip_mask[0]); + prefix = ip_mask[1]; + i = 0; + while (i < length && g_ascii_isdigit (prefix[i])) + i++; + prefix[i] = '\0'; + iblock->prefix = (guint32) atoi (ip_mask[1]); + } else if (strstr (ip, "netmask")) { + ip_mask = g_strsplit (ip, " ", 0); + length = g_strv_length (ip_mask); + if (!nm_utils_ipaddr_valid (AF_INET, ip_mask[0])) + goto error; + iblock->ip = g_strdup (ip_mask[0]); + i = 0; + while (i < length && !strstr (ip_mask[++i], "netmask")) ; + while (i < length && ip_mask[++i][0] == '\0') ; + if (i >= length) + goto error; + if (!inet_pton (AF_INET, ip_mask[i], &tmp_ip4_addr)) + goto error; + iblock->prefix = nm_utils_ip4_netmask_to_prefix (tmp_ip4_addr); + } else { + g_slice_free (ip_block, iblock); + if (!is_ip6_address (ip) && !strstr (ip, "dhcp")) + nm_log_warn (LOGD_SETTINGS, "Can't handle ipv4 address: %s, missing netmask or prefix", ip); + return NULL; + } + if (iblock->prefix == 0 || iblock->prefix > 32) { + nm_log_warn (LOGD_SETTINGS, "Can't handle ipv4 address: %s, invalid prefix", ip); + goto error; + } + g_strfreev (ip_mask); + return iblock; +error: + if (!is_ip6_address (ip)) + nm_log_warn (LOGD_SETTINGS, "Can't handle IPv4 address: %s", ip); + g_strfreev (ip_mask); + g_free (iblock->ip); + g_slice_free (ip_block, iblock); + return NULL; +} + +static ip_block * +create_ip_block (gchar * ip) +{ + ip_block *iblock = g_slice_new0 (ip_block); + gchar *dup_ip = g_strdup (ip); + gchar *prefix = NULL; + + if ((prefix = strstr (dup_ip, "/")) != NULL) { + *prefix = '\0'; + prefix++; + } + if (!nm_utils_ipaddr_valid (AF_INET6, dup_ip)) + goto error; + iblock->ip = dup_ip; + if (prefix) { + errno = 0; + iblock->prefix = strtol (prefix, NULL, 10); + if (errno || iblock->prefix <= 0 || iblock->prefix > 128) { + goto error; + } + } else + iblock->prefix = 64; + return iblock; +error: + if (!is_ip4_address (ip)) + nm_log_warn (LOGD_SETTINGS, "Can't handle IPv6 address: %s", ip); + g_slice_free (ip_block, iblock); + g_free (dup_ip); + return NULL; +} + +static char * +get_ip4_gateway (gchar * gateway) +{ + gchar *tmp, *split; + + if (!gateway) + return NULL; + tmp = find_gateway_str (gateway); + if (!tmp) { + nm_log_warn (LOGD_SETTINGS, "Couldn't obtain gateway in \"%s\"", gateway); + return NULL; + } + tmp = g_strdup (tmp); + strip_string (tmp, ' '); + strip_string (tmp, '"'); + + // Only one gateway is selected + if ((split = strstr (tmp, "\"")) != NULL) + *split = '\0'; + + if (!nm_utils_ipaddr_valid (AF_INET, tmp)) + goto error; + return tmp; +error: + if (!is_ip6_address (tmp)) + nm_log_warn (LOGD_SETTINGS, "Can't handle IPv4 gateway: %s", tmp); + g_free (tmp); + return NULL; +} + +static char * +get_ip6_next_hop (gchar * next_hop) +{ + gchar *tmp; + + if (!next_hop) + return NULL; + tmp = find_gateway_str (next_hop); + if (!tmp) { + nm_log_warn (LOGD_SETTINGS, "Couldn't obtain next_hop in \"%s\"", next_hop); + return NULL; + } + tmp = g_strdup (tmp); + strip_string (tmp, ' '); + strip_string (tmp, '"'); + g_strstrip (tmp); + if (!nm_utils_ipaddr_valid (AF_INET6, tmp)) + goto error; + return tmp; +error: + if (!is_ip4_address (tmp)) + nm_log_warn (LOGD_SETTINGS, "Can't handle IPv6 next_hop: %s", tmp); + g_free (tmp); + + return NULL; +} + +ip_block * +convert_ip4_config_block (const char *conn_name) +{ + gchar **ipset; + guint length; + guint i; + gchar *ip; + char *def_gateway = NULL; + const char *routes; + ip_block *start = NULL, *current = NULL, *iblock = NULL; + + g_return_val_if_fail (conn_name != NULL, NULL); + + ipset = split_addresses (ifnet_get_data (conn_name, "config")); + length = ipset ? g_strv_length (ipset) : 0; + + routes = ifnet_get_data (conn_name, "routes"); + if (routes) + def_gateway = get_ip4_gateway (strstr (routes, "default")); + + for (i = 0; i < length; i++) { + ip = ipset[i]; + ip = strip_string (ip, '"'); + iblock = create_ip4_block (ip); + if (iblock == NULL) + continue; + if (!iblock->next_hop && def_gateway != NULL) + iblock->next_hop = g_strdup (def_gateway); + if (start == NULL) + start = current = iblock; + else { + current->next = iblock; + current = iblock; + } + } + g_strfreev (ipset); + g_free (def_gateway); + return start; +} + +ip_block * +convert_ip6_config_block (const char *conn_name) +{ + gchar **ipset; + guint length; + guint i; + gchar *ip; + ip_block *start = NULL, *current = NULL, *iblock = NULL; + + g_return_val_if_fail (conn_name != NULL, NULL); + ipset = split_addresses (ifnet_get_data (conn_name, "config")); + length = ipset ? g_strv_length (ipset) : 0; + for (i = 0; i < length; i++) { + ip = ipset[i]; + ip = strip_string (ip, '"'); + iblock = create_ip_block (ip); + if (iblock == NULL) + continue; + if (start == NULL) + start = current = iblock; + else { + current->next = iblock; + current = iblock; + } + } + g_strfreev (ipset); + return start; +} + +ip_block * +convert_ip4_routes_block (const char *conn_name) +{ + gchar **ipset; + guint length; + guint i; + gchar *ip; + ip_block *start = NULL, *current = NULL, *iblock = NULL; + + g_return_val_if_fail (conn_name != NULL, NULL); + + ipset = split_routes (ifnet_get_data (conn_name, "routes")); + length = ipset ? g_strv_length (ipset) : 0; + for (i = 0; i < length; i++) { + ip = ipset[i]; + if (find_default_gateway_str (ip) || strstr (ip, "::") + || !find_gateway_str (ip)) + continue; + ip = strip_string (ip, '"'); + iblock = create_ip4_block (ip); + if (iblock == NULL) + continue; + iblock->next_hop = get_ip4_gateway (ip); + if (start == NULL) + start = current = iblock; + else { + current->next = iblock; + current = iblock; + } + } + g_strfreev (ipset); + return start; +} + +ip_block * +convert_ip6_routes_block (const char *conn_name) +{ + gchar **ipset; + guint length; + guint i; + gchar *ip, *tmp_addr; + ip_block *start = NULL, *current = NULL, *iblock = NULL; + + g_return_val_if_fail (conn_name != NULL, NULL); + ipset = split_routes (ifnet_get_data (conn_name, "routes")); + length = ipset ? g_strv_length (ipset) : 0; + for (i = 0; i < length; i++) { + ip = ipset[i]; + ip = strip_string (ip, '"'); + if (ip[0] == '\0') + continue; + if ((tmp_addr = find_default_gateway_str (ip)) != NULL) { + if (!is_ip6_address (tmp_addr)) + continue; + else { + iblock = g_slice_new0 (ip_block); + iblock->ip = g_strdup ("::"); + iblock->prefix = 128; + } + } else + iblock = create_ip_block (ip); + if (iblock == NULL) + continue; + iblock->next_hop = get_ip6_next_hop (ip); + if (iblock->next_hop == NULL) { + destroy_ip_block (iblock); + continue; + } + if (start == NULL) + start = current = iblock; + else { + current->next = iblock; + current = iblock; + } + } + g_strfreev (ipset); + return start; +} + +void +destroy_ip_block (ip_block * iblock) +{ + g_free (iblock->ip); + g_free (iblock->next_hop); + g_slice_free (ip_block, iblock); +} + +void +set_ip4_dns_servers (NMSettingIPConfig *s_ip4, const char *conn_name) +{ + const char *dns_servers; + gchar **server_list, *stripped; + guint length, i; + guint32 tmp_ip4_addr; + + dns_servers = ifnet_get_data (conn_name, "dns_servers"); + if (!dns_servers) + return; + stripped = g_strdup (dns_servers); + strip_string (stripped, '"'); + server_list = g_strsplit (stripped, " ", 0); + g_free (stripped); + + length = g_strv_length (server_list); + if (length) + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, + TRUE, NULL); + for (i = 0; i < length; i++) { + g_strstrip (server_list[i]); + if (server_list[i][0] == '\0') + continue; + if (!inet_pton (AF_INET, server_list[i], &tmp_ip4_addr)) { + if (!is_ip6_address (server_list[i])) + nm_log_warn (LOGD_SETTINGS, "ignored dns: %s\n", server_list[i]); + continue; + } + if (!nm_setting_ip_config_add_dns (s_ip4, server_list[i])) + nm_log_warn (LOGD_SETTINGS, "warning: duplicate DNS server %s", server_list[i]); + } + g_strfreev (server_list); +} + +void +set_ip6_dns_servers (NMSettingIPConfig *s_ip6, const char *conn_name) +{ + const char *dns_servers; + gchar **server_list, *stripped; + guint length, i; + struct in6_addr tmp_ip6_addr; + + dns_servers = ifnet_get_data (conn_name, "dns_servers"); + if (!dns_servers) + return; + + stripped = g_strdup (dns_servers); + strip_string (stripped, '"'); + server_list = g_strsplit (stripped, " ", 0); + g_free (stripped); + + length = g_strv_length (server_list); + if (length) + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, + TRUE, NULL); + for (i = 0; i < length; i++) { + g_strstrip (server_list[i]); + if (server_list[i][0] == '\0') + continue; + if (!inet_pton (AF_INET6, server_list[i], &tmp_ip6_addr)) { + if (is_ip6_address (server_list[i])) + nm_log_warn (LOGD_SETTINGS, "ignored dns: %s\n", server_list[i]); + continue; + } + if (!nm_setting_ip_config_add_dns (s_ip6, server_list[i])) + nm_log_warn (LOGD_SETTINGS, "warning: duplicate DNS server %s", server_list[i]); + } + g_strfreev (server_list); +} + +gboolean +is_managed (const char *conn_name) +{ + gchar *config; + + g_return_val_if_fail (conn_name != NULL, FALSE); + config = (gchar *) ifnet_get_data (conn_name, "managed"); + if (!config) + return TRUE; + if (strcmp (config, "false") == 0) + return FALSE; + return TRUE; +} + +static char * +_has_prefix_impl (char *str, const char *prefix, gsize prefix_len) +{ + if (!g_str_has_prefix (str, prefix)) + return NULL; + str += prefix_len; + if (!g_ascii_isspace (str[0])) + return NULL; + do { + str++; + } while (g_ascii_isspace (str[0])); + return str; +} +#define _has_prefix(STR, PREFIX) _has_prefix_impl (STR, PREFIX, NM_STRLEN (PREFIX)) + +void +get_dhcp_hostname_and_client_id (char **hostname, char **client_id) +{ + const char *dhcp_client; + const gchar *dhcpcd_conf = SYSCONFDIR "/dhcpcd.conf"; + const gchar *dhclient_conf = SYSCONFDIR "/dhcp/dhclient.conf"; + gchar *line = NULL, *tmp = NULL, *contents = NULL, *tmp1; + gchar **all_lines; + guint line_num, i; + gboolean use_dhclient = FALSE; + + *hostname = NULL; + *client_id = NULL; + dhcp_client = nm_dhcp_manager_get_config (nm_dhcp_manager_get ()); + if (dhcp_client) { + if (!strcmp (dhcp_client, "dhclient")) { + g_file_get_contents (dhclient_conf, &contents, NULL, + NULL); + use_dhclient = TRUE; + } else if (!strcmp (dhcp_client, "dhcpcd")) { + g_file_get_contents (dhcpcd_conf, &contents, NULL, + NULL); + } + } else { + if (g_file_test (dhclient_conf, G_FILE_TEST_IS_REGULAR)) { + g_file_get_contents (dhclient_conf, &contents, NULL, + NULL); + use_dhclient = TRUE; + } else if (g_file_test (dhcpcd_conf, G_FILE_TEST_IS_REGULAR)) { + g_file_get_contents (dhcpcd_conf, &contents, NULL, + NULL); + } + } + if (!contents) + return; + all_lines = g_strsplit (contents, "\n", 0); + line_num = g_strv_length (all_lines); + for (i = 0; i < line_num; i++) { + line = all_lines[i]; + g_strstrip (line); + if (line[0] == '#' || line[0] == '\0') + continue; + if (!use_dhclient) { + // dhcpcd.conf + if ((tmp = _has_prefix (line, "hostname"))) { + if (tmp[0] != '\0') { + g_free (*hostname); + *hostname = g_strdup (tmp); + } else + nm_log_info (LOGD_SETTINGS, "dhcpcd hostname not defined, ignoring"); + } else if ((tmp = _has_prefix (line, "clientid"))) { + if (tmp[0] != '\0') { + g_free (*client_id); + *client_id = g_strdup (tmp); + } else + nm_log_info (LOGD_SETTINGS, "dhcpcd clientid not defined, ignoring"); + } + } else { + // dhclient.conf + if ((tmp1 = _has_prefix (line, "send"))) { + if ((tmp = _has_prefix (tmp1, "host-name"))) { + strip_string (tmp, ';'); + strip_string (tmp, '"'); + if (tmp[0] != '\0') { + g_free (*hostname); + *hostname = g_strdup (tmp); + } else + nm_log_info (LOGD_SETTINGS, "dhclient hostname not defined, ignoring"); + } else if ((tmp = _has_prefix (tmp1, "dhcp-client-identifier"))) { + strip_string (tmp, ';'); + if (tmp[0] != '\0') { + g_free (*client_id); + *client_id = g_strdup (tmp); + } else + nm_log_info (LOGD_SETTINGS, "dhclient clientid not defined, ignoring"); + } + } + } + } + g_strfreev (all_lines); + g_free (contents); +} + +gchar *backup_file (const gchar* target) +{ + GFile *source, *backup; + gchar* backup_path; + GError *error = NULL; + + source = g_file_new_for_path (target); + + if (!g_file_query_exists (source, NULL)) { + g_object_unref (source); + return NULL; + } + + backup_path = g_strdup_printf ("%s.bak", target); + backup = g_file_new_for_path (backup_path); + + if (!g_file_copy (source, backup, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error)) { + nm_log_warn (LOGD_SETTINGS, "Backup failed: %s", error->message); + g_free (backup_path); + backup_path = NULL; + g_error_free (error); + } + + g_object_unref (source); + g_object_unref (backup); + + return backup_path; +} diff --git a/src/settings/plugins/ifnet/nms-ifnet-net-utils.h b/src/settings/plugins/ifnet/nms-ifnet-net-utils.h new file mode 100644 index 00000000..79d44642 --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-net-utils.h @@ -0,0 +1,71 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#ifndef _IFNET_UTILS_H +#define _IFNET_UTILS_H + +#define IFNET_PLUGIN_NAME "SettingsPlugin-Ifnet" + +#include + +#include +#include + +#include "nms-ifnet-net-parser.h" + +#define has_default_ip4_route(conn_name) has_default_route((conn_name), &is_ip4_address) +#define has_default_ip6_route(conn_name) has_default_route((conn_name), &is_ip6_address) + +typedef struct _ip_block { + char *ip; + guint32 prefix; + char *next_hop; + struct _ip_block *next; +} ip_block; + +gboolean is_static_ip4 (const char *conn_name); +gboolean is_static_ip6 (const char *conn_name); +gboolean is_ip4_address (const char *in_address); +gboolean is_ip6_address (const char *in_address); +gboolean has_ip6_address (const char *conn_name); +gboolean has_default_route (const char *conn_name, gboolean (*check_fn) (const char *)); +gboolean reload_parsers (void); + +ip_block *convert_ip4_config_block (const char *conn_name); +ip_block *convert_ip6_config_block (const char *conn_name); +ip_block *convert_ip4_routes_block (const char *conn_name); +ip_block *convert_ip6_routes_block (const char *conn_name); +void destroy_ip_block (ip_block * iblock); + +void set_ip4_dns_servers (NMSettingIPConfig * s_ip4, const char *conn_name); +void set_ip6_dns_servers (NMSettingIPConfig * s_ip6, const char *conn_name); + +gchar *strip_string (gchar *str, gchar t); +gboolean is_managed (const char *conn_name); + +gboolean is_hex (const char *value); +gboolean is_ascii (const char *value); +gboolean is_true (const char *str); + +void get_dhcp_hostname_and_client_id (char **hostname, char **client_id); + +gchar *backup_file (const gchar* target); +#endif diff --git a/src/settings/plugins/ifnet/nms-ifnet-plugin.c b/src/settings/plugins/ifnet/nms-ifnet-plugin.c new file mode 100644 index 00000000..5a6a8ce8 --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-plugin.c @@ -0,0 +1,514 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service (ifnet) + * + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifnet-plugin.h" + +#include +#include + +#include "nm-utils.h" +#include "nm-setting-connection.h" +#include "nm-dbus-interface.h" +#include "settings/nm-settings-plugin.h" +#include "nm-config.h" +#include "NetworkManagerUtils.h" + +#include "nms-ifnet-connection.h" +#include "nms-ifnet-net-utils.h" +#include "nms-ifnet-net-parser.h" +#include "nms-ifnet-wpa-parser.h" +#include "nms-ifnet-connection-parser.h" + +#define IFNET_PLUGIN_NAME_PRINT "ifnet" +#define IFNET_PLUGIN_INFO "(C) 1999-2010 Gentoo Foundation, Inc. To report bugs please use bugs.gentoo.org with [networkmanager] or [qiaomuf] prefix." +#define IFNET_MANAGE_WELL_KNOWN_DEFAULT TRUE + +/*****************************************************************************/ + +typedef void (*FileChangedFn) (gpointer user_data); + +typedef struct { + FileChangedFn callback; + gpointer user_data; +} FileMonitorInfo; + +/*****************************************************************************/ + +typedef struct { + GHashTable *connections; /* uuid::connection */ + gboolean unmanaged_well_known; + + GFileMonitor *net_monitor; + GFileMonitor *wpa_monitor; +} SettingsPluginIfnetPrivate; + +struct _SettingsPluginIfnet { + GObject parent; + SettingsPluginIfnetPrivate _priv; +}; + +struct _SettingsPluginIfnetClass { + GObjectClass parent; +}; + +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); + +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfnet, settings_plugin_ifnet, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) + +#define SETTINGS_PLUGIN_IFNET_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginIfnet, SETTINGS_IS_PLUGIN_IFNET) + +/*****************************************************************************/ + +static SettingsPluginIfnet *settings_plugin_ifnet_get (void); + +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfnet, settings_plugin_ifnet_get, SETTINGS_TYPE_PLUGIN_IFNET); + +/*****************************************************************************/ + +static void reload_connections (NMSettingsPlugin *config); + +/*****************************************************************************/ + +static gboolean +is_managed_plugin (void) +{ + return nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG, + NM_CONFIG_KEYFILE_GROUP_IFNET, NM_CONFIG_KEYFILE_KEY_IFNET_MANAGED, + IFNET_MANAGE_WELL_KNOWN_DEFAULT); +} + +static void +file_changed (GFileMonitor * monitor, + GFile * file, + GFile * other_file, + GFileMonitorEvent event_type, gpointer user_data) +{ + FileMonitorInfo *info; + + switch (event_type) { + case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: + info = (FileMonitorInfo *) user_data; + info->callback (info->user_data); + break; + default: + break; + } +} + +static GFileMonitor * +monitor_file_changes (const char *filename, + FileChangedFn callback, gpointer user_data) +{ + GFile *file; + GFileMonitor *monitor; + FileMonitorInfo *info; + GError **error = NULL; + + if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) + return NULL; + file = g_file_new_for_path (filename); + monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, error); + g_object_unref (file); + + if (monitor) { + info = g_new0 (FileMonitorInfo, 1); + info->callback = callback; + info->user_data = user_data; + g_object_weak_ref (G_OBJECT (monitor), (GWeakNotify) g_free, + info); + g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), + info); + } else { + nm_log_warn (LOGD_SETTINGS, "Monitoring %s failed, error: %s", filename, + error == NULL ? "nothing" : (*error)->message); + } + + return monitor; +} + +static void +setup_monitors (NMIfnetConnection * connection, gpointer user_data) +{ + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); + + if (nm_config_get_monitor_connection_files (nm_config_get ())) { + priv->net_monitor = + monitor_file_changes (CONF_NET_FILE, (FileChangedFn) reload_connections, + user_data); + priv->wpa_monitor = + monitor_file_changes (WPA_SUPPLICANT_CONF, (FileChangedFn) reload_connections, + user_data); + } +} + +static void +cancel_monitors (NMIfnetConnection * connection, gpointer user_data) +{ + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); + + if (priv->net_monitor) { + g_file_monitor_cancel (priv->net_monitor); + g_object_unref (priv->net_monitor); + } + if (priv->wpa_monitor) { + g_file_monitor_cancel (priv->wpa_monitor); + g_object_unref (priv->wpa_monitor); + } +} + +static void +connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) +{ + g_hash_table_remove (SETTINGS_PLUGIN_IFNET_GET_PRIVATE ((SettingsPluginIfnet *) user_data)->connections, + nm_connection_get_uuid (NM_CONNECTION (obj))); +} + +static void +track_new_connection (SettingsPluginIfnet *self, NMIfnetConnection *connection) +{ + g_hash_table_insert (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self)->connections, + g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), + g_object_ref (connection)); + g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, + G_CALLBACK (connection_removed_cb), + self); +} + +static void +reload_connections (NMSettingsPlugin *config) +{ + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); + GList *conn_names = NULL, *n_iter = NULL; + gboolean auto_refresh; + GError *error = NULL; + + /* save names for removing unused connections */ + GHashTable *new_connections = NULL; + GHashTableIter iter; + const char *uuid; + NMSettingsConnection *candidate; + + if (priv->unmanaged_well_known) + return; + + if (!reload_parsers ()) + return; + + nm_log_info (LOGD_SETTINGS, "Loading connections"); + + auto_refresh = nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG, + NM_CONFIG_KEYFILE_GROUP_IFNET, NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH, + FALSE); + + new_connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); + + /* Reread on-disk data and refresh in-memory connections from it */ + conn_names = ifnet_get_connection_names (); + for (n_iter = conn_names; n_iter; n_iter = g_list_next (n_iter)) { + NMIfnetConnection *new; + NMIfnetConnection *old; + const char *conn_name = n_iter->data; + + /* read the new connection */ + new = nm_ifnet_connection_new (NULL, conn_name); + if (!new) + continue; + + g_signal_connect (G_OBJECT (new), "ifnet_setup_monitors", + G_CALLBACK (setup_monitors), config); + g_signal_connect (G_OBJECT (new), "ifnet_cancel_monitors", + G_CALLBACK (cancel_monitors), config); + + old = g_hash_table_lookup (priv->connections, + nm_connection_get_uuid (NM_CONNECTION (new))); + if (old && new) { + if (auto_refresh) { + /* If connection has changed, remove the old one and add the + * new one to force a disconnect/reconnect with new settings + */ + if (!nm_connection_compare (NM_CONNECTION (old), + NM_CONNECTION (new), + NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | + NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { + nm_log_info (LOGD_SETTINGS, "Auto refreshing %s", conn_name); + + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old), FALSE); + track_new_connection (self, new); + if (is_managed_plugin () && is_managed (conn_name)) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); + } + } else { + /* Update existing connection with new settings */ + if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (old), + NM_CONNECTION (new), + FALSE, /* don't set Unsaved */ + "ifnet-update", + &error)) { + /* Shouldn't ever get here as 'new' was verified by the reader already + * and the UUID did not change. */ + g_assert_not_reached (); + } + g_assert_no_error (error); + nm_log_info (LOGD_SETTINGS, "Connection %s updated", + nm_connection_get_id (NM_CONNECTION (new))); + } + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); + } else if (new) { + track_new_connection (self, new); + if (is_managed_plugin () && is_managed (conn_name)) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); + } + + /* Track all valid connections so we can remove deleted ones later */ + g_hash_table_insert (new_connections, + (gpointer) nm_connection_get_uuid (NM_CONNECTION (new)), + new); + } + + /* remove deleted/unused connections */ + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, (gpointer) &uuid, (gpointer) &candidate)) { + /* only saved connections (which have a conn_name) get removed; unsaved + * ones obviously don't exist in /etc/conf.d/net yet and shouldn't get + * blown away by net file changes. + */ + if ( nm_ifnet_connection_get_conn_name (NM_IFNET_CONNECTION (candidate)) + && !g_hash_table_lookup (new_connections, uuid)) { + nm_settings_connection_signal_remove (candidate, FALSE); + g_hash_table_iter_remove (&iter); + } + } + g_hash_table_destroy (new_connections); + g_list_free (conn_names); +} + +static NMSettingsConnection * +add_connection (NMSettingsPlugin *config, + NMConnection *source, + gboolean save_to_disk, + GError **error) +{ + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE ((SettingsPluginIfnet *) config); + NMIfnetConnection *new = NULL; + + /* Ensure we reject attempts to add the connection long before we're + * asked to write it to disk. + */ + if (!ifnet_can_write_connection (source, error)) + return NULL; + + if (save_to_disk) { + if (!ifnet_add_new_connection (source, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL, NULL, error)) + return NULL; + reload_connections (config); + new = g_hash_table_lookup (priv->connections, nm_connection_get_uuid (source)); + } else { + new = nm_ifnet_connection_new (source, NULL); + if (new) { + track_new_connection (SETTINGS_PLUGIN_IFNET (config), new); + /* track_new_connection refs 'new' */ + g_object_unref (new); + } + } + + return (NMSettingsConnection *) new; +} + +static void +check_unmanaged (gpointer key, gpointer data, gpointer user_data) +{ + NMIfnetConnection *connection = NM_IFNET_CONNECTION (data); + GSList **list = (GSList **) user_data; + const char *mac, *conn_name; + char *unmanaged_spec; + GSList *iter; + + conn_name = nm_ifnet_connection_get_conn_name (connection); + + if (!conn_name || is_managed (conn_name)) + return; + + nm_log_info (LOGD_SETTINGS, "Checking unmanaged: %s", conn_name); + mac = ifnet_get_data (conn_name, "mac"); + if (mac) + unmanaged_spec = g_strdup_printf ("mac:%s", mac); + else + unmanaged_spec = g_strdup_printf ("interface-name:%s", conn_name); + + /* Just return if the unmanaged spec is already in the list */ + for (iter = *list; iter; iter = g_slist_next (iter)) { + if (g_str_equal (iter->data, unmanaged_spec)) { + g_free (unmanaged_spec); + return; + } + } + + nm_log_info (LOGD_SETTINGS, "Add unmanaged: %s", unmanaged_spec); + *list = g_slist_prepend (*list, unmanaged_spec); +} + +static GSList * +get_unmanaged_specs (NMSettingsPlugin * config) +{ + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE ((SettingsPluginIfnet *) config); + GSList *list = NULL; + + nm_log_info (LOGD_SETTINGS, "getting unmanaged specs..."); + g_hash_table_foreach (priv->connections, check_unmanaged, &list); + return list; +} + +static GSList * +get_connections (NMSettingsPlugin *config) +{ + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE ((SettingsPluginIfnet *) config); + GSList *connections = NULL; + GHashTableIter iter; + NMIfnetConnection *connection; + + nm_log_info (LOGD_SETTINGS, "(%p) ... get_connections.", config); + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) { + const char *conn_name = nm_ifnet_connection_get_conn_name (connection); + + if (!conn_name || (!priv->unmanaged_well_known && is_managed (conn_name))) + connections = g_slist_prepend (connections, connection); + } + nm_log_info (LOGD_SETTINGS, "(%p) connections count: %d", + config, g_slist_length (connections)); + return connections; +} + +/*****************************************************************************/ + +static void +get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ + switch (prop_id) { + case NM_SETTINGS_PLUGIN_PROP_NAME: + g_value_set_string (value, IFNET_PLUGIN_NAME_PRINT); + break; + case NM_SETTINGS_PLUGIN_PROP_INFO: + g_value_set_string (value, IFNET_PLUGIN_INFO); + break; + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, + NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +init (NMSettingsPlugin *config) +{ + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); + + nm_log_info (LOGD_SETTINGS, "Initializing!"); + + priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); + priv->unmanaged_well_known = !is_managed_plugin (); + nm_log_info (LOGD_SETTINGS, "management mode: %s", + priv->unmanaged_well_known ? "unmanaged" : "managed"); + + setup_monitors (NULL, config); + reload_connections (config); + + nm_log_info (LOGD_SETTINGS, "Initialzation complete!"); +} + +/*****************************************************************************/ + +static void +settings_plugin_ifnet_init (SettingsPluginIfnet * plugin) +{ +} + +static void +dispose (GObject * object) +{ + SettingsPluginIfnet *plugin = SETTINGS_PLUGIN_IFNET (object); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE ((SettingsPluginIfnet *) plugin); + + cancel_monitors (NULL, object); + if (priv->connections) { + g_hash_table_destroy (priv->connections); + priv->connections = NULL; + } + + ifnet_destroy (); + wpa_parser_destroy (); + G_OBJECT_CLASS (settings_plugin_ifnet_parent_class)->dispose (object); +} + +static void +settings_plugin_ifnet_class_init (SettingsPluginIfnetClass * req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + + object_class->dispose = dispose; + object_class->get_property = get_property; + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); +} + +static void +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) +{ + plugin_iface->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; + plugin_iface->add_connection = add_connection; + plugin_iface->reload_connections = reload_connections; +} + +/*****************************************************************************/ + +G_MODULE_EXPORT GObject * +nm_settings_plugin_factory (void) +{ + return g_object_ref (settings_plugin_ifnet_get ()); +} diff --git a/src/settings/plugins/ifnet/nms-ifnet-plugin.h b/src/settings/plugins/ifnet/nms-ifnet-plugin.h new file mode 100644 index 00000000..f006e7e4 --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-plugin.h @@ -0,0 +1,38 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service (ifnet) + * + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#define SETTINGS_TYPE_PLUGIN_IFNET (settings_plugin_ifnet_get_type ()) +#define SETTINGS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnet)) +#define SETTINGS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) +#define SETTINGS_IS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFNET)) +#define SETTINGS_IS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFNET)) +#define SETTINGS_PLUGIN_IFNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) + +typedef struct _SettingsPluginIfnet SettingsPluginIfnet; +typedef struct _SettingsPluginIfnetClass SettingsPluginIfnetClass; + +GType settings_plugin_ifnet_get_type (void); + +#endif diff --git a/src/settings/plugins/ifnet/nms-ifnet-wpa-parser.c b/src/settings/plugins/ifnet/nms-ifnet-wpa-parser.c new file mode 100644 index 00000000..61e4da7c --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-wpa-parser.c @@ -0,0 +1,583 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifnet-wpa-parser.h" + +#include +#include + +#include "settings/nm-settings-plugin.h" + +#include "nms-ifnet-net-parser.h" +#include "nms-ifnet-net-utils.h" + +/* Security information */ +static GHashTable *wsec_table = NULL; + +/* Global information used for writing */ +static GHashTable *wsec_global_table = NULL; + +static gboolean wpa_parser_data_changed = FALSE; + +static long +wpa_get_long (GHashTable *table, const char *key) +{ + return atol (g_hash_table_lookup (table, key)); +} + +static void +destroy_security (GHashTable * network) +{ + gpointer key, value; + GHashTableIter iter; + + g_return_if_fail (network); + g_hash_table_iter_init (&iter, network); + while (g_hash_table_iter_next (&iter, &key, &value)) { + g_free (key); + g_free (value); + } + + g_hash_table_destroy (network); +} + +static GHashTable * +add_security (GHashTable *security) +{ + GHashTable *oldsecurity; + const char *ssid, *value; + char *ssid_key; + gboolean is_hex_ssid; + + /* Every security information should have a ssid */ + ssid = g_hash_table_lookup (security, "ssid"); + if (!ssid) { + destroy_security (security); + return NULL; + } + + /* Hex format begins with " */ + is_hex_ssid = (ssid[0] != '"'); + if ((value = g_hash_table_lookup (security, "disabled")) != NULL) { + if (strcmp (value, "1") == 0) { + destroy_security (security); + return NULL; + } + } + + /* Default priority is 1 */ + if (g_hash_table_lookup (security, "priority") == NULL) + g_hash_table_insert (security, g_strdup ("priority"), + g_strdup ("1")); + + oldsecurity = g_hash_table_lookup (wsec_table, ssid); + /* Security with lower priority will be ignored */ + if (oldsecurity != NULL) { + if (wpa_get_long (oldsecurity, "priority") >= + wpa_get_long (security, "priority")) { + destroy_security (security); + return NULL; + } else { + g_hash_table_remove (wsec_table, ssid); + destroy_security (oldsecurity); + } + } + + /* format ssid */ + ssid_key = + is_hex_ssid ? g_strdup_printf ("0x%s", + ssid) : + strip_string (g_strdup (ssid), '"'); + g_hash_table_insert (wsec_table, ssid_key, security); + return security; +} + +static void +add_key_value (GHashTable * network, gchar * line) +{ + gpointer orig_key, orig_value; + gchar **key_value; + + if (g_str_has_prefix (line, "network={")) + line += 9; + strip_string (line, '{'); + strip_string (line, '}'); + if (line[0] == '\0') + return; + key_value = g_strsplit (line, "=", 2); + if (g_strv_length (key_value) != 2) { + g_strfreev (key_value); + return; + } + g_strstrip (key_value[0]); + g_strstrip (key_value[1]); + + /* Reserve quotes for psk, wep_key, ssid + * Quotes will determine whether they are hex format */ + if (strcmp (key_value[0], "psk") != 0 + && !g_str_has_prefix (key_value[0], "wep_key") + && strcmp (key_value[0], "ssid") != 0) + strip_string (key_value[1], '"'); + + /* This sucks */ + if (g_hash_table_lookup_extended (network, key_value[0], &orig_key, &orig_value)) { + g_hash_table_remove (network, orig_key); + g_free (orig_key); + g_free (orig_value); + } + + g_hash_table_insert (network, g_strdup (key_value[0]), + g_strdup (key_value[1])); + g_strfreev (key_value); +} + +static void +add_one_wep_key (GHashTable * table, int key_num, gchar * one_wep_key) +{ + if (one_wep_key[0] == 's') { + //asc key + g_hash_table_insert (table, + g_strdup_printf ("wep_key%d", key_num - 1), + g_strdup_printf ("\"%s\"", + one_wep_key + 2)); + } else { + gchar buf[30]; + int i = 0, j = 0; + + //hex key + while (one_wep_key[i] != '\0') { + if (one_wep_key[i] != '-') + buf[j++] = one_wep_key[i]; + i++; + } + buf[j] = '\0'; + g_hash_table_insert (table, + g_strdup_printf ("wep_key%d", key_num - 1), + g_strdup (buf)); + + } +} + +/* Reading wep security information from /etc/conf.d/net. + * This should not be used in future, use wpa_supplicant instead. */ +static void +add_keys_from_net (void) +{ + GList *names = ifnet_get_connection_names (); + GList *iter = names; + gchar *wep_keys = "(\\[([1-4])\\]\\s+(s:\\w{5}|s:\\w{13}|" + "([\\da-fA-F]{4}\\-){2}[\\da-fA-F]{2}|" + "([\\da-fA-F]{4}\\-){6}[\\da-fA-F]{2})\\s+)"; + gchar *key_method = + "\\s+key\\s+\\[([1-4])\\]\\s+enc\\s+(open|restricted)"; + GRegex *regex_keys = g_regex_new (wep_keys, 0, 0, NULL); + GRegex *regex_method = g_regex_new (key_method, 0, 0, NULL); + GMatchInfo *keys_info; + GMatchInfo *method_info; + + while (iter) { + gchar *conn_name = iter->data; + GHashTable *table; + const char *key_str; + + if ((key_str = ifnet_get_data (conn_name, "key")) == NULL) { + iter = g_list_next (iter); + continue; + } + + wpa_add_security (conn_name); + table = _get_hash_table (conn_name); + /* Give lowest priority */ + wpa_set_data (conn_name, "priority", "0"); + g_regex_match (regex_keys, key_str, 0, &keys_info); + /* add wep keys */ + while (g_match_info_matches (keys_info)) { + gchar *key_num = g_match_info_fetch (keys_info, 2); + gchar *one_wep_key = g_match_info_fetch (keys_info, 3); + + add_one_wep_key (table, atoi (key_num), one_wep_key); + g_free (key_num); + g_free (one_wep_key); + g_match_info_next (keys_info, NULL); + } + g_match_info_free (keys_info); + + g_regex_match (regex_method, key_str, 0, &method_info); + /* set default key index and auth alg */ + if (g_match_info_matches (method_info)) { + gchar *default_idx = + g_match_info_fetch (method_info, 1); + gchar *method = g_match_info_fetch (method_info, 2); + + default_idx[0]--; + g_hash_table_insert (table, g_strdup ("wep_tx_keyidx"), + default_idx); + g_hash_table_insert (table, g_strdup ("auth_alg"), + g_ascii_strup (method, -1)); + } + g_match_info_free (method_info); + add_security (table); + iter = g_list_next (iter); + } + g_list_free (names); + g_regex_unref (regex_keys); + g_regex_unref (regex_method); +} + +static void +add_global_data (gchar * line) +{ + gchar **key_value; + + g_strstrip (line); + key_value = g_strsplit (line, "=", 2); + if (g_strv_length (key_value) != 2) { + nm_log_warn (LOGD_SETTINGS, "Can't handle this line: %s\n", line); + g_strfreev (key_value); + return; + } + g_hash_table_insert (wsec_global_table, + g_strdup (g_strstrip (key_value[0])), + g_strdup (g_strstrip (key_value[1]))); + g_strfreev (key_value); +} + +void +wpa_parser_init (const char *wpa_supplicant_conf) +{ + GIOChannel *channel = NULL; + gchar *line; + gboolean complete = FALSE; + + wpa_parser_data_changed = FALSE; + wsec_table = g_hash_table_new (g_str_hash, g_str_equal); + wsec_global_table = g_hash_table_new (g_str_hash, g_str_equal); + + if (g_file_test (wpa_supplicant_conf, G_FILE_TEST_IS_REGULAR)) + channel = + g_io_channel_new_file (wpa_supplicant_conf, "r", NULL); + if (channel == NULL) { + nm_log_warn (LOGD_SETTINGS, "Can't open %s for wireless security", + wpa_supplicant_conf); + return; + } + + while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL) + != G_IO_STATUS_EOF) { + g_strstrip (line); + if (line[0] != '#' && line[0] != '\0') { + if (strstr (line, "network={") == NULL) { + add_global_data (line); + g_free (line); + continue; + } else { + GHashTable *network = + g_hash_table_new (g_str_hash, g_str_equal); + + do { + gchar *quote_start, *quote_end = NULL, *comment; + + if (line[0] == '#' || line[0] == '\0') { + g_free (line); + continue; + } + /* ignore inline comments unless inside + a double-quoted string */ + if ((quote_start = strchr (line, '"')) != NULL) + quote_end = strrchr (quote_start + 1, '"'); + if ((comment = strchr ((quote_end != NULL) ? + quote_end : line, '#')) != NULL) + *comment = '\0'; + if (strstr (line, "}") != NULL) + complete = TRUE; + add_key_value (network, line); + g_free (line); + } while (complete == FALSE + && + g_io_channel_read_line + (channel, &line, NULL, + NULL, NULL) != G_IO_STATUS_EOF); + add_security (network); + //EOF in inner loop + if (complete == FALSE) { + g_free (line); + break; + } + complete = FALSE; + } + } else + g_free (line); + } + + g_io_channel_shutdown (channel, FALSE, NULL); + g_io_channel_unref (channel); + + add_keys_from_net (); +} + +const char * +wpa_get_value (const char *ssid, const char *key) +{ + GHashTable *target = g_hash_table_lookup (wsec_table, ssid); + + if (target) + return g_hash_table_lookup (target, key); + return NULL; +} + +gboolean +exist_ssid (const char *ssid) +{ + return g_hash_table_lookup (wsec_table, ssid) != NULL; +} + +GHashTable * +_get_hash_table (const char *ssid) +{ + return g_hash_table_lookup (wsec_table, ssid); +} + +static gchar *quoted_keys[] = + { "identity", "cert", "private", "phase", "password", NULL }; + +/* tell whether the key needs quotes when writing is performed */ +static gboolean +need_quote (gchar * key) +{ + int i = 0; + + while (quoted_keys[i] != NULL) { + if (strstr (key, quoted_keys[i])) + return TRUE; + i++; + } + return FALSE; +} + +gboolean +wpa_flush_to_file (const char *config_file) +{ + GIOChannel *channel; + GError *error = NULL; + gpointer key, value, ssid, security; + GHashTableIter iter, iter_security; + gchar *out_line; + gsize bytes_written; + gboolean result = FALSE; + + if (!wpa_parser_data_changed) + return TRUE; + if (!wsec_table || !wsec_global_table) + return FALSE; + + backup_file (config_file); + + channel = g_io_channel_new_file (config_file, "w", NULL); + if (!channel) { + nm_log_warn (LOGD_SETTINGS, "Can't open file %s for writing", config_file); + return FALSE; + } + g_hash_table_iter_init (&iter, wsec_global_table); + nm_log_info (LOGD_SETTINGS, "Writing to %s", config_file); + g_io_channel_write_chars (channel, + "#Generated by NetworkManager\n" + "###### Global Configuration ######\n", + -1, &bytes_written, &error); + if (error) + goto done; + + /* Writing global information */ + while (g_hash_table_iter_next (&iter, &key, &value)) { + out_line = + g_strdup_printf ("%s=%s\n", (gchar *) key, (gchar *) value); + g_io_channel_write_chars (channel, out_line, -1, &bytes_written, + &error); + if (bytes_written == 0 || error) + break; + g_free (out_line); + } + if (error) + goto done; + g_io_channel_write_chars (channel, + "\n###### Security Configuration ######\n", + -1, &bytes_written, &error); + if (error) + goto done; + + g_hash_table_iter_init (&iter, wsec_table); + /* Writing security */ + while (g_hash_table_iter_next (&iter, &ssid, &security)) { + g_hash_table_iter_init (&iter_security, + (GHashTable *) security); + g_io_channel_write_chars (channel, "network={\n", -1, + &bytes_written, &error); + if (error) + goto done; + while (g_hash_table_iter_next (&iter_security, &key, &value)) { + out_line = + g_strdup_printf (need_quote ((gchar *) key) ? + "\t%s=\"%s\"\n" : "\t%s=%s\n", + (gchar *) key, (gchar *) value); + g_io_channel_write_chars (channel, out_line, -1, + &bytes_written, &error); + if (bytes_written == 0 || error) + goto done; + g_free (out_line); + } + g_io_channel_write_chars (channel, "}\n\n", -1, &bytes_written, &error); + + } + g_io_channel_flush (channel, &error); + if (error) + goto done; + + wpa_parser_data_changed = FALSE; + result = TRUE; +done: + if (error) { + nm_log_warn (LOGD_SETTINGS, "Error writing WPA configuration: %s", error->message); + g_error_free (error); + } + g_io_channel_shutdown (channel, FALSE, NULL); + g_io_channel_unref (channel); + return result; +} + +/* If value is NULL, this method will delete old key value pair */ +void +wpa_set_data (const char *ssid, const char *key, const char *value) +{ + gpointer old_key = NULL, old_value = NULL; + GHashTable *security = g_hash_table_lookup (wsec_table, ssid); + gchar * stripped = NULL; + + g_return_if_fail (security != NULL); + + if (value){ + stripped = g_strdup(value); + if (strcmp (key, "ssid") != 0 && strcmp (key, "psk") != 0 + && !g_str_has_prefix (key, "wep_key")) + strip_string (stripped, '"'); + } + + /* Remove old key value pairs */ + if (g_hash_table_lookup_extended + (security, key, &old_key, &old_value)) { + if (stripped && !strcmp(old_value, stripped)){ + g_free (stripped); + return; + } + g_hash_table_remove (security, old_key); + g_free (old_key); + g_free (old_value); + } else if (!value) + return; + + /* Add new key value */ + if (stripped) + g_hash_table_insert (security, g_strdup (key), stripped); + wpa_parser_data_changed = TRUE; +} + +gboolean +wpa_has_security (const char *ssid) +{ + return g_hash_table_lookup (wsec_table, ssid) != NULL; +} + +gboolean +wpa_add_security (const char *ssid) +{ + if (wpa_has_security (ssid)) + return TRUE; + else { + GHashTable *security = + g_hash_table_new (g_str_hash, g_str_equal); + gchar *ssid_i; + + nm_log_info (LOGD_SETTINGS, "Adding security for %s", ssid); + if (g_str_has_prefix (ssid, "0x")) { + /* hex ssid */ + ssid_i = g_strdup (ssid + 2); + } else { + /* ascii ssid requires quotes */ + ssid_i = g_strdup_printf ("\"%s\"", ssid); + } + g_hash_table_insert (security, strdup ("ssid"), ssid_i); + g_hash_table_insert (security, strdup ("priority"), + strdup ("1")); + g_hash_table_insert (wsec_table, g_strdup (ssid), security); + wpa_parser_data_changed = TRUE; + return TRUE; + } +} + +gboolean +wpa_delete_security (const char *ssid) +{ + gpointer old_key, old_value; + + g_return_val_if_fail (wsec_table != NULL && ssid != NULL, FALSE); + nm_log_info (LOGD_SETTINGS, "Deleting security for %s", ssid); + if (!g_hash_table_lookup_extended + (wsec_table, ssid, &old_key, &old_value)) + return FALSE; + g_hash_table_remove (wsec_table, old_key); + g_free (old_key); + destroy_security ((GHashTable *) old_value); + wpa_parser_data_changed = TRUE; + return TRUE; + +} + +void +wpa_parser_destroy (void) +{ + GHashTableIter iter; + gpointer key; + gpointer value; + + /* Destroy security */ + if (wsec_table) { + g_hash_table_iter_init (&iter, wsec_table); + while (g_hash_table_iter_next (&iter, &key, &value)) { + destroy_security ((GHashTable *) value); + g_free (key); + } + + g_hash_table_destroy (wsec_table); + wsec_table = NULL; + } + + /* Destroy global data */ + if (wsec_global_table) { + g_hash_table_iter_init (&iter, wsec_global_table); + while (g_hash_table_iter_next (&iter, &key, &value)) { + g_free (key); + g_free (value); + } + + g_hash_table_destroy (wsec_global_table); + wsec_global_table = NULL; + } +} diff --git a/src/settings/plugins/ifnet/nms-ifnet-wpa-parser.h b/src/settings/plugins/ifnet/nms-ifnet-wpa-parser.h new file mode 100644 index 00000000..d096f468 --- /dev/null +++ b/src/settings/plugins/ifnet/nms-ifnet-wpa-parser.h @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Mu Qiao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 1999-2010 Gentoo Foundation, Inc. + */ + +#ifndef _WPA_PARSER_H +#define _WPA_PARSER_H + +#define WPA_SUPPLICANT_CONF SYSCONFDIR "/wpa_supplicant/wpa_supplicant.conf" + +void wpa_parser_init (const char *wpa_supplicant_conf); +void wpa_parser_destroy (void); + +/* reader functions */ +const char *wpa_get_value (const char *ssid, const char *key); +gboolean exist_ssid (const char *ssid); +GHashTable *_get_hash_table (const char *ssid); +gboolean wpa_has_security (const char *ssid); + +/* writer functions */ +gboolean wpa_flush_to_file (const char *config_file); +void wpa_set_data (const char *ssid, const char *key, const char *value); +gboolean wpa_add_security (const char *ssid); +gboolean wpa_delete_security (const char *ssid); +#endif diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c deleted file mode 100644 index a0676cf8..00000000 --- a/src/settings/plugins/ifnet/plugin.c +++ /dev/null @@ -1,502 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service (ifnet) - * - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#include "nm-default.h" - -#include - -#include - -#include "nm-utils.h" -#include "nm-setting-connection.h" - -#include "nm-default.h" -#include "nm-dbus-interface.h" -#include "nm-settings-plugin.h" -#include "nm-ifnet-connection.h" -#include "nm-config.h" -#include "NetworkManagerUtils.h" - -#include "plugin.h" -#include "net_utils.h" -#include "net_parser.h" -#include "wpa_parser.h" -#include "connection_parser.h" - -#define IFNET_PLUGIN_NAME_PRINT "ifnet" -#define IFNET_PLUGIN_INFO "(C) 1999-2010 Gentoo Foundation, Inc. To report bugs please use bugs.gentoo.org with [networkmanager] or [qiaomuf] prefix." -#define IFNET_MANAGE_WELL_KNOWN_DEFAULT TRUE - -typedef struct { - GHashTable *connections; /* uuid::connection */ - gboolean unmanaged_well_known; - - GFileMonitor *net_monitor; - GFileMonitor *wpa_monitor; - -} SettingsPluginIfnetPrivate; - -typedef void (*FileChangedFn) (gpointer user_data); - -typedef struct { - FileChangedFn callback; - gpointer user_data; -} FileMonitorInfo; - -static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); - -static void reload_connections (NMSettingsPlugin *config); - -G_DEFINE_TYPE_EXTENDED (SettingsPluginIfnet, settings_plugin_ifnet, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_interface_init)) -#define SETTINGS_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetPrivate)) - -static SettingsPluginIfnet *settings_plugin_ifnet_get (void); -NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfnet, settings_plugin_ifnet_get, SETTINGS_TYPE_PLUGIN_IFNET); - -static gboolean -is_managed_plugin (void) -{ - return nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG, - NM_CONFIG_KEYFILE_GROUP_IFNET, NM_CONFIG_KEYFILE_KEY_IFNET_MANAGED, - IFNET_MANAGE_WELL_KNOWN_DEFAULT); -} - -static void -file_changed (GFileMonitor * monitor, - GFile * file, - GFile * other_file, - GFileMonitorEvent event_type, gpointer user_data) -{ - FileMonitorInfo *info; - - switch (event_type) { - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - info = (FileMonitorInfo *) user_data; - info->callback (info->user_data); - break; - default: - break; - } -} - -static GFileMonitor * -monitor_file_changes (const char *filename, - FileChangedFn callback, gpointer user_data) -{ - GFile *file; - GFileMonitor *monitor; - FileMonitorInfo *info; - GError **error = NULL; - - if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) - return NULL; - file = g_file_new_for_path (filename); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, error); - g_object_unref (file); - - if (monitor) { - info = g_new0 (FileMonitorInfo, 1); - info->callback = callback; - info->user_data = user_data; - g_object_weak_ref (G_OBJECT (monitor), (GWeakNotify) g_free, - info); - g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), - info); - } else { - nm_log_warn (LOGD_SETTINGS, "Monitoring %s failed, error: %s", filename, - error == NULL ? "nothing" : (*error)->message); - } - - return monitor; -} - -static void -setup_monitors (NMIfnetConnection * connection, gpointer user_data) -{ - SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - - if (nm_config_get_monitor_connection_files (nm_config_get ())) { - priv->net_monitor = - monitor_file_changes (CONF_NET_FILE, (FileChangedFn) reload_connections, - user_data); - priv->wpa_monitor = - monitor_file_changes (WPA_SUPPLICANT_CONF, (FileChangedFn) reload_connections, - user_data); - } -} - -static void -cancel_monitors (NMIfnetConnection * connection, gpointer user_data) -{ - SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - - if (priv->net_monitor) { - g_file_monitor_cancel (priv->net_monitor); - g_object_unref (priv->net_monitor); - } - if (priv->wpa_monitor) { - g_file_monitor_cancel (priv->wpa_monitor); - g_object_unref (priv->wpa_monitor); - } -} - -static void -connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) -{ - g_hash_table_remove (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (user_data)->connections, - nm_connection_get_uuid (NM_CONNECTION (obj))); -} - -static void -track_new_connection (SettingsPluginIfnet *self, NMIfnetConnection *connection) -{ - g_hash_table_insert (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self)->connections, - g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), - g_object_ref (connection)); - g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, - G_CALLBACK (connection_removed_cb), - self); -} - -static void -reload_connections (NMSettingsPlugin *config) -{ - SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - GList *conn_names = NULL, *n_iter = NULL; - gboolean auto_refresh; - GError *error = NULL; - - /* save names for removing unused connections */ - GHashTable *new_connections = NULL; - GHashTableIter iter; - const char *uuid; - NMSettingsConnection *candidate; - - if (priv->unmanaged_well_known) - return; - - if (!reload_parsers ()) - return; - - nm_log_info (LOGD_SETTINGS, "Loading connections"); - - auto_refresh = nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG, - NM_CONFIG_KEYFILE_GROUP_IFNET, NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH, - FALSE); - - new_connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); - - /* Reread on-disk data and refresh in-memory connections from it */ - conn_names = ifnet_get_connection_names (); - for (n_iter = conn_names; n_iter; n_iter = g_list_next (n_iter)) { - NMIfnetConnection *new; - NMIfnetConnection *old; - const char *conn_name = n_iter->data; - - /* read the new connection */ - new = nm_ifnet_connection_new (NULL, conn_name); - if (!new) - continue; - - g_signal_connect (G_OBJECT (new), "ifnet_setup_monitors", - G_CALLBACK (setup_monitors), config); - g_signal_connect (G_OBJECT (new), "ifnet_cancel_monitors", - G_CALLBACK (cancel_monitors), config); - - old = g_hash_table_lookup (priv->connections, - nm_connection_get_uuid (NM_CONNECTION (new))); - if (old && new) { - if (auto_refresh) { - /* If connection has changed, remove the old one and add the - * new one to force a disconnect/reconnect with new settings - */ - if (!nm_connection_compare (NM_CONNECTION (old), - NM_CONNECTION (new), - NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | - NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { - nm_log_info (LOGD_SETTINGS, "Auto refreshing %s", conn_name); - - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old)); - track_new_connection (self, new); - if (is_managed_plugin () && is_managed (conn_name)) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); - } - } else { - /* Update existing connection with new settings */ - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (old), - NM_CONNECTION (new), - FALSE, /* don't set Unsaved */ - "ifnet-update", - &error)) { - /* Shouldn't ever get here as 'new' was verified by the reader already - * and the UUID did not change. */ - g_assert_not_reached (); - } - g_assert_no_error (error); - nm_log_info (LOGD_SETTINGS, "Connection %s updated", - nm_connection_get_id (NM_CONNECTION (new))); - } - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); - } else if (new) { - track_new_connection (self, new); - if (is_managed_plugin () && is_managed (conn_name)) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); - } - - /* Track all valid connections so we can remove deleted ones later */ - g_hash_table_insert (new_connections, - (gpointer) nm_connection_get_uuid (NM_CONNECTION (new)), - new); - } - - /* remove deleted/unused connections */ - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, (gpointer) &uuid, (gpointer) &candidate)) { - /* only saved connections (which have a conn_name) get removed; unsaved - * ones obviously don't exist in /etc/conf.d/net yet and shouldn't get - * blown away by net file changes. - */ - if ( nm_ifnet_connection_get_conn_name (NM_IFNET_CONNECTION (candidate)) - && !g_hash_table_lookup (new_connections, uuid)) { - nm_settings_connection_signal_remove (candidate); - g_hash_table_iter_remove (&iter); - } - } - g_hash_table_destroy (new_connections); - g_list_free (conn_names); -} - -static NMSettingsConnection * -add_connection (NMSettingsPlugin *config, - NMConnection *source, - gboolean save_to_disk, - GError **error) -{ - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); - NMIfnetConnection *new = NULL; - - /* Ensure we reject attempts to add the connection long before we're - * asked to write it to disk. - */ - if (!ifnet_can_write_connection (source, error)) - return NULL; - - if (save_to_disk) { - if (!ifnet_add_new_connection (source, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL, NULL, error)) - return NULL; - reload_connections (config); - new = g_hash_table_lookup (priv->connections, nm_connection_get_uuid (source)); - } else { - new = nm_ifnet_connection_new (source, NULL); - if (new) { - track_new_connection (SETTINGS_PLUGIN_IFNET (config), new); - /* track_new_connection refs 'new' */ - g_object_unref (new); - } - } - - return (NMSettingsConnection *) new; -} - -static void -check_unmanaged (gpointer key, gpointer data, gpointer user_data) -{ - NMIfnetConnection *connection = NM_IFNET_CONNECTION (data); - GSList **list = (GSList **) user_data; - const char *mac, *conn_name; - char *unmanaged_spec; - GSList *iter; - - conn_name = nm_ifnet_connection_get_conn_name (connection); - - if (!conn_name || is_managed (conn_name)) - return; - - nm_log_info (LOGD_SETTINGS, "Checking unmanaged: %s", conn_name); - mac = ifnet_get_data (conn_name, "mac"); - if (mac) - unmanaged_spec = g_strdup_printf ("mac:%s", mac); - else - unmanaged_spec = g_strdup_printf ("interface-name:%s", conn_name); - - /* Just return if the unmanaged spec is already in the list */ - for (iter = *list; iter; iter = g_slist_next (iter)) { - if (g_str_equal (iter->data, unmanaged_spec)) { - g_free (unmanaged_spec); - return; - } - } - - nm_log_info (LOGD_SETTINGS, "Add unmanaged: %s", unmanaged_spec); - *list = g_slist_prepend (*list, unmanaged_spec); -} - -static GSList * -get_unmanaged_specs (NMSettingsPlugin * config) -{ - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); - GSList *list = NULL; - - nm_log_info (LOGD_SETTINGS, "getting unmanaged specs..."); - g_hash_table_foreach (priv->connections, check_unmanaged, &list); - return list; -} - -static void -init (NMSettingsPlugin *config) -{ - SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - - nm_log_info (LOGD_SETTINGS, "Initializing!"); - - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - priv->unmanaged_well_known = !is_managed_plugin (); - nm_log_info (LOGD_SETTINGS, "management mode: %s", - priv->unmanaged_well_known ? "unmanaged" : "managed"); - - setup_monitors (NULL, config); - reload_connections (config); - - nm_log_info (LOGD_SETTINGS, "Initialzation complete!"); -} - -static GSList * -get_connections (NMSettingsPlugin *config) -{ - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); - GSList *connections = NULL; - GHashTableIter iter; - NMIfnetConnection *connection; - - nm_log_info (LOGD_SETTINGS, "(%p) ... get_connections.", config); - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) { - const char *conn_name = nm_ifnet_connection_get_conn_name (connection); - - if (!conn_name || (!priv->unmanaged_well_known && is_managed (conn_name))) - connections = g_slist_prepend (connections, connection); - } - nm_log_info (LOGD_SETTINGS, "(%p) connections count: %d", - config, g_slist_length (connections)); - return connections; -} - -static void -settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) -{ - plugin_iface->init = init; - plugin_iface->get_connections = get_connections; - plugin_iface->get_unmanaged_specs = get_unmanaged_specs; - plugin_iface->add_connection = add_connection; - plugin_iface->reload_connections = reload_connections; -} - -static void -settings_plugin_ifnet_init (SettingsPluginIfnet * plugin) -{ -} - -static void -get_property (GObject * object, guint prop_id, GValue * value, - GParamSpec * pspec) -{ - switch (prop_id) { - case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, IFNET_PLUGIN_NAME_PRINT); - break; - case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, IFNET_PLUGIN_INFO); - break; - case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: - g_value_set_uint (value, - NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject * object, guint prop_id, const GValue * value, - GParamSpec * pspec) -{ - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject * object) -{ - SettingsPluginIfnet *plugin = SETTINGS_PLUGIN_IFNET (object); - SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (plugin); - - cancel_monitors (NULL, object); - if (priv->connections) { - g_hash_table_destroy (priv->connections); - priv->connections = NULL; - } - - ifnet_destroy (); - wpa_parser_destroy (); - G_OBJECT_CLASS (settings_plugin_ifnet_parent_class)->dispose (object); -} - -static void -settings_plugin_ifnet_class_init (SettingsPluginIfnetClass * req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (SettingsPluginIfnetPrivate)); - - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_NAME, - NM_SETTINGS_PLUGIN_NAME); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_INFO, - NM_SETTINGS_PLUGIN_INFO); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, - NM_SETTINGS_PLUGIN_CAPABILITIES); -} - -G_MODULE_EXPORT GObject * -nm_settings_plugin_factory (void) -{ - return g_object_ref (settings_plugin_ifnet_get ()); -} diff --git a/src/settings/plugins/ifnet/plugin.h b/src/settings/plugins/ifnet/plugin.h deleted file mode 100644 index 09640968..00000000 --- a/src/settings/plugins/ifnet/plugin.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service (ifnet) - * - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#define SETTINGS_TYPE_PLUGIN_IFNET (settings_plugin_ifnet_get_type ()) -#define SETTINGS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnet)) -#define SETTINGS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) -#define SETTINGS_IS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFNET)) -#define SETTINGS_IS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFNET)) -#define SETTINGS_PLUGIN_IFNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) - -typedef struct _SettingsPluginIfnet SettingsPluginIfnet; -typedef struct _SettingsPluginIfnetClass SettingsPluginIfnetClass; - -struct _SettingsPluginIfnet { - GObject parent; -}; - -struct _SettingsPluginIfnetClass { - GObjectClass parent; -}; - -GType settings_plugin_ifnet_get_type (void); -#endif diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am deleted file mode 100644 index 8ece14c6..00000000 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -if ENABLE_TESTS - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS= \ - -I$(srcdir)/../ \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/src/platform \ - -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(CHECK_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) \ - -DTEST_IFNET_DIR=\"$(abs_srcdir)\" \ - -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ - -DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \ - -DSYSCONFDIR=\"nonexistent\" - -noinst_PROGRAMS = test-ifnet -test_ifnet_SOURCES = \ - test-ifnet.c \ - ../connection_parser.c \ - ../net_parser.c \ - ../net_utils.c \ - ../wpa_parser.c - -test_ifnet_LDFLAGS = \ - $(CODE_COVERAGE_LDFLAGS) - -test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-ifnet - -check-local: - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifnet.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - -EXTRA_DIST = \ - net \ - net.all \ - nm-system-settings.conf \ - wpa_supplicant.conf \ - test_ca_cert.pem diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in deleted file mode 100644 index 18f3c20c..00000000 --- a/src/settings/plugins/ifnet/tests/Makefile.in +++ /dev/null @@ -1,1234 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-ifnet$(EXEEXT) -@ENABLE_TESTS_TRUE@TESTS = test-ifnet$(EXEEXT) -subdir = src/settings/plugins/ifnet/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am__test_ifnet_SOURCES_DIST = test-ifnet.c ../connection_parser.c \ - ../net_parser.c ../net_utils.c ../wpa_parser.c -@ENABLE_TESTS_TRUE@am_test_ifnet_OBJECTS = test-ifnet.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ connection_parser.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ net_parser.$(OBJEXT) net_utils.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ wpa_parser.$(OBJEXT) -test_ifnet_OBJECTS = $(am_test_ifnet_OBJECTS) -@ENABLE_TESTS_TRUE@test_ifnet_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -test_ifnet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(test_ifnet_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_ifnet_SOURCES) -DIST_SOURCES = $(am__test_ifnet_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/platform \ -@ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -@ENABLE_TESTS_TRUE@ $(CHECK_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -DTEST_IFNET_DIR=\"$(abs_srcdir)\" \ -@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ -@ENABLE_TESTS_TRUE@ -DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \ -@ENABLE_TESTS_TRUE@ -DSYSCONFDIR=\"nonexistent\" - -@ENABLE_TESTS_TRUE@test_ifnet_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-ifnet.c \ -@ENABLE_TESTS_TRUE@ ../connection_parser.c \ -@ENABLE_TESTS_TRUE@ ../net_parser.c \ -@ENABLE_TESTS_TRUE@ ../net_utils.c \ -@ENABLE_TESTS_TRUE@ ../wpa_parser.c - -@ENABLE_TESTS_TRUE@test_ifnet_LDFLAGS = \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) - -@ENABLE_TESTS_TRUE@test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la -EXTRA_DIST = \ - net \ - net.all \ - nm-system-settings.conf \ - wpa_supplicant.conf \ - test_ca_cert.pem - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifnet/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifnet/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-ifnet$(EXEEXT): $(test_ifnet_OBJECTS) $(test_ifnet_DEPENDENCIES) $(EXTRA_test_ifnet_DEPENDENCIES) - @rm -f test-ifnet$(EXEEXT) - $(AM_V_CCLD)$(test_ifnet_LINK) $(test_ifnet_OBJECTS) $(test_ifnet_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_parser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_parser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifnet.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpa_parser.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -connection_parser.o: ../connection_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT connection_parser.o -MD -MP -MF $(DEPDIR)/connection_parser.Tpo -c -o connection_parser.o `test -f '../connection_parser.c' || echo '$(srcdir)/'`../connection_parser.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/connection_parser.Tpo $(DEPDIR)/connection_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../connection_parser.c' object='connection_parser.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o connection_parser.o `test -f '../connection_parser.c' || echo '$(srcdir)/'`../connection_parser.c - -connection_parser.obj: ../connection_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT connection_parser.obj -MD -MP -MF $(DEPDIR)/connection_parser.Tpo -c -o connection_parser.obj `if test -f '../connection_parser.c'; then $(CYGPATH_W) '../connection_parser.c'; else $(CYGPATH_W) '$(srcdir)/../connection_parser.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/connection_parser.Tpo $(DEPDIR)/connection_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../connection_parser.c' object='connection_parser.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o connection_parser.obj `if test -f '../connection_parser.c'; then $(CYGPATH_W) '../connection_parser.c'; else $(CYGPATH_W) '$(srcdir)/../connection_parser.c'; fi` - -net_parser.o: ../net_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_parser.o -MD -MP -MF $(DEPDIR)/net_parser.Tpo -c -o net_parser.o `test -f '../net_parser.c' || echo '$(srcdir)/'`../net_parser.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/net_parser.Tpo $(DEPDIR)/net_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../net_parser.c' object='net_parser.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_parser.o `test -f '../net_parser.c' || echo '$(srcdir)/'`../net_parser.c - -net_parser.obj: ../net_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_parser.obj -MD -MP -MF $(DEPDIR)/net_parser.Tpo -c -o net_parser.obj `if test -f '../net_parser.c'; then $(CYGPATH_W) '../net_parser.c'; else $(CYGPATH_W) '$(srcdir)/../net_parser.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/net_parser.Tpo $(DEPDIR)/net_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../net_parser.c' object='net_parser.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_parser.obj `if test -f '../net_parser.c'; then $(CYGPATH_W) '../net_parser.c'; else $(CYGPATH_W) '$(srcdir)/../net_parser.c'; fi` - -net_utils.o: ../net_utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_utils.o -MD -MP -MF $(DEPDIR)/net_utils.Tpo -c -o net_utils.o `test -f '../net_utils.c' || echo '$(srcdir)/'`../net_utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/net_utils.Tpo $(DEPDIR)/net_utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../net_utils.c' object='net_utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_utils.o `test -f '../net_utils.c' || echo '$(srcdir)/'`../net_utils.c - -net_utils.obj: ../net_utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_utils.obj -MD -MP -MF $(DEPDIR)/net_utils.Tpo -c -o net_utils.obj `if test -f '../net_utils.c'; then $(CYGPATH_W) '../net_utils.c'; else $(CYGPATH_W) '$(srcdir)/../net_utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/net_utils.Tpo $(DEPDIR)/net_utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../net_utils.c' object='net_utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_utils.obj `if test -f '../net_utils.c'; then $(CYGPATH_W) '../net_utils.c'; else $(CYGPATH_W) '$(srcdir)/../net_utils.c'; fi` - -wpa_parser.o: ../wpa_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT wpa_parser.o -MD -MP -MF $(DEPDIR)/wpa_parser.Tpo -c -o wpa_parser.o `test -f '../wpa_parser.c' || echo '$(srcdir)/'`../wpa_parser.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/wpa_parser.Tpo $(DEPDIR)/wpa_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../wpa_parser.c' object='wpa_parser.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wpa_parser.o `test -f '../wpa_parser.c' || echo '$(srcdir)/'`../wpa_parser.c - -wpa_parser.obj: ../wpa_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT wpa_parser.obj -MD -MP -MF $(DEPDIR)/wpa_parser.Tpo -c -o wpa_parser.obj `if test -f '../wpa_parser.c'; then $(CYGPATH_W) '../wpa_parser.c'; else $(CYGPATH_W) '$(srcdir)/../wpa_parser.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/wpa_parser.Tpo $(DEPDIR)/wpa_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../wpa_parser.c' object='wpa_parser.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wpa_parser.obj `if test -f '../wpa_parser.c'; then $(CYGPATH_W) '../wpa_parser.c'; else $(CYGPATH_W) '$(srcdir)/../wpa_parser.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-ifnet.log: test-ifnet$(EXEEXT) - @p='test-ifnet$(EXEEXT)'; \ - b='test-ifnet'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am \ - check-local clean clean-generic clean-libtool \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am recheck tags tags-am uninstall \ - uninstall-am - -.PRECIOUS: Makefile - - -@ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@@VALGRIND_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifnet.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifnet/tests/test-ifnet.c b/src/settings/plugins/ifnet/tests/test-ifnet.c index 49f88f1c..68f2b928 100644 --- a/src/settings/plugins/ifnet/tests/test-ifnet.c +++ b/src/settings/plugins/ifnet/tests/test-ifnet.c @@ -30,27 +30,27 @@ #include "nm-utils.h" -#include "nm-linux-platform.h" +#include "platform/nm-linux-platform.h" +#include "dhcp/nm-dhcp-manager.h" -#include "net_parser.h" -#include "net_utils.h" -#include "wpa_parser.h" -#include "connection_parser.h" -#include "nm-config.h" +#include "settings/plugins/ifnet/nms-ifnet-net-parser.h" +#include "settings/plugins/ifnet/nms-ifnet-net-utils.h" +#include "settings/plugins/ifnet/nms-ifnet-wpa-parser.h" +#include "settings/plugins/ifnet/nms-ifnet-connection-parser.h" #include "nm-test-utils-core.h" -/* Fake NMConfig handling; the values it returns don't matter, so this +/* Fake config handling; the values it returns don't matter, so this * is easier than forcing it to read our own config file, etc. */ -NMConfig * -nm_config_get (void) +NMDhcpManager * +nm_dhcp_manager_get (void) { return NULL; } const char * -nm_config_get_dhcp_client (NMConfig *config) +nm_dhcp_manager_get_config (NMDhcpManager *dhcp_manager) { return "dhclient"; } diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c deleted file mode 100644 index 505222ab..00000000 --- a/src/settings/plugins/ifnet/wpa_parser.c +++ /dev/null @@ -1,581 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-settings-plugin.h" -#include "wpa_parser.h" -#include "net_parser.h" -#include "net_utils.h" - -/* Security information */ -static GHashTable *wsec_table = NULL; - -/* Global information used for writing */ -static GHashTable *wsec_global_table = NULL; - -static gboolean wpa_parser_data_changed = FALSE; - -static long -wpa_get_long (GHashTable *table, const char *key) -{ - return atol (g_hash_table_lookup (table, key)); -} - -static void -destroy_security (GHashTable * network) -{ - gpointer key, value; - GHashTableIter iter; - - g_return_if_fail (network); - g_hash_table_iter_init (&iter, network); - while (g_hash_table_iter_next (&iter, &key, &value)) { - g_free (key); - g_free (value); - } - - g_hash_table_destroy (network); -} - -static GHashTable * -add_security (GHashTable *security) -{ - GHashTable *oldsecurity; - const char *ssid, *value; - char *ssid_key; - gboolean is_hex_ssid; - - /* Every security information should have a ssid */ - ssid = g_hash_table_lookup (security, "ssid"); - if (!ssid) { - destroy_security (security); - return NULL; - } - - /* Hex format begins with " */ - is_hex_ssid = (ssid[0] != '"'); - if ((value = g_hash_table_lookup (security, "disabled")) != NULL) { - if (strcmp (value, "1") == 0) { - destroy_security (security); - return NULL; - } - } - - /* Default priority is 1 */ - if (g_hash_table_lookup (security, "priority") == NULL) - g_hash_table_insert (security, g_strdup ("priority"), - g_strdup ("1")); - - oldsecurity = g_hash_table_lookup (wsec_table, ssid); - /* Security with lower priority will be ignored */ - if (oldsecurity != NULL) { - if (wpa_get_long (oldsecurity, "priority") >= - wpa_get_long (security, "priority")) { - destroy_security (security); - return NULL; - } else { - g_hash_table_remove (wsec_table, ssid); - destroy_security (oldsecurity); - } - } - - /* format ssid */ - ssid_key = - is_hex_ssid ? g_strdup_printf ("0x%s", - ssid) : - strip_string (g_strdup (ssid), '"'); - g_hash_table_insert (wsec_table, ssid_key, security); - return security; -} - -static void -add_key_value (GHashTable * network, gchar * line) -{ - gpointer orig_key, orig_value; - gchar **key_value; - - if (g_str_has_prefix (line, "network={")) - line += 9; - strip_string (line, '{'); - strip_string (line, '}'); - if (line[0] == '\0') - return; - key_value = g_strsplit (line, "=", 2); - if (g_strv_length (key_value) != 2) { - g_strfreev (key_value); - return; - } - g_strstrip (key_value[0]); - g_strstrip (key_value[1]); - - /* Reserve quotes for psk, wep_key, ssid - * Quotes will determine whether they are hex format */ - if (strcmp (key_value[0], "psk") != 0 - && !g_str_has_prefix (key_value[0], "wep_key") - && strcmp (key_value[0], "ssid") != 0) - strip_string (key_value[1], '"'); - - /* This sucks */ - if (g_hash_table_lookup_extended (network, key_value[0], &orig_key, &orig_value)) { - g_hash_table_remove (network, orig_key); - g_free (orig_key); - g_free (orig_value); - } - - g_hash_table_insert (network, g_strdup (key_value[0]), - g_strdup (key_value[1])); - g_strfreev (key_value); -} - -static void -add_one_wep_key (GHashTable * table, int key_num, gchar * one_wep_key) -{ - if (one_wep_key[0] == 's') { - //asc key - g_hash_table_insert (table, - g_strdup_printf ("wep_key%d", key_num - 1), - g_strdup_printf ("\"%s\"", - one_wep_key + 2)); - } else { - gchar buf[30]; - int i = 0, j = 0; - - //hex key - while (one_wep_key[i] != '\0') { - if (one_wep_key[i] != '-') - buf[j++] = one_wep_key[i]; - i++; - } - buf[j] = '\0'; - g_hash_table_insert (table, - g_strdup_printf ("wep_key%d", key_num - 1), - g_strdup (buf)); - - } -} - -/* Reading wep security information from /etc/conf.d/net. - * This should not be used in future, use wpa_supplicant instead. */ -static void -add_keys_from_net (void) -{ - GList *names = ifnet_get_connection_names (); - GList *iter = names; - gchar *wep_keys = "(\\[([1-4])\\]\\s+(s:\\w{5}|s:\\w{13}|" - "([\\da-fA-F]{4}\\-){2}[\\da-fA-F]{2}|" - "([\\da-fA-F]{4}\\-){6}[\\da-fA-F]{2})\\s+)"; - gchar *key_method = - "\\s+key\\s+\\[([1-4])\\]\\s+enc\\s+(open|restricted)"; - GRegex *regex_keys = g_regex_new (wep_keys, 0, 0, NULL); - GRegex *regex_method = g_regex_new (key_method, 0, 0, NULL); - GMatchInfo *keys_info; - GMatchInfo *method_info; - - while (iter) { - gchar *conn_name = iter->data; - GHashTable *table; - const char *key_str; - - if ((key_str = ifnet_get_data (conn_name, "key")) == NULL) { - iter = g_list_next (iter); - continue; - } - - wpa_add_security (conn_name); - table = _get_hash_table (conn_name); - /* Give lowest priority */ - wpa_set_data (conn_name, "priority", "0"); - g_regex_match (regex_keys, key_str, 0, &keys_info); - /* add wep keys */ - while (g_match_info_matches (keys_info)) { - gchar *key_num = g_match_info_fetch (keys_info, 2); - gchar *one_wep_key = g_match_info_fetch (keys_info, 3); - - add_one_wep_key (table, atoi (key_num), one_wep_key); - g_free (key_num); - g_free (one_wep_key); - g_match_info_next (keys_info, NULL); - } - g_match_info_free (keys_info); - - g_regex_match (regex_method, key_str, 0, &method_info); - /* set default key index and auth alg */ - if (g_match_info_matches (method_info)) { - gchar *default_idx = - g_match_info_fetch (method_info, 1); - gchar *method = g_match_info_fetch (method_info, 2); - - default_idx[0]--; - g_hash_table_insert (table, g_strdup ("wep_tx_keyidx"), - default_idx); - g_hash_table_insert (table, g_strdup ("auth_alg"), - g_ascii_strup (method, -1)); - } - g_match_info_free (method_info); - add_security (table); - iter = g_list_next (iter); - } - g_list_free (names); - g_regex_unref (regex_keys); - g_regex_unref (regex_method); -} - -static void -add_global_data (gchar * line) -{ - gchar **key_value; - - g_strstrip (line); - key_value = g_strsplit (line, "=", 2); - if (g_strv_length (key_value) != 2) { - nm_log_warn (LOGD_SETTINGS, "Can't handle this line: %s\n", line); - g_strfreev (key_value); - return; - } - g_hash_table_insert (wsec_global_table, - g_strdup (g_strstrip (key_value[0])), - g_strdup (g_strstrip (key_value[1]))); - g_strfreev (key_value); -} - -void -wpa_parser_init (const char *wpa_supplicant_conf) -{ - GIOChannel *channel = NULL; - gchar *line; - gboolean complete = FALSE; - - wpa_parser_data_changed = FALSE; - wsec_table = g_hash_table_new (g_str_hash, g_str_equal); - wsec_global_table = g_hash_table_new (g_str_hash, g_str_equal); - - if (g_file_test (wpa_supplicant_conf, G_FILE_TEST_IS_REGULAR)) - channel = - g_io_channel_new_file (wpa_supplicant_conf, "r", NULL); - if (channel == NULL) { - nm_log_warn (LOGD_SETTINGS, "Can't open %s for wireless security", - wpa_supplicant_conf); - return; - } - - while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL) - != G_IO_STATUS_EOF) { - g_strstrip (line); - if (line[0] != '#' && line[0] != '\0') { - if (strstr (line, "network={") == NULL) { - add_global_data (line); - g_free (line); - continue; - } else { - GHashTable *network = - g_hash_table_new (g_str_hash, g_str_equal); - - do { - gchar *quote_start, *quote_end = NULL, *comment; - - if (line[0] == '#' || line[0] == '\0') { - g_free (line); - continue; - } - /* ignore inline comments unless inside - a double-quoted string */ - if ((quote_start = strchr (line, '"')) != NULL) - quote_end = strrchr (quote_start + 1, '"'); - if ((comment = strchr ((quote_end != NULL) ? - quote_end : line, '#')) != NULL) - *comment = '\0'; - if (strstr (line, "}") != NULL) - complete = TRUE; - add_key_value (network, line); - g_free (line); - } while (complete == FALSE - && - g_io_channel_read_line - (channel, &line, NULL, - NULL, NULL) != G_IO_STATUS_EOF); - add_security (network); - //EOF in inner loop - if (complete == FALSE) { - g_free (line); - break; - } - complete = FALSE; - } - } else - g_free (line); - } - - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - - add_keys_from_net (); -} - -const char * -wpa_get_value (const char *ssid, const char *key) -{ - GHashTable *target = g_hash_table_lookup (wsec_table, ssid); - - if (target) - return g_hash_table_lookup (target, key); - return NULL; -} - -gboolean -exist_ssid (const char *ssid) -{ - return g_hash_table_lookup (wsec_table, ssid) != NULL; -} - -GHashTable * -_get_hash_table (const char *ssid) -{ - return g_hash_table_lookup (wsec_table, ssid); -} - -static gchar *quoted_keys[] = - { "identity", "cert", "private", "phase", "password", NULL }; - -/* tell whether the key needs quotes when writing is performed */ -static gboolean -need_quote (gchar * key) -{ - int i = 0; - - while (quoted_keys[i] != NULL) { - if (strstr (key, quoted_keys[i])) - return TRUE; - i++; - } - return FALSE; -} - -gboolean -wpa_flush_to_file (const char *config_file) -{ - GIOChannel *channel; - GError *error = NULL; - gpointer key, value, ssid, security; - GHashTableIter iter, iter_security; - gchar *out_line; - gsize bytes_written; - gboolean result = FALSE; - - if (!wpa_parser_data_changed) - return TRUE; - if (!wsec_table || !wsec_global_table) - return FALSE; - - backup_file (config_file); - - channel = g_io_channel_new_file (config_file, "w", NULL); - if (!channel) { - nm_log_warn (LOGD_SETTINGS, "Can't open file %s for writing", config_file); - return FALSE; - } - g_hash_table_iter_init (&iter, wsec_global_table); - nm_log_info (LOGD_SETTINGS, "Writing to %s", config_file); - g_io_channel_write_chars (channel, - "#Generated by NetworkManager\n" - "###### Global Configuration ######\n", - -1, &bytes_written, &error); - if (error) - goto done; - - /* Writing global information */ - while (g_hash_table_iter_next (&iter, &key, &value)) { - out_line = - g_strdup_printf ("%s=%s\n", (gchar *) key, (gchar *) value); - g_io_channel_write_chars (channel, out_line, -1, &bytes_written, - &error); - if (bytes_written == 0 || error) - break; - g_free (out_line); - } - if (error) - goto done; - g_io_channel_write_chars (channel, - "\n###### Security Configuration ######\n", - -1, &bytes_written, &error); - if (error) - goto done; - - g_hash_table_iter_init (&iter, wsec_table); - /* Writing security */ - while (g_hash_table_iter_next (&iter, &ssid, &security)) { - g_hash_table_iter_init (&iter_security, - (GHashTable *) security); - g_io_channel_write_chars (channel, "network={\n", -1, - &bytes_written, &error); - if (error) - goto done; - while (g_hash_table_iter_next (&iter_security, &key, &value)) { - out_line = - g_strdup_printf (need_quote ((gchar *) key) ? - "\t%s=\"%s\"\n" : "\t%s=%s\n", - (gchar *) key, (gchar *) value); - g_io_channel_write_chars (channel, out_line, -1, - &bytes_written, &error); - if (bytes_written == 0 || error) - goto done; - g_free (out_line); - } - g_io_channel_write_chars (channel, "}\n\n", -1, &bytes_written, &error); - - } - g_io_channel_flush (channel, &error); - if (error) - goto done; - - wpa_parser_data_changed = FALSE; - result = TRUE; -done: - if (error) { - nm_log_warn (LOGD_SETTINGS, "Error writing WPA configuration: %s", error->message); - g_error_free (error); - } - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - return result; -} - -/* If value is NULL, this method will delete old key value pair */ -void -wpa_set_data (const char *ssid, const char *key, const char *value) -{ - gpointer old_key = NULL, old_value = NULL; - GHashTable *security = g_hash_table_lookup (wsec_table, ssid); - gchar * stripped = NULL; - - g_return_if_fail (security != NULL); - - if (value){ - stripped = g_strdup(value); - if (strcmp (key, "ssid") != 0 && strcmp (key, "psk") != 0 - && !g_str_has_prefix (key, "wep_key")) - strip_string (stripped, '"'); - } - - /* Remove old key value pairs */ - if (g_hash_table_lookup_extended - (security, key, &old_key, &old_value)) { - if (stripped && !strcmp(old_value, stripped)){ - g_free (stripped); - return; - } - g_hash_table_remove (security, old_key); - g_free (old_key); - g_free (old_value); - } else if (!value) - return; - - /* Add new key value */ - if (stripped) - g_hash_table_insert (security, g_strdup (key), stripped); - wpa_parser_data_changed = TRUE; -} - -gboolean -wpa_has_security (const char *ssid) -{ - return g_hash_table_lookup (wsec_table, ssid) != NULL; -} - -gboolean -wpa_add_security (const char *ssid) -{ - if (wpa_has_security (ssid)) - return TRUE; - else { - GHashTable *security = - g_hash_table_new (g_str_hash, g_str_equal); - gchar *ssid_i; - - nm_log_info (LOGD_SETTINGS, "Adding security for %s", ssid); - if (g_str_has_prefix (ssid, "0x")) { - /* hex ssid */ - ssid_i = g_strdup (ssid + 2); - } else { - /* ascii ssid requires quotes */ - ssid_i = g_strdup_printf ("\"%s\"", ssid); - } - g_hash_table_insert (security, strdup ("ssid"), ssid_i); - g_hash_table_insert (security, strdup ("priority"), - strdup ("1")); - g_hash_table_insert (wsec_table, g_strdup (ssid), security); - wpa_parser_data_changed = TRUE; - return TRUE; - } -} - -gboolean -wpa_delete_security (const char *ssid) -{ - gpointer old_key, old_value; - - g_return_val_if_fail (wsec_table != NULL && ssid != NULL, FALSE); - nm_log_info (LOGD_SETTINGS, "Deleting security for %s", ssid); - if (!g_hash_table_lookup_extended - (wsec_table, ssid, &old_key, &old_value)) - return FALSE; - g_hash_table_remove (wsec_table, old_key); - g_free (old_key); - destroy_security ((GHashTable *) old_value); - wpa_parser_data_changed = TRUE; - return TRUE; - -} - -void -wpa_parser_destroy (void) -{ - GHashTableIter iter; - gpointer key; - gpointer value; - - /* Destroy security */ - if (wsec_table) { - g_hash_table_iter_init (&iter, wsec_table); - while (g_hash_table_iter_next (&iter, &key, &value)) { - destroy_security ((GHashTable *) value); - g_free (key); - } - - g_hash_table_destroy (wsec_table); - wsec_table = NULL; - } - - /* Destroy global data */ - if (wsec_global_table) { - g_hash_table_iter_init (&iter, wsec_global_table); - while (g_hash_table_iter_next (&iter, &key, &value)) { - g_free (key); - g_free (value); - } - - g_hash_table_destroy (wsec_global_table); - wsec_global_table = NULL; - } -} diff --git a/src/settings/plugins/ifnet/wpa_parser.h b/src/settings/plugins/ifnet/wpa_parser.h deleted file mode 100644 index d096f468..00000000 --- a/src/settings/plugins/ifnet/wpa_parser.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * Mu Qiao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 1999-2010 Gentoo Foundation, Inc. - */ - -#ifndef _WPA_PARSER_H -#define _WPA_PARSER_H - -#define WPA_SUPPLICANT_CONF SYSCONFDIR "/wpa_supplicant/wpa_supplicant.conf" - -void wpa_parser_init (const char *wpa_supplicant_conf); -void wpa_parser_destroy (void); - -/* reader functions */ -const char *wpa_get_value (const char *ssid, const char *key); -gboolean exist_ssid (const char *ssid); -GHashTable *_get_hash_table (const char *ssid); -gboolean wpa_has_security (const char *ssid); - -/* writer functions */ -gboolean wpa_flush_to_file (const char *config_file); -void wpa_set_data (const char *ssid, const char *key, const char *value); -gboolean wpa_add_security (const char *ssid); -gboolean wpa_delete_security (const char *ssid); -#endif diff --git a/src/settings/plugins/ifupdown/Makefile.am b/src/settings/plugins/ifupdown/Makefile.am deleted file mode 100644 index 94b0be54..00000000 --- a/src/settings/plugins/ifupdown/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -SUBDIRS = . tests - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(GUDEV_CFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -noinst_LTLIBRARIES = libifupdown-io.la - -libifupdown_io_la_SOURCES = \ - interface_parser.c \ - interface_parser.h \ - parser.c \ - parser.h - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifupdown.la - -libnm_settings_plugin_ifupdown_la_SOURCES = \ - nm-ifupdown-connection.c \ - nm-ifupdown-connection.h \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifupdown_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifupdown_la_LIBADD = libifupdown-io.la - diff --git a/src/settings/plugins/ifupdown/Makefile.in b/src/settings/plugins/ifupdown/Makefile.in deleted file mode 100644 index 385a55d9..00000000 --- a/src/settings/plugins/ifupdown/Makefile.in +++ /dev/null @@ -1,979 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ifupdown -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES) -libifupdown_io_la_LIBADD = -am_libifupdown_io_la_OBJECTS = interface_parser.lo parser.lo -libifupdown_io_la_OBJECTS = $(am_libifupdown_io_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_ifupdown_la_DEPENDENCIES = libifupdown-io.la -am_libnm_settings_plugin_ifupdown_la_OBJECTS = \ - nm-ifupdown-connection.lo plugin.lo -libnm_settings_plugin_ifupdown_la_OBJECTS = \ - $(am_libnm_settings_plugin_ifupdown_la_OBJECTS) -libnm_settings_plugin_ifupdown_la_LINK = $(LIBTOOL) $(AM_V_lt) \ - --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ - $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_ifupdown_la_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libifupdown_io_la_SOURCES) \ - $(libnm_settings_plugin_ifupdown_la_SOURCES) -DIST_SOURCES = $(libifupdown_io_la_SOURCES) \ - $(libnm_settings_plugin_ifupdown_la_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = . tests -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(GUDEV_CFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -noinst_LTLIBRARIES = libifupdown-io.la -libifupdown_io_la_SOURCES = \ - interface_parser.c \ - interface_parser.h \ - parser.c \ - parser.h - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifupdown.la -libnm_settings_plugin_ifupdown_la_SOURCES = \ - nm-ifupdown-connection.c \ - nm-ifupdown-connection.h \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifupdown_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifupdown_la_LIBADD = libifupdown-io.la -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifupdown/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifupdown/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libifupdown-io.la: $(libifupdown_io_la_OBJECTS) $(libifupdown_io_la_DEPENDENCIES) $(EXTRA_libifupdown_io_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libifupdown_io_la_OBJECTS) $(libifupdown_io_la_LIBADD) $(LIBS) - -libnm-settings-plugin-ifupdown.la: $(libnm_settings_plugin_ifupdown_la_OBJECTS) $(libnm_settings_plugin_ifupdown_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ifupdown_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_ifupdown_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ifupdown_la_OBJECTS) $(libnm_settings_plugin_ifupdown_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface_parser.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ifupdown-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile $(LTLIBRARIES) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - clean-pkglibLTLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-pkglibLTLIBRARIES install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifupdown/interface_parser.c b/src/settings/plugins/ifupdown/interface_parser.c deleted file mode 100644 index 3386a6ba..00000000 --- a/src/settings/plugins/ifupdown/interface_parser.c +++ /dev/null @@ -1,413 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * Tom Parker - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2004 Tom Parker - */ - -#include "nm-default.h" - -#include "interface_parser.h" - -#include -#include -#include -#include -#include - -#include "nm-utils.h" - -if_block* first; -if_block* last; - -if_data* last_data; - -void add_block(const char *type, const char* name) -{ - if_block *ret = g_slice_new0 (struct _if_block); - ret->name = g_strdup(name); - ret->type = g_strdup(type); - if (first == NULL) - first = last = ret; - else - { - last->next = ret; - last = ret; - } - last_data = NULL; -} - -void add_data(const char *key,const char *data) -{ - if_data *ret; - char *idx; - - /* Check if there is a block where we can attach our data */ - if (first == NULL) - return; - - ret = g_slice_new0 (struct _if_data); - ret->key = g_strdup(key); - - /* Normalize keys. Convert '_' to '-', as ifupdown accepts both variants. - * When querying keys via ifparser_getkey(), use '-'. */ - while ((idx = strrchr(ret->key, '_'))) { - *idx = '-'; - } - ret->data = g_strdup(data); - - if (last->info == NULL) - { - last->info = ret; - last_data = ret; - } - else - { - last_data->next = ret; - last_data = last_data->next; - } -} - -/* join values in src with spaces into dst; dst needs to be large enough */ -static char *join_values_with_spaces(char *dst, char **src) -{ - if (dst != NULL) { - *dst = '\0'; - if (src != NULL && *src != NULL) { - strcat(dst, *src); - - for (src++; *src != NULL; src++) { - strcat(dst, " "); - strcat(dst, *src); - } - } - } - return(dst); -} - -static void _ifparser_source (const char *path, const char *en_dir, int quiet, int dir); - -static void -_recursive_ifparser (const char *eni_file, int quiet) -{ - FILE *inp; - char line[255]; - int skip_to_block = 1; - int skip_long_line = 0; - int offs = 0; - - /* Check if interfaces file exists and open it */ - if (!g_file_test (eni_file, G_FILE_TEST_EXISTS)) { - if (!quiet) - nm_log_warn (LOGD_SETTINGS, "interfaces file %s doesn't exist\n", eni_file); - return; - } - inp = fopen (eni_file, "re"); - if (inp == NULL) { - if (!quiet) - nm_log_warn (LOGD_SETTINGS, "Can't open %s\n", eni_file); - return; - } - if (!quiet) - nm_log_info (LOGD_SETTINGS, " interface-parser: parsing file %s\n", eni_file); - - - while (!feof(inp)) - { - char *token[128]; /* 255 chars can only be split into 127 tokens */ - char value[255]; /* large enough to join previously split tokens */ - char *safeptr; - int toknum; - int len = 0; - - char *ptr = fgets(line+offs, 255-offs, inp); - if (ptr == NULL) - break; - - len = strlen(line); - /* skip over-long lines */ - if (!feof(inp) && len > 0 && line[len-1] != '\n') { - if (!skip_long_line) { - if (!quiet) - nm_log_warn (LOGD_SETTINGS, "Skipping over-long-line '%s...'\n", line); - } - skip_long_line = 1; - continue; - } - - /* trailing '\n' found: remove it & reset offset to 0 */ - if (len > 0 && line[len-1] == '\n') { - line[--len] = '\0'; - offs = 0; - } - - /* if we're in long_line_skip mode, terminate it for real next line */ - if (skip_long_line) { - if (len == 0 || line[len-1] != '\\') - skip_long_line = 0; - continue; - } - - /* unwrap wrapped lines */ - if (len > 0 && line[len-1] == '\\') { - offs = len - 1; - continue; - } - -#define SPACES " \t" - /* tokenize input; */ - for (toknum = 0, token[toknum] = strtok_r(line, SPACES, &safeptr); - token[toknum] != NULL; - toknum++, token[toknum] = strtok_r(NULL, SPACES, &safeptr)) - ; - - /* ignore comments and empty lines */ - if (toknum == 0 || *token[0]=='#') - continue; - - if (toknum < 2) { - if (!quiet) { - nm_log_warn (LOGD_SETTINGS, "Can't parse interface line '%s'\n", - join_values_with_spaces(value, token)); - } - skip_to_block = 1; - continue; - } - - /* There are six different stanzas: - * iface, mapping, auto, allow-*, source, and source-directory. - * Create a block for each of them except source and source-directory. */ - - /* iface stanza takes at least 3 parameters */ - if (strcmp(token[0], "iface") == 0) { - if (toknum < 4) { - if (!quiet) { - nm_log_warn (LOGD_SETTINGS, "Can't parse iface line '%s'\n", - join_values_with_spaces(value, token)); - } - continue; - } - add_block(token[0], token[1]); - skip_to_block = 0; - add_data(token[2], join_values_with_spaces(value, token + 3)); - } - /* auto and allow-auto stanzas are equivalent, - * both can take multiple interfaces as parameters: add one block for each */ - else if (strcmp(token[0], "auto") == 0 || - strcmp(token[0], "allow-auto") == 0) { - int i; - for (i = 1; i < toknum; i++) - add_block("auto", token[i]); - skip_to_block = 0; - } - else if (strcmp(token[0], "mapping") == 0) { - add_block(token[0], join_values_with_spaces(value, token + 1)); - skip_to_block = 0; - } - /* allow-* can take multiple interfaces as parameters: add one block for each */ - else if (strncmp(token[0],"allow-",6) == 0) { - int i; - for (i = 1; i < toknum; i++) - add_block(token[0], token[i]); - skip_to_block = 0; - } - /* source and source-directory stanzas take one or more paths as parameters */ - else if (strcmp (token[0], "source") == 0 || strcmp (token[0], "source-directory") == 0) { - int i; - char *en_dir; - - skip_to_block = 0; - - if (toknum == 1) { - if (!quiet) { - nm_log_warn (LOGD_SETTINGS, "Invalid %s line without parameters\n", - token[0]); - } - continue; - } - - en_dir = g_path_get_dirname (eni_file); - for (i = 1; i < toknum; ++i) { - if (strcmp (token[0], "source-directory") == 0) - _ifparser_source (token[i], en_dir, quiet, TRUE); - else - _ifparser_source (token[i], en_dir, quiet, FALSE); - } - g_free (en_dir); - } - else { - if (skip_to_block) { - if (!quiet) { - nm_log_warn (LOGD_SETTINGS, "ignoring out-of-block data '%s'\n", - join_values_with_spaces(value, token)); - } - } else - add_data(token[0], join_values_with_spaces(value, token + 1)); - } - } - fclose(inp); - - if (!quiet) - nm_log_info (LOGD_SETTINGS, " interface-parser: finished parsing file %s\n", eni_file); -} - -static void -_ifparser_source (const char *path, const char *en_dir, int quiet, int dir) -{ - char *abs_path; - const char *item; - wordexp_t we; - GDir *source_dir; - GError *error = NULL; - uint i; - - if (g_path_is_absolute (path)) - abs_path = g_strdup (path); - else - abs_path = g_build_filename (en_dir, path, NULL); - - if (!quiet) - nm_log_info (LOGD_SETTINGS, " interface-parser: source line includes interfaces file(s) %s\n", abs_path); - - /* ifupdown uses WRDE_NOCMD for wordexp. */ - if (wordexp (abs_path, &we, WRDE_NOCMD)) { - if (!quiet) - nm_log_warn (LOGD_SETTINGS, "word expansion for %s failed\n", abs_path); - } else { - for (i = 0; i < we.we_wordc; i++) { - if (dir) { - source_dir = g_dir_open (we.we_wordv[i], 0, &error); - if (!source_dir) { - if (!quiet) { - nm_log_warn (LOGD_SETTINGS, "Failed to open directory %s: %s", - we.we_wordv[i], error->message); - } - g_clear_error (&error); - } else { - while ((item = g_dir_read_name (source_dir))) - _ifparser_source (item, we.we_wordv[i], quiet, FALSE); - g_dir_close (source_dir); - } - } else - _recursive_ifparser (we.we_wordv[i], quiet); - } - wordfree (&we); - } - g_free (abs_path); -} - -void ifparser_init (const char *eni_file, int quiet) -{ - first = last = NULL; - _recursive_ifparser (eni_file, quiet); -} - -void _destroy_data(if_data *ifd) -{ - if (ifd == NULL) - return; - _destroy_data(ifd->next); - g_free(ifd->key); - g_free(ifd->data); - g_slice_free(struct _if_data, ifd); - return; -} - -void _destroy_block(if_block* ifb) -{ - if (ifb == NULL) - return; - _destroy_block(ifb->next); - _destroy_data(ifb->info); - g_free(ifb->name); - g_free(ifb->type); - g_slice_free(struct _if_block, ifb); - return; -} - -void ifparser_destroy(void) -{ - _destroy_block(first); - first = last = NULL; -} - -if_block *ifparser_getfirst(void) -{ - return first; -} - -int ifparser_get_num_blocks(void) -{ - int i = 0; - if_block *iter = first; - - while (iter) { - i++; - iter = iter->next; - } - return i; -} - -if_block *ifparser_getif(const char* iface) -{ - if_block *curr = first; - while(curr!=NULL) - { - if (strcmp(curr->type,"iface")==0 && strcmp(curr->name,iface)==0) - return curr; - curr = curr->next; - } - return NULL; -} - -const char *ifparser_getkey(if_block* iface, const char *key) -{ - if_data *curr = iface->info; - while(curr!=NULL) - { - if (strcmp(curr->key,key)==0) - return curr->data; - curr = curr->next; - } - return NULL; -} - -gboolean -ifparser_haskey(if_block* iface, const char *key) -{ - if_data *curr = iface->info; - - while (curr != NULL) { - if (strcmp (curr->key, key) == 0) - return TRUE; - curr = curr->next; - } - return FALSE; -} - -int ifparser_get_num_info(if_block* iface) -{ - int i = 0; - if_data *iter = iface->info; - - while (iter) { - i++; - iter = iter->next; - } - return i; -} diff --git a/src/settings/plugins/ifupdown/interface_parser.h b/src/settings/plugins/ifupdown/interface_parser.h deleted file mode 100644 index bf9c4465..00000000 --- a/src/settings/plugins/ifupdown/interface_parser.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * Tom Parker - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2004 Tom Parker - */ - - -#ifndef _INTERFACE_PARSER_H -#define _INTERFACE_PARSER_H - -typedef struct _if_data -{ - char *key; - char *data; - struct _if_data *next; -} if_data; - -typedef struct _if_block -{ - char *type; - char *name; - if_data *info; - struct _if_block *next; -} if_block; - -void ifparser_init(const char *eni_file, int quiet); -void ifparser_destroy(void); - -if_block *ifparser_getif(const char* iface); -if_block *ifparser_getfirst(void); -const char *ifparser_getkey(if_block* iface, const char *key); -gboolean ifparser_haskey(if_block* iface, const char *key); -int ifparser_get_num_blocks(void); -int ifparser_get_num_info(if_block* iface); - -void add_block(const char *type, const char* name); -void add_data(const char *key,const char *data); -void _destroy_data(if_data *ifd); -void _destroy_block(if_block* ifb); -#endif diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c deleted file mode 100644 index 34ecf8b9..00000000 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service (ifupdown) - * - * Alexander Sack - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2007,2008 Canonical Ltd. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-dbus-interface.h" -#include "nm-utils.h" -#include "nm-setting-wireless-security.h" -#include "nm-settings-connection.h" -#include "nm-settings-plugin.h" -#include "nm-ifupdown-connection.h" -#include "parser.h" - -G_DEFINE_TYPE (NMIfupdownConnection, nm_ifupdown_connection, NM_TYPE_SETTINGS_CONNECTION) - -NMIfupdownConnection* -nm_ifupdown_connection_new (if_block *block) -{ - GObject *object; - GError *error = NULL; - - g_return_val_if_fail (block != NULL, NULL); - - object = g_object_new (NM_TYPE_IFUPDOWN_CONNECTION, NULL); - - if (!ifupdown_update_connection_from_if_block (NM_CONNECTION (object), block, &error)) { - nm_log_warn (LOGD_SETTINGS, "%s.%d - invalid connection read from /etc/network/interfaces: %s", - __FILE__, - __LINE__, - error->message); - g_object_unref (object); - return NULL; - } - - return (NMIfupdownConnection *) object; -} - -static gboolean -supports_secrets (NMSettingsConnection *connection, const char *setting_name) -{ - nm_log_info (LOGD_SETTINGS, "supports_secrets() for setting_name: '%s'", setting_name); - - return (strcmp (setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) == 0); -} - -static void -nm_ifupdown_connection_init (NMIfupdownConnection *connection) -{ -} - -static void -nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class) -{ - NMSettingsConnectionClass *connection_class = NM_SETTINGS_CONNECTION_CLASS (ifupdown_connection_class); - - connection_class->supports_secrets = supports_secrets; -} - diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h deleted file mode 100644 index e1999bef..00000000 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* NetworkManager system settings service (ifupdown) - * - * Alexander Sack - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Canonical Ltd. - */ - -#ifndef __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ -#define __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ - -#include - -#include "interface_parser.h" - -#define NM_TYPE_IFUPDOWN_CONNECTION (nm_ifupdown_connection_get_type ()) -#define NM_IFUPDOWN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnection)) -#define NM_IFUPDOWN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionClass)) -#define NM_IS_IFUPDOWN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFUPDOWN_CONNECTION)) -#define NM_IS_IFUPDOWN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFUPDOWN_CONNECTION)) -#define NM_IFUPDOWN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionClass)) - -typedef struct { - NMSettingsConnection parent; -} NMIfupdownConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMIfupdownConnectionClass; - -GType nm_ifupdown_connection_get_type (void); - -NMIfupdownConnection *nm_ifupdown_connection_new (if_block *block); - -#endif /* __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-connection.c b/src/settings/plugins/ifupdown/nms-ifupdown-connection.c new file mode 100644 index 00000000..c3d231fe --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-connection.c @@ -0,0 +1,96 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service (ifupdown) + * + * Alexander Sack + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2007,2008 Canonical Ltd. + */ + +#include "nm-default.h" + +#include "nms-ifupdown-connection.h" + +#include +#include + +#include "nm-dbus-interface.h" +#include "nm-utils.h" +#include "nm-setting-wireless-security.h" +#include "settings/nm-settings-connection.h" +#include "settings/nm-settings-plugin.h" + +#include "nms-ifupdown-parser.h" + +/*****************************************************************************/ + +struct _NMIfupdownConnection { + NMSettingsConnection parent; +}; + +struct _NMIfupdownConnectionClass { + NMSettingsConnectionClass parent; +}; + +G_DEFINE_TYPE (NMIfupdownConnection, nm_ifupdown_connection, NM_TYPE_SETTINGS_CONNECTION) + +/*****************************************************************************/ + +static gboolean +supports_secrets (NMSettingsConnection *connection, const char *setting_name) +{ + nm_log_info (LOGD_SETTINGS, "supports_secrets() for setting_name: '%s'", setting_name); + + return (strcmp (setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) == 0); +} + +/*****************************************************************************/ + +static void +nm_ifupdown_connection_init (NMIfupdownConnection *connection) +{ +} + +NMIfupdownConnection* +nm_ifupdown_connection_new (if_block *block) +{ + GObject *object; + GError *error = NULL; + + g_return_val_if_fail (block != NULL, NULL); + + object = g_object_new (NM_TYPE_IFUPDOWN_CONNECTION, NULL); + + if (!ifupdown_update_connection_from_if_block (NM_CONNECTION (object), block, &error)) { + nm_log_warn (LOGD_SETTINGS, "%s.%d - invalid connection read from /etc/network/interfaces: %s", + __FILE__, + __LINE__, + error->message); + g_object_unref (object); + return NULL; + } + + return (NMIfupdownConnection *) object; +} + +static void +nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class) +{ + NMSettingsConnectionClass *connection_class = NM_SETTINGS_CONNECTION_CLASS (ifupdown_connection_class); + + connection_class->supports_secrets = supports_secrets; +} + diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-connection.h b/src/settings/plugins/ifupdown/nms-ifupdown-connection.h new file mode 100644 index 00000000..7536c23e --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-connection.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* NetworkManager system settings service (ifupdown) + * + * Alexander Sack + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2008 Canonical Ltd. + */ + +#ifndef __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ +#define __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ + +#include "settings/nm-settings-connection.h" + +#include "nms-ifupdown-interface-parser.h" + +#define NM_TYPE_IFUPDOWN_CONNECTION (nm_ifupdown_connection_get_type ()) +#define NM_IFUPDOWN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnection)) +#define NM_IFUPDOWN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionClass)) +#define NM_IS_IFUPDOWN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFUPDOWN_CONNECTION)) +#define NM_IS_IFUPDOWN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFUPDOWN_CONNECTION)) +#define NM_IFUPDOWN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionClass)) + +typedef struct _NMIfupdownConnection NMIfupdownConnection; +typedef struct _NMIfupdownConnectionClass NMIfupdownConnectionClass; + +GType nm_ifupdown_connection_get_type (void); + +NMIfupdownConnection *nm_ifupdown_connection_new (if_block *block); + +#endif /* __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c new file mode 100644 index 00000000..8421afc2 --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c @@ -0,0 +1,404 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * Tom Parker + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2004 Tom Parker + */ + +#include "nm-default.h" + +#include "nms-ifupdown-interface-parser.h" + +#include +#include +#include +#include +#include + +#include "nm-utils.h" + +if_block* first; +if_block* last; + +if_data* last_data; + +void add_block(const char *type, const char* name) +{ + if_block *ret = g_slice_new0 (struct _if_block); + ret->name = g_strdup(name); + ret->type = g_strdup(type); + if (first == NULL) + first = last = ret; + else + { + last->next = ret; + last = ret; + } + last_data = NULL; +} + +void add_data(const char *key,const char *data) +{ + if_data *ret; + char *idx; + + /* Check if there is a block where we can attach our data */ + if (first == NULL) + return; + + ret = g_slice_new0 (struct _if_data); + ret->key = g_strdup(key); + + /* Normalize keys. Convert '_' to '-', as ifupdown accepts both variants. + * When querying keys via ifparser_getkey(), use '-'. */ + while ((idx = strrchr(ret->key, '_'))) { + *idx = '-'; + } + ret->data = g_strdup(data); + + if (last->info == NULL) + { + last->info = ret; + last_data = ret; + } + else + { + last_data->next = ret; + last_data = last_data->next; + } +} + +/* join values in src with spaces into dst; dst needs to be large enough */ +static char *join_values_with_spaces(char *dst, char **src) +{ + if (dst != NULL) { + *dst = '\0'; + if (src != NULL && *src != NULL) { + strcat(dst, *src); + + for (src++; *src != NULL; src++) { + strcat(dst, " "); + strcat(dst, *src); + } + } + } + return(dst); +} + +static void _ifparser_source (const char *path, const char *en_dir, int quiet, int dir); + +static void +_recursive_ifparser (const char *eni_file, int quiet) +{ + FILE *inp; + char line[255]; + int skip_to_block = 1; + int skip_long_line = 0; + int offs = 0; + + /* Check if interfaces file exists and open it */ + if (!g_file_test (eni_file, G_FILE_TEST_EXISTS)) { + if (!quiet) + nm_log_warn (LOGD_SETTINGS, "interfaces file %s doesn't exist\n", eni_file); + return; + } + inp = fopen (eni_file, "re"); + if (inp == NULL) { + if (!quiet) + nm_log_warn (LOGD_SETTINGS, "Can't open %s\n", eni_file); + return; + } + if (!quiet) + nm_log_info (LOGD_SETTINGS, " interface-parser: parsing file %s\n", eni_file); + + + while (!feof(inp)) + { + char *token[128]; /* 255 chars can only be split into 127 tokens */ + char value[255]; /* large enough to join previously split tokens */ + char *safeptr; + int toknum; + int len = 0; + + char *ptr = fgets(line+offs, 255-offs, inp); + if (ptr == NULL) + break; + + len = strlen(line); + /* skip over-long lines */ + if (!feof(inp) && len > 0 && line[len-1] != '\n') { + if (!skip_long_line) { + if (!quiet) + nm_log_warn (LOGD_SETTINGS, "Skipping over-long-line '%s...'\n", line); + } + skip_long_line = 1; + continue; + } + + /* trailing '\n' found: remove it & reset offset to 0 */ + if (len > 0 && line[len-1] == '\n') { + line[--len] = '\0'; + offs = 0; + } + + /* if we're in long_line_skip mode, terminate it for real next line */ + if (skip_long_line) { + if (len == 0 || line[len-1] != '\\') + skip_long_line = 0; + continue; + } + + /* unwrap wrapped lines */ + if (len > 0 && line[len-1] == '\\') { + offs = len - 1; + continue; + } + +#define SPACES " \t" + /* tokenize input; */ + for (toknum = 0, token[toknum] = strtok_r(line, SPACES, &safeptr); + token[toknum] != NULL; + toknum++, token[toknum] = strtok_r(NULL, SPACES, &safeptr)) + ; + + /* ignore comments and empty lines */ + if (toknum == 0 || *token[0]=='#') + continue; + + if (toknum < 2) { + if (!quiet) { + nm_log_warn (LOGD_SETTINGS, "Can't parse interface line '%s'\n", + join_values_with_spaces(value, token)); + } + skip_to_block = 1; + continue; + } + + /* There are six different stanzas: + * iface, mapping, auto, allow-*, source, and source-directory. + * Create a block for each of them except source and source-directory. */ + + /* iface stanza takes at least 3 parameters */ + if (strcmp(token[0], "iface") == 0) { + if (toknum < 4) { + if (!quiet) { + nm_log_warn (LOGD_SETTINGS, "Can't parse iface line '%s'\n", + join_values_with_spaces(value, token)); + } + continue; + } + add_block(token[0], token[1]); + skip_to_block = 0; + add_data(token[2], join_values_with_spaces(value, token + 3)); + } + /* auto and allow-auto stanzas are equivalent, + * both can take multiple interfaces as parameters: add one block for each */ + else if (strcmp(token[0], "auto") == 0 || + strcmp(token[0], "allow-auto") == 0) { + int i; + for (i = 1; i < toknum; i++) + add_block("auto", token[i]); + skip_to_block = 0; + } + else if (strcmp(token[0], "mapping") == 0) { + add_block(token[0], join_values_with_spaces(value, token + 1)); + skip_to_block = 0; + } + /* allow-* can take multiple interfaces as parameters: add one block for each */ + else if (strncmp(token[0],"allow-",6) == 0) { + int i; + for (i = 1; i < toknum; i++) + add_block(token[0], token[i]); + skip_to_block = 0; + } + /* source and source-directory stanzas take one or more paths as parameters */ + else if (strcmp (token[0], "source") == 0 || strcmp (token[0], "source-directory") == 0) { + int i; + char *en_dir; + + skip_to_block = 0; + en_dir = g_path_get_dirname (eni_file); + for (i = 1; i < toknum; ++i) { + if (strcmp (token[0], "source-directory") == 0) + _ifparser_source (token[i], en_dir, quiet, TRUE); + else + _ifparser_source (token[i], en_dir, quiet, FALSE); + } + g_free (en_dir); + } + else { + if (skip_to_block) { + if (!quiet) { + nm_log_warn (LOGD_SETTINGS, "ignoring out-of-block data '%s'\n", + join_values_with_spaces(value, token)); + } + } else + add_data(token[0], join_values_with_spaces(value, token + 1)); + } + } + fclose(inp); + + if (!quiet) + nm_log_info (LOGD_SETTINGS, " interface-parser: finished parsing file %s\n", eni_file); +} + +static void +_ifparser_source (const char *path, const char *en_dir, int quiet, int dir) +{ + char *abs_path; + const char *item; + wordexp_t we; + GDir *source_dir; + GError *error = NULL; + uint i; + + if (g_path_is_absolute (path)) + abs_path = g_strdup (path); + else + abs_path = g_build_filename (en_dir, path, NULL); + + if (!quiet) + nm_log_info (LOGD_SETTINGS, " interface-parser: source line includes interfaces file(s) %s\n", abs_path); + + /* ifupdown uses WRDE_NOCMD for wordexp. */ + if (wordexp (abs_path, &we, WRDE_NOCMD)) { + if (!quiet) + nm_log_warn (LOGD_SETTINGS, "word expansion for %s failed\n", abs_path); + } else { + for (i = 0; i < we.we_wordc; i++) { + if (dir) { + source_dir = g_dir_open (we.we_wordv[i], 0, &error); + if (!source_dir) { + if (!quiet) { + nm_log_warn (LOGD_SETTINGS, "Failed to open directory %s: %s", + we.we_wordv[i], error->message); + } + g_clear_error (&error); + } else { + while ((item = g_dir_read_name (source_dir))) + _ifparser_source (item, we.we_wordv[i], quiet, FALSE); + g_dir_close (source_dir); + } + } else + _recursive_ifparser (we.we_wordv[i], quiet); + } + wordfree (&we); + } + g_free (abs_path); +} + +void ifparser_init (const char *eni_file, int quiet) +{ + first = last = NULL; + _recursive_ifparser (eni_file, quiet); +} + +void _destroy_data(if_data *ifd) +{ + if (ifd == NULL) + return; + _destroy_data(ifd->next); + g_free(ifd->key); + g_free(ifd->data); + g_slice_free(struct _if_data, ifd); + return; +} + +void _destroy_block(if_block* ifb) +{ + if (ifb == NULL) + return; + _destroy_block(ifb->next); + _destroy_data(ifb->info); + g_free(ifb->name); + g_free(ifb->type); + g_slice_free(struct _if_block, ifb); + return; +} + +void ifparser_destroy(void) +{ + _destroy_block(first); + first = last = NULL; +} + +if_block *ifparser_getfirst(void) +{ + return first; +} + +int ifparser_get_num_blocks(void) +{ + int i = 0; + if_block *iter = first; + + while (iter) { + i++; + iter = iter->next; + } + return i; +} + +if_block *ifparser_getif(const char* iface) +{ + if_block *curr = first; + while(curr!=NULL) + { + if (strcmp(curr->type,"iface")==0 && strcmp(curr->name,iface)==0) + return curr; + curr = curr->next; + } + return NULL; +} + +const char *ifparser_getkey(if_block* iface, const char *key) +{ + if_data *curr = iface->info; + while(curr!=NULL) + { + if (strcmp(curr->key,key)==0) + return curr->data; + curr = curr->next; + } + return NULL; +} + +gboolean +ifparser_haskey(if_block* iface, const char *key) +{ + if_data *curr = iface->info; + + while (curr != NULL) { + if (strcmp (curr->key, key) == 0) + return TRUE; + curr = curr->next; + } + return FALSE; +} + +int ifparser_get_num_info(if_block* iface) +{ + int i = 0; + if_data *iter = iface->info; + + while (iter) { + i++; + iter = iter->next; + } + return i; +} diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h new file mode 100644 index 00000000..bf9c4465 --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * Tom Parker + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2004 Tom Parker + */ + + +#ifndef _INTERFACE_PARSER_H +#define _INTERFACE_PARSER_H + +typedef struct _if_data +{ + char *key; + char *data; + struct _if_data *next; +} if_data; + +typedef struct _if_block +{ + char *type; + char *name; + if_data *info; + struct _if_block *next; +} if_block; + +void ifparser_init(const char *eni_file, int quiet); +void ifparser_destroy(void); + +if_block *ifparser_getif(const char* iface); +if_block *ifparser_getfirst(void); +const char *ifparser_getkey(if_block* iface, const char *key); +gboolean ifparser_haskey(if_block* iface, const char *key); +int ifparser_get_num_blocks(void); +int ifparser_get_num_info(if_block* iface); + +void add_block(const char *type, const char* name); +void add_data(const char *key,const char *data); +void _destroy_data(if_data *ifd); +void _destroy_block(if_block* ifb); +#endif diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-parser.c b/src/settings/plugins/ifupdown/nms-ifupdown-parser.c new file mode 100644 index 00000000..99879c92 --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-parser.c @@ -0,0 +1,724 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* NetworkManager system settings service (ifupdown) + * + * Alexander Sack + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2008 Canonical Ltd. + */ + +#include "nm-default.h" + +#include "nms-ifupdown-parser.h" + +#include +#include +#include +#include +#include + +#include "nm-core-internal.h" +#include "settings/nm-settings-plugin.h" + +#include "nms-ifupdown-plugin.h" +#include "nms-ifupdown-parser.h" + + +static const gchar* +_ifupdownplugin_guess_connection_type (if_block *block) +{ + if_data *curr = block->info; + const gchar* ret_type = NULL; + const gchar* value = ifparser_getkey(block, "inet"); + if(value && !strcmp("ppp", value)) { + ret_type = NM_SETTING_PPP_SETTING_NAME; + } + + while(!ret_type && curr) { + if(!strncmp("wireless-", curr->key, strlen("wireless-")) || + !strncmp("wpa-", curr->key, strlen("wpa-"))) { + ret_type = NM_SETTING_WIRELESS_SETTING_NAME; + } + curr = curr->next; + } + + if(!ret_type) + ret_type = NM_SETTING_WIRED_SETTING_NAME; + + nm_log_info (LOGD_SETTINGS, "guessed connection type (%s) = %s", block->name, ret_type); + return ret_type; +} + + +struct _Mapping { + const gchar *domain; + const gpointer target; +}; + +static gpointer +map_by_mapping(struct _Mapping *mapping, const gchar *key) +{ + struct _Mapping *curr = mapping; + while(curr->domain) { + if(!strcmp(curr->domain, key)) + return curr->target; + curr++; + } + return NULL; +} + +static void +update_wireless_setting_from_if_block(NMConnection *connection, + if_block *block) +{ + gint wpa_l= strlen("wpa-"); + gint wireless_l= strlen("wireless-"); + + if_data *curr = block->info; + const gchar* value = ifparser_getkey (block, "inet"); + struct _Mapping mapping[] = { + {"ssid", "ssid"}, + {"essid", "ssid"}, + {"mode", "mode"}, + { NULL, NULL} + }; + + NMSettingWireless *wireless_setting = NULL; + + if(value && !strcmp("ppp", value)) { + return; + } + + nm_log_info (LOGD_SETTINGS, "update wireless settings (%s).", block->name); + wireless_setting = NM_SETTING_WIRELESS(nm_setting_wireless_new()); + + while(curr) { + if(strlen(curr->key) > wireless_l && + !strncmp("wireless-", curr->key, wireless_l)) { + const gchar* newkey = map_by_mapping(mapping, curr->key+wireless_l); + nm_log_info (LOGD_SETTINGS, "wireless setting key: %s='%s'", newkey, curr->data); + if(newkey && !strcmp("ssid", newkey)) { + GBytes *ssid; + gint len = strlen(curr->data); + + ssid = g_bytes_new (curr->data, len); + g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL); + g_bytes_unref (ssid); + nm_log_info (LOGD_SETTINGS, "setting wireless ssid = %d", len); + } else if(newkey && !strcmp("mode", newkey)) { + if (!g_ascii_strcasecmp (curr->data, "Managed") || !g_ascii_strcasecmp (curr->data, "Auto")) + g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA, NULL); + else if (!g_ascii_strcasecmp (curr->data, "Ad-Hoc")) + g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_ADHOC, NULL); + else if (!g_ascii_strcasecmp (curr->data, "Master")) + g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_AP, NULL); + else + nm_log_warn (LOGD_SETTINGS, "Invalid mode '%s' (not 'Ad-Hoc', 'Ap', 'Managed', or 'Auto')", curr->data); + } else { + g_object_set(wireless_setting, + newkey, curr->data, + NULL); + } + } else if(strlen(curr->key) > wpa_l && + !strncmp("wpa-", curr->key, wpa_l)) { + const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l); + + if(newkey && !strcmp("ssid", newkey)) { + GBytes *ssid; + gint len = strlen(curr->data); + + ssid = g_bytes_new (curr->data, len); + g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL); + g_bytes_unref (ssid); + nm_log_info (LOGD_SETTINGS, "setting wpa ssid = %d", len); + } else if(newkey) { + + g_object_set(wireless_setting, + newkey, curr->data, + NULL); + nm_log_info (LOGD_SETTINGS, "setting wpa newkey(%s)=data(%s)", newkey, curr->data); + } + } + curr = curr->next; + } + nm_connection_add_setting(connection, (NMSetting*) wireless_setting); +} + +typedef gchar* (*IfupdownStrDupeFunc) (gpointer value, gpointer data); +typedef gpointer (*IfupdownStrToTypeFunc) (const gchar* value); + +static char* +normalize_dupe_wireless_key (gpointer value, gpointer data) { + char* valuec = value; + char* endc = valuec + strlen (valuec); + char* delim = valuec; + char* next = delim; + char* result = malloc (strlen (valuec) + 1); + char* result_cur = result; + + while (*delim && (next = strchr (delim, '-')) != NULL) { + if (next == delim) { + delim++; + continue; + } + strncpy (result_cur, delim, next - delim); + result_cur += next - delim; + delim = next + 1; + } + if (*delim && strlen (valuec) > GPOINTER_TO_UINT(delim - valuec)) { + strncpy (result_cur, delim, endc - delim); + result_cur += endc - delim; + } + *result_cur = '\0'; + return result; +} + +static char* +normalize_dupe (gpointer value, gpointer data) { + return g_strdup(value); +} + +static char* +normalize_tolower (gpointer value, gpointer data) { + return g_ascii_strdown(value, -1); +} + +static char *normalize_psk (gpointer value, gpointer data) +{ + if (strlen (value) >= 8 && strlen (value) <= 64) + return g_strdup (value); + return NULL; +} + +static gpointer +string_to_gpointerint(const gchar* data) +{ + gint result = (gint) strtol (data, NULL, 10); + return GINT_TO_POINTER(result); +} + +static gpointer +string_to_glist_of_strings(const gchar* data) +{ + GSList *ret = NULL; + gchar *string = (gchar*) data; + while(string) { + gchar* next = NULL; + if( (next = strchr(string, ' ')) || + (next = strchr(string, '\t')) || + (next = strchr(string, '\0')) ) { + + gchar *part = g_strndup(string, (next - string)); + ret = g_slist_append(ret, part); + if (*next) + string = next+1; + else + string = NULL; + } else { + string = NULL; + } + } + return ret; +} + +static void +slist_free_all(gpointer slist) +{ + g_slist_free_full ((GSList *) slist, g_free); +} + +static void +update_wireless_security_setting_from_if_block(NMConnection *connection, + if_block *block) +{ + gint wpa_l= strlen("wpa-"); + gint wireless_l= strlen("wireless-"); + if_data *curr = block->info; + const gchar* value = ifparser_getkey (block, "inet"); + struct _Mapping mapping[] = { + {"psk", "psk"}, + {"identity", "leap-username"}, + {"password", "leap-password"}, + {"key", "wep-key0"}, + {"key-mgmt", "key-mgmt"}, + {"group", "group"}, + {"pairwise", "pairwise"}, + {"proto", "proto"}, + {"pin", "pin"}, + {"wep-key0", "wep-key0"}, + {"wep-key1", "wep-key1"}, + {"wep-key2", "wep-key2"}, + {"wep-key3", "wep-key3"}, + {"wep-tx-keyidx", "wep-tx-keyidx"}, + { NULL, NULL} + }; + + struct _Mapping dupe_mapping[] = { + {"psk", normalize_psk}, + {"identity", normalize_dupe}, + {"password", normalize_dupe}, + {"key", normalize_dupe_wireless_key}, + {"key-mgmt", normalize_tolower}, + {"group", normalize_tolower}, + {"pairwise", normalize_tolower}, + {"proto", normalize_tolower}, + {"pin", normalize_dupe}, + {"wep-key0", normalize_dupe_wireless_key}, + {"wep-key1", normalize_dupe_wireless_key}, + {"wep-key2", normalize_dupe_wireless_key}, + {"wep-key3", normalize_dupe_wireless_key}, + {"wep-tx-keyidx", normalize_dupe}, + { NULL, NULL} + }; + + struct _Mapping type_mapping[] = { + {"group", string_to_glist_of_strings}, + {"pairwise", string_to_glist_of_strings}, + {"proto", string_to_glist_of_strings}, + {"wep-tx-keyidx", string_to_gpointerint}, + { NULL, NULL} + }; + + struct _Mapping free_type_mapping[] = { + {"group", slist_free_all}, + {"pairwise", slist_free_all}, + {"proto", slist_free_all}, + { NULL, NULL} + }; + + NMSettingWirelessSecurity *wireless_security_setting; + NMSettingWireless *s_wireless; + gboolean security = FALSE; + + if(value && !strcmp("ppp", value)) { + return; + } + + s_wireless = nm_connection_get_setting_wireless(connection); + g_return_if_fail(s_wireless); + + nm_log_info (LOGD_SETTINGS, "update wireless security settings (%s).", block->name); + wireless_security_setting = + NM_SETTING_WIRELESS_SECURITY(nm_setting_wireless_security_new()); + + while(curr) { + if(strlen(curr->key) > wireless_l && + !strncmp("wireless-", curr->key, wireless_l)) { + + gchar *property_value = NULL; + gpointer typed_property_value = NULL; + const gchar* newkey = map_by_mapping(mapping, curr->key+wireless_l); + IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wireless_l); + IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wireless_l); + GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wireless_l); + if(!newkey || !dupe_func) + goto next; + + property_value = (*dupe_func) (curr->data, connection); + nm_log_info (LOGD_SETTINGS, "setting wireless security key: %s=%s", + newkey, property_value); + + if (type_map_func) { + errno = 0; + typed_property_value = (*type_map_func) (property_value); + if(errno) + goto wireless_next; + } + + g_object_set(wireless_security_setting, + newkey, typed_property_value ? typed_property_value : property_value, + NULL); + security = TRUE; + + wireless_next: + g_free(property_value); + if (typed_property_value && free_func) + (*free_func) (typed_property_value); + + } else if(strlen(curr->key) > wpa_l && + !strncmp("wpa-", curr->key, wpa_l)) { + + gchar *property_value = NULL; + gpointer typed_property_value = NULL; + const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l); + IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wpa_l); + IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wpa_l); + GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wpa_l); + if(!newkey || !dupe_func) + goto next; + + property_value = (*dupe_func) (curr->data, connection); + nm_log_info (LOGD_SETTINGS, "setting wpa security key: %s=%s", + newkey, +#ifdef DEBUG_SECRETS + property_value +#else /* DEBUG_SECRETS */ + !strcmp("key", newkey) || + !strcmp("leap-password", newkey) || + !strcmp("pin", newkey) || + !strcmp("psk", newkey) || + !strcmp("wep-key0", newkey) || + !strcmp("wep-key1", newkey) || + !strcmp("wep-key2", newkey) || + !strcmp("wep-key3", newkey) || + NULL ? + "" : property_value +#endif /* DEBUG_SECRETS */ + ); + + if (type_map_func) { + errno = 0; + typed_property_value = (*type_map_func) (property_value); + if(errno) + goto wpa_next; + } + + g_object_set(wireless_security_setting, + newkey, typed_property_value ? typed_property_value : property_value, + NULL); + security = TRUE; + + wpa_next: + g_free(property_value); + if (free_func && typed_property_value) + (*free_func) (typed_property_value); + } + next: + curr = curr->next; + } + + + if (security) + nm_connection_add_setting (connection, NM_SETTING (wireless_security_setting)); +} + +static void +update_wired_setting_from_if_block(NMConnection *connection, + if_block *block) +{ + NMSettingWired *s_wired = NULL; + s_wired = NM_SETTING_WIRED(nm_setting_wired_new()); + nm_connection_add_setting(connection, NM_SETTING(s_wired)); +} + +static void +ifupdown_ip4_add_dns (NMSettingIPConfig *s_ip4, const char *dns) +{ + guint32 addr; + char **list, **iter; + + if (dns == NULL) + return; + + list = g_strsplit_set (dns, " \t", -1); + for (iter = list; iter && *iter; iter++) { + g_strstrip (*iter); + if (g_ascii_isspace (*iter[0])) + continue; + if (!inet_pton (AF_INET, *iter, &addr)) { + nm_log_warn (LOGD_SETTINGS, " ignoring invalid nameserver '%s'", *iter); + continue; + } + + if (!nm_setting_ip_config_add_dns (s_ip4, *iter)) + nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); + } + g_strfreev (list); +} + +static gboolean +update_ip4_setting_from_if_block(NMConnection *connection, + if_block *block, + GError **error) +{ + + NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new()); + const char *type = ifparser_getkey(block, "inet"); + gboolean is_static = type && !strcmp("static", type); + + if (!is_static) { + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + } else { + guint32 tmp_mask; + NMIPAddress *addr; + const char *address_v; + const char *netmask_v; + const char *gateway_v; + const char *nameserver_v; + const char *nameservers_v; + const char *search_v; + char **list, **iter; + guint32 netmask_int = 32; + + /* Address */ + address_v = ifparser_getkey (block, "address"); + if (!address_v) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IPv4 address"); + goto error; + } + + /* mask/prefix */ + netmask_v = ifparser_getkey (block, "netmask"); + if (netmask_v) { + if (strlen (netmask_v) < 7) { + netmask_int = atoi (netmask_v); + } else if (!inet_pton (AF_INET, netmask_v, &tmp_mask)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IPv4 netmask '%s'", netmask_v); + goto error; + } else { + netmask_int = nm_utils_ip4_netmask_to_prefix (tmp_mask); + } + } + + /* Add the new address to the setting */ + addr = nm_ip_address_new (AF_INET, address_v, netmask_int, error); + if (!addr) + goto error; + + if (nm_setting_ip_config_add_address (s_ip4, addr)) { + nm_log_info (LOGD_SETTINGS, "addresses count: %d", + nm_setting_ip_config_get_num_addresses (s_ip4)); + } else { + nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP4 address"); + } + nm_ip_address_unref (addr); + + /* gateway */ + gateway_v = ifparser_getkey (block, "gateway"); + if (gateway_v) { + if (!nm_utils_ipaddr_valid (AF_INET, gateway_v)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IPv4 gateway '%s'", gateway_v); + goto error; + } + if (!nm_setting_ip_config_get_gateway (s_ip4)) + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL); + } + + nameserver_v = ifparser_getkey (block, "dns-nameserver"); + ifupdown_ip4_add_dns (s_ip4, nameserver_v); + + nameservers_v = ifparser_getkey (block, "dns-nameservers"); + ifupdown_ip4_add_dns (s_ip4, nameservers_v); + + if (!nm_setting_ip_config_get_num_dns (s_ip4)) + nm_log_info (LOGD_SETTINGS, "No dns-nameserver configured in /etc/network/interfaces"); + + /* DNS searches */ + search_v = ifparser_getkey (block, "dns-search"); + if (search_v) { + list = g_strsplit_set (search_v, " \t", -1); + for (iter = list; iter && *iter; iter++) { + g_strstrip (*iter); + if (g_ascii_isspace (*iter[0])) + continue; + if (!nm_setting_ip_config_add_dns_search (s_ip4, *iter)) + nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); + } + g_strfreev (list); + } + + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL); + } + + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + return TRUE; + +error: + g_object_unref (s_ip4); + return FALSE; +} + +static void +ifupdown_ip6_add_dns (NMSettingIPConfig *s_ip6, const char *dns) +{ + struct in6_addr addr; + char **list, **iter; + + if (dns == NULL) + return; + + list = g_strsplit_set (dns, " \t", -1); + for (iter = list; iter && *iter; iter++) { + g_strstrip (*iter); + if (g_ascii_isspace (*iter[0])) + continue; + if (!inet_pton (AF_INET6, *iter, &addr)) { + nm_log_warn (LOGD_SETTINGS, " ignoring invalid nameserver '%s'", *iter); + continue; + } + + if (!nm_setting_ip_config_add_dns (s_ip6, *iter)) + nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); + } + g_strfreev (list); +} + +static gboolean +update_ip6_setting_from_if_block(NMConnection *connection, + if_block *block, + GError **error) +{ + NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (nm_setting_ip6_config_new()); + const char *type = ifparser_getkey(block, "inet6"); + gboolean is_static = type && (!strcmp("static", type) || + !strcmp("v4tunnel", type)); + + if (!is_static) { + g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); + } else { + NMIPAddress *addr; + const char *address_v; + const char *prefix_v; + const char *gateway_v; + const char *nameserver_v; + const char *nameservers_v; + const char *search_v; + int prefix_int = 128; + char **list, **iter; + + /* Address */ + address_v = ifparser_getkey(block, "address"); + if (!address_v) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IPv6 address"); + goto error; + } + + /* Prefix */ + prefix_v = ifparser_getkey(block, "netmask"); + if (prefix_v) + prefix_int = g_ascii_strtoll (prefix_v, NULL, 10); + + /* Add the new address to the setting */ + addr = nm_ip_address_new (AF_INET6, address_v, prefix_int, error); + if (!addr) + goto error; + + if (nm_setting_ip_config_add_address (s_ip6, addr)) { + nm_log_info (LOGD_SETTINGS, "addresses count: %d", + nm_setting_ip_config_get_num_addresses (s_ip6)); + } else { + nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP6 address"); + } + nm_ip_address_unref (addr); + + /* gateway */ + gateway_v = ifparser_getkey (block, "gateway"); + if (gateway_v) { + if (!nm_utils_ipaddr_valid (AF_INET6, gateway_v)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IPv6 gateway '%s'", gateway_v); + goto error; + } + if (!nm_setting_ip_config_get_gateway (s_ip6)) + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL); + } + + nameserver_v = ifparser_getkey(block, "dns-nameserver"); + ifupdown_ip6_add_dns (s_ip6, nameserver_v); + + nameservers_v = ifparser_getkey(block, "dns-nameservers"); + ifupdown_ip6_add_dns (s_ip6, nameservers_v); + + if (!nm_setting_ip_config_get_num_dns (s_ip6)) + nm_log_info (LOGD_SETTINGS, "No dns-nameserver configured in /etc/network/interfaces"); + + /* DNS searches */ + search_v = ifparser_getkey (block, "dns-search"); + if (search_v) { + list = g_strsplit_set (search_v, " \t", -1); + for (iter = list; iter && *iter; iter++) { + g_strstrip (*iter); + if (isblank (*iter[0])) + continue; + if (!nm_setting_ip_config_add_dns_search (s_ip6, *iter)) + nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); + } + g_strfreev (list); + } + + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NULL); + } + + nm_connection_add_setting (connection, NM_SETTING (s_ip6)); + return TRUE; + +error: + g_object_unref (s_ip6); + return FALSE; +} + +gboolean +ifupdown_update_connection_from_if_block (NMConnection *connection, + if_block *block, + GError **error) +{ + const char *type = NULL; + char *idstr = NULL; + char *uuid_base = NULL; + char *uuid = NULL; + NMSettingConnection *s_con; + gboolean success = FALSE; + + s_con = nm_connection_get_setting_connection (connection); + if(!s_con) { + s_con = NM_SETTING_CONNECTION (nm_setting_connection_new()); + g_assert (s_con); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + } + + type = _ifupdownplugin_guess_connection_type (block); + idstr = g_strconcat ("Ifupdown (", block->name, ")", NULL); + uuid_base = idstr; + + uuid = nm_utils_uuid_generate_from_string (uuid_base, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); + g_object_set (s_con, + NM_SETTING_CONNECTION_TYPE, type, + NM_SETTING_CONNECTION_INTERFACE_NAME, block->name, + NM_SETTING_CONNECTION_ID, idstr, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_READ_ONLY, TRUE, + NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, + NULL); + g_free (uuid); + + nm_log_info (LOGD_SETTINGS, "update_connection_setting_from_if_block: name:%s, type:%s, id:%s, uuid: %s", + block->name, type, idstr, nm_setting_connection_get_uuid (s_con)); + + if (!strcmp (NM_SETTING_WIRED_SETTING_NAME, type)) + update_wired_setting_from_if_block (connection, block); + else if (!strcmp (NM_SETTING_WIRELESS_SETTING_NAME, type)) { + update_wireless_setting_from_if_block (connection, block); + update_wireless_security_setting_from_if_block (connection, block); + } + + if (ifparser_haskey(block, "inet6")) + success = update_ip6_setting_from_if_block (connection, block, error); + else + success = update_ip4_setting_from_if_block (connection, block, error); + + if (success == TRUE) + success = nm_connection_verify (connection, error); + + g_free (idstr); + return success; +} diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-parser.h b/src/settings/plugins/ifupdown/nms-ifupdown-parser.h new file mode 100644 index 00000000..36e52e2c --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-parser.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* NetworkManager system settings service (ifupdown) + * + * Alexander Sack + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2008 Canonical Ltd. + */ + +#ifndef __PARSER_H__ +#define __PARSER_H__ + +#include + +#include "nms-ifupdown-interface-parser.h" + +gboolean +ifupdown_update_connection_from_if_block (NMConnection *connection, + if_block *block, + GError **error); + +#endif /* __PARSER_H__ */ diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c new file mode 100644 index 00000000..211e5d57 --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c @@ -0,0 +1,527 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* NetworkManager system settings service (ifupdown) + * + * Alexander Sack + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2007,2008 Canonical Ltd. + * (C) Copyright 2009 - 2011 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-ifupdown-plugin.h" + +#include +#include +#include +#include + +#include "nm-setting-connection.h" +#include "nm-dbus-interface.h" +#include "settings/nm-settings-plugin.h" +#include "nm-setting-ip4-config.h" +#include "nm-setting-wireless.h" +#include "nm-setting-wired.h" +#include "nm-setting-ppp.h" +#include "nm-utils.h" +#include "nm-core-internal.h" +#include "NetworkManagerUtils.h" +#include "nm-config.h" + +#include "nms-ifupdown-interface-parser.h" +#include "nms-ifupdown-connection.h" +#include "nms-ifupdown-parser.h" + +#define ENI_INTERFACES_FILE "/etc/network/interfaces" + +#define IFUPDOWN_PLUGIN_NAME "ifupdown" +#define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd. To report bugs please use the NetworkManager mailing list." + +#define IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT TRUE + +/* #define ALWAYS_UNMANAGE TRUE */ +#ifndef ALWAYS_UNMANAGE +#define ALWAYS_UNMANAGE FALSE +#endif + +/*****************************************************************************/ + +typedef struct { + GUdevClient *client; + + GHashTable *connections; /* /e/n/i block name :: NMIfupdownConnection */ + + /* Stores all blocks/interfaces read from /e/n/i regardless of whether + * there is an NMIfupdownConnection for block. + */ + GHashTable *eni_ifaces; + + /* Stores any network interfaces the kernel knows about */ + GHashTable *kernel_ifaces; + + gboolean unmanage_well_known; +} SettingsPluginIfupdownPrivate; + +struct _SettingsPluginIfupdown { + GObject parent; + SettingsPluginIfupdownPrivate _priv; +}; + +struct _SettingsPluginIfupdownClass { + GObjectClass parent; +}; + +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); + +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfupdown, settings_plugin_ifupdown, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) + +#define SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginIfupdown, SETTINGS_IS_PLUGIN_IFUPDOWN) + +/*****************************************************************************/ + +static SettingsPluginIfupdown *settings_plugin_ifupdown_get (void); +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfupdown, settings_plugin_ifupdown_get, SETTINGS_TYPE_PLUGIN_IFUPDOWN); + +/*****************************************************************************/ + +static void +bind_device_to_connection (SettingsPluginIfupdown *self, + GUdevDevice *device, + NMIfupdownConnection *exported) +{ + NMSettingWired *s_wired; + NMSettingWireless *s_wifi; + const char *iface, *address; + + iface = g_udev_device_get_name (device); + if (!iface) { + nm_log_warn (LOGD_SETTINGS, "failed to get ifname for device."); + return; + } + + address = g_udev_device_get_sysfs_attr (device, "address"); + if (!address || !strlen (address)) { + nm_log_warn (LOGD_SETTINGS, "failed to get MAC address for %s", iface); + return; + } + + if (!nm_utils_hwaddr_valid (address, ETH_ALEN)) { + nm_log_warn (LOGD_SETTINGS, "failed to parse MAC address '%s' for %s", + address, iface); + return; + } + + s_wired = nm_connection_get_setting_wired (NM_CONNECTION (exported)); + s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (exported)); + if (s_wired) { + nm_log_info (LOGD_SETTINGS, "locking wired connection setting"); + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, address, NULL); + } else if (s_wifi) { + nm_log_info (LOGD_SETTINGS, "locking wireless connection setting"); + g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, address, NULL); + } + + nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL, NULL); +} + +static void +udev_device_added (SettingsPluginIfupdown *self, GUdevDevice *device) +{ + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + const char *iface, *path; + NMIfupdownConnection *exported; + + iface = g_udev_device_get_name (device); + path = g_udev_device_get_sysfs_path (device); + if (!iface || !path) + return; + + nm_log_info (LOGD_SETTINGS, "devices added (path: %s, iface: %s)", path, iface); + + /* if we have a configured connection for this particular iface + * we want to either unmanage the device or lock it + */ + exported = g_hash_table_lookup (priv->connections, iface); + if (!exported && !g_hash_table_lookup (priv->eni_ifaces, iface)) { + nm_log_info (LOGD_SETTINGS, "device added (path: %s, iface: %s): no ifupdown configuration found.", + path, iface); + return; + } + + g_hash_table_insert (priv->kernel_ifaces, g_strdup (iface), g_object_ref (device)); + + if (exported) + bind_device_to_connection (self, device, exported); + + if (ALWAYS_UNMANAGE || priv->unmanage_well_known) + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); +} + +static void +udev_device_removed (SettingsPluginIfupdown *self, GUdevDevice *device) +{ + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + const char *iface, *path; + + iface = g_udev_device_get_name (device); + path = g_udev_device_get_sysfs_path (device); + if (!iface || !path) + return; + + nm_log_info (LOGD_SETTINGS, "devices removed (path: %s, iface: %s)", path, iface); + + if (!g_hash_table_remove (priv->kernel_ifaces, iface)) + return; + + if (ALWAYS_UNMANAGE || priv->unmanage_well_known) + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); +} + +static void +udev_device_changed (SettingsPluginIfupdown *self, GUdevDevice *device) +{ + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + const char *iface, *path; + + iface = g_udev_device_get_name (device); + path = g_udev_device_get_sysfs_path (device); + if (!iface || !path) + return; + + nm_log_info (LOGD_SETTINGS, "device changed (path: %s, iface: %s)", path, iface); + + if (!g_hash_table_lookup (priv->kernel_ifaces, iface)) + return; + + if (ALWAYS_UNMANAGE || priv->unmanage_well_known) + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); +} + +static void +handle_uevent (GUdevClient *client, + const char *action, + GUdevDevice *device, + gpointer user_data) +{ + SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (user_data); + const char *subsys; + + g_return_if_fail (action != NULL); + + /* A bit paranoid */ + subsys = g_udev_device_get_subsystem (device); + g_return_if_fail (subsys != NULL); + g_return_if_fail (strcmp (subsys, "net") == 0); + + if (!strcmp (action, "add")) + udev_device_added (self, device); + else if (!strcmp (action, "remove")) + udev_device_removed (self, device); + else if (!strcmp (action, "change")) + udev_device_changed (self, device); +} + +/* Returns the plugins currently known list of connections. The returned + * list is freed by the system settings service. + */ +static GSList* +get_connections (NMSettingsPlugin *config) +{ + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE ((SettingsPluginIfupdown *) config); + GSList *connections; + + nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections.", GPOINTER_TO_UINT(config)); + + if(priv->unmanage_well_known) { + nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections (managed=false): return empty list.", GPOINTER_TO_UINT(config)); + return NULL; + } + + connections = _nm_utils_hash_values_to_slist (priv->connections); + + nm_log_info (LOGD_SETTINGS, "(%d) connections count: %d", GPOINTER_TO_UINT(config), g_slist_length(connections)); + return connections; +} + +/* + * Return a list of device specifications which NetworkManager should not + * manage. Returned list will be freed by the system settings service, and + * each element must be allocated using g_malloc() or its variants. + */ +static GSList* +get_unmanaged_specs (NMSettingsPlugin *config) +{ + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE ((SettingsPluginIfupdown *) config); + GSList *specs = NULL; + GHashTableIter iter; + GUdevDevice *device; + const char *iface; + + if (!ALWAYS_UNMANAGE && !priv->unmanage_well_known) + return NULL; + + nm_log_info (LOGD_SETTINGS, "get unmanaged devices count: %d", + g_hash_table_size (priv->kernel_ifaces)); + + g_hash_table_iter_init (&iter, priv->kernel_ifaces); + while (g_hash_table_iter_next (&iter, (gpointer) &iface, (gpointer) &device)) { + const char *address; + + address = g_udev_device_get_sysfs_attr (device, "address"); + if (address) + specs = g_slist_append (specs, g_strdup_printf ("mac:%s", address)); + else + specs = g_slist_append (specs, g_strdup_printf ("interface-name:%s", iface)); + } + return specs; +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case NM_SETTINGS_PLUGIN_PROP_NAME: + g_value_set_string (value, IFUPDOWN_PLUGIN_NAME); + break; + case NM_SETTINGS_PLUGIN_PROP_INFO: + g_value_set_string (value, IFUPDOWN_PLUGIN_INFO); + break; + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_NONE); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +init (NMSettingsPlugin *config) +{ + SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (config); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + GHashTable *auto_ifaces; + if_block *block = NULL; + GList *keys, *iter; + GHashTableIter con_iter; + const char *block_name; + NMIfupdownConnection *connection; + const char *subsys[2] = { "net", NULL }; + + auto_ifaces = g_hash_table_new (g_str_hash, g_str_equal); + + if(!priv->connections) + priv->connections = g_hash_table_new (g_str_hash, g_str_equal); + + if(!priv->kernel_ifaces) + priv->kernel_ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); + + if(!priv->eni_ifaces) + priv->eni_ifaces = g_hash_table_new (g_str_hash, g_str_equal); + + nm_log_info (LOGD_SETTINGS, "init!"); + + priv->client = g_udev_client_new (subsys); + if (!priv->client) { + nm_log_warn (LOGD_SETTINGS, " error initializing libgudev"); + } else + g_signal_connect (priv->client, "uevent", G_CALLBACK (handle_uevent), self); + + /* Read in all the interfaces */ + ifparser_init (ENI_INTERFACES_FILE, 0); + block = ifparser_getfirst (); + while (block) { + if(!strcmp ("auto", block->type) || !strcmp ("allow-hotplug", block->type)) + g_hash_table_insert (auto_ifaces, block->name, GUINT_TO_POINTER (1)); + else if (!strcmp ("iface", block->type)) { + NMIfupdownConnection *exported; + + /* Bridge configuration */ + if(!strncmp ("br", block->name, 2)) { + /* Try to find bridge ports */ + const char *ports = ifparser_getkey (block, "bridge-ports"); + if (ports) { + int i; + int state = 0; + char **port_ifaces; + + nm_log_info (LOGD_SETTINGS, "found bridge ports %s for %s", ports, block->name); + + port_ifaces = g_strsplit_set (ports, " \t", -1); + for (i = 0; i < g_strv_length (port_ifaces); i++) { + char *token = port_ifaces[i]; + /* Skip crazy stuff like regex or all */ + if (!strcmp ("all", token)) { + continue; + } + /* Small SM to skip everything inside regex */ + if (!strcmp ("regex", token)) { + state++; + continue; + } + if (!strcmp ("noregex", token)) { + state--; + continue; + } + if (state == 0 && strlen (token) > 0) { + nm_log_info (LOGD_SETTINGS, "adding bridge port %s to eni_ifaces", token); + g_hash_table_insert (priv->eni_ifaces, g_strdup (token), "known"); + } + } + g_strfreev (port_ifaces); + } + goto next; + } + + /* Skip loopback configuration */ + if(!strcmp ("lo", block->name)) { + goto next; + } + + /* Remove any connection for this block that was previously found */ + exported = g_hash_table_lookup (priv->connections, block->name); + if (exported) { + nm_log_info (LOGD_SETTINGS, "deleting %s from connections", block->name); + nm_settings_connection_delete (NM_SETTINGS_CONNECTION (exported), NULL, NULL); + g_hash_table_remove (priv->connections, block->name); + } + + /* add the new connection */ + exported = nm_ifupdown_connection_new (block); + if (exported) { + nm_log_info (LOGD_SETTINGS, "adding %s to connections", block->name); + g_hash_table_insert (priv->connections, block->name, exported); + } + nm_log_info (LOGD_SETTINGS, "adding iface %s to eni_ifaces", block->name); + g_hash_table_insert (priv->eni_ifaces, block->name, "known"); + } else if (!strcmp ("mapping", block->type)) { + g_hash_table_insert (priv->eni_ifaces, block->name, "known"); + nm_log_info (LOGD_SETTINGS, "adding mapping %s to eni_ifaces", block->name); + } + next: + block = block->next; + } + + /* Make 'auto' interfaces autoconnect=TRUE */ + g_hash_table_iter_init (&con_iter, priv->connections); + while (g_hash_table_iter_next (&con_iter, (gpointer) &block_name, (gpointer) &connection)) { + NMSettingConnection *setting; + + if (g_hash_table_lookup (auto_ifaces, block_name)) { + setting = nm_connection_get_setting_connection (NM_CONNECTION (connection)); + g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL); + nm_log_info (LOGD_SETTINGS, "autoconnect"); + } + } + g_hash_table_destroy (auto_ifaces); + + /* Check the config file to find out whether to manage interfaces */ + priv->unmanage_well_known = !nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG, + NM_CONFIG_KEYFILE_GROUP_IFUPDOWN, + NM_CONFIG_KEYFILE_KEY_IFUPDOWN_MANAGED, + !IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT); + nm_log_info (LOGD_SETTINGS, "management mode: %s", priv->unmanage_well_known ? "unmanaged" : "managed"); + + /* Add well-known interfaces */ + keys = g_udev_client_query_by_subsystem (priv->client, "net"); + for (iter = keys; iter; iter = g_list_next (iter)) { + udev_device_added (self, G_UDEV_DEVICE (iter->data)); + g_object_unref (G_UDEV_DEVICE (iter->data)); + } + g_list_free (keys); + + /* Now if we're running in managed mode, let NM know there are new connections */ + if (!priv->unmanage_well_known) { + GList *con_list = g_hash_table_get_values (priv->connections); + GList *cl_iter; + + for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) { + g_signal_emit_by_name (self, + NM_SETTINGS_PLUGIN_CONNECTION_ADDED, + NM_SETTINGS_CONNECTION (cl_iter->data)); + } + g_list_free (con_list); + } + + nm_log_info (LOGD_SETTINGS, "end _init."); +} + +/*****************************************************************************/ + +static void +settings_plugin_ifupdown_init (SettingsPluginIfupdown *plugin) +{ +} + +static void +dispose (GObject *object) +{ + SettingsPluginIfupdown *plugin = SETTINGS_PLUGIN_IFUPDOWN (object); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (plugin); + + g_clear_pointer (&priv->kernel_ifaces, g_hash_table_destroy); + g_clear_pointer (&priv->eni_ifaces, g_hash_table_destroy); + g_clear_object (&priv->client); + + G_OBJECT_CLASS (settings_plugin_ifupdown_parent_class)->dispose (object); +} + +static void +settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + + object_class->dispose = dispose; + object_class->get_property = get_property; + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); +} + +static void +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) +{ + plugin_iface->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; +} + +/*****************************************************************************/ + +G_MODULE_EXPORT GObject * +nm_settings_plugin_factory (void) +{ + return g_object_ref (settings_plugin_ifupdown_get ()); +} + diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.h b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.h new file mode 100644 index 00000000..c2a3639c --- /dev/null +++ b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.h @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* NetworkManager system settings service (ifupdown) + * + * Alexander Sack + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2008 Canonical Ltd. + */ + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#define PLUGIN_NAME "ifupdown" + +#define SETTINGS_TYPE_PLUGIN_IFUPDOWN (settings_plugin_ifupdown_get_type ()) +#define SETTINGS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdown)) +#define SETTINGS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownClass)) +#define SETTINGS_IS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN)) +#define SETTINGS_IS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFUPDOWN)) +#define SETTINGS_PLUGIN_IFUPDOWN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownClass)) + +typedef struct _SettingsPluginIfupdown SettingsPluginIfupdown; +typedef struct _SettingsPluginIfupdownClass SettingsPluginIfupdownClass; + +GType settings_plugin_ifupdown_get_type (void); + +#endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c deleted file mode 100644 index 109018dd..00000000 --- a/src/settings/plugins/ifupdown/parser.c +++ /dev/null @@ -1,726 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* NetworkManager system settings service (ifupdown) - * - * Alexander Sack - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Canonical Ltd. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include - -#include "nm-core-internal.h" -#include "nm-settings-plugin.h" - -#include "parser.h" -#include "plugin.h" - - -#define WPA_PMK_LEN 32 - -#include "parser.h" - -static const gchar* -_ifupdownplugin_guess_connection_type (if_block *block) -{ - if_data *curr = block->info; - const gchar* ret_type = NULL; - const gchar* value = ifparser_getkey(block, "inet"); - if(value && !strcmp("ppp", value)) { - ret_type = NM_SETTING_PPP_SETTING_NAME; - } - - while(!ret_type && curr) { - if(!strncmp("wireless-", curr->key, strlen("wireless-")) || - !strncmp("wpa-", curr->key, strlen("wpa-"))) { - ret_type = NM_SETTING_WIRELESS_SETTING_NAME; - } - curr = curr->next; - } - - if(!ret_type) - ret_type = NM_SETTING_WIRED_SETTING_NAME; - - nm_log_info (LOGD_SETTINGS, "guessed connection type (%s) = %s", block->name, ret_type); - return ret_type; -} - - -struct _Mapping { - const gchar *domain; - const gpointer target; -}; - -static gpointer -map_by_mapping(struct _Mapping *mapping, const gchar *key) -{ - struct _Mapping *curr = mapping; - while(curr->domain) { - if(!strcmp(curr->domain, key)) - return curr->target; - curr++; - } - return NULL; -} - -static void -update_wireless_setting_from_if_block(NMConnection *connection, - if_block *block) -{ - gint wpa_l= strlen("wpa-"); - gint wireless_l= strlen("wireless-"); - - if_data *curr = block->info; - const gchar* value = ifparser_getkey (block, "inet"); - struct _Mapping mapping[] = { - {"ssid", "ssid"}, - {"essid", "ssid"}, - {"mode", "mode"}, - { NULL, NULL} - }; - - NMSettingWireless *wireless_setting = NULL; - - if(value && !strcmp("ppp", value)) { - return; - } - - nm_log_info (LOGD_SETTINGS, "update wireless settings (%s).", block->name); - wireless_setting = NM_SETTING_WIRELESS(nm_setting_wireless_new()); - - while(curr) { - if(strlen(curr->key) > wireless_l && - !strncmp("wireless-", curr->key, wireless_l)) { - const gchar* newkey = map_by_mapping(mapping, curr->key+wireless_l); - nm_log_info (LOGD_SETTINGS, "wireless setting key: %s='%s'", newkey, curr->data); - if(newkey && !strcmp("ssid", newkey)) { - GBytes *ssid; - gint len = strlen(curr->data); - - ssid = g_bytes_new (curr->data, len); - g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL); - g_bytes_unref (ssid); - nm_log_info (LOGD_SETTINGS, "setting wireless ssid = %d", len); - } else if(newkey && !strcmp("mode", newkey)) { - if (!g_ascii_strcasecmp (curr->data, "Managed") || !g_ascii_strcasecmp (curr->data, "Auto")) - g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA, NULL); - else if (!g_ascii_strcasecmp (curr->data, "Ad-Hoc")) - g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_ADHOC, NULL); - else if (!g_ascii_strcasecmp (curr->data, "Master")) - g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_AP, NULL); - else - nm_log_warn (LOGD_SETTINGS, "Invalid mode '%s' (not 'Ad-Hoc', 'Ap', 'Managed', or 'Auto')", curr->data); - } else { - g_object_set(wireless_setting, - newkey, curr->data, - NULL); - } - } else if(strlen(curr->key) > wpa_l && - !strncmp("wpa-", curr->key, wpa_l)) { - const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l); - - if(newkey && !strcmp("ssid", newkey)) { - GBytes *ssid; - gint len = strlen(curr->data); - - ssid = g_bytes_new (curr->data, len); - g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL); - g_bytes_unref (ssid); - nm_log_info (LOGD_SETTINGS, "setting wpa ssid = %d", len); - } else if(newkey) { - - g_object_set(wireless_setting, - newkey, curr->data, - NULL); - nm_log_info (LOGD_SETTINGS, "setting wpa newkey(%s)=data(%s)", newkey, curr->data); - } - } - curr = curr->next; - } - nm_connection_add_setting(connection, (NMSetting*) wireless_setting); -} - -typedef gchar* (*IfupdownStrDupeFunc) (gpointer value, gpointer data); -typedef gpointer (*IfupdownStrToTypeFunc) (const gchar* value); - -static char* -normalize_dupe_wireless_key (gpointer value, gpointer data) { - char* valuec = value; - char* endc = valuec + strlen (valuec); - char* delim = valuec; - char* next = delim; - char* result = malloc (strlen (valuec) + 1); - char* result_cur = result; - - while (*delim && (next = strchr (delim, '-')) != NULL) { - if (next == delim) { - delim++; - continue; - } - strncpy (result_cur, delim, next - delim); - result_cur += next - delim; - delim = next + 1; - } - if (*delim && strlen (valuec) > GPOINTER_TO_UINT(delim - valuec)) { - strncpy (result_cur, delim, endc - delim); - result_cur += endc - delim; - } - *result_cur = '\0'; - return result; -} - -static char* -normalize_dupe (gpointer value, gpointer data) { - return g_strdup(value); -} - -static char* -normalize_tolower (gpointer value, gpointer data) { - return g_ascii_strdown(value, -1); -} - -static char *normalize_psk (gpointer value, gpointer data) -{ - if (strlen (value) >= 8 && strlen (value) <= 64) - return g_strdup (value); - return NULL; -} - -static gpointer -string_to_gpointerint(const gchar* data) -{ - gint result = (gint) strtol (data, NULL, 10); - return GINT_TO_POINTER(result); -} - -static gpointer -string_to_glist_of_strings(const gchar* data) -{ - GSList *ret = NULL; - gchar *string = (gchar*) data; - while(string) { - gchar* next = NULL; - if( (next = strchr(string, ' ')) || - (next = strchr(string, '\t')) || - (next = strchr(string, '\0')) ) { - - gchar *part = g_strndup(string, (next - string)); - ret = g_slist_append(ret, part); - if (*next) - string = next+1; - else - string = NULL; - } else { - string = NULL; - } - } - return ret; -} - -static void -slist_free_all(gpointer slist) -{ - g_slist_free_full ((GSList *) slist, g_free); -} - -static void -update_wireless_security_setting_from_if_block(NMConnection *connection, - if_block *block) -{ - gint wpa_l= strlen("wpa-"); - gint wireless_l= strlen("wireless-"); - if_data *curr = block->info; - const gchar* value = ifparser_getkey (block, "inet"); - struct _Mapping mapping[] = { - {"psk", "psk"}, - {"identity", "leap-username"}, - {"password", "leap-password"}, - {"key", "wep-key0"}, - {"key-mgmt", "key-mgmt"}, - {"group", "group"}, - {"pairwise", "pairwise"}, - {"proto", "proto"}, - {"pin", "pin"}, - {"wep-key0", "wep-key0"}, - {"wep-key1", "wep-key1"}, - {"wep-key2", "wep-key2"}, - {"wep-key3", "wep-key3"}, - {"wep-tx-keyidx", "wep-tx-keyidx"}, - { NULL, NULL} - }; - - struct _Mapping dupe_mapping[] = { - {"psk", normalize_psk}, - {"identity", normalize_dupe}, - {"password", normalize_dupe}, - {"key", normalize_dupe_wireless_key}, - {"key-mgmt", normalize_tolower}, - {"group", normalize_tolower}, - {"pairwise", normalize_tolower}, - {"proto", normalize_tolower}, - {"pin", normalize_dupe}, - {"wep-key0", normalize_dupe_wireless_key}, - {"wep-key1", normalize_dupe_wireless_key}, - {"wep-key2", normalize_dupe_wireless_key}, - {"wep-key3", normalize_dupe_wireless_key}, - {"wep-tx-keyidx", normalize_dupe}, - { NULL, NULL} - }; - - struct _Mapping type_mapping[] = { - {"group", string_to_glist_of_strings}, - {"pairwise", string_to_glist_of_strings}, - {"proto", string_to_glist_of_strings}, - {"wep-tx-keyidx", string_to_gpointerint}, - { NULL, NULL} - }; - - struct _Mapping free_type_mapping[] = { - {"group", slist_free_all}, - {"pairwise", slist_free_all}, - {"proto", slist_free_all}, - { NULL, NULL} - }; - - NMSettingWirelessSecurity *wireless_security_setting; - NMSettingWireless *s_wireless; - gboolean security = FALSE; - - if(value && !strcmp("ppp", value)) { - return; - } - - s_wireless = nm_connection_get_setting_wireless(connection); - g_return_if_fail(s_wireless); - - nm_log_info (LOGD_SETTINGS, "update wireless security settings (%s).", block->name); - wireless_security_setting = - NM_SETTING_WIRELESS_SECURITY(nm_setting_wireless_security_new()); - - while(curr) { - if(strlen(curr->key) > wireless_l && - !strncmp("wireless-", curr->key, wireless_l)) { - - gchar *property_value = NULL; - gpointer typed_property_value = NULL; - const gchar* newkey = map_by_mapping(mapping, curr->key+wireless_l); - IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wireless_l); - IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wireless_l); - GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wireless_l); - if(!newkey || !dupe_func) - goto next; - - property_value = (*dupe_func) (curr->data, connection); - nm_log_info (LOGD_SETTINGS, "setting wireless security key: %s=%s", - newkey, property_value); - - if (type_map_func) { - errno = 0; - typed_property_value = (*type_map_func) (property_value); - if(errno) - goto wireless_next; - } - - g_object_set(wireless_security_setting, - newkey, typed_property_value ? typed_property_value : property_value, - NULL); - security = TRUE; - - wireless_next: - g_free(property_value); - if (typed_property_value && free_func) - (*free_func) (typed_property_value); - - } else if(strlen(curr->key) > wpa_l && - !strncmp("wpa-", curr->key, wpa_l)) { - - gchar *property_value = NULL; - gpointer typed_property_value = NULL; - const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l); - IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wpa_l); - IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wpa_l); - GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wpa_l); - if(!newkey || !dupe_func) - goto next; - - property_value = (*dupe_func) (curr->data, connection); - nm_log_info (LOGD_SETTINGS, "setting wpa security key: %s=%s", - newkey, -#ifdef DEBUG_SECRETS - property_value -#else /* DEBUG_SECRETS */ - !strcmp("key", newkey) || - !strcmp("leap-password", newkey) || - !strcmp("pin", newkey) || - !strcmp("psk", newkey) || - !strcmp("wep-key0", newkey) || - !strcmp("wep-key1", newkey) || - !strcmp("wep-key2", newkey) || - !strcmp("wep-key3", newkey) || - NULL ? - "" : property_value -#endif /* DEBUG_SECRETS */ - ); - - if (type_map_func) { - errno = 0; - typed_property_value = (*type_map_func) (property_value); - if(errno) - goto wpa_next; - } - - g_object_set(wireless_security_setting, - newkey, typed_property_value ? typed_property_value : property_value, - NULL); - security = TRUE; - - wpa_next: - g_free(property_value); - if (free_func && typed_property_value) - (*free_func) (typed_property_value); - } - next: - curr = curr->next; - } - - - if (security) - nm_connection_add_setting (connection, NM_SETTING (wireless_security_setting)); -} - -static void -update_wired_setting_from_if_block(NMConnection *connection, - if_block *block) -{ - NMSettingWired *s_wired = NULL; - s_wired = NM_SETTING_WIRED(nm_setting_wired_new()); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); -} - -static void -ifupdown_ip4_add_dns (NMSettingIPConfig *s_ip4, const char *dns) -{ - guint32 addr; - char **list, **iter; - - if (dns == NULL) - return; - - list = g_strsplit_set (dns, " \t", -1); - for (iter = list; iter && *iter; iter++) { - g_strstrip (*iter); - if (g_ascii_isspace (*iter[0])) - continue; - if (!inet_pton (AF_INET, *iter, &addr)) { - nm_log_warn (LOGD_SETTINGS, " ignoring invalid nameserver '%s'", *iter); - continue; - } - - if (!nm_setting_ip_config_add_dns (s_ip4, *iter)) - nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); - } - g_strfreev (list); -} - -static gboolean -update_ip4_setting_from_if_block(NMConnection *connection, - if_block *block, - GError **error) -{ - - NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new()); - const char *type = ifparser_getkey(block, "inet"); - gboolean is_static = type && !strcmp("static", type); - - if (!is_static) { - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - } else { - guint32 tmp_mask; - NMIPAddress *addr; - const char *address_v; - const char *netmask_v; - const char *gateway_v; - const char *nameserver_v; - const char *nameservers_v; - const char *search_v; - char **list, **iter; - guint32 netmask_int = 32; - - /* Address */ - address_v = ifparser_getkey (block, "address"); - if (!address_v) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IPv4 address"); - goto error; - } - - /* mask/prefix */ - netmask_v = ifparser_getkey (block, "netmask"); - if (netmask_v) { - if (strlen (netmask_v) < 7) { - netmask_int = atoi (netmask_v); - } else if (!inet_pton (AF_INET, netmask_v, &tmp_mask)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IPv4 netmask '%s'", netmask_v); - goto error; - } else { - netmask_int = nm_utils_ip4_netmask_to_prefix (tmp_mask); - } - } - - /* Add the new address to the setting */ - addr = nm_ip_address_new (AF_INET, address_v, netmask_int, error); - if (!addr) - goto error; - - if (nm_setting_ip_config_add_address (s_ip4, addr)) { - nm_log_info (LOGD_SETTINGS, "addresses count: %d", - nm_setting_ip_config_get_num_addresses (s_ip4)); - } else { - nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP4 address"); - } - nm_ip_address_unref (addr); - - /* gateway */ - gateway_v = ifparser_getkey (block, "gateway"); - if (gateway_v) { - if (!nm_utils_ipaddr_valid (AF_INET, gateway_v)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IPv4 gateway '%s'", gateway_v); - goto error; - } - if (!nm_setting_ip_config_get_gateway (s_ip4)) - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL); - } - - nameserver_v = ifparser_getkey (block, "dns-nameserver"); - ifupdown_ip4_add_dns (s_ip4, nameserver_v); - - nameservers_v = ifparser_getkey (block, "dns-nameservers"); - ifupdown_ip4_add_dns (s_ip4, nameservers_v); - - if (!nm_setting_ip_config_get_num_dns (s_ip4)) - nm_log_info (LOGD_SETTINGS, "No dns-nameserver configured in /etc/network/interfaces"); - - /* DNS searches */ - search_v = ifparser_getkey (block, "dns-search"); - if (search_v) { - list = g_strsplit_set (search_v, " \t", -1); - for (iter = list; iter && *iter; iter++) { - g_strstrip (*iter); - if (g_ascii_isspace (*iter[0])) - continue; - if (!nm_setting_ip_config_add_dns_search (s_ip4, *iter)) - nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); - } - g_strfreev (list); - } - - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL); - } - - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - return TRUE; - -error: - g_object_unref (s_ip4); - return FALSE; -} - -static void -ifupdown_ip6_add_dns (NMSettingIPConfig *s_ip6, const char *dns) -{ - struct in6_addr addr; - char **list, **iter; - - if (dns == NULL) - return; - - list = g_strsplit_set (dns, " \t", -1); - for (iter = list; iter && *iter; iter++) { - g_strstrip (*iter); - if (g_ascii_isspace (*iter[0])) - continue; - if (!inet_pton (AF_INET6, *iter, &addr)) { - nm_log_warn (LOGD_SETTINGS, " ignoring invalid nameserver '%s'", *iter); - continue; - } - - if (!nm_setting_ip_config_add_dns (s_ip6, *iter)) - nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); - } - g_strfreev (list); -} - -static gboolean -update_ip6_setting_from_if_block(NMConnection *connection, - if_block *block, - GError **error) -{ - NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (nm_setting_ip6_config_new()); - const char *type = ifparser_getkey(block, "inet6"); - gboolean is_static = type && (!strcmp("static", type) || - !strcmp("v4tunnel", type)); - - if (!is_static) { - g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - } else { - NMIPAddress *addr; - const char *address_v; - const char *prefix_v; - const char *gateway_v; - const char *nameserver_v; - const char *nameservers_v; - const char *search_v; - int prefix_int = 128; - char **list, **iter; - - /* Address */ - address_v = ifparser_getkey(block, "address"); - if (!address_v) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IPv6 address"); - goto error; - } - - /* Prefix */ - prefix_v = ifparser_getkey(block, "netmask"); - if (prefix_v) - prefix_int = g_ascii_strtoll (prefix_v, NULL, 10); - - /* Add the new address to the setting */ - addr = nm_ip_address_new (AF_INET6, address_v, prefix_int, error); - if (!addr) - goto error; - - if (nm_setting_ip_config_add_address (s_ip6, addr)) { - nm_log_info (LOGD_SETTINGS, "addresses count: %d", - nm_setting_ip_config_get_num_addresses (s_ip6)); - } else { - nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP6 address"); - } - nm_ip_address_unref (addr); - - /* gateway */ - gateway_v = ifparser_getkey (block, "gateway"); - if (gateway_v) { - if (!nm_utils_ipaddr_valid (AF_INET6, gateway_v)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IPv6 gateway '%s'", gateway_v); - goto error; - } - if (!nm_setting_ip_config_get_gateway (s_ip6)) - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL); - } - - nameserver_v = ifparser_getkey(block, "dns-nameserver"); - ifupdown_ip6_add_dns (s_ip6, nameserver_v); - - nameservers_v = ifparser_getkey(block, "dns-nameservers"); - ifupdown_ip6_add_dns (s_ip6, nameservers_v); - - if (!nm_setting_ip_config_get_num_dns (s_ip6)) - nm_log_info (LOGD_SETTINGS, "No dns-nameserver configured in /etc/network/interfaces"); - - /* DNS searches */ - search_v = ifparser_getkey (block, "dns-search"); - if (search_v) { - list = g_strsplit_set (search_v, " \t", -1); - for (iter = list; iter && *iter; iter++) { - g_strstrip (*iter); - if (isblank (*iter[0])) - continue; - if (!nm_setting_ip_config_add_dns_search (s_ip6, *iter)) - nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); - } - g_strfreev (list); - } - - g_object_set (s_ip6, - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, - NULL); - } - - nm_connection_add_setting (connection, NM_SETTING (s_ip6)); - return TRUE; - -error: - g_object_unref (s_ip6); - return FALSE; -} - -gboolean -ifupdown_update_connection_from_if_block (NMConnection *connection, - if_block *block, - GError **error) -{ - const char *type = NULL; - char *idstr = NULL; - char *uuid_base = NULL; - char *uuid = NULL; - NMSettingConnection *s_con; - gboolean success = FALSE; - - s_con = nm_connection_get_setting_connection (connection); - if(!s_con) { - s_con = NM_SETTING_CONNECTION (nm_setting_connection_new()); - g_assert (s_con); - nm_connection_add_setting (connection, NM_SETTING (s_con)); - } - - type = _ifupdownplugin_guess_connection_type (block); - idstr = g_strconcat ("Ifupdown (", block->name, ")", NULL); - uuid_base = idstr; - - uuid = nm_utils_uuid_generate_from_string (uuid_base, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); - g_object_set (s_con, - NM_SETTING_CONNECTION_TYPE, type, - NM_SETTING_CONNECTION_INTERFACE_NAME, block->name, - NM_SETTING_CONNECTION_ID, idstr, - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_READ_ONLY, TRUE, - NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, - NULL); - g_free (uuid); - - nm_log_info (LOGD_SETTINGS, "update_connection_setting_from_if_block: name:%s, type:%s, id:%s, uuid: %s", - block->name, type, idstr, nm_setting_connection_get_uuid (s_con)); - - if (!strcmp (NM_SETTING_WIRED_SETTING_NAME, type)) - update_wired_setting_from_if_block (connection, block); - else if (!strcmp (NM_SETTING_WIRELESS_SETTING_NAME, type)) { - update_wireless_setting_from_if_block (connection, block); - update_wireless_security_setting_from_if_block (connection, block); - } - - if (ifparser_haskey(block, "inet6")) - success = update_ip6_setting_from_if_block (connection, block, error); - else - success = update_ip4_setting_from_if_block (connection, block, error); - - if (success == TRUE) - success = nm_connection_verify (connection, error); - - g_free (idstr); - return success; -} diff --git a/src/settings/plugins/ifupdown/parser.h b/src/settings/plugins/ifupdown/parser.h deleted file mode 100644 index 549f1ad3..00000000 --- a/src/settings/plugins/ifupdown/parser.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* NetworkManager system settings service (ifupdown) - * - * Alexander Sack - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Canonical Ltd. - */ - -#ifndef __PARSER_H__ -#define __PARSER_H__ - -#include -#include "interface_parser.h" - -gboolean -ifupdown_update_connection_from_if_block (NMConnection *connection, - if_block *block, - GError **error); - -#endif /* __PARSER_H__ */ diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c deleted file mode 100644 index b506b2d6..00000000 --- a/src/settings/plugins/ifupdown/plugin.c +++ /dev/null @@ -1,561 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* NetworkManager system settings service (ifupdown) - * - * Alexander Sack - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2007,2008 Canonical Ltd. - * (C) Copyright 2009 - 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-setting-connection.h" - -#include "interface_parser.h" - -#include "nm-dbus-interface.h" -#include "nm-settings-plugin.h" -#include "nm-setting-ip4-config.h" -#include "nm-setting-wireless.h" -#include "nm-setting-wired.h" -#include "nm-setting-ppp.h" -#include "nm-utils.h" -#include "nm-core-internal.h" -#include "NetworkManagerUtils.h" - -#include "nm-ifupdown-connection.h" -#include "plugin.h" -#include "parser.h" - -#include "nm-config.h" - -#define ENI_INTERFACES_FILE "/etc/network/interfaces" - -#define IFUPDOWN_PLUGIN_NAME "ifupdown" -#define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd. To report bugs please use the NetworkManager mailing list." - -#define IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT TRUE - -/* #define ALWAYS_UNMANAGE TRUE */ -#ifndef ALWAYS_UNMANAGE -# define ALWAYS_UNMANAGE FALSE -#endif - -typedef struct { - GUdevClient *client; - - GHashTable *connections; /* /e/n/i block name :: NMIfupdownConnection */ - - /* Stores all blocks/interfaces read from /e/n/i regardless of whether - * there is an NMIfupdownConnection for block. - */ - GHashTable *eni_ifaces; - - /* Stores any network interfaces the kernel knows about */ - GHashTable *kernel_ifaces; - - gboolean unmanage_well_known; -} SettingsPluginIfupdownPrivate; - -static void -settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); - -G_DEFINE_TYPE_EXTENDED (SettingsPluginIfupdown, settings_plugin_ifupdown, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_interface_init)) - -#define SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownPrivate)) - -static SettingsPluginIfupdown *settings_plugin_ifupdown_get (void); -NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfupdown, settings_plugin_ifupdown_get, SETTINGS_TYPE_PLUGIN_IFUPDOWN); - -static void -settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class); - -static void -init (NMSettingsPlugin *config); - -/* Returns the plugins currently known list of connections. The returned - * list is freed by the system settings service. - */ -static GSList* -get_connections (NMSettingsPlugin *config); - -/* - * Return a list of device specifications which NetworkManager should not - * manage. Returned list will be freed by the system settings service, and - * each element must be allocated using g_malloc() or its variants. - */ -static GSList* -get_unmanaged_specs (NMSettingsPlugin *config); - - -/* GObject */ -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); - -static void -dispose (GObject *object); - -static void -settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) -{ - plugin_iface->init = init; - plugin_iface->get_connections = get_connections; - plugin_iface->get_unmanaged_specs = get_unmanaged_specs; -} - -static void -settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (SettingsPluginIfupdownPrivate)); - - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_NAME, - NM_SETTINGS_PLUGIN_NAME); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_INFO, - NM_SETTINGS_PLUGIN_INFO); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, - NM_SETTINGS_PLUGIN_CAPABILITIES); -} - -static void -bind_device_to_connection (SettingsPluginIfupdown *self, - GUdevDevice *device, - NMIfupdownConnection *exported) -{ - NMSettingWired *s_wired; - NMSettingWireless *s_wifi; - const char *iface, *address; - - iface = g_udev_device_get_name (device); - if (!iface) { - nm_log_warn (LOGD_SETTINGS, "failed to get ifname for device."); - return; - } - - address = g_udev_device_get_sysfs_attr (device, "address"); - if (!address || !strlen (address)) { - nm_log_warn (LOGD_SETTINGS, "failed to get MAC address for %s", iface); - return; - } - - if (!nm_utils_hwaddr_valid (address, ETH_ALEN)) { - nm_log_warn (LOGD_SETTINGS, "failed to parse MAC address '%s' for %s", - address, iface); - return; - } - - s_wired = nm_connection_get_setting_wired (NM_CONNECTION (exported)); - s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (exported)); - if (s_wired) { - nm_log_info (LOGD_SETTINGS, "locking wired connection setting"); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, address, NULL); - } else if (s_wifi) { - nm_log_info (LOGD_SETTINGS, "locking wireless connection setting"); - g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, address, NULL); - } - - nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL, NULL); -} - -static void -udev_device_added (SettingsPluginIfupdown *self, GUdevDevice *device) -{ - SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); - const char *iface, *path; - NMIfupdownConnection *exported; - - iface = g_udev_device_get_name (device); - path = g_udev_device_get_sysfs_path (device); - if (!iface || !path) - return; - - nm_log_info (LOGD_SETTINGS, "devices added (path: %s, iface: %s)", path, iface); - - /* if we have a configured connection for this particular iface - * we want to either unmanage the device or lock it - */ - exported = g_hash_table_lookup (priv->connections, iface); - if (!exported && !g_hash_table_lookup (priv->eni_ifaces, iface)) { - nm_log_info (LOGD_SETTINGS, "device added (path: %s, iface: %s): no ifupdown configuration found.", - path, iface); - return; - } - - g_hash_table_insert (priv->kernel_ifaces, g_strdup (iface), g_object_ref (device)); - - if (exported) - bind_device_to_connection (self, device, exported); - - if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); -} - -static void -udev_device_removed (SettingsPluginIfupdown *self, GUdevDevice *device) -{ - SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); - const char *iface, *path; - - iface = g_udev_device_get_name (device); - path = g_udev_device_get_sysfs_path (device); - if (!iface || !path) - return; - - nm_log_info (LOGD_SETTINGS, "devices removed (path: %s, iface: %s)", path, iface); - - if (!g_hash_table_remove (priv->kernel_ifaces, iface)) - return; - - if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); -} - -static void -udev_device_changed (SettingsPluginIfupdown *self, GUdevDevice *device) -{ - SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); - const char *iface, *path; - - iface = g_udev_device_get_name (device); - path = g_udev_device_get_sysfs_path (device); - if (!iface || !path) - return; - - nm_log_info (LOGD_SETTINGS, "device changed (path: %s, iface: %s)", path, iface); - - if (!g_hash_table_lookup (priv->kernel_ifaces, iface)) - return; - - if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); -} - -static void -handle_uevent (GUdevClient *client, - const char *action, - GUdevDevice *device, - gpointer user_data) -{ - SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (user_data); - const char *subsys; - - g_return_if_fail (action != NULL); - - /* A bit paranoid */ - subsys = g_udev_device_get_subsystem (device); - g_return_if_fail (subsys != NULL); - g_return_if_fail (strcmp (subsys, "net") == 0); - - if (!strcmp (action, "add")) - udev_device_added (self, device); - else if (!strcmp (action, "remove")) - udev_device_removed (self, device); - else if (!strcmp (action, "change")) - udev_device_changed (self, device); -} - -static void -init (NMSettingsPlugin *config) -{ - SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (config); - SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); - GHashTable *auto_ifaces; - if_block *block = NULL; - GList *keys, *iter; - GHashTableIter con_iter; - const char *block_name; - NMIfupdownConnection *connection; - const char *subsys[2] = { "net", NULL }; - - auto_ifaces = g_hash_table_new (g_str_hash, g_str_equal); - - if(!priv->connections) - priv->connections = g_hash_table_new (g_str_hash, g_str_equal); - - if(!priv->kernel_ifaces) - priv->kernel_ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - - if(!priv->eni_ifaces) - priv->eni_ifaces = g_hash_table_new (g_str_hash, g_str_equal); - - nm_log_info (LOGD_SETTINGS, "init!"); - - priv->client = g_udev_client_new (subsys); - if (!priv->client) { - nm_log_warn (LOGD_SETTINGS, " error initializing libgudev"); - } else - g_signal_connect (priv->client, "uevent", G_CALLBACK (handle_uevent), self); - - /* Read in all the interfaces */ - ifparser_init (ENI_INTERFACES_FILE, 0); - block = ifparser_getfirst (); - while (block) { - if(!strcmp ("auto", block->type) || !strcmp ("allow-hotplug", block->type)) - g_hash_table_insert (auto_ifaces, block->name, GUINT_TO_POINTER (1)); - else if (!strcmp ("iface", block->type)) { - NMIfupdownConnection *exported; - - /* Bridge configuration */ - if(!strncmp ("br", block->name, 2)) { - /* Try to find bridge ports */ - const char *ports = ifparser_getkey (block, "bridge-ports"); - if (ports) { - int i; - int state = 0; - char **port_ifaces; - - nm_log_info (LOGD_SETTINGS, "found bridge ports %s for %s", ports, block->name); - - port_ifaces = g_strsplit_set (ports, " \t", -1); - for (i = 0; i < g_strv_length (port_ifaces); i++) { - char *token = port_ifaces[i]; - /* Skip crazy stuff like regex or all */ - if (!strcmp ("all", token)) { - continue; - } - /* Small SM to skip everything inside regex */ - if (!strcmp ("regex", token)) { - state++; - continue; - } - if (!strcmp ("noregex", token)) { - state--; - continue; - } - if (state == 0 && strlen (token) > 0) { - nm_log_info (LOGD_SETTINGS, "adding bridge port %s to eni_ifaces", token); - g_hash_table_insert (priv->eni_ifaces, g_strdup (token), "known"); - } - } - g_strfreev (port_ifaces); - } - goto next; - } - - /* Skip loopback configuration */ - if(!strcmp ("lo", block->name)) { - goto next; - } - - /* Remove any connection for this block that was previously found */ - exported = g_hash_table_lookup (priv->connections, block->name); - if (exported) { - nm_log_info (LOGD_SETTINGS, "deleting %s from connections", block->name); - nm_settings_connection_delete (NM_SETTINGS_CONNECTION (exported), NULL, NULL); - g_hash_table_remove (priv->connections, block->name); - } - - /* add the new connection */ - exported = nm_ifupdown_connection_new (block); - if (exported) { - nm_log_info (LOGD_SETTINGS, "adding %s to connections", block->name); - g_hash_table_insert (priv->connections, block->name, exported); - } - nm_log_info (LOGD_SETTINGS, "adding iface %s to eni_ifaces", block->name); - g_hash_table_insert (priv->eni_ifaces, block->name, "known"); - } else if (!strcmp ("mapping", block->type)) { - g_hash_table_insert (priv->eni_ifaces, block->name, "known"); - nm_log_info (LOGD_SETTINGS, "adding mapping %s to eni_ifaces", block->name); - } - next: - block = block->next; - } - - /* Make 'auto' interfaces autoconnect=TRUE */ - g_hash_table_iter_init (&con_iter, priv->connections); - while (g_hash_table_iter_next (&con_iter, (gpointer) &block_name, (gpointer) &connection)) { - NMSettingConnection *setting; - - if (g_hash_table_lookup (auto_ifaces, block_name)) { - setting = nm_connection_get_setting_connection (NM_CONNECTION (connection)); - g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL); - nm_log_info (LOGD_SETTINGS, "autoconnect"); - } - } - g_hash_table_destroy (auto_ifaces); - - /* Check the config file to find out whether to manage interfaces */ - priv->unmanage_well_known = !nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG, - NM_CONFIG_KEYFILE_GROUP_IFUPDOWN, - NM_CONFIG_KEYFILE_KEY_IFUPDOWN_MANAGED, - !IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT); - nm_log_info (LOGD_SETTINGS, "management mode: %s", priv->unmanage_well_known ? "unmanaged" : "managed"); - - /* Add well-known interfaces */ - keys = g_udev_client_query_by_subsystem (priv->client, "net"); - for (iter = keys; iter; iter = g_list_next (iter)) { - udev_device_added (self, G_UDEV_DEVICE (iter->data)); - g_object_unref (G_UDEV_DEVICE (iter->data)); - } - g_list_free (keys); - - /* Now if we're running in managed mode, let NM know there are new connections */ - if (!priv->unmanage_well_known) { - GList *con_list = g_hash_table_get_values (priv->connections); - GList *cl_iter; - - for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) { - g_signal_emit_by_name (self, - NM_SETTINGS_PLUGIN_CONNECTION_ADDED, - NM_SETTINGS_CONNECTION (cl_iter->data)); - } - g_list_free (con_list); - } - - nm_log_info (LOGD_SETTINGS, "end _init."); -} - - -/* Returns the plugins currently known list of connections. The returned - * list is freed by the system settings service. - */ -static GSList* -get_connections (NMSettingsPlugin *config) -{ - SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - GSList *connections; - - nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections.", GPOINTER_TO_UINT(config)); - - if(priv->unmanage_well_known) { - nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections (managed=false): return empty list.", GPOINTER_TO_UINT(config)); - return NULL; - } - - connections = _nm_utils_hash_values_to_slist (priv->connections); - - nm_log_info (LOGD_SETTINGS, "(%d) connections count: %d", GPOINTER_TO_UINT(config), g_slist_length(connections)); - return connections; -} - -/* - * Return a list of device specifications which NetworkManager should not - * manage. Returned list will be freed by the system settings service, and - * each element must be allocated using g_malloc() or its variants. - */ -static GSList* -get_unmanaged_specs (NMSettingsPlugin *config) -{ - SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - GSList *specs = NULL; - GHashTableIter iter; - GUdevDevice *device; - const char *iface; - - if (!ALWAYS_UNMANAGE && !priv->unmanage_well_known) - return NULL; - - nm_log_info (LOGD_SETTINGS, "get unmanaged devices count: %d", - g_hash_table_size (priv->kernel_ifaces)); - - g_hash_table_iter_init (&iter, priv->kernel_ifaces); - while (g_hash_table_iter_next (&iter, (gpointer) &iface, (gpointer) &device)) { - const char *address; - - address = g_udev_device_get_sysfs_attr (device, "address"); - if (address) - specs = g_slist_append (specs, g_strdup_printf ("mac:%s", address)); - else - specs = g_slist_append (specs, g_strdup_printf ("interface-name:%s", iface)); - } - return specs; -} - -static void -settings_plugin_ifupdown_init (SettingsPluginIfupdown *plugin) -{ -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, IFUPDOWN_PLUGIN_NAME); - break; - case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, IFUPDOWN_PLUGIN_INFO); - break; - case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_NONE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - SettingsPluginIfupdown *plugin = SETTINGS_PLUGIN_IFUPDOWN (object); - SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (plugin); - - if (priv->kernel_ifaces) - g_hash_table_destroy(priv->kernel_ifaces); - - if (priv->eni_ifaces) - g_hash_table_destroy(priv->eni_ifaces); - - if (priv->client) - g_object_unref (priv->client); - - - G_OBJECT_CLASS (settings_plugin_ifupdown_parent_class)->dispose (object); -} - -G_MODULE_EXPORT GObject * -nm_settings_plugin_factory (void) -{ - return g_object_ref (settings_plugin_ifupdown_get ()); -} - diff --git a/src/settings/plugins/ifupdown/plugin.h b/src/settings/plugins/ifupdown/plugin.h deleted file mode 100644 index b568ea78..00000000 --- a/src/settings/plugins/ifupdown/plugin.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* NetworkManager system settings service (ifupdown) - * - * Alexander Sack - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Canonical Ltd. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#define PLUGIN_NAME "ifupdown" - -#define SETTINGS_TYPE_PLUGIN_IFUPDOWN (settings_plugin_ifupdown_get_type ()) -#define SETTINGS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdown)) -#define SETTINGS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownClass)) -#define SETTINGS_IS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN)) -#define SETTINGS_IS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFUPDOWN)) -#define SETTINGS_PLUGIN_IFUPDOWN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownClass)) - -typedef struct _SettingsPluginIfupdown SettingsPluginIfupdown; -typedef struct _SettingsPluginIfupdownClass SettingsPluginIfupdownClass; - -struct _SettingsPluginIfupdown { - GObject parent; -}; - -struct _SettingsPluginIfupdownClass { - GObjectClass parent; -}; - -GType settings_plugin_ifupdown_get_type (void); - -#endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ifupdown/tests/Makefile.am b/src/settings/plugins/ifupdown/tests/Makefile.am deleted file mode 100644 index 3d702375..00000000 --- a/src/settings/plugins/ifupdown/tests/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -if ENABLE_TESTS - -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(srcdir)/../ \ - -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DTEST_ENI_DIR=\"$(abs_srcdir)\" - -noinst_PROGRAMS = test-ifupdown - -test_ifupdown_SOURCES = \ - test-ifupdown.c \ - ../interface_parser.c \ - ../parser.c - -test_ifupdown_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-ifupdown - -check-local: - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifupdown.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - -EXTRA_DIST = \ - test1 test2 test3 test4 test5 test6 test7 test8 test9 test11 test12 \ - test13 test14 test15 test16 test17-wired-static-verify-ip4 \ - test18-wired-static-verify-ip6 test19-wired-static-verify-ip4-plen \ - test20-source-stanza test20-source-stanza.eth0 test20-source-stanza.eth1 \ - test21-source-dir-stanza test21-source-dir-stanza.d diff --git a/src/settings/plugins/ifupdown/tests/Makefile.in b/src/settings/plugins/ifupdown/tests/Makefile.in deleted file mode 100644 index b3be79e1..00000000 --- a/src/settings/plugins/ifupdown/tests/Makefile.in +++ /dev/null @@ -1,1188 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-ifupdown$(EXEEXT) -@ENABLE_TESTS_TRUE@TESTS = test-ifupdown$(EXEEXT) -subdir = src/settings/plugins/ifupdown/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am__test_ifupdown_SOURCES_DIST = test-ifupdown.c ../interface_parser.c \ - ../parser.c -@ENABLE_TESTS_TRUE@am_test_ifupdown_OBJECTS = test-ifupdown.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ interface_parser.$(OBJEXT) parser.$(OBJEXT) -test_ifupdown_OBJECTS = $(am_test_ifupdown_OBJECTS) -@ENABLE_TESTS_TRUE@test_ifupdown_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_ifupdown_SOURCES) -DIST_SOURCES = $(am__test_ifupdown_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ -@ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -@ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -DTEST_ENI_DIR=\"$(abs_srcdir)\" - -@ENABLE_TESTS_TRUE@test_ifupdown_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-ifupdown.c \ -@ENABLE_TESTS_TRUE@ ../interface_parser.c \ -@ENABLE_TESTS_TRUE@ ../parser.c - -@ENABLE_TESTS_TRUE@test_ifupdown_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la - -EXTRA_DIST = \ - test1 test2 test3 test4 test5 test6 test7 test8 test9 test11 test12 \ - test13 test14 test15 test16 test17-wired-static-verify-ip4 \ - test18-wired-static-verify-ip6 test19-wired-static-verify-ip4-plen \ - test20-source-stanza test20-source-stanza.eth0 test20-source-stanza.eth1 \ - test21-source-dir-stanza test21-source-dir-stanza.d - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifupdown/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifupdown/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-ifupdown$(EXEEXT): $(test_ifupdown_OBJECTS) $(test_ifupdown_DEPENDENCIES) $(EXTRA_test_ifupdown_DEPENDENCIES) - @rm -f test-ifupdown$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ifupdown_OBJECTS) $(test_ifupdown_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface_parser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifupdown.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -interface_parser.o: ../interface_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interface_parser.o -MD -MP -MF $(DEPDIR)/interface_parser.Tpo -c -o interface_parser.o `test -f '../interface_parser.c' || echo '$(srcdir)/'`../interface_parser.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/interface_parser.Tpo $(DEPDIR)/interface_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../interface_parser.c' object='interface_parser.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interface_parser.o `test -f '../interface_parser.c' || echo '$(srcdir)/'`../interface_parser.c - -interface_parser.obj: ../interface_parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interface_parser.obj -MD -MP -MF $(DEPDIR)/interface_parser.Tpo -c -o interface_parser.obj `if test -f '../interface_parser.c'; then $(CYGPATH_W) '../interface_parser.c'; else $(CYGPATH_W) '$(srcdir)/../interface_parser.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/interface_parser.Tpo $(DEPDIR)/interface_parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../interface_parser.c' object='interface_parser.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interface_parser.obj `if test -f '../interface_parser.c'; then $(CYGPATH_W) '../interface_parser.c'; else $(CYGPATH_W) '$(srcdir)/../interface_parser.c'; fi` - -parser.o: ../parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parser.o -MD -MP -MF $(DEPDIR)/parser.Tpo -c -o parser.o `test -f '../parser.c' || echo '$(srcdir)/'`../parser.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/parser.Tpo $(DEPDIR)/parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../parser.c' object='parser.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o parser.o `test -f '../parser.c' || echo '$(srcdir)/'`../parser.c - -parser.obj: ../parser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parser.obj -MD -MP -MF $(DEPDIR)/parser.Tpo -c -o parser.obj `if test -f '../parser.c'; then $(CYGPATH_W) '../parser.c'; else $(CYGPATH_W) '$(srcdir)/../parser.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/parser.Tpo $(DEPDIR)/parser.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../parser.c' object='parser.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o parser.obj `if test -f '../parser.c'; then $(CYGPATH_W) '../parser.c'; else $(CYGPATH_W) '$(srcdir)/../parser.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-ifupdown.log: test-ifupdown$(EXEEXT) - @p='test-ifupdown$(EXEEXT)'; \ - b='test-ifupdown'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am \ - check-local clean clean-generic clean-libtool \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am recheck tags tags-am uninstall \ - uninstall-am - -.PRECIOUS: Makefile - - -@ENABLE_TESTS_TRUE@@VALGRIND_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifupdown.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 11b42c71..d037b8a6 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -23,8 +23,9 @@ #include #include "nm-core-internal.h" -#include "interface_parser.h" -#include "parser.h" + +#include "settings/plugins/ifupdown/nms-ifupdown-interface-parser.h" +#include "settings/plugins/ifupdown/nms-ifupdown-parser.h" #include "nm-test-utils-core.h" diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am deleted file mode 100644 index 08119dae..00000000 --- a/src/settings/plugins/keyfile/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -SUBDIRS = . tests - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DNMCONFDIR=\"$(nmconfdir)\" - -noinst_LTLIBRARIES = \ - libkeyfile-io.la \ - libnm-settings-plugin-keyfile.la - -##### I/O library for testcases ##### - -libkeyfile_io_la_SOURCES = \ - reader.c \ - reader.h \ - writer.c \ - writer.h \ - utils.c \ - utils.h - -libkeyfile_io_la_LIBADD = $(GLIB_LIBS) - -##################################### - -libnm_settings_plugin_keyfile_la_SOURCES = \ - nm-keyfile-connection.c \ - nm-keyfile-connection.h \ - plugin.c \ - plugin.h - -libnm_settings_plugin_keyfile_la_LIBADD = \ - libkeyfile-io.la - -keyfiledir=$(sysconfdir)/NetworkManager/system-connections - -install-data-hook: - $(mkinstalldirs) -m 0755 $(DESTDIR)$(keyfiledir) - diff --git a/src/settings/plugins/keyfile/Makefile.in b/src/settings/plugins/keyfile/Makefile.in deleted file mode 100644 index 085dfdd5..00000000 --- a/src/settings/plugins/keyfile/Makefile.in +++ /dev/null @@ -1,925 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/keyfile -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LTLIBRARIES = $(noinst_LTLIBRARIES) -am__DEPENDENCIES_1 = -libkeyfile_io_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_libkeyfile_io_la_OBJECTS = reader.lo writer.lo utils.lo -libkeyfile_io_la_OBJECTS = $(am_libkeyfile_io_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_keyfile_la_DEPENDENCIES = libkeyfile-io.la -am_libnm_settings_plugin_keyfile_la_OBJECTS = \ - nm-keyfile-connection.lo plugin.lo -libnm_settings_plugin_keyfile_la_OBJECTS = \ - $(am_libnm_settings_plugin_keyfile_la_OBJECTS) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libkeyfile_io_la_SOURCES) \ - $(libnm_settings_plugin_keyfile_la_SOURCES) -DIST_SOURCES = $(libkeyfile_io_la_SOURCES) \ - $(libnm_settings_plugin_keyfile_la_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = . tests -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DNMCONFDIR=\"$(nmconfdir)\" - -noinst_LTLIBRARIES = \ - libkeyfile-io.la \ - libnm-settings-plugin-keyfile.la - - -##### I/O library for testcases ##### -libkeyfile_io_la_SOURCES = \ - reader.c \ - reader.h \ - writer.c \ - writer.h \ - utils.c \ - utils.h - -libkeyfile_io_la_LIBADD = $(GLIB_LIBS) - -##################################### -libnm_settings_plugin_keyfile_la_SOURCES = \ - nm-keyfile-connection.c \ - nm-keyfile-connection.h \ - plugin.c \ - plugin.h - -libnm_settings_plugin_keyfile_la_LIBADD = \ - libkeyfile-io.la - -keyfiledir = $(sysconfdir)/NetworkManager/system-connections -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/keyfile/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/keyfile/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libkeyfile-io.la: $(libkeyfile_io_la_OBJECTS) $(libkeyfile_io_la_DEPENDENCIES) $(EXTRA_libkeyfile_io_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libkeyfile_io_la_OBJECTS) $(libkeyfile_io_la_LIBADD) $(LIBS) - -libnm-settings-plugin-keyfile.la: $(libnm_settings_plugin_keyfile_la_OBJECTS) $(libnm_settings_plugin_keyfile_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_keyfile_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libnm_settings_plugin_keyfile_la_OBJECTS) $(libnm_settings_plugin_keyfile_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-keyfile-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile $(LTLIBRARIES) -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - @$(NORMAL_INSTALL) - $(MAKE) $(AM_MAKEFLAGS) install-data-hook -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) install-am install-data-am \ - install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool \ - clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am \ - install-data-hook install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -install-data-hook: - $(mkinstalldirs) -m 0755 $(DESTDIR)$(keyfiledir) - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c deleted file mode 100644 index 97a5ee4c..00000000 --- a/src/settings/plugins/keyfile/nm-keyfile-connection.c +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2012 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-dbus-interface.h" -#include "nm-setting-connection.h" -#include "nm-utils.h" - -#include "nm-settings-plugin.h" -#include "nm-keyfile-connection.h" -#include "reader.h" -#include "writer.h" -#include "utils.h" - -G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION) - -NMKeyfileConnection * -nm_keyfile_connection_new (NMConnection *source, - const char *full_path, - GError **error) -{ - GObject *object; - NMConnection *tmp; - const char *uuid; - gboolean update_unsaved = TRUE; - - g_assert (source || full_path); - - /* If we're given a connection already, prefer that instead of re-reading */ - if (source) - tmp = g_object_ref (source); - else { - tmp = nm_keyfile_plugin_connection_from_file (full_path, error); - if (!tmp) - return NULL; - - uuid = nm_connection_get_uuid (NM_CONNECTION (tmp)); - if (!uuid) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Connection in file %s had no UUID", full_path); - g_object_unref (tmp); - return NULL; - } - - /* If we just read the connection from disk, it's clearly not Unsaved */ - update_unsaved = FALSE; - } - - object = (GObject *) g_object_new (NM_TYPE_KEYFILE_CONNECTION, - NM_SETTINGS_CONNECTION_FILENAME, full_path, - NULL); - - /* Update our settings with what was read from the file */ - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - update_unsaved, - NULL, - error)) { - g_object_unref (object); - object = NULL; - } - - g_object_unref (tmp); - return (NMKeyfileConnection *) object; -} - -static void -commit_changes (NMSettingsConnection *connection, - NMSettingsConnectionCommitReason commit_reason, - NMSettingsConnectionCommitFunc callback, - gpointer user_data) -{ - char *path = NULL; - GError *error = NULL; - - if (!nm_keyfile_plugin_write_connection (NM_CONNECTION (connection), - nm_settings_connection_get_filename (connection), - NM_FLAGS_ALL (commit_reason, NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION - | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED), - &path, - &error)) { - callback (connection, error, user_data); - g_clear_error (&error); - return; - } - - /* Update the filename if it changed */ - if ( path - && g_strcmp0 (path, nm_settings_connection_get_filename (connection)) != 0) { - gs_free char *old_path = g_strdup (nm_settings_connection_get_filename (connection)); - - nm_settings_connection_set_filename (connection, path); - if (old_path) { - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"", - NM_KEYFILE_CONNECTION_LOG_ARG (connection), - old_path); - } else { - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and persist connection", - NM_KEYFILE_CONNECTION_LOG_ARG (connection)); - } - } else { - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT, - NM_KEYFILE_CONNECTION_LOG_ARG (connection)); - } - - g_free (path); - - NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection, - commit_reason, - callback, - user_data); -} - -static void -do_delete (NMSettingsConnection *connection, - NMSettingsConnectionDeleteFunc callback, - gpointer user_data) -{ - const char *path; - - path = nm_settings_connection_get_filename (connection); - if (path) - g_unlink (path); - - NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->delete (connection, - callback, - user_data); -} - -/* GObject */ - -static void -nm_keyfile_connection_init (NMKeyfileConnection *connection) -{ -} - -static void -nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class) -{ - NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (keyfile_connection_class); - - /* Virtual methods */ - settings_class->commit_changes = commit_changes; - settings_class->delete = do_delete; -} diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.h b/src/settings/plugins/keyfile/nm-keyfile-connection.h deleted file mode 100644 index 31dbe754..00000000 --- a/src/settings/plugins/keyfile/nm-keyfile-connection.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2012 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_KEYFILE_CONNECTION_H__ -#define __NETWORKMANAGER_KEYFILE_CONNECTION_H__ - -#include - -#define NM_TYPE_KEYFILE_CONNECTION (nm_keyfile_connection_get_type ()) -#define NM_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnection)) -#define NM_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionClass)) -#define NM_IS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_KEYFILE_CONNECTION)) -#define NM_IS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_KEYFILE_CONNECTION)) -#define NM_KEYFILE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionClass)) - -typedef struct { - NMSettingsConnection parent; -} NMKeyfileConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMKeyfileConnectionClass; - -GType nm_keyfile_connection_get_type (void); - -NMKeyfileConnection *nm_keyfile_connection_new (NMConnection *source, - const char *filename, - GError **error); - -#endif /* __NETWORKMANAGER_KEYFILE_CONNECTION_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-connection.c b/src/settings/plugins/keyfile/nms-keyfile-connection.c new file mode 100644 index 00000000..ff654acf --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-connection.c @@ -0,0 +1,180 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2012 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-keyfile-connection.h" + +#include +#include + +#include "nm-dbus-interface.h" +#include "nm-setting-connection.h" +#include "nm-utils.h" + +#include "settings/nm-settings-plugin.h" + +#include "nms-keyfile-reader.h" +#include "nms-keyfile-writer.h" +#include "nms-keyfile-utils.h" + +/*****************************************************************************/ + +struct _NMSKeyfileConnection { + NMSettingsConnection parent; +}; + +struct _NMSKeyfileConnectionClass { + NMSettingsConnectionClass parent; +}; + +G_DEFINE_TYPE (NMSKeyfileConnection, nms_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION) + +/*****************************************************************************/ + +static void +commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, + NMSettingsConnectionCommitFunc callback, + gpointer user_data) +{ + char *path = NULL; + GError *error = NULL; + + if (!nms_keyfile_writer_connection (NM_CONNECTION (connection), + nm_settings_connection_get_filename (connection), + NM_FLAGS_ALL (commit_reason, NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION + | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED), + &path, + &error)) { + callback (connection, error, user_data); + g_clear_error (&error); + return; + } + + /* Update the filename if it changed */ + if ( path + && g_strcmp0 (path, nm_settings_connection_get_filename (connection)) != 0) { + gs_free char *old_path = g_strdup (nm_settings_connection_get_filename (connection)); + + nm_settings_connection_set_filename (connection, path); + if (old_path) { + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"", + NMS_KEYFILE_CONNECTION_LOG_ARG (connection), + old_path); + } else { + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT" and persist connection", + NMS_KEYFILE_CONNECTION_LOG_ARG (connection)); + } + } else { + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT, + NMS_KEYFILE_CONNECTION_LOG_ARG (connection)); + } + + g_free (path); + + NM_SETTINGS_CONNECTION_CLASS (nms_keyfile_connection_parent_class)->commit_changes (connection, + commit_reason, + callback, + user_data); +} + +static void +do_delete (NMSettingsConnection *connection, + NMSettingsConnectionDeleteFunc callback, + gpointer user_data) +{ + const char *path; + + path = nm_settings_connection_get_filename (connection); + if (path) + g_unlink (path); + + NM_SETTINGS_CONNECTION_CLASS (nms_keyfile_connection_parent_class)->delete (connection, + callback, + user_data); +} + +/*****************************************************************************/ + +static void +nms_keyfile_connection_init (NMSKeyfileConnection *connection) +{ +} + +NMSKeyfileConnection * +nms_keyfile_connection_new (NMConnection *source, + const char *full_path, + GError **error) +{ + GObject *object; + NMConnection *tmp; + const char *uuid; + gboolean update_unsaved = TRUE; + + g_assert (source || full_path); + + /* If we're given a connection already, prefer that instead of re-reading */ + if (source) + tmp = g_object_ref (source); + else { + tmp = nms_keyfile_reader_from_file (full_path, error); + if (!tmp) + return NULL; + + uuid = nm_connection_get_uuid (NM_CONNECTION (tmp)); + if (!uuid) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Connection in file %s had no UUID", full_path); + g_object_unref (tmp); + return NULL; + } + + /* If we just read the connection from disk, it's clearly not Unsaved */ + update_unsaved = FALSE; + } + + object = (GObject *) g_object_new (NMS_TYPE_KEYFILE_CONNECTION, + NM_SETTINGS_CONNECTION_FILENAME, full_path, + NULL); + + /* Update our settings with what was read from the file */ + if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), + tmp, + update_unsaved, + NULL, + error)) { + g_object_unref (object); + object = NULL; + } + + g_object_unref (tmp); + return (NMSKeyfileConnection *) object; +} + +static void +nms_keyfile_connection_class_init (NMSKeyfileConnectionClass *keyfile_connection_class) +{ + NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (keyfile_connection_class); + + settings_class->commit_changes = commit_changes; + settings_class->delete = do_delete; +} diff --git a/src/settings/plugins/keyfile/nms-keyfile-connection.h b/src/settings/plugins/keyfile/nms-keyfile-connection.h new file mode 100644 index 00000000..f96d7590 --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-connection.h @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2012 Red Hat, Inc. + */ + +#ifndef __NMS_KEYFILE_CONNECTION_H__ +#define __NMS_KEYFILE_CONNECTION_H__ + +#include "settings/nm-settings-connection.h" + +#define NMS_TYPE_KEYFILE_CONNECTION (nms_keyfile_connection_get_type ()) +#define NMS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnection)) +#define NMS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnectionClass)) +#define NMS_IS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_KEYFILE_CONNECTION)) +#define NMS_IS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_KEYFILE_CONNECTION)) +#define NMS_KEYFILE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnectionClass)) + +typedef struct _NMSKeyfileConnection NMSKeyfileConnection; +typedef struct _NMSKeyfileConnectionClass NMSKeyfileConnectionClass; + +GType nms_keyfile_connection_get_type (void); + +NMSKeyfileConnection *nms_keyfile_connection_new (NMConnection *source, + const char *filename, + GError **error); + +#endif /* __NMS_KEYFILE_CONNECTION_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/settings/plugins/keyfile/nms-keyfile-plugin.c new file mode 100644 index 00000000..97306d66 --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.c @@ -0,0 +1,662 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2013 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-keyfile-plugin.h" + +#include +#include +#include +#include + +#include + +#include "nm-connection.h" +#include "nm-setting.h" +#include "nm-setting-connection.h" +#include "nm-utils.h" +#include "nm-config.h" +#include "nm-core-internal.h" + +#include "settings/nm-settings-plugin.h" + +#include "nms-keyfile-connection.h" +#include "nms-keyfile-writer.h" +#include "nms-keyfile-utils.h" + +/*****************************************************************************/ + +typedef struct { + GHashTable *connections; /* uuid::connection */ + + gboolean initialized; + GFileMonitor *monitor; + gulong monitor_id; + + NMConfig *config; +} NMSKeyfilePluginPrivate; + +struct _NMSKeyfilePlugin { + GObject parent; + NMSKeyfilePluginPrivate _priv; +}; + +struct _NMSKeyfilePluginClass { + GObjectClass parent; +}; + +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); + +G_DEFINE_TYPE_EXTENDED (NMSKeyfilePlugin, nms_keyfile_plugin, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) + +#define NMS_KEYFILE_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSKeyfilePlugin, NMS_IS_KEYFILE_PLUGIN) + +/*****************************************************************************/ + +#define _NMLOG_PREFIX_NAME "keyfile" +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG(level, ...) \ + nm_log ((level), _NMLOG_DOMAIN, \ + "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + _NMLOG_PREFIX_NAME": " \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)) + +/*****************************************************************************/ + +static void +connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) +{ + g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) user_data)->connections, + nm_connection_get_uuid (NM_CONNECTION (obj))); +} + +/* Monitoring */ + +static void +remove_connection (NMSKeyfilePlugin *self, NMSKeyfileConnection *connection) +{ + gboolean removed; + + g_return_if_fail (connection != NULL); + + _LOGI ("removed " NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection)); + + /* Removing from the hash table should drop the last reference */ + g_object_ref (connection); + g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self); + removed = g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE (self)->connections, + nm_connection_get_uuid (NM_CONNECTION (connection))); + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection), FALSE); + g_object_unref (connection); + + g_return_if_fail (removed); +} + +static NMSKeyfileConnection * +find_by_path (NMSKeyfilePlugin *self, const char *path) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self); + GHashTableIter iter; + NMSettingsConnection *candidate = NULL; + + g_return_val_if_fail (path != NULL, NULL); + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { + if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0) + return NMS_KEYFILE_CONNECTION (candidate); + } + return NULL; +} + +/* update_connection: + * @self: the plugin instance + * @source: if %NULL, this re-reads the connection from @full_path + * and updates it. When passing @source, this adds a connection from + * memory. + * @full_path: the filename of the keyfile to be loaded + * @connection: an existing connection that might be updated. + * If given, @connection must be an existing connection that is currently + * owned by the plugin. + * @protect_existing_connection: if %TRUE, and !@connection, we don't allow updating + * an existing connection with the same UUID. + * If %TRUE and @connection, allow updating only if the reload would modify + * @connection (without changing its UUID) or if we would create a new connection. + * In other words, if this paramter is %TRUE, we only allow creating a + * new connection (with an unseen UUID) or updating the passed in @connection + * (whereas the UUID cannot change). + * Note, that this allows for @connection to be replaced by a new connection. + * @protected_connections: (allow-none): if given, we only update an + * existing connection if it is not contained in this hash. + * @error: error in case of failure + * + * Loads a connection from file @full_path. This can both be used to + * load a connection initially or to update an existing connection. + * + * If you pass in an existing connection and the reloaded file happens + * to have a different UUID, the connection is deleted. + * Beware, that means that after the function, you have a dangling pointer + * if the returned connection is different from @connection. + * + * Returns: the updated connection. + * */ +static NMSKeyfileConnection * +update_connection (NMSKeyfilePlugin *self, + NMConnection *source, + const char *full_path, + NMSKeyfileConnection *connection, + gboolean protect_existing_connection, + GHashTable *protected_connections, + GError **error) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self); + NMSKeyfileConnection *connection_new; + NMSKeyfileConnection *connection_by_uuid; + GError *local = NULL; + const char *uuid; + + g_return_val_if_fail (!source || NM_IS_CONNECTION (source), NULL); + g_return_val_if_fail (full_path || source, NULL); + + if (full_path) + _LOGD ("loading from file \"%s\"...", full_path); + + connection_new = nms_keyfile_connection_new (source, full_path, &local); + if (!connection_new) { + /* Error; remove the connection */ + if (source) + _LOGW ("error creating connection %s: %s", nm_connection_get_uuid (source), local->message); + else + _LOGW ("error loading connection from file %s: %s", full_path, local->message); + if ( connection + && !protect_existing_connection + && (!protected_connections || !g_hash_table_contains (protected_connections, connection))) + remove_connection (self, connection); + g_propagate_error (error, local); + return NULL; + } + + uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new)); + connection_by_uuid = g_hash_table_lookup (priv->connections, uuid); + + if ( connection + && connection != connection_by_uuid) { + + if ( (protect_existing_connection && connection_by_uuid != NULL) + || (protected_connections && g_hash_table_contains (protected_connections, connection))) { + NMSKeyfileConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection; + + if (source) + _LOGW ("cannot update protected "NMS_KEYFILE_CONNECTION_LOG_FMT" connection due to conflicting UUID %s", NMS_KEYFILE_CONNECTION_LOG_ARG (conflicting), uuid); + else + _LOGW ("cannot load %s due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, full_path, NMS_KEYFILE_CONNECTION_LOG_ARG (conflicting)); + g_object_unref (connection_new); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Cannot update protected connection due to conflicting UUID"); + return NULL; + } + + /* The new connection has a different UUID then the original one. + * Remove @connection. */ + remove_connection (self, connection); + } + + if ( connection_by_uuid + && ( (!connection && protect_existing_connection) + || (protected_connections && g_hash_table_contains (protected_connections, connection_by_uuid)))) { + if (source) + _LOGW ("cannot update connection due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); + else + _LOGW ("cannot load %s due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, full_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); + g_object_unref (connection_new); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Skip updating protected connection during reload"); + return NULL; + } + + if (connection_by_uuid) { + const char *old_path; + + old_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)); + + if (nm_connection_compare (NM_CONNECTION (connection_by_uuid), + NM_CONNECTION (connection_new), + NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | + NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { + /* Nothing to do... except updating the path. */ + if (old_path && g_strcmp0 (old_path, full_path) != 0) + _LOGI ("rename \"%s\" to "NMS_KEYFILE_CONNECTION_LOG_FMT" without other changes", old_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + } else { + /* An existing connection changed. */ + if (source) + _LOGI ("update "NMS_KEYFILE_CONNECTION_LOG_FMT" from %s", NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new), NMS_KEYFILE_CONNECTION_LOG_PATH (old_path)); + else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new)))) + _LOGI ("update "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + else if (old_path) + _LOGI ("rename \"%s\" to "NMS_KEYFILE_CONNECTION_LOG_FMT, old_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + else + _LOGI ("update and persist "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + + if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid), + NM_CONNECTION (connection_new), + FALSE, /* don't set Unsaved */ + "keyfile-update", + &local)) { + /* Shouldn't ever get here as 'connection_new' was verified by the reader already + * and the UUID did not change. */ + g_assert_not_reached (); + } + g_assert_no_error (local); + } + nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (connection_by_uuid), full_path); + g_object_unref (connection_new); + return connection_by_uuid; + } else { + if (source) + _LOGI ("add connection "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + else + _LOGI ("new connection "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + g_hash_table_insert (priv->connections, g_strdup (uuid), connection_new); + + g_signal_connect (connection_new, NM_SETTINGS_CONNECTION_REMOVED, + G_CALLBACK (connection_removed_cb), + self); + + if (!source) { + /* Only raise the signal if we were called without source, i.e. if we read the connection from file. + * Otherwise, we were called by add_connection() which does not expect the signal. */ + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); + } + return connection_new; + } +} + +static void +dir_changed (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type, + gpointer user_data) +{ + NMSettingsPlugin *config = NM_SETTINGS_PLUGIN (user_data); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config); + NMSKeyfileConnection *connection; + char *full_path; + gboolean exists; + + full_path = g_file_get_path (file); + if (nms_keyfile_utils_should_ignore_file (full_path)) { + g_free (full_path); + return; + } + exists = g_file_test (full_path, G_FILE_TEST_EXISTS); + + _LOGD ("dir_changed(%s) = %d; file %s", full_path, event_type, exists ? "exists" : "does not exist"); + + connection = find_by_path (self, full_path); + + switch (event_type) { + case G_FILE_MONITOR_EVENT_DELETED: + if (!exists && connection) + remove_connection (NMS_KEYFILE_PLUGIN (config), connection); + break; + case G_FILE_MONITOR_EVENT_CREATED: + case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: + if (exists) + update_connection (NMS_KEYFILE_PLUGIN (config), NULL, full_path, connection, TRUE, NULL, NULL); + break; + default: + break; + } + + g_free (full_path); +} + +static void +config_changed_cb (NMConfig *config, + NMConfigData *config_data, + NMConfigChangeFlags changes, + NMConfigData *old_data, + NMSKeyfilePlugin *self) +{ + gs_free char *old_value = NULL, *new_value = NULL; + + old_value = nm_config_data_get_value (old_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC); + new_value = nm_config_data_get_value (config_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC); + + if (g_strcmp0 (old_value, new_value) != 0) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); +} + +static void +setup_monitoring (NMSettingsPlugin *config) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config); + GFile *file; + GFileMonitor *monitor; + + if (nm_config_get_monitor_connection_files (priv->config)) { + file = g_file_new_for_path (nms_keyfile_utils_get_path ()); + monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); + g_object_unref (file); + + if (monitor) { + priv->monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), config); + priv->monitor = monitor; + } + } + + g_signal_connect (G_OBJECT (priv->config), + NM_CONFIG_SIGNAL_CONFIG_CHANGED, + G_CALLBACK (config_changed_cb), + config); +} + +static GHashTable * +_paths_from_connections (GHashTable *connections) +{ + GHashTableIter iter; + NMSKeyfileConnection *connection; + GHashTable *paths = g_hash_table_new (g_str_hash, g_str_equal); + + g_hash_table_iter_init (&iter, connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { + const char *path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)); + + if (path) + g_hash_table_add (paths, (void *) path); + } + return paths; +} + +static int +_sort_paths (const char **f1, const char **f2, GHashTable *paths) +{ + struct stat st; + gboolean c1, c2; + gint64 m1, m2; + + c1 = !!g_hash_table_contains (paths, *f1); + c2 = !!g_hash_table_contains (paths, *f2); + if (c1 != c2) + return c1 ? -1 : 1; + + m1 = stat (*f1, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; + m2 = stat (*f2, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; + if (m1 != m2) + return m1 > m2 ? -1 : 1; + + return strcmp (*f1, *f2); +} + +static void +read_connections (NMSettingsPlugin *config) +{ + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self); + GDir *dir; + GError *error = NULL; + const char *item; + GHashTable *alive_connections; + GHashTableIter iter; + NMSKeyfileConnection *connection; + GPtrArray *dead_connections = NULL; + guint i; + GPtrArray *filenames; + GHashTable *paths; + + dir = g_dir_open (nms_keyfile_utils_get_path (), 0, &error); + if (!dir) { + _LOGW ("cannot read directory '%s': %s", + nms_keyfile_utils_get_path (), + error->message); + g_clear_error (&error); + return; + } + + alive_connections = g_hash_table_new (NULL, NULL); + + filenames = g_ptr_array_new_with_free_func (g_free); + while ((item = g_dir_read_name (dir))) { + if (nms_keyfile_utils_should_ignore_file (item)) + continue; + g_ptr_array_add (filenames, g_build_filename (nms_keyfile_utils_get_path (), item, NULL)); + } + g_dir_close (dir); + + /* While reloading, we don't replace connections that we already loaded while + * iterating over the files. + * + * To have sensible, reproducible behavior, sort the paths by last modification + * time prefering older files. + */ + paths = _paths_from_connections (priv->connections); + g_ptr_array_sort_with_data (filenames, (GCompareDataFunc) _sort_paths, paths); + g_hash_table_destroy (paths); + + for (i = 0; i < filenames->len; i++) { + connection = update_connection (self, NULL, filenames->pdata[i], NULL, FALSE, alive_connections, NULL); + if (connection) + g_hash_table_add (alive_connections, connection); + } + g_ptr_array_free (filenames, TRUE); + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { + if ( !g_hash_table_contains (alive_connections, connection) + && nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection))) { + if (!dead_connections) + dead_connections = g_ptr_array_new (); + g_ptr_array_add (dead_connections, connection); + } + } + g_hash_table_destroy (alive_connections); + + if (dead_connections) { + for (i = 0; i < dead_connections->len; i++) + remove_connection (self, dead_connections->pdata[i]); + g_ptr_array_free (dead_connections, TRUE); + } +} + +/*****************************************************************************/ + +static GSList * +get_connections (NMSettingsPlugin *config) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config); + + if (!priv->initialized) { + setup_monitoring (config); + read_connections (config); + priv->initialized = TRUE; + } + return _nm_utils_hash_values_to_slist (priv->connections); +} + +static gboolean +load_connection (NMSettingsPlugin *config, + const char *filename) +{ + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN ((NMSKeyfilePlugin *) config); + NMSKeyfileConnection *connection; + int dir_len = strlen (nms_keyfile_utils_get_path ()); + + if ( strncmp (filename, nms_keyfile_utils_get_path (), dir_len) != 0 + || filename[dir_len] != '/' + || strchr (filename + dir_len + 1, '/') != NULL) + return FALSE; + + if (nms_keyfile_utils_should_ignore_file (filename + dir_len + 1)) + return FALSE; + + connection = update_connection (self, NULL, filename, find_by_path (self, filename), TRUE, NULL, NULL); + + return (connection != NULL); +} + +static void +reload_connections (NMSettingsPlugin *config) +{ + read_connections (config); +} + +static NMSettingsConnection * +add_connection (NMSettingsPlugin *config, + NMConnection *connection, + gboolean save_to_disk, + GError **error) +{ + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config); + gs_free char *path = NULL; + + if (save_to_disk) { + if (!nms_keyfile_writer_connection (connection, NULL, FALSE, &path, error)) + return NULL; + } + return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); +} + +static GSList * +get_unmanaged_specs (NMSettingsPlugin *config) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config); + gs_free char *value = NULL; + + value = nm_config_data_get_value (nm_config_get_data (priv->config), + NM_CONFIG_KEYFILE_GROUP_KEYFILE, + NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, + NM_CONFIG_GET_VALUE_TYPE_SPEC); + return nm_match_spec_split (value); +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case NM_SETTINGS_PLUGIN_PROP_NAME: + g_value_set_string (value, NMS_KEYFILE_PLUGIN_NAME); + break; + case NM_SETTINGS_PLUGIN_PROP_INFO: + g_value_set_string (value, NMS_KEYFILE_PLUGIN_INFO); + break; + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nms_keyfile_plugin_init (NMSKeyfilePlugin *plugin) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (plugin); + + priv->config = g_object_ref (nm_config_get ()); + priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); +} + +static void +constructed (GObject *object) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) object); + + G_OBJECT_CLASS (nms_keyfile_plugin_parent_class)->constructed (object); + + if (nm_config_data_has_value (nm_config_get_data_orig (priv->config), + NM_CONFIG_KEYFILE_GROUP_KEYFILE, + NM_CONFIG_KEYFILE_KEY_KEYFILE_HOSTNAME, + NM_CONFIG_GET_VALUE_RAW)) + _LOGW ("'hostname' option is deprecated and has no effect"); +} + +NMSKeyfilePlugin * +nms_keyfile_plugin_new (void) +{ + return g_object_new (NMS_TYPE_KEYFILE_PLUGIN, NULL); +} + +static void +dispose (GObject *object) +{ + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) object); + + if (priv->monitor) { + nm_clear_g_signal_handler (priv->monitor, &priv->monitor_id); + + g_file_monitor_cancel (priv->monitor); + g_clear_object (&priv->monitor); + } + + if (priv->connections) { + g_hash_table_destroy (priv->connections); + priv->connections = NULL; + } + + if (priv->config) { + g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, object); + g_clear_object (&priv->config); + } + + G_OBJECT_CLASS (nms_keyfile_plugin_parent_class)->dispose (object); +} + +static void +nms_keyfile_plugin_class_init (NMSKeyfilePluginClass *req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + + object_class->constructed = constructed; + object_class->dispose = dispose; + object_class->get_property = get_property; + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); + + g_object_class_override_property (object_class, + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); +} + +static void +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) +{ + plugin_iface->get_connections = get_connections; + plugin_iface->load_connection = load_connection; + plugin_iface->reload_connections = reload_connections; + plugin_iface->add_connection = add_connection; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; +} diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.h b/src/settings/plugins/keyfile/nms-keyfile-plugin.h new file mode 100644 index 00000000..41f47aac --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.h @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. + */ + +#ifndef __NMS_KEYFILE_PLUGIN_H__ +#define __NMS_KEYFILE_PLUGIN_H__ + +#define NMS_TYPE_KEYFILE_PLUGIN (nms_keyfile_plugin_get_type ()) +#define NMS_KEYFILE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePlugin)) +#define NMS_KEYFILE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePluginClass)) +#define NMS_IS_KEYFILE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_KEYFILE_PLUGIN)) +#define NMS_IS_KEYFILE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_KEYFILE_PLUGIN)) +#define NMS_KEYFILE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePluginClass)) + +typedef struct _NMSKeyfilePlugin NMSKeyfilePlugin; +typedef struct _NMSKeyfilePluginClass NMSKeyfilePluginClass; + +GType nms_keyfile_plugin_get_type (void); + +NMSKeyfilePlugin *nms_keyfile_plugin_new (void); + +#endif /* __NMS_KEYFILE_PLUGIN_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-reader.c b/src/settings/plugins/keyfile/nms-keyfile-reader.c new file mode 100644 index 00000000..39a01480 --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-reader.c @@ -0,0 +1,143 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2015 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-keyfile-reader.h" + +#include +#include + +#include "nm-keyfile-internal.h" + +#include "NetworkManagerUtils.h" + +/*****************************************************************************/ + +static const char * +_fmt_warn (const char *group, NMSetting *setting, const char *property_name, const char *message, char **out_message) +{ + const char *setting_name = setting ? nm_setting_get_name (setting) : NULL; + + if (group) { + char *res; + + if (setting_name) { + if (property_name && !strcmp (group, setting_name)) + res = g_strdup_printf ("%s.%s: %s", group, property_name, message); + else if (property_name) + res = g_strdup_printf ("%s/%s.%s: %s", group, setting_name, property_name, message); + else if (!strcmp (group, setting_name)) + res = g_strdup_printf ("%s: %s", group, message); + else + res = g_strdup_printf ("%s/%s: %s", group, setting_name, message); + } else + res = g_strdup_printf ("%s: %s", group, message); + *out_message = res; + return res; + } else + return message; +} + +static gboolean +_handler_read (GKeyFile *keyfile, + NMConnection *connection, + NMKeyfileReadType type, + void *type_data, + void *user_data, + GError **error) +{ + if (type == NM_KEYFILE_READ_TYPE_WARN) { + NMKeyfileReadTypeDataWarn *warn_data = type_data; + NMLogLevel level; + char *message_free = NULL; + + if (warn_data->severity > NM_KEYFILE_WARN_SEVERITY_WARN) + level = LOGL_ERR; + else if (warn_data->severity >= NM_KEYFILE_WARN_SEVERITY_WARN) + level = LOGL_WARN; + else if (warn_data->severity == NM_KEYFILE_WARN_SEVERITY_INFO_MISSING_FILE) + level = LOGL_WARN; + else + level = LOGL_INFO; + + nm_log (level, LOGD_SETTINGS, "keyfile: %s", + _fmt_warn (warn_data->group, warn_data->setting, + warn_data->property_name, warn_data->message, + &message_free)); + g_free (message_free); + return TRUE; + } + return FALSE; +} + +NMConnection * +nms_keyfile_reader_from_file (const char *filename, GError **error) +{ + GKeyFile *key_file; + struct stat statbuf; + NMConnection *connection = NULL; + GError *verify_error = NULL; + + if (stat (filename, &statbuf) != 0 || !S_ISREG (statbuf.st_mode)) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "File did not exist or was not a regular file"); + return NULL; + } + + if (!NM_FLAGS_HAS (nm_utils_get_testing (), NM_UTILS_TEST_NO_KEYFILE_OWNER_CHECK)) { + if (statbuf.st_mode & 0077) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "File permissions (%o) were insecure", + statbuf.st_mode); + return NULL; + } + + if (statbuf.st_uid != 0) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "File owner (%o) is insecure", + statbuf.st_mode); + return NULL; + } + } + + key_file = g_key_file_new (); + if (!g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, error)) + goto out; + + connection = nm_keyfile_read (key_file, filename, NULL, _handler_read, NULL, error); + if (!connection) + goto out; + + /* Normalize and verify the connection */ + if (!nm_connection_normalize (connection, NULL, NULL, &verify_error)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid connection: %s", + verify_error->message); + g_clear_error (&verify_error); + g_object_unref (connection); + connection = NULL; + } + +out: + g_key_file_free (key_file); + return connection; +} + diff --git a/src/settings/plugins/keyfile/nms-keyfile-reader.h b/src/settings/plugins/keyfile/nms-keyfile-reader.h new file mode 100644 index 00000000..c52fea31 --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-reader.h @@ -0,0 +1,29 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 Red Hat, Inc. + */ + +#ifndef __NMS_KEYFILE_READER_H__ +#define __NMS_KEYFILE_READER_H__ + +#include + +NMConnection *nms_keyfile_reader_from_file (const char *filename, GError **error); + +#endif /* __NMS_KEYFILE_READER_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.c b/src/settings/plugins/keyfile/nms-keyfile-utils.c new file mode 100644 index 00000000..03f06670 --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.c @@ -0,0 +1,170 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2010 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-keyfile-utils.h" + +#include +#include + +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-wireless-security.h" +#include "nm-config.h" + +#define NM_CONFIG_KEYFILE_PATH_DEFAULT NMCONFDIR "/system-connections" + +/*****************************************************************************/ + +static const char temp_letters[] = +"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + +/* + * Check '.[a-zA-Z0-9]{6}' file suffix used for temporary files by g_file_set_contents() (mkstemp()). + */ +static gboolean +check_mkstemp_suffix (const char *path) +{ + const char *ptr; + + g_return_val_if_fail (path != NULL, FALSE); + + /* Matches *.[a-zA-Z0-9]{6} suffix of mkstemp()'s temporary files */ + ptr = strrchr (path, '.'); + if (ptr && (strspn (ptr + 1, temp_letters) == 6) && (! ptr[7])) + return TRUE; + return FALSE; +} + +static gboolean +check_prefix (const char *base, const char *tag) +{ + int len, tag_len; + + g_return_val_if_fail (base != NULL, TRUE); + g_return_val_if_fail (tag != NULL, TRUE); + + len = strlen (base); + tag_len = strlen (tag); + if ((len > tag_len) && !g_ascii_strncasecmp (base, tag, tag_len)) + return TRUE; + return FALSE; +} + +static gboolean +check_suffix (const char *base, const char *tag) +{ + int len, tag_len; + + g_return_val_if_fail (base != NULL, TRUE); + g_return_val_if_fail (tag != NULL, TRUE); + + len = strlen (base); + tag_len = strlen (tag); + if ((len > tag_len) && !g_ascii_strcasecmp (base + len - tag_len, tag)) + return TRUE; + return FALSE; +} + +#define SWP_TAG ".swp" +#define SWPX_TAG ".swpx" +#define PEM_TAG ".pem" +#define DER_TAG ".der" + +gboolean +nms_keyfile_utils_should_ignore_file (const char *filename) +{ + gs_free char *base = NULL; + + g_return_val_if_fail (filename != NULL, TRUE); + + base = g_path_get_basename (filename); + g_return_val_if_fail (base != NULL, TRUE); + + /* Ignore hidden and backup files */ + /* should_ignore_file() must mirror escape_filename() */ + if (check_prefix (base, ".") || check_suffix (base, "~")) + return TRUE; + /* Ignore temporary files */ + if (check_mkstemp_suffix (base)) + return TRUE; + /* Ignore 802.1x certificates and keys */ + if (check_suffix (base, PEM_TAG) || check_suffix (base, DER_TAG)) + return TRUE; + + return FALSE; +} + +char * +nms_keyfile_utils_escape_filename (const char *filename) +{ + GString *str; + const char *f = filename; + const char ESCAPE_CHAR = '*'; + + /* keyfile used to escape with '*', do not change that behavior. + * But for newly added escapings, use '_' instead. */ + const char ESCAPE_CHAR2 = '_'; + + g_return_val_if_fail (filename && filename[0], NULL); + + str = g_string_sized_new (60); + + /* Convert '/' to ESCAPE_CHAR */ + for (f = filename; f[0]; f++) { + if (f[0] == '/') + g_string_append_c (str, ESCAPE_CHAR); + else + g_string_append_c (str, f[0]); + } + + /* escape_filename() must avoid anything that should_ignore_file() would reject. + * We can escape here more aggressivly then what we would read back. */ + if (check_prefix (str->str, ".")) + str->str[0] = ESCAPE_CHAR2; + if (check_suffix (str->str, "~")) + str->str[str->len - 1] = ESCAPE_CHAR2; + if ( check_mkstemp_suffix (str->str) + || check_suffix (str->str, PEM_TAG) + || check_suffix (str->str, DER_TAG)) + g_string_append_c (str, ESCAPE_CHAR2); + + return g_string_free (str, FALSE);; +} + +/*****************************************************************************/ + +const char * +nms_keyfile_utils_get_path (void) +{ + static char *path = NULL; + + if (G_UNLIKELY (!path)) { + path = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG, + NM_CONFIG_KEYFILE_GROUP_KEYFILE, + NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH, + NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); + if (!path) + path = g_strdup (""NM_CONFIG_KEYFILE_PATH_DEFAULT""); + } + return path; +} + diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.h b/src/settings/plugins/keyfile/nms-keyfile-utils.h new file mode 100644 index 00000000..be7d668a --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.h @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * (C) Copyright 2010-2016 Red Hat, Inc. + */ + +#ifndef __NMS_KEYFILE_UTILS_H__ +#define __NMS_KEYFILE_UTILS_H__ + +#include "NetworkManagerUtils.h" + +#define NMS_KEYFILE_PLUGIN_NAME "keyfile" +#define NMS_KEYFILE_PLUGIN_INFO "(c) 2007 - 2016 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." + +#define NMS_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") +#define NMS_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")" +#define NMS_KEYFILE_CONNECTION_LOG_ARG(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) +#define NMS_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" +#define NMS_KEYFILE_CONNECTION_LOG_ARGD(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con) + +gboolean nms_keyfile_utils_should_ignore_file (const char *filename); + +char *nms_keyfile_utils_escape_filename (const char *filename); + +const char *nms_keyfile_utils_get_path (void); + +#endif /* __NMS_KEYFILE_UTILS_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.c b/src/settings/plugins/keyfile/nms-keyfile-writer.c new file mode 100644 index 00000000..95897db3 --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.c @@ -0,0 +1,328 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2015 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nms-keyfile-writer.h" + +#include +#include +#include +#include +#include + +#include "nm-keyfile-internal.h" + +#include "nms-keyfile-utils.h" + +/*****************************************************************************/ + +typedef struct { + const char *keyfile_dir; +} WriteInfo; + +static void +cert_writer (NMConnection *connection, + GKeyFile *file, + NMKeyfileWriteTypeDataCert *cert_data, + WriteInfo *info, + GError **error) +{ + const char *setting_name = nm_setting_get_name (NM_SETTING (cert_data->setting)); + NMSetting8021xCKScheme scheme; + NMSetting8021xCKFormat format; + const char *path = NULL, *ext = "pem"; + + scheme = cert_data->scheme_func (cert_data->setting); + if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) { + char *tmp = NULL; + const char *accepted_path = NULL; + + path = cert_data->path_func (cert_data->setting); + g_assert (path); + + if (g_str_has_prefix (path, info->keyfile_dir)) { + const char *p = path + strlen (info->keyfile_dir); + + /* If the path is rooted in the keyfile directory, just use a + * relative path instead of an absolute one. + */ + if (*p == '/') { + while (*p == '/') + p++; + if (p[0]) { + /* If @p looks like an integer list, the following detection will fail too and + * we will file:// qualify the path below. We thus avoid writing a path string + * that would be interpreted as legacy binary format by reader. */ + tmp = nm_keyfile_detect_unqualified_path_scheme (info->keyfile_dir, p, -1, FALSE, NULL); + if (tmp) { + g_clear_pointer (&tmp, g_free); + accepted_path = p; + } + } + } + } + if (!accepted_path) { + /* What we are about to write, must also be understood by the reader. + * Otherwise, add a file:// prefix */ + tmp = nm_keyfile_detect_unqualified_path_scheme (info->keyfile_dir, path, -1, FALSE, NULL); + if (tmp) { + g_clear_pointer (&tmp, g_free); + accepted_path = path; + } + } + + if (!accepted_path) + accepted_path = tmp = g_strconcat (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH, path, NULL); + nm_keyfile_plugin_kf_set_string (file, setting_name, cert_data->property_name, accepted_path); + g_free (tmp); + } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PKCS11) { + nm_keyfile_plugin_kf_set_string (file, setting_name, cert_data->property_name, + cert_data->uri_func (cert_data->setting)); + } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) { + GBytes *blob; + const guint8 *blob_data; + gsize blob_len; + gboolean success; + GError *local = NULL; + char *new_path; + + blob = cert_data->blob_func (cert_data->setting); + g_assert (blob); + blob_data = g_bytes_get_data (blob, &blob_len); + + if (cert_data->format_func) { + /* Get the extension for a private key */ + format = cert_data->format_func (cert_data->setting); + if (format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) + ext = "p12"; + } else { + /* DER or PEM format certificate? */ + if (blob_len > 2 && blob_data[0] == 0x30 && blob_data[1] == 0x82) + ext = "der"; + } + + /* Write the raw data out to the standard file so that we can use paths + * from now on instead of pushing around the certificate data. + */ + new_path = g_strdup_printf ("%s/%s-%s.%s", info->keyfile_dir, nm_connection_get_uuid (connection), + cert_data->suffix, ext); + + success = nm_utils_file_set_contents (new_path, (const gchar *) blob_data, + blob_len, 0600, &local); + if (success) { + /* Write the path value to the keyfile. + * We know, that basename(new_path) starts with a UUID, hence no conflict with "data:;base64," */ + nm_keyfile_plugin_kf_set_string (file, setting_name, cert_data->property_name, strrchr (new_path, '/') + 1); + } else { + nm_log_warn (LOGD_SETTINGS, "keyfile: %s.%s: failed to write certificate to file %s: %s", + setting_name, cert_data->property_name, new_path, local->message); + g_error_free (local); + } + g_free (new_path); + } else { + /* scheme_func() returns UNKNOWN in all other cases. The only valid case + * where a scheme is allowed to be UNKNOWN, is unsetting the value. In this + * case, we don't expect the writer to be called, because the default value + * will not be serialized. + * The only other reason for the scheme to be UNKNOWN is an invalid cert. + * But our connection verifies, so that cannot happen either. */ + g_return_if_reached (); + } +} + +static gboolean +_handler_write (NMConnection *connection, + GKeyFile *keyfile, + NMKeyfileWriteType type, + void *type_data, + void *user_data, + GError **error) +{ + if (type == NM_KEYFILE_WRITE_TYPE_CERT) { + cert_writer (connection, keyfile, + (NMKeyfileWriteTypeDataCert *) type_data, + (WriteInfo *) user_data, error); + return TRUE; + } + return FALSE; +} + +static gboolean +_internal_write_connection (NMConnection *connection, + const char *keyfile_dir, + uid_t owner_uid, + pid_t owner_grp, + const char *existing_path, + gboolean force_rename, + char **out_path, + GError **error) +{ + GKeyFile *key_file; + gs_free char *data = NULL; + gsize len; + gs_free char *path = NULL; + const char *id; + WriteInfo info = { 0 }; + GError *local_err = NULL; + int errsv; + + g_return_val_if_fail (!out_path || !*out_path, FALSE); + g_return_val_if_fail (keyfile_dir && keyfile_dir[0] == '/', FALSE); + + if (!nm_connection_verify (connection, error)) + g_return_val_if_reached (FALSE); + + id = nm_connection_get_id (connection); + g_assert (id && *id); + + info.keyfile_dir = keyfile_dir; + + key_file = nm_keyfile_write (connection, _handler_write, &info, error); + if (!key_file) + return FALSE; + data = g_key_file_to_data (key_file, &len, error); + g_key_file_unref (key_file); + if (!data) + return FALSE; + + /* If we have existing file path, use it. Else generate one from + * connection's ID. + */ + if (existing_path != NULL && !force_rename) { + path = g_strdup (existing_path); + } else { + char *filename_escaped = nms_keyfile_utils_escape_filename (id); + + path = g_build_filename (keyfile_dir, filename_escaped, NULL); + g_free (filename_escaped); + } + + /* If a file with this path already exists (but isn't the existing path + * of the connection) then we need another name. Multiple connections + * can have the same ID (ie if two connections with the same ID are visible + * to different users) but of course can't have the same path. Yeah, + * there's a race here, but there's not a lot we can do about it, and + * we shouldn't get more than one connection with the same UUID either. + */ + if (g_strcmp0 (path, existing_path) != 0 && g_file_test (path, G_FILE_TEST_EXISTS)) { + guint i; + gboolean name_found = FALSE; + + /* A keyfile with this connection's ID already exists. Pick another name. */ + for (i = 0; i < 100; i++) { + char *filename, *filename_escaped; + + if (i == 0) + filename = g_strdup_printf ("%s-%s", id, nm_connection_get_uuid (connection)); + else + filename = g_strdup_printf ("%s-%s-%u", id, nm_connection_get_uuid (connection), i); + + filename_escaped = nms_keyfile_utils_escape_filename (filename); + + g_free (path); + path = g_strdup_printf ("%s/%s", keyfile_dir, filename_escaped); + g_free (filename); + g_free (filename_escaped); + if (g_strcmp0 (path, existing_path) == 0 || !g_file_test (path, G_FILE_TEST_EXISTS)) { + name_found = TRUE; + break; + } + } + if (!name_found) { + if (existing_path == NULL) { + /* this really should not happen, we tried hard to find an unused name... bail out. */ + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "could not find suitable keyfile file name (%s already used)", path); + return FALSE; + } + /* Both our preferred path based on connection id and id-uuid are taken. + * Fallback to @existing_path */ + g_free (path); + path = g_strdup (existing_path); + } + } + + /* In case of updating the connection and changing the file path, + * we need to remove the old one, not to end up with two connections. + */ + if (existing_path != NULL && strcmp (path, existing_path) != 0) + unlink (existing_path); + + nm_utils_file_set_contents (path, data, len, 0600, &local_err); + if (local_err) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "error writing to file '%s': %s", + path, local_err->message); + g_error_free (local_err); + return FALSE; + } + + if (chown (path, owner_uid, owner_grp) < 0) { + errsv = errno; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "error chowning '%s': %s (%d)", + path, g_strerror (errsv), errsv); + unlink (path); + return FALSE; + } + + if (out_path && g_strcmp0 (existing_path, path)) { + *out_path = path; /* pass path out to caller */ + path = NULL; + } + + return TRUE; +} + +gboolean +nms_keyfile_writer_connection (NMConnection *connection, + const char *existing_path, + gboolean force_rename, + char **out_path, + GError **error) +{ + return _internal_write_connection (connection, + nms_keyfile_utils_get_path (), + 0, 0, + existing_path, + force_rename, + out_path, + error); +} + +gboolean +nms_keyfile_writer_test_connection (NMConnection *connection, + const char *keyfile_dir, + uid_t owner_uid, + pid_t owner_grp, + char **out_path, + GError **error) +{ + return _internal_write_connection (connection, + keyfile_dir, + owner_uid, owner_grp, + NULL, + FALSE, + out_path, + error); +} + diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.h b/src/settings/plugins/keyfile/nms-keyfile-writer.h new file mode 100644 index 00000000..4f43455d --- /dev/null +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.h @@ -0,0 +1,40 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service - keyfile plugin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. + */ + +#ifndef __NMS_KEYFILE_WRITER_H__ +#define __NMS_KEYFILE_WRITER_H__ + +#include + +gboolean nms_keyfile_writer_connection (NMConnection *connection, + const char *existing_path, + gboolean force_rename, + char **out_path, + GError **error); + +gboolean nms_keyfile_writer_test_connection (NMConnection *connection, + const char *keyfile_dir, + uid_t owner_uid, + pid_t owner_grp, + char **out_path, + GError **error); + +#endif /* __NMS_KEYFILE_WRITER_H__ */ diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c deleted file mode 100644 index c5598fc5..00000000 --- a/src/settings/plugins/keyfile/plugin.c +++ /dev/null @@ -1,648 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2013 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include - -#include "nm-connection.h" -#include "nm-setting.h" -#include "nm-setting-connection.h" -#include "nm-utils.h" -#include "nm-config.h" -#include "nm-core-internal.h" - -#include "plugin.h" -#include "nm-settings-plugin.h" -#include "nm-keyfile-connection.h" -#include "writer.h" -#include "utils.h" - -static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); - -G_DEFINE_TYPE_EXTENDED (SettingsPluginKeyfile, settings_plugin_keyfile, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_interface_init)) - -#define SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfilePrivate)) - -typedef struct { - GHashTable *connections; /* uuid::connection */ - - gboolean initialized; - GFileMonitor *monitor; - gulong monitor_id; - - NMConfig *config; -} SettingsPluginKeyfilePrivate; - -static void -connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) -{ - g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (user_data)->connections, - nm_connection_get_uuid (NM_CONNECTION (obj))); -} - -/* Monitoring */ - -static void -remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection) -{ - gboolean removed; - - g_return_if_fail (connection != NULL); - - nm_log_info (LOGD_SETTINGS, "keyfile: removed " NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection)); - - /* Removing from the hash table should drop the last reference */ - g_object_ref (connection); - g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self); - removed = g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self)->connections, - nm_connection_get_uuid (NM_CONNECTION (connection))); - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); - g_object_unref (connection); - - g_return_if_fail (removed); -} - -static NMKeyfileConnection * -find_by_path (SettingsPluginKeyfile *self, const char *path) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); - GHashTableIter iter; - NMSettingsConnection *candidate = NULL; - - g_return_val_if_fail (path != NULL, NULL); - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { - if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0) - return NM_KEYFILE_CONNECTION (candidate); - } - return NULL; -} - -/* update_connection: - * @self: the plugin instance - * @source: if %NULL, this re-reads the connection from @full_path - * and updates it. When passing @source, this adds a connection from - * memory. - * @full_path: the filename of the keyfile to be loaded - * @connection: an existing connection that might be updated. - * If given, @connection must be an existing connection that is currently - * owned by the plugin. - * @protect_existing_connection: if %TRUE, and !@connection, we don't allow updating - * an existing connection with the same UUID. - * If %TRUE and @connection, allow updating only if the reload would modify - * @connection (without changing its UUID) or if we would create a new connection. - * In other words, if this paramter is %TRUE, we only allow creating a - * new connection (with an unseen UUID) or updating the passed in @connection - * (whereas the UUID cannot change). - * Note, that this allows for @connection to be replaced by a new connection. - * @protected_connections: (allow-none): if given, we only update an - * existing connection if it is not contained in this hash. - * @error: error in case of failure - * - * Loads a connection from file @full_path. This can both be used to - * load a connection initially or to update an existing connection. - * - * If you pass in an existing connection and the reloaded file happens - * to have a different UUID, the connection is deleted. - * Beware, that means that after the function, you have a dangling pointer - * if the returned connection is different from @connection. - * - * Returns: the updated connection. - * */ -static NMKeyfileConnection * -update_connection (SettingsPluginKeyfile *self, - NMConnection *source, - const char *full_path, - NMKeyfileConnection *connection, - gboolean protect_existing_connection, - GHashTable *protected_connections, - GError **error) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); - NMKeyfileConnection *connection_new; - NMKeyfileConnection *connection_by_uuid; - GError *local = NULL; - const char *uuid; - - g_return_val_if_fail (!source || NM_IS_CONNECTION (source), NULL); - g_return_val_if_fail (full_path || source, NULL); - - if (full_path) - nm_log_dbg (LOGD_SETTINGS, "keyfile: loading from file \"%s\"...", full_path); - - connection_new = nm_keyfile_connection_new (source, full_path, &local); - if (!connection_new) { - /* Error; remove the connection */ - if (source) - nm_log_warn (LOGD_SETTINGS, "keyfile: error creating connection %s: %s", nm_connection_get_uuid (source), local->message); - else - nm_log_warn (LOGD_SETTINGS, "keyfile: error loading connection from file %s: %s", full_path, local->message); - if ( connection - && !protect_existing_connection - && (!protected_connections || !g_hash_table_contains (protected_connections, connection))) - remove_connection (self, connection); - g_propagate_error (error, local); - return NULL; - } - - uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new)); - connection_by_uuid = g_hash_table_lookup (priv->connections, uuid); - - if ( connection - && connection != connection_by_uuid) { - - if ( (protect_existing_connection && connection_by_uuid != NULL) - || (protected_connections && g_hash_table_contains (protected_connections, connection))) { - NMKeyfileConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection; - - if (source) - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update protected "NM_KEYFILE_CONNECTION_LOG_FMT" connection due to conflicting UUID %s", NM_KEYFILE_CONNECTION_LOG_ARG (conflicting), uuid); - else - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, full_path, NM_KEYFILE_CONNECTION_LOG_ARG (conflicting)); - g_object_unref (connection_new); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Cannot update protected connection due to conflicting UUID"); - return NULL; - } - - /* The new connection has a different UUID then the original one. - * Remove @connection. */ - remove_connection (self, connection); - } - - if ( connection_by_uuid - && ( (!connection && protect_existing_connection) - || (protected_connections && g_hash_table_contains (protected_connections, connection_by_uuid)))) { - if (source) - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update connection due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); - else - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, full_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); - g_object_unref (connection_new); - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Skip updating protected connection during reload"); - return NULL; - } - - if (connection_by_uuid) { - const char *old_path; - - old_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)); - - if (nm_connection_compare (NM_CONNECTION (connection_by_uuid), - NM_CONNECTION (connection_new), - NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | - NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { - /* Nothing to do... except updating the path. */ - if (old_path && g_strcmp0 (old_path, full_path) != 0) - nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NM_KEYFILE_CONNECTION_LOG_FMT" without other changes", old_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); - } else { - /* An existing connection changed. */ - if (source) - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" from %s", NM_KEYFILE_CONNECTION_LOG_ARG (connection_new), NM_KEYFILE_CONNECTION_LOG_PATH (old_path)); - else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new)))) - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); - else if (old_path) - nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NM_KEYFILE_CONNECTION_LOG_FMT, old_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); - else - nm_log_info (LOGD_SETTINGS, "keyfile: update and persist "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); - - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid), - NM_CONNECTION (connection_new), - FALSE, /* don't set Unsaved */ - "keyfile-update", - &local)) { - /* Shouldn't ever get here as 'connection_new' was verified by the reader already - * and the UUID did not change. */ - g_assert_not_reached (); - } - g_assert_no_error (local); - } - nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (connection_by_uuid), full_path); - g_object_unref (connection_new); - return connection_by_uuid; - } else { - if (source) - nm_log_info (LOGD_SETTINGS, "keyfile: add connection "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); - else - nm_log_info (LOGD_SETTINGS, "keyfile: new connection "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); - g_hash_table_insert (priv->connections, g_strdup (uuid), connection_new); - - g_signal_connect (connection_new, NM_SETTINGS_CONNECTION_REMOVED, - G_CALLBACK (connection_removed_cb), - self); - - if (!source) { - /* Only raise the signal if we were called without source, i.e. if we read the connection from file. - * Otherwise, we were called by add_connection() which does not expect the signal. */ - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); - } - return connection_new; - } -} - -static void -dir_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) -{ - NMSettingsPlugin *config = NM_SETTINGS_PLUGIN (user_data); - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); - NMKeyfileConnection *connection; - char *full_path; - gboolean exists; - - full_path = g_file_get_path (file); - if (nm_keyfile_plugin_utils_should_ignore_file (full_path)) { - g_free (full_path); - return; - } - exists = g_file_test (full_path, G_FILE_TEST_EXISTS); - - nm_log_dbg (LOGD_SETTINGS, "dir_changed(%s) = %d; file %s", full_path, event_type, exists ? "exists" : "does not exist"); - - connection = find_by_path (self, full_path); - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - if (!exists && connection) - remove_connection (SETTINGS_PLUGIN_KEYFILE (config), connection); - break; - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - if (exists) - update_connection (SETTINGS_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL); - break; - default: - break; - } - - g_free (full_path); -} - -static void -config_changed_cb (NMConfig *config, - NMConfigData *config_data, - NMConfigChangeFlags changes, - NMConfigData *old_data, - SettingsPluginKeyfile *self) -{ - gs_free char *old_value = NULL, *new_value = NULL; - - old_value = nm_config_data_get_value (old_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC); - new_value = nm_config_data_get_value (config_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC); - - if (g_strcmp0 (old_value, new_value) != 0) - g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); -} - -static void -setup_monitoring (NMSettingsPlugin *config) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (config); - GFile *file; - GFileMonitor *monitor; - - if (nm_config_get_monitor_connection_files (nm_config_get ())) { - file = g_file_new_for_path (nm_keyfile_plugin_get_path ()); - monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - - if (monitor) { - priv->monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), config); - priv->monitor = monitor; - } - } - - g_signal_connect (G_OBJECT (priv->config), - NM_CONFIG_SIGNAL_CONFIG_CHANGED, - G_CALLBACK (config_changed_cb), - config); -} - -static GHashTable * -_paths_from_connections (GHashTable *connections) -{ - GHashTableIter iter; - NMKeyfileConnection *connection; - GHashTable *paths = g_hash_table_new (g_str_hash, g_str_equal); - - g_hash_table_iter_init (&iter, connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { - const char *path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)); - - if (path) - g_hash_table_add (paths, (void *) path); - } - return paths; -} - -static int -_sort_paths (const char **f1, const char **f2, GHashTable *paths) -{ - struct stat st; - gboolean c1, c2; - gint64 m1, m2; - - c1 = !!g_hash_table_contains (paths, *f1); - c2 = !!g_hash_table_contains (paths, *f2); - if (c1 != c2) - return c1 ? -1 : 1; - - m1 = stat (*f1, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; - m2 = stat (*f2, &st) == 0 ? (gint64) st.st_mtime : G_MININT64; - if (m1 != m2) - return m1 > m2 ? -1 : 1; - - return strcmp (*f1, *f2); -} - -static void -read_connections (NMSettingsPlugin *config) -{ - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); - GDir *dir; - GError *error = NULL; - const char *item; - GHashTable *alive_connections; - GHashTableIter iter; - NMKeyfileConnection *connection; - GPtrArray *dead_connections = NULL; - guint i; - GPtrArray *filenames; - GHashTable *paths; - - dir = g_dir_open (nm_keyfile_plugin_get_path (), 0, &error); - if (!dir) { - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': %s", - nm_keyfile_plugin_get_path (), - error->message); - g_clear_error (&error); - return; - } - - alive_connections = g_hash_table_new (NULL, NULL); - - filenames = g_ptr_array_new_with_free_func (g_free); - while ((item = g_dir_read_name (dir))) { - if (nm_keyfile_plugin_utils_should_ignore_file (item)) - continue; - g_ptr_array_add (filenames, g_build_filename (nm_keyfile_plugin_get_path (), item, NULL)); - } - g_dir_close (dir); - - /* While reloading, we don't replace connections that we already loaded while - * iterating over the files. - * - * To have sensible, reproducible behavior, sort the paths by last modification - * time prefering older files. - */ - paths = _paths_from_connections (priv->connections); - g_ptr_array_sort_with_data (filenames, (GCompareDataFunc) _sort_paths, paths); - g_hash_table_destroy (paths); - - for (i = 0; i < filenames->len; i++) { - connection = update_connection (self, NULL, filenames->pdata[i], NULL, FALSE, alive_connections, NULL); - if (connection) - g_hash_table_add (alive_connections, connection); - } - g_ptr_array_free (filenames, TRUE); - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) { - if ( !g_hash_table_contains (alive_connections, connection) - && nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection))) { - if (!dead_connections) - dead_connections = g_ptr_array_new (); - g_ptr_array_add (dead_connections, connection); - } - } - g_hash_table_destroy (alive_connections); - - if (dead_connections) { - for (i = 0; i < dead_connections->len; i++) - remove_connection (self, dead_connections->pdata[i]); - g_ptr_array_free (dead_connections, TRUE); - } -} - -/* Plugin */ - -static GSList * -get_connections (NMSettingsPlugin *config) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (config); - - if (!priv->initialized) { - setup_monitoring (config); - read_connections (config); - priv->initialized = TRUE; - } - return _nm_utils_hash_values_to_slist (priv->connections); -} - -static gboolean -load_connection (NMSettingsPlugin *config, - const char *filename) -{ - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); - NMKeyfileConnection *connection; - int dir_len = strlen (nm_keyfile_plugin_get_path ()); - - if ( strncmp (filename, nm_keyfile_plugin_get_path (), dir_len) != 0 - || filename[dir_len] != '/' - || strchr (filename + dir_len + 1, '/') != NULL) - return FALSE; - - if (nm_keyfile_plugin_utils_should_ignore_file (filename + dir_len + 1)) - return FALSE; - - connection = update_connection (self, NULL, filename, find_by_path (self, filename), TRUE, NULL, NULL); - - return (connection != NULL); -} - -static void -reload_connections (NMSettingsPlugin *config) -{ - read_connections (config); -} - -static NMSettingsConnection * -add_connection (NMSettingsPlugin *config, - NMConnection *connection, - gboolean save_to_disk, - GError **error) -{ - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); - gs_free char *path = NULL; - - if (save_to_disk) { - if (!nm_keyfile_plugin_write_connection (connection, NULL, FALSE, &path, error)) - return NULL; - } - return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); -} - -static GSList * -get_unmanaged_specs (NMSettingsPlugin *config) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (config); - gs_free char *value = NULL; - - value = nm_config_data_get_value (nm_config_get_data (priv->config), - NM_CONFIG_KEYFILE_GROUP_KEYFILE, - NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, - NM_CONFIG_GET_VALUE_TYPE_SPEC); - return nm_match_spec_split (value); -} - -/* GObject */ - -static void -settings_plugin_keyfile_init (SettingsPluginKeyfile *plugin) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (plugin); - - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, KEYFILE_PLUGIN_NAME); - break; - case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, KEYFILE_PLUGIN_INFO); - break; - case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -constructed (GObject *object) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (object); - - priv->config = g_object_ref (nm_config_get ()); - if (nm_config_data_has_value (nm_config_get_data_orig (priv->config), - NM_CONFIG_KEYFILE_GROUP_KEYFILE, - NM_CONFIG_KEYFILE_KEY_KEYFILE_HOSTNAME, - NM_CONFIG_GET_VALUE_RAW)) - nm_log_warn (LOGD_SETTINGS, "keyfile: 'hostname' option is deprecated and has no effect"); -} - -static void -dispose (GObject *object) -{ - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (object); - - if (priv->monitor) { - nm_clear_g_signal_handler (priv->monitor, &priv->monitor_id); - - g_file_monitor_cancel (priv->monitor); - g_clear_object (&priv->monitor); - } - - if (priv->connections) { - g_hash_table_destroy (priv->connections); - priv->connections = NULL; - } - - if (priv->config) { - g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, object); - g_clear_object (&priv->config); - } - - G_OBJECT_CLASS (settings_plugin_keyfile_parent_class)->dispose (object); -} - -static void -settings_plugin_keyfile_class_init (SettingsPluginKeyfileClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (SettingsPluginKeyfilePrivate)); - - object_class->constructed = constructed; - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_NAME, - NM_SETTINGS_PLUGIN_NAME); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_INFO, - NM_SETTINGS_PLUGIN_INFO); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, - NM_SETTINGS_PLUGIN_CAPABILITIES); -} - -static void -settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) -{ - /* interface implementation */ - plugin_iface->get_connections = get_connections; - plugin_iface->load_connection = load_connection; - plugin_iface->reload_connections = reload_connections; - plugin_iface->add_connection = add_connection; - plugin_iface->get_unmanaged_specs = get_unmanaged_specs; -} - -GObject * -nm_settings_keyfile_plugin_new (void) -{ - return g_object_new (SETTINGS_TYPE_PLUGIN_KEYFILE, NULL); -} diff --git a/src/settings/plugins/keyfile/plugin.h b/src/settings/plugins/keyfile/plugin.h deleted file mode 100644 index a22b9c49..00000000 --- a/src/settings/plugins/keyfile/plugin.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#define SETTINGS_TYPE_PLUGIN_KEYFILE (settings_plugin_keyfile_get_type ()) -#define SETTINGS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfile)) -#define SETTINGS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass)) -#define SETTINGS_IS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE)) -#define SETTINGS_IS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE)) -#define SETTINGS_PLUGIN_KEYFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass)) - -typedef struct { - GObject parent; -} SettingsPluginKeyfile; - -typedef struct { - GObjectClass parent; -} SettingsPluginKeyfileClass; - -GType settings_plugin_keyfile_get_type (void); - -GObject *nm_settings_keyfile_plugin_new (void); - -#endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c deleted file mode 100644 index 264b26a4..00000000 --- a/src/settings/plugins/keyfile/reader.c +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2015 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "reader.h" - -#include "nm-keyfile-internal.h" -#include "NetworkManagerUtils.h" - -static const char * -_fmt_warn (const char *group, NMSetting *setting, const char *property_name, const char *message, char **out_message) -{ - const char *setting_name = setting ? nm_setting_get_name (setting) : NULL; - - if (group) { - char *res; - - if (setting_name) { - if (property_name && !strcmp (group, setting_name)) - res = g_strdup_printf ("%s.%s: %s", group, property_name, message); - else if (property_name) - res = g_strdup_printf ("%s/%s.%s: %s", group, setting_name, property_name, message); - else if (!strcmp (group, setting_name)) - res = g_strdup_printf ("%s: %s", group, message); - else - res = g_strdup_printf ("%s/%s: %s", group, setting_name, message); - } else - res = g_strdup_printf ("%s: %s", group, message); - *out_message = res; - return res; - } else - return message; -} - -static gboolean -_handler_read (GKeyFile *keyfile, - NMConnection *connection, - NMKeyfileReadType type, - void *type_data, - void *user_data, - GError **error) -{ - if (type == NM_KEYFILE_READ_TYPE_WARN) { - NMKeyfileReadTypeDataWarn *warn_data = type_data; - NMLogLevel level; - char *message_free = NULL; - - if (warn_data->severity > NM_KEYFILE_WARN_SEVERITY_WARN) - level = LOGL_ERR; - else if (warn_data->severity >= NM_KEYFILE_WARN_SEVERITY_WARN) - level = LOGL_WARN; - else if (warn_data->severity == NM_KEYFILE_WARN_SEVERITY_INFO_MISSING_FILE) - level = LOGL_WARN; - else - level = LOGL_INFO; - - nm_log (level, LOGD_SETTINGS, "keyfile: %s", - _fmt_warn (warn_data->group, warn_data->setting, - warn_data->property_name, warn_data->message, - &message_free)); - g_free (message_free); - return TRUE; - } - return FALSE; -} - -NMConnection * -nm_keyfile_plugin_connection_from_file (const char *filename, GError **error) -{ - GKeyFile *key_file; - struct stat statbuf; - NMConnection *connection = NULL; - GError *verify_error = NULL; - - if (stat (filename, &statbuf) != 0 || !S_ISREG (statbuf.st_mode)) { - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "File did not exist or was not a regular file"); - return NULL; - } - - if (statbuf.st_mode & 0077) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "File permissions (%o) were insecure", - statbuf.st_mode); - return NULL; - } - - if (!NM_FLAGS_HAS (nm_utils_get_testing (), NM_UTILS_TEST_NO_KEYFILE_OWNER_CHECK)) { - if (statbuf.st_uid != 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "File owner (%o) is insecure", - statbuf.st_mode); - return NULL; - } - } - - key_file = g_key_file_new (); - if (!g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, error)) - goto out; - - connection = nm_keyfile_read (key_file, filename, NULL, _handler_read, NULL, error); - if (!connection) - goto out; - - /* Normalize and verify the connection */ - if (!nm_connection_normalize (connection, NULL, NULL, &verify_error)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "invalid connection: %s", - verify_error->message); - g_clear_error (&verify_error); - g_object_unref (connection); - connection = NULL; - } - -out: - g_key_file_free (key_file); - return connection; -} - diff --git a/src/settings/plugins/keyfile/reader.h b/src/settings/plugins/keyfile/reader.h deleted file mode 100644 index 7bbc6005..00000000 --- a/src/settings/plugins/keyfile/reader.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 Red Hat, Inc. - */ - -#ifndef _KEYFILE_PLUGIN_READER_H -#define _KEYFILE_PLUGIN_READER_H - -#include - -NMConnection *nm_keyfile_plugin_connection_from_file (const char *filename, GError **error); - -#endif /* _KEYFILE_PLUGIN_READER_H */ diff --git a/src/settings/plugins/keyfile/tests/Makefile.am b/src/settings/plugins/keyfile/tests/Makefile.am deleted file mode 100644 index fd08b896..00000000 --- a/src/settings/plugins/keyfile/tests/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -if ENABLE_TESTS - -SUBDIRS=keyfiles - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(srcdir)/../ \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) \ - -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ - -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ - -DNMCONFDIR=\"nonexistent\" - -noinst_PROGRAMS = test-keyfile - -test_keyfile_SOURCES = \ - test-keyfile.c \ - ../reader.c \ - ../writer.c \ - ../utils.c - -test_keyfile_LDADD = \ - $(top_builddir)/src/libNetworkManager.la \ - $(CODE_COVERAGE_LDFLAGS) - -@VALGRIND_RULES@ -TESTS = test-keyfile - -endif diff --git a/src/settings/plugins/keyfile/tests/Makefile.in b/src/settings/plugins/keyfile/tests/Makefile.in deleted file mode 100644 index ffa882b2..00000000 --- a/src/settings/plugins/keyfile/tests/Makefile.in +++ /dev/null @@ -1,1317 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-keyfile$(EXEEXT) -@ENABLE_TESTS_TRUE@TESTS = test-keyfile$(EXEEXT) -subdir = src/settings/plugins/keyfile/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am__test_keyfile_SOURCES_DIST = test-keyfile.c ../reader.c ../writer.c \ - ../utils.c -@ENABLE_TESTS_TRUE@am_test_keyfile_OBJECTS = test-keyfile.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ reader.$(OBJEXT) writer.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ utils.$(OBJEXT) -test_keyfile_OBJECTS = $(am_test_keyfile_OBJECTS) -am__DEPENDENCIES_1 = -@ENABLE_TESTS_TRUE@test_keyfile_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ -@ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_keyfile_SOURCES) -DIST_SOURCES = $(am__test_keyfile_SOURCES_DIST) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - check recheck distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -DIST_SUBDIRS = keyfiles -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@ENABLE_TESTS_TRUE@SUBDIRS = keyfiles -@ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ -@ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -@ENABLE_TESTS_TRUE@ -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ -@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ -@ENABLE_TESTS_TRUE@ -DNMCONFDIR=\"nonexistent\" - -@ENABLE_TESTS_TRUE@test_keyfile_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-keyfile.c \ -@ENABLE_TESTS_TRUE@ ../reader.c \ -@ENABLE_TESTS_TRUE@ ../writer.c \ -@ENABLE_TESTS_TRUE@ ../utils.c - -@ENABLE_TESTS_TRUE@test_keyfile_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) - -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/keyfile/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/keyfile/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-keyfile$(EXEEXT): $(test_keyfile_OBJECTS) $(test_keyfile_DEPENDENCIES) $(EXTRA_test_keyfile_DEPENDENCIES) - @rm -f test-keyfile$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_keyfile_OBJECTS) $(test_keyfile_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-keyfile.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -reader.o: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.o -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c - -reader.obj: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.obj -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` - -writer.o: ../writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.o -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c - -writer.obj: ../writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.obj -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` - -utils.o: ../utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.o -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c - -utils.obj: ../utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.obj -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-keyfile.log: test-keyfile$(EXEEXT) - @p='test-keyfile$(EXEEXT)'; \ - b='test-keyfile'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-recursive -all-am: Makefile $(PROGRAMS) -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) check-am install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-TESTS check-am clean clean-generic clean-libtool \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \ - uninstall uninstall-am - -.PRECIOUS: Makefile - - -@ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am deleted file mode 100644 index be431067..00000000 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -KEYFILES = \ - Test_Wired_Connection \ - Test_GSM_Connection \ - Test_Wireless_Connection \ - Test_Wired_Connection_MAC_Case \ - Test_MAC_Old_Format \ - Test_MAC_IB_Old_Format \ - Test_Wired_Connection_IP6 \ - ATT_Data_Connect_BT \ - ATT_Data_Connect_Plain \ - Test_String_SSID \ - Test_Intlist_SSID \ - Test_Intlike_SSID \ - Test_Intlike_SSID_2 \ - Test_Wired_TLS_Old \ - Test_Wired_TLS_New \ - Test_Wired_TLS_Blob \ - Test_Wired_TLS_Path_Missing \ - Test_InfiniBand_Connection \ - Test_Bridge_Main \ - Test_Bridge_Component \ - Test_New_Wired_Group_Name \ - Test_New_Wireless_Group_Names \ - Test_minimal_1 \ - Test_minimal_2 \ - Test_minimal_slave_1 \ - Test_minimal_slave_2 \ - Test_minimal_slave_3 \ - Test_minimal_slave_4 \ - Test_Missing_Vlan_Setting \ - Test_Missing_Vlan_Flags \ - Test_Missing_ID_UUID \ - Test_Enum_Property \ - Test_Flags_Property - -CERTS = \ - test-ca-cert.pem \ - test-key-and-cert.pem - -EXTRA_DIST = $(KEYFILES) $(CERTS) - -check-local: - @for f in $(KEYFILES); do \ - chmod 0600 $(abs_srcdir)/$$f; \ - done - diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in deleted file mode 100644 index cac6dcd0..00000000 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in +++ /dev/null @@ -1,647 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/keyfile/tests/keyfiles -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -KEYFILES = \ - Test_Wired_Connection \ - Test_GSM_Connection \ - Test_Wireless_Connection \ - Test_Wired_Connection_MAC_Case \ - Test_MAC_Old_Format \ - Test_MAC_IB_Old_Format \ - Test_Wired_Connection_IP6 \ - ATT_Data_Connect_BT \ - ATT_Data_Connect_Plain \ - Test_String_SSID \ - Test_Intlist_SSID \ - Test_Intlike_SSID \ - Test_Intlike_SSID_2 \ - Test_Wired_TLS_Old \ - Test_Wired_TLS_New \ - Test_Wired_TLS_Blob \ - Test_Wired_TLS_Path_Missing \ - Test_InfiniBand_Connection \ - Test_Bridge_Main \ - Test_Bridge_Component \ - Test_New_Wired_Group_Name \ - Test_New_Wireless_Group_Names \ - Test_minimal_1 \ - Test_minimal_2 \ - Test_minimal_slave_1 \ - Test_minimal_slave_2 \ - Test_minimal_slave_3 \ - Test_minimal_slave_4 \ - Test_Missing_Vlan_Setting \ - Test_Missing_Vlan_Flags \ - Test_Missing_ID_UUID \ - Test_Enum_Property \ - Test_Flags_Property - -CERTS = \ - test-ca-cert.pem \ - test-key-and-cert.pem - -EXTRA_DIST = $(KEYFILES) $(CERTS) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/keyfile/tests/keyfiles/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/keyfile/tests/keyfiles/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: all all-am check check-am check-local clean clean-generic \ - clean-libtool cscopelist-am ctags-am distclean \ - distclean-generic distclean-libtool distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ - uninstall-am - -.PRECIOUS: Makefile - - -check-local: - @for f in $(KEYFILES); do \ - chmod 0600 $(abs_srcdir)/$$f; \ - done - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_dcb_connection b/src/settings/plugins/keyfile/tests/keyfiles/Test_dcb_connection new file mode 100644 index 00000000..16d4b45e --- /dev/null +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_dcb_connection @@ -0,0 +1,33 @@ +[connection] +id=dcb connection 1 +uuid=ac3c251e-260f-49b6-8ceb-12d37ea00751 +type=ethernet +autoconnect=false +permissions= +secondaries= + +[ethernet] +mac-address-blacklist= + +[dcb] +app-fcoe-flags=1 +app-fip-flags=1 +app-iscsi-flags=1 +priority-bandwidth=0;0;0;0;0;0;0;0; +priority-flow-control=0;0;0;0;0;0;0;0; +priority-flow-control-flags=1 +priority-group-bandwidth=100;0;0;0;0;0;0;0; +priority-group-flags=1 +priority-group-id=0;0;0;0;0;0;0;0; +priority-strict-bandwidth=0;0;0;0;0;0;0;0; +priority-traffic-class=0;0;0;0;0;0;0;0; + +[ipv4] +dns-search= +method=auto + +[ipv6] +addr-gen-mode=stable-privacy +dns-search= +ip6-privacy=0 +method=auto diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index e63fa495..f1102bd3 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -30,12 +30,14 @@ #include "nm-core-internal.h" -#include "reader.h" -#include "writer.h" -#include "utils.h" +#include "settings/plugins/keyfile/nms-keyfile-reader.h" +#include "settings/plugins/keyfile/nms-keyfile-writer.h" +#include "settings/plugins/keyfile/nms-keyfile-utils.h" #include "nm-test-utils-core.h" +/*****************************************************************************/ + static void check_ip_address (NMSettingIPConfig *config, int idx, const char *address, int plen) { @@ -62,12 +64,12 @@ check_ip_route (NMSettingIPConfig *config, int idx, const char *destination, int static NMConnection * keyfile_read_connection_from_file (const char *filename) { - GError *error = NULL; + gs_free_error GError *error = NULL; NMConnection *connection; g_assert (filename); - connection = nm_keyfile_plugin_connection_from_file (filename, &error); + connection = nms_keyfile_reader_from_file (filename, &error); g_assert_no_error (error); nmtst_assert_connection_verifies_without_normalization (connection); @@ -75,15 +77,101 @@ keyfile_read_connection_from_file (const char *filename) return connection; } +static void +assert_reread (NMConnection *connection, gboolean normalize_connection, const char *testfile) +{ + gs_unref_object NMConnection *reread = NULL; + gs_unref_object NMConnection *connection_clone = NULL; + GError *error = NULL; + GError **p_error = (nmtst_get_rand_int () % 2) ? &error : NULL; + NMSettingConnection *s_con; + + g_assert (NM_IS_CONNECTION (connection)); + g_assert (testfile && testfile[0]); + + reread = nms_keyfile_reader_from_file (testfile, p_error); + g_assert_no_error (error); + g_assert (NM_IS_CONNECTION (reread)); + + if ( !normalize_connection + && (s_con = nm_connection_get_setting_connection (connection)) + && !nm_setting_connection_get_master (s_con) + && !nm_connection_get_setting_proxy (connection)) { + connection_clone = nmtst_clone_connection (connection); + connection = connection_clone; + nm_connection_add_setting (connection, nm_setting_proxy_new ()); + } + + nmtst_assert_connection_equals (connection, normalize_connection, reread, FALSE); +} + +static void +assert_reread_and_unlink (NMConnection *connection, gboolean normalize_connection, const char *testfile) +{ + assert_reread (connection, normalize_connection, testfile); + unlink (testfile); +} + +static void +write_test_connection (NMConnection *connection, char **testfile) +{ + uid_t owner_uid; + gid_t owner_grp; + gboolean success; + GError *error = NULL; + GError **p_error = (nmtst_get_rand_int () % 2) ? &error : NULL; + + g_assert (NM_IS_CONNECTION (connection)); + g_assert (testfile && !*testfile); + + owner_uid = geteuid (); + owner_grp = getegid (); + + success = nms_keyfile_writer_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, testfile, p_error); + g_assert_no_error (error); + g_assert (success); + g_assert (*testfile && (*testfile)[0]); +} + +static void +write_test_connection_and_reread (NMConnection *connection, gboolean normalize_connection) +{ + gs_free char *testfile = NULL; + + g_assert (NM_IS_CONNECTION (connection)); + + write_test_connection (connection, &testfile); + assert_reread_and_unlink (connection, normalize_connection, testfile); +} + +static GKeyFile * +keyfile_load_from_file (const char *testfile) +{ + GKeyFile *keyfile; + GError *error = NULL; + gboolean success; + + g_assert (testfile && *testfile); + + keyfile = g_key_file_new (); + success = g_key_file_load_from_file (keyfile, testfile, G_KEY_FILE_NONE, &error); + g_assert_no_error (error); + g_assert(success); + + return keyfile; +} + +/*****************************************************************************/ + static void test_read_valid_wired_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; gboolean success; @@ -116,7 +204,8 @@ test_read_valid_wired_connection (void) "*ipv6.routes*semicolon at the end*routes1*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*ipv6.route*semicolon at the end*route6*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", &error); + g_assert_no_error (error); g_test_assert_expected_messages (); g_assert (connection); @@ -215,7 +304,6 @@ test_read_valid_wired_connection (void) check_ip_route (s_ip6, 4, "7:8:9:0:1:2:3:4", 125, NULL, 5); check_ip_route (s_ip6, 5, "8:9:0:1:2:3:4:5", 124, NULL, 6); check_ip_route (s_ip6, 6, "8:9:0:1:2:3:4:6", 123, NULL, -1); - g_object_unref (connection); } static void @@ -224,7 +312,7 @@ add_one_ip_address (NMSettingIPConfig *s_ip, guint32 prefix) { NMIPAddress *ip_addr; - GError *error = NULL; + gs_free_error GError *error = NULL; ip_addr = nm_ip_address_new (NM_IS_SETTING_IP4_CONFIG (s_ip) ? AF_INET : AF_INET6, addr, prefix, &error); @@ -241,7 +329,7 @@ add_one_ip_route (NMSettingIPConfig *s_ip, gint64 metric) { NMIPRoute *route; - GError *error = NULL; + gs_free_error GError *error = NULL; g_assert (prefix > 0); route = nm_ip_route_new (NM_IS_SETTING_IP4_CONFIG (s_ip) ? AF_INET : AF_INET6, @@ -255,19 +343,13 @@ add_one_ip_route (NMSettingIPConfig *s_ip, static void test_write_wired_connection (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; const char *mac = "99:88:77:66:55:44"; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; const char *dns1 = "4.2.2.1"; const char *dns2 = "4.2.2.2"; const char *address1 = "192.168.0.5"; @@ -302,7 +384,6 @@ test_write_wired_connection (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Work Wired", NM_SETTING_CONNECTION_UUID, uuid, @@ -310,7 +391,6 @@ test_write_wired_connection (void) NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_TIMESTAMP, timestamp, NULL); - g_free (uuid); /* Wired setting */ @@ -372,39 +452,21 @@ test_write_wired_connection (void) /* DNS searches */ nm_setting_ip_config_add_dns_search (s_ip6, "wallaceandgromit.com"); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, NULL); - g_assert (reread); - g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } static void test_read_ip6_wired_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_IP6", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_IP6", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -433,25 +495,17 @@ test_read_ip6_wired_connection (void) g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip6), ==, 1); check_ip_address (s_ip6, 0, "abcd:1234:ffff::cdde", 64); g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip6), ==, "abcd:1234:ffff::cdd1"); - - g_object_unref (connection); } static void test_write_ip6_wired_connection (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; const char *dns = "1::cafe"; const char *address = "abcd::beef"; const char *gw = "dcba::beef"; @@ -463,14 +517,12 @@ test_write_ip6_wired_connection (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Work Wired IP6", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ @@ -505,34 +557,16 @@ test_write_ip6_wired_connection (void) /* DNS searches */ nm_setting_ip_config_add_dns_search (s_ip6, "wallaceandgromit.com"); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, NULL); - g_assert (reread); - g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } static void test_read_wired_mac_case (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *mac; char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55 }; gboolean success; @@ -543,7 +577,7 @@ test_read_wired_mac_case (void) "*ipv4.addresses*semicolon at the end*addresses2*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*ipv6.routes*semicolon at the end*routes1*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL); g_test_assert_expected_messages (); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -562,22 +596,20 @@ test_read_wired_mac_case (void) mac = nm_setting_wired_get_mac_address (s_wired); g_assert (mac); g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, sizeof (expected_mac_address))); - - g_object_unref (connection); } static void test_read_mac_old_format (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWired *s_wired; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; const char *mac; char expected_mac[ETH_ALEN] = { 0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55 }; char expected_cloned_mac[ETH_ALEN] = { 0x00, 0x16, 0xaa, 0xbb, 0xcc, 0xfe }; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_MAC_Old_Format", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_MAC_Old_Format", &error); g_assert_no_error (error); g_assert (connection); @@ -597,23 +629,21 @@ test_read_mac_old_format (void) mac = nm_setting_wired_get_cloned_mac_address (s_wired); g_assert (mac); g_assert (nm_utils_hwaddr_matches (mac, -1, expected_cloned_mac, ETH_ALEN)); - - g_object_unref (connection); } static void test_read_mac_ib_old_format (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingInfiniband *s_ib; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; const char *mac; guint8 expected_mac[INFINIBAND_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x90 }; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_MAC_IB_Old_Format", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_MAC_IB_Old_Format", &error); g_assert_no_error (error); g_assert (connection); @@ -628,23 +658,21 @@ test_read_mac_ib_old_format (void) mac = nm_setting_infiniband_get_mac_address (s_ib); g_assert (mac); g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac, sizeof (expected_mac))); - - g_object_unref (connection); } static void test_read_valid_wireless_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingIPConfig *s_ip4; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *bssid; const guint8 expected_bssid[ETH_ALEN] = { 0x00, 0x1a, 0x33, 0x44, 0x99, 0x82 }; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wireless_Connection", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wireless_Connection", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -669,28 +697,20 @@ test_read_valid_wireless_connection (void) s_ip4 = nm_connection_get_setting_ip4_config (connection); g_assert (s_ip4); g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - - g_object_unref (connection); } static void test_write_wireless_connection (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; const char *bssid = "aa:b9:a1:74:55:44"; GBytes *ssid; unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 }; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; guint64 timestamp = 0x12344433L; connection = nm_simple_connection_new (); @@ -700,7 +720,6 @@ test_write_wireless_connection (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Work Wireless", NM_SETTING_CONNECTION_UUID, uuid, @@ -708,7 +727,6 @@ test_write_wireless_connection (void) NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_CONNECTION_TIMESTAMP, timestamp, NULL); - g_free (uuid); /* Wireless setting */ @@ -743,40 +761,22 @@ test_write_wireless_connection (void) NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, NULL); - g_assert (reread); - g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } static void test_read_string_ssid (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWireless *s_wireless; - GError *error = NULL; + gs_free_error GError *error = NULL; GBytes *ssid; const guint8 *ssid_data; gsize ssid_len; const char *expected_ssid = "blah blah ssid 1234"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_String_SSID", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_String_SSID", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -789,26 +789,21 @@ test_read_string_ssid (void) g_assert (ssid); ssid_data = g_bytes_get_data (ssid, &ssid_len); g_assert_cmpmem (ssid_data, ssid_len, expected_ssid, strlen (expected_ssid)); - - g_object_unref (connection); } static void test_write_string_ssid (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wireless; NMSettingIPConfig *s_ip4; - char *uuid, *testfile = NULL, *tmp; + char *tmp; + gs_free char *testfile = NULL; GBytes *ssid; unsigned char tmpssid[] = { 65, 49, 50, 51, 32, 46, 92, 46, 36, 37, 126, 93 }; - gboolean success; - NMConnection *reread; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; - GKeyFile *keyfile; + gs_unref_keyfile GKeyFile *keyfile = NULL; connection = nm_simple_connection_new (); @@ -817,13 +812,11 @@ test_write_string_ssid (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "String SSID Test", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wireless setting */ @@ -843,50 +836,31 @@ test_write_string_ssid (void) NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); + write_test_connection (connection, &testfile); /* Ensure the SSID was written out as a string */ - keyfile = g_key_file_new (); - g_assert (g_key_file_load_from_file (keyfile, testfile, 0, NULL)); + keyfile = keyfile_load_from_file (testfile); tmp = g_key_file_get_string (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, NULL); g_assert (tmp); g_assert_cmpmem (tmp, strlen (tmp), tmpssid, sizeof (tmpssid)); g_free (tmp); - g_key_file_free (keyfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, NULL); - g_assert (reread); - - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + assert_reread_and_unlink (connection, TRUE, testfile); } static void test_read_intlist_ssid (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWireless *s_wifi; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; GBytes *ssid; const guint8 *ssid_data; gsize ssid_len; const char *expected_ssid = "blah1234"; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlist_SSID", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlist_SSID", &error); g_assert_no_error (error); g_assert (connection); @@ -902,26 +876,21 @@ test_read_intlist_ssid (void) g_assert (ssid != NULL); ssid_data = g_bytes_get_data (ssid, &ssid_len); g_assert_cmpmem (ssid_data, ssid_len, expected_ssid, strlen (expected_ssid)); - - g_object_unref (connection); } static void test_write_intlist_ssid (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingIPConfig *s_ip4; - char *uuid, *testfile = NULL; + gs_free char *testfile = NULL; GBytes *ssid; unsigned char tmpssid[] = { 65, 49, 50, 51, 0, 50, 50 }; - gboolean success; - NMConnection *reread; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; - GKeyFile *keyfile; + gs_free_error GError *error = NULL; + gs_unref_keyfile GKeyFile *keyfile = NULL; gint *intlist; gsize len = 0, i; @@ -934,13 +903,11 @@ test_write_intlist_ssid (void) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Intlist SSID Test", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wireless setting */ s_wifi = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); @@ -957,19 +924,10 @@ test_write_intlist_ssid (void) nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile != NULL); + write_test_connection (connection, &testfile); /* Ensure the SSID was written out as an int list */ - keyfile = g_key_file_new (); - success = g_key_file_load_from_file (keyfile, testfile, 0, &error); - g_assert_no_error (error); - g_assert (success); + keyfile = keyfile_load_from_file (testfile); intlist = g_key_file_get_integer_list (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, &len, &error); g_assert_no_error (error); @@ -980,36 +938,22 @@ test_write_intlist_ssid (void) g_assert_cmpint (intlist[i], ==, tmpssid[i]); g_free (intlist); - g_key_file_free (keyfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + assert_reread_and_unlink (connection, TRUE, testfile); } static void test_read_intlike_ssid (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWireless *s_wifi; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; GBytes *ssid; const guint8 *ssid_data; gsize ssid_len; const char *expected_ssid = "101"; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID", &error); g_assert_no_error (error); g_assert (connection); @@ -1026,23 +970,21 @@ test_read_intlike_ssid (void) ssid_data = g_bytes_get_data (ssid, &ssid_len); g_assert_cmpint (ssid_len, ==, strlen (expected_ssid)); g_assert_cmpint (memcmp (ssid_data, expected_ssid, strlen (expected_ssid)), ==, 0); - - g_object_unref (connection); } static void test_read_intlike_ssid_2 (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWireless *s_wifi; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; GBytes *ssid; const guint8 *ssid_data; gsize ssid_len; const char *expected_ssid = "11;12;13;"; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID_2", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID_2", &error); g_assert_no_error (error); g_assert (connection); @@ -1059,30 +1001,24 @@ test_read_intlike_ssid_2 (void) ssid_data = g_bytes_get_data (ssid, &ssid_len); g_assert_cmpint (ssid_len, ==, strlen (expected_ssid)); g_assert_cmpint (memcmp (ssid_data, expected_ssid, strlen (expected_ssid)), ==, 0); - - g_object_unref (connection); } static void test_write_intlike_ssid (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingIPConfig *s_ip4; - char *uuid, *testfile = NULL; + gs_free char *testfile = NULL; GBytes *ssid; unsigned char tmpssid[] = { 49, 48, 49 }; - gboolean success; - NMConnection *reread; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; - GKeyFile *keyfile; + gs_free_error GError *error = NULL; + gs_unref_keyfile GKeyFile *keyfile = NULL; char *tmp; connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ @@ -1090,13 +1026,11 @@ test_write_intlike_ssid (void) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Intlike SSID Test", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wireless setting */ s_wifi = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); @@ -1113,19 +1047,10 @@ test_write_intlike_ssid (void) nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile != NULL); + write_test_connection (connection, &testfile); /* Ensure the SSID was written out as a plain "101" */ - keyfile = g_key_file_new (); - success = g_key_file_load_from_file (keyfile, testfile, 0, &error); - g_assert_no_error (error); - g_assert (success); + keyfile = keyfile_load_from_file (testfile); tmp = g_key_file_get_string (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, &error); g_assert_no_error (error); @@ -1133,39 +1058,22 @@ test_write_intlike_ssid (void) g_assert_cmpstr (tmp, ==, "101"); g_free (tmp); - g_key_file_free (keyfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + assert_reread_and_unlink (connection, TRUE, testfile); } static void test_write_intlike_ssid_2 (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingIPConfig *s_ip4; - char *uuid, *testfile = NULL; + gs_free char *testfile = NULL; GBytes *ssid; unsigned char tmpssid[] = { 49, 49, 59, 49, 50, 59, 49, 51, 59}; - gboolean success; - NMConnection *reread; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; - GKeyFile *keyfile; + gs_free_error GError *error = NULL; + gs_unref_keyfile GKeyFile *keyfile = NULL; char *tmp; connection = nm_simple_connection_new (); @@ -1177,13 +1085,11 @@ test_write_intlike_ssid_2 (void) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Intlike SSID Test 2", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wireless setting */ s_wifi = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); @@ -1200,19 +1106,10 @@ test_write_intlike_ssid_2 (void) nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile != NULL); + write_test_connection (connection, &testfile); /* Ensure the SSID was written out as a plain "11;12;13;" */ - keyfile = g_key_file_new (); - success = g_key_file_load_from_file (keyfile, testfile, 0, &error); - g_assert_no_error (error); - g_assert (success); + keyfile = keyfile_load_from_file (testfile); tmp = g_key_file_get_string (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, &error); g_assert_no_error (error); @@ -1220,37 +1117,23 @@ test_write_intlike_ssid_2 (void) g_assert_cmpstr (tmp, ==, "11\\;12\\;13\\;"); g_free (tmp); - g_key_file_free (keyfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + assert_reread_and_unlink (connection, TRUE, testfile); } static void test_read_bt_dun_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingBluetooth *s_bluetooth; NMSettingSerial *s_serial; NMSettingGsm *s_gsm; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *bdaddr; const guint8 expected_bdaddr[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_BT", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_BT", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -1281,26 +1164,18 @@ test_read_bt_dun_connection (void) s_serial = nm_connection_get_setting_serial (connection); g_assert (s_serial); g_assert (nm_setting_serial_get_parity (s_serial) == NM_SETTING_SERIAL_PARITY_ODD); - - g_object_unref (connection); } static void test_write_bt_dun_connection (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingBluetooth *s_bt; NMSettingIPConfig *s_ip4; NMSettingGsm *s_gsm; - char *uuid; const char *bdaddr = "aa:b9:a1:74:55:44"; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; guint64 timestamp = 0x12344433L; connection = nm_simple_connection_new (); @@ -1310,7 +1185,6 @@ test_write_bt_dun_connection (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "T-Mobile Funkadelic", NM_SETTING_CONNECTION_UUID, uuid, @@ -1318,7 +1192,6 @@ test_write_bt_dun_connection (void) NM_SETTING_CONNECTION_TYPE, NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_CONNECTION_TIMESTAMP, timestamp, NULL); - g_free (uuid); /* Bluetooth setting */ @@ -1350,39 +1223,20 @@ test_write_bt_dun_connection (void) NM_SETTING_GSM_NUMBER, "*99#", NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, NULL); - g_assert (reread); - - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, TRUE); } static void test_read_gsm_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingSerial *s_serial; NMSettingGsm *s_gsm; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_Plain", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_Plain", &error); g_assert_no_error (error); g_assert (connection); @@ -1416,24 +1270,16 @@ test_read_gsm_connection (void) s_serial = nm_connection_get_setting_serial (connection); g_assert (s_serial); g_assert_cmpint (nm_setting_serial_get_parity (s_serial), ==, NM_SETTING_SERIAL_PARITY_ODD); - - g_object_unref (connection); } static void test_write_gsm_connection (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; NMSettingGsm *s_gsm; - char *uuid; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; guint64 timestamp = 0x12344433L; connection = nm_simple_connection_new (); @@ -1443,7 +1289,6 @@ test_write_gsm_connection (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "T-Mobile Funkadelic 2", NM_SETTING_CONNECTION_UUID, uuid, @@ -1451,7 +1296,6 @@ test_write_gsm_connection (void) NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CONNECTION_TIMESTAMP, timestamp, NULL); - g_free (uuid); /* IP4 setting */ @@ -1479,36 +1323,16 @@ test_write_gsm_connection (void) NM_SETTING_GSM_SIM_OPERATOR_ID, "310260", NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile != NULL); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_clear_error (&error); - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, TRUE); } static void test_read_wired_8021x_tls_blob_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWired *s_wired; NMSetting8021x *s_8021x; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *tmp; gboolean success; GBytes *blob; @@ -1517,7 +1341,7 @@ test_read_wired_8021x_tls_blob_connection (void) "* * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "* * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1561,24 +1385,22 @@ test_read_wired_8021x_tls_blob_connection (void) tmp = nm_setting_802_1x_get_private_key_path (s_8021x); g_assert_cmpstr (tmp, ==, "/CASA/dcbw/Desktop/certinfra/client.pem"); - - g_object_unref (connection); } static void test_read_wired_8021x_tls_bad_path_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWired *s_wired; NMSetting8021x *s_8021x; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *tmp; char *tmp2; gboolean success; g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*does not exist*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error); g_test_assert_expected_messages (); g_assert_no_error (error); g_assert (connection); @@ -1618,16 +1440,15 @@ test_read_wired_8021x_tls_bad_path_connection (void) g_assert_cmpstr (tmp, ==, tmp2); g_free (tmp2); - g_object_unref (connection); } static void test_read_wired_8021x_tls_old_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWired *s_wired; NMSetting8021x *s_8021x; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *tmp; gboolean success; @@ -1637,7 +1458,7 @@ test_read_wired_8021x_tls_old_connection (void) "* * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "* * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1670,22 +1491,20 @@ test_read_wired_8021x_tls_old_connection (void) tmp = nm_setting_802_1x_get_private_key_path (s_8021x); g_assert (g_strcmp0 (tmp, "/CASA/dcbw/Desktop/certinfra/client.pem") == 0); - - g_object_unref (connection); } static void test_read_wired_8021x_tls_new_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWired *s_wired; NMSetting8021x *s_8021x; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *tmp; char *tmp2; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_New", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_New", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1724,7 +1543,6 @@ test_read_wired_8021x_tls_new_connection (void) g_assert_cmpstr (tmp, ==, tmp2); g_free (tmp2); - g_object_unref (connection); } #define TEST_WIRED_TLS_CA_CERT TEST_KEYFILES_DIR"/test-ca-cert.pem" @@ -1734,14 +1552,14 @@ test_read_wired_8021x_tls_new_connection (void) static NMConnection * create_wired_tls_connection (NMSetting8021xCKScheme scheme) { + NMTST_UUID_INIT (uuid); NMConnection *connection; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; NMSetting *s_wired; NMSetting8021x *s_8021x; - char *uuid; gboolean success; - GError *error = NULL; + gs_free_error GError *error = NULL; connection = nm_simple_connection_new (); g_assert (connection != NULL); @@ -1751,13 +1569,11 @@ create_wired_tls_connection (NMSetting8021xCKScheme scheme) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Wired Really Secure TLS", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); @@ -1815,29 +1631,22 @@ get_path (const char *file, gboolean relative) static void test_write_wired_8021x_tls_connection_path (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; char *tmp, *tmp2; gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - GKeyFile *keyfile; + gs_free char *testfile = NULL; + gs_free_error GError *error = NULL; + gs_unref_keyfile GKeyFile *keyfile = NULL; gboolean relative = FALSE; connection = create_wired_tls_connection (NM_SETTING_802_1X_CK_SCHEME_PATH); g_assert (connection != NULL); - /* Write out the connection */ - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, geteuid (), getegid (), &testfile, &error); - if (!success) { - g_assert (error); - g_warning ("Failed to write keyfile: %s", error->message); - g_assert (success); - } - g_assert (testfile); + write_test_connection (connection, &testfile); /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); + reread = nms_keyfile_reader_from_file (testfile, &error); if (!reread) { g_assert (error); g_warning ("Failed to re-read test connection: %s", error->message); @@ -1851,14 +1660,7 @@ test_write_wired_8021x_tls_connection_path (void) } /* Ensure the cert and key values are properly written out */ - keyfile = g_key_file_new (); - g_assert (keyfile); - success = g_key_file_load_from_file (keyfile, testfile, G_KEY_FILE_NONE, &error); - if (!success) { - g_assert (error); - g_warning ("Failed to re-read test file %s: %s", testfile, error->message); - g_assert (success); - } + keyfile = keyfile_load_from_file (testfile); /* Depending on whether this test is being run from 'make check' or * 'make distcheck' we might be using relative paths (check) or @@ -1899,28 +1701,22 @@ test_write_wired_8021x_tls_connection_path (void) g_free (tmp2); g_free (tmp); - g_key_file_free (keyfile); unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); } static void test_write_wired_8021x_tls_connection_blob (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSetting8021x *s_8021x; - gboolean success; - NMConnection *reread; - char *testfile = NULL; + gs_free char *testfile = NULL; char *new_ca_cert; char *new_client_cert; char *new_priv_key; const char *uuid; - GError *error = NULL; + gs_free_error GError *error = NULL; GBytes *password_raw = NULL; #define PASSWORD_RAW "password-raw\0test" @@ -1937,14 +1733,7 @@ test_write_wired_8021x_tls_connection_blob (void) NULL); g_bytes_unref (password_raw); - /* Write out the connection */ - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, geteuid (), getegid (), &testfile, &error); - if (!success) { - g_assert (error); - g_warning ("Failed to write keyfile: %s", error->message); - g_assert (success); - } - g_assert (testfile); + write_test_connection (connection, &testfile); /* Check that the new certs got written out */ s_con = nm_connection_get_setting_connection (connection); @@ -1965,7 +1754,7 @@ test_write_wired_8021x_tls_connection_blob (void) g_assert (g_file_test (new_priv_key, G_FILE_TEST_EXISTS)); /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); + reread = nms_keyfile_reader_from_file (testfile, &error); if (!reread) { g_assert (error); g_warning ("Failed to re-read test connection: %s", error->message); @@ -1985,7 +1774,6 @@ test_write_wired_8021x_tls_connection_blob (void) g_assert (!memcmp (g_bytes_get_data (password_raw, NULL), PASSWORD_RAW, NM_STRLEN (PASSWORD_RAW))); unlink (testfile); - g_free (testfile); /* Clean up written certs */ unlink (new_ca_cert); @@ -1996,18 +1784,23 @@ test_write_wired_8021x_tls_connection_blob (void) unlink (new_priv_key); g_free (new_priv_key); +} - g_object_unref (reread); - g_object_unref (connection); +static void +test_read_dcb_connection (void) +{ + gs_unref_object NMConnection *connection = NULL; + + connection = keyfile_read_connection_from_file (TEST_KEYFILES_DIR"/Test_dcb_connection"); } static void test_read_infiniband_connection (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingInfiniband *s_ib; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *mac; guint8 expected_mac[INFINIBAND_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, @@ -2016,7 +1809,7 @@ test_read_infiniband_connection (void) const char *expected_uuid = "4e80a56d-c99f-4aad-a6dd-b449bc398c57"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_InfiniBand_Connection", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_InfiniBand_Connection", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2036,29 +1829,20 @@ test_read_infiniband_connection (void) mac = nm_setting_infiniband_get_mac_address (s_ib); g_assert (mac); g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac, sizeof (expected_mac))); - - g_object_unref (connection); } static void test_write_infiniband_connection (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingInfiniband *s_ib; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; const char *mac = "99:88:77:66:55:44:ab:bc:cd:de:ef:f0:0a:1b:2c:3d:4e:5f:6f:ba"; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ @@ -2066,14 +1850,12 @@ test_write_infiniband_connection (void) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Work InfiniBand", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_INFINIBAND_SETTING_NAME, NULL); - g_free (uuid); /* InfiniBand setting */ s_ib = (NMSettingInfiniband *) nm_setting_infiniband_new (); @@ -2098,41 +1880,22 @@ test_write_infiniband_connection (void) nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); - - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } static void test_read_bridge_main (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; NMSettingBridge *s_bridge; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *expected_id = "Test Bridge Main"; const char *expected_uuid = "8f061643-fe41-4d4c-a8d9-097d26e2ad3a"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Main", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Main", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2161,25 +1924,17 @@ test_read_bridge_main (void) g_assert_cmpuint (nm_setting_bridge_get_max_age (s_bridge), ==, 39); g_assert_cmpuint (nm_setting_bridge_get_ageing_time (s_bridge), ==, 235352); g_assert_cmpuint (nm_setting_bridge_get_multicast_snooping (s_bridge), ==, FALSE); - - g_object_unref (connection); } static void test_write_bridge_main (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingBridge *s_bridge; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; connection = nm_simple_connection_new (); g_assert (connection); @@ -2189,7 +1944,6 @@ test_write_bridge_main (void) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Main", NM_SETTING_CONNECTION_UUID, uuid, @@ -2197,7 +1951,6 @@ test_write_bridge_main (void) NM_SETTING_CONNECTION_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME, "br0", NULL); - g_free (uuid); /* Bridge setting */ s_bridge = (NMSettingBridge *) nm_setting_bridge_new (); @@ -2222,43 +1975,24 @@ test_write_bridge_main (void) nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); - - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } static void test_read_bridge_component (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingBridgePort *s_port; NMSettingWired *s_wired; const char *mac; guint8 expected_mac[ETH_ALEN] = { 0x00, 0x22, 0x15, 0x59, 0x62, 0x97 }; - GError *error = NULL; + gs_free_error GError *error = NULL; const char *expected_id = "Test Bridge Component"; const char *expected_uuid = "d7b4f96c-c45e-4298-bef8-f48574f8c1c0"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Component", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Component", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2286,25 +2020,17 @@ test_read_bridge_component (void) g_assert (nm_setting_bridge_port_get_hairpin_mode (s_port)); g_assert_cmpuint (nm_setting_bridge_port_get_priority (s_port), ==, 28); g_assert_cmpuint (nm_setting_bridge_port_get_path_cost (s_port), ==, 100); - - g_object_unref (connection); } static void test_write_bridge_component (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingBridgePort *s_port; NMSettingWired *s_wired; - char *uuid; const char *mac = "99:88:77:66:55:44"; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; connection = nm_simple_connection_new (); g_assert (connection); @@ -2314,7 +2040,6 @@ test_write_bridge_component (void) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Component", NM_SETTING_CONNECTION_UUID, uuid, @@ -2323,7 +2048,6 @@ test_write_bridge_component (void) NM_SETTING_CONNECTION_MASTER, "br0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); @@ -2345,39 +2069,20 @@ test_write_bridge_component (void) NM_SETTING_BRIDGE_PORT_PATH_COST, 99, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); - - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } static void test_read_new_wired_group_name (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWired *s_wired; const char *mac; guint8 expected_mac[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wired_Group_Name", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_New_Wired_Group_Name", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2392,24 +2097,18 @@ test_read_new_wired_group_name (void) mac = nm_setting_wired_get_mac_address (s_wired); g_assert (mac); g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac, sizeof (expected_mac))); - - g_object_unref (connection); } static void test_write_new_wired_group_name (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; + gs_unref_keyfile GKeyFile *kf = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; - char *uuid; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; - GKeyFile *kf; + gs_free char *testfile = NULL; + gs_free_error GError *error = NULL; char *s; gint mtu; @@ -2421,13 +2120,11 @@ test_write_new_wired_group_name (void) g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired New Group Name", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -2435,25 +2132,12 @@ test_write_new_wired_group_name (void) g_object_set (s_wired, NM_SETTING_WIRED_MTU, 1400, NULL); nm_connection_add_setting (connection, NM_SETTING (s_wired)); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); + write_test_connection (connection, &testfile); - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); + assert_reread (connection, TRUE, testfile); /* Look at the keyfile itself to ensure we wrote out the new group names and type */ - kf = g_key_file_new (); - success = g_key_file_load_from_file (kf, testfile, G_KEY_FILE_NONE, &error); - g_assert_no_error (error); - g_assert (success); + kf = keyfile_load_from_file (testfile); s = g_key_file_get_string (kf, NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE, &error); g_assert_no_error (error); @@ -2465,27 +2149,22 @@ test_write_new_wired_group_name (void) g_assert_cmpint (mtu, ==, 1400); unlink (testfile); - g_free (testfile); - - g_key_file_unref (kf); - g_object_unref (reread); - g_object_unref (connection); } static void test_read_new_wireless_group_names (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; GBytes *ssid; const guint8 *ssid_data; gsize ssid_len; const char *expected_ssid = "foobar"; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wireless_Group_Names", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_New_Wireless_Group_Names", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2509,28 +2188,22 @@ test_read_new_wireless_group_names (void) g_assert (s_wsec); g_assert_cmpstr (nm_setting_wireless_security_get_key_mgmt (s_wsec), ==, "wpa-psk"); g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "s3cu4e passphrase"); - - g_object_unref (connection); } static void test_write_new_wireless_group_names (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; + gs_unref_keyfile GKeyFile *kf = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - char *uuid; GBytes *ssid; unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 }; const char *expected_psk = "asdfasdfasdfa12315"; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; - GKeyFile *kf; + gs_free char *testfile = NULL; + gs_free_error GError *error = NULL; char *s; connection = nm_simple_connection_new (); @@ -2540,13 +2213,11 @@ test_write_new_wireless_group_names (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write New Wireless Group Names", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* WiFi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -2567,26 +2238,12 @@ test_write_new_wireless_group_names (void) NM_SETTING_WIRELESS_SECURITY_PSK, expected_psk, NULL); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - - g_assert (testfile); + write_test_connection (connection, &testfile); - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); + assert_reread (connection, TRUE, testfile); /* Look at the keyfile itself to ensure we wrote out the new group names and type */ - kf = g_key_file_new (); - success = g_key_file_load_from_file (kf, testfile, G_KEY_FILE_NONE, &error); - g_assert_no_error (error); - g_assert (success); + kf = keyfile_load_from_file (testfile); s = g_key_file_get_string (kf, NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE, &error); g_assert_no_error (error); @@ -2604,22 +2261,17 @@ test_write_new_wireless_group_names (void) g_free (s); unlink (testfile); - g_free (testfile); - - g_key_file_unref (kf); - g_object_unref (reread); - g_object_unref (connection); } static void test_read_missing_vlan_setting (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingVlan *s_vlan; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Setting", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Setting", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2631,19 +2283,17 @@ test_read_missing_vlan_setting (void) g_assert (s_vlan); g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 0); g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, NM_VLAN_FLAG_REORDER_HEADERS); - - g_object_unref (connection); } static void test_read_missing_vlan_flags (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingVlan *s_vlan; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Flags", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Flags", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2657,18 +2307,16 @@ test_read_missing_vlan_flags (void) g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 444); g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "em1"); g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, NM_VLAN_FLAG_REORDER_HEADERS); - - g_object_unref (connection); } static void test_read_missing_id_uuid (void) { - NMConnection *connection; - GError *error = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_ID_UUID", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_ID_UUID", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2678,14 +2326,12 @@ test_read_missing_id_uuid (void) /* Ensure the ID and UUID properties are there */ g_assert_cmpstr (nm_connection_get_id (connection), ==, "Test_Missing_ID_UUID"); g_assert (nm_connection_get_uuid (connection)); - - g_object_unref (connection); } static void test_read_minimal (void) { - NMConnection *connection = NULL; + gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *con_archetype = NULL; NMSettingConnection *s_con; @@ -2717,7 +2363,7 @@ test_read_minimal (void) static void test_read_minimal_slave (void) { - NMConnection *connection = NULL; + gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *con_archetype = NULL; NMSettingConnection *s_con; @@ -2769,12 +2415,12 @@ test_read_minimal_slave (void) static void test_read_enum_property (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingIPConfig *s_ip6; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Enum_Property", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Enum_Property", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2785,24 +2431,16 @@ test_read_enum_property (void) s_ip6 = nm_connection_get_setting_ip6_config (connection); g_assert (s_ip6); g_assert_cmpint (nm_setting_ip6_config_get_ip6_privacy (NM_SETTING_IP6_CONFIG (s_ip6)), ==, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR); - - g_object_unref (connection); } static void test_write_enum_property (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip6; - char *uuid; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; connection = nm_simple_connection_new (); @@ -2811,13 +2449,11 @@ test_write_enum_property (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Enum Property", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); @@ -2833,37 +2469,18 @@ test_write_enum_property (void) nmtst_connection_normalize (connection); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - nmtst_assert_connection_equals (reread, FALSE, connection, FALSE); - - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } static void test_read_flags_property (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingGsm *s_gsm; - GError *error = NULL; + gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Flags_Property", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Flags_Property", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2875,23 +2492,15 @@ test_read_flags_property (void) g_assert (s_gsm); g_assert_cmpint (nm_setting_gsm_get_password_flags (s_gsm), ==, NM_SETTING_SECRET_FLAG_AGENT_OWNED | NM_SETTING_SECRET_FLAG_NOT_REQUIRED); - - g_object_unref (connection); } static void test_write_flags_property (void) { - NMConnection *connection; + NMTST_UUID_INIT (uuid); + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; NMSetting *s_gsm; - char *uuid; - gboolean success; - NMConnection *reread; - char *testfile = NULL; - GError *error = NULL; - pid_t owner_grp; - uid_t owner_uid; connection = nm_simple_connection_new (); @@ -2900,13 +2509,11 @@ test_write_flags_property (void) s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Flags Property", NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME, NULL); - g_free (uuid); /* GSM setting */ s_gsm = nm_setting_gsm_new (); @@ -2920,26 +2527,7 @@ test_write_flags_property (void) nmtst_connection_normalize (connection); - /* Write out the connection */ - owner_uid = geteuid (); - owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - g_assert_no_error (error); - g_assert (success); - g_assert (testfile); - - /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); - g_assert_no_error (error); - g_assert (reread); - - nmtst_assert_connection_equals (reread, FALSE, connection, FALSE); - - unlink (testfile); - g_free (testfile); - - g_object_unref (reread); - g_object_unref (connection); + write_test_connection_and_reread (connection, FALSE); } /*****************************************************************************/ @@ -2951,18 +2539,18 @@ _escape_filename (const char *filename, gboolean would_be_ignored) g_assert (filename && filename[0]); - if (!!would_be_ignored != !!nm_keyfile_plugin_utils_should_ignore_file (filename)) { + if (!!would_be_ignored != !!nms_keyfile_utils_should_ignore_file (filename)) { if (would_be_ignored) g_error ("We expect filename \"%s\" to be ignored, but it isn't", filename); else g_error ("We expect filename \"%s\" not to be ignored, but it is", filename); } - esc = nm_keyfile_plugin_utils_escape_filename (filename); + esc = nms_keyfile_utils_escape_filename (filename); g_assert (esc && esc[0]); g_assert (!strchr (esc, '/')); - if (nm_keyfile_plugin_utils_should_ignore_file (esc)) + if (nms_keyfile_utils_should_ignore_file (esc)) g_error ("Escaping filename \"%s\" yielded \"%s\", but this is ignored", filename, esc); } @@ -2999,6 +2587,9 @@ int main (int argc, char **argv) _nm_utils_set_testing (NM_UTILS_TEST_NO_KEYFILE_OWNER_CHECK); nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); + if (g_mkdir_with_parents (TEST_SCRATCH_DIR, 0755) != 0) + g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR, g_strerror (errno)); + /* The tests */ g_test_add_func ("/keyfile/test_read_valid_wired_connection", test_read_valid_wired_connection); g_test_add_func ("/keyfile/test_write_wired_connection", test_write_wired_connection); @@ -3039,6 +2630,8 @@ int main (int argc, char **argv) g_test_add_func ("/keyfile/test_write_wired_8021x_tls_connection_path", test_write_wired_8021x_tls_connection_path); g_test_add_func ("/keyfile/test_write_wired_8021x_tls_connection_blob", test_write_wired_8021x_tls_connection_blob); + g_test_add_func ("/keyfile/test_read_dcb_connection", test_read_dcb_connection); + g_test_add_func ("/keyfile/test_read_infiniband_connection", test_read_infiniband_connection); g_test_add_func ("/keyfile/test_write_infiniband_connection", test_write_infiniband_connection); diff --git a/src/settings/plugins/keyfile/utils.c b/src/settings/plugins/keyfile/utils.c deleted file mode 100644 index b5c306e4..00000000 --- a/src/settings/plugins/keyfile/utils.c +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2010 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "utils.h" -#include "nm-setting-wired.h" -#include "nm-setting-wireless.h" -#include "nm-setting-wireless-security.h" -#include "nm-config.h" - -#define NM_CONFIG_KEYFILE_PATH_DEFAULT NMCONFDIR "/system-connections" - -static const char temp_letters[] = -"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - -/* - * Check '.[a-zA-Z0-9]{6}' file suffix used for temporary files by g_file_set_contents() (mkstemp()). - */ -static gboolean -check_mkstemp_suffix (const char *path) -{ - const char *ptr; - - g_return_val_if_fail (path != NULL, FALSE); - - /* Matches *.[a-zA-Z0-9]{6} suffix of mkstemp()'s temporary files */ - ptr = strrchr (path, '.'); - if (ptr && (strspn (ptr + 1, temp_letters) == 6) && (! ptr[7])) - return TRUE; - return FALSE; -} - -static gboolean -check_prefix (const char *base, const char *tag) -{ - int len, tag_len; - - g_return_val_if_fail (base != NULL, TRUE); - g_return_val_if_fail (tag != NULL, TRUE); - - len = strlen (base); - tag_len = strlen (tag); - if ((len > tag_len) && !g_ascii_strncasecmp (base, tag, tag_len)) - return TRUE; - return FALSE; -} - -static gboolean -check_suffix (const char *base, const char *tag) -{ - int len, tag_len; - - g_return_val_if_fail (base != NULL, TRUE); - g_return_val_if_fail (tag != NULL, TRUE); - - len = strlen (base); - tag_len = strlen (tag); - if ((len > tag_len) && !g_ascii_strcasecmp (base + len - tag_len, tag)) - return TRUE; - return FALSE; -} - -#define SWP_TAG ".swp" -#define SWPX_TAG ".swpx" -#define PEM_TAG ".pem" -#define DER_TAG ".der" - -gboolean -nm_keyfile_plugin_utils_should_ignore_file (const char *filename) -{ - gs_free char *base = NULL; - - g_return_val_if_fail (filename != NULL, TRUE); - - base = g_path_get_basename (filename); - g_return_val_if_fail (base != NULL, TRUE); - - /* Ignore hidden and backup files */ - /* should_ignore_file() must mirror escape_filename() */ - if (check_prefix (base, ".") || check_suffix (base, "~")) - return TRUE; - /* Ignore temporary files */ - if (check_mkstemp_suffix (base)) - return TRUE; - /* Ignore 802.1x certificates and keys */ - if (check_suffix (base, PEM_TAG) || check_suffix (base, DER_TAG)) - return TRUE; - - return FALSE; -} - -char * -nm_keyfile_plugin_utils_escape_filename (const char *filename) -{ - GString *str; - const char *f = filename; - const char ESCAPE_CHAR = '*'; - - /* keyfile used to escape with '*', do not change that behavior. - * But for newly added escapings, use '_' instead. */ - const char ESCAPE_CHAR2 = '_'; - - g_return_val_if_fail (filename && filename[0], NULL); - - str = g_string_sized_new (60); - - /* Convert '/' to ESCAPE_CHAR */ - for (f = filename; f[0]; f++) { - if (f[0] == '/') - g_string_append_c (str, ESCAPE_CHAR); - else - g_string_append_c (str, f[0]); - } - - /* escape_filename() must avoid anything that should_ignore_file() would reject. - * We can escape here more aggressivly then what we would read back. */ - if (check_prefix (str->str, ".")) - str->str[0] = ESCAPE_CHAR2; - if (check_suffix (str->str, "~")) - str->str[str->len - 1] = ESCAPE_CHAR2; - if ( check_mkstemp_suffix (str->str) - || check_suffix (str->str, PEM_TAG) - || check_suffix (str->str, DER_TAG)) - g_string_append_c (str, ESCAPE_CHAR2); - - return g_string_free (str, FALSE);; -} - -/*****************************************************************************/ - -const char * -nm_keyfile_plugin_get_path (void) -{ - static char *path = NULL; - - if (G_UNLIKELY (!path)) { - path = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG, - NM_CONFIG_KEYFILE_GROUP_KEYFILE, - NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH, - NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); - if (!path) - path = g_strdup (""NM_CONFIG_KEYFILE_PATH_DEFAULT""); - } - return path; -} - -/*****************************************************************************/ - diff --git a/src/settings/plugins/keyfile/utils.h b/src/settings/plugins/keyfile/utils.h deleted file mode 100644 index 85aa5458..00000000 --- a/src/settings/plugins/keyfile/utils.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2010 Red Hat, Inc. - */ - -#ifndef _UTILS_H_ -#define _UTILS_H_ - -#include "NetworkManagerUtils.h" - -#define KEYFILE_PLUGIN_NAME "keyfile" -#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." - -#define NM_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") -#define NM_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")" -#define NM_KEYFILE_CONNECTION_LOG_ARG(con) NM_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) -#define NM_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" -#define NM_KEYFILE_CONNECTION_LOG_ARGD(con) NM_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con) - -gboolean nm_keyfile_plugin_utils_should_ignore_file (const char *filename); - -char *nm_keyfile_plugin_utils_escape_filename (const char *filename); - -const char *nm_keyfile_plugin_get_path (void); - -#endif /* _UTILS_H_ */ - diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c deleted file mode 100644 index c8eb8800..00000000 --- a/src/settings/plugins/keyfile/writer.c +++ /dev/null @@ -1,385 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2015 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include - -#include "writer.h" -#include "utils.h" -#include "nm-keyfile-internal.h" - -typedef struct { - const char *keyfile_dir; -} WriteInfo; - - -static gboolean -write_cert_key_file (const char *path, - const guint8 *data, - gsize data_len, - GError **error) -{ - char *tmppath; - int fd = -1, written; - gboolean success = FALSE; - mode_t saved_umask; - - tmppath = g_malloc0 (strlen (path) + 10); - g_assert (tmppath); - memcpy (tmppath, path, strlen (path)); - strcat (tmppath, ".XXXXXX"); - - /* Only readable by root */ - saved_umask = umask (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); - - errno = 0; - fd = mkstemp (tmppath); - if (fd < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not create temporary file for '%s': %d", - path, errno); - goto out; - } - - errno = 0; - written = write (fd, data, data_len); - if (written != data_len) { - close (fd); - unlink (tmppath); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not write temporary file for '%s': %d", - path, errno); - goto out; - } - close (fd); - - /* Try to rename */ - errno = 0; - if (rename (tmppath, path) == 0) - success = TRUE; - else { - unlink (tmppath); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not rename temporary file to '%s': %d", - path, errno); - } - -out: - umask (saved_umask); - g_free (tmppath); - return success; -} - -static void -cert_writer (NMConnection *connection, - GKeyFile *file, - NMKeyfileWriteTypeDataCert *cert_data, - WriteInfo *info, - GError **error) -{ - const char *setting_name = nm_setting_get_name (NM_SETTING (cert_data->setting)); - NMSetting8021xCKScheme scheme; - NMSetting8021xCKFormat format; - const char *path = NULL, *ext = "pem"; - - scheme = cert_data->scheme_func (cert_data->setting); - if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) { - char *tmp = NULL; - const char *accepted_path = NULL; - - path = cert_data->path_func (cert_data->setting); - g_assert (path); - - if (g_str_has_prefix (path, info->keyfile_dir)) { - const char *p = path + strlen (info->keyfile_dir); - - /* If the path is rooted in the keyfile directory, just use a - * relative path instead of an absolute one. - */ - if (*p == '/') { - while (*p == '/') - p++; - if (p[0]) { - /* If @p looks like an integer list, the following detection will fail too and - * we will file:// qualify the path below. We thus avoid writing a path string - * that would be interpreted as legacy binary format by reader. */ - tmp = nm_keyfile_detect_unqualified_path_scheme (info->keyfile_dir, p, -1, FALSE, NULL); - if (tmp) { - g_clear_pointer (&tmp, g_free); - accepted_path = p; - } - } - } - } - if (!accepted_path) { - /* What we are about to write, must also be understood by the reader. - * Otherwise, add a file:// prefix */ - tmp = nm_keyfile_detect_unqualified_path_scheme (info->keyfile_dir, path, -1, FALSE, NULL); - if (tmp) { - g_clear_pointer (&tmp, g_free); - accepted_path = path; - } - } - - if (!accepted_path) - accepted_path = tmp = g_strconcat (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH, path, NULL); - nm_keyfile_plugin_kf_set_string (file, setting_name, cert_data->property_name, accepted_path); - g_free (tmp); - } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) { - GBytes *blob; - const guint8 *blob_data; - gsize blob_len; - gboolean success; - GError *local = NULL; - char *new_path; - - blob = cert_data->blob_func (cert_data->setting); - g_assert (blob); - blob_data = g_bytes_get_data (blob, &blob_len); - - if (cert_data->format_func) { - /* Get the extension for a private key */ - format = cert_data->format_func (cert_data->setting); - if (format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) - ext = "p12"; - } else { - /* DER or PEM format certificate? */ - if (blob_len > 2 && blob_data[0] == 0x30 && blob_data[1] == 0x82) - ext = "der"; - } - - /* Write the raw data out to the standard file so that we can use paths - * from now on instead of pushing around the certificate data. - */ - new_path = g_strdup_printf ("%s/%s-%s.%s", info->keyfile_dir, nm_connection_get_uuid (connection), - cert_data->suffix, ext); - - success = write_cert_key_file (new_path, blob_data, blob_len, &local); - if (success) { - /* Write the path value to the keyfile. - * We know, that basename(new_path) starts with a UUID, hence no conflict with "data:;base64," */ - nm_keyfile_plugin_kf_set_string (file, setting_name, cert_data->property_name, strrchr (new_path, '/') + 1); - } else { - nm_log_warn (LOGD_SETTINGS, "keyfile: %s.%s: failed to write certificate to file %s: %s", - setting_name, cert_data->property_name, new_path, local->message); - g_error_free (local); - } - g_free (new_path); - } else { - /* scheme_func() returns UNKNOWN in all other cases. The only valid case - * where a scheme is allowed to be UNKNOWN, is unsetting the value. In this - * case, we don't expect the writer to be called, because the default value - * will not be serialized. - * The only other reason for the scheme to be UNKNOWN is an invalid cert. - * But our connection verifies, so that cannot happen either. */ - g_return_if_reached (); - } -} - -static gboolean -_handler_write (NMConnection *connection, - GKeyFile *keyfile, - NMKeyfileWriteType type, - void *type_data, - void *user_data, - GError **error) -{ - if (type == NM_KEYFILE_WRITE_TYPE_CERT) { - cert_writer (connection, keyfile, - (NMKeyfileWriteTypeDataCert *) type_data, - (WriteInfo *) user_data, error); - return TRUE; - } - return FALSE; -} - -static gboolean -_internal_write_connection (NMConnection *connection, - const char *keyfile_dir, - uid_t owner_uid, - pid_t owner_grp, - const char *existing_path, - gboolean force_rename, - char **out_path, - GError **error) -{ - GKeyFile *key_file; - gs_free char *data = NULL; - gsize len; - gs_free char *path = NULL; - const char *id; - WriteInfo info = { 0 }; - GError *local_err = NULL; - int errsv; - gboolean success = FALSE; - mode_t saved_umask; - - g_return_val_if_fail (!out_path || !*out_path, FALSE); - g_return_val_if_fail (keyfile_dir && keyfile_dir[0] == '/', FALSE); - - if (!nm_connection_verify (connection, error)) - g_return_val_if_reached (FALSE); - - id = nm_connection_get_id (connection); - g_assert (id && *id); - - info.keyfile_dir = keyfile_dir; - - key_file = nm_keyfile_write (connection, _handler_write, &info, error); - if (!key_file) - return FALSE; - data = g_key_file_to_data (key_file, &len, error); - g_key_file_unref (key_file); - if (!data) - return FALSE; - - /* If we have existing file path, use it. Else generate one from - * connection's ID. - */ - if (existing_path != NULL && !force_rename) { - path = g_strdup (existing_path); - } else { - char *filename_escaped = nm_keyfile_plugin_utils_escape_filename (id); - - path = g_build_filename (keyfile_dir, filename_escaped, NULL); - g_free (filename_escaped); - } - - /* If a file with this path already exists (but isn't the existing path - * of the connection) then we need another name. Multiple connections - * can have the same ID (ie if two connections with the same ID are visible - * to different users) but of course can't have the same path. Yeah, - * there's a race here, but there's not a lot we can do about it, and - * we shouldn't get more than one connection with the same UUID either. - */ - if (g_strcmp0 (path, existing_path) != 0 && g_file_test (path, G_FILE_TEST_EXISTS)) { - guint i; - gboolean name_found = FALSE; - - /* A keyfile with this connection's ID already exists. Pick another name. */ - for (i = 0; i < 100; i++) { - char *filename, *filename_escaped; - - if (i == 0) - filename = g_strdup_printf ("%s-%s", id, nm_connection_get_uuid (connection)); - else - filename = g_strdup_printf ("%s-%s-%u", id, nm_connection_get_uuid (connection), i); - - filename_escaped = nm_keyfile_plugin_utils_escape_filename (filename); - - g_free (path); - path = g_strdup_printf ("%s/%s", keyfile_dir, filename_escaped); - g_free (filename); - g_free (filename_escaped); - if (g_strcmp0 (path, existing_path) == 0 || !g_file_test (path, G_FILE_TEST_EXISTS)) { - name_found = TRUE; - break; - } - } - if (!name_found) { - if (existing_path == NULL) { - /* this really should not happen, we tried hard to find an unused name... bail out. */ - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "could not find suitable keyfile file name (%s already used)", path); - return FALSE; - } - /* Both our preferred path based on connection id and id-uuid are taken. - * Fallback to @existing_path */ - g_free (path); - path = g_strdup (existing_path); - } - } - - /* In case of updating the connection and changing the file path, - * we need to remove the old one, not to end up with two connections. - */ - if (existing_path != NULL && strcmp (path, existing_path) != 0) - unlink (existing_path); - - saved_umask = umask (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); - - g_file_set_contents (path, data, len, &local_err); - if (local_err) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "error writing to file '%s': %s", - path, local_err->message); - g_error_free (local_err); - goto out; - } - - if (chown (path, owner_uid, owner_grp) < 0) { - errsv = errno; - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "error chowning '%s': %s (%d)", - path, g_strerror (errsv), errsv); - unlink (path); - goto out; - } - - if (out_path && g_strcmp0 (existing_path, path)) { - *out_path = path; /* pass path out to caller */ - path = NULL; - } - - success = TRUE; -out: - umask (saved_umask); - return success; -} - -gboolean -nm_keyfile_plugin_write_connection (NMConnection *connection, - const char *existing_path, - gboolean force_rename, - char **out_path, - GError **error) -{ - return _internal_write_connection (connection, - nm_keyfile_plugin_get_path (), - 0, 0, - existing_path, - force_rename, - out_path, - error); -} - -gboolean -nm_keyfile_plugin_write_test_connection (NMConnection *connection, - const char *keyfile_dir, - uid_t owner_uid, - pid_t owner_grp, - char **out_path, - GError **error) -{ - return _internal_write_connection (connection, - keyfile_dir, - owner_uid, owner_grp, - NULL, - FALSE, - out_path, - error); -} - diff --git a/src/settings/plugins/keyfile/writer.h b/src/settings/plugins/keyfile/writer.h deleted file mode 100644 index 89435651..00000000 --- a/src/settings/plugins/keyfile/writer.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#ifndef _KEYFILE_PLUGIN_WRITER_H -#define _KEYFILE_PLUGIN_WRITER_H - -#include - -gboolean nm_keyfile_plugin_write_connection (NMConnection *connection, - const char *existing_path, - gboolean force_rename, - char **out_path, - GError **error); - -gboolean nm_keyfile_plugin_write_test_connection (NMConnection *connection, - const char *keyfile_dir, - uid_t owner_uid, - pid_t owner_grp, - char **out_path, - GError **error); - -#endif /* _KEYFILE_PLUGIN_WRITER_H */ diff --git a/src/supplicant-manager/nm-supplicant-config.c b/src/supplicant-manager/nm-supplicant-config.c deleted file mode 100644 index 6283edd6..00000000 --- a/src/supplicant-manager/nm-supplicant-config.c +++ /dev/null @@ -1,1128 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2012 Red Hat, Inc. - * Copyright (C) 2007 - 2008 Novell, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "nm-supplicant-config.h" -#include "nm-supplicant-settings-verify.h" -#include "nm-setting.h" -#include "NetworkManagerUtils.h" -#include "nm-utils.h" - -#define NM_SUPPLICANT_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_SUPPLICANT_CONFIG, \ - NMSupplicantConfigPrivate)) - -G_DEFINE_TYPE (NMSupplicantConfig, nm_supplicant_config, G_TYPE_OBJECT) - -typedef struct { - char *value; - guint32 len; - OptType type; -} ConfigOption; - -typedef struct -{ - GHashTable *config; - GHashTable *blobs; - guint32 ap_scan; - gboolean fast_required; - gboolean dispose_has_run; -} NMSupplicantConfigPrivate; - -NMSupplicantConfig * -nm_supplicant_config_new (void) -{ - return g_object_new (NM_TYPE_SUPPLICANT_CONFIG, NULL); -} - -static void -config_option_free (ConfigOption *opt) -{ - g_free (opt->value); - g_slice_free (ConfigOption, opt); -} - -static void -blob_free (GByteArray *array) -{ - g_byte_array_free (array, TRUE); -} - -static void -nm_supplicant_config_init (NMSupplicantConfig * self) -{ - NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); - - priv->config = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) config_option_free); - - priv->blobs = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) blob_free); - - priv->ap_scan = 1; - priv->dispose_has_run = FALSE; -} - -static gboolean -nm_supplicant_config_add_option_with_type (NMSupplicantConfig *self, - const char *key, - const char *value, - gint32 len, - OptType opt_type, - gboolean secret, - GError **error) -{ - NMSupplicantConfigPrivate *priv; - ConfigOption *old_opt; - ConfigOption *opt; - OptType type; - - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); - g_return_val_if_fail (key != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - nm_assert (!error || !*error); - - priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); - - if (len < 0) - len = strlen (value); - - if (opt_type != TYPE_INVALID) - type = opt_type; - else { - type = nm_supplicant_settings_verify_setting (key, value, len); - if (type == TYPE_INVALID) { - char buf[255]; - memset (&buf[0], 0, sizeof (buf)); - memcpy (&buf[0], value, len > 254 ? 254 : len); - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "key '%s' and/or value '%s' invalid", key, secret ? "" : buf); - return FALSE; - } - } - - old_opt = (ConfigOption *) g_hash_table_lookup (priv->config, key); - if (old_opt) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "key '%s' already configured", key); - return FALSE; - } - - opt = g_slice_new0 (ConfigOption); - opt->value = g_malloc (len + 1); - memcpy (opt->value, value, len); - opt->value[len] = '\0'; - - opt->len = len; - opt->type = type; - - { - char buf[255]; - memset (&buf[0], 0, sizeof (buf)); - memcpy (&buf[0], opt->value, opt->len > 254 ? 254 : opt->len); - nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, secret ? "" : &buf[0]); - } - - g_hash_table_insert (priv->config, g_strdup (key), opt); - - return TRUE; -} - -static gboolean -nm_supplicant_config_add_option (NMSupplicantConfig *self, - const char *key, - const char *value, - gint32 len, - gboolean secret, - GError **error) -{ - return nm_supplicant_config_add_option_with_type (self, key, value, len, TYPE_INVALID, secret, error); -} - -static gboolean -nm_supplicant_config_add_blob (NMSupplicantConfig *self, - const char *key, - GBytes *value, - const char *blobid, - GError **error) -{ - NMSupplicantConfigPrivate *priv; - ConfigOption *old_opt; - ConfigOption *opt; - OptType type; - GByteArray *blob; - const guint8 *data; - gsize data_len; - - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); - g_return_val_if_fail (key != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - g_return_val_if_fail (blobid != NULL, FALSE); - - data = g_bytes_get_data (value, &data_len); - g_return_val_if_fail (data_len > 0, FALSE); - - priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); - - type = nm_supplicant_settings_verify_setting (key, (const char *) data, data_len); - if (type == TYPE_INVALID) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "key '%s' and/or its contained value is invalid", key); - return FALSE; - } - - old_opt = (ConfigOption *) g_hash_table_lookup (priv->config, key); - if (old_opt) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "key '%s' already configured", key); - return FALSE; - } - - blob = g_byte_array_sized_new (data_len); - g_byte_array_append (blob, data, data_len); - - opt = g_slice_new0 (ConfigOption); - opt->value = g_strdup_printf ("blob://%s", blobid); - opt->len = strlen (opt->value); - opt->type = type; - - nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, opt->value); - - g_hash_table_insert (priv->config, g_strdup (key), opt); - g_hash_table_insert (priv->blobs, g_strdup (blobid), blob); - - return TRUE; -} - -static gboolean -nm_supplicant_config_add_blob_for_connection (NMSupplicantConfig *self, - GBytes *field, - const char *name, - const char *con_uid, - GError **error) -{ - if (field && g_bytes_get_size (field)) { - gs_free char *uid = NULL; - char *p; - - uid = g_strdup_printf ("%s-%s", con_uid, name); - for (p = uid; *p; p++) { - if (*p == '/') - *p = '-'; - } - if (!nm_supplicant_config_add_blob (self, name, field, uid, error)) - return FALSE; - } - return TRUE; -} - -static void -nm_supplicant_config_finalize (GObject *object) -{ - /* Complete object destruction */ - g_hash_table_destroy (NM_SUPPLICANT_CONFIG_GET_PRIVATE (object)->config); - g_hash_table_destroy (NM_SUPPLICANT_CONFIG_GET_PRIVATE (object)->blobs); - - /* Chain up to the parent class */ - G_OBJECT_CLASS (nm_supplicant_config_parent_class)->finalize (object); -} - - -static void -nm_supplicant_config_class_init (NMSupplicantConfigClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = nm_supplicant_config_finalize; - - g_type_class_add_private (object_class, sizeof (NMSupplicantConfigPrivate)); -} - -guint32 -nm_supplicant_config_get_ap_scan (NMSupplicantConfig * self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), 1); - - return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->ap_scan; -} - -gboolean -nm_supplicant_config_fast_required (NMSupplicantConfig *self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); - - return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->fast_required; -} - -GVariant * -nm_supplicant_config_to_variant (NMSupplicantConfig *self) -{ - NMSupplicantConfigPrivate *priv; - GVariantBuilder builder; - GHashTableIter iter; - ConfigOption *option; - const char *key; - - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), NULL); - - priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); - - g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); - - g_hash_table_iter_init (&iter, priv->config); - while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &option)) { - switch (option->type) { - case TYPE_INT: - g_variant_builder_add (&builder, "{sv}", key, g_variant_new_int32 (atoi (option->value))); - break; - case TYPE_BYTES: - case TYPE_UTF8: - g_variant_builder_add (&builder, "{sv}", - key, - g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, - option->value, option->len, 1)); - break; - case TYPE_KEYWORD: - case TYPE_STRING: - g_variant_builder_add (&builder, "{sv}", key, g_variant_new_string (option->value)); - break; - default: - break; - } - } - - return g_variant_builder_end (&builder); -} - -GHashTable * -nm_supplicant_config_get_blobs (NMSupplicantConfig * self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), NULL); - - return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->blobs; -} - -static const char * -wifi_freqs_to_string (gboolean bg_band) -{ - static const char *str_2ghz = NULL; - static const char *str_5ghz = NULL; - const char *str; - - str = bg_band ? str_2ghz : str_5ghz; - - if (G_UNLIKELY (str == NULL)) { - GString *tmp; - const guint *freqs; - int i; - - freqs = bg_band ? nm_utils_wifi_2ghz_freqs () : nm_utils_wifi_5ghz_freqs (); - tmp = g_string_sized_new (bg_band ? 70 : 225); - for (i = 0; freqs[i]; i++) - g_string_append_printf (tmp, i == 0 ? "%d" : " %d", freqs[i]); - str = g_string_free (tmp, FALSE); - if (bg_band) - str_2ghz = str; - else - str_5ghz = str; - } - return str; -} - -gboolean -nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self, - NMSettingWireless * setting, - guint32 fixed_freq, - GError **error) -{ - NMSupplicantConfigPrivate *priv; - gboolean is_adhoc, is_ap; - const char *mode, *band; - guint32 channel; - GBytes *ssid; - const char *bssid; - - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); - g_return_val_if_fail (setting != NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); - - mode = nm_setting_wireless_get_mode (setting); - is_adhoc = (mode && !strcmp (mode, "adhoc")) ? TRUE : FALSE; - is_ap = (mode && !strcmp (mode, "ap")) ? TRUE : FALSE; - if (is_adhoc || is_ap) - priv->ap_scan = 2; - else - priv->ap_scan = 1; - - ssid = nm_setting_wireless_get_ssid (setting); - if (!nm_supplicant_config_add_option (self, "ssid", - (char *) g_bytes_get_data (ssid, NULL), - g_bytes_get_size (ssid), - FALSE, - error)) - return FALSE; - - if (is_adhoc) { - if (!nm_supplicant_config_add_option (self, "mode", "1", -1, FALSE, error)) - return FALSE; - } - - if (is_ap) { - if (!nm_supplicant_config_add_option (self, "mode", "2", -1, FALSE, error)) - return FALSE; - } - - if ((is_adhoc || is_ap) && fixed_freq) { - gs_free char *str_freq = NULL; - - str_freq = g_strdup_printf ("%u", fixed_freq); - if (!nm_supplicant_config_add_option (self, "frequency", str_freq, -1, FALSE, error)) - return FALSE; - } - - /* Except for Ad-Hoc and Hotspot, request that the driver probe for the - * specific SSID we want to associate with. - */ - if (!(is_adhoc || is_ap)) { - if (!nm_supplicant_config_add_option (self, "scan_ssid", "1", -1, FALSE, error)) - return FALSE; - } - - bssid = nm_setting_wireless_get_bssid (setting); - if (bssid) { - if (!nm_supplicant_config_add_option (self, "bssid", - bssid, strlen (bssid), - FALSE, - error)) - return FALSE; - } - - band = nm_setting_wireless_get_band (setting); - channel = nm_setting_wireless_get_channel (setting); - if (band) { - if (channel) { - guint32 freq; - gs_free char *str_freq = NULL; - - freq = nm_utils_wifi_channel_to_freq (channel, band); - str_freq = g_strdup_printf ("%u", freq); - if (!nm_supplicant_config_add_option (self, "freq_list", str_freq, -1, FALSE, error)) - return FALSE; - } else { - const char *freqs = NULL; - - if (!strcmp (band, "a")) - freqs = wifi_freqs_to_string (FALSE); - else if (!strcmp (band, "bg")) - freqs = wifi_freqs_to_string (TRUE); - - if (freqs && !nm_supplicant_config_add_option (self, "freq_list", freqs, strlen (freqs), FALSE, error)) - return FALSE; - } - } - - return TRUE; -} - -static gboolean -add_string_val (NMSupplicantConfig *self, - const char *field, - const char *name, - gboolean ucase, - gboolean secret, - GError **error) -{ - - if (field) { - gs_free char *value = NULL; - - if (ucase) { - value = g_ascii_strup (field, -1); - field = value; - } - return nm_supplicant_config_add_option (self, name, field, strlen (field), secret, error); - } - return TRUE; -} - -#define ADD_STRING_LIST_VAL(self, setting, setting_name, field, field_plural, name, separator, ucase, secret, error) \ - ({ \ - typeof (*(setting)) *_setting = (setting); \ - gboolean _success = TRUE; \ - \ - if (nm_setting_##setting_name##_get_num_##field_plural (_setting)) { \ - const char _separator = (separator); \ - GString *_str = g_string_new (NULL); \ - guint _k, _n; \ - \ - _n = nm_setting_##setting_name##_get_num_##field_plural (_setting); \ - for (_k = 0; _k < _n; _k++) { \ - const char *item = nm_setting_##setting_name##_get_##field (_setting, _k); \ - \ - if (!_str->len) { \ - g_string_append (_str, item); \ - } else { \ - g_string_append_c (_str, _separator); \ - g_string_append (_str, item); \ - } \ - } \ - if ((ucase)) \ - g_string_ascii_up (_str); \ - if (_str->len) { \ - if (!nm_supplicant_config_add_option ((self), (name), _str->str, -1, (secret), (error))) \ - _success = FALSE; \ - } \ - g_string_free (_str, TRUE); \ - } \ - _success; \ - }) - -static void -wep128_passphrase_hash (const char *input, - size_t input_len, - guint8 *out_digest, - size_t *out_digest_len) -{ - GChecksum *sum; - guint8 data[64]; - int i; - - g_return_if_fail (out_digest != NULL); - g_return_if_fail (out_digest_len != NULL); - g_return_if_fail (*out_digest_len >= 16); - - /* Get at least 64 bytes by repeating the passphrase into the buffer */ - for (i = 0; i < sizeof (data); i++) - data[i] = input[i % input_len]; - - sum = g_checksum_new (G_CHECKSUM_MD5); - g_assert (sum); - g_checksum_update (sum, data, sizeof (data)); - g_checksum_get_digest (sum, out_digest, out_digest_len); - g_checksum_free (sum); - - g_assert (*out_digest_len == 16); - /* WEP104 keys are 13 bytes in length (26 hex characters) */ - *out_digest_len = 13; -} - -static gboolean -add_wep_key (NMSupplicantConfig *self, - const char *key, - const char *name, - NMWepKeyType wep_type, - GError **error) -{ - size_t key_len = key ? strlen (key) : 0; - - if (!key || !key_len) - return TRUE; - - if (wep_type == NM_WEP_KEY_TYPE_UNKNOWN) { - if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_KEY)) - wep_type = NM_WEP_KEY_TYPE_KEY; - else if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_PASSPHRASE)) - wep_type = NM_WEP_KEY_TYPE_PASSPHRASE; - } - - if ( (wep_type == NM_WEP_KEY_TYPE_UNKNOWN) - || (wep_type == NM_WEP_KEY_TYPE_KEY)) { - if ((key_len == 10) || (key_len == 26)) { - gs_unref_bytes GBytes *bytes = NULL; - - bytes = nm_utils_hexstr2bin (key); - if (!bytes) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "cannot add wep-key %s to suplicant config because key is not hex", - name); - return FALSE; - } - if (!nm_supplicant_config_add_option (self, - name, - g_bytes_get_data (bytes, NULL), - g_bytes_get_size (bytes), - TRUE, - error)) - return FALSE; - } else if ((key_len == 5) || (key_len == 13)) { - if (!nm_supplicant_config_add_option (self, name, key, key_len, TRUE, error)) - return FALSE; - } else { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "Cannot add wep-key %s to suplicant config because key-length %u is invalid", - name, (guint) key_len); - return FALSE; - } - } else if (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE) { - guint8 digest[16]; - size_t digest_len = sizeof (digest); - - wep128_passphrase_hash (key, key_len, digest, &digest_len); - if (!nm_supplicant_config_add_option (self, name, (const char *) digest, digest_len, TRUE, error)) - return FALSE; - } - - return TRUE; -} - -gboolean -nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self, - NMSettingWirelessSecurity *setting, - NMSetting8021x *setting_8021x, - const char *con_uuid, - guint32 mtu, - GError **error) -{ - const char *key_mgmt, *auth_alg; - const char *psk; - - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); - g_return_val_if_fail (setting != NULL, FALSE); - g_return_val_if_fail (con_uuid != NULL, FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - key_mgmt = nm_setting_wireless_security_get_key_mgmt (setting); - if (!add_string_val (self, key_mgmt, "key_mgmt", TRUE, FALSE, error)) - return FALSE; - - auth_alg = nm_setting_wireless_security_get_auth_alg (setting); - if (!add_string_val (self, auth_alg, "auth_alg", TRUE, FALSE, error)) - return FALSE; - - psk = nm_setting_wireless_security_get_psk (setting); - if (psk) { - size_t psk_len = strlen (psk); - - if (psk_len == 64) { - gs_unref_bytes GBytes *bytes = NULL; - - /* Hex PSK */ - bytes = nm_utils_hexstr2bin (psk); - if (!bytes) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "Cannot add psk to supplicant config due to invalid hex"); - return FALSE; - } - - if (!nm_supplicant_config_add_option (self, - "psk", - g_bytes_get_data (bytes, NULL), - g_bytes_get_size (bytes), - TRUE, - error)) - return FALSE; - } else if (psk_len >= 8 && psk_len <= 63) { - /* Use TYPE_STRING here so that it gets pushed to the - * supplicant as a string, and therefore gets quoted, - * and therefore the supplicant will interpret it as a - * passphrase and not a hex key. - */ - if (!nm_supplicant_config_add_option_with_type (self, "psk", psk, -1, TYPE_STRING, TRUE, error)) - return FALSE; - } else { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "Cannot add psk to supplicant config due to invalid PSK length %u (not between 8 and 63 characters)", - (guint) psk_len); - return FALSE; - } - } - - /* Only WPA-specific things when using WPA */ - if ( !strcmp (key_mgmt, "wpa-none") - || !strcmp (key_mgmt, "wpa-psk") - || !strcmp (key_mgmt, "wpa-eap")) { - if (!ADD_STRING_LIST_VAL (self, setting, wireless_security, proto, protos, "proto", ' ', TRUE, FALSE, error)) - return FALSE; - if (!ADD_STRING_LIST_VAL (self, setting, wireless_security, pairwise, pairwise, "pairwise", ' ', TRUE, FALSE, error)) - return FALSE; - if (!ADD_STRING_LIST_VAL (self, setting, wireless_security, group, groups, "group", ' ', TRUE, FALSE, error)) - return FALSE; - } - - /* WEP keys if required */ - if (!strcmp (key_mgmt, "none")) { - NMWepKeyType wep_type = nm_setting_wireless_security_get_wep_key_type (setting); - const char *wep0 = nm_setting_wireless_security_get_wep_key (setting, 0); - const char *wep1 = nm_setting_wireless_security_get_wep_key (setting, 1); - const char *wep2 = nm_setting_wireless_security_get_wep_key (setting, 2); - const char *wep3 = nm_setting_wireless_security_get_wep_key (setting, 3); - - if (!add_wep_key (self, wep0, "wep_key0", wep_type, error)) - return FALSE; - if (!add_wep_key (self, wep1, "wep_key1", wep_type, error)) - return FALSE; - if (!add_wep_key (self, wep2, "wep_key2", wep_type, error)) - return FALSE; - if (!add_wep_key (self, wep3, "wep_key3", wep_type, error)) - return FALSE; - - if (wep0 || wep1 || wep2 || wep3) { - gs_free char *value = NULL; - - value = g_strdup_printf ("%d", nm_setting_wireless_security_get_wep_tx_keyidx (setting)); - if (!nm_supplicant_config_add_option (self, "wep_tx_keyidx", value, -1, FALSE, error)) - return FALSE; - } - } - - if (auth_alg && !strcmp (auth_alg, "leap")) { - /* LEAP */ - if (!strcmp (key_mgmt, "ieee8021x")) { - const char *tmp; - - tmp = nm_setting_wireless_security_get_leap_username (setting); - if (!add_string_val (self, tmp, "identity", FALSE, FALSE, error)) - return FALSE; - - tmp = nm_setting_wireless_security_get_leap_password (setting); - if (!add_string_val (self, tmp, "password", FALSE, TRUE, error)) - return FALSE; - - if (!add_string_val (self, "leap", "eap", TRUE, FALSE, error)) - return FALSE; - } else { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "Invalid key-mgmt \"%s\" for leap", key_mgmt); - return FALSE; - } - } else { - /* 802.1x for Dynamic WEP and WPA-Enterprise */ - if (!strcmp (key_mgmt, "ieee8021x") || !strcmp (key_mgmt, "wpa-eap")) { - if (!setting_8021x) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "Cannot set key-mgmt %s with missing 8021x setting", key_mgmt); - return FALSE; - } - if (!nm_supplicant_config_add_setting_8021x (self, setting_8021x, con_uuid, mtu, FALSE, error)) - return FALSE; - } - - if (!strcmp (key_mgmt, "wpa-eap")) { - /* If using WPA Enterprise, enable optimized background scanning - * to ensure roaming within an ESS works well. - */ - if (!nm_supplicant_config_add_option (self, "bgscan", "simple:30:-65:300", -1, FALSE, error)) - return FALSE; - - /* When using WPA-Enterprise, we want to use Proactive Key Caching (also - * called Opportunistic Key Caching) to avoid full EAP exchanges when - * roaming between access points in the same mobility group. - */ - if (!nm_supplicant_config_add_option (self, "proactive_key_caching", "1", -1, FALSE, error)) - return FALSE; - } - } - - return TRUE; -} - -gboolean -nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self, - NMSetting8021x *setting, - const char *con_uuid, - guint32 mtu, - gboolean wired, - GError **error) -{ - NMSupplicantConfigPrivate *priv; - char *tmp; - const char *peapver, *value, *path; - gboolean added; - GString *phase1, *phase2; - GBytes *bytes; - gboolean fast = FALSE; - guint32 i, num_eap; - gboolean fast_provisoning_allowed = FALSE; - const char *ca_path_override = NULL, *ca_cert_override = NULL; - guint32 frag, hdrs; - gs_free char *frag_str = NULL; - - g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); - g_return_val_if_fail (setting != NULL, FALSE); - g_return_val_if_fail (con_uuid != NULL, FALSE); - - priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); - - value = nm_setting_802_1x_get_password (setting); - if (value) { - if (!add_string_val (self, value, "password", FALSE, TRUE, error)) - return FALSE; - } else { - bytes = nm_setting_802_1x_get_password_raw (setting); - if (bytes) { - if (!nm_supplicant_config_add_option (self, - "password", - (const char *) g_bytes_get_data (bytes, NULL), - g_bytes_get_size (bytes), - TRUE, - error)) - return FALSE; - } - } - value = nm_setting_802_1x_get_pin (setting); - if (!add_string_val (self, value, "pin", FALSE, TRUE, error)) - return FALSE; - - if (wired) { - if (!add_string_val (self, "IEEE8021X", "key_mgmt", FALSE, FALSE, error)) - return FALSE; - /* Wired 802.1x must always use eapol_flags=0 */ - if (!add_string_val (self, "0", "eapol_flags", FALSE, FALSE, error)) - return FALSE; - priv->ap_scan = 0; - } - - if (!ADD_STRING_LIST_VAL (self, setting, 802_1x, eap_method, eap_methods, "eap", ' ', TRUE, FALSE, error)) - return FALSE; - - /* Check EAP method for special handling: PEAP + GTC, FAST */ - num_eap = nm_setting_802_1x_get_num_eap_methods (setting); - for (i = 0; i < num_eap; i++) { - const char *method = nm_setting_802_1x_get_eap_method (setting, i); - - if (method && (strcasecmp (method, "fast") == 0)) { - fast = TRUE; - priv->fast_required = TRUE; - } - } - - /* Adjust the fragment size according to MTU, but do not set it higher than 1280-14 - * for better compatibility */ - hdrs = 14; /* EAPOL + EAP-TLS */ - frag = 1280 - hdrs; - if (mtu > hdrs) - frag = CLAMP (mtu - hdrs, 100, frag); - frag_str = g_strdup_printf ("%u", frag); - - if (!nm_supplicant_config_add_option (self, "fragment_size", frag_str, -1, FALSE, error)) - return FALSE; - - phase1 = g_string_new (NULL); - peapver = nm_setting_802_1x_get_phase1_peapver (setting); - if (peapver) { - if (!strcmp (peapver, "0")) - g_string_append (phase1, "peapver=0"); - else if (!strcmp (peapver, "1")) - g_string_append (phase1, "peapver=1"); - } - - if (nm_setting_802_1x_get_phase1_peaplabel (setting)) { - if (phase1->len) - g_string_append_c (phase1, ' '); - g_string_append_printf (phase1, "peaplabel=%s", nm_setting_802_1x_get_phase1_peaplabel (setting)); - } - - value = nm_setting_802_1x_get_phase1_fast_provisioning (setting); - if (value) { - if (phase1->len) - g_string_append_c (phase1, ' '); - g_string_append_printf (phase1, "fast_provisioning=%s", value); - - if (strcmp (value, "0") != 0) - fast_provisoning_allowed = TRUE; - } - - if (phase1->len) { - if (!add_string_val (self, phase1->str, "phase1", FALSE, FALSE, error)) { - g_string_free (phase1, TRUE); - return FALSE; - } - } - g_string_free (phase1, TRUE); - - phase2 = g_string_new (NULL); - if (nm_setting_802_1x_get_phase2_auth (setting) && !fast_provisoning_allowed) { - tmp = g_ascii_strup (nm_setting_802_1x_get_phase2_auth (setting), -1); - g_string_append_printf (phase2, "auth=%s", tmp); - g_free (tmp); - } - - if (nm_setting_802_1x_get_phase2_autheap (setting)) { - if (phase2->len) - g_string_append_c (phase2, ' '); - tmp = g_ascii_strup (nm_setting_802_1x_get_phase2_autheap (setting), -1); - g_string_append_printf (phase2, "autheap=%s", tmp); - g_free (tmp); - } - - if (phase2->len) { - if (!add_string_val (self, phase2->str, "phase2", FALSE, FALSE, error)) { - g_string_free (phase2, TRUE); - return FALSE; - } - } - g_string_free (phase2, TRUE); - - /* PAC file */ - path = nm_setting_802_1x_get_pac_file (setting); - if (path) { - if (!add_string_val (self, path, "pac_file", FALSE, FALSE, error)) - return FALSE; - } else { - /* PAC file is not specified. - * If provisioning is allowed, use an blob format. - */ - if (fast_provisoning_allowed) { - gs_free char *blob_name = NULL; - - blob_name = g_strdup_printf ("blob://pac-blob-%s", con_uuid); - if (!add_string_val (self, blob_name, "pac_file", FALSE, FALSE, error)) - return FALSE; - } else { - /* This is only error for EAP-FAST; don't disturb other methods. */ - if (fast) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "EAP-FAST error: no PAC file provided and " - "automatic PAC provisioning is disabled"); - return FALSE; - } - } - } - - /* If user wants to use system CA certs, either populate ca_path (if the path - * is a directory) or ca_cert (the path is a file name) */ - if (nm_setting_802_1x_get_system_ca_certs (setting)) { - if (g_file_test (SYSTEM_CA_PATH, G_FILE_TEST_IS_DIR)) - ca_path_override = SYSTEM_CA_PATH; - else - ca_cert_override = SYSTEM_CA_PATH; - } - - /* CA path */ - path = nm_setting_802_1x_get_ca_path (setting); - path = ca_path_override ? ca_path_override : path; - if (path) { - if (!add_string_val (self, path, "ca_path", FALSE, FALSE, error)) - return FALSE; - } - - /* Phase2 CA path */ - path = nm_setting_802_1x_get_phase2_ca_path (setting); - path = ca_path_override ? ca_path_override : path; - if (path) { - if (!add_string_val (self, path, "ca_path2", FALSE, FALSE, error)) - return FALSE; - } - - /* CA certificate */ - if (ca_cert_override) { - if (!add_string_val (self, ca_cert_override, "ca_cert", FALSE, FALSE, error)) - return FALSE; - } else { - switch (nm_setting_802_1x_get_ca_cert_scheme (setting)) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - bytes = nm_setting_802_1x_get_ca_cert_blob (setting); - if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "ca_cert", con_uuid, error)) - return FALSE; - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = nm_setting_802_1x_get_ca_cert_path (setting); - if (!add_string_val (self, path, "ca_cert", FALSE, FALSE, error)) - return FALSE; - break; - default: - break; - } - } - - /* Phase 2 CA certificate */ - if (ca_cert_override) { - if (!add_string_val (self, ca_cert_override, "ca_cert2", FALSE, FALSE, error)) - return FALSE; - } else { - switch (nm_setting_802_1x_get_phase2_ca_cert_scheme (setting)) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - bytes = nm_setting_802_1x_get_phase2_ca_cert_blob (setting); - if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "ca_cert2", con_uuid, error)) - return FALSE; - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = nm_setting_802_1x_get_phase2_ca_cert_path (setting); - if (!add_string_val (self, path, "ca_cert2", FALSE, FALSE, error)) - return FALSE; - break; - default: - break; - } - } - - /* Subject match */ - value = nm_setting_802_1x_get_subject_match (setting); - if (!add_string_val (self, value, "subject_match", FALSE, FALSE, error)) - return FALSE; - value = nm_setting_802_1x_get_phase2_subject_match (setting); - if (!add_string_val (self, value, "subject_match2", FALSE, FALSE, error)) - return FALSE; - - /* altSubjectName match */ - if (!ADD_STRING_LIST_VAL (self, setting, 802_1x, altsubject_match, altsubject_matches, "altsubject_match", ';', FALSE, FALSE, error)) - return FALSE; - if (!ADD_STRING_LIST_VAL (self, setting, 802_1x, phase2_altsubject_match, phase2_altsubject_matches, "altsubject_match2", ';', FALSE, FALSE, error)) - return FALSE; - - /* Domain suffix match */ - value = nm_setting_802_1x_get_domain_suffix_match (setting); - if (!add_string_val (self, value, "domain_suffix_match", FALSE, FALSE, error)) - return FALSE; - value = nm_setting_802_1x_get_phase2_domain_suffix_match (setting); - if (!add_string_val (self, value, "domain_suffix_match2", FALSE, FALSE, error)) - return FALSE; - - /* Private key */ - added = FALSE; - switch (nm_setting_802_1x_get_private_key_scheme (setting)) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - bytes = nm_setting_802_1x_get_private_key_blob (setting); - if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "private_key", con_uuid, error)) - return FALSE; - added = TRUE; - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = nm_setting_802_1x_get_private_key_path (setting); - if (!add_string_val (self, path, "private_key", FALSE, FALSE, error)) - return FALSE; - added = TRUE; - break; - default: - break; - } - - if (added) { - NMSetting8021xCKFormat format; - NMSetting8021xCKScheme scheme; - - format = nm_setting_802_1x_get_private_key_format (setting); - scheme = nm_setting_802_1x_get_private_key_scheme (setting); - - if ( scheme == NM_SETTING_802_1X_CK_SCHEME_PATH - || format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { - /* Only add the private key password for PKCS#12 blobs and - * all path schemes, since in both of these cases the private key - * isn't decrypted at all. - */ - value = nm_setting_802_1x_get_private_key_password (setting); - if (!add_string_val (self, value, "private_key_passwd", FALSE, TRUE, error)) - return FALSE; - } - - if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) { - /* Only add the client cert if the private key is not PKCS#12, as - * wpa_supplicant configuration directs us to do. - */ - switch (nm_setting_802_1x_get_client_cert_scheme (setting)) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - bytes = nm_setting_802_1x_get_client_cert_blob (setting); - if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "client_cert", con_uuid, error)) - return FALSE; - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = nm_setting_802_1x_get_client_cert_path (setting); - if (!add_string_val (self, path, "client_cert", FALSE, FALSE, error)) - return FALSE; - break; - default: - break; - } - } - } - - /* Phase 2 private key */ - added = FALSE; - switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - bytes = nm_setting_802_1x_get_phase2_private_key_blob (setting); - if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "private_key2", con_uuid, error)) - return FALSE; - added = TRUE; - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = nm_setting_802_1x_get_phase2_private_key_path (setting); - if (!add_string_val (self, path, "private_key2", FALSE, FALSE, error)) - return FALSE; - added = TRUE; - break; - default: - break; - } - - if (added) { - NMSetting8021xCKFormat format; - NMSetting8021xCKScheme scheme; - - format = nm_setting_802_1x_get_phase2_private_key_format (setting); - scheme = nm_setting_802_1x_get_phase2_private_key_scheme (setting); - - if ( scheme == NM_SETTING_802_1X_CK_SCHEME_PATH - || format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { - /* Only add the private key password for PKCS#12 blobs and - * all path schemes, since in both of these cases the private key - * isn't decrypted at all. - */ - value = nm_setting_802_1x_get_phase2_private_key_password (setting); - if (!add_string_val (self, value, "private_key2_passwd", FALSE, TRUE, error)) - return FALSE; - } - - if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) { - /* Only add the client cert if the private key is not PKCS#12, as - * wpa_supplicant configuration directs us to do. - */ - switch (nm_setting_802_1x_get_phase2_client_cert_scheme (setting)) { - case NM_SETTING_802_1X_CK_SCHEME_BLOB: - bytes = nm_setting_802_1x_get_phase2_client_cert_blob (setting); - if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "client_cert2", con_uuid, error)) - return FALSE; - break; - case NM_SETTING_802_1X_CK_SCHEME_PATH: - path = nm_setting_802_1x_get_phase2_client_cert_path (setting); - if (!add_string_val (self, path, "client_cert2", FALSE, FALSE, error)) - return FALSE; - break; - default: - break; - } - } - } - - value = nm_setting_802_1x_get_identity (setting); - if (!add_string_val (self, value, "identity", FALSE, FALSE, error)) - return FALSE; - value = nm_setting_802_1x_get_anonymous_identity (setting); - if (!add_string_val (self, value, "anonymous_identity", FALSE, FALSE, error)) - return FALSE; - - return TRUE; -} - -gboolean -nm_supplicant_config_add_no_security (NMSupplicantConfig *self, GError **error) -{ - return nm_supplicant_config_add_option (self, "key_mgmt", "NONE", -1, FALSE, error); -} - diff --git a/src/supplicant-manager/nm-supplicant-config.h b/src/supplicant-manager/nm-supplicant-config.h deleted file mode 100644 index bf3e64c5..00000000 --- a/src/supplicant-manager/nm-supplicant-config.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2012 Red Hat, Inc. - * Copyright (C) 2007 - 2008 Novell, Inc. - */ - -#ifndef __NETWORKMANAGER_SUPPLICANT_CONFIG_H__ -#define __NETWORKMANAGER_SUPPLICANT_CONFIG_H__ - -#include -#include -#include - -#include "nm-supplicant-types.h" - -#define NM_TYPE_SUPPLICANT_CONFIG (nm_supplicant_config_get_type ()) -#define NM_SUPPLICANT_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_CONFIG, NMSupplicantConfig)) -#define NM_SUPPLICANT_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_CONFIG, NMSupplicantConfigClass)) -#define NM_IS_SUPPLICANT_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SUPPLICANT_CONFIG)) -#define NM_IS_SUPPLICANT_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_CONFIG)) -#define NM_SUPPLICANT_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_CONFIG, NMSupplicantConfigClass)) - -struct _NMSupplicantConfig -{ - GObject parent; -}; - -typedef struct -{ - GObjectClass parent; -} NMSupplicantConfigClass; - - -GType nm_supplicant_config_get_type (void); - -NMSupplicantConfig *nm_supplicant_config_new (void); - -guint32 nm_supplicant_config_get_ap_scan (NMSupplicantConfig *self); - -gboolean nm_supplicant_config_fast_required (NMSupplicantConfig *self); - -GVariant *nm_supplicant_config_to_variant (NMSupplicantConfig *self); - -GHashTable *nm_supplicant_config_get_blobs (NMSupplicantConfig *self); - -gboolean nm_supplicant_config_add_setting_wireless (NMSupplicantConfig *self, - NMSettingWireless *setting, - guint32 fixed_freq, - GError **error); - -gboolean nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self, - NMSettingWirelessSecurity *setting, - NMSetting8021x *setting_8021x, - const char *con_uuid, - guint32 mtu, - GError **error); - -gboolean nm_supplicant_config_add_no_security (NMSupplicantConfig *self, - GError **error); - -gboolean nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self, - NMSetting8021x *setting, - const char *con_uuid, - guint32 mtu, - gboolean wired, - GError **error); - -#endif /* __NETWORKMANAGER_SUPPLICANT_CONFIG_H__ */ diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c deleted file mode 100644 index 05d9aa67..00000000 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ /dev/null @@ -1,1663 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2012 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#include "nm-default.h" - -#include -#include - -#include "NetworkManagerUtils.h" -#include "nm-supplicant-interface.h" -#include "nm-supplicant-config.h" -#include "nm-core-internal.h" -#include "nm-dbus-compat.h" - -#define WPAS_DBUS_IFACE_INTERFACE WPAS_DBUS_INTERFACE ".Interface" -#define WPAS_DBUS_IFACE_BSS WPAS_DBUS_INTERFACE ".BSS" -#define WPAS_DBUS_IFACE_NETWORK WPAS_DBUS_INTERFACE ".Network" -#define WPAS_ERROR_INVALID_IFACE WPAS_DBUS_INTERFACE ".InvalidInterface" -#define WPAS_ERROR_EXISTS_ERROR WPAS_DBUS_INTERFACE ".InterfaceExists" - -G_DEFINE_TYPE (NMSupplicantInterface, nm_supplicant_interface, G_TYPE_OBJECT) - -#define NM_SUPPLICANT_INTERFACE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_SUPPLICANT_INTERFACE, \ - NMSupplicantInterfacePrivate)) - -/* Signals */ -enum { - STATE, /* change in the interface's state */ - REMOVED, /* interface was removed by the supplicant */ - NEW_BSS, /* interface saw a new access point from a scan */ - BSS_UPDATED, /* a BSS property changed */ - BSS_REMOVED, /* supplicant removed BSS from its scan list */ - SCAN_DONE, /* wifi scan is complete */ - CONNECTION_ERROR, /* an error occurred during a connection request */ - CREDENTIALS_REQUEST, /* 802.1x identity or password requested */ - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - - -/* Properties */ -NM_GOBJECT_PROPERTIES_DEFINE (NMSupplicantInterface, - PROP_IFACE, - PROP_SCANNING, - PROP_CURRENT_BSS, - PROP_IS_WIRELESS, - PROP_FAST_SUPPORTED, - PROP_AP_SUPPORT, -); - -typedef struct { - char * dev; - bool is_wireless; - bool fast_supported; - gboolean has_credreq; /* Whether querying 802.1x credentials is supported */ - NMSupplicantFeature ap_support; /* Lightweight AP mode support */ - NMSupplicantFeature mac_randomization_support; - guint32 max_scan_ssids; - guint32 ready_count; - - char * object_path; - guint32 state; - int disconnect_reason; - - gboolean scanning; - - GDBusProxy * wpas_proxy; - GCancellable * init_cancellable; - GDBusProxy * iface_proxy; - GCancellable * other_cancellable; - GCancellable * assoc_cancellable; - char * net_path; - guint32 blobs_left; - GHashTable * bss_proxies; - char * current_bss; - - gint32 last_scan; /* timestamp as returned by nm_utils_get_monotonic_timestamp_s() */ - - NMSupplicantConfig *cfg; -} NMSupplicantInterfacePrivate; - -/*********************************************************************************************/ - -#define _NMLOG_DOMAIN LOGD_SUPPLICANT -#define _NMLOG_PREFIX_NAME "sup-iface" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - char _sbuf[64]; \ - \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME, \ - ((self) \ - ? nm_sprintf_buf (_sbuf, \ - "[%p,%s]", \ - (self), \ - NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev) \ - : "") \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -/*********************************************************************************************/ - -static void -emit_error_helper (NMSupplicantInterface *self, GError *error) -{ - char *name = NULL; - - if (g_dbus_error_is_remote_error (error)) - name = g_dbus_error_get_remote_error (error); - - g_signal_emit (self, signals[CONNECTION_ERROR], 0, name, error->message); - g_free (name); -} - -static void -bss_props_changed_cb (GDBusProxy *proxy, - GVariant *changed_properties, - char **invalidated_properties, - gpointer user_data) -{ - NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (priv->scanning) - priv->last_scan = nm_utils_get_monotonic_timestamp_s (); - - g_signal_emit (self, signals[BSS_UPDATED], 0, - g_dbus_proxy_get_object_path (proxy), - changed_properties); -} - -static GVariant * -_get_bss_proxy_properties (NMSupplicantInterface *self, GDBusProxy *proxy) -{ - gs_strfreev char **properties = NULL; - GVariantBuilder builder; - char **iter; - - iter = properties = g_dbus_proxy_get_cached_property_names (proxy); - if (!iter) - return NULL; - - g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); - while (*iter) { - GVariant *copy = g_dbus_proxy_get_cached_property (proxy, *iter); - - g_variant_builder_add (&builder, "{sv}", *iter++, copy); - g_variant_unref (copy); - } - - return g_variant_builder_end (&builder); -} - -#define BSS_PROXY_INITED "bss-proxy-inited" - -static void -on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *props = NULL; - - if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - self = NM_SUPPLICANT_INTERFACE (user_data); - _LOGD ("failed to acquire BSS proxy: (%s)", error->message); - g_hash_table_remove (NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->bss_proxies, - g_dbus_proxy_get_object_path (proxy)); - } - return; - } - - self = NM_SUPPLICANT_INTERFACE (user_data); - props = _get_bss_proxy_properties (self, proxy); - if (!props) - return; - - g_object_set_data (G_OBJECT (proxy), BSS_PROXY_INITED, GUINT_TO_POINTER (TRUE)); - - g_signal_emit (self, signals[NEW_BSS], 0, - g_dbus_proxy_get_object_path (proxy), - g_variant_ref_sink (props)); -} - -static void -handle_new_bss (NMSupplicantInterface *self, const char *object_path) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - GDBusProxy *bss_proxy; - - g_return_if_fail (object_path != NULL); - - if (g_hash_table_lookup (priv->bss_proxies, object_path)) - return; - - bss_proxy = g_object_new (G_TYPE_DBUS_PROXY, - "g-bus-type", G_BUS_TYPE_SYSTEM, - "g-flags", G_DBUS_PROXY_FLAGS_NONE, - "g-name", WPAS_DBUS_SERVICE, - "g-object-path", object_path, - "g-interface-name", WPAS_DBUS_IFACE_BSS, - NULL); - g_hash_table_insert (priv->bss_proxies, - (char *) g_dbus_proxy_get_object_path (bss_proxy), - bss_proxy); - g_signal_connect (bss_proxy, "g-properties-changed", G_CALLBACK (bss_props_changed_cb), self); - g_async_initable_init_async (G_ASYNC_INITABLE (bss_proxy), - G_PRIORITY_DEFAULT, - priv->other_cancellable, - (GAsyncReadyCallback) on_bss_proxy_acquired, - self); -} - -static void -set_state (NMSupplicantInterface *self, guint32 new_state) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - guint32 old_state = priv->state; - - g_return_if_fail (new_state < NM_SUPPLICANT_INTERFACE_STATE_LAST); - - if (new_state == priv->state) - return; - - /* DOWN is a terminal state */ - g_return_if_fail (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DOWN); - - /* Cannot regress to READY, STARTING, or INIT from higher states */ - if (priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY) - g_return_if_fail (new_state > NM_SUPPLICANT_INTERFACE_STATE_READY); - - if (new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) { - if (priv->other_cancellable) { - g_warn_if_fail (priv->other_cancellable == NULL); - g_cancellable_cancel (priv->other_cancellable); - g_clear_object (&priv->other_cancellable); - } - priv->other_cancellable = g_cancellable_new (); - } else if (new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) { - if (priv->init_cancellable) - g_cancellable_cancel (priv->init_cancellable); - g_clear_object (&priv->init_cancellable); - - if (priv->other_cancellable) - g_cancellable_cancel (priv->other_cancellable); - g_clear_object (&priv->other_cancellable); - - if (priv->iface_proxy) - g_signal_handlers_disconnect_by_data (priv->iface_proxy, self); - } - - priv->state = new_state; - - if ( priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING - || old_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING) - priv->last_scan = nm_utils_get_monotonic_timestamp_s (); - - /* Disconnect reason is no longer relevant when not in the DISCONNECTED state */ - if (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED) - priv->disconnect_reason = 0; - - g_signal_emit (self, signals[STATE], 0, - priv->state, - old_state, - priv->disconnect_reason); -} - -static int -wpas_state_string_to_enum (const char *str_state) -{ - if (!strcmp (str_state, "interface_disabled")) - return NM_SUPPLICANT_INTERFACE_STATE_DISABLED; - else if (!strcmp (str_state, "disconnected")) - return NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED; - else if (!strcmp (str_state, "inactive")) - return NM_SUPPLICANT_INTERFACE_STATE_INACTIVE; - else if (!strcmp (str_state, "scanning")) - return NM_SUPPLICANT_INTERFACE_STATE_SCANNING; - else if (!strcmp (str_state, "authenticating")) - return NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING; - else if (!strcmp (str_state, "associating")) - return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING; - else if (!strcmp (str_state, "associated")) - return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED; - else if (!strcmp (str_state, "4way_handshake")) - return NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE; - else if (!strcmp (str_state, "group_handshake")) - return NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE; - else if (!strcmp (str_state, "completed")) - return NM_SUPPLICANT_INTERFACE_STATE_COMPLETED; - - return -1; -} - -static void -set_state_from_string (NMSupplicantInterface *self, const char *new_state) -{ - int state; - - state = wpas_state_string_to_enum (new_state); - if (state == -1) { - _LOGW ("unknown supplicant state '%s'", new_state); - return; - } - set_state (self, (guint32) state); -} - -static void -set_scanning (NMSupplicantInterface *self, gboolean new_scanning) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (priv->scanning != new_scanning) { - priv->scanning = new_scanning; - - /* Cache time of last scan completion */ - if (priv->scanning == FALSE) - priv->last_scan = nm_utils_get_monotonic_timestamp_s (); - - _notify (self, PROP_SCANNING); - } -} - -gboolean -nm_supplicant_interface_get_scanning (NMSupplicantInterface *self) -{ - NMSupplicantInterfacePrivate *priv; - - g_return_val_if_fail (self != NULL, FALSE); - - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - if (priv->scanning) - return TRUE; - if (priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING) - return TRUE; - return FALSE; -} - -const char * -nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self) -{ - NMSupplicantInterfacePrivate *priv; - - g_return_val_if_fail (self != NULL, FALSE); - - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - return priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY ? priv->current_bss : NULL; -} - -gint32 -nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self) -{ - return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->last_scan; -} - -#define MATCH_PROPERTY(p, n, v, t) (!strcmp (p, n) && g_variant_is_of_type (v, t)) - -static void -parse_capabilities (NMSupplicantInterface *self, GVariant *capabilities) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - gboolean have_active = FALSE, have_ssid = FALSE; - gint32 max_scan_ssids = -1; - const char **array; - - g_return_if_fail (capabilities && g_variant_is_of_type (capabilities, G_VARIANT_TYPE_VARDICT)); - - if ( g_variant_lookup (capabilities, "Scan", "^a&s", &array) - && array) { - if (g_strv_contains (array, "active")) - have_active = TRUE; - if (g_strv_contains (array, "ssid")) - have_ssid = TRUE; - g_free (array); - } - - if (g_variant_lookup (capabilities, "MaxScanSSID", "i", &max_scan_ssids)) { - /* We need active scan and SSID probe capabilities to care about MaxScanSSIDs */ - if (max_scan_ssids > 0 && have_active && have_ssid) { - /* wpa_supplicant's WPAS_MAX_SCAN_SSIDS value is 16, but for speed - * and to ensure we don't disclose too many SSIDs from the hidden - * list, we'll limit to 5. - */ - priv->max_scan_ssids = CLAMP (max_scan_ssids, 0, 5); - _LOGI ("supports %d scan SSIDs", priv->max_scan_ssids); - } - } -} - -static void -iface_check_ready (NMSupplicantInterface *self) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (priv->ready_count && priv->state < NM_SUPPLICANT_INTERFACE_STATE_READY) { - priv->ready_count--; - if (priv->ready_count == 0) - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_READY); - } -} - -gboolean -nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self, - const char *field, - const char *value, - GError **error) -{ - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *reply = NULL; - - g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE); - g_return_val_if_fail (field != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - g_return_val_if_fail (priv->has_credreq == TRUE, FALSE); - - /* Need a network block object path */ - g_return_val_if_fail (priv->net_path, FALSE); - reply = g_dbus_proxy_call_sync (priv->iface_proxy, - "NetworkReply", - g_variant_new ("(oss)", - priv->net_path, - field, - value), - G_DBUS_CALL_FLAGS_NONE, - 5000, - NULL, - error); - if (error && *error) - g_dbus_error_strip_remote_error (*error); - - return !!reply; -} - -static void -iface_check_netreply_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; - - /* We know NetworkReply is supported if the NetworkReply method returned - * successfully (which is unexpected since we sent a bogus network - * object path) or if we got an "InvalidArgs" (which indicates NetworkReply - * is supported). We know it's not supported if we get an - * "UnknownMethod" error. - */ - - variant = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (variant || _nm_dbus_error_has_name (error, "fi.w1.wpa_supplicant1.InvalidArgs")) - priv->has_credreq = TRUE; - - _LOGD ("supplicant %s network credentials requests", - priv->has_credreq ? "supports" : "does not support"); - - iface_check_ready (self); -} - -NMSupplicantFeature -nm_supplicant_interface_get_ap_support (NMSupplicantInterface *self) -{ - return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->ap_support; -} - -void -nm_supplicant_interface_set_ap_support (NMSupplicantInterface *self, - NMSupplicantFeature ap_support) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - /* Use the best indicator of support between the supplicant global - * Capabilities property and the interface's introspection data. - */ - if (ap_support > priv->ap_support) - priv->ap_support = ap_support; -} - -static void -set_preassoc_scan_mac_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; - - variant = _nm_dbus_proxy_call_finish (proxy, result, - G_VARIANT_TYPE ("()"), - &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - if (error) - _LOGW ("failed to enable scan MAC address randomization (%s)", error->message); - iface_check_ready (self); -} - -static void -iface_introspect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; - const char *data; - - variant = _nm_dbus_proxy_call_finish (proxy, result, - G_VARIANT_TYPE ("(s)"), - &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (variant) { - g_variant_get (variant, "(&s)", &data); - - /* The ProbeRequest method only exists if AP mode has been enabled */ - if (strstr (data, "ProbeRequest")) - priv->ap_support = NM_SUPPLICANT_FEATURE_YES; - - if (strstr (data, "PreassocMacAddr")) { - priv->mac_randomization_support = NM_SUPPLICANT_FEATURE_YES; - - /* Turn on MAC randomization during scans by default */ - priv->ready_count++; - g_dbus_proxy_call (priv->iface_proxy, - DBUS_INTERFACE_PROPERTIES ".Set", - g_variant_new ("(ssv)", - WPAS_DBUS_IFACE_INTERFACE, - "PreassocMacAddr", - g_variant_new_string ("0")), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - (GAsyncReadyCallback) set_preassoc_scan_mac_cb, - self); - } - } - - iface_check_ready (self); -} - -static void -wpas_iface_scan_done (GDBusProxy *proxy, - gboolean success, - gpointer user_data) -{ - NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - GVariant *props; - GHashTableIter iter; - char *bss_path; - GDBusProxy *bss_proxy; - - /* Cache last scan completed time */ - priv->last_scan = nm_utils_get_monotonic_timestamp_s (); - - g_signal_emit (self, signals[SCAN_DONE], 0, success); - - /* Emit NEW_BSS so that wifi device has the APs (in case it removed them) */ - g_hash_table_iter_init (&iter, priv->bss_proxies); - while (g_hash_table_iter_next (&iter, (gpointer) &bss_path, (gpointer) &bss_proxy)) { - if (g_object_get_data (G_OBJECT (bss_proxy), BSS_PROXY_INITED)) { - props = _get_bss_proxy_properties (self, bss_proxy); - if (props) { - g_signal_emit (self, signals[NEW_BSS], 0, - bss_path, - g_variant_ref_sink (props)); - g_variant_unref (props); - } - } - } -} - -static void -wpas_iface_bss_added (GDBusProxy *proxy, - const char *path, - GVariant *props, - gpointer user_data) -{ - NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (priv->scanning) - priv->last_scan = nm_utils_get_monotonic_timestamp_s (); - - handle_new_bss (self, path); -} - -static void -wpas_iface_bss_removed (GDBusProxy *proxy, - const char *path, - gpointer user_data) -{ - NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - g_signal_emit (self, signals[BSS_REMOVED], 0, path); - g_hash_table_remove (priv->bss_proxies, path); -} - -static void -wpas_iface_network_request (GDBusProxy *proxy, - const char *path, - const char *field, - const char *message, - gpointer user_data) -{ - NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (priv->has_credreq && priv->net_path && !g_strcmp0 (path, priv->net_path)) - g_signal_emit (self, signals[CREDENTIALS_REQUEST], 0, field, message); -} - -static void -props_changed_cb (GDBusProxy *proxy, - GVariant *changed_properties, - GStrv invalidated_properties, - gpointer user_data) -{ - NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - const char *s, **array, **iter; - gboolean b = FALSE; - gint32 i32; - GVariant *v; - - g_object_freeze_notify (G_OBJECT (self)); - - if (g_variant_lookup (changed_properties, "Scanning", "b", &b)) - set_scanning (self, b); - - if ( g_variant_lookup (changed_properties, "State", "&s", &s) - && priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY) { - /* Only transition to actual wpa_supplicant interface states (ie, - * anything > READY) after the NMSupplicantInterface has had a - * chance to initialize, which is signalled by entering the READY - * state. - */ - set_state_from_string (self, s); - } - - if (g_variant_lookup (changed_properties, "BSSs", "^a&o", &array)) { - iter = array; - while (*iter) - handle_new_bss (self, *iter++); - g_free (array); - } - - if (g_variant_lookup (changed_properties, "CurrentBSS", "&o", &s)) { - if (strcmp (s, "/") == 0) - s = NULL; - if (g_strcmp0 (s, priv->current_bss) != 0) { - g_free (priv->current_bss); - priv->current_bss = g_strdup (s); - _notify (self, PROP_CURRENT_BSS); - } - } - - v = g_variant_lookup_value (changed_properties, "Capabilities", G_VARIANT_TYPE_VARDICT); - if (v) { - parse_capabilities (self, v); - g_variant_unref (v); - } - - if (g_variant_lookup (changed_properties, "DisconnectReason", "i", &i32)) { - /* Disconnect reason is currently only given for deauthentication events, - * not disassociation; currently they are IEEE 802.11 "reason codes", - * defined by (IEEE 802.11-2007, 7.3.1.7, Table 7-22). Any locally caused - * deauthentication will be negative, while authentications caused by the - * AP will be positive. - */ - priv->disconnect_reason = i32; - if (priv->disconnect_reason != 0) - _LOGW ("connection disconnected (reason %d)", priv->disconnect_reason); - } - - g_object_thaw_notify (G_OBJECT (self)); -} - -static void -on_iface_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_free_error GError *error = NULL; - - if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - self = NM_SUPPLICANT_INTERFACE (user_data); - _LOGW ("failed to acquire wpa_supplicant interface proxy: (%s)", error->message); - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); - } - return; - } - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - _nm_dbus_signal_connect (priv->iface_proxy, "ScanDone", G_VARIANT_TYPE ("(b)"), - G_CALLBACK (wpas_iface_scan_done), self); - _nm_dbus_signal_connect (priv->iface_proxy, "BSSAdded", G_VARIANT_TYPE ("(oa{sv})"), - G_CALLBACK (wpas_iface_bss_added), self); - _nm_dbus_signal_connect (priv->iface_proxy, "BSSRemoved", G_VARIANT_TYPE ("(o)"), - G_CALLBACK (wpas_iface_bss_removed), self); - _nm_dbus_signal_connect (priv->iface_proxy, "NetworkRequest", G_VARIANT_TYPE ("(oss)"), - G_CALLBACK (wpas_iface_network_request), self); - - /* Scan result aging parameters */ - g_dbus_proxy_call (priv->iface_proxy, - "org.freedesktop.DBus.Properties.Set", - g_variant_new ("(ssv)", - WPAS_DBUS_IFACE_INTERFACE, - "BSSExpireAge", - g_variant_new_uint32 (250)), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - NULL, - NULL); - g_dbus_proxy_call (priv->iface_proxy, - "org.freedesktop.DBus.Properties.Set", - g_variant_new ("(ssv)", - WPAS_DBUS_IFACE_INTERFACE, - "BSSExpireCount", - g_variant_new_uint32 (2)), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - NULL, - NULL); - - /* Check whether NetworkReply and AP mode are supported */ - priv->ready_count = 1; - g_dbus_proxy_call (priv->iface_proxy, - "NetworkReply", - g_variant_new ("(oss)", - "/fff", - "foobar", - "foobar"), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - (GAsyncReadyCallback) iface_check_netreply_cb, - self); - - if (priv->ap_support == NM_SUPPLICANT_FEATURE_UNKNOWN || - priv->mac_randomization_support == NM_SUPPLICANT_FEATURE_UNKNOWN) { - /* If the global supplicant capabilities property is not present, we can - * fall back to checking whether the ProbeRequest method is supported. If - * neither of these works we have no way of determining if AP mode is - * supported or not. hostap 1.0 and earlier don't support either of these. - */ - priv->ready_count++; - g_dbus_proxy_call (priv->iface_proxy, - DBUS_INTERFACE_INTROSPECTABLE ".Introspect", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - (GAsyncReadyCallback) iface_introspect_cb, - self); - } -} - -static void -interface_add_done (NMSupplicantInterface *self, const char *path) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - _LOGD ("interface added to supplicant"); - - priv->object_path = g_strdup (path); - priv->iface_proxy = g_object_new (G_TYPE_DBUS_PROXY, - "g-bus-type", G_BUS_TYPE_SYSTEM, - "g-flags", G_DBUS_PROXY_FLAGS_NONE, - "g-name", WPAS_DBUS_SERVICE, - "g-object-path", priv->object_path, - "g-interface-name", WPAS_DBUS_IFACE_INTERFACE, - NULL); - g_signal_connect (priv->iface_proxy, "g-properties-changed", G_CALLBACK (props_changed_cb), self); - g_async_initable_init_async (G_ASYNC_INITABLE (priv->iface_proxy), - G_PRIORITY_DEFAULT, - priv->init_cancellable, - (GAsyncReadyCallback) on_iface_proxy_acquired, - self); -} - -static void -interface_get_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; - const char *path; - - variant = _nm_dbus_proxy_call_finish (proxy, result, - G_VARIANT_TYPE ("(o)"), - &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (variant) { - g_variant_get (variant, "(&o)", &path); - interface_add_done (self, path); - } else { - g_dbus_error_strip_remote_error (error); - _LOGE ("error getting interface: %s", error->message); - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); - } -} - -static void -interface_add_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_free_error GError *error = NULL; - gs_unref_variant GVariant *variant = NULL; - const char *path; - - variant = _nm_dbus_proxy_call_finish (proxy, result, - G_VARIANT_TYPE ("(o)"), - &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (variant) { - g_variant_get (variant, "(&o)", &path); - interface_add_done (self, path); - } else if (_nm_dbus_error_has_name (error, WPAS_ERROR_EXISTS_ERROR)) { - /* Interface already added, just get its object path */ - g_dbus_proxy_call (priv->wpas_proxy, - "GetInterface", - g_variant_new ("(s)", priv->dev), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - (GAsyncReadyCallback) interface_get_cb, - self); - } else if ( g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN) - || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_EXEC_FAILED) - || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_FORK_FAILED) - || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_FAILED) - || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_TIMEOUT) - || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NO_REPLY) - || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_TIMED_OUT) - || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND)) { - /* Supplicant wasn't running and could not be launched via service - * activation. Wait for it to start by moving back to the INIT - * state. - */ - g_dbus_error_strip_remote_error (error); - _LOGD ("failed to activate supplicant: %s", error->message); - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_INIT); - } else { - g_dbus_error_strip_remote_error (error); - _LOGE ("error adding interface: %s", error->message); - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); - } -} - -#if HAVE_WEXT -#define DEFAULT_WIFI_DRIVER "nl80211,wext" -#else -#define DEFAULT_WIFI_DRIVER "nl80211" -#endif - -static void -on_wpas_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_free_error GError *error = NULL; - GDBusProxy *wpas_proxy; - GVariantBuilder props; - - wpas_proxy = g_dbus_proxy_new_for_bus_finish (result, &error); - if (!wpas_proxy) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - self = NM_SUPPLICANT_INTERFACE (user_data); - _LOGW ("failed to acquire wpa_supplicant proxy: (%s)", error->message); - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); - } - return; - } - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - priv->wpas_proxy = wpas_proxy; - - /* Try to add the interface to the supplicant. If the supplicant isn't - * running, this will start it via D-Bus activation and return the response - * when the supplicant has started. - */ - - g_variant_builder_init (&props, G_VARIANT_TYPE_VARDICT); - g_variant_builder_add (&props, "{sv}", - "Driver", - g_variant_new_string (priv->is_wireless ? DEFAULT_WIFI_DRIVER : "wired")); - g_variant_builder_add (&props, "{sv}", - "Ifname", - g_variant_new_string (priv->dev)); - - g_dbus_proxy_call (priv->wpas_proxy, - "CreateInterface", - g_variant_new ("(a{sv})", &props), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - (GAsyncReadyCallback) interface_add_cb, - self); -} - -static void -interface_add (NMSupplicantInterface *self) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - /* Can only start the interface from INIT state */ - g_return_if_fail (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT); - - _LOGD ("adding interface to supplicant"); - - /* Move to starting to prevent double-calls of interface_add() */ - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_STARTING); - - g_warn_if_fail (priv->init_cancellable == NULL); - g_clear_object (&priv->init_cancellable); - priv->init_cancellable = g_cancellable_new (); - - g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | - G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, - NULL, - WPAS_DBUS_SERVICE, - WPAS_DBUS_PATH, - WPAS_DBUS_INTERFACE, - priv->init_cancellable, - (GAsyncReadyCallback) on_wpas_proxy_acquired, - self); -} - -void -nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self, - gboolean available) -{ - NMSupplicantInterfacePrivate *priv; - - g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); - - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (available) { - /* This can happen if the supplicant couldn't be activated but - * for some reason was started after the activation failure. - */ - if (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT) - interface_add (self); - } else { - /* The supplicant stopped; so we must tear down the interface */ - set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); - } -} - -static void -log_result_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if ( !reply - && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) - && !strstr (error->message, "fi.w1.wpa_supplicant1.NotConnected")) { - g_dbus_error_strip_remote_error (error); - nm_log_warn (_NMLOG_DOMAIN, "%s: failed to %s: %s", - _NMLOG_PREFIX_NAME, (const char *) user_data, error->message); - } -} - -void -nm_supplicant_interface_disconnect (NMSupplicantInterface * self) -{ - NMSupplicantInterfacePrivate *priv; - - g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); - - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - /* Cancel all pending calls related to a prior connection attempt */ - if (priv->assoc_cancellable) { - g_cancellable_cancel (priv->assoc_cancellable); - g_clear_object (&priv->assoc_cancellable); - } - - /* Don't do anything if there is no connection to the supplicant yet. */ - if (!priv->iface_proxy) - return; - - /* Disconnect from the current AP */ - if ( (priv->state >= NM_SUPPLICANT_INTERFACE_STATE_SCANNING) - && (priv->state <= NM_SUPPLICANT_INTERFACE_STATE_COMPLETED)) { - g_dbus_proxy_call (priv->iface_proxy, - "Disconnect", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - (GAsyncReadyCallback) log_result_cb, - "disconnect"); - } - - /* Remove any network that was added by NetworkManager */ - if (priv->net_path) { - g_dbus_proxy_call (priv->iface_proxy, - "RemoveNetwork", - g_variant_new ("(o)", priv->net_path), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->other_cancellable, - (GAsyncReadyCallback) log_result_cb, - "remove network"); - g_free (priv->net_path); - priv->net_path = NULL; - } -} - -static void -select_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if ( !reply - && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - self = NM_SUPPLICANT_INTERFACE (user_data); - g_dbus_error_strip_remote_error (error); - _LOGW ("couldn't select network config: %s", error->message); - emit_error_helper (self, error); - } -} - -static void -call_select_network (NMSupplicantInterface *self) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - /* We only select the network after all blobs (if any) have been set */ - if (priv->blobs_left == 0) { - g_dbus_proxy_call (priv->iface_proxy, - "SelectNetwork", - g_variant_new ("(o)", priv->net_path), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->assoc_cancellable, - (GAsyncReadyCallback) select_network_cb, - self); - } -} - -static void -add_blob_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - priv->blobs_left--; - if (reply) - call_select_network (self); - else { - g_dbus_error_strip_remote_error (error); - _LOGW ("couldn't set network certificates: %s", error->message); - emit_error_helper (self, error); - } -} - -static void -add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - GHashTable *blobs; - GHashTableIter iter; - const char *blob_name; - GByteArray *blob_data; - - reply = _nm_dbus_proxy_call_finish (proxy, result, - G_VARIANT_TYPE ("(o)"), - &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - g_free (priv->net_path); - priv->net_path = NULL; - - if (error) { - g_dbus_error_strip_remote_error (error); - _LOGW ("adding network to supplicant failed: %s", error->message); - emit_error_helper (self, error); - return; - } - - g_variant_get (reply, "(o)", &priv->net_path); - - /* Send blobs first; otherwise jump to selecting the network */ - blobs = nm_supplicant_config_get_blobs (priv->cfg); - priv->blobs_left = g_hash_table_size (blobs); - - g_hash_table_iter_init (&iter, blobs); - while (g_hash_table_iter_next (&iter, (gpointer) &blob_name, (gpointer) &blob_data)) { - g_dbus_proxy_call (priv->iface_proxy, - "AddBlob", - g_variant_new ("(s@ay)", - blob_name, - g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, - blob_data->data, blob_data->len, 1)), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->assoc_cancellable, - (GAsyncReadyCallback) add_blob_cb, - self); - } - - call_select_network (self); -} - -static void -add_network (NMSupplicantInterface *self) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - g_dbus_proxy_call (priv->iface_proxy, - "AddNetwork", - g_variant_new ("(@a{sv})", nm_supplicant_config_to_variant (priv->cfg)), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->assoc_cancellable, - (GAsyncReadyCallback) add_network_cb, - self); -} - -static void -set_mac_randomization_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (!reply) { - g_dbus_error_strip_remote_error (error); - _LOGW ("couldn't send MAC randomization mode to the supplicant interface: %s", - error->message); - emit_error_helper (self, error); - return; - } - - _LOGT ("config: set MAC randomization to 0"); - add_network (self); -} - -static void -set_ap_scan_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - NMSupplicantInterfacePrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - if (!reply) { - g_dbus_error_strip_remote_error (error); - _LOGW ("couldn't send AP scan mode to the supplicant interface: %s", - error->message); - emit_error_helper (self, error); - return; - } - - _LOGI ("config: set interface ap_scan to %d", - nm_supplicant_config_get_ap_scan (priv->cfg)); - - if (priv->mac_randomization_support == NM_SUPPLICANT_FEATURE_YES) { - /* Enable/disable association MAC address randomization */ - g_dbus_proxy_call (priv->iface_proxy, - DBUS_INTERFACE_PROPERTIES ".Set", - g_variant_new ("(ssv)", - WPAS_DBUS_IFACE_INTERFACE, - "MacAddr", - g_variant_new_string ("0")), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->assoc_cancellable, - (GAsyncReadyCallback) set_mac_randomization_cb, - self); - } else - add_network (self); -} - -gboolean -nm_supplicant_interface_set_config (NMSupplicantInterface *self, - NMSupplicantConfig *cfg, - GError **error) -{ - NMSupplicantInterfacePrivate *priv; - - g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE); - - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - nm_supplicant_interface_disconnect (self); - - /* Make sure the supplicant supports EAP-FAST before trying to send - * it an EAP-FAST configuration. - */ - if (nm_supplicant_config_fast_required (cfg) && !priv->fast_supported) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "EAP-FAST is not supported by the supplicant"); - return FALSE; - } - - g_clear_object (&priv->cfg); - if (cfg) { - priv->assoc_cancellable = g_cancellable_new (); - priv->cfg = g_object_ref (cfg); - g_dbus_proxy_call (priv->iface_proxy, - DBUS_INTERFACE_PROPERTIES ".Set", - g_variant_new ("(ssv)", - WPAS_DBUS_IFACE_INTERFACE, - "ApScan", - g_variant_new_uint32 (nm_supplicant_config_get_ap_scan (priv->cfg))), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->assoc_cancellable, - (GAsyncReadyCallback) set_ap_scan_cb, - self); - } - return TRUE; -} - -static void -scan_request_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantInterface *self; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_SUPPLICANT_INTERFACE (user_data); - - if (error) { - if (_nm_dbus_error_has_name (error, "fi.w1.wpa_supplicant1.Interface.ScanError")) - _LOGD ("could not get scan request result: %s", error->message); - else { - g_dbus_error_strip_remote_error (error); - _LOGW ("could not get scan request result: %s", error->message); - } - } - g_signal_emit (self, signals[SCAN_DONE], 0, error ? FALSE : TRUE); -} - -gboolean -nm_supplicant_interface_request_scan (NMSupplicantInterface *self, const GPtrArray *ssids) -{ - NMSupplicantInterfacePrivate *priv; - GVariantBuilder builder; - guint i; - - g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE); - - priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - /* Scan parameters */ - g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); - g_variant_builder_add (&builder, "{sv}", "Type", g_variant_new_string ("active")); - if (ssids) { - GVariantBuilder ssids_builder; - - g_variant_builder_init (&ssids_builder, G_VARIANT_TYPE_BYTESTRING_ARRAY); - for (i = 0; i < ssids->len; i++) { - GByteArray *ssid = g_ptr_array_index (ssids, i); - g_variant_builder_add (&ssids_builder, "@ay", - g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, - ssid->data, ssid->len, 1)); - } - g_variant_builder_add (&builder, "{sv}", "SSIDs", g_variant_builder_end (&ssids_builder)); - } - - g_dbus_proxy_call (priv->iface_proxy, - "Scan", - g_variant_new ("(a{sv})", &builder), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->other_cancellable, - (GAsyncReadyCallback) scan_request_cb, - self); - return TRUE; -} - -guint32 -nm_supplicant_interface_get_state (NMSupplicantInterface * self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NM_SUPPLICANT_INTERFACE_STATE_DOWN); - - return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->state; -} - -const char * -nm_supplicant_interface_state_to_string (guint32 state) -{ - switch (state) { - case NM_SUPPLICANT_INTERFACE_STATE_INIT: - return "init"; - case NM_SUPPLICANT_INTERFACE_STATE_STARTING: - return "starting"; - case NM_SUPPLICANT_INTERFACE_STATE_READY: - return "ready"; - case NM_SUPPLICANT_INTERFACE_STATE_DISABLED: - return "disabled"; - case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED: - return "disconnected"; - case NM_SUPPLICANT_INTERFACE_STATE_INACTIVE: - return "inactive"; - case NM_SUPPLICANT_INTERFACE_STATE_SCANNING: - return "scanning"; - case NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING: - return "authenticating"; - case NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING: - return "associating"; - case NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED: - return "associated"; - case NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE: - return "4-way handshake"; - case NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE: - return "group handshake"; - case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED: - return "completed"; - case NM_SUPPLICANT_INTERFACE_STATE_DOWN: - return "down"; - default: - break; - } - return "unknown"; -} - -const char * -nm_supplicant_interface_get_object_path (NMSupplicantInterface *self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL); - - return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->object_path; -} - -const char * -nm_supplicant_interface_get_ifname (NMSupplicantInterface *self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL); - - return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev; -} - -guint -nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), 0); - - return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->max_scan_ssids; -} - -/*******************************************************************/ - -NMSupplicantInterface * -nm_supplicant_interface_new (const char *ifname, - gboolean is_wireless, - gboolean fast_supported, - NMSupplicantFeature ap_support) -{ - g_return_val_if_fail (ifname != NULL, NULL); - - return g_object_new (NM_TYPE_SUPPLICANT_INTERFACE, - NM_SUPPLICANT_INTERFACE_IFACE, ifname, - NM_SUPPLICANT_INTERFACE_IS_WIRELESS, is_wireless, - NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, fast_supported, - NM_SUPPLICANT_INTERFACE_AP_SUPPORT, (int) ap_support, - NULL); -} - -static void -nm_supplicant_interface_init (NMSupplicantInterface * self) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); - - priv->state = NM_SUPPLICANT_INTERFACE_STATE_INIT; - priv->bss_proxies = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); -} - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_IFACE: - /* construct-only */ - priv->dev = g_value_dup_string (value); - g_return_if_fail (priv->dev); - break; - case PROP_IS_WIRELESS: - /* construct-only */ - priv->is_wireless = g_value_get_boolean (value); - break; - case PROP_FAST_SUPPORTED: - /* construct-only */ - priv->fast_supported = g_value_get_boolean (value); - break; - case PROP_AP_SUPPORT: - /* construct-only */ - priv->ap_support = g_value_get_int (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_SCANNING: - g_value_set_boolean (value, priv->scanning); - break; - case PROP_CURRENT_BSS: - g_value_set_string (value, priv->current_bss); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object); - - if (priv->iface_proxy) - g_signal_handlers_disconnect_by_data (priv->iface_proxy, NM_SUPPLICANT_INTERFACE (object)); - g_clear_object (&priv->iface_proxy); - - nm_clear_g_cancellable (&priv->init_cancellable); - nm_clear_g_cancellable (&priv->other_cancellable); - nm_clear_g_cancellable (&priv->assoc_cancellable); - - g_clear_object (&priv->wpas_proxy); - g_clear_pointer (&priv->bss_proxies, (GDestroyNotify) g_hash_table_destroy); - - g_clear_pointer (&priv->net_path, g_free); - g_clear_pointer (&priv->dev, g_free); - g_clear_pointer (&priv->object_path, g_free); - g_clear_pointer (&priv->current_bss, g_free); - - g_clear_object (&priv->cfg); - - /* Chain up to the parent class */ - G_OBJECT_CLASS (nm_supplicant_interface_parent_class)->dispose (object); -} - -static void -nm_supplicant_interface_class_init (NMSupplicantInterfaceClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof (NMSupplicantInterfacePrivate)); - - object_class->dispose = dispose; - object_class->set_property = set_property; - object_class->get_property = get_property; - - /* Properties */ - obj_properties[PROP_SCANNING] = - g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_SCANNING, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_CURRENT_BSS] = - g_param_spec_string (NM_SUPPLICANT_INTERFACE_CURRENT_BSS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IFACE] = - g_param_spec_string (NM_SUPPLICANT_INTERFACE_IFACE, "", "", - NULL, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IS_WIRELESS] = - g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_IS_WIRELESS, "", "", - TRUE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_FAST_SUPPORTED] = - g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, "", "", - TRUE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_properties[PROP_AP_SUPPORT] = - g_param_spec_int (NM_SUPPLICANT_INTERFACE_AP_SUPPORT, "", "", - NM_SUPPLICANT_FEATURE_UNKNOWN, - NM_SUPPLICANT_FEATURE_YES, - NM_SUPPLICANT_FEATURE_UNKNOWN, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - - /* Signals */ - signals[STATE] = - g_signal_new (NM_SUPPLICANT_INTERFACE_STATE, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, state), - NULL, NULL, NULL, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT); - - signals[REMOVED] = - g_signal_new (NM_SUPPLICANT_INTERFACE_REMOVED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, removed), - NULL, NULL, NULL, - G_TYPE_NONE, 0); - - signals[NEW_BSS] = - g_signal_new (NM_SUPPLICANT_INTERFACE_NEW_BSS, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, new_bss), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT); - - signals[BSS_UPDATED] = - g_signal_new (NM_SUPPLICANT_INTERFACE_BSS_UPDATED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, bss_updated), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT); - - signals[BSS_REMOVED] = - g_signal_new (NM_SUPPLICANT_INTERFACE_BSS_REMOVED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, bss_removed), - NULL, NULL, NULL, - G_TYPE_NONE, 1, G_TYPE_STRING); - - signals[SCAN_DONE] = - g_signal_new (NM_SUPPLICANT_INTERFACE_SCAN_DONE, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, scan_done), - NULL, NULL, NULL, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - - signals[CONNECTION_ERROR] = - g_signal_new (NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, connection_error), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); - - signals[CREDENTIALS_REQUEST] = - g_signal_new (NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMSupplicantInterfaceClass, credentials_request), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); -} - diff --git a/src/supplicant-manager/nm-supplicant-interface.h b/src/supplicant-manager/nm-supplicant-interface.h deleted file mode 100644 index a586e7ea..00000000 --- a/src/supplicant-manager/nm-supplicant-interface.h +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2010 Red Hat, Inc. - * Copyright (C) 2007 - 2008 Novell, Inc. - */ - -#ifndef __NETWORKMANAGER_SUPPLICANT_INTERFACE_H__ -#define __NETWORKMANAGER_SUPPLICANT_INTERFACE_H__ - -#include "nm-supplicant-types.h" - -/* - * Supplicant interface states - * A mix of wpa_supplicant interface states and internal states. - */ -enum { - NM_SUPPLICANT_INTERFACE_STATE_INIT = 0, - NM_SUPPLICANT_INTERFACE_STATE_STARTING, - NM_SUPPLICANT_INTERFACE_STATE_READY, - NM_SUPPLICANT_INTERFACE_STATE_DISABLED, - NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED, - NM_SUPPLICANT_INTERFACE_STATE_INACTIVE, - NM_SUPPLICANT_INTERFACE_STATE_SCANNING, - NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING, - NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING, - NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED, - NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE, - NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE, - NM_SUPPLICANT_INTERFACE_STATE_COMPLETED, - NM_SUPPLICANT_INTERFACE_STATE_DOWN, - NM_SUPPLICANT_INTERFACE_STATE_LAST -}; - -#define NM_TYPE_SUPPLICANT_INTERFACE (nm_supplicant_interface_get_type ()) -#define NM_SUPPLICANT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterface)) -#define NM_SUPPLICANT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterfaceClass)) -#define NM_IS_SUPPLICANT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SUPPLICANT_INTERFACE)) -#define NM_IS_SUPPLICANT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_INTERFACE)) -#define NM_SUPPLICANT_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterfaceClass)) - -/* Properties */ -#define NM_SUPPLICANT_INTERFACE_IFACE "iface" -#define NM_SUPPLICANT_INTERFACE_SCANNING "scanning" -#define NM_SUPPLICANT_INTERFACE_CURRENT_BSS "current-bss" -#define NM_SUPPLICANT_INTERFACE_IS_WIRELESS "is-wireless" -#define NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED "fast-supported" -#define NM_SUPPLICANT_INTERFACE_AP_SUPPORT "ap-support" - -/* Signals */ -#define NM_SUPPLICANT_INTERFACE_STATE "state" -#define NM_SUPPLICANT_INTERFACE_REMOVED "removed" -#define NM_SUPPLICANT_INTERFACE_NEW_BSS "new-bss" -#define NM_SUPPLICANT_INTERFACE_BSS_UPDATED "bss-updated" -#define NM_SUPPLICANT_INTERFACE_BSS_REMOVED "bss-removed" -#define NM_SUPPLICANT_INTERFACE_SCAN_DONE "scan-done" -#define NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR "connection-error" -#define NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST "credentials-request" - -struct _NMSupplicantInterface { - GObject parent; -}; - -typedef struct { - GObjectClass parent; - - /* Signals */ - - /* change in the interface's state */ - void (*state) (NMSupplicantInterface * iface, - guint32 new_state, - guint32 old_state, - int disconnect_reason); - - /* interface was removed by the supplicant */ - void (*removed) (NMSupplicantInterface * iface); - - /* interface saw a new BSS */ - void (*new_bss) (NMSupplicantInterface *iface, - const char *object_path, - GVariant *props); - - /* a BSS property changed */ - void (*bss_updated) (NMSupplicantInterface *iface, - const char *object_path, - GVariant *props); - - /* supplicant removed a BSS from its scan list */ - void (*bss_removed) (NMSupplicantInterface *iface, - const char *object_path); - - /* wireless scan is done */ - void (*scan_done) (NMSupplicantInterface *iface, - gboolean success); - - /* an error occurred during a connection request */ - void (*connection_error) (NMSupplicantInterface * iface, - const char * name, - const char * message); - - /* 802.1x credentials requested */ - void (*credentials_request) (NMSupplicantInterface *iface, - const char *field, - const char *message); -} NMSupplicantInterfaceClass; - -GType nm_supplicant_interface_get_type (void); - -NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname, - gboolean is_wireless, - gboolean fast_supported, - NMSupplicantFeature ap_support); - -void nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self, - gboolean available); - -gboolean nm_supplicant_interface_set_config (NMSupplicantInterface * iface, - NMSupplicantConfig * cfg, - GError **error); - -void nm_supplicant_interface_disconnect (NMSupplicantInterface * iface); - -const char *nm_supplicant_interface_get_object_path (NMSupplicantInterface * iface); - -gboolean nm_supplicant_interface_request_scan (NMSupplicantInterface * self, const GPtrArray *ssids); - -guint32 nm_supplicant_interface_get_state (NMSupplicantInterface * self); - -const char *nm_supplicant_interface_state_to_string (guint32 state); - -gboolean nm_supplicant_interface_get_scanning (NMSupplicantInterface *self); - -const char *nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self); - -gint32 nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self); - -const char *nm_supplicant_interface_get_ifname (NMSupplicantInterface *self); - -guint nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self); - -gboolean nm_supplicant_interface_get_has_credentials_request (NMSupplicantInterface *self); - -gboolean nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self, - const char *field, - const char *value, - GError **error); - -NMSupplicantFeature nm_supplicant_interface_get_ap_support (NMSupplicantInterface *self); - -void nm_supplicant_interface_set_ap_support (NMSupplicantInterface *self, - NMSupplicantFeature apmode); - -#endif /* NM_SUPPLICANT_INTERFACE_H */ diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c deleted file mode 100644 index 57cd5713..00000000 --- a/src/supplicant-manager/nm-supplicant-manager.c +++ /dev/null @@ -1,410 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2010 Red Hat, Inc. - * Copyright (C) 2007 - 2008 Novell, Inc. - */ - -#include "nm-default.h" - -#include - -#include "nm-supplicant-manager.h" -#include "nm-supplicant-interface.h" -#include "nm-supplicant-types.h" -#include "nm-core-internal.h" - -#define NM_SUPPLICANT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_SUPPLICANT_MANAGER, \ - NMSupplicantManagerPrivate)) - -G_DEFINE_TYPE (NMSupplicantManager, nm_supplicant_manager, G_TYPE_OBJECT) - -#define _NMLOG_DOMAIN LOGD_SUPPLICANT -#define _NMLOG_PREFIX_NAME "supplicant" -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), _NMLOG_DOMAIN, \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - _NMLOG_PREFIX_NAME": " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - -typedef struct { - GDBusProxy * proxy; - GCancellable * cancellable; - gboolean running; - - GSList *ifaces; - gboolean fast_supported; - NMSupplicantFeature ap_support; - guint die_count_reset_id; - guint die_count; -} NMSupplicantManagerPrivate; - -/********************************************************************/ - -G_DEFINE_QUARK (nm-supplicant-error-quark, nm_supplicant_error); - -/********************************************************************/ - -static inline gboolean -die_count_exceeded (guint32 count) -{ - return count > 2; -} - -static gboolean -is_available (NMSupplicantManager *self) -{ - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - - return priv->running - && !die_count_exceeded (priv->die_count); -} - -/********************************************************************/ - -static void -_sup_iface_last_ref (gpointer data, - GObject *object, - gboolean is_last_ref) -{ - NMSupplicantManager *self = data; - NMSupplicantManagerPrivate *priv; - NMSupplicantInterface *sup_iface = (NMSupplicantInterface *) object; - const char *op; - - g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self)); - g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (sup_iface)); - g_return_if_fail (is_last_ref); - - priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - - if (!g_slist_find (priv->ifaces, sup_iface)) - g_return_if_reached (); - - /* Ask wpa_supplicant to remove this interface */ - if ( priv->running - && priv->proxy - && (op = nm_supplicant_interface_get_object_path (sup_iface))) { - g_dbus_proxy_call (priv->proxy, - "RemoveInterface", - g_variant_new ("(o)", op), - G_DBUS_CALL_FLAGS_NONE, - 3000, - NULL, - NULL, - NULL); - } - - priv->ifaces = g_slist_remove (priv->ifaces, sup_iface); - g_object_remove_toggle_ref ((GObject *) sup_iface, _sup_iface_last_ref, self); -} - -/** - * nm_supplicant_manager_create_interface: - * @self: the #NMSupplicantManager - * @ifname: the interface for which to obtain the supplicant interface - * @is_wireless: whether the interface is supposed to be wireless. - * - * Note: the manager owns a reference to the instance and the only way to - * get the manager to release it, is by dropping all other references - * to the supplicant-interface (or destroying the manager). - * - * Returns: (transfer full): returns a #NMSupplicantInterface or %NULL. - * Must be unrefed at the end. - * */ -NMSupplicantInterface * -nm_supplicant_manager_create_interface (NMSupplicantManager *self, - const char *ifname, - gboolean is_wireless) -{ - NMSupplicantManagerPrivate *priv; - NMSupplicantInterface *iface; - GSList *ifaces; - - g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL); - g_return_val_if_fail (ifname != NULL, NULL); - - priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - - _LOGD ("(%s): creating new supplicant interface", ifname); - - /* assert against not requesting duplicate interfaces. */ - for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) { - if (g_strcmp0 (nm_supplicant_interface_get_ifname (ifaces->data), ifname) == 0) - g_return_val_if_reached (NULL); - } - - iface = nm_supplicant_interface_new (ifname, - is_wireless, - priv->fast_supported, - priv->ap_support); - - priv->ifaces = g_slist_prepend (priv->ifaces, iface); - g_object_add_toggle_ref ((GObject *) iface, _sup_iface_last_ref, self); - - /* If we're making the supplicant take a time out for a bit, don't - * let the supplicant interface start immediately, just let it hang - * around in INIT state until we're ready to talk to the supplicant - * again. - */ - if (is_available (self)) - nm_supplicant_interface_set_supplicant_available (iface, TRUE); - - return iface; -} - -static void -update_capabilities (NMSupplicantManager *self) -{ - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - GSList *ifaces; - const char **array; - GVariant *value; - - /* The supplicant only advertises global capabilities if the following - * commit has been applied: - * - * commit 1634ac0654eba8d458640a115efc0a6cde3bac4d - * Author: Dan Williams - * Date: Sat Sep 29 19:06:30 2012 +0300 - * - * dbus: Add global capabilities property - */ - priv->ap_support = NM_SUPPLICANT_FEATURE_UNKNOWN; - - value = g_dbus_proxy_get_cached_property (priv->proxy, "Capabilities"); - if (value) { - if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) { - array = g_variant_get_strv (value, NULL); - priv->ap_support = NM_SUPPLICANT_FEATURE_NO; - if (array) { - if (g_strv_contains (array, "ap")) - priv->ap_support = NM_SUPPLICANT_FEATURE_YES; - g_free (array); - } - } - g_variant_unref (value); - } - - /* Tell all interfaces about results of the AP check */ - for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) - nm_supplicant_interface_set_ap_support (ifaces->data, priv->ap_support); - - _LOGD ("AP mode is %ssupported", - (priv->ap_support == NM_SUPPLICANT_FEATURE_YES) ? "" : - (priv->ap_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly "); - - /* EAP-FAST */ - priv->fast_supported = FALSE; - value = g_dbus_proxy_get_cached_property (priv->proxy, "EapMethods"); - if (value) { - if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) { - array = g_variant_get_strv (value, NULL); - if (array) { - if (g_strv_contains (array, "fast")) - priv->fast_supported = TRUE; - g_free (array); - } - } - g_variant_unref (value); - } - - _LOGD ("EAP-FAST is %ssupported", priv->fast_supported ? "" : "not "); -} - -static void -availability_changed (NMSupplicantManager *self, gboolean available) -{ - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - GSList *ifaces, *iter; - - if (!priv->ifaces) - return; - - /* setting the supplicant as unavailable might cause the caller to unref - * the supplicant (and thus remove the instance from the list of interfaces. - * Delay that by taking an additional reference first. */ - ifaces = g_slist_copy (priv->ifaces); - for (iter = ifaces; iter; iter = iter->next) - g_object_ref (iter->data); - for (iter = ifaces; iter; iter = iter->next) - nm_supplicant_interface_set_supplicant_available (iter->data, available); - g_slist_free_full (ifaces, g_object_unref); -} - -static void -set_running (NMSupplicantManager *self, gboolean now_running) -{ - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - gboolean old_available = is_available (self); - gboolean new_available; - - priv->running = now_running; - new_available = is_available (self); - if (old_available != new_available) - availability_changed (self, new_available); -} - -static void -set_die_count (NMSupplicantManager *self, guint new_die_count) -{ - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - gboolean old_available = is_available (self); - gboolean new_available; - - priv->die_count = new_die_count; - new_available = is_available (self); - if (old_available != new_available) - availability_changed (self, new_available); -} - -static gboolean -wpas_die_count_reset_cb (gpointer user_data) -{ - NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data); - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - - /* Reset the die count back to zero, which allows use of the supplicant again */ - priv->die_count_reset_id = 0; - set_die_count (self, 0); - _LOGI ("wpa_supplicant die count reset"); - return FALSE; -} - -static void -name_owner_cb (GDBusProxy *proxy, GParamSpec *pspec, gpointer user_data) -{ - NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data); - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - char *owner; - - g_return_if_fail (proxy == priv->proxy); - - owner = g_dbus_proxy_get_name_owner (proxy); - _LOGI ("wpa_supplicant %s", owner ? "running" : "stopped"); - - if (owner) { - set_running (self, TRUE); - update_capabilities (self); - } else if (priv->running) { - /* Reschedule the die count reset timeout. Every time the supplicant - * dies we wait 10 seconds before resetting the counter. If the - * supplicant died more than twice before the timer is reset, then - * we don't try to talk to the supplicant for a while. - */ - if (priv->die_count_reset_id) - g_source_remove (priv->die_count_reset_id); - priv->die_count_reset_id = g_timeout_add_seconds (10, wpas_die_count_reset_cb, self); - set_die_count (self, priv->die_count + 1); - - if (die_count_exceeded (priv->die_count)) { - _LOGI ("wpa_supplicant die count %d; ignoring for 10 seconds", - priv->die_count); - } - - set_running (self, FALSE); - - priv->fast_supported = FALSE; - } - - g_free (owner); -} - -static void -on_proxy_acquired (GObject *object, GAsyncResult *result, gpointer user_data) -{ - NMSupplicantManager *self; - NMSupplicantManagerPrivate *priv; - GError *error = NULL; - GDBusProxy *proxy; - - proxy = g_dbus_proxy_new_for_bus_finish (result, &error); - if (!proxy) { - _LOGW ("failed to acquire wpa_supplicant proxy: Wi-Fi and 802.1x will not be available (%s)", - error->message); - g_clear_error (&error); - return; - } - - self = NM_SUPPLICANT_MANAGER (user_data); - priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - - priv->proxy = proxy; - g_signal_connect (priv->proxy, "notify::g-name-owner", G_CALLBACK (name_owner_cb), self); - name_owner_cb (priv->proxy, NULL, self); -} - -/*******************************************************************/ - -NM_DEFINE_SINGLETON_GETTER (NMSupplicantManager, nm_supplicant_manager_get, NM_TYPE_SUPPLICANT_MANAGER); - -static void -nm_supplicant_manager_init (NMSupplicantManager *self) -{ - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - - priv->cancellable = g_cancellable_new (); - g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - WPAS_DBUS_SERVICE, - WPAS_DBUS_PATH, - WPAS_DBUS_INTERFACE, - priv->cancellable, - (GAsyncReadyCallback) on_proxy_acquired, - self); -} - -static void -dispose (GObject *object) -{ - NMSupplicantManager *self = (NMSupplicantManager *) object; - NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); - GSList *ifaces; - - nm_clear_g_source (&priv->die_count_reset_id); - - if (priv->cancellable) { - g_cancellable_cancel (priv->cancellable); - g_clear_object (&priv->cancellable); - } - - if (priv->ifaces) { - for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) - g_object_remove_toggle_ref (ifaces->data, _sup_iface_last_ref, self); - g_slist_free (priv->ifaces); - priv->ifaces = NULL; - } - - g_clear_object (&priv->proxy); - - G_OBJECT_CLASS (nm_supplicant_manager_parent_class)->dispose (object); -} - -static void -nm_supplicant_manager_class_init (NMSupplicantManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof (NMSupplicantManagerPrivate)); - - object_class->dispose = dispose; -} - diff --git a/src/supplicant-manager/nm-supplicant-manager.h b/src/supplicant-manager/nm-supplicant-manager.h deleted file mode 100644 index 4cd7a0bd..00000000 --- a/src/supplicant-manager/nm-supplicant-manager.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2008 Red Hat, Inc. - * Copyright (C) 2007 - 2008 Novell, Inc. - */ - -#ifndef __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ -#define __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ - -#include "nm-supplicant-types.h" -#include "nm-device.h" - -#define NM_TYPE_SUPPLICANT_MANAGER (nm_supplicant_manager_get_type ()) -#define NM_SUPPLICANT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManager)) -#define NM_SUPPLICANT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManagerClass)) -#define NM_IS_SUPPLICANT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SUPPLICANT_MANAGER)) -#define NM_IS_SUPPLICANT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_MANAGER)) -#define NM_SUPPLICANT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManagerClass)) - -struct _NMSupplicantManager -{ - GObject parent; -}; - -typedef struct -{ - GObjectClass parent; -} NMSupplicantManagerClass; - -GType nm_supplicant_manager_get_type (void); - -NMSupplicantManager *nm_supplicant_manager_get (void); - -NMSupplicantInterface *nm_supplicant_manager_create_interface (NMSupplicantManager *mgr, - const char *ifname, - gboolean is_wireless); - -#endif /* __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ */ diff --git a/src/supplicant-manager/nm-supplicant-settings-verify.c b/src/supplicant-manager/nm-supplicant-settings-verify.c deleted file mode 100644 index bb046f93..00000000 --- a/src/supplicant-manager/nm-supplicant-settings-verify.c +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2012 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include - -#include "nm-supplicant-settings-verify.h" - -struct Opt { - const char * key; - const OptType type; - const gint32 int_low; /* Inclusive */ - const gint32 int_high; /* Inclusive; max length for strings */ - const gboolean str_allowed_multiple; - const char ** str_allowed; -}; - - -static gboolean validate_type_int (const struct Opt * opt, - const char * value, - const guint32 len); - -static gboolean validate_type_bytes (const struct Opt * opt, - const char * value, - const guint32 len); - -static gboolean validate_type_utf8 (const struct Opt *opt, - const char * value, - const guint32 len); - -static gboolean validate_type_keyword (const struct Opt * opt, - const char * value, - const guint32 len); - -typedef gboolean (*validate_func)(const struct Opt *, const char *, const guint32); - -struct validate_entry { - const OptType type; - const validate_func func; -}; - -static const struct validate_entry validate_table[] = { - { TYPE_INT, validate_type_int }, - { TYPE_BYTES, validate_type_bytes }, - { TYPE_UTF8, validate_type_utf8 }, - { TYPE_KEYWORD, validate_type_keyword }, -}; - - -const char * pairwise_allowed[] = { "CCMP", "TKIP", "NONE", NULL }; -const char * group_allowed[] = { "CCMP", "TKIP", "WEP104", "WEP40", NULL }; -const char * proto_allowed[] = { "WPA", "RSN", NULL }; -const char * key_mgmt_allowed[] = { "WPA-PSK", "WPA-EAP", "IEEE8021X", "WPA-NONE", - "NONE", NULL }; -const char * auth_alg_allowed[] = { "OPEN", "SHARED", "LEAP", NULL }; -const char * eap_allowed[] = { "LEAP", "MD5", "TLS", "PEAP", "TTLS", "SIM", - "PSK", "FAST", "PWD", NULL }; - -const char * phase1_allowed[] = {"peapver=0", "peapver=1", "peaplabel=1", - "peap_outer_success=0", "include_tls_length=1", - "sim_min_num_chal=3", "fast_provisioning=0", - "fast_provisioning=1", "fast_provisioning=2", - "fast_provisioning=3", NULL }; -const char * phase2_allowed[] = {"auth=PAP", "auth=CHAP", "auth=MSCHAP", - "auth=MSCHAPV2", "auth=GTC", "auth=OTP", - "auth=MD5", "auth=TLS", "autheap=MD5", - "autheap=MSCHAPV2", "autheap=OTP", - "autheap=GTC", "autheap=TLS", NULL }; - -static const struct Opt opt_table[] = { - { "ssid", TYPE_BYTES, 0, 32,FALSE, NULL }, - { "bssid", TYPE_KEYWORD, 0, 0, FALSE, NULL }, - { "scan_ssid", TYPE_INT, 0, 1, FALSE, NULL }, - { "mode", TYPE_INT, 0, 2, FALSE, NULL }, - { "frequency", TYPE_INT, 2412, 5825, FALSE, NULL }, - { "auth_alg", TYPE_KEYWORD, 0, 0, FALSE, auth_alg_allowed }, - { "psk", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "pairwise", TYPE_KEYWORD, 0, 0, FALSE, pairwise_allowed }, - { "group", TYPE_KEYWORD, 0, 0, FALSE, group_allowed }, - { "proto", TYPE_KEYWORD, 0, 0, FALSE, proto_allowed }, - { "key_mgmt", TYPE_KEYWORD, 0, 0, FALSE, key_mgmt_allowed }, - { "wep_key0", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "wep_key1", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "wep_key2", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "wep_key3", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "wep_tx_keyidx", TYPE_INT, 0, 3, FALSE, NULL }, - { "eapol_flags", TYPE_INT, 0, 3, FALSE, NULL }, - { "eap", TYPE_KEYWORD, 0, 0, FALSE, eap_allowed }, - { "identity", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "password", TYPE_UTF8, 0, 0, FALSE, NULL }, - { "ca_path", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "subject_match", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "altsubject_match", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "domain_suffix_match",TYPE_BYTES, 0, 0, FALSE, NULL }, - { "ca_cert", TYPE_BYTES, 0, 65536, FALSE, NULL }, - { "client_cert", TYPE_BYTES, 0, 65536, FALSE, NULL }, - { "private_key", TYPE_BYTES, 0, 65536, FALSE, NULL }, - { "private_key_passwd", TYPE_BYTES, 0, 1024, FALSE, NULL }, - { "phase1", TYPE_KEYWORD, 0, 0, TRUE, phase1_allowed }, - { "phase2", TYPE_KEYWORD, 0, 0, TRUE, phase2_allowed }, - { "anonymous_identity", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "ca_path2", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "subject_match2", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "altsubject_match2", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "domain_suffix_match2", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "ca_cert2", TYPE_BYTES, 0, 65536, FALSE, NULL }, - { "client_cert2", TYPE_BYTES, 0, 65536, FALSE, NULL }, - { "private_key2", TYPE_BYTES, 0, 65536, FALSE, NULL }, - { "private_key2_passwd",TYPE_BYTES, 0, 1024, FALSE, NULL }, - { "pin", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "pcsc", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "nai", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "eappsk", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "pac_file", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "engine", TYPE_INT, 0, 1, FALSE, NULL }, - { "engine_id", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "key_id", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "fragment_size", TYPE_INT, 1, 2000, FALSE, NULL }, - { "proactive_key_caching", TYPE_INT, 0, 1, FALSE, NULL }, - { "bgscan", TYPE_BYTES, 0, 0, FALSE, NULL }, - { "pac_file", TYPE_BYTES, 0, 1024, FALSE, NULL }, - { "freq_list", TYPE_KEYWORD, 0, 0, FALSE, NULL }, -}; - - -static gboolean -validate_type_int (const struct Opt * opt, - const char * value, - const guint32 len) -{ - long int intval; - - g_return_val_if_fail (opt != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - errno = 0; - intval = strtol (value, NULL, 10); - if (errno != 0) - return FALSE; - - /* strtol returns a long, but we are dealing with ints */ - if (intval > INT_MAX || intval < INT_MIN) - return FALSE; - if (intval > opt->int_high || intval < opt->int_low) - return FALSE; - - return TRUE; -} - -static gboolean -validate_type_bytes (const struct Opt * opt, - const char * value, - const guint32 len) -{ - guint32 check_len; - - g_return_val_if_fail (opt != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - check_len = opt->int_high ? opt->int_high : 255; - if (len > check_len) - return FALSE; - - return TRUE; -} - -static gboolean -validate_type_utf8 (const struct Opt *opt, - const char * value, - const guint32 len) -{ - guint32 check_len; - - g_return_val_if_fail (opt != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - check_len = opt->int_high ? opt->int_high : 255; - /* Note that we deliberately don't validate the UTF-8, because - some "UTF-8" fields, such as 8021x.password, do not actually - have to be valid UTF-8 */ - if (g_utf8_strlen (value, len) > check_len) - return FALSE; - - return TRUE; -} - -static gboolean -validate_type_keyword (const struct Opt * opt, - const char * value, - const guint32 len) -{ - char ** allowed; - gchar ** candidates = NULL; - char ** candidate; - gboolean found = FALSE; - - g_return_val_if_fail (opt != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - /* Allow everything */ - if (!opt->str_allowed) - return TRUE; - - candidates = g_strsplit (value, " ", 0); - if (!candidates) - goto out; - - /* validate each space-separated word in 'value' */ - for (candidate = candidates; *candidate; candidate++) { - found = FALSE; - for (allowed = (char **) opt->str_allowed; *allowed; allowed++) { - if (strcmp (*candidate, *allowed) == 0) { - found = TRUE; - break; - } - } - if (!found) - break; - } - -out: - g_strfreev (candidates); - return found; -} - -OptType -nm_supplicant_settings_verify_setting (const char * key, - const char * value, - const guint32 len) -{ - OptType type = TYPE_INVALID; - int opt_count = sizeof (opt_table) / sizeof (opt_table[0]); - int val_count = sizeof (validate_table) / sizeof (validate_table[0]); - int i, j; - - g_return_val_if_fail (key != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - for (i = 0; i < opt_count; i++) { - if (strcmp (opt_table[i].key, key) != 0) - continue; - - for (j = 0; j < val_count; j++) { - if (validate_table[j].type == opt_table[i].type) { - if ((*(validate_table[j].func))(&opt_table[i], value, len)) { - type = opt_table[i].type; - break; - } - } - } - } - - return type; -} - diff --git a/src/supplicant-manager/nm-supplicant-settings-verify.h b/src/supplicant-manager/nm-supplicant-settings-verify.h deleted file mode 100644 index 920343ba..00000000 --- a/src/supplicant-manager/nm-supplicant-settings-verify.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2008 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_SUPPLICANT_SETTINGS_VERIFY_H__ -#define __NETWORKMANAGER_SUPPLICANT_SETTINGS_VERIFY_H__ - -typedef enum { - TYPE_INVALID = 0, - TYPE_INT, - TYPE_BYTES, - TYPE_UTF8, - TYPE_KEYWORD, - TYPE_STRING -} OptType; - -OptType nm_supplicant_settings_verify_setting (const char * key, - const char * value, - const guint32 len); - - -#endif /* __NETWORKMANAGER_SUPPLICANT_SETTINGS_VERIFY_H__ */ diff --git a/src/supplicant-manager/nm-supplicant-types.h b/src/supplicant-manager/nm-supplicant-types.h deleted file mode 100644 index e9be5be4..00000000 --- a/src/supplicant-manager/nm-supplicant-types.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2006 - 2008 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_SUPPLICANT_TYPES_H__ -#define __NETWORKMANAGER_SUPPLICANT_TYPES_H__ - -#define WPAS_DBUS_SERVICE "fi.w1.wpa_supplicant1" -#define WPAS_DBUS_PATH "/fi/w1/wpa_supplicant1" -#define WPAS_DBUS_INTERFACE "fi.w1.wpa_supplicant1" - -typedef struct _NMSupplicantManager NMSupplicantManager; -typedef struct _NMSupplicantInterface NMSupplicantInterface; -typedef struct _NMSupplicantConfig NMSupplicantConfig; - -typedef enum { - NM_SUPPLICANT_FEATURE_UNKNOWN = 0, /* Can't detect whether supported or not */ - NM_SUPPLICANT_FEATURE_NO = 1, /* Feature definitely not supported */ - NM_SUPPLICANT_FEATURE_YES = 2, /* Feature definitely supported */ -} NMSupplicantFeature; - -/** - * NMSupplicantError: - * @NM_SUPPLICANT_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SUPPLICANT_ERROR_CONFIG: a failure constructing the - * wpa-supplicant configuration. - */ -typedef enum { - NM_SUPPLICANT_ERROR_UNKNOWN = 0, /*< nick=Unknown >*/ - NM_SUPPLICANT_ERROR_CONFIG = 1, /*< nick=Config >*/ -} NMSupplicantError; - -#define NM_SUPPLICANT_ERROR (nm_supplicant_error_quark ()) -GQuark nm_supplicant_error_quark (void); - -#endif /* NM_SUPPLICANT_TYPES_H */ diff --git a/src/supplicant-manager/tests/Makefile.am b/src/supplicant-manager/tests/Makefile.am deleted file mode 100644 index 3ab9122e..00000000 --- a/src/supplicant-manager/tests/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -SUBDIRS=certs - -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/supplicant-manager \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - -DTEST_CERT_DIR=\"$(abs_srcdir)/certs\" \ - $(GLIB_CFLAGS) - -noinst_PROGRAMS = test-supplicant-config - -test_supplicant_config_SOURCES = \ - test-supplicant-config.c - -test_supplicant_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-supplicant-config diff --git a/src/supplicant-manager/tests/Makefile.in b/src/supplicant-manager/tests/Makefile.in deleted file mode 100644 index eb6b03ea..00000000 --- a/src/supplicant-manager/tests/Makefile.in +++ /dev/null @@ -1,1256 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-supplicant-config$(EXEEXT) -TESTS = test-supplicant-config$(EXEEXT) -subdir = src/supplicant-manager/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_supplicant_config_OBJECTS = test-supplicant-config.$(OBJEXT) -test_supplicant_config_OBJECTS = $(am_test_supplicant_config_OBJECTS) -test_supplicant_config_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_supplicant_config_SOURCES) -DIST_SOURCES = $(test_supplicant_config_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - check recheck distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = certs -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/supplicant-manager \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - -DTEST_CERT_DIR=\"$(abs_srcdir)/certs\" \ - $(GLIB_CFLAGS) - -test_supplicant_config_SOURCES = \ - test-supplicant-config.c - -test_supplicant_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/supplicant-manager/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/supplicant-manager/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-supplicant-config$(EXEEXT): $(test_supplicant_config_OBJECTS) $(test_supplicant_config_DEPENDENCIES) $(EXTRA_test_supplicant_config_DEPENDENCIES) - @rm -f test-supplicant-config$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_supplicant_config_OBJECTS) $(test_supplicant_config_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-supplicant-config.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-supplicant-config.log: test-supplicant-config$(EXEEXT) - @p='test-supplicant-config$(EXEEXT)'; \ - b='test-supplicant-config'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-recursive -all-am: Makefile $(PROGRAMS) -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) check-am install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-TESTS check-am clean clean-generic clean-libtool \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \ - uninstall uninstall-am - -.PRECIOUS: Makefile - - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/supplicant-manager/tests/certs/Makefile.am b/src/supplicant-manager/tests/certs/Makefile.am deleted file mode 100644 index f2e889f7..00000000 --- a/src/supplicant-manager/tests/certs/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -CERTS = \ - test-ca-cert.pem \ - test-cert.p12 - -EXTRA_DIST = $(CERTS) - diff --git a/src/supplicant-manager/tests/certs/Makefile.in b/src/supplicant-manager/tests/certs/Makefile.in deleted file mode 100644 index 3d348a38..00000000 --- a/src/supplicant-manager/tests/certs/Makefile.in +++ /dev/null @@ -1,605 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/supplicant-manager/tests/certs -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -CERTS = \ - test-ca-cert.pem \ - test-cert.p12 - -EXTRA_DIST = $(CERTS) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/supplicant-manager/tests/certs/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/supplicant-manager/tests/certs/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/supplicant-manager/tests/certs/test-ca-cert.pem b/src/supplicant-manager/tests/certs/test-ca-cert.pem deleted file mode 100644 index ef1be20d..00000000 --- a/src/supplicant-manager/tests/certs/test-ca-cert.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEjzCCA3egAwIBAgIJAOvnZPt59yIZMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYD -VQQGEwJVUzESMBAGA1UECBMJQmVya3NoaXJlMRAwDgYDVQQHEwdOZXdidXJ5MRcw -FQYDVQQKEw5NeSBDb21wYW55IEx0ZDEQMA4GA1UECxMHVGVzdGluZzENMAsGA1UE -AxMEdGVzdDEcMBoGCSqGSIb3DQEJARYNdGVzdEB0ZXN0LmNvbTAeFw0wOTAzMTAx -NTEyMTRaFw0xOTAzMDgxNTEyMTRaMIGLMQswCQYDVQQGEwJVUzESMBAGA1UECBMJ -QmVya3NoaXJlMRAwDgYDVQQHEwdOZXdidXJ5MRcwFQYDVQQKEw5NeSBDb21wYW55 -IEx0ZDEQMA4GA1UECxMHVGVzdGluZzENMAsGA1UEAxMEdGVzdDEcMBoGCSqGSIb3 -DQEJARYNdGVzdEB0ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC -ggEBAKot9j+/+CX1/gZLgJHIXCRgCItKLGnf7qGbgqB9T2ACBqR0jllKWwDKrcWU -xjXNIc+GF9Wnv+lX6G0Okn4Zt3/uRNobL+2b/yOF7M3Td3/9W873zdkQQX930YZc -Rr8uxdRPP5bxiCgtcw632y21sSEbG9mjccAUnV/0jdvfmMNj0i8gN6E0fMBiJ9S3 -FkxX/KFvt9JWE9CtoyL7ki7UIDq+6vj7Gd5N0B3dOa1y+rRHZzKlJPcSXQSEYUS4 -HmKDwiKSVahft8c4tDn7KPi0vex91hlgZVd3usL2E/Vq7o5D9FAZ5kZY0AdFXwdm -J4lO4Mj7ac7GE4vNERNcXVIX59sCAwEAAaOB8zCB8DAdBgNVHQ4EFgQUuDU3Mr7P -T3n1e3Sy8hBauoDFahAwgcAGA1UdIwSBuDCBtYAUuDU3Mr7PT3n1e3Sy8hBauoDF -ahChgZGkgY4wgYsxCzAJBgNVBAYTAlVTMRIwEAYDVQQIEwlCZXJrc2hpcmUxEDAO -BgNVBAcTB05ld2J1cnkxFzAVBgNVBAoTDk15IENvbXBhbnkgTHRkMRAwDgYDVQQL -EwdUZXN0aW5nMQ0wCwYDVQQDEwR0ZXN0MRwwGgYJKoZIhvcNAQkBFg10ZXN0QHRl -c3QuY29tggkA6+dk+3n3IhkwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOC -AQEAVRG4aALIvCXCiKfe7K+iJxjBVRDFPEf7JWA9LGgbFOn6pNvbxonrR+0BETdc -JV1ET4ct2xsE7QNFIkp9GKRC+6J32zCo8qtLCD5+v436r8TUG2/t2JRMkb9I2XVT -p7RJoot6M0Ltf8KNQUPYh756xmKZ4USfQUwc58MOSDGY8VWEXJOYij9Pf0e0c52t -qiCEjXH7uXiS8Pgq9TYm7AkWSOrglYhSa83x0f8mtT8Q15nBESIHZ6o8FAS2bBgn -B0BkrKRjtBUkuJG3vTox+bYINh2Gxi1JZHWSV1tN5z3hd4VFcKqanW5OgQwToBqp -3nniskIjbH0xjgZf/nVMyLnjxg== ------END CERTIFICATE----- diff --git a/src/supplicant-manager/tests/certs/test-cert.p12 b/src/supplicant-manager/tests/certs/test-cert.p12 deleted file mode 100644 index ae4a6830..00000000 Binary files a/src/supplicant-manager/tests/certs/test-cert.p12 and /dev/null differ diff --git a/src/supplicant-manager/tests/test-supplicant-config.c b/src/supplicant-manager/tests/test-supplicant-config.c deleted file mode 100644 index e8f84448..00000000 --- a/src/supplicant-manager/tests/test-supplicant-config.c +++ /dev/null @@ -1,614 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-core-internal.h" - -#include "nm-supplicant-config.h" -#include "nm-supplicant-settings-verify.h" - -#include "nm-test-utils-core.h" - -static gboolean -validate_opt (const char *detail, - GVariant *config, - const char *key, - OptType val_type, - gconstpointer expected, - size_t expected_len) -{ - char *config_key; - GVariant *config_value; - gboolean found = FALSE; - const guint8 *bytes; - gsize len; - const char *s; - const unsigned char *expected_array = expected; - GVariantIter iter; - - g_assert (g_variant_is_of_type (config, G_VARIANT_TYPE_VARDICT)); - - g_variant_iter_init (&iter, config); - while (g_variant_iter_next (&iter, "{&sv}", (gpointer) &config_key, (gpointer) &config_value)) { - if (!strcmp (key, config_key)) { - found = TRUE; - switch (val_type) { - case TYPE_INT: - g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_INT32)); - g_assert_cmpint (g_variant_get_int32 (config_value), ==, GPOINTER_TO_INT (expected)); - break; - case TYPE_BYTES: - g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_BYTESTRING)); - bytes = g_variant_get_fixed_array (config_value, &len, 1); - g_assert_cmpint (len, ==, expected_len); - g_assert (memcmp (bytes, expected_array, expected_len) == 0); - break; - case TYPE_KEYWORD: - case TYPE_STRING: - g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_STRING)); - if (expected_len == -1) - expected_len = strlen ((const char *) expected); - s = g_variant_get_string (config_value, NULL); - g_assert_cmpint (strlen (s), ==, expected_len); - g_assert_cmpstr (s, ==, expected); - break; - default: - g_assert_not_reached (); - break; - } - } - g_variant_unref (config_value); - } - - return found; -} - -static void -test_wifi_open (void) -{ - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMSupplicantConfig *config = NULL; - gs_unref_variant GVariant *config_dict = NULL; - NMSettingConnection *s_con; - NMSettingWireless *s_wifi; - NMSettingIPConfig *s_ip4; - char *uuid; - gboolean success; - GError *error = NULL; - GBytes *ssid; - const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; - const char *bssid_str = "11:22:33:44:55:66"; - - connection = nm_simple_connection_new (); - - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new (); - nm_connection_add_setting (connection, NM_SETTING (s_con)); - - uuid = nm_utils_uuid_generate (); - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, "Test Wifi Open", - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, - NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, - NULL); - g_free (uuid); - - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - - ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); - - g_object_set (s_wifi, - NM_SETTING_WIRELESS_SSID, ssid, - NM_SETTING_WIRELESS_BSSID, bssid_str, - NM_SETTING_WIRELESS_MODE, "infrastructure", - NM_SETTING_WIRELESS_BAND, "bg", - NULL); - - g_bytes_unref (ssid); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - - success = nm_connection_verify (connection, &error); - g_assert_no_error (error); - g_assert (success); - - config = nm_supplicant_config_new (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'ssid' value 'Test SSID'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'scan_ssid' value '1'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'bssid' value '11:22:33:44:55:66'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'freq_list' value *"); - g_assert (nm_supplicant_config_add_setting_wireless (config, - s_wifi, - 0, - &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'key_mgmt' value 'NONE'"); - g_assert (nm_supplicant_config_add_no_security (config, &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - config_dict = nm_supplicant_config_to_variant (config); - g_assert (config_dict); - - validate_opt ("wifi-open", config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); - validate_opt ("wifi-open", config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); - validate_opt ("wifi-open", config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); - validate_opt ("wifi-open", config_dict, "key_mgmt", TYPE_KEYWORD, "NONE", -1); -} - -static void -test_wifi_wep_key (const char *detail, - NMWepKeyType wep_type, - const char *key_data, - const unsigned char *expected, - size_t expected_size) -{ - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMSupplicantConfig *config = NULL; - gs_unref_variant GVariant *config_dict = NULL; - NMSettingConnection *s_con; - NMSettingWireless *s_wifi; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig *s_ip4; - char *uuid; - gboolean success; - GError *error = NULL; - GBytes *ssid; - const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; - const char *bssid_str = "11:22:33:44:55:66"; - - connection = nm_simple_connection_new (); - - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new (); - nm_connection_add_setting (connection, NM_SETTING (s_con)); - - uuid = nm_utils_uuid_generate (); - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, "Test Wifi WEP Key", - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, - NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, - NULL); - g_free (uuid); - - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - - ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); - - g_object_set (s_wifi, - NM_SETTING_WIRELESS_SSID, ssid, - NM_SETTING_WIRELESS_BSSID, bssid_str, - NM_SETTING_WIRELESS_MODE, "infrastructure", - NM_SETTING_WIRELESS_BAND, "bg", - NULL); - - g_bytes_unref (ssid); - - /* Wifi Security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wsec)); - - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", - NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, wep_type, - NULL); - nm_setting_wireless_security_set_wep_key (s_wsec, 0, key_data); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - - success = nm_connection_verify (connection, &error); - g_assert_no_error (error); - g_assert (success); - - config = nm_supplicant_config_new (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'ssid' value 'Test SSID'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'scan_ssid' value '1'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'bssid' value '11:22:33:44:55:66'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'freq_list' value *"); - g_assert (nm_supplicant_config_add_setting_wireless (config, - s_wifi, - 0, - &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'key_mgmt' value 'NONE'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'wep_key0' value *"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'wep_tx_keyidx' value '0'"); - g_assert (nm_supplicant_config_add_setting_wireless_security (config, - s_wsec, - NULL, - "376aced7-b28c-46be-9a62-fcdf072571da", - 1500, - &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - config_dict = nm_supplicant_config_to_variant (config); - g_assert (config_dict); - - validate_opt (detail, config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); - validate_opt (detail, config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); - validate_opt (detail, config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); - validate_opt (detail, config_dict, "key_mgmt", TYPE_KEYWORD, "NONE", -1); - validate_opt (detail, config_dict, "wep_tx_keyidx", TYPE_INT, GINT_TO_POINTER (0), -1); - validate_opt (detail, config_dict, "wep_key0", TYPE_BYTES, expected, expected_size); -} - -static void -test_wifi_wep (void) -{ - const char *key1 = "12345"; - const unsigned char key1_expected[] = { 0x31, 0x32, 0x33, 0x34, 0x35 }; - const char *key2 = "ascii test$$$"; - const unsigned char key2_expected[] = { 0x61, 0x73, 0x63, 0x69, 0x69, 0x20, 0x74, 0x65, 0x73, 0x74, 0x24, 0x24, 0x24 }; - const char *key3 = "abcdef1234"; - const unsigned char key3_expected[] = { 0xab, 0xcd, 0xef, 0x12, 0x34 }; - const char *key4 = "96aec785c6392675f87f592972"; - const unsigned char key4_expected[] = { 0x96, 0xae, 0xc7, 0x85, 0xc6, 0x39, 0x26, 0x75, 0xf8, 0x7f, 0x59, 0x29, 0x72 }; - const char *key5 = "r34lly l33t w3p p4ssphr4s3 for t3st1ng"; - const unsigned char key5_expected[] = { 0xce, 0x68, 0x8b, 0x35, 0xf6, 0x0a, 0x2b, 0xbf, 0xc9, 0x8f, 0xed, 0x10, 0xda }; - - test_wifi_wep_key ("wifi-wep-ascii-40", NM_WEP_KEY_TYPE_KEY, key1, key1_expected, sizeof (key1_expected)); - test_wifi_wep_key ("wifi-wep-ascii-104", NM_WEP_KEY_TYPE_KEY, key2, key2_expected, sizeof (key2_expected)); - test_wifi_wep_key ("wifi-wep-hex-40", NM_WEP_KEY_TYPE_KEY, key3, key3_expected, sizeof (key3_expected)); - test_wifi_wep_key ("wifi-wep-hex-104", NM_WEP_KEY_TYPE_KEY, key4, key4_expected, sizeof (key4_expected)); - test_wifi_wep_key ("wifi-wep-passphrase-104", NM_WEP_KEY_TYPE_PASSPHRASE, key5, key5_expected, sizeof (key5_expected)); - - test_wifi_wep_key ("wifi-wep-old-hex-104", NM_WEP_KEY_TYPE_UNKNOWN, key4, key4_expected, sizeof (key4_expected)); -} - -static void -test_wifi_wpa_psk (const char *detail, - OptType key_type, - const char *key_data, - const unsigned char *expected, - size_t expected_size) -{ - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMSupplicantConfig *config = NULL; - gs_unref_variant GVariant *config_dict = NULL; - NMSettingConnection *s_con; - NMSettingWireless *s_wifi; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig *s_ip4; - char *uuid; - gboolean success; - GError *error = NULL; - GBytes *ssid; - const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; - const char *bssid_str = "11:22:33:44:55:66"; - - connection = nm_simple_connection_new (); - - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new (); - nm_connection_add_setting (connection, NM_SETTING (s_con)); - - uuid = nm_utils_uuid_generate (); - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, "Test Wifi WEP Key", - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, - NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, - NULL); - g_free (uuid); - - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - - ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); - - g_object_set (s_wifi, - NM_SETTING_WIRELESS_SSID, ssid, - NM_SETTING_WIRELESS_BSSID, bssid_str, - NM_SETTING_WIRELESS_MODE, "infrastructure", - NM_SETTING_WIRELESS_BAND, "bg", - NULL); - - g_bytes_unref (ssid); - - /* Wifi Security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wsec)); - - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", - NM_SETTING_WIRELESS_SECURITY_PSK, key_data, - NULL); - - nm_setting_wireless_security_add_proto (s_wsec, "wpa"); - nm_setting_wireless_security_add_proto (s_wsec, "rsn"); - nm_setting_wireless_security_add_pairwise (s_wsec, "tkip"); - nm_setting_wireless_security_add_pairwise (s_wsec, "ccmp"); - nm_setting_wireless_security_add_group (s_wsec, "tkip"); - nm_setting_wireless_security_add_group (s_wsec, "ccmp"); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - - success = nm_connection_verify (connection, &error); - g_assert_no_error (error); - g_assert (success); - - config = nm_supplicant_config_new (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'ssid' value 'Test SSID'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'scan_ssid' value '1'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'bssid' value '11:22:33:44:55:66'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'freq_list' value *"); - g_assert (nm_supplicant_config_add_setting_wireless (config, - s_wifi, - 0, - &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'key_mgmt' value 'WPA-PSK'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'psk' value *"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'proto' value 'WPA RSN'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'pairwise' value 'TKIP CCMP'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'group' value 'TKIP CCMP'"); - g_assert (nm_supplicant_config_add_setting_wireless_security (config, - s_wsec, - NULL, - "376aced7-b28c-46be-9a62-fcdf072571da", - 1500, - &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - config_dict = nm_supplicant_config_to_variant (config); - g_assert (config_dict); - - validate_opt (detail, config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); - validate_opt (detail, config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); - validate_opt (detail, config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); - validate_opt (detail, config_dict, "key_mgmt", TYPE_KEYWORD, "WPA-PSK", -1); - validate_opt (detail, config_dict, "proto", TYPE_KEYWORD, "WPA RSN", -1); - validate_opt (detail, config_dict, "pairwise", TYPE_KEYWORD, "TKIP CCMP", -1); - validate_opt (detail, config_dict, "group", TYPE_KEYWORD, "TKIP CCMP", -1); - validate_opt (detail, config_dict, "psk", key_type, expected, expected_size); -} - -static void -test_wifi_wpa_psk_types (void) -{ - const char *key1 = "d4721e911461d3cdef9793858e977fcda091779243abb7316c2f11605a160893"; - const unsigned char key1_expected[] = { 0xd4, 0x72, 0x1e, 0x91, 0x14, 0x61, 0xd3, 0xcd, - 0xef, 0x97, 0x93, 0x85, 0x8e, 0x97, 0x7f, 0xcd, - 0xa0, 0x91, 0x77, 0x92, 0x43, 0xab, 0xb7, 0x31, - 0x6c, 0x2f, 0x11, 0x60, 0x5a, 0x16, 0x08, 0x93 }; - const char *key2 = "r34lly l33t wp4 p4ssphr4s3 for t3st1ng"; - - test_wifi_wpa_psk ("wifi-wpa-psk-hex", TYPE_BYTES, key1, key1_expected, sizeof (key1_expected)); - test_wifi_wpa_psk ("wifi-wep-psk-passphrase", TYPE_STRING, key2, (gconstpointer) key2, strlen (key2)); -} - -static void -test_wifi_eap (void) -{ - gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMSupplicantConfig *config = NULL; - gs_unref_variant GVariant *config_dict = NULL; - NMSettingConnection *s_con; - NMSettingWireless *s_wifi; - NMSettingWirelessSecurity *s_wsec; - NMSetting8021x *s_8021x; - NMSettingIPConfig *s_ip4; - char *uuid; - gboolean success; - GError *error = NULL; - GBytes *ssid; - const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; - const char *bssid_str = "11:22:33:44:55:66"; - guint32 mtu = 1100; - - connection = nm_simple_connection_new (); - - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new (); - nm_connection_add_setting (connection, NM_SETTING (s_con)); - - uuid = nm_utils_uuid_generate (); - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, "Test Wifi EAP-TLS", - NM_SETTING_CONNECTION_UUID, uuid, - NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, - NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, - NULL); - g_free (uuid); - - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wifi)); - - ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); - - g_object_set (s_wifi, - NM_SETTING_WIRELESS_SSID, ssid, - NM_SETTING_WIRELESS_BSSID, bssid_str, - NM_SETTING_WIRELESS_MODE, "infrastructure", - NM_SETTING_WIRELESS_BAND, "bg", - NULL); - - g_bytes_unref (ssid); - - /* Wifi Security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - nm_connection_add_setting (connection, NM_SETTING (s_wsec)); - - g_object_set (s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", - NULL); - - nm_setting_wireless_security_add_proto (s_wsec, "wpa"); - nm_setting_wireless_security_add_proto (s_wsec, "rsn"); - nm_setting_wireless_security_add_pairwise (s_wsec, "tkip"); - nm_setting_wireless_security_add_pairwise (s_wsec, "ccmp"); - nm_setting_wireless_security_add_group (s_wsec, "tkip"); - nm_setting_wireless_security_add_group (s_wsec, "ccmp"); - - /* 802-1X setting */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - nm_connection_add_setting (connection, NM_SETTING (s_8021x)); - nm_setting_802_1x_add_eap_method (s_8021x, "tls"); - nm_setting_802_1x_set_client_cert (s_8021x, TEST_CERT_DIR "/test-cert.p12", NM_SETTING_802_1X_CK_SCHEME_PATH, NULL, NULL); - nm_setting_802_1x_set_ca_cert (s_8021x, TEST_CERT_DIR "/test-ca-cert.pem", NM_SETTING_802_1X_CK_SCHEME_PATH, NULL, NULL); - nm_setting_802_1x_set_private_key (s_8021x, TEST_CERT_DIR "/test-cert.p12", NULL, NM_SETTING_802_1X_CK_SCHEME_PATH, NULL, NULL); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - - success = nm_connection_verify (connection, &error); - g_assert_no_error (error); - g_assert (success); - - config = nm_supplicant_config_new (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'ssid' value 'Test SSID'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'scan_ssid' value '1'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'bssid' value '11:22:33:44:55:66'*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'freq_list' value *"); - g_assert (nm_supplicant_config_add_setting_wireless (config, - s_wifi, - 0, - &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'key_mgmt' value 'WPA-EAP'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'proto' value 'WPA RSN'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'pairwise' value 'TKIP CCMP'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*added 'group' value 'TKIP CCMP'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*Config: added 'eap' value 'TLS'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*Config: added 'fragment_size' value '1086'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "* Config: added 'ca_cert' value '*/test-ca-cert.pem'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "* Config: added 'private_key' value '*/test-cert.p12'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*Config: added 'bgscan' value 'simple:30:-65:300'"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*Config: added 'proactive_key_caching' value '1'"); - g_assert (nm_supplicant_config_add_setting_wireless_security (config, - s_wsec, - s_8021x, - "d5b488af-9cab-41ed-bad4-97709c58430f", - mtu, - &error)); - g_assert_no_error (error); - g_test_assert_expected_messages (); - - config_dict = nm_supplicant_config_to_variant (config); - g_assert (config_dict); - - validate_opt ("wifi-eap", config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); - validate_opt ("wifi-eap", config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); - validate_opt ("wifi-eap", config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); - validate_opt ("wifi-eap", config_dict, "key_mgmt", TYPE_KEYWORD, "WPA-EAP", -1); - validate_opt ("wifi-eap", config_dict, "eap", TYPE_KEYWORD, "TLS", -1); - validate_opt ("wifi-eap", config_dict, "proto", TYPE_KEYWORD, "WPA RSN", -1); - validate_opt ("wifi-eap", config_dict, "pairwise", TYPE_KEYWORD, "TKIP CCMP", -1); - validate_opt ("wifi-eap", config_dict, "group", TYPE_KEYWORD, "TKIP CCMP", -1); - validate_opt ("wifi-eap", config_dict, "fragment_size", TYPE_INT, GINT_TO_POINTER(mtu-14), -1); -} - -NMTST_DEFINE (); - -int main (int argc, char **argv) -{ - nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); - - g_test_add_func ("/supplicant-config/wifi-open", test_wifi_open); - g_test_add_func ("/supplicant-config/wifi-wep", test_wifi_wep); - g_test_add_func ("/supplicant-config/wifi-wpa-psk-types", test_wifi_wpa_psk_types); - g_test_add_func ("/supplicant-config/wifi-eap", test_wifi_eap); - - return g_test_run (); -} - diff --git a/src/supplicant/nm-supplicant-config.c b/src/supplicant/nm-supplicant-config.c new file mode 100644 index 00000000..8f766d7c --- /dev/null +++ b/src/supplicant/nm-supplicant-config.c @@ -0,0 +1,1246 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2012 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#include "nm-default.h" + +#include "nm-supplicant-config.h" + +#include +#include + +#include "nm-supplicant-settings-verify.h" +#include "nm-setting.h" +#include "NetworkManagerUtils.h" +#include "nm-utils.h" + +typedef struct { + char *value; + guint32 len; + OptType type; +} ConfigOption; + +/*****************************************************************************/ + +typedef struct { + GHashTable *config; + GHashTable *blobs; + guint32 ap_scan; + gboolean fast_required; + gboolean dispose_has_run; +} NMSupplicantConfigPrivate; + +struct _NMSupplicantConfig { + GObject parent; + NMSupplicantConfigPrivate _priv; +}; + +struct _NMSupplicantConfigClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMSupplicantConfig, nm_supplicant_config, G_TYPE_OBJECT) + +#define NM_SUPPLICANT_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSupplicantConfig, NM_IS_SUPPLICANT_CONFIG) + +/*****************************************************************************/ + +NMSupplicantConfig * +nm_supplicant_config_new (void) +{ + return g_object_new (NM_TYPE_SUPPLICANT_CONFIG, NULL); +} + +static void +config_option_free (ConfigOption *opt) +{ + g_free (opt->value); + g_slice_free (ConfigOption, opt); +} + +static void +blob_free (GByteArray *array) +{ + g_byte_array_free (array, TRUE); +} + +static void +nm_supplicant_config_init (NMSupplicantConfig * self) +{ + NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); + + priv->config = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) config_option_free); + + priv->blobs = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) blob_free); + + priv->ap_scan = 1; + priv->dispose_has_run = FALSE; +} + +static gboolean +nm_supplicant_config_add_option_with_type (NMSupplicantConfig *self, + const char *key, + const char *value, + gint32 len, + OptType opt_type, + const char *hidden, + GError **error) +{ + NMSupplicantConfigPrivate *priv; + ConfigOption *old_opt; + ConfigOption *opt; + OptType type; + + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + nm_assert (!error || !*error); + + priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); + + if (len < 0) + len = strlen (value); + + if (opt_type != TYPE_INVALID) + type = opt_type; + else { + type = nm_supplicant_settings_verify_setting (key, value, len); + if (type == TYPE_INVALID) { + char buf[255]; + memset (&buf[0], 0, sizeof (buf)); + memcpy (&buf[0], value, len > 254 ? 254 : len); + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "key '%s' and/or value '%s' invalid", key, hidden ? hidden : buf); + return FALSE; + } + } + + old_opt = (ConfigOption *) g_hash_table_lookup (priv->config, key); + if (old_opt) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "key '%s' already configured", key); + return FALSE; + } + + opt = g_slice_new0 (ConfigOption); + opt->value = g_malloc (len + 1); + memcpy (opt->value, value, len); + opt->value[len] = '\0'; + + opt->len = len; + opt->type = type; + + { + char buf[255]; + memset (&buf[0], 0, sizeof (buf)); + memcpy (&buf[0], opt->value, opt->len > 254 ? 254 : opt->len); + nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, hidden ? hidden : &buf[0]); + } + + g_hash_table_insert (priv->config, g_strdup (key), opt); + + return TRUE; +} + +static gboolean +nm_supplicant_config_add_option (NMSupplicantConfig *self, + const char *key, + const char *value, + gint32 len, + const char *hidden, + GError **error) +{ + return nm_supplicant_config_add_option_with_type (self, key, value, len, TYPE_INVALID, hidden, error); +} + +static gboolean +nm_supplicant_config_add_blob (NMSupplicantConfig *self, + const char *key, + GBytes *value, + const char *blobid, + GError **error) +{ + NMSupplicantConfigPrivate *priv; + ConfigOption *old_opt; + ConfigOption *opt; + OptType type; + GByteArray *blob; + const guint8 *data; + gsize data_len; + + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (blobid != NULL, FALSE); + + data = g_bytes_get_data (value, &data_len); + g_return_val_if_fail (data_len > 0, FALSE); + + priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); + + type = nm_supplicant_settings_verify_setting (key, (const char *) data, data_len); + if (type == TYPE_INVALID) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "key '%s' and/or its contained value is invalid", key); + return FALSE; + } + + old_opt = (ConfigOption *) g_hash_table_lookup (priv->config, key); + if (old_opt) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "key '%s' already configured", key); + return FALSE; + } + + blob = g_byte_array_sized_new (data_len); + g_byte_array_append (blob, data, data_len); + + opt = g_slice_new0 (ConfigOption); + opt->value = g_strdup_printf ("blob://%s", blobid); + opt->len = strlen (opt->value); + opt->type = type; + + nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, opt->value); + + g_hash_table_insert (priv->config, g_strdup (key), opt); + g_hash_table_insert (priv->blobs, g_strdup (blobid), blob); + + return TRUE; +} + +static gboolean +nm_supplicant_config_add_blob_for_connection (NMSupplicantConfig *self, + GBytes *field, + const char *name, + const char *con_uid, + GError **error) +{ + if (field && g_bytes_get_size (field)) { + gs_free char *uid = NULL; + char *p; + + uid = g_strdup_printf ("%s-%s", con_uid, name); + for (p = uid; *p; p++) { + if (*p == '/') + *p = '-'; + } + if (!nm_supplicant_config_add_blob (self, name, field, uid, error)) + return FALSE; + } + return TRUE; +} + +static void +nm_supplicant_config_finalize (GObject *object) +{ + NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE ((NMSupplicantConfig *) object); + + g_hash_table_destroy (priv->config); + g_hash_table_destroy (priv->blobs); + + G_OBJECT_CLASS (nm_supplicant_config_parent_class)->finalize (object); +} + + +static void +nm_supplicant_config_class_init (NMSupplicantConfigClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = nm_supplicant_config_finalize; +} + +guint32 +nm_supplicant_config_get_ap_scan (NMSupplicantConfig * self) +{ + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), 1); + + return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->ap_scan; +} + +gboolean +nm_supplicant_config_fast_required (NMSupplicantConfig *self) +{ + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); + + return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->fast_required; +} + +GVariant * +nm_supplicant_config_to_variant (NMSupplicantConfig *self) +{ + NMSupplicantConfigPrivate *priv; + GVariantBuilder builder; + GHashTableIter iter; + ConfigOption *option; + const char *key; + + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), NULL); + + priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + + g_hash_table_iter_init (&iter, priv->config); + while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &option)) { + switch (option->type) { + case TYPE_INT: + g_variant_builder_add (&builder, "{sv}", key, g_variant_new_int32 (atoi (option->value))); + break; + case TYPE_BYTES: + case TYPE_UTF8: + g_variant_builder_add (&builder, "{sv}", + key, + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + option->value, option->len, 1)); + break; + case TYPE_KEYWORD: + case TYPE_STRING: + g_variant_builder_add (&builder, "{sv}", key, g_variant_new_string (option->value)); + break; + default: + break; + } + } + + return g_variant_builder_end (&builder); +} + +GHashTable * +nm_supplicant_config_get_blobs (NMSupplicantConfig * self) +{ + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), NULL); + + return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->blobs; +} + +static const char * +wifi_freqs_to_string (gboolean bg_band) +{ + static const char *str_2ghz = NULL; + static const char *str_5ghz = NULL; + const char *str; + + str = bg_band ? str_2ghz : str_5ghz; + + if (G_UNLIKELY (str == NULL)) { + GString *tmp; + const guint *freqs; + int i; + + freqs = bg_band ? nm_utils_wifi_2ghz_freqs () : nm_utils_wifi_5ghz_freqs (); + tmp = g_string_sized_new (bg_band ? 70 : 225); + for (i = 0; freqs[i]; i++) + g_string_append_printf (tmp, i == 0 ? "%d" : " %d", freqs[i]); + str = g_string_free (tmp, FALSE); + if (bg_band) + str_2ghz = str; + else + str_5ghz = str; + } + return str; +} + +gboolean +nm_supplicant_config_add_setting_macsec (NMSupplicantConfig * self, + NMSettingMacsec * setting, + GError **error) +{ + NMSupplicantConfigPrivate *priv; + gs_unref_bytes GBytes *bytes = NULL; + const char *value; + char buf[32]; + int port; + + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); + g_return_val_if_fail (setting != NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); + + if (!nm_supplicant_config_add_option (self, "macsec_policy", "1", -1, NULL, error)) + return FALSE; + + value = nm_setting_macsec_get_encrypt (setting) ? "0" : "1"; + if (!nm_supplicant_config_add_option (self, "macsec_integ_only", value, -1, NULL, error)) + return FALSE; + + port = nm_setting_macsec_get_port (setting); + if (port > 0 && port < 65534) { + snprintf (buf, sizeof (buf), "%d", port); + if (!nm_supplicant_config_add_option (self, "macsec_port", buf, -1, NULL, error)) + return FALSE; + } + + if (nm_setting_macsec_get_mode (setting) == NM_SETTING_MACSEC_MODE_PSK) { + if (!nm_supplicant_config_add_option (self, "key_mgmt", "NONE", -1, NULL, error)) + return FALSE; + + /* CAK */ + value = nm_setting_macsec_get_mka_cak (setting); + if (!value) { + g_set_error_literal (error, + NM_SUPPLICANT_ERROR, + NM_SUPPLICANT_ERROR_CONFIG, + "missing MKA CAK"); + return FALSE; + } + + bytes = nm_utils_hexstr2bin (value); + if (!nm_supplicant_config_add_option (self, + "mka_cak", + g_bytes_get_data (bytes, NULL), + g_bytes_get_size (bytes), + "", + error)) + return FALSE; + + /* CKN */ + value = nm_setting_macsec_get_mka_ckn (setting); + if (!value) { + g_set_error_literal (error, + NM_SUPPLICANT_ERROR, + NM_SUPPLICANT_ERROR_CONFIG, + "missing MKA CKN"); + return FALSE; + } + + bytes = nm_utils_hexstr2bin (value); + if (!nm_supplicant_config_add_option (self, + "mka_ckn", + g_bytes_get_data (bytes, NULL), + g_bytes_get_size (bytes), + NULL, + error)) + return FALSE; + } + + return TRUE; +} + +gboolean +nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self, + NMSettingWireless * setting, + guint32 fixed_freq, + GError **error) +{ + NMSupplicantConfigPrivate *priv; + gboolean is_adhoc, is_ap; + const char *mode, *band; + guint32 channel; + GBytes *ssid; + const char *bssid; + + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); + g_return_val_if_fail (setting != NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); + + mode = nm_setting_wireless_get_mode (setting); + is_adhoc = (mode && !strcmp (mode, "adhoc")) ? TRUE : FALSE; + is_ap = (mode && !strcmp (mode, "ap")) ? TRUE : FALSE; + if (is_adhoc || is_ap) + priv->ap_scan = 2; + else + priv->ap_scan = 1; + + ssid = nm_setting_wireless_get_ssid (setting); + if (!nm_supplicant_config_add_option (self, "ssid", + (char *) g_bytes_get_data (ssid, NULL), + g_bytes_get_size (ssid), + NULL, + error)) + return FALSE; + + if (is_adhoc) { + if (!nm_supplicant_config_add_option (self, "mode", "1", -1, NULL, error)) + return FALSE; + } + + if (is_ap) { + if (!nm_supplicant_config_add_option (self, "mode", "2", -1, NULL, error)) + return FALSE; + } + + if ((is_adhoc || is_ap) && fixed_freq) { + gs_free char *str_freq = NULL; + + str_freq = g_strdup_printf ("%u", fixed_freq); + if (!nm_supplicant_config_add_option (self, "frequency", str_freq, -1, NULL, error)) + return FALSE; + } + + /* Except for Ad-Hoc and Hotspot, request that the driver probe for the + * specific SSID we want to associate with. + */ + if (!(is_adhoc || is_ap)) { + if (!nm_supplicant_config_add_option (self, "scan_ssid", "1", -1, NULL, error)) + return FALSE; + } + + bssid = nm_setting_wireless_get_bssid (setting); + if (bssid) { + if (!nm_supplicant_config_add_option (self, "bssid", + bssid, strlen (bssid), + NULL, + error)) + return FALSE; + } + + band = nm_setting_wireless_get_band (setting); + channel = nm_setting_wireless_get_channel (setting); + if (band) { + if (channel) { + guint32 freq; + gs_free char *str_freq = NULL; + + freq = nm_utils_wifi_channel_to_freq (channel, band); + str_freq = g_strdup_printf ("%u", freq); + if (!nm_supplicant_config_add_option (self, "freq_list", str_freq, -1, NULL, error)) + return FALSE; + } else { + const char *freqs = NULL; + + if (!strcmp (band, "a")) + freqs = wifi_freqs_to_string (FALSE); + else if (!strcmp (band, "bg")) + freqs = wifi_freqs_to_string (TRUE); + + if (freqs && !nm_supplicant_config_add_option (self, "freq_list", freqs, strlen (freqs), NULL, error)) + return FALSE; + } + } + + return TRUE; +} + +static gboolean +add_string_val (NMSupplicantConfig *self, + const char *field, + const char *name, + gboolean ucase, + const char *hidden, + GError **error) +{ + + if (field) { + gs_free char *value = NULL; + + if (ucase) { + value = g_ascii_strup (field, -1); + field = value; + } + return nm_supplicant_config_add_option (self, name, field, strlen (field), hidden, error); + } + return TRUE; +} + +#define ADD_STRING_LIST_VAL(self, setting, setting_name, field, field_plural, name, separator, ucase, hidden, error) \ + ({ \ + typeof (*(setting)) *_setting = (setting); \ + gboolean _success = TRUE; \ + \ + if (nm_setting_##setting_name##_get_num_##field_plural (_setting)) { \ + const char _separator = (separator); \ + GString *_str = g_string_new (NULL); \ + guint _k, _n; \ + \ + _n = nm_setting_##setting_name##_get_num_##field_plural (_setting); \ + for (_k = 0; _k < _n; _k++) { \ + const char *item = nm_setting_##setting_name##_get_##field (_setting, _k); \ + \ + if (!_str->len) { \ + g_string_append (_str, item); \ + } else { \ + g_string_append_c (_str, _separator); \ + g_string_append (_str, item); \ + } \ + } \ + if ((ucase)) \ + g_string_ascii_up (_str); \ + if (_str->len) { \ + if (!nm_supplicant_config_add_option ((self), (name), _str->str, -1, (hidden), (error))) \ + _success = FALSE; \ + } \ + g_string_free (_str, TRUE); \ + } \ + _success; \ + }) + +static void +wep128_passphrase_hash (const char *input, + size_t input_len, + guint8 *out_digest, + size_t *out_digest_len) +{ + GChecksum *sum; + guint8 data[64]; + int i; + + g_return_if_fail (out_digest != NULL); + g_return_if_fail (out_digest_len != NULL); + g_return_if_fail (*out_digest_len >= 16); + + /* Get at least 64 bytes by repeating the passphrase into the buffer */ + for (i = 0; i < sizeof (data); i++) + data[i] = input[i % input_len]; + + sum = g_checksum_new (G_CHECKSUM_MD5); + g_assert (sum); + g_checksum_update (sum, data, sizeof (data)); + g_checksum_get_digest (sum, out_digest, out_digest_len); + g_checksum_free (sum); + + g_assert (*out_digest_len == 16); + /* WEP104 keys are 13 bytes in length (26 hex characters) */ + *out_digest_len = 13; +} + +static gboolean +add_wep_key (NMSupplicantConfig *self, + const char *key, + const char *name, + NMWepKeyType wep_type, + GError **error) +{ + size_t key_len = key ? strlen (key) : 0; + + if (!key || !key_len) + return TRUE; + + if (wep_type == NM_WEP_KEY_TYPE_UNKNOWN) { + if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_KEY)) + wep_type = NM_WEP_KEY_TYPE_KEY; + else if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_PASSPHRASE)) + wep_type = NM_WEP_KEY_TYPE_PASSPHRASE; + } + + if ( (wep_type == NM_WEP_KEY_TYPE_UNKNOWN) + || (wep_type == NM_WEP_KEY_TYPE_KEY)) { + if ((key_len == 10) || (key_len == 26)) { + gs_unref_bytes GBytes *bytes = NULL; + + bytes = nm_utils_hexstr2bin (key); + if (!bytes) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "cannot add wep-key %s to suplicant config because key is not hex", + name); + return FALSE; + } + if (!nm_supplicant_config_add_option (self, + name, + g_bytes_get_data (bytes, NULL), + g_bytes_get_size (bytes), + "", + error)) + return FALSE; + } else if ((key_len == 5) || (key_len == 13)) { + if (!nm_supplicant_config_add_option (self, name, key, key_len, "", error)) + return FALSE; + } else { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "Cannot add wep-key %s to suplicant config because key-length %u is invalid", + name, (guint) key_len); + return FALSE; + } + } else if (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE) { + guint8 digest[16]; + size_t digest_len = sizeof (digest); + + wep128_passphrase_hash (key, key_len, digest, &digest_len); + if (!nm_supplicant_config_add_option (self, name, (const char *) digest, digest_len, "", error)) + return FALSE; + } + + return TRUE; +} + +gboolean +nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self, + NMSettingWirelessSecurity *setting, + NMSetting8021x *setting_8021x, + const char *con_uuid, + guint32 mtu, + GError **error) +{ + const char *key_mgmt, *auth_alg; + const char *psk; + + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); + g_return_val_if_fail (setting != NULL, FALSE); + g_return_val_if_fail (con_uuid != NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + key_mgmt = nm_setting_wireless_security_get_key_mgmt (setting); + if (!add_string_val (self, key_mgmt, "key_mgmt", TRUE, NULL, error)) + return FALSE; + + auth_alg = nm_setting_wireless_security_get_auth_alg (setting); + if (!add_string_val (self, auth_alg, "auth_alg", TRUE, NULL, error)) + return FALSE; + + psk = nm_setting_wireless_security_get_psk (setting); + if (psk) { + size_t psk_len = strlen (psk); + + if (psk_len == 64) { + gs_unref_bytes GBytes *bytes = NULL; + + /* Hex PSK */ + bytes = nm_utils_hexstr2bin (psk); + if (!bytes) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "Cannot add psk to supplicant config due to invalid hex"); + return FALSE; + } + + if (!nm_supplicant_config_add_option (self, + "psk", + g_bytes_get_data (bytes, NULL), + g_bytes_get_size (bytes), + "", + error)) + return FALSE; + } else if (psk_len >= 8 && psk_len <= 63) { + /* Use TYPE_STRING here so that it gets pushed to the + * supplicant as a string, and therefore gets quoted, + * and therefore the supplicant will interpret it as a + * passphrase and not a hex key. + */ + if (!nm_supplicant_config_add_option_with_type (self, "psk", psk, -1, TYPE_STRING, "", error)) + return FALSE; + } else { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "Cannot add psk to supplicant config due to invalid PSK length %u (not between 8 and 63 characters)", + (guint) psk_len); + return FALSE; + } + } + + /* Only WPA-specific things when using WPA */ + if ( !strcmp (key_mgmt, "wpa-none") + || !strcmp (key_mgmt, "wpa-psk") + || !strcmp (key_mgmt, "wpa-eap")) { + if (!ADD_STRING_LIST_VAL (self, setting, wireless_security, proto, protos, "proto", ' ', TRUE, NULL, error)) + return FALSE; + if (!ADD_STRING_LIST_VAL (self, setting, wireless_security, pairwise, pairwise, "pairwise", ' ', TRUE, NULL, error)) + return FALSE; + if (!ADD_STRING_LIST_VAL (self, setting, wireless_security, group, groups, "group", ' ', TRUE, NULL, error)) + return FALSE; + } + + /* WEP keys if required */ + if (!strcmp (key_mgmt, "none")) { + NMWepKeyType wep_type = nm_setting_wireless_security_get_wep_key_type (setting); + const char *wep0 = nm_setting_wireless_security_get_wep_key (setting, 0); + const char *wep1 = nm_setting_wireless_security_get_wep_key (setting, 1); + const char *wep2 = nm_setting_wireless_security_get_wep_key (setting, 2); + const char *wep3 = nm_setting_wireless_security_get_wep_key (setting, 3); + + if (!add_wep_key (self, wep0, "wep_key0", wep_type, error)) + return FALSE; + if (!add_wep_key (self, wep1, "wep_key1", wep_type, error)) + return FALSE; + if (!add_wep_key (self, wep2, "wep_key2", wep_type, error)) + return FALSE; + if (!add_wep_key (self, wep3, "wep_key3", wep_type, error)) + return FALSE; + + if (wep0 || wep1 || wep2 || wep3) { + gs_free char *value = NULL; + + value = g_strdup_printf ("%d", nm_setting_wireless_security_get_wep_tx_keyidx (setting)); + if (!nm_supplicant_config_add_option (self, "wep_tx_keyidx", value, -1, NULL, error)) + return FALSE; + } + } + + if (auth_alg && !strcmp (auth_alg, "leap")) { + /* LEAP */ + if (!strcmp (key_mgmt, "ieee8021x")) { + const char *tmp; + + tmp = nm_setting_wireless_security_get_leap_username (setting); + if (!add_string_val (self, tmp, "identity", FALSE, NULL, error)) + return FALSE; + + tmp = nm_setting_wireless_security_get_leap_password (setting); + if (!add_string_val (self, tmp, "password", FALSE, "", error)) + return FALSE; + + if (!add_string_val (self, "leap", "eap", TRUE, NULL, error)) + return FALSE; + } else { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "Invalid key-mgmt \"%s\" for leap", key_mgmt); + return FALSE; + } + } else { + /* 802.1x for Dynamic WEP and WPA-Enterprise */ + if (!strcmp (key_mgmt, "ieee8021x") || !strcmp (key_mgmt, "wpa-eap")) { + if (!setting_8021x) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "Cannot set key-mgmt %s with missing 8021x setting", key_mgmt); + return FALSE; + } + if (!nm_supplicant_config_add_setting_8021x (self, setting_8021x, con_uuid, mtu, FALSE, error)) + return FALSE; + } + + if (!strcmp (key_mgmt, "wpa-eap")) { + /* If using WPA Enterprise, enable optimized background scanning + * to ensure roaming within an ESS works well. + */ + if (!nm_supplicant_config_add_option (self, "bgscan", "simple:30:-65:300", -1, NULL, error)) + return FALSE; + + /* When using WPA-Enterprise, we want to use Proactive Key Caching (also + * called Opportunistic Key Caching) to avoid full EAP exchanges when + * roaming between access points in the same mobility group. + */ + if (!nm_supplicant_config_add_option (self, "proactive_key_caching", "1", -1, NULL, error)) + return FALSE; + } + } + + return TRUE; +} + +gboolean +nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self, + NMSetting8021x *setting, + const char *con_uuid, + guint32 mtu, + gboolean wired, + GError **error) +{ + NMSupplicantConfigPrivate *priv; + char *tmp; + const char *peapver, *value, *path; + gboolean added; + GString *phase1, *phase2; + GBytes *bytes; + gboolean fast = FALSE; + guint32 i, num_eap; + gboolean fast_provisoning_allowed = FALSE; + const char *ca_path_override = NULL, *ca_cert_override = NULL; + guint32 frag, hdrs; + gs_free char *frag_str = NULL; + + g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); + g_return_val_if_fail (setting != NULL, FALSE); + g_return_val_if_fail (con_uuid != NULL, FALSE); + + priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); + + value = nm_setting_802_1x_get_password (setting); + if (value) { + if (!add_string_val (self, value, "password", FALSE, "", error)) + return FALSE; + } else { + bytes = nm_setting_802_1x_get_password_raw (setting); + if (bytes) { + if (!nm_supplicant_config_add_option (self, + "password", + (const char *) g_bytes_get_data (bytes, NULL), + g_bytes_get_size (bytes), + "", + error)) + return FALSE; + } + } + value = nm_setting_802_1x_get_pin (setting); + if (!add_string_val (self, value, "pin", FALSE, "", error)) + return FALSE; + + if (wired) { + if (!add_string_val (self, "IEEE8021X", "key_mgmt", FALSE, NULL, error)) + return FALSE; + /* Wired 802.1x must always use eapol_flags=0 */ + if (!add_string_val (self, "0", "eapol_flags", FALSE, NULL, error)) + return FALSE; + priv->ap_scan = 0; + } + + if (!ADD_STRING_LIST_VAL (self, setting, 802_1x, eap_method, eap_methods, "eap", ' ', TRUE, NULL, error)) + return FALSE; + + /* Check EAP method for special handling: PEAP + GTC, FAST */ + num_eap = nm_setting_802_1x_get_num_eap_methods (setting); + for (i = 0; i < num_eap; i++) { + const char *method = nm_setting_802_1x_get_eap_method (setting, i); + + if (method && (strcasecmp (method, "fast") == 0)) { + fast = TRUE; + priv->fast_required = TRUE; + } + } + + /* Adjust the fragment size according to MTU, but do not set it higher than 1280-14 + * for better compatibility */ + hdrs = 14; /* EAPOL + EAP-TLS */ + frag = 1280 - hdrs; + if (mtu > hdrs) + frag = CLAMP (mtu - hdrs, 100, frag); + frag_str = g_strdup_printf ("%u", frag); + + if (!nm_supplicant_config_add_option (self, "fragment_size", frag_str, -1, NULL, error)) + return FALSE; + + phase1 = g_string_new (NULL); + peapver = nm_setting_802_1x_get_phase1_peapver (setting); + if (peapver) { + if (!strcmp (peapver, "0")) + g_string_append (phase1, "peapver=0"); + else if (!strcmp (peapver, "1")) + g_string_append (phase1, "peapver=1"); + } + + if (nm_setting_802_1x_get_phase1_peaplabel (setting)) { + if (phase1->len) + g_string_append_c (phase1, ' '); + g_string_append_printf (phase1, "peaplabel=%s", nm_setting_802_1x_get_phase1_peaplabel (setting)); + } + + value = nm_setting_802_1x_get_phase1_fast_provisioning (setting); + if (value) { + if (phase1->len) + g_string_append_c (phase1, ' '); + g_string_append_printf (phase1, "fast_provisioning=%s", value); + + if (strcmp (value, "0") != 0) + fast_provisoning_allowed = TRUE; + } + + if (phase1->len) { + if (!add_string_val (self, phase1->str, "phase1", FALSE, NULL, error)) { + g_string_free (phase1, TRUE); + return FALSE; + } + } + g_string_free (phase1, TRUE); + + phase2 = g_string_new (NULL); + if (nm_setting_802_1x_get_phase2_auth (setting) && !fast_provisoning_allowed) { + tmp = g_ascii_strup (nm_setting_802_1x_get_phase2_auth (setting), -1); + g_string_append_printf (phase2, "auth=%s", tmp); + g_free (tmp); + } + + if (nm_setting_802_1x_get_phase2_autheap (setting)) { + if (phase2->len) + g_string_append_c (phase2, ' '); + tmp = g_ascii_strup (nm_setting_802_1x_get_phase2_autheap (setting), -1); + g_string_append_printf (phase2, "autheap=%s", tmp); + g_free (tmp); + } + + if (phase2->len) { + if (!add_string_val (self, phase2->str, "phase2", FALSE, NULL, error)) { + g_string_free (phase2, TRUE); + return FALSE; + } + } + g_string_free (phase2, TRUE); + + /* PAC file */ + path = nm_setting_802_1x_get_pac_file (setting); + if (path) { + if (!add_string_val (self, path, "pac_file", FALSE, NULL, error)) + return FALSE; + } else { + /* PAC file is not specified. + * If provisioning is allowed, use an blob format. + */ + if (fast_provisoning_allowed) { + gs_free char *blob_name = NULL; + + blob_name = g_strdup_printf ("blob://pac-blob-%s", con_uuid); + if (!add_string_val (self, blob_name, "pac_file", FALSE, NULL, error)) + return FALSE; + } else { + /* This is only error for EAP-FAST; don't disturb other methods. */ + if (fast) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "EAP-FAST error: no PAC file provided and " + "automatic PAC provisioning is disabled"); + return FALSE; + } + } + } + + /* If user wants to use system CA certs, either populate ca_path (if the path + * is a directory) or ca_cert (the path is a file name) */ + if (nm_setting_802_1x_get_system_ca_certs (setting)) { + if (g_file_test (SYSTEM_CA_PATH, G_FILE_TEST_IS_DIR)) + ca_path_override = SYSTEM_CA_PATH; + else + ca_cert_override = SYSTEM_CA_PATH; + } + + /* CA path */ + path = nm_setting_802_1x_get_ca_path (setting); + path = ca_path_override ? ca_path_override : path; + if (path) { + if (!add_string_val (self, path, "ca_path", FALSE, NULL, error)) + return FALSE; + } + + /* Phase2 CA path */ + path = nm_setting_802_1x_get_phase2_ca_path (setting); + path = ca_path_override ? ca_path_override : path; + if (path) { + if (!add_string_val (self, path, "ca_path2", FALSE, NULL, error)) + return FALSE; + } + + /* CA certificate */ + if (ca_cert_override) { + if (!add_string_val (self, ca_cert_override, "ca_cert", FALSE, NULL, error)) + return FALSE; + } else { + switch (nm_setting_802_1x_get_ca_cert_scheme (setting)) { + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + bytes = nm_setting_802_1x_get_ca_cert_blob (setting); + if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "ca_cert", con_uuid, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = nm_setting_802_1x_get_ca_cert_path (setting); + if (!add_string_val (self, path, "ca_cert", FALSE, NULL, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PKCS11: + path = nm_setting_802_1x_get_ca_cert_uri (setting); + if (!add_string_val (self, path, "ca_cert", FALSE, NULL, error)) + return FALSE; + break; + default: + break; + } + } + + /* Phase 2 CA certificate */ + if (ca_cert_override) { + if (!add_string_val (self, ca_cert_override, "ca_cert2", FALSE, NULL, error)) + return FALSE; + } else { + switch (nm_setting_802_1x_get_phase2_ca_cert_scheme (setting)) { + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + bytes = nm_setting_802_1x_get_phase2_ca_cert_blob (setting); + if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "ca_cert2", con_uuid, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = nm_setting_802_1x_get_phase2_ca_cert_path (setting); + if (!add_string_val (self, path, "ca_cert2", FALSE, NULL, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PKCS11: + path = nm_setting_802_1x_get_phase2_ca_cert_uri (setting); + if (!add_string_val (self, path, "ca_cert2", FALSE, NULL, error)) + return FALSE; + break; + default: + break; + } + } + + /* Subject match */ + value = nm_setting_802_1x_get_subject_match (setting); + if (!add_string_val (self, value, "subject_match", FALSE, NULL, error)) + return FALSE; + value = nm_setting_802_1x_get_phase2_subject_match (setting); + if (!add_string_val (self, value, "subject_match2", FALSE, NULL, error)) + return FALSE; + + /* altSubjectName match */ + if (!ADD_STRING_LIST_VAL (self, setting, 802_1x, altsubject_match, altsubject_matches, "altsubject_match", ';', FALSE, NULL, error)) + return FALSE; + if (!ADD_STRING_LIST_VAL (self, setting, 802_1x, phase2_altsubject_match, phase2_altsubject_matches, "altsubject_match2", ';', FALSE, NULL, error)) + return FALSE; + + /* Domain suffix match */ + value = nm_setting_802_1x_get_domain_suffix_match (setting); + if (!add_string_val (self, value, "domain_suffix_match", FALSE, NULL, error)) + return FALSE; + value = nm_setting_802_1x_get_phase2_domain_suffix_match (setting); + if (!add_string_val (self, value, "domain_suffix_match2", FALSE, NULL, error)) + return FALSE; + + /* Private key */ + added = FALSE; + switch (nm_setting_802_1x_get_private_key_scheme (setting)) { + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + bytes = nm_setting_802_1x_get_private_key_blob (setting); + if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "private_key", con_uuid, error)) + return FALSE; + added = TRUE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = nm_setting_802_1x_get_private_key_path (setting); + if (!add_string_val (self, path, "private_key", FALSE, NULL, error)) + return FALSE; + added = TRUE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PKCS11: + path = nm_setting_802_1x_get_private_key_uri (setting); + if (!add_string_val (self, path, "private_key", FALSE, NULL, error)) + return FALSE; + added = TRUE; + break; + default: + break; + } + + if (added) { + NMSetting8021xCKFormat format; + NMSetting8021xCKScheme scheme; + + format = nm_setting_802_1x_get_private_key_format (setting); + scheme = nm_setting_802_1x_get_private_key_scheme (setting); + + if ( scheme == NM_SETTING_802_1X_CK_SCHEME_PATH + || format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { + /* Only add the private key password for PKCS#12 blobs and + * all path schemes, since in both of these cases the private key + * isn't decrypted at all. + */ + value = nm_setting_802_1x_get_private_key_password (setting); + if (!add_string_val (self, value, "private_key_passwd", FALSE, "", error)) + return FALSE; + } + + if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) { + /* Only add the client cert if the private key is not PKCS#12, as + * wpa_supplicant configuration directs us to do. + */ + switch (nm_setting_802_1x_get_client_cert_scheme (setting)) { + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + bytes = nm_setting_802_1x_get_client_cert_blob (setting); + if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "client_cert", con_uuid, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = nm_setting_802_1x_get_client_cert_path (setting); + if (!add_string_val (self, path, "client_cert", FALSE, NULL, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PKCS11: + path = nm_setting_802_1x_get_client_cert_uri (setting); + if (!add_string_val (self, path, "client_cert", FALSE, NULL, error)) + return FALSE; + break; + default: + break; + } + } + } + + /* Phase 2 private key */ + added = FALSE; + switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) { + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + bytes = nm_setting_802_1x_get_phase2_private_key_blob (setting); + if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "private_key2", con_uuid, error)) + return FALSE; + added = TRUE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = nm_setting_802_1x_get_phase2_private_key_path (setting); + if (!add_string_val (self, path, "private_key2", FALSE, NULL, error)) + return FALSE; + added = TRUE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PKCS11: + path = nm_setting_802_1x_get_phase2_private_key_uri (setting); + if (!add_string_val (self, path, "private_key2", FALSE, NULL, error)) + return FALSE; + added = TRUE; + break; + default: + break; + } + + if (added) { + NMSetting8021xCKFormat format; + NMSetting8021xCKScheme scheme; + + format = nm_setting_802_1x_get_phase2_private_key_format (setting); + scheme = nm_setting_802_1x_get_phase2_private_key_scheme (setting); + + if ( scheme == NM_SETTING_802_1X_CK_SCHEME_PATH + || format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) { + /* Only add the private key password for PKCS#12 blobs and + * all path schemes, since in both of these cases the private key + * isn't decrypted at all. + */ + value = nm_setting_802_1x_get_phase2_private_key_password (setting); + if (!add_string_val (self, value, "private_key2_passwd", FALSE, "", error)) + return FALSE; + } + + if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) { + /* Only add the client cert if the private key is not PKCS#12, as + * wpa_supplicant configuration directs us to do. + */ + switch (nm_setting_802_1x_get_phase2_client_cert_scheme (setting)) { + case NM_SETTING_802_1X_CK_SCHEME_BLOB: + bytes = nm_setting_802_1x_get_phase2_client_cert_blob (setting); + if (!nm_supplicant_config_add_blob_for_connection (self, bytes, "client_cert2", con_uuid, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PATH: + path = nm_setting_802_1x_get_phase2_client_cert_path (setting); + if (!add_string_val (self, path, "client_cert2", FALSE, NULL, error)) + return FALSE; + break; + case NM_SETTING_802_1X_CK_SCHEME_PKCS11: + path = nm_setting_802_1x_get_phase2_client_cert_uri (setting); + if (!add_string_val (self, path, "client_cert2", FALSE, NULL, error)) + return FALSE; + break; + default: + break; + } + } + } + + value = nm_setting_802_1x_get_identity (setting); + if (!add_string_val (self, value, "identity", FALSE, NULL, error)) + return FALSE; + value = nm_setting_802_1x_get_anonymous_identity (setting); + if (!add_string_val (self, value, "anonymous_identity", FALSE, NULL, error)) + return FALSE; + + return TRUE; +} + +gboolean +nm_supplicant_config_add_no_security (NMSupplicantConfig *self, GError **error) +{ + return nm_supplicant_config_add_option (self, "key_mgmt", "NONE", -1, NULL, error); +} + diff --git a/src/supplicant/nm-supplicant-config.h b/src/supplicant/nm-supplicant-config.h new file mode 100644 index 00000000..40fca61b --- /dev/null +++ b/src/supplicant/nm-supplicant-config.h @@ -0,0 +1,79 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2012 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#ifndef __NETWORKMANAGER_SUPPLICANT_CONFIG_H__ +#define __NETWORKMANAGER_SUPPLICANT_CONFIG_H__ + +#include +#include +#include +#include + +#include "nm-supplicant-types.h" + +#define NM_TYPE_SUPPLICANT_CONFIG (nm_supplicant_config_get_type ()) +#define NM_SUPPLICANT_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_CONFIG, NMSupplicantConfig)) +#define NM_SUPPLICANT_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_CONFIG, NMSupplicantConfigClass)) +#define NM_IS_SUPPLICANT_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SUPPLICANT_CONFIG)) +#define NM_IS_SUPPLICANT_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_CONFIG)) +#define NM_SUPPLICANT_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_CONFIG, NMSupplicantConfigClass)) + +typedef struct _NMSupplicantConfigClass NMSupplicantConfigClass; + +GType nm_supplicant_config_get_type (void); + +NMSupplicantConfig *nm_supplicant_config_new (void); + +guint32 nm_supplicant_config_get_ap_scan (NMSupplicantConfig *self); + +gboolean nm_supplicant_config_fast_required (NMSupplicantConfig *self); + +GVariant *nm_supplicant_config_to_variant (NMSupplicantConfig *self); + +GHashTable *nm_supplicant_config_get_blobs (NMSupplicantConfig *self); + +gboolean nm_supplicant_config_add_setting_wireless (NMSupplicantConfig *self, + NMSettingWireless *setting, + guint32 fixed_freq, + GError **error); + +gboolean nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self, + NMSettingWirelessSecurity *setting, + NMSetting8021x *setting_8021x, + const char *con_uuid, + guint32 mtu, + GError **error); + +gboolean nm_supplicant_config_add_no_security (NMSupplicantConfig *self, + GError **error); + +gboolean nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self, + NMSetting8021x *setting, + const char *con_uuid, + guint32 mtu, + gboolean wired, + GError **error); + +gboolean nm_supplicant_config_add_setting_macsec (NMSupplicantConfig *self, + NMSettingMacsec *setting, + GError **error); + +#endif /* __NETWORKMANAGER_SUPPLICANT_CONFIG_H__ */ diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c new file mode 100644 index 00000000..6fc85535 --- /dev/null +++ b/src/supplicant/nm-supplicant-interface.c @@ -0,0 +1,1681 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2012 Red Hat, Inc. + * Copyright (C) 2006 - 2008 Novell, Inc. + */ + +#include "nm-default.h" + +#include "nm-supplicant-interface.h" + +#include +#include + +#include "NetworkManagerUtils.h" +#include "nm-supplicant-config.h" +#include "nm-core-internal.h" +#include "nm-dbus-compat.h" + +#define WPAS_DBUS_IFACE_INTERFACE WPAS_DBUS_INTERFACE ".Interface" +#define WPAS_DBUS_IFACE_BSS WPAS_DBUS_INTERFACE ".BSS" +#define WPAS_DBUS_IFACE_NETWORK WPAS_DBUS_INTERFACE ".Network" +#define WPAS_ERROR_INVALID_IFACE WPAS_DBUS_INTERFACE ".InvalidInterface" +#define WPAS_ERROR_EXISTS_ERROR WPAS_DBUS_INTERFACE ".InterfaceExists" + +/*****************************************************************************/ + +enum { + STATE, /* change in the interface's state */ + REMOVED, /* interface was removed by the supplicant */ + NEW_BSS, /* interface saw a new access point from a scan */ + BSS_UPDATED, /* a BSS property changed */ + BSS_REMOVED, /* supplicant removed BSS from its scan list */ + SCAN_DONE, /* wifi scan is complete */ + CONNECTION_ERROR, /* an error occurred during a connection request */ + CREDENTIALS_REQUEST, /* 802.1x identity or password requested */ + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +NM_GOBJECT_PROPERTIES_DEFINE (NMSupplicantInterface, + PROP_IFACE, + PROP_SCANNING, + PROP_CURRENT_BSS, + PROP_DRIVER, + PROP_FAST_SUPPORTED, + PROP_AP_SUPPORT, +); + +typedef struct { + char * dev; + NMSupplicantDriver driver; + bool fast_supported; + gboolean has_credreq; /* Whether querying 802.1x credentials is supported */ + NMSupplicantFeature ap_support; /* Lightweight AP mode support */ + NMSupplicantFeature mac_randomization_support; + guint32 max_scan_ssids; + guint32 ready_count; + + char * object_path; + guint32 state; + int disconnect_reason; + + gboolean scanning; + + GDBusProxy * wpas_proxy; + GCancellable * init_cancellable; + GDBusProxy * iface_proxy; + GCancellable * other_cancellable; + GCancellable * assoc_cancellable; + char * net_path; + guint32 blobs_left; + GHashTable * bss_proxies; + char * current_bss; + + gint32 last_scan; /* timestamp as returned by nm_utils_get_monotonic_timestamp_s() */ + + NMSupplicantConfig *cfg; +} NMSupplicantInterfacePrivate; + +struct _NMSupplicantInterface { + GObject parent; + NMSupplicantInterfacePrivate _priv; +}; + +struct _NMSupplicantInterfaceClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMSupplicantInterface, nm_supplicant_interface, G_TYPE_OBJECT) + +#define NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSupplicantInterface, NM_IS_SUPPLICANT_INTERFACE) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SUPPLICANT +#define _NMLOG_PREFIX_NAME "sup-iface" +#define _NMLOG(level, ...) \ + G_STMT_START { \ + char _sbuf[64]; \ + \ + nm_log ((level), _NMLOG_DOMAIN, \ + "%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + _NMLOG_PREFIX_NAME, \ + ((self) \ + ? nm_sprintf_buf (_sbuf, \ + "[%p,%s]", \ + (self), \ + NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev) \ + : "") \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + +/*****************************************************************************/ + +static void +emit_error_helper (NMSupplicantInterface *self, GError *error) +{ + char *name = NULL; + + if (g_dbus_error_is_remote_error (error)) + name = g_dbus_error_get_remote_error (error); + + g_signal_emit (self, signals[CONNECTION_ERROR], 0, name, error->message); + g_free (name); +} + +static void +bss_props_changed_cb (GDBusProxy *proxy, + GVariant *changed_properties, + char **invalidated_properties, + gpointer user_data) +{ + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (priv->scanning) + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); + + g_signal_emit (self, signals[BSS_UPDATED], 0, + g_dbus_proxy_get_object_path (proxy), + changed_properties); +} + +static GVariant * +_get_bss_proxy_properties (NMSupplicantInterface *self, GDBusProxy *proxy) +{ + gs_strfreev char **properties = NULL; + GVariantBuilder builder; + char **iter; + + iter = properties = g_dbus_proxy_get_cached_property_names (proxy); + if (!iter) + return NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + while (*iter) { + GVariant *copy = g_dbus_proxy_get_cached_property (proxy, *iter); + + g_variant_builder_add (&builder, "{sv}", *iter++, copy); + g_variant_unref (copy); + } + + return g_variant_builder_end (&builder); +} + +#define BSS_PROXY_INITED "bss-proxy-inited" + +static void +on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *props = NULL; + + if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + self = NM_SUPPLICANT_INTERFACE (user_data); + _LOGD ("failed to acquire BSS proxy: (%s)", error->message); + g_hash_table_remove (NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->bss_proxies, + g_dbus_proxy_get_object_path (proxy)); + } + return; + } + + self = NM_SUPPLICANT_INTERFACE (user_data); + props = _get_bss_proxy_properties (self, proxy); + if (!props) + return; + + g_object_set_data (G_OBJECT (proxy), BSS_PROXY_INITED, GUINT_TO_POINTER (TRUE)); + + g_signal_emit (self, signals[NEW_BSS], 0, + g_dbus_proxy_get_object_path (proxy), + g_variant_ref_sink (props)); +} + +static void +handle_new_bss (NMSupplicantInterface *self, const char *object_path) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + GDBusProxy *bss_proxy; + + g_return_if_fail (object_path != NULL); + + if (g_hash_table_lookup (priv->bss_proxies, object_path)) + return; + + bss_proxy = g_object_new (G_TYPE_DBUS_PROXY, + "g-bus-type", G_BUS_TYPE_SYSTEM, + "g-flags", G_DBUS_PROXY_FLAGS_NONE, + "g-name", WPAS_DBUS_SERVICE, + "g-object-path", object_path, + "g-interface-name", WPAS_DBUS_IFACE_BSS, + NULL); + g_hash_table_insert (priv->bss_proxies, + (char *) g_dbus_proxy_get_object_path (bss_proxy), + bss_proxy); + g_signal_connect (bss_proxy, "g-properties-changed", G_CALLBACK (bss_props_changed_cb), self); + g_async_initable_init_async (G_ASYNC_INITABLE (bss_proxy), + G_PRIORITY_DEFAULT, + priv->other_cancellable, + (GAsyncReadyCallback) on_bss_proxy_acquired, + self); +} + +static void +set_state (NMSupplicantInterface *self, guint32 new_state) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + guint32 old_state = priv->state; + + g_return_if_fail (new_state < NM_SUPPLICANT_INTERFACE_STATE_LAST); + + if (new_state == priv->state) + return; + + /* DOWN is a terminal state */ + g_return_if_fail (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DOWN); + + /* Cannot regress to READY, STARTING, or INIT from higher states */ + if (priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY) + g_return_if_fail (new_state > NM_SUPPLICANT_INTERFACE_STATE_READY); + + if (new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) { + if (priv->other_cancellable) { + g_warn_if_fail (priv->other_cancellable == NULL); + g_cancellable_cancel (priv->other_cancellable); + g_clear_object (&priv->other_cancellable); + } + priv->other_cancellable = g_cancellable_new (); + } else if (new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) { + if (priv->init_cancellable) + g_cancellable_cancel (priv->init_cancellable); + g_clear_object (&priv->init_cancellable); + + if (priv->other_cancellable) + g_cancellable_cancel (priv->other_cancellable); + g_clear_object (&priv->other_cancellable); + + if (priv->iface_proxy) + g_signal_handlers_disconnect_by_data (priv->iface_proxy, self); + } + + priv->state = new_state; + + if ( priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING + || old_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING) + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); + + /* Disconnect reason is no longer relevant when not in the DISCONNECTED state */ + if (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED) + priv->disconnect_reason = 0; + + g_signal_emit (self, signals[STATE], 0, + priv->state, + old_state, + priv->disconnect_reason); +} + +static int +wpas_state_string_to_enum (const char *str_state) +{ + if (!strcmp (str_state, "interface_disabled")) + return NM_SUPPLICANT_INTERFACE_STATE_DISABLED; + else if (!strcmp (str_state, "disconnected")) + return NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED; + else if (!strcmp (str_state, "inactive")) + return NM_SUPPLICANT_INTERFACE_STATE_INACTIVE; + else if (!strcmp (str_state, "scanning")) + return NM_SUPPLICANT_INTERFACE_STATE_SCANNING; + else if (!strcmp (str_state, "authenticating")) + return NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING; + else if (!strcmp (str_state, "associating")) + return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING; + else if (!strcmp (str_state, "associated")) + return NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED; + else if (!strcmp (str_state, "4way_handshake")) + return NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE; + else if (!strcmp (str_state, "group_handshake")) + return NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE; + else if (!strcmp (str_state, "completed")) + return NM_SUPPLICANT_INTERFACE_STATE_COMPLETED; + + return -1; +} + +static void +set_state_from_string (NMSupplicantInterface *self, const char *new_state) +{ + int state; + + state = wpas_state_string_to_enum (new_state); + if (state == -1) { + _LOGW ("unknown supplicant state '%s'", new_state); + return; + } + set_state (self, (guint32) state); +} + +static void +set_scanning (NMSupplicantInterface *self, gboolean new_scanning) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (priv->scanning != new_scanning) { + priv->scanning = new_scanning; + + /* Cache time of last scan completion */ + if (priv->scanning == FALSE) + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); + + _notify (self, PROP_SCANNING); + } +} + +gboolean +nm_supplicant_interface_get_scanning (NMSupplicantInterface *self) +{ + NMSupplicantInterfacePrivate *priv; + + g_return_val_if_fail (self != NULL, FALSE); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + if (priv->scanning) + return TRUE; + if (priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING) + return TRUE; + return FALSE; +} + +const char * +nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self) +{ + NMSupplicantInterfacePrivate *priv; + + g_return_val_if_fail (self != NULL, FALSE); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + return priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY ? priv->current_bss : NULL; +} + +gint32 +nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self) +{ + return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->last_scan; +} + +#define MATCH_PROPERTY(p, n, v, t) (!strcmp (p, n) && g_variant_is_of_type (v, t)) + +static void +parse_capabilities (NMSupplicantInterface *self, GVariant *capabilities) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + gboolean have_active = FALSE, have_ssid = FALSE; + gint32 max_scan_ssids = -1; + const char **array; + + g_return_if_fail (capabilities && g_variant_is_of_type (capabilities, G_VARIANT_TYPE_VARDICT)); + + if ( g_variant_lookup (capabilities, "Scan", "^a&s", &array) + && array) { + if (g_strv_contains (array, "active")) + have_active = TRUE; + if (g_strv_contains (array, "ssid")) + have_ssid = TRUE; + g_free (array); + } + + if (g_variant_lookup (capabilities, "MaxScanSSID", "i", &max_scan_ssids)) { + /* We need active scan and SSID probe capabilities to care about MaxScanSSIDs */ + if (max_scan_ssids > 0 && have_active && have_ssid) { + /* wpa_supplicant's WPAS_MAX_SCAN_SSIDS value is 16, but for speed + * and to ensure we don't disclose too many SSIDs from the hidden + * list, we'll limit to 5. + */ + priv->max_scan_ssids = CLAMP (max_scan_ssids, 0, 5); + _LOGI ("supports %d scan SSIDs", priv->max_scan_ssids); + } + } +} + +static void +iface_check_ready (NMSupplicantInterface *self) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (priv->ready_count && priv->state < NM_SUPPLICANT_INTERFACE_STATE_READY) { + priv->ready_count--; + if (priv->ready_count == 0) + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_READY); + } +} + +gboolean +nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self, + const char *field, + const char *value, + GError **error) +{ + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *reply = NULL; + + g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE); + g_return_val_if_fail (field != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + g_return_val_if_fail (priv->has_credreq == TRUE, FALSE); + + /* Need a network block object path */ + g_return_val_if_fail (priv->net_path, FALSE); + reply = g_dbus_proxy_call_sync (priv->iface_proxy, + "NetworkReply", + g_variant_new ("(oss)", + priv->net_path, + field, + value), + G_DBUS_CALL_FLAGS_NONE, + 5000, + NULL, + error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + + return !!reply; +} + +static void +iface_check_netreply_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; + + /* We know NetworkReply is supported if the NetworkReply method returned + * successfully (which is unexpected since we sent a bogus network + * object path) or if we got an "InvalidArgs" (which indicates NetworkReply + * is supported). We know it's not supported if we get an + * "UnknownMethod" error. + */ + + variant = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (variant || _nm_dbus_error_has_name (error, "fi.w1.wpa_supplicant1.InvalidArgs")) + priv->has_credreq = TRUE; + + _LOGD ("supplicant %s network credentials requests", + priv->has_credreq ? "supports" : "does not support"); + + iface_check_ready (self); +} + +NMSupplicantFeature +nm_supplicant_interface_get_ap_support (NMSupplicantInterface *self) +{ + return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->ap_support; +} + +void +nm_supplicant_interface_set_ap_support (NMSupplicantInterface *self, + NMSupplicantFeature ap_support) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* Use the best indicator of support between the supplicant global + * Capabilities property and the interface's introspection data. + */ + if (ap_support > priv->ap_support) + priv->ap_support = ap_support; +} + +static void +set_preassoc_scan_mac_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; + + variant = _nm_dbus_proxy_call_finish (proxy, result, + G_VARIANT_TYPE ("()"), + &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + if (error) + _LOGW ("failed to enable scan MAC address randomization (%s)", error->message); + iface_check_ready (self); +} + +static void +iface_introspect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; + const char *data; + + variant = _nm_dbus_proxy_call_finish (proxy, result, + G_VARIANT_TYPE ("(s)"), + &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (variant) { + g_variant_get (variant, "(&s)", &data); + + /* The ProbeRequest method only exists if AP mode has been enabled */ + if (strstr (data, "ProbeRequest")) + priv->ap_support = NM_SUPPLICANT_FEATURE_YES; + + if (strstr (data, "PreassocMacAddr")) { + priv->mac_randomization_support = NM_SUPPLICANT_FEATURE_YES; + + /* Turn on MAC randomization during scans by default */ + priv->ready_count++; + g_dbus_proxy_call (priv->iface_proxy, + DBUS_INTERFACE_PROPERTIES ".Set", + g_variant_new ("(ssv)", + WPAS_DBUS_IFACE_INTERFACE, + "PreassocMacAddr", + g_variant_new_string ("0")), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + (GAsyncReadyCallback) set_preassoc_scan_mac_cb, + self); + } + } + + iface_check_ready (self); +} + +static void +wpas_iface_scan_done (GDBusProxy *proxy, + gboolean success, + gpointer user_data) +{ + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + GVariant *props; + GHashTableIter iter; + char *bss_path; + GDBusProxy *bss_proxy; + + /* Cache last scan completed time */ + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); + + g_signal_emit (self, signals[SCAN_DONE], 0, success); + + /* Emit NEW_BSS so that wifi device has the APs (in case it removed them) */ + g_hash_table_iter_init (&iter, priv->bss_proxies); + while (g_hash_table_iter_next (&iter, (gpointer) &bss_path, (gpointer) &bss_proxy)) { + if (g_object_get_data (G_OBJECT (bss_proxy), BSS_PROXY_INITED)) { + props = _get_bss_proxy_properties (self, bss_proxy); + if (props) { + g_signal_emit (self, signals[NEW_BSS], 0, + bss_path, + g_variant_ref_sink (props)); + g_variant_unref (props); + } + } + } +} + +static void +wpas_iface_bss_added (GDBusProxy *proxy, + const char *path, + GVariant *props, + gpointer user_data) +{ + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (priv->scanning) + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); + + handle_new_bss (self, path); +} + +static void +wpas_iface_bss_removed (GDBusProxy *proxy, + const char *path, + gpointer user_data) +{ + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + g_signal_emit (self, signals[BSS_REMOVED], 0, path); + g_hash_table_remove (priv->bss_proxies, path); +} + +static void +wpas_iface_network_request (GDBusProxy *proxy, + const char *path, + const char *field, + const char *message, + gpointer user_data) +{ + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (priv->has_credreq && priv->net_path && !g_strcmp0 (path, priv->net_path)) + g_signal_emit (self, signals[CREDENTIALS_REQUEST], 0, field, message); +} + +static void +props_changed_cb (GDBusProxy *proxy, + GVariant *changed_properties, + GStrv invalidated_properties, + gpointer user_data) +{ + NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + const char *s, **array, **iter; + gboolean b = FALSE; + gint32 i32; + GVariant *v; + + g_object_freeze_notify (G_OBJECT (self)); + + if (g_variant_lookup (changed_properties, "Scanning", "b", &b)) + set_scanning (self, b); + + if ( g_variant_lookup (changed_properties, "State", "&s", &s) + && priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY) { + /* Only transition to actual wpa_supplicant interface states (ie, + * anything > READY) after the NMSupplicantInterface has had a + * chance to initialize, which is signalled by entering the READY + * state. + */ + set_state_from_string (self, s); + } + + if (g_variant_lookup (changed_properties, "BSSs", "^a&o", &array)) { + iter = array; + while (*iter) + handle_new_bss (self, *iter++); + g_free (array); + } + + if (g_variant_lookup (changed_properties, "CurrentBSS", "&o", &s)) { + if (strcmp (s, "/") == 0) + s = NULL; + if (g_strcmp0 (s, priv->current_bss) != 0) { + g_free (priv->current_bss); + priv->current_bss = g_strdup (s); + _notify (self, PROP_CURRENT_BSS); + } + } + + v = g_variant_lookup_value (changed_properties, "Capabilities", G_VARIANT_TYPE_VARDICT); + if (v) { + parse_capabilities (self, v); + g_variant_unref (v); + } + + if (g_variant_lookup (changed_properties, "DisconnectReason", "i", &i32)) { + /* Disconnect reason is currently only given for deauthentication events, + * not disassociation; currently they are IEEE 802.11 "reason codes", + * defined by (IEEE 802.11-2007, 7.3.1.7, Table 7-22). Any locally caused + * deauthentication will be negative, while authentications caused by the + * AP will be positive. + */ + priv->disconnect_reason = i32; + if (priv->disconnect_reason != 0) + _LOGW ("connection disconnected (reason %d)", priv->disconnect_reason); + } + + g_object_thaw_notify (G_OBJECT (self)); +} + +static void +on_iface_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_free_error GError *error = NULL; + + if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + self = NM_SUPPLICANT_INTERFACE (user_data); + _LOGW ("failed to acquire wpa_supplicant interface proxy: (%s)", error->message); + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); + } + return; + } + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + _nm_dbus_signal_connect (priv->iface_proxy, "ScanDone", G_VARIANT_TYPE ("(b)"), + G_CALLBACK (wpas_iface_scan_done), self); + _nm_dbus_signal_connect (priv->iface_proxy, "BSSAdded", G_VARIANT_TYPE ("(oa{sv})"), + G_CALLBACK (wpas_iface_bss_added), self); + _nm_dbus_signal_connect (priv->iface_proxy, "BSSRemoved", G_VARIANT_TYPE ("(o)"), + G_CALLBACK (wpas_iface_bss_removed), self); + _nm_dbus_signal_connect (priv->iface_proxy, "NetworkRequest", G_VARIANT_TYPE ("(oss)"), + G_CALLBACK (wpas_iface_network_request), self); + + /* Scan result aging parameters */ + g_dbus_proxy_call (priv->iface_proxy, + "org.freedesktop.DBus.Properties.Set", + g_variant_new ("(ssv)", + WPAS_DBUS_IFACE_INTERFACE, + "BSSExpireAge", + g_variant_new_uint32 (250)), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + NULL, + NULL); + g_dbus_proxy_call (priv->iface_proxy, + "org.freedesktop.DBus.Properties.Set", + g_variant_new ("(ssv)", + WPAS_DBUS_IFACE_INTERFACE, + "BSSExpireCount", + g_variant_new_uint32 (2)), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + NULL, + NULL); + + /* Check whether NetworkReply and AP mode are supported */ + priv->ready_count = 1; + g_dbus_proxy_call (priv->iface_proxy, + "NetworkReply", + g_variant_new ("(oss)", + "/fff", + "foobar", + "foobar"), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + (GAsyncReadyCallback) iface_check_netreply_cb, + self); + + if (priv->ap_support == NM_SUPPLICANT_FEATURE_UNKNOWN || + priv->mac_randomization_support == NM_SUPPLICANT_FEATURE_UNKNOWN) { + /* If the global supplicant capabilities property is not present, we can + * fall back to checking whether the ProbeRequest method is supported. If + * neither of these works we have no way of determining if AP mode is + * supported or not. hostap 1.0 and earlier don't support either of these. + */ + priv->ready_count++; + g_dbus_proxy_call (priv->iface_proxy, + DBUS_INTERFACE_INTROSPECTABLE ".Introspect", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + (GAsyncReadyCallback) iface_introspect_cb, + self); + } +} + +static void +interface_add_done (NMSupplicantInterface *self, const char *path) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + _LOGD ("interface added to supplicant"); + + priv->object_path = g_strdup (path); + priv->iface_proxy = g_object_new (G_TYPE_DBUS_PROXY, + "g-bus-type", G_BUS_TYPE_SYSTEM, + "g-flags", G_DBUS_PROXY_FLAGS_NONE, + "g-name", WPAS_DBUS_SERVICE, + "g-object-path", priv->object_path, + "g-interface-name", WPAS_DBUS_IFACE_INTERFACE, + NULL); + g_signal_connect (priv->iface_proxy, "g-properties-changed", G_CALLBACK (props_changed_cb), self); + g_async_initable_init_async (G_ASYNC_INITABLE (priv->iface_proxy), + G_PRIORITY_DEFAULT, + priv->init_cancellable, + (GAsyncReadyCallback) on_iface_proxy_acquired, + self); +} + +static void +interface_get_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; + const char *path; + + variant = _nm_dbus_proxy_call_finish (proxy, result, + G_VARIANT_TYPE ("(o)"), + &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (variant) { + g_variant_get (variant, "(&o)", &path); + interface_add_done (self, path); + } else { + g_dbus_error_strip_remote_error (error); + _LOGE ("error getting interface: %s", error->message); + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); + } +} + +static void +interface_add_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *variant = NULL; + const char *path; + + variant = _nm_dbus_proxy_call_finish (proxy, result, + G_VARIANT_TYPE ("(o)"), + &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (variant) { + g_variant_get (variant, "(&o)", &path); + interface_add_done (self, path); + } else if (_nm_dbus_error_has_name (error, WPAS_ERROR_EXISTS_ERROR)) { + /* Interface already added, just get its object path */ + g_dbus_proxy_call (priv->wpas_proxy, + "GetInterface", + g_variant_new ("(s)", priv->dev), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + (GAsyncReadyCallback) interface_get_cb, + self); + } else if ( g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_EXEC_FAILED) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_FORK_FAILED) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_FAILED) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_TIMEOUT) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NO_REPLY) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_TIMED_OUT) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND)) { + /* Supplicant wasn't running and could not be launched via service + * activation. Wait for it to start by moving back to the INIT + * state. + */ + g_dbus_error_strip_remote_error (error); + _LOGD ("failed to activate supplicant: %s", error->message); + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_INIT); + } else { + g_dbus_error_strip_remote_error (error); + _LOGE ("error adding interface: %s", error->message); + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); + } +} + +#if HAVE_WEXT +#define DEFAULT_WIFI_DRIVER "nl80211,wext" +#else +#define DEFAULT_WIFI_DRIVER "nl80211" +#endif + +static void +on_wpas_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_free_error GError *error = NULL; + GDBusProxy *wpas_proxy; + GVariantBuilder props; + const char *driver_name = NULL; + + wpas_proxy = g_dbus_proxy_new_for_bus_finish (result, &error); + if (!wpas_proxy) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + self = NM_SUPPLICANT_INTERFACE (user_data); + _LOGW ("failed to acquire wpa_supplicant proxy: (%s)", error->message); + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); + } + return; + } + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + priv->wpas_proxy = wpas_proxy; + + /* Try to add the interface to the supplicant. If the supplicant isn't + * running, this will start it via D-Bus activation and return the response + * when the supplicant has started. + */ + + switch (priv->driver) { + case NM_SUPPLICANT_DRIVER_WIRELESS: + driver_name = DEFAULT_WIFI_DRIVER; + break; + case NM_SUPPLICANT_DRIVER_WIRED: + driver_name = "wired"; + break; + case NM_SUPPLICANT_DRIVER_MACSEC: + driver_name = "macsec_linux"; + break; + } + + g_return_if_fail (driver_name); + + g_variant_builder_init (&props, G_VARIANT_TYPE_VARDICT); + g_variant_builder_add (&props, "{sv}", + "Driver", + g_variant_new_string (driver_name)); + g_variant_builder_add (&props, "{sv}", + "Ifname", + g_variant_new_string (priv->dev)); + + g_dbus_proxy_call (priv->wpas_proxy, + "CreateInterface", + g_variant_new ("(a{sv})", &props), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + (GAsyncReadyCallback) interface_add_cb, + self); +} + +static void +interface_add (NMSupplicantInterface *self) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* Can only start the interface from INIT state */ + g_return_if_fail (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT); + + _LOGD ("adding interface to supplicant"); + + /* Move to starting to prevent double-calls of interface_add() */ + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_STARTING); + + g_warn_if_fail (priv->init_cancellable == NULL); + g_clear_object (&priv->init_cancellable); + priv->init_cancellable = g_cancellable_new (); + + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | + G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, + NULL, + WPAS_DBUS_SERVICE, + WPAS_DBUS_PATH, + WPAS_DBUS_INTERFACE, + priv->init_cancellable, + (GAsyncReadyCallback) on_wpas_proxy_acquired, + self); +} + +void +nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self, + gboolean available) +{ + NMSupplicantInterfacePrivate *priv; + + g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (available) { + /* This can happen if the supplicant couldn't be activated but + * for some reason was started after the activation failure. + */ + if (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT) + interface_add (self); + } else { + /* The supplicant stopped; so we must tear down the interface */ + set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN); + } +} + +static void +log_result_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if ( !reply + && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) + && !strstr (error->message, "fi.w1.wpa_supplicant1.NotConnected")) { + g_dbus_error_strip_remote_error (error); + nm_log_warn (_NMLOG_DOMAIN, "%s: failed to %s: %s", + _NMLOG_PREFIX_NAME, (const char *) user_data, error->message); + } +} + +void +nm_supplicant_interface_disconnect (NMSupplicantInterface * self) +{ + NMSupplicantInterfacePrivate *priv; + + g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* Cancel all pending calls related to a prior connection attempt */ + if (priv->assoc_cancellable) { + g_cancellable_cancel (priv->assoc_cancellable); + g_clear_object (&priv->assoc_cancellable); + } + + /* Don't do anything if there is no connection to the supplicant yet. */ + if (!priv->iface_proxy) + return; + + /* Disconnect from the current AP */ + if ( (priv->state >= NM_SUPPLICANT_INTERFACE_STATE_SCANNING) + && (priv->state <= NM_SUPPLICANT_INTERFACE_STATE_COMPLETED)) { + g_dbus_proxy_call (priv->iface_proxy, + "Disconnect", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + (GAsyncReadyCallback) log_result_cb, + "disconnect"); + } + + /* Remove any network that was added by NetworkManager */ + if (priv->net_path) { + g_dbus_proxy_call (priv->iface_proxy, + "RemoveNetwork", + g_variant_new ("(o)", priv->net_path), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->other_cancellable, + (GAsyncReadyCallback) log_result_cb, + "remove network"); + g_free (priv->net_path); + priv->net_path = NULL; + } +} + +static void +select_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if ( !reply + && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + self = NM_SUPPLICANT_INTERFACE (user_data); + g_dbus_error_strip_remote_error (error); + _LOGW ("couldn't select network config: %s", error->message); + emit_error_helper (self, error); + } +} + +static void +call_select_network (NMSupplicantInterface *self) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* We only select the network after all blobs (if any) have been set */ + if (priv->blobs_left == 0) { + g_dbus_proxy_call (priv->iface_proxy, + "SelectNetwork", + g_variant_new ("(o)", priv->net_path), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->assoc_cancellable, + (GAsyncReadyCallback) select_network_cb, + self); + } +} + +static void +add_blob_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + priv->blobs_left--; + if (reply) + call_select_network (self); + else { + g_dbus_error_strip_remote_error (error); + _LOGW ("couldn't set network certificates: %s", error->message); + emit_error_helper (self, error); + } +} + +static void +add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + GHashTable *blobs; + GHashTableIter iter; + const char *blob_name; + GByteArray *blob_data; + + reply = _nm_dbus_proxy_call_finish (proxy, result, + G_VARIANT_TYPE ("(o)"), + &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + g_free (priv->net_path); + priv->net_path = NULL; + + if (error) { + g_dbus_error_strip_remote_error (error); + _LOGW ("adding network to supplicant failed: %s", error->message); + emit_error_helper (self, error); + return; + } + + g_variant_get (reply, "(o)", &priv->net_path); + + /* Send blobs first; otherwise jump to selecting the network */ + blobs = nm_supplicant_config_get_blobs (priv->cfg); + priv->blobs_left = g_hash_table_size (blobs); + + g_hash_table_iter_init (&iter, blobs); + while (g_hash_table_iter_next (&iter, (gpointer) &blob_name, (gpointer) &blob_data)) { + g_dbus_proxy_call (priv->iface_proxy, + "AddBlob", + g_variant_new ("(s@ay)", + blob_name, + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + blob_data->data, blob_data->len, 1)), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->assoc_cancellable, + (GAsyncReadyCallback) add_blob_cb, + self); + } + + call_select_network (self); +} + +static void +add_network (NMSupplicantInterface *self) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + g_dbus_proxy_call (priv->iface_proxy, + "AddNetwork", + g_variant_new ("(@a{sv})", nm_supplicant_config_to_variant (priv->cfg)), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->assoc_cancellable, + (GAsyncReadyCallback) add_network_cb, + self); +} + +static void +set_mac_randomization_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (!reply) { + g_dbus_error_strip_remote_error (error); + _LOGW ("couldn't send MAC randomization mode to the supplicant interface: %s", + error->message); + emit_error_helper (self, error); + return; + } + + _LOGT ("config: set MAC randomization to 0"); + add_network (self); +} + +static void +set_ap_scan_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + NMSupplicantInterfacePrivate *priv; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + if (!reply) { + g_dbus_error_strip_remote_error (error); + _LOGW ("couldn't send AP scan mode to the supplicant interface: %s", + error->message); + emit_error_helper (self, error); + return; + } + + _LOGI ("config: set interface ap_scan to %d", + nm_supplicant_config_get_ap_scan (priv->cfg)); + + if (priv->mac_randomization_support == NM_SUPPLICANT_FEATURE_YES) { + /* Enable/disable association MAC address randomization */ + g_dbus_proxy_call (priv->iface_proxy, + DBUS_INTERFACE_PROPERTIES ".Set", + g_variant_new ("(ssv)", + WPAS_DBUS_IFACE_INTERFACE, + "MacAddr", + g_variant_new_string ("0")), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->assoc_cancellable, + (GAsyncReadyCallback) set_mac_randomization_cb, + self); + } else + add_network (self); +} + +gboolean +nm_supplicant_interface_set_config (NMSupplicantInterface *self, + NMSupplicantConfig *cfg, + GError **error) +{ + NMSupplicantInterfacePrivate *priv; + + g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + nm_supplicant_interface_disconnect (self); + + /* Make sure the supplicant supports EAP-FAST before trying to send + * it an EAP-FAST configuration. + */ + if (nm_supplicant_config_fast_required (cfg) && !priv->fast_supported) { + g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, + "EAP-FAST is not supported by the supplicant"); + return FALSE; + } + + g_clear_object (&priv->cfg); + if (cfg) { + priv->assoc_cancellable = g_cancellable_new (); + priv->cfg = g_object_ref (cfg); + g_dbus_proxy_call (priv->iface_proxy, + DBUS_INTERFACE_PROPERTIES ".Set", + g_variant_new ("(ssv)", + WPAS_DBUS_IFACE_INTERFACE, + "ApScan", + g_variant_new_uint32 (nm_supplicant_config_get_ap_scan (priv->cfg))), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->assoc_cancellable, + (GAsyncReadyCallback) set_ap_scan_cb, + self); + } + return TRUE; +} + +static void +scan_request_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantInterface *self; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_SUPPLICANT_INTERFACE (user_data); + + if (error) { + if (_nm_dbus_error_has_name (error, "fi.w1.wpa_supplicant1.Interface.ScanError")) + _LOGD ("could not get scan request result: %s", error->message); + else { + g_dbus_error_strip_remote_error (error); + _LOGW ("could not get scan request result: %s", error->message); + } + } + g_signal_emit (self, signals[SCAN_DONE], 0, error ? FALSE : TRUE); +} + +gboolean +nm_supplicant_interface_request_scan (NMSupplicantInterface *self, const GPtrArray *ssids) +{ + NMSupplicantInterfacePrivate *priv; + GVariantBuilder builder; + guint i; + + g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* Scan parameters */ + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + g_variant_builder_add (&builder, "{sv}", "Type", g_variant_new_string ("active")); + if (ssids) { + GVariantBuilder ssids_builder; + + g_variant_builder_init (&ssids_builder, G_VARIANT_TYPE_BYTESTRING_ARRAY); + for (i = 0; i < ssids->len; i++) { + GByteArray *ssid = g_ptr_array_index (ssids, i); + g_variant_builder_add (&ssids_builder, "@ay", + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + ssid->data, ssid->len, 1)); + } + g_variant_builder_add (&builder, "{sv}", "SSIDs", g_variant_builder_end (&ssids_builder)); + } + + g_dbus_proxy_call (priv->iface_proxy, + "Scan", + g_variant_new ("(a{sv})", &builder), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->other_cancellable, + (GAsyncReadyCallback) scan_request_cb, + self); + return TRUE; +} + +guint32 +nm_supplicant_interface_get_state (NMSupplicantInterface * self) +{ + g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NM_SUPPLICANT_INTERFACE_STATE_DOWN); + + return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->state; +} + +const char * +nm_supplicant_interface_state_to_string (guint32 state) +{ + switch (state) { + case NM_SUPPLICANT_INTERFACE_STATE_INIT: + return "init"; + case NM_SUPPLICANT_INTERFACE_STATE_STARTING: + return "starting"; + case NM_SUPPLICANT_INTERFACE_STATE_READY: + return "ready"; + case NM_SUPPLICANT_INTERFACE_STATE_DISABLED: + return "disabled"; + case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED: + return "disconnected"; + case NM_SUPPLICANT_INTERFACE_STATE_INACTIVE: + return "inactive"; + case NM_SUPPLICANT_INTERFACE_STATE_SCANNING: + return "scanning"; + case NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING: + return "authenticating"; + case NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING: + return "associating"; + case NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED: + return "associated"; + case NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE: + return "4-way handshake"; + case NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE: + return "group handshake"; + case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED: + return "completed"; + case NM_SUPPLICANT_INTERFACE_STATE_DOWN: + return "down"; + default: + break; + } + return "unknown"; +} + +const char * +nm_supplicant_interface_get_object_path (NMSupplicantInterface *self) +{ + g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL); + + return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->object_path; +} + +const char * +nm_supplicant_interface_get_ifname (NMSupplicantInterface *self) +{ + g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), NULL); + + return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev; +} + +guint +nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self) +{ + g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), 0); + + return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->max_scan_ssids; +} + +/*****************************************************************************/ + +NMSupplicantInterface * +nm_supplicant_interface_new (const char *ifname, + NMSupplicantDriver driver, + gboolean fast_supported, + NMSupplicantFeature ap_support) +{ + g_return_val_if_fail (ifname != NULL, NULL); + + return g_object_new (NM_TYPE_SUPPLICANT_INTERFACE, + NM_SUPPLICANT_INTERFACE_IFACE, ifname, + NM_SUPPLICANT_INTERFACE_DRIVER, (guint) driver, + NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, fast_supported, + NM_SUPPLICANT_INTERFACE_AP_SUPPORT, (int) ap_support, + NULL); +} + +static void +nm_supplicant_interface_init (NMSupplicantInterface * self) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + priv->state = NM_SUPPLICANT_INTERFACE_STATE_INIT; + priv->bss_proxies = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE ((NMSupplicantInterface *) object); + + switch (prop_id) { + case PROP_IFACE: + /* construct-only */ + priv->dev = g_value_dup_string (value); + g_return_if_fail (priv->dev); + break; + case PROP_DRIVER: + /* construct-only */ + priv->driver = g_value_get_uint (value); + break; + case PROP_FAST_SUPPORTED: + /* construct-only */ + priv->fast_supported = g_value_get_boolean (value); + break; + case PROP_AP_SUPPORT: + /* construct-only */ + priv->ap_support = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE ((NMSupplicantInterface *) object); + + switch (prop_id) { + case PROP_SCANNING: + g_value_set_boolean (value, priv->scanning); + break; + case PROP_CURRENT_BSS: + g_value_set_string (value, priv->current_bss); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE ((NMSupplicantInterface *) object); + + if (priv->iface_proxy) + g_signal_handlers_disconnect_by_data (priv->iface_proxy, object); + g_clear_object (&priv->iface_proxy); + + nm_clear_g_cancellable (&priv->init_cancellable); + nm_clear_g_cancellable (&priv->other_cancellable); + nm_clear_g_cancellable (&priv->assoc_cancellable); + + g_clear_object (&priv->wpas_proxy); + g_clear_pointer (&priv->bss_proxies, (GDestroyNotify) g_hash_table_destroy); + + g_clear_pointer (&priv->net_path, g_free); + g_clear_pointer (&priv->dev, g_free); + g_clear_pointer (&priv->object_path, g_free); + g_clear_pointer (&priv->current_bss, g_free); + + g_clear_object (&priv->cfg); + + /* Chain up to the parent class */ + G_OBJECT_CLASS (nm_supplicant_interface_parent_class)->dispose (object); +} + +static void +nm_supplicant_interface_class_init (NMSupplicantInterfaceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = dispose; + object_class->set_property = set_property; + object_class->get_property = get_property; + + obj_properties[PROP_SCANNING] = + g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_SCANNING, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_CURRENT_BSS] = + g_param_spec_string (NM_SUPPLICANT_INTERFACE_CURRENT_BSS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_IFACE] = + g_param_spec_string (NM_SUPPLICANT_INTERFACE_IFACE, "", "", + NULL, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_DRIVER] = + g_param_spec_uint (NM_SUPPLICANT_INTERFACE_DRIVER, "", "", + 0, G_MAXUINT, NM_SUPPLICANT_DRIVER_WIRELESS, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_FAST_SUPPORTED] = + g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, "", "", + TRUE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_AP_SUPPORT] = + g_param_spec_int (NM_SUPPLICANT_INTERFACE_AP_SUPPORT, "", "", + NM_SUPPLICANT_FEATURE_UNKNOWN, + NM_SUPPLICANT_FEATURE_YES, + NM_SUPPLICANT_FEATURE_UNKNOWN, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + signals[STATE] = + g_signal_new (NM_SUPPLICANT_INTERFACE_STATE, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT); + + signals[REMOVED] = + g_signal_new (NM_SUPPLICANT_INTERFACE_REMOVED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 0); + + signals[NEW_BSS] = + g_signal_new (NM_SUPPLICANT_INTERFACE_NEW_BSS, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT); + + signals[BSS_UPDATED] = + g_signal_new (NM_SUPPLICANT_INTERFACE_BSS_UPDATED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT); + + signals[BSS_REMOVED] = + g_signal_new (NM_SUPPLICANT_INTERFACE_BSS_REMOVED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_STRING); + + signals[SCAN_DONE] = + g_signal_new (NM_SUPPLICANT_INTERFACE_SCAN_DONE, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + signals[CONNECTION_ERROR] = + g_signal_new (NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + + signals[CREDENTIALS_REQUEST] = + g_signal_new (NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); +} + diff --git a/src/supplicant/nm-supplicant-interface.h b/src/supplicant/nm-supplicant-interface.h new file mode 100644 index 00000000..5ab66d5d --- /dev/null +++ b/src/supplicant/nm-supplicant-interface.h @@ -0,0 +1,122 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#ifndef __NETWORKMANAGER_SUPPLICANT_INTERFACE_H__ +#define __NETWORKMANAGER_SUPPLICANT_INTERFACE_H__ + +#include "nm-supplicant-types.h" + +/* + * Supplicant interface states + * A mix of wpa_supplicant interface states and internal states. + */ +enum { + NM_SUPPLICANT_INTERFACE_STATE_INIT = 0, + NM_SUPPLICANT_INTERFACE_STATE_STARTING, + NM_SUPPLICANT_INTERFACE_STATE_READY, + NM_SUPPLICANT_INTERFACE_STATE_DISABLED, + NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED, + NM_SUPPLICANT_INTERFACE_STATE_INACTIVE, + NM_SUPPLICANT_INTERFACE_STATE_SCANNING, + NM_SUPPLICANT_INTERFACE_STATE_AUTHENTICATING, + NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING, + NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED, + NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE, + NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE, + NM_SUPPLICANT_INTERFACE_STATE_COMPLETED, + NM_SUPPLICANT_INTERFACE_STATE_DOWN, + NM_SUPPLICANT_INTERFACE_STATE_LAST +}; + +#define NM_TYPE_SUPPLICANT_INTERFACE (nm_supplicant_interface_get_type ()) +#define NM_SUPPLICANT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterface)) +#define NM_SUPPLICANT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterfaceClass)) +#define NM_IS_SUPPLICANT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SUPPLICANT_INTERFACE)) +#define NM_IS_SUPPLICANT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_INTERFACE)) +#define NM_SUPPLICANT_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterfaceClass)) + +/* Properties */ +#define NM_SUPPLICANT_INTERFACE_IFACE "iface" +#define NM_SUPPLICANT_INTERFACE_SCANNING "scanning" +#define NM_SUPPLICANT_INTERFACE_CURRENT_BSS "current-bss" +#define NM_SUPPLICANT_INTERFACE_DRIVER "driver" +#define NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED "fast-supported" +#define NM_SUPPLICANT_INTERFACE_AP_SUPPORT "ap-support" + +/* Signals */ +#define NM_SUPPLICANT_INTERFACE_STATE "state" +#define NM_SUPPLICANT_INTERFACE_REMOVED "removed" +#define NM_SUPPLICANT_INTERFACE_NEW_BSS "new-bss" +#define NM_SUPPLICANT_INTERFACE_BSS_UPDATED "bss-updated" +#define NM_SUPPLICANT_INTERFACE_BSS_REMOVED "bss-removed" +#define NM_SUPPLICANT_INTERFACE_SCAN_DONE "scan-done" +#define NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR "connection-error" +#define NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST "credentials-request" + +typedef struct _NMSupplicantInterfaceClass NMSupplicantInterfaceClass; + +GType nm_supplicant_interface_get_type (void); + +NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname, + NMSupplicantDriver driver, + gboolean fast_supported, + NMSupplicantFeature ap_support); + +void nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self, + gboolean available); + +gboolean nm_supplicant_interface_set_config (NMSupplicantInterface * iface, + NMSupplicantConfig * cfg, + GError **error); + +void nm_supplicant_interface_disconnect (NMSupplicantInterface * iface); + +const char *nm_supplicant_interface_get_object_path (NMSupplicantInterface * iface); + +gboolean nm_supplicant_interface_request_scan (NMSupplicantInterface * self, const GPtrArray *ssids); + +guint32 nm_supplicant_interface_get_state (NMSupplicantInterface * self); + +const char *nm_supplicant_interface_state_to_string (guint32 state); + +gboolean nm_supplicant_interface_get_scanning (NMSupplicantInterface *self); + +const char *nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self); + +gint32 nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self); + +const char *nm_supplicant_interface_get_ifname (NMSupplicantInterface *self); + +guint nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self); + +gboolean nm_supplicant_interface_get_has_credentials_request (NMSupplicantInterface *self); + +gboolean nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self, + const char *field, + const char *value, + GError **error); + +NMSupplicantFeature nm_supplicant_interface_get_ap_support (NMSupplicantInterface *self); + +void nm_supplicant_interface_set_ap_support (NMSupplicantInterface *self, + NMSupplicantFeature apmode); + +#endif /* NM_SUPPLICANT_INTERFACE_H */ diff --git a/src/supplicant/nm-supplicant-manager.c b/src/supplicant/nm-supplicant-manager.c new file mode 100644 index 00000000..2fbfa391 --- /dev/null +++ b/src/supplicant/nm-supplicant-manager.c @@ -0,0 +1,413 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2010 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#include "nm-default.h" + +#include "nm-supplicant-manager.h" + +#include + +#include "nm-supplicant-interface.h" +#include "nm-supplicant-types.h" +#include "nm-core-internal.h" + +/*****************************************************************************/ + +typedef struct { + GDBusProxy * proxy; + GCancellable * cancellable; + gboolean running; + + GSList *ifaces; + gboolean fast_supported; + NMSupplicantFeature ap_support; + guint die_count_reset_id; + guint die_count; +} NMSupplicantManagerPrivate; + +struct _NMSupplicantManager { + GObject parent; + NMSupplicantManagerPrivate _priv; +}; + +struct _NMSupplicantManagerClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMSupplicantManager, nm_supplicant_manager, G_TYPE_OBJECT) + +#define NM_SUPPLICANT_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSupplicantManager, NM_IS_SUPPLICANT_MANAGER) + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SUPPLICANT +#define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "supplicant", __VA_ARGS__) + +/*****************************************************************************/ + +G_DEFINE_QUARK (nm-supplicant-error-quark, nm_supplicant_error); + +/*****************************************************************************/ + +static inline gboolean +die_count_exceeded (guint32 count) +{ + return count > 2; +} + +static gboolean +is_available (NMSupplicantManager *self) +{ + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + + return priv->running + && !die_count_exceeded (priv->die_count); +} + +/*****************************************************************************/ + +static void +_sup_iface_last_ref (gpointer data, + GObject *object, + gboolean is_last_ref) +{ + NMSupplicantManager *self = data; + NMSupplicantManagerPrivate *priv; + NMSupplicantInterface *sup_iface = (NMSupplicantInterface *) object; + const char *op; + + g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self)); + g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (sup_iface)); + g_return_if_fail (is_last_ref); + + priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + + if (!g_slist_find (priv->ifaces, sup_iface)) + g_return_if_reached (); + + /* Ask wpa_supplicant to remove this interface */ + if ( priv->running + && priv->proxy + && (op = nm_supplicant_interface_get_object_path (sup_iface))) { + g_dbus_proxy_call (priv->proxy, + "RemoveInterface", + g_variant_new ("(o)", op), + G_DBUS_CALL_FLAGS_NONE, + 3000, + NULL, + NULL, + NULL); + } + + priv->ifaces = g_slist_remove (priv->ifaces, sup_iface); + g_object_remove_toggle_ref ((GObject *) sup_iface, _sup_iface_last_ref, self); +} + +/** + * nm_supplicant_manager_create_interface: + * @self: the #NMSupplicantManager + * @ifname: the interface for which to obtain the supplicant interface + * @is_wireless: whether the interface is supposed to be wireless. + * + * Note: the manager owns a reference to the instance and the only way to + * get the manager to release it, is by dropping all other references + * to the supplicant-interface (or destroying the manager). + * + * Returns: (transfer full): returns a #NMSupplicantInterface or %NULL. + * Must be unrefed at the end. + * */ +NMSupplicantInterface * +nm_supplicant_manager_create_interface (NMSupplicantManager *self, + const char *ifname, + NMSupplicantDriver driver) +{ + NMSupplicantManagerPrivate *priv; + NMSupplicantInterface *iface; + GSList *ifaces; + + g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL); + g_return_val_if_fail (ifname != NULL, NULL); + + priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + + _LOGD ("(%s): creating new supplicant interface", ifname); + + /* assert against not requesting duplicate interfaces. */ + for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) { + if (g_strcmp0 (nm_supplicant_interface_get_ifname (ifaces->data), ifname) == 0) + g_return_val_if_reached (NULL); + } + + iface = nm_supplicant_interface_new (ifname, + driver, + priv->fast_supported, + priv->ap_support); + + priv->ifaces = g_slist_prepend (priv->ifaces, iface); + g_object_add_toggle_ref ((GObject *) iface, _sup_iface_last_ref, self); + + /* If we're making the supplicant take a time out for a bit, don't + * let the supplicant interface start immediately, just let it hang + * around in INIT state until we're ready to talk to the supplicant + * again. + */ + if (is_available (self)) + nm_supplicant_interface_set_supplicant_available (iface, TRUE); + + return iface; +} + +static void +update_capabilities (NMSupplicantManager *self) +{ + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + GSList *ifaces; + const char **array; + GVariant *value; + + /* The supplicant only advertises global capabilities if the following + * commit has been applied: + * + * commit 1634ac0654eba8d458640a115efc0a6cde3bac4d + * Author: Dan Williams + * Date: Sat Sep 29 19:06:30 2012 +0300 + * + * dbus: Add global capabilities property + */ + priv->ap_support = NM_SUPPLICANT_FEATURE_UNKNOWN; + + value = g_dbus_proxy_get_cached_property (priv->proxy, "Capabilities"); + if (value) { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) { + array = g_variant_get_strv (value, NULL); + priv->ap_support = NM_SUPPLICANT_FEATURE_NO; + if (array) { + if (g_strv_contains (array, "ap")) + priv->ap_support = NM_SUPPLICANT_FEATURE_YES; + g_free (array); + } + } + g_variant_unref (value); + } + + /* Tell all interfaces about results of the AP check */ + for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) + nm_supplicant_interface_set_ap_support (ifaces->data, priv->ap_support); + + _LOGD ("AP mode is %ssupported", + (priv->ap_support == NM_SUPPLICANT_FEATURE_YES) ? "" : + (priv->ap_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly "); + + /* EAP-FAST */ + priv->fast_supported = FALSE; + value = g_dbus_proxy_get_cached_property (priv->proxy, "EapMethods"); + if (value) { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) { + array = g_variant_get_strv (value, NULL); + if (array) { + if (g_strv_contains (array, "fast")) + priv->fast_supported = TRUE; + g_free (array); + } + } + g_variant_unref (value); + } + + _LOGD ("EAP-FAST is %ssupported", priv->fast_supported ? "" : "not "); +} + +static void +availability_changed (NMSupplicantManager *self, gboolean available) +{ + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + GSList *ifaces, *iter; + + if (!priv->ifaces) + return; + + /* setting the supplicant as unavailable might cause the caller to unref + * the supplicant (and thus remove the instance from the list of interfaces. + * Delay that by taking an additional reference first. */ + ifaces = g_slist_copy (priv->ifaces); + for (iter = ifaces; iter; iter = iter->next) + g_object_ref (iter->data); + for (iter = ifaces; iter; iter = iter->next) + nm_supplicant_interface_set_supplicant_available (iter->data, available); + g_slist_free_full (ifaces, g_object_unref); +} + +static void +set_running (NMSupplicantManager *self, gboolean now_running) +{ + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + gboolean old_available = is_available (self); + gboolean new_available; + + priv->running = now_running; + new_available = is_available (self); + if (old_available != new_available) + availability_changed (self, new_available); +} + +static void +set_die_count (NMSupplicantManager *self, guint new_die_count) +{ + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + gboolean old_available = is_available (self); + gboolean new_available; + + priv->die_count = new_die_count; + new_available = is_available (self); + if (old_available != new_available) + availability_changed (self, new_available); +} + +static gboolean +wpas_die_count_reset_cb (gpointer user_data) +{ + NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data); + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + + /* Reset the die count back to zero, which allows use of the supplicant again */ + priv->die_count_reset_id = 0; + set_die_count (self, 0); + _LOGI ("wpa_supplicant die count reset"); + return FALSE; +} + +static void +name_owner_cb (GDBusProxy *proxy, GParamSpec *pspec, gpointer user_data) +{ + NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data); + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + char *owner; + + g_return_if_fail (proxy == priv->proxy); + + owner = g_dbus_proxy_get_name_owner (proxy); + _LOGI ("wpa_supplicant %s", owner ? "running" : "stopped"); + + if (owner) { + set_running (self, TRUE); + update_capabilities (self); + } else if (priv->running) { + /* Reschedule the die count reset timeout. Every time the supplicant + * dies we wait 10 seconds before resetting the counter. If the + * supplicant died more than twice before the timer is reset, then + * we don't try to talk to the supplicant for a while. + */ + if (priv->die_count_reset_id) + g_source_remove (priv->die_count_reset_id); + priv->die_count_reset_id = g_timeout_add_seconds (10, wpas_die_count_reset_cb, self); + set_die_count (self, priv->die_count + 1); + + if (die_count_exceeded (priv->die_count)) { + _LOGI ("wpa_supplicant die count %d; ignoring for 10 seconds", + priv->die_count); + } + + set_running (self, FALSE); + + priv->fast_supported = FALSE; + } + + g_free (owner); +} + +static void +on_proxy_acquired (GObject *object, GAsyncResult *result, gpointer user_data) +{ + NMSupplicantManager *self; + NMSupplicantManagerPrivate *priv; + GError *error = NULL; + GDBusProxy *proxy; + + proxy = g_dbus_proxy_new_for_bus_finish (result, &error); + if (!proxy) { + _LOGW ("failed to acquire wpa_supplicant proxy: Wi-Fi and 802.1x will not be available (%s)", + error->message); + g_clear_error (&error); + return; + } + + self = NM_SUPPLICANT_MANAGER (user_data); + priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + + priv->proxy = proxy; + g_signal_connect (priv->proxy, "notify::g-name-owner", G_CALLBACK (name_owner_cb), self); + name_owner_cb (priv->proxy, NULL, self); +} + +/*****************************************************************************/ + +NM_DEFINE_SINGLETON_GETTER (NMSupplicantManager, nm_supplicant_manager_get, NM_TYPE_SUPPLICANT_MANAGER); + +static void +nm_supplicant_manager_init (NMSupplicantManager *self) +{ + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + + priv->cancellable = g_cancellable_new (); + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + WPAS_DBUS_SERVICE, + WPAS_DBUS_PATH, + WPAS_DBUS_INTERFACE, + priv->cancellable, + (GAsyncReadyCallback) on_proxy_acquired, + self); +} + +static void +dispose (GObject *object) +{ + NMSupplicantManager *self = (NMSupplicantManager *) object; + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + GSList *ifaces; + + nm_clear_g_source (&priv->die_count_reset_id); + + if (priv->cancellable) { + g_cancellable_cancel (priv->cancellable); + g_clear_object (&priv->cancellable); + } + + if (priv->ifaces) { + for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) + g_object_remove_toggle_ref (ifaces->data, _sup_iface_last_ref, self); + g_slist_free (priv->ifaces); + priv->ifaces = NULL; + } + + g_clear_object (&priv->proxy); + + G_OBJECT_CLASS (nm_supplicant_manager_parent_class)->dispose (object); +} + +static void +nm_supplicant_manager_class_init (NMSupplicantManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = dispose; +} + diff --git a/src/supplicant/nm-supplicant-manager.h b/src/supplicant/nm-supplicant-manager.h new file mode 100644 index 00000000..8928cf20 --- /dev/null +++ b/src/supplicant/nm-supplicant-manager.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#ifndef __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ +#define __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ + +#include "nm-supplicant-types.h" +#include "devices/nm-device.h" + +#define NM_TYPE_SUPPLICANT_MANAGER (nm_supplicant_manager_get_type ()) +#define NM_SUPPLICANT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManager)) +#define NM_SUPPLICANT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManagerClass)) +#define NM_IS_SUPPLICANT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SUPPLICANT_MANAGER)) +#define NM_IS_SUPPLICANT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_MANAGER)) +#define NM_SUPPLICANT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManagerClass)) + +typedef struct _NMSupplicantManagerClass NMSupplicantManagerClass; + +GType nm_supplicant_manager_get_type (void); + +NMSupplicantManager *nm_supplicant_manager_get (void); + +NMSupplicantInterface *nm_supplicant_manager_create_interface (NMSupplicantManager *mgr, + const char *ifname, + NMSupplicantDriver driver); + +#endif /* __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ */ diff --git a/src/supplicant/nm-supplicant-settings-verify.c b/src/supplicant/nm-supplicant-settings-verify.c new file mode 100644 index 00000000..9e220808 --- /dev/null +++ b/src/supplicant/nm-supplicant-settings-verify.c @@ -0,0 +1,281 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2012 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-supplicant-settings-verify.h" + +#include +#include +#include +#include + +struct Opt { + const char * key; + const OptType type; + const gint32 int_low; /* Inclusive */ + const gint32 int_high; /* Inclusive; max length for strings */ + const gboolean str_allowed_multiple; + const char ** str_allowed; +}; + + +static gboolean validate_type_int (const struct Opt * opt, + const char * value, + const guint32 len); + +static gboolean validate_type_bytes (const struct Opt * opt, + const char * value, + const guint32 len); + +static gboolean validate_type_utf8 (const struct Opt *opt, + const char * value, + const guint32 len); + +static gboolean validate_type_keyword (const struct Opt * opt, + const char * value, + const guint32 len); + +typedef gboolean (*validate_func)(const struct Opt *, const char *, const guint32); + +struct validate_entry { + const OptType type; + const validate_func func; +}; + +static const struct validate_entry validate_table[] = { + { TYPE_INT, validate_type_int }, + { TYPE_BYTES, validate_type_bytes }, + { TYPE_UTF8, validate_type_utf8 }, + { TYPE_KEYWORD, validate_type_keyword }, +}; + + +const char * pairwise_allowed[] = { "CCMP", "TKIP", "NONE", NULL }; +const char * group_allowed[] = { "CCMP", "TKIP", "WEP104", "WEP40", NULL }; +const char * proto_allowed[] = { "WPA", "RSN", NULL }; +const char * key_mgmt_allowed[] = { "WPA-PSK", "WPA-EAP", "IEEE8021X", "WPA-NONE", + "NONE", NULL }; +const char * auth_alg_allowed[] = { "OPEN", "SHARED", "LEAP", NULL }; +const char * eap_allowed[] = { "LEAP", "MD5", "TLS", "PEAP", "TTLS", "SIM", + "PSK", "FAST", "PWD", NULL }; + +const char * phase1_allowed[] = {"peapver=0", "peapver=1", "peaplabel=1", + "peap_outer_success=0", "include_tls_length=1", + "sim_min_num_chal=3", "fast_provisioning=0", + "fast_provisioning=1", "fast_provisioning=2", + "fast_provisioning=3", NULL }; +const char * phase2_allowed[] = {"auth=PAP", "auth=CHAP", "auth=MSCHAP", + "auth=MSCHAPV2", "auth=GTC", "auth=OTP", + "auth=MD5", "auth=TLS", "autheap=MD5", + "autheap=MSCHAPV2", "autheap=OTP", + "autheap=GTC", "autheap=TLS", NULL }; + +static const struct Opt opt_table[] = { + { "ssid", TYPE_BYTES, 0, 32,FALSE, NULL }, + { "bssid", TYPE_KEYWORD, 0, 0, FALSE, NULL }, + { "scan_ssid", TYPE_INT, 0, 1, FALSE, NULL }, + { "mode", TYPE_INT, 0, 2, FALSE, NULL }, + { "frequency", TYPE_INT, 2412, 5825, FALSE, NULL }, + { "auth_alg", TYPE_KEYWORD, 0, 0, FALSE, auth_alg_allowed }, + { "psk", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "pairwise", TYPE_KEYWORD, 0, 0, FALSE, pairwise_allowed }, + { "group", TYPE_KEYWORD, 0, 0, FALSE, group_allowed }, + { "proto", TYPE_KEYWORD, 0, 0, FALSE, proto_allowed }, + { "key_mgmt", TYPE_KEYWORD, 0, 0, FALSE, key_mgmt_allowed }, + { "wep_key0", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "wep_key1", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "wep_key2", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "wep_key3", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "wep_tx_keyidx", TYPE_INT, 0, 3, FALSE, NULL }, + { "eapol_flags", TYPE_INT, 0, 3, FALSE, NULL }, + { "eap", TYPE_KEYWORD, 0, 0, FALSE, eap_allowed }, + { "identity", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "password", TYPE_UTF8, 0, 0, FALSE, NULL }, + { "ca_path", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "subject_match", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "altsubject_match", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "domain_suffix_match",TYPE_BYTES, 0, 0, FALSE, NULL }, + { "ca_cert", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "client_cert", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "private_key", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "private_key_passwd", TYPE_BYTES, 0, 1024, FALSE, NULL }, + { "phase1", TYPE_KEYWORD, 0, 0, TRUE, phase1_allowed }, + { "phase2", TYPE_KEYWORD, 0, 0, TRUE, phase2_allowed }, + { "anonymous_identity", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "ca_path2", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "subject_match2", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "altsubject_match2", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "domain_suffix_match2", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "ca_cert2", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "client_cert2", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "private_key2", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "private_key2_passwd",TYPE_BYTES, 0, 1024, FALSE, NULL }, + { "pin", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "pcsc", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "nai", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "eappsk", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "pac_file", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "engine", TYPE_INT, 0, 1, FALSE, NULL }, + { "engine_id", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "key_id", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "fragment_size", TYPE_INT, 1, 2000, FALSE, NULL }, + { "proactive_key_caching", TYPE_INT, 0, 1, FALSE, NULL }, + { "bgscan", TYPE_BYTES, 0, 0, FALSE, NULL }, + { "pac_file", TYPE_BYTES, 0, 1024, FALSE, NULL }, + { "freq_list", TYPE_KEYWORD, 0, 0, FALSE, NULL }, + { "macsec_policy", TYPE_INT, 0, 1, FALSE, NULL }, + { "macsec_integ_only", TYPE_INT, 0, 1, FALSE, NULL }, + { "mka_cak", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "mka_ckn", TYPE_BYTES, 0, 65536, FALSE, NULL }, + { "macsec_port", TYPE_INT, 1, 65534, FALSE, NULL }, +}; + + +static gboolean +validate_type_int (const struct Opt * opt, + const char * value, + const guint32 len) +{ + long int intval; + + g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + errno = 0; + intval = strtol (value, NULL, 10); + if (errno != 0) + return FALSE; + + /* strtol returns a long, but we are dealing with ints */ + if (intval > INT_MAX || intval < INT_MIN) + return FALSE; + if (intval > opt->int_high || intval < opt->int_low) + return FALSE; + + return TRUE; +} + +static gboolean +validate_type_bytes (const struct Opt * opt, + const char * value, + const guint32 len) +{ + guint32 check_len; + + g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + check_len = opt->int_high ? opt->int_high : 255; + if (len > check_len) + return FALSE; + + return TRUE; +} + +static gboolean +validate_type_utf8 (const struct Opt *opt, + const char * value, + const guint32 len) +{ + guint32 check_len; + + g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + check_len = opt->int_high ? opt->int_high : 255; + /* Note that we deliberately don't validate the UTF-8, because + some "UTF-8" fields, such as 8021x.password, do not actually + have to be valid UTF-8 */ + if (g_utf8_strlen (value, len) > check_len) + return FALSE; + + return TRUE; +} + +static gboolean +validate_type_keyword (const struct Opt * opt, + const char * value, + const guint32 len) +{ + char ** allowed; + gchar ** candidates = NULL; + char ** candidate; + gboolean found = FALSE; + + g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + /* Allow everything */ + if (!opt->str_allowed) + return TRUE; + + candidates = g_strsplit (value, " ", 0); + if (!candidates) + goto out; + + /* validate each space-separated word in 'value' */ + for (candidate = candidates; *candidate; candidate++) { + found = FALSE; + for (allowed = (char **) opt->str_allowed; *allowed; allowed++) { + if (strcmp (*candidate, *allowed) == 0) { + found = TRUE; + break; + } + } + if (!found) + break; + } + +out: + g_strfreev (candidates); + return found; +} + +OptType +nm_supplicant_settings_verify_setting (const char * key, + const char * value, + const guint32 len) +{ + OptType type = TYPE_INVALID; + int opt_count = sizeof (opt_table) / sizeof (opt_table[0]); + int val_count = sizeof (validate_table) / sizeof (validate_table[0]); + int i, j; + + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + for (i = 0; i < opt_count; i++) { + if (strcmp (opt_table[i].key, key) != 0) + continue; + + for (j = 0; j < val_count; j++) { + if (validate_table[j].type == opt_table[i].type) { + if ((*(validate_table[j].func))(&opt_table[i], value, len)) { + type = opt_table[i].type; + break; + } + } + } + } + + return type; +} + diff --git a/src/supplicant/nm-supplicant-settings-verify.h b/src/supplicant/nm-supplicant-settings-verify.h new file mode 100644 index 00000000..920343ba --- /dev/null +++ b/src/supplicant/nm-supplicant-settings-verify.h @@ -0,0 +1,38 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2008 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_SUPPLICANT_SETTINGS_VERIFY_H__ +#define __NETWORKMANAGER_SUPPLICANT_SETTINGS_VERIFY_H__ + +typedef enum { + TYPE_INVALID = 0, + TYPE_INT, + TYPE_BYTES, + TYPE_UTF8, + TYPE_KEYWORD, + TYPE_STRING +} OptType; + +OptType nm_supplicant_settings_verify_setting (const char * key, + const char * value, + const guint32 len); + + +#endif /* __NETWORKMANAGER_SUPPLICANT_SETTINGS_VERIFY_H__ */ diff --git a/src/supplicant/nm-supplicant-types.h b/src/supplicant/nm-supplicant-types.h new file mode 100644 index 00000000..f75827ec --- /dev/null +++ b/src/supplicant/nm-supplicant-types.h @@ -0,0 +1,58 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2006 - 2008 Red Hat, Inc. + */ + +#ifndef __NETWORKMANAGER_SUPPLICANT_TYPES_H__ +#define __NETWORKMANAGER_SUPPLICANT_TYPES_H__ + +#define WPAS_DBUS_SERVICE "fi.w1.wpa_supplicant1" +#define WPAS_DBUS_PATH "/fi/w1/wpa_supplicant1" +#define WPAS_DBUS_INTERFACE "fi.w1.wpa_supplicant1" + +typedef struct _NMSupplicantManager NMSupplicantManager; +typedef struct _NMSupplicantInterface NMSupplicantInterface; +typedef struct _NMSupplicantConfig NMSupplicantConfig; + +typedef enum { + NM_SUPPLICANT_FEATURE_UNKNOWN = 0, /* Can't detect whether supported or not */ + NM_SUPPLICANT_FEATURE_NO = 1, /* Feature definitely not supported */ + NM_SUPPLICANT_FEATURE_YES = 2, /* Feature definitely supported */ +} NMSupplicantFeature; + +/** + * NMSupplicantError: + * @NM_SUPPLICANT_ERROR_UNKNOWN: unknown or unclassified error + * @NM_SUPPLICANT_ERROR_CONFIG: a failure constructing the + * wpa-supplicant configuration. + */ +typedef enum { + NM_SUPPLICANT_ERROR_UNKNOWN = 0, /*< nick=Unknown >*/ + NM_SUPPLICANT_ERROR_CONFIG = 1, /*< nick=Config >*/ +} NMSupplicantError; + +typedef enum { + NM_SUPPLICANT_DRIVER_WIRELESS, + NM_SUPPLICANT_DRIVER_WIRED, + NM_SUPPLICANT_DRIVER_MACSEC, +} NMSupplicantDriver; + +#define NM_SUPPLICANT_ERROR (nm_supplicant_error_quark ()) +GQuark nm_supplicant_error_quark (void); + +#endif /* NM_SUPPLICANT_TYPES_H */ diff --git a/src/supplicant/tests/certs/test-ca-cert.pem b/src/supplicant/tests/certs/test-ca-cert.pem new file mode 100644 index 00000000..ef1be20d --- /dev/null +++ b/src/supplicant/tests/certs/test-ca-cert.pem @@ -0,0 +1,27 @@ +-----BEGIN CERTIFICATE----- +MIIEjzCCA3egAwIBAgIJAOvnZPt59yIZMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYD +VQQGEwJVUzESMBAGA1UECBMJQmVya3NoaXJlMRAwDgYDVQQHEwdOZXdidXJ5MRcw +FQYDVQQKEw5NeSBDb21wYW55IEx0ZDEQMA4GA1UECxMHVGVzdGluZzENMAsGA1UE +AxMEdGVzdDEcMBoGCSqGSIb3DQEJARYNdGVzdEB0ZXN0LmNvbTAeFw0wOTAzMTAx +NTEyMTRaFw0xOTAzMDgxNTEyMTRaMIGLMQswCQYDVQQGEwJVUzESMBAGA1UECBMJ +QmVya3NoaXJlMRAwDgYDVQQHEwdOZXdidXJ5MRcwFQYDVQQKEw5NeSBDb21wYW55 +IEx0ZDEQMA4GA1UECxMHVGVzdGluZzENMAsGA1UEAxMEdGVzdDEcMBoGCSqGSIb3 +DQEJARYNdGVzdEB0ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAKot9j+/+CX1/gZLgJHIXCRgCItKLGnf7qGbgqB9T2ACBqR0jllKWwDKrcWU +xjXNIc+GF9Wnv+lX6G0Okn4Zt3/uRNobL+2b/yOF7M3Td3/9W873zdkQQX930YZc +Rr8uxdRPP5bxiCgtcw632y21sSEbG9mjccAUnV/0jdvfmMNj0i8gN6E0fMBiJ9S3 +FkxX/KFvt9JWE9CtoyL7ki7UIDq+6vj7Gd5N0B3dOa1y+rRHZzKlJPcSXQSEYUS4 +HmKDwiKSVahft8c4tDn7KPi0vex91hlgZVd3usL2E/Vq7o5D9FAZ5kZY0AdFXwdm +J4lO4Mj7ac7GE4vNERNcXVIX59sCAwEAAaOB8zCB8DAdBgNVHQ4EFgQUuDU3Mr7P +T3n1e3Sy8hBauoDFahAwgcAGA1UdIwSBuDCBtYAUuDU3Mr7PT3n1e3Sy8hBauoDF +ahChgZGkgY4wgYsxCzAJBgNVBAYTAlVTMRIwEAYDVQQIEwlCZXJrc2hpcmUxEDAO +BgNVBAcTB05ld2J1cnkxFzAVBgNVBAoTDk15IENvbXBhbnkgTHRkMRAwDgYDVQQL +EwdUZXN0aW5nMQ0wCwYDVQQDEwR0ZXN0MRwwGgYJKoZIhvcNAQkBFg10ZXN0QHRl +c3QuY29tggkA6+dk+3n3IhkwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOC +AQEAVRG4aALIvCXCiKfe7K+iJxjBVRDFPEf7JWA9LGgbFOn6pNvbxonrR+0BETdc +JV1ET4ct2xsE7QNFIkp9GKRC+6J32zCo8qtLCD5+v436r8TUG2/t2JRMkb9I2XVT +p7RJoot6M0Ltf8KNQUPYh756xmKZ4USfQUwc58MOSDGY8VWEXJOYij9Pf0e0c52t +qiCEjXH7uXiS8Pgq9TYm7AkWSOrglYhSa83x0f8mtT8Q15nBESIHZ6o8FAS2bBgn +B0BkrKRjtBUkuJG3vTox+bYINh2Gxi1JZHWSV1tN5z3hd4VFcKqanW5OgQwToBqp +3nniskIjbH0xjgZf/nVMyLnjxg== +-----END CERTIFICATE----- diff --git a/src/supplicant/tests/certs/test-cert.p12 b/src/supplicant/tests/certs/test-cert.p12 new file mode 100644 index 00000000..ae4a6830 Binary files /dev/null and b/src/supplicant/tests/certs/test-cert.p12 differ diff --git a/src/supplicant/tests/test-supplicant-config.c b/src/supplicant/tests/test-supplicant-config.c new file mode 100644 index 00000000..fd91e921 --- /dev/null +++ b/src/supplicant/tests/test-supplicant-config.c @@ -0,0 +1,614 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2008 - 2011 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-core-internal.h" + +#include "supplicant/nm-supplicant-config.h" +#include "supplicant/nm-supplicant-settings-verify.h" + +#include "nm-test-utils-core.h" + +static gboolean +validate_opt (const char *detail, + GVariant *config, + const char *key, + OptType val_type, + gconstpointer expected, + size_t expected_len) +{ + char *config_key; + GVariant *config_value; + gboolean found = FALSE; + const guint8 *bytes; + gsize len; + const char *s; + const unsigned char *expected_array = expected; + GVariantIter iter; + + g_assert (g_variant_is_of_type (config, G_VARIANT_TYPE_VARDICT)); + + g_variant_iter_init (&iter, config); + while (g_variant_iter_next (&iter, "{&sv}", (gpointer) &config_key, (gpointer) &config_value)) { + if (!strcmp (key, config_key)) { + found = TRUE; + switch (val_type) { + case TYPE_INT: + g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_INT32)); + g_assert_cmpint (g_variant_get_int32 (config_value), ==, GPOINTER_TO_INT (expected)); + break; + case TYPE_BYTES: + g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_BYTESTRING)); + bytes = g_variant_get_fixed_array (config_value, &len, 1); + g_assert_cmpint (len, ==, expected_len); + g_assert (memcmp (bytes, expected_array, expected_len) == 0); + break; + case TYPE_KEYWORD: + case TYPE_STRING: + g_assert (g_variant_is_of_type (config_value, G_VARIANT_TYPE_STRING)); + if (expected_len == -1) + expected_len = strlen ((const char *) expected); + s = g_variant_get_string (config_value, NULL); + g_assert_cmpint (strlen (s), ==, expected_len); + g_assert_cmpstr (s, ==, expected); + break; + default: + g_assert_not_reached (); + break; + } + } + g_variant_unref (config_value); + } + + return found; +} + +static void +test_wifi_open (void) +{ + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMSupplicantConfig *config = NULL; + gs_unref_variant GVariant *config_dict = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingIPConfig *s_ip4; + char *uuid; + gboolean success; + GError *error = NULL; + GBytes *ssid; + const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; + const char *bssid_str = "11:22:33:44:55:66"; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Wifi Open", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wifi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); + + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_BSSID, bssid_str, + NM_SETTING_WIRELESS_MODE, "infrastructure", + NM_SETTING_WIRELESS_BAND, "bg", + NULL); + + g_bytes_unref (ssid); + + /* IP4 setting */ + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + config = nm_supplicant_config_new (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'ssid' value 'Test SSID'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'scan_ssid' value '1'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'bssid' value '11:22:33:44:55:66'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'freq_list' value *"); + g_assert (nm_supplicant_config_add_setting_wireless (config, + s_wifi, + 0, + &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'key_mgmt' value 'NONE'"); + g_assert (nm_supplicant_config_add_no_security (config, &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + config_dict = nm_supplicant_config_to_variant (config); + g_assert (config_dict); + + validate_opt ("wifi-open", config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); + validate_opt ("wifi-open", config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); + validate_opt ("wifi-open", config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); + validate_opt ("wifi-open", config_dict, "key_mgmt", TYPE_KEYWORD, "NONE", -1); +} + +static void +test_wifi_wep_key (const char *detail, + NMWepKeyType wep_type, + const char *key_data, + const unsigned char *expected, + size_t expected_size) +{ + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMSupplicantConfig *config = NULL; + gs_unref_variant GVariant *config_dict = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + char *uuid; + gboolean success; + GError *error = NULL; + GBytes *ssid; + const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; + const char *bssid_str = "11:22:33:44:55:66"; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Wifi WEP Key", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wifi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); + + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_BSSID, bssid_str, + NM_SETTING_WIRELESS_MODE, "infrastructure", + NM_SETTING_WIRELESS_BAND, "bg", + NULL); + + g_bytes_unref (ssid); + + /* Wifi Security setting */ + s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wsec)); + + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", + NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, wep_type, + NULL); + nm_setting_wireless_security_set_wep_key (s_wsec, 0, key_data); + + /* IP4 setting */ + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + config = nm_supplicant_config_new (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'ssid' value 'Test SSID'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'scan_ssid' value '1'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'bssid' value '11:22:33:44:55:66'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'freq_list' value *"); + g_assert (nm_supplicant_config_add_setting_wireless (config, + s_wifi, + 0, + &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'key_mgmt' value 'NONE'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'wep_key0' value *"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'wep_tx_keyidx' value '0'"); + g_assert (nm_supplicant_config_add_setting_wireless_security (config, + s_wsec, + NULL, + "376aced7-b28c-46be-9a62-fcdf072571da", + 1500, + &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + config_dict = nm_supplicant_config_to_variant (config); + g_assert (config_dict); + + validate_opt (detail, config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); + validate_opt (detail, config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); + validate_opt (detail, config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); + validate_opt (detail, config_dict, "key_mgmt", TYPE_KEYWORD, "NONE", -1); + validate_opt (detail, config_dict, "wep_tx_keyidx", TYPE_INT, GINT_TO_POINTER (0), -1); + validate_opt (detail, config_dict, "wep_key0", TYPE_BYTES, expected, expected_size); +} + +static void +test_wifi_wep (void) +{ + const char *key1 = "12345"; + const unsigned char key1_expected[] = { 0x31, 0x32, 0x33, 0x34, 0x35 }; + const char *key2 = "ascii test$$$"; + const unsigned char key2_expected[] = { 0x61, 0x73, 0x63, 0x69, 0x69, 0x20, 0x74, 0x65, 0x73, 0x74, 0x24, 0x24, 0x24 }; + const char *key3 = "abcdef1234"; + const unsigned char key3_expected[] = { 0xab, 0xcd, 0xef, 0x12, 0x34 }; + const char *key4 = "96aec785c6392675f87f592972"; + const unsigned char key4_expected[] = { 0x96, 0xae, 0xc7, 0x85, 0xc6, 0x39, 0x26, 0x75, 0xf8, 0x7f, 0x59, 0x29, 0x72 }; + const char *key5 = "r34lly l33t w3p p4ssphr4s3 for t3st1ng"; + const unsigned char key5_expected[] = { 0xce, 0x68, 0x8b, 0x35, 0xf6, 0x0a, 0x2b, 0xbf, 0xc9, 0x8f, 0xed, 0x10, 0xda }; + + test_wifi_wep_key ("wifi-wep-ascii-40", NM_WEP_KEY_TYPE_KEY, key1, key1_expected, sizeof (key1_expected)); + test_wifi_wep_key ("wifi-wep-ascii-104", NM_WEP_KEY_TYPE_KEY, key2, key2_expected, sizeof (key2_expected)); + test_wifi_wep_key ("wifi-wep-hex-40", NM_WEP_KEY_TYPE_KEY, key3, key3_expected, sizeof (key3_expected)); + test_wifi_wep_key ("wifi-wep-hex-104", NM_WEP_KEY_TYPE_KEY, key4, key4_expected, sizeof (key4_expected)); + test_wifi_wep_key ("wifi-wep-passphrase-104", NM_WEP_KEY_TYPE_PASSPHRASE, key5, key5_expected, sizeof (key5_expected)); + + test_wifi_wep_key ("wifi-wep-old-hex-104", NM_WEP_KEY_TYPE_UNKNOWN, key4, key4_expected, sizeof (key4_expected)); +} + +static void +test_wifi_wpa_psk (const char *detail, + OptType key_type, + const char *key_data, + const unsigned char *expected, + size_t expected_size) +{ + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMSupplicantConfig *config = NULL; + gs_unref_variant GVariant *config_dict = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIPConfig *s_ip4; + char *uuid; + gboolean success; + GError *error = NULL; + GBytes *ssid; + const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; + const char *bssid_str = "11:22:33:44:55:66"; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Wifi WEP Key", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wifi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); + + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_BSSID, bssid_str, + NM_SETTING_WIRELESS_MODE, "infrastructure", + NM_SETTING_WIRELESS_BAND, "bg", + NULL); + + g_bytes_unref (ssid); + + /* Wifi Security setting */ + s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wsec)); + + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", + NM_SETTING_WIRELESS_SECURITY_PSK, key_data, + NULL); + + nm_setting_wireless_security_add_proto (s_wsec, "wpa"); + nm_setting_wireless_security_add_proto (s_wsec, "rsn"); + nm_setting_wireless_security_add_pairwise (s_wsec, "tkip"); + nm_setting_wireless_security_add_pairwise (s_wsec, "ccmp"); + nm_setting_wireless_security_add_group (s_wsec, "tkip"); + nm_setting_wireless_security_add_group (s_wsec, "ccmp"); + + /* IP4 setting */ + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + config = nm_supplicant_config_new (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'ssid' value 'Test SSID'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'scan_ssid' value '1'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'bssid' value '11:22:33:44:55:66'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'freq_list' value *"); + g_assert (nm_supplicant_config_add_setting_wireless (config, + s_wifi, + 0, + &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'key_mgmt' value 'WPA-PSK'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'psk' value *"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'proto' value 'WPA RSN'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'pairwise' value 'TKIP CCMP'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'group' value 'TKIP CCMP'"); + g_assert (nm_supplicant_config_add_setting_wireless_security (config, + s_wsec, + NULL, + "376aced7-b28c-46be-9a62-fcdf072571da", + 1500, + &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + config_dict = nm_supplicant_config_to_variant (config); + g_assert (config_dict); + + validate_opt (detail, config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); + validate_opt (detail, config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); + validate_opt (detail, config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); + validate_opt (detail, config_dict, "key_mgmt", TYPE_KEYWORD, "WPA-PSK", -1); + validate_opt (detail, config_dict, "proto", TYPE_KEYWORD, "WPA RSN", -1); + validate_opt (detail, config_dict, "pairwise", TYPE_KEYWORD, "TKIP CCMP", -1); + validate_opt (detail, config_dict, "group", TYPE_KEYWORD, "TKIP CCMP", -1); + validate_opt (detail, config_dict, "psk", key_type, expected, expected_size); +} + +static void +test_wifi_wpa_psk_types (void) +{ + const char *key1 = "d4721e911461d3cdef9793858e977fcda091779243abb7316c2f11605a160893"; + const unsigned char key1_expected[] = { 0xd4, 0x72, 0x1e, 0x91, 0x14, 0x61, 0xd3, 0xcd, + 0xef, 0x97, 0x93, 0x85, 0x8e, 0x97, 0x7f, 0xcd, + 0xa0, 0x91, 0x77, 0x92, 0x43, 0xab, 0xb7, 0x31, + 0x6c, 0x2f, 0x11, 0x60, 0x5a, 0x16, 0x08, 0x93 }; + const char *key2 = "r34lly l33t wp4 p4ssphr4s3 for t3st1ng"; + + test_wifi_wpa_psk ("wifi-wpa-psk-hex", TYPE_BYTES, key1, key1_expected, sizeof (key1_expected)); + test_wifi_wpa_psk ("wifi-wep-psk-passphrase", TYPE_STRING, key2, (gconstpointer) key2, strlen (key2)); +} + +static void +test_wifi_eap (void) +{ + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMSupplicantConfig *config = NULL; + gs_unref_variant GVariant *config_dict = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSetting8021x *s_8021x; + NMSettingIPConfig *s_ip4; + char *uuid; + gboolean success; + GError *error = NULL; + GBytes *ssid; + const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; + const char *bssid_str = "11:22:33:44:55:66"; + guint32 mtu = 1100; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Wifi EAP-TLS", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wifi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); + + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_BSSID, bssid_str, + NM_SETTING_WIRELESS_MODE, "infrastructure", + NM_SETTING_WIRELESS_BAND, "bg", + NULL); + + g_bytes_unref (ssid); + + /* Wifi Security setting */ + s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wsec)); + + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", + NULL); + + nm_setting_wireless_security_add_proto (s_wsec, "wpa"); + nm_setting_wireless_security_add_proto (s_wsec, "rsn"); + nm_setting_wireless_security_add_pairwise (s_wsec, "tkip"); + nm_setting_wireless_security_add_pairwise (s_wsec, "ccmp"); + nm_setting_wireless_security_add_group (s_wsec, "tkip"); + nm_setting_wireless_security_add_group (s_wsec, "ccmp"); + + /* 802-1X setting */ + s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); + nm_connection_add_setting (connection, NM_SETTING (s_8021x)); + nm_setting_802_1x_add_eap_method (s_8021x, "tls"); + nm_setting_802_1x_set_client_cert (s_8021x, TEST_CERT_DIR "/test-cert.p12", NM_SETTING_802_1X_CK_SCHEME_PATH, NULL, NULL); + nm_setting_802_1x_set_ca_cert (s_8021x, TEST_CERT_DIR "/test-ca-cert.pem", NM_SETTING_802_1X_CK_SCHEME_PATH, NULL, NULL); + nm_setting_802_1x_set_private_key (s_8021x, TEST_CERT_DIR "/test-cert.p12", NULL, NM_SETTING_802_1X_CK_SCHEME_PATH, NULL, NULL); + + /* IP4 setting */ + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + config = nm_supplicant_config_new (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'ssid' value 'Test SSID'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'scan_ssid' value '1'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'bssid' value '11:22:33:44:55:66'*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'freq_list' value *"); + g_assert (nm_supplicant_config_add_setting_wireless (config, + s_wifi, + 0, + &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'key_mgmt' value 'WPA-EAP'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'proto' value 'WPA RSN'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'pairwise' value 'TKIP CCMP'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*added 'group' value 'TKIP CCMP'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*Config: added 'eap' value 'TLS'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*Config: added 'fragment_size' value '1086'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "* Config: added 'ca_cert' value '*/test-ca-cert.pem'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "* Config: added 'private_key' value '*/test-cert.p12'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*Config: added 'bgscan' value 'simple:30:-65:300'"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, + "*Config: added 'proactive_key_caching' value '1'"); + g_assert (nm_supplicant_config_add_setting_wireless_security (config, + s_wsec, + s_8021x, + "d5b488af-9cab-41ed-bad4-97709c58430f", + mtu, + &error)); + g_assert_no_error (error); + g_test_assert_expected_messages (); + + config_dict = nm_supplicant_config_to_variant (config); + g_assert (config_dict); + + validate_opt ("wifi-eap", config_dict, "scan_ssid", TYPE_INT, GINT_TO_POINTER (1), -1); + validate_opt ("wifi-eap", config_dict, "ssid", TYPE_BYTES, ssid_data, sizeof (ssid_data)); + validate_opt ("wifi-eap", config_dict, "bssid", TYPE_KEYWORD, bssid_str, -1); + validate_opt ("wifi-eap", config_dict, "key_mgmt", TYPE_KEYWORD, "WPA-EAP", -1); + validate_opt ("wifi-eap", config_dict, "eap", TYPE_KEYWORD, "TLS", -1); + validate_opt ("wifi-eap", config_dict, "proto", TYPE_KEYWORD, "WPA RSN", -1); + validate_opt ("wifi-eap", config_dict, "pairwise", TYPE_KEYWORD, "TKIP CCMP", -1); + validate_opt ("wifi-eap", config_dict, "group", TYPE_KEYWORD, "TKIP CCMP", -1); + validate_opt ("wifi-eap", config_dict, "fragment_size", TYPE_INT, GINT_TO_POINTER(mtu-14), -1); +} + +NMTST_DEFINE (); + +int main (int argc, char **argv) +{ + nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); + + g_test_add_func ("/supplicant-config/wifi-open", test_wifi_open); + g_test_add_func ("/supplicant-config/wifi-wep", test_wifi_wep); + g_test_add_func ("/supplicant-config/wifi-wpa-psk-types", test_wifi_wpa_psk_types); + g_test_add_func ("/supplicant-config/wifi-eap", test_wifi_eap); + + return g_test_run (); +} + diff --git a/src/systemd/nm-sd.h b/src/systemd/nm-sd.h index f07a7082..f988dfd0 100644 --- a/src/systemd/nm-sd.h +++ b/src/systemd/nm-sd.h @@ -19,6 +19,13 @@ #ifndef __NM_SD_H__ #define __NM_SD_H__ +#include "systemd/src/systemd/sd-dhcp-client.h" +#include "systemd/src/systemd/sd-dhcp6-client.h" +#include "systemd/src/systemd/sd-lldp.h" +#include "systemd/src/systemd/sd-ipv4ll.h" + +/*****************************************************************************/ + guint nm_sd_event_attach_default (void); /***************************************************************************** diff --git a/src/systemd/sd-adapt/format-util.h b/src/systemd/sd-adapt/format-util.h new file mode 100644 index 00000000..637892c2 --- /dev/null +++ b/src/systemd/sd-adapt/format-util.h @@ -0,0 +1,3 @@ +#pragma once + +/* dummy header */ diff --git a/src/systemd/sd-adapt/formats-util.h b/src/systemd/sd-adapt/formats-util.h deleted file mode 100644 index 637892c2..00000000 --- a/src/systemd/sd-adapt/formats-util.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -/* dummy header */ diff --git a/src/systemd/sd-adapt/glob-util.h b/src/systemd/sd-adapt/glob-util.h new file mode 100644 index 00000000..637892c2 --- /dev/null +++ b/src/systemd/sd-adapt/glob-util.h @@ -0,0 +1,3 @@ +#pragma once + +/* dummy header */ diff --git a/src/systemd/sd-adapt/khash.h b/src/systemd/sd-adapt/khash.h new file mode 100644 index 00000000..637892c2 --- /dev/null +++ b/src/systemd/sd-adapt/khash.h @@ -0,0 +1,3 @@ +#pragma once + +/* dummy header */ diff --git a/src/systemd/src/basic/alloc-util.h b/src/systemd/src/basic/alloc-util.h index ceeee519..a44dd473 100644 --- a/src/systemd/src/basic/alloc-util.h +++ b/src/systemd/src/basic/alloc-util.h @@ -43,6 +43,14 @@ static inline void *mfree(void *memory) { return NULL; } +#define free_and_replace(a, b) \ + ({ \ + free(a); \ + (a) = (b); \ + (b) = NULL; \ + 0; \ + }) + void* memdup(const void *p, size_t l) _alloc_(2); static inline void freep(void *p) { diff --git a/src/systemd/src/basic/escape.c b/src/systemd/src/basic/escape.c index 406b791f..ac96f0ee 100644 --- a/src/systemd/src/basic/escape.c +++ b/src/systemd/src/basic/escape.c @@ -335,7 +335,7 @@ int cunescape_length_with_prefix(const char *s, size_t length, const char *prefi assert(remaining > 0); if (*f != '\\') { - /* A literal literal, copy verbatim */ + /* A literal, copy verbatim */ *(t++) = *f; continue; } diff --git a/src/systemd/src/basic/extract-word.c b/src/systemd/src/basic/extract-word.c index eb54daa3..734712dc 100644 --- a/src/systemd/src/basic/extract-word.c +++ b/src/systemd/src/basic/extract-word.c @@ -50,7 +50,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra /* Bail early if called after last value or with no input */ if (!*p) - goto finish_force_terminate; + goto finish; c = **p; if (!separators) @@ -230,8 +230,8 @@ int extract_first_word_and_warn( *p = save; r = extract_first_word(p, ret, separators, flags|EXTRACT_CUNESCAPE_RELAX); if (r >= 0) { - /* It worked this time, hence it must have been an invalid escape sequence we could correct. */ - log_syntax(unit, LOG_WARNING, filename, line, EINVAL, "Invalid escape sequences in line, correcting: \"%s\"", rvalue); + /* It worked this time, hence it must have been an invalid escape sequence. */ + log_syntax(unit, LOG_WARNING, filename, line, EINVAL, "Ignoring unknown escape sequences: \"%s\"", *ret); return r; } diff --git a/src/systemd/src/basic/fd-util.c b/src/systemd/src/basic/fd-util.c index c518f757..d1c988e1 100644 --- a/src/systemd/src/basic/fd-util.c +++ b/src/systemd/src/basic/fd-util.c @@ -26,6 +26,7 @@ #include #include +#include "dirent-util.h" #include "fd-util.h" #include "fs-util.h" #include "macro.h" @@ -237,12 +238,9 @@ int close_all_fds(const int except[], unsigned n_except) { return r; } - while ((de = readdir(d))) { + FOREACH_DIRENT(de, d, return -errno) { int fd = -1; - if (hidden_or_backup_file(de->d_name)) - continue; - if (safe_atoi(de->d_name, &fd) < 0) /* Let's better ignore this, just in case */ continue; diff --git a/src/systemd/src/basic/fileio.c b/src/systemd/src/basic/fileio.c index b2fe15ca..8ef0db7f 100644 --- a/src/systemd/src/basic/fileio.c +++ b/src/systemd/src/basic/fileio.c @@ -39,6 +39,7 @@ #include "hexdecoct.h" #include "log.h" #include "macro.h" +#include "missing.h" #include "parse-util.h" #include "path-util.h" #include "random-util.h" @@ -677,7 +678,7 @@ static int load_env_file_push( return -EINVAL; } - p = strjoin(key, "=", strempty(value), NULL); + p = strjoin(key, "=", strempty(value)); if (!p) return -ENOMEM; @@ -965,9 +966,9 @@ static int search_and_fopen_internal(const char *path, const char *mode, const c FILE *f; if (root) - p = strjoin(root, *i, "/", path, NULL); + p = strjoin(root, *i, "/", path); else - p = strjoin(*i, "/", path, NULL); + p = strjoin(*i, "/", path); if (!p) return -ENOMEM; @@ -1046,7 +1047,7 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) { if (r < 0) return r; - fd = mkostemp_safe(t, O_WRONLY|O_CLOEXEC); + fd = mkostemp_safe(t); if (fd < 0) { free(t); return -errno; @@ -1079,7 +1080,7 @@ int fflush_and_check(FILE *f) { } /* This is much like mkostemp() but is subject to umask(). */ -int mkostemp_safe(char *pattern, int flags) { +int mkostemp_safe(char *pattern) { _cleanup_umask_ mode_t u = 0; int fd; @@ -1087,7 +1088,7 @@ int mkostemp_safe(char *pattern, int flags) { u = umask(077); - fd = mkostemp(pattern, flags); + fd = mkostemp(pattern, O_CLOEXEC); if (fd < 0) return -errno; @@ -1287,17 +1288,15 @@ int open_tmpfile_unlinkable(const char *directory, int flags) { /* Returns an unlinked temporary file that cannot be linked into the file system anymore */ -#ifdef O_TMPFILE /* Try O_TMPFILE first, if it is supported */ fd = open(directory, flags|O_TMPFILE|O_EXCL, S_IRUSR|S_IWUSR); if (fd >= 0) return fd; -#endif /* Fall back to unguessable name + unlinking */ p = strjoina(directory, "/systemd-tmp-XXXXXX"); - fd = mkostemp_safe(p, flags); + fd = mkostemp_safe(p); if (fd < 0) return fd; @@ -1320,7 +1319,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) { * which case "ret_path" will be returned as NULL. If not possible a the tempoary path name used is returned in * "ret_path". Use link_tmpfile() below to rename the result after writing the file in full. */ -#ifdef O_TMPFILE { _cleanup_free_ char *dn = NULL; @@ -1336,7 +1334,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) { log_debug_errno(errno, "Failed to use O_TMPFILE on %s: %m", dn); } -#endif r = tempfn_random(target, NULL, &tmp); if (r < 0) @@ -1419,4 +1416,23 @@ int read_nul_string(FILE *f, char **ret) { return 0; } + +int mkdtemp_malloc(const char *template, char **ret) { + char *p; + + assert(template); + assert(ret); + + p = strdup(template); + if (!p) + return -ENOMEM; + + if (!mkdtemp(p)) { + free(p); + return -errno; + } + + *ret = p; + return 0; +} #endif /* NM_IGNORED */ diff --git a/src/systemd/src/basic/fileio.h b/src/systemd/src/basic/fileio.h index 9ac497d9..17b38a5d 100644 --- a/src/systemd/src/basic/fileio.h +++ b/src/systemd/src/basic/fileio.h @@ -71,7 +71,7 @@ int search_and_fopen_nulstr(const char *path, const char *mode, const char *root int fflush_and_check(FILE *f); int fopen_temporary(const char *path, FILE **_f, char **_temp_path); -int mkostemp_safe(char *pattern, int flags); +int mkostemp_safe(char *pattern); int tempfn_xxxxxx(const char *p, const char *extra, char **ret); int tempfn_random(const char *p, const char *extra, char **ret); @@ -88,3 +88,5 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path); int link_tmpfile(int fd, const char *path, const char *target); int read_nul_string(FILE *f, char **ret); + +int mkdtemp_malloc(const char *template, char **ret); diff --git a/src/systemd/src/basic/fs-util.c b/src/systemd/src/basic/fs-util.c index de0cd8fb..3919fbcd 100644 --- a/src/systemd/src/basic/fs-util.c +++ b/src/systemd/src/basic/fs-util.c @@ -19,7 +19,6 @@ #include "nm-sd-adapt.h" -#include #include #include #include @@ -229,25 +228,25 @@ int readlink_and_make_absolute(const char *p, char **r) { return 0; } -int readlink_and_canonicalize(const char *p, char **r) { +int readlink_and_canonicalize(const char *p, const char *root, char **ret) { char *t, *s; - int j; + int r; assert(p); - assert(r); + assert(ret); - j = readlink_and_make_absolute(p, &t); - if (j < 0) - return j; + r = readlink_and_make_absolute(p, &t); + if (r < 0) + return r; - s = canonicalize_file_name(t); - if (s) { + r = chase_symlinks(t, root, 0, &s); + if (r < 0) + /* If we can't follow up, then let's return the original string, slightly cleaned up. */ + *ret = path_kill_slashes(t); + else { + *ret = s; free(t); - *r = s; - } else - *r = t; - - path_kill_slashes(*r); + } return 0; } @@ -453,6 +452,7 @@ int mkfifo_atomic(const char *path, mode_t mode) { int get_files_in_directory(const char *path, char ***list) { _cleanup_closedir_ DIR *d = NULL; + struct dirent *de; size_t bufsize = 0, n = 0; _cleanup_strv_free_ char **l = NULL; @@ -466,16 +466,7 @@ int get_files_in_directory(const char *path, char ***list) { if (!d) return -errno; - for (;;) { - struct dirent *de; - - errno = 0; - de = readdir(d); - if (!de && errno > 0) - return -errno; - if (!de) - break; - + FOREACH_DIRENT_ALL(de, d, return -errno) { dirent_ensure_type(d, de); if (!dirent_is_file(de)) @@ -604,4 +595,220 @@ int inotify_add_watch_fd(int fd, int what, uint32_t mask) { return r; } + +int chase_symlinks(const char *path, const char *original_root, unsigned flags, char **ret) { + _cleanup_free_ char *buffer = NULL, *done = NULL, *root = NULL; + _cleanup_close_ int fd = -1; + unsigned max_follow = 32; /* how many symlinks to follow before giving up and returning ELOOP */ + bool exists = true; + char *todo; + int r; + + assert(path); + + /* This is a lot like canonicalize_file_name(), but takes an additional "root" parameter, that allows following + * symlinks relative to a root directory, instead of the root of the host. + * + * Note that "root" primarily matters if we encounter an absolute symlink. It is also used when following + * relative symlinks to ensure they cannot be used to "escape" the root directory. The path parameter passed is + * assumed to be already prefixed by it, except if the CHASE_PREFIX_ROOT flag is set, in which case it is first + * prefixed accordingly. + * + * Algorithmically this operates on two path buffers: "done" are the components of the path we already + * processed and resolved symlinks, "." and ".." of. "todo" are the components of the path we still need to + * process. On each iteration, we move one component from "todo" to "done", processing it's special meaning + * each time. The "todo" path always starts with at least one slash, the "done" path always ends in no + * slash. We always keep an O_PATH fd to the component we are currently processing, thus keeping lookup races + * at a minimum. + * + * Suggested usage: whenever you want to canonicalize a path, use this function. Pass the absolute path you got + * as-is: fully qualified and relative to your host's root. Optionally, specify the root parameter to tell this + * function what to do when encountering a symlink with an absolute path as directory: prefix it by the + * specified path. + * + * Note: there's also chase_symlinks_prefix() (see below), which as first step prefixes the passed path by the + * passed root. */ + + if (original_root) { + r = path_make_absolute_cwd(original_root, &root); + if (r < 0) + return r; + + if (flags & CHASE_PREFIX_ROOT) + path = prefix_roota(root, path); + } + + r = path_make_absolute_cwd(path, &buffer); + if (r < 0) + return r; + + fd = open("/", O_CLOEXEC|O_NOFOLLOW|O_PATH); + if (fd < 0) + return -errno; + + todo = buffer; + for (;;) { + _cleanup_free_ char *first = NULL; + _cleanup_close_ int child = -1; + struct stat st; + size_t n, m; + + /* Determine length of first component in the path */ + n = strspn(todo, "/"); /* The slashes */ + m = n + strcspn(todo + n, "/"); /* The entire length of the component */ + + /* Extract the first component. */ + first = strndup(todo, m); + if (!first) + return -ENOMEM; + + todo += m; + + /* Just a single slash? Then we reached the end. */ + if (isempty(first) || path_equal(first, "/")) + break; + + /* Just a dot? Then let's eat this up. */ + if (path_equal(first, "/.")) + continue; + + /* Two dots? Then chop off the last bit of what we already found out. */ + if (path_equal(first, "/..")) { + _cleanup_free_ char *parent = NULL; + int fd_parent = -1; + + /* If we already are at the top, then going up will not change anything. This is in-line with + * how the kernel handles this. */ + if (isempty(done) || path_equal(done, "/")) + continue; + + parent = dirname_malloc(done); + if (!parent) + return -ENOMEM; + + /* Don't allow this to leave the root dir. */ + if (root && + path_startswith(done, root) && + !path_startswith(parent, root)) + continue; + + free_and_replace(done, parent); + + fd_parent = openat(fd, "..", O_CLOEXEC|O_NOFOLLOW|O_PATH); + if (fd_parent < 0) + return -errno; + + safe_close(fd); + fd = fd_parent; + + continue; + } + + /* Otherwise let's see what this is. */ + child = openat(fd, first + n, O_CLOEXEC|O_NOFOLLOW|O_PATH); + if (child < 0) { + + if (errno == ENOENT && + (flags & CHASE_NONEXISTENT) && + (isempty(todo) || path_is_safe(todo))) { + + /* If CHASE_NONEXISTENT is set, and the path does not exist, then that's OK, return + * what we got so far. But don't allow this if the remaining path contains "../ or "./" + * or something else weird. */ + + if (!strextend(&done, first, todo, NULL)) + return -ENOMEM; + + exists = false; + break; + } + + return -errno; + } + + if (fstat(child, &st) < 0) + return -errno; + + if (S_ISLNK(st.st_mode)) { + _cleanup_free_ char *destination = NULL; + + /* This is a symlink, in this case read the destination. But let's make sure we don't follow + * symlinks without bounds. */ + if (--max_follow <= 0) + return -ELOOP; + + r = readlinkat_malloc(fd, first + n, &destination); + if (r < 0) + return r; + if (isempty(destination)) + return -EINVAL; + + if (path_is_absolute(destination)) { + + /* An absolute destination. Start the loop from the beginning, but use the root + * directory as base. */ + + safe_close(fd); + fd = open(root ?: "/", O_CLOEXEC|O_NOFOLLOW|O_PATH); + if (fd < 0) + return -errno; + + free_and_replace(buffer, destination); + + todo = buffer; + free(done); + + /* Note that we do not revalidate the root, we take it as is. */ + if (isempty(root)) + done = NULL; + else { + done = strdup(root); + if (!done) + return -ENOMEM; + } + + } else { + char *joined; + + /* A relative destination. If so, this is what we'll prefix what's left to do with what + * we just read, and start the loop again, but remain in the current directory. */ + + joined = strjoin("/", destination, todo); + if (!joined) + return -ENOMEM; + + free(buffer); + todo = buffer = joined; + } + + continue; + } + + /* If this is not a symlink, then let's just add the name we read to what we already verified. */ + if (!done) { + done = first; + first = NULL; + } else { + if (!strextend(&done, first, NULL)) + return -ENOMEM; + } + + /* And iterate again, but go one directory further down. */ + safe_close(fd); + fd = child; + child = -1; + } + + if (!done) { + /* Special case, turn the empty string into "/", to indicate the root directory. */ + done = strdup("/"); + if (!done) + return -ENOMEM; + } + + *ret = done; + done = NULL; + + return exists; +} #endif /* NM_IGNORED */ diff --git a/src/systemd/src/basic/fs-util.h b/src/systemd/src/basic/fs-util.h index 2c3b9a1c..5fe5c71f 100644 --- a/src/systemd/src/basic/fs-util.h +++ b/src/systemd/src/basic/fs-util.h @@ -39,7 +39,7 @@ int readlinkat_malloc(int fd, const char *p, char **ret); int readlink_malloc(const char *p, char **r); int readlink_value(const char *p, char **ret); int readlink_and_make_absolute(const char *p, char **r); -int readlink_and_canonicalize(const char *p, char **r); +int readlink_and_canonicalize(const char *p, const char *root, char **r); int readlink_and_make_absolute_root(const char *root, const char *path, char **ret); int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); @@ -77,3 +77,17 @@ union inotify_event_buffer { }; int inotify_add_watch_fd(int fd, int what, uint32_t mask); + +enum { + CHASE_PREFIX_ROOT = 1, /* If set, the specified path will be prefixed by the specified root before beginning the iteration */ + CHASE_NONEXISTENT = 2, /* If set, it's OK if the path doesn't actually exist. */ +}; + +int chase_symlinks(const char *path_with_prefix, const char *root, unsigned flags, char **ret); + +/* Useful for usage with _cleanup_(), removes a directory and frees the pointer */ +static inline void rmdir_and_free(char *p) { + (void) rmdir(p); + free(p); +} +DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rmdir_and_free); diff --git a/src/systemd/src/basic/hostname-util.c b/src/systemd/src/basic/hostname-util.c index 480f9d9d..732a0ce7 100644 --- a/src/systemd/src/basic/hostname-util.c +++ b/src/systemd/src/basic/hostname-util.c @@ -165,7 +165,6 @@ char* hostname_cleanup(char *s) { *(d++) = *p; dot = false; } - } if (dot && d > s) diff --git a/src/systemd/src/basic/in-addr-util.c b/src/systemd/src/basic/in-addr-util.c index 95230e7d..37dc14f0 100644 --- a/src/systemd/src/basic/in-addr-util.c +++ b/src/systemd/src/basic/in-addr-util.c @@ -33,15 +33,9 @@ #include "util.h" bool in4_addr_is_null(const struct in_addr *a) { - return a->s_addr == 0; -} + assert(a); -bool in6_addr_is_null(const struct in6_addr *a) { - return - a->s6_addr32[0] == 0 && - a->s6_addr32[1] == 0 && - a->s6_addr32[2] == 0 && - a->s6_addr32[3] == 0; + return a->s_addr == 0; } int in_addr_is_null(int family, const union in_addr_union *u) { @@ -51,16 +45,22 @@ int in_addr_is_null(int family, const union in_addr_union *u) { return in4_addr_is_null(&u->in); if (family == AF_INET6) - return in6_addr_is_null(&u->in6); + return IN6_IS_ADDR_UNSPECIFIED(&u->in6); return -EAFNOSUPPORT; } +bool in4_addr_is_link_local(const struct in_addr *a) { + assert(a); + + return (be32toh(a->s_addr) & UINT32_C(0xFFFF0000)) == (UINT32_C(169) << 24 | UINT32_C(254) << 16); +} + int in_addr_is_link_local(int family, const union in_addr_union *u) { assert(u); if (family == AF_INET) - return (be32toh(u->in.s_addr) & UINT32_C(0xFFFF0000)) == (UINT32_C(169) << 24 | UINT32_C(254) << 16); + return in4_addr_is_link_local(&u->in); if (family == AF_INET6) return IN6_IS_ADDR_LINKLOCAL(&u->in6); @@ -68,12 +68,18 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) { return -EAFNOSUPPORT; } +bool in4_addr_is_localhost(const struct in_addr *a) { + assert(a); + + /* All of 127.x.x.x is localhost. */ + return (be32toh(a->s_addr) & UINT32_C(0xFF000000)) == UINT32_C(127) << 24; +} + int in_addr_is_localhost(int family, const union in_addr_union *u) { assert(u); if (family == AF_INET) - /* All of 127.x.x.x is localhost. */ - return (be32toh(u->in.s_addr) & UINT32_C(0xFF000000)) == UINT32_C(127) << 24; + return in4_addr_is_localhost(&u->in); if (family == AF_INET6) return IN6_IS_ADDR_LOOPBACK(&u->in6); @@ -279,15 +285,14 @@ fallback: } int in_addr_from_string(int family, const char *s, union in_addr_union *ret) { - + union in_addr_union buffer; assert(s); - assert(ret); if (!IN_SET(family, AF_INET, AF_INET6)) return -EAFNOSUPPORT; errno = 0; - if (inet_pton(family, s, ret) <= 0) + if (inet_pton(family, s, ret ?: &buffer) <= 0) return errno > 0 ? -errno : -EINVAL; return 0; @@ -297,18 +302,18 @@ int in_addr_from_string_auto(const char *s, int *family, union in_addr_union *re int r; assert(s); - assert(family); - assert(ret); r = in_addr_from_string(AF_INET, s, ret); if (r >= 0) { - *family = AF_INET; + if (family) + *family = AF_INET; return 0; } r = in_addr_from_string(AF_INET6, s, ret); if (r >= 0) { - *family = AF_INET6; + if (family) + *family = AF_INET6; return 0; } diff --git a/src/systemd/src/basic/in-addr-util.h b/src/systemd/src/basic/in-addr-util.h index d60064ae..64a812c3 100644 --- a/src/systemd/src/basic/in-addr-util.h +++ b/src/systemd/src/basic/in-addr-util.h @@ -37,11 +37,14 @@ struct in_addr_data { }; bool in4_addr_is_null(const struct in_addr *a); -bool in6_addr_is_null(const struct in6_addr *a); - int in_addr_is_null(int family, const union in_addr_union *u); + +bool in4_addr_is_link_local(const struct in_addr *a); int in_addr_is_link_local(int family, const union in_addr_union *u); + +bool in4_addr_is_localhost(const struct in_addr *a); int in_addr_is_localhost(int family, const union in_addr_union *u); + int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b); int in_addr_prefix_intersect(int family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen); int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen); diff --git a/src/systemd/src/basic/list.h b/src/systemd/src/basic/list.h index 5962aa42..c3771a17 100644 --- a/src/systemd/src/basic/list.h +++ b/src/systemd/src/basic/list.h @@ -142,6 +142,8 @@ } else { \ if ((_b->name##_prev = _a->name##_prev)) \ _b->name##_prev->name##_next = _b; \ + else \ + *_head = _b; \ _b->name##_next = _a; \ _a->name##_prev = _b; \ } \ diff --git a/src/systemd/src/basic/log.h b/src/systemd/src/basic/log.h index 322ad6ca..ccf2930f 100644 --- a/src/systemd/src/basic/log.h +++ b/src/systemd/src/basic/log.h @@ -101,18 +101,22 @@ int log_object_internal( const char *func, const char *object_field, const char *object, - const char *format, ...) _printf_(8,9); + const char *extra_field, + const char *extra, + const char *format, ...) _printf_(10,11); int log_object_internalv( int level, int error, - const char*file, + const char *file, int line, const char *func, const char *object_field, const char *object, + const char *extra_field, + const char *extra, const char *format, - va_list ap) _printf_(8,0); + va_list ap) _printf_(9,0); int log_struct_internal( int level, diff --git a/src/systemd/src/basic/parse-util.c b/src/systemd/src/basic/parse-util.c index 27386631..9a7a0bbc 100644 --- a/src/systemd/src/basic/parse-util.c +++ b/src/systemd/src/basic/parse-util.c @@ -579,4 +579,20 @@ int parse_nice(const char *p, int *ret) { *ret = n; return 0; } + +int parse_ip_port(const char *s, uint16_t *ret) { + uint16_t l; + int r; + + r = safe_atou16(s, &l); + if (r < 0) + return r; + + if (l == 0) + return -EINVAL; + + *ret = (uint16_t) l; + + return 0; +} #endif /* NM_IGNORED */ diff --git a/src/systemd/src/basic/parse-util.h b/src/systemd/src/basic/parse-util.h index 461e1cd4..4d132f0d 100644 --- a/src/systemd/src/basic/parse-util.h +++ b/src/systemd/src/basic/parse-util.h @@ -110,3 +110,5 @@ int parse_percent_unbounded(const char *p); int parse_percent(const char *p); int parse_nice(const char *p, int *ret); + +int parse_ip_port(const char *s, uint16_t *ret); diff --git a/src/systemd/src/basic/path-util.c b/src/systemd/src/basic/path-util.c index 86d35bbe..dec95041 100644 --- a/src/systemd/src/basic/path-util.c +++ b/src/systemd/src/basic/path-util.c @@ -36,9 +36,11 @@ #include "alloc-util.h" #include "extract-word.h" #include "fs-util.h" +#include "glob-util.h" #include "log.h" #include "macro.h" #include "missing.h" +#include "parse-util.h" #include "path-util.h" #include "stat-util.h" #include "string-util.h" @@ -84,7 +86,7 @@ char *path_make_absolute(const char *p, const char *prefix) { if (path_is_absolute(p) || !prefix) return strdup(p); - return strjoin(prefix, "/", p, NULL); + return strjoin(prefix, "/", p); } int path_make_absolute_cwd(const char *p, char **ret) { @@ -105,7 +107,7 @@ int path_make_absolute_cwd(const char *p, char **ret) { if (!cwd) return negative_errno(); - c = strjoin(cwd, "/", p, NULL); + c = strjoin(cwd, "/", p); } if (!c) return -ENOMEM; @@ -221,10 +223,11 @@ int path_strv_make_absolute_cwd(char **l) { return 0; } -char **path_strv_resolve(char **l, const char *prefix) { +char **path_strv_resolve(char **l, const char *root) { char **s; unsigned k = 0; bool enomem = false; + int r; if (strv_isempty(l)) return l; @@ -234,17 +237,17 @@ char **path_strv_resolve(char **l, const char *prefix) { * changes on failure. */ STRV_FOREACH(s, l) { - char *t, *u; _cleanup_free_ char *orig = NULL; + char *t, *u; if (!path_is_absolute(*s)) { free(*s); continue; } - if (prefix) { + if (root) { orig = *s; - t = strappend(prefix, orig); + t = prefix_root(root, orig); if (!t) { enomem = true; continue; @@ -252,28 +255,26 @@ char **path_strv_resolve(char **l, const char *prefix) { } else t = *s; - errno = 0; - u = canonicalize_file_name(t); - if (!u) { - if (errno == ENOENT) { - if (prefix) { - u = orig; - orig = NULL; - free(t); - } else - u = t; - } else { + r = chase_symlinks(t, root, 0, &u); + if (r == -ENOENT) { + if (root) { + u = orig; + orig = NULL; free(t); - if (errno == ENOMEM || errno == 0) - enomem = true; + } else + u = t; + } else if (r < 0) { + free(t); - continue; - } - } else if (prefix) { + if (r == -ENOMEM) + enomem = true; + + continue; + } else if (root) { char *x; free(t); - x = path_startswith(u, prefix); + x = path_startswith(u, root); if (x) { /* restore the slash if it was lost */ if (!startswith(x, "/")) @@ -289,9 +290,7 @@ char **path_strv_resolve(char **l, const char *prefix) { } else { /* canonicalized path goes outside of * prefix, keep the original path instead */ - free(u); - u = orig; - orig = NULL; + free_and_replace(u, orig); } } else free(t); @@ -307,12 +306,12 @@ char **path_strv_resolve(char **l, const char *prefix) { return l; } -char **path_strv_resolve_uniq(char **l, const char *prefix) { +char **path_strv_resolve_uniq(char **l, const char *root) { if (strv_isempty(l)) return l; - if (!path_strv_resolve(l, prefix)) + if (!path_strv_resolve(l, root)) return NULL; return strv_uniq(l); @@ -359,6 +358,16 @@ char* path_startswith(const char *path, const char *prefix) { assert(path); assert(prefix); + /* Returns a pointer to the start of the first component after the parts matched by + * the prefix, iff + * - both paths are absolute or both paths are relative, + * and + * - each component in prefix in turn matches a component in path at the same position. + * An empty string will be returned when the prefix and path are equivalent. + * + * Returns NULL otherwise. + */ + if ((path[0] == '/') != (prefix[0] == '/')) return NULL; @@ -449,13 +458,11 @@ char* path_join(const char *root, const char *path, const char *rest) { return strjoin(root, endswith(root, "/") ? "" : "/", path[0] == '/' ? path+1 : path, rest ? (endswith(path, "/") ? "" : "/") : NULL, - rest && rest[0] == '/' ? rest+1 : rest, - NULL); + rest && rest[0] == '/' ? rest+1 : rest); else return strjoin(path, rest ? (endswith(path, "/") ? "" : "/") : NULL, - rest && rest[0] == '/' ? rest+1 : rest, - NULL); + rest && rest[0] == '/' ? rest+1 : rest); } int find_binary(const char *name, char **ret) { @@ -499,7 +506,7 @@ int find_binary(const char *name, char **ret) { if (!path_is_absolute(element)) continue; - j = strjoin(element, "/", name, NULL); + j = strjoin(element, "/", name); if (!j) return -ENOMEM; @@ -817,8 +824,79 @@ bool is_device_path(const char *path) { /* Returns true on paths that refer to a device, either in * sysfs or in /dev */ - return - path_startswith(path, "/dev/") || - path_startswith(path, "/sys/"); + return path_startswith(path, "/dev/") || + path_startswith(path, "/sys/"); +} + +bool is_deviceallow_pattern(const char *path) { + return path_startswith(path, "/dev/") || + startswith(path, "block-") || + startswith(path, "char-"); +} + +int systemd_installation_has_version(const char *root, unsigned minimal_version) { + const char *pattern; + int r; + + /* Try to guess if systemd installation is later than the specified version. This + * is hacky and likely to yield false negatives, particularly if the installation + * is non-standard. False positives should be relatively rare. + */ + + NULSTR_FOREACH(pattern, + /* /lib works for systems without usr-merge, and for systems with a sane + * usr-merge, where /lib is a symlink to /usr/lib. /usr/lib is necessary + * for Gentoo which does a merge without making /lib a symlink. + */ + "lib/systemd/libsystemd-shared-*.so\0" + "usr/lib/systemd/libsystemd-shared-*.so\0") { + + _cleanup_strv_free_ char **names = NULL; + _cleanup_free_ char *path = NULL; + char *c, **name; + + path = prefix_root(root, pattern); + if (!path) + return -ENOMEM; + + r = glob_extend(&names, path); + if (r == -ENOENT) + continue; + if (r < 0) + return r; + + assert_se((c = endswith(path, "*.so"))); + *c = '\0'; /* truncate the glob part */ + + STRV_FOREACH(name, names) { + /* This is most likely to run only once, hence let's not optimize anything. */ + char *t, *t2; + unsigned version; + + t = startswith(*name, path); + if (!t) + continue; + + t2 = endswith(t, ".so"); + if (!t2) + continue; + + t2[0] = '\0'; /* truncate the suffix */ + + r = safe_atou(t, &version); + if (r < 0) { + log_debug_errno(r, "Found libsystemd shared at \"%s.so\", but failed to parse version: %m", *name); + continue; + } + + log_debug("Found libsystemd shared at \"%s.so\", version %u (%s).", + *name, version, + version >= minimal_version ? "OK" : "too old"); + if (version >= minimal_version) + return true; + } + } + + return false; } #endif /* NM_IGNORED */ diff --git a/src/systemd/src/basic/path-util.h b/src/systemd/src/basic/path-util.h index a27c13fc..349cdac7 100644 --- a/src/systemd/src/basic/path-util.h +++ b/src/systemd/src/basic/path-util.h @@ -24,6 +24,7 @@ #include #include "macro.h" +#include "string-util.h" #include "time-util.h" #define DEFAULT_PATH_NORMAL "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" @@ -65,9 +66,21 @@ static inline bool path_equal_ptr(const char *a, const char *b) { _found; \ }) +#define PATH_STARTSWITH_SET(p, ...) \ + ({ \ + char **s; \ + bool _found = false; \ + STRV_FOREACH(s, STRV_MAKE(__VA_ARGS__)) \ + if (path_startswith(p, *s)) { \ + _found = true; \ + break; \ + } \ + _found; \ + }) + int path_strv_make_absolute_cwd(char **l); -char** path_strv_resolve(char **l, const char *prefix); -char** path_strv_resolve_uniq(char **l, const char *prefix); +char** path_strv_resolve(char **l, const char *root); +char** path_strv_resolve_uniq(char **l, const char *root); int find_binary(const char *name, char **filename); @@ -125,3 +138,6 @@ char *file_in_same_dir(const char *path, const char *filename); bool hidden_or_backup_file(const char *filename) _pure_; bool is_device_path(const char *path); +bool is_deviceallow_pattern(const char *path); + +int systemd_installation_has_version(const char *root, unsigned minimal_version); diff --git a/src/systemd/src/basic/prioq.c b/src/systemd/src/basic/prioq.c index 809e2122..64ad638e 100644 --- a/src/systemd/src/basic/prioq.c +++ b/src/systemd/src/basic/prioq.c @@ -64,9 +64,7 @@ Prioq* prioq_free(Prioq *q) { return NULL; free(q->items); - free(q); - - return NULL; + return mfree(q); } int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func) { diff --git a/src/systemd/src/basic/socket-util.c b/src/systemd/src/basic/socket-util.c index be57d829..57bc4b70 100644 --- a/src/systemd/src/basic/socket-util.c +++ b/src/systemd/src/basic/socket-util.c @@ -36,7 +36,7 @@ #include "alloc-util.h" #include "fd-util.h" #include "fileio.h" -#include "formats-util.h" +#include "format-util.h" #include "log.h" #include "macro.h" #include "missing.h" @@ -444,7 +444,7 @@ const char* socket_address_get_path(const SocketAddress *a) { } bool socket_ipv6_is_supported(void) { - if (access("/proc/net/sockstat6", F_OK) != 0) + if (access("/proc/net/if_inet6", F_OK) != 0) return false; return true; @@ -1064,3 +1064,20 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng return NULL; } + +int socket_ioctl_fd(void) { + int fd; + + /* Create a socket to invoke the various network interface ioctl()s on. Traditionally only AF_INET was good for + * that. Since kernel 4.6 AF_NETLINK works for this too. We first try to use AF_INET hence, but if that's not + * available (for example, because it is made unavailable via SECCOMP or such), we'll fall back to the more + * generic AF_NETLINK. */ + + fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0); + if (fd < 0) + fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_GENERIC); + if (fd < 0) + return -errno; + + return fd; +} diff --git a/src/systemd/src/basic/socket-util.h b/src/systemd/src/basic/socket-util.h index 2536b085..2ef572ba 100644 --- a/src/systemd/src/basic/socket-util.h +++ b/src/systemd/src/basic/socket-util.h @@ -154,3 +154,5 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng 1 + strnlen(_sa->sun_path+1, sizeof(_sa->sun_path)-1) : \ strnlen(_sa->sun_path, sizeof(_sa->sun_path))); \ }) + +int socket_ioctl_fd(void); diff --git a/src/systemd/src/basic/sparse-endian.h b/src/systemd/src/basic/sparse-endian.h index c913fda8..a3573b84 100644 --- a/src/systemd/src/basic/sparse-endian.h +++ b/src/systemd/src/basic/sparse-endian.h @@ -26,19 +26,19 @@ #include #ifdef __CHECKER__ -#define __bitwise __attribute__((bitwise)) -#define __force __attribute__((force)) +#define __sd_bitwise __attribute__((bitwise)) +#define __sd_force __attribute__((force)) #else -#define __bitwise -#define __force +#define __sd_bitwise +#define __sd_force #endif -typedef uint16_t __bitwise le16_t; -typedef uint16_t __bitwise be16_t; -typedef uint32_t __bitwise le32_t; -typedef uint32_t __bitwise be32_t; -typedef uint64_t __bitwise le64_t; -typedef uint64_t __bitwise be64_t; +typedef uint16_t __sd_bitwise le16_t; +typedef uint16_t __sd_bitwise be16_t; +typedef uint32_t __sd_bitwise le32_t; +typedef uint32_t __sd_bitwise be32_t; +typedef uint64_t __sd_bitwise le64_t; +typedef uint64_t __sd_bitwise be64_t; #undef htobe16 #undef htole16 @@ -69,20 +69,23 @@ typedef uint64_t __bitwise be64_t; #define bswap_64_on_be(x) __bswap_64(x) #endif -static inline le16_t htole16(uint16_t value) { return (le16_t __force) bswap_16_on_be(value); } -static inline le32_t htole32(uint32_t value) { return (le32_t __force) bswap_32_on_be(value); } -static inline le64_t htole64(uint64_t value) { return (le64_t __force) bswap_64_on_be(value); } +static inline le16_t htole16(uint16_t value) { return (le16_t __sd_force) bswap_16_on_be(value); } +static inline le32_t htole32(uint32_t value) { return (le32_t __sd_force) bswap_32_on_be(value); } +static inline le64_t htole64(uint64_t value) { return (le64_t __sd_force) bswap_64_on_be(value); } -static inline be16_t htobe16(uint16_t value) { return (be16_t __force) bswap_16_on_le(value); } -static inline be32_t htobe32(uint32_t value) { return (be32_t __force) bswap_32_on_le(value); } -static inline be64_t htobe64(uint64_t value) { return (be64_t __force) bswap_64_on_le(value); } +static inline be16_t htobe16(uint16_t value) { return (be16_t __sd_force) bswap_16_on_le(value); } +static inline be32_t htobe32(uint32_t value) { return (be32_t __sd_force) bswap_32_on_le(value); } +static inline be64_t htobe64(uint64_t value) { return (be64_t __sd_force) bswap_64_on_le(value); } -static inline uint16_t le16toh(le16_t value) { return bswap_16_on_be((uint16_t __force)value); } -static inline uint32_t le32toh(le32_t value) { return bswap_32_on_be((uint32_t __force)value); } -static inline uint64_t le64toh(le64_t value) { return bswap_64_on_be((uint64_t __force)value); } +static inline uint16_t le16toh(le16_t value) { return bswap_16_on_be((uint16_t __sd_force)value); } +static inline uint32_t le32toh(le32_t value) { return bswap_32_on_be((uint32_t __sd_force)value); } +static inline uint64_t le64toh(le64_t value) { return bswap_64_on_be((uint64_t __sd_force)value); } -static inline uint16_t be16toh(be16_t value) { return bswap_16_on_le((uint16_t __force)value); } -static inline uint32_t be32toh(be32_t value) { return bswap_32_on_le((uint32_t __force)value); } -static inline uint64_t be64toh(be64_t value) { return bswap_64_on_le((uint64_t __force)value); } +static inline uint16_t be16toh(be16_t value) { return bswap_16_on_le((uint16_t __sd_force)value); } +static inline uint32_t be32toh(be32_t value) { return bswap_32_on_le((uint32_t __sd_force)value); } +static inline uint64_t be64toh(be64_t value) { return bswap_64_on_le((uint64_t __sd_force)value); } + +#undef __sd_bitwise +#undef __sd_force #endif /* SPARSE_ENDIAN_H */ diff --git a/src/systemd/src/basic/string-util.c b/src/systemd/src/basic/string-util.c index b4e774cc..aeb9e2a9 100644 --- a/src/systemd/src/basic/string-util.c +++ b/src/systemd/src/basic/string-util.c @@ -220,7 +220,7 @@ char *strappend(const char *s, const char *suffix) { return strnappend(s, suffix, suffix ? strlen(suffix) : 0); } -char *strjoin(const char *x, ...) { +char *strjoin_real(const char *x, ...) { va_list ap; size_t l; char *r, *p; @@ -446,7 +446,7 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le if (old_length <= 3 || old_length <= new_length) return strndup(s, old_length); - r = new0(char, new_length+1); + r = new0(char, new_length+3); if (!r) return NULL; @@ -456,12 +456,12 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le x = new_length - 3; memcpy(r, s, x); - r[x] = '.'; - r[x+1] = '.'; - r[x+2] = '.'; + r[x] = 0xe2; /* tri-dot ellipsis: … */ + r[x+1] = 0x80; + r[x+2] = 0xa6; memcpy(r + x + 3, - s + old_length - (new_length - x - 3), - new_length - x - 3); + s + old_length - (new_length - x - 1), + new_length - x - 1); return r; } @@ -614,8 +614,7 @@ char *strreplace(const char *text, const char *old_string, const char *new_strin return r; oom: - free(r); - return NULL; + return mfree(r); } char *strip_tab_ansi(char **ibuf, size_t *_isz) { @@ -686,8 +685,7 @@ char *strip_tab_ansi(char **ibuf, size_t *_isz) { if (ferror(f)) { fclose(f); - free(obuf); - return NULL; + return mfree(obuf); } fclose(f); diff --git a/src/systemd/src/basic/string-util.h b/src/systemd/src/basic/string-util.h index b75aba63..e99f7964 100644 --- a/src/systemd/src/basic/string-util.h +++ b/src/systemd/src/basic/string-util.h @@ -70,6 +70,10 @@ static inline const char *empty_to_null(const char *p) { return isempty(p) ? NULL : p; } +static inline const char *strdash_if_empty(const char *str) { + return isempty(str) ? "-" : str; +} + static inline char *startswith(const char *s, const char *prefix) { size_t l; @@ -103,16 +107,14 @@ const char* split(const char **state, size_t *l, const char *separator, bool quo #define FOREACH_WORD_SEPARATOR(word, length, s, separator, state) \ _FOREACH_WORD(word, length, s, separator, false, state) -#define FOREACH_WORD_QUOTED(word, length, s, state) \ - _FOREACH_WORD(word, length, s, WHITESPACE, true, state) - #define _FOREACH_WORD(word, length, s, separator, quoted, state) \ for ((state) = (s), (word) = split(&(state), &(length), (separator), (quoted)); (word); (word) = split(&(state), &(length), (separator), (quoted))) char *strappend(const char *s, const char *suffix); char *strnappend(const char *s, const char *suffix, size_t length); -char *strjoin(const char *x, ...) _sentinel_; +char *strjoin_real(const char *x, ...) _sentinel_; +#define strjoin(a, ...) strjoin_real((a), __VA_ARGS__, NULL) #define strjoina(a, ...) \ ({ \ diff --git a/src/systemd/src/basic/strv.c b/src/systemd/src/basic/strv.c index eeb8c1e0..a3660f08 100644 --- a/src/systemd/src/basic/strv.c +++ b/src/systemd/src/basic/strv.c @@ -89,8 +89,7 @@ void strv_clear(char **l) { char **strv_free(char **l) { strv_clear(l); - free(l); - return NULL; + return mfree(l); } char **strv_free_erase(char **l) { @@ -430,8 +429,7 @@ char *strv_join_quoted(char **l) { return buf; oom: - free(buf); - return NULL; + return mfree(buf); } int strv_push(char ***l, char *value) { @@ -873,8 +871,7 @@ char ***strv_free_free(char ***l) { for (i = l; *i; i++) strv_free(*i); - free(l); - return NULL; + return mfree(l); } char **strv_skip(char **l, size_t n) { diff --git a/src/systemd/src/basic/strv.h b/src/systemd/src/basic/strv.h index 683ce83a..385ad177 100644 --- a/src/systemd/src/basic/strv.h +++ b/src/systemd/src/basic/strv.h @@ -96,10 +96,13 @@ bool strv_overlap(char **a, char **b) _pure_; #define STRV_FOREACH(s, l) \ for ((s) = (l); (s) && *(s); (s)++) -#define STRV_FOREACH_BACKWARDS(s, l) \ - STRV_FOREACH(s, l) \ - ; \ - for ((s)--; (l) && ((s) >= (l)); (s)--) +#define STRV_FOREACH_BACKWARDS(s, l) \ + for (s = ({ \ + char **_l = l; \ + _l ? _l + strv_length(_l) - 1U : NULL; \ + }); \ + (l) && ((s) >= (l)); \ + (s)--) #define STRV_FOREACH_PAIR(x, y, l) \ for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1)) @@ -141,6 +144,11 @@ void strv_print(char **l); }) #define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x) +#define STRPTR_IN_SET(x, ...) \ + ({ \ + const char* _x = (x); \ + _x && strv_contains(STRV_MAKE(__VA_ARGS__), _x); \ + }) #define FOREACH_STRING(x, ...) \ for (char **_l = ({ \ diff --git a/src/systemd/src/basic/time-util.c b/src/systemd/src/basic/time-util.c index 212c8f4e..f6de8ca5 100644 --- a/src/systemd/src/basic/time-util.c +++ b/src/systemd/src/basic/time-util.c @@ -42,8 +42,6 @@ #include "strv.h" #include "time-util.h" -static nsec_t timespec_load_nsec(const struct timespec *ts); - static clockid_t map_clock_id(clockid_t c) { /* Some more exotic archs (s390, ppc, …) lack the "ALARM" flavour of the clocks. Thus, clock_gettime() will @@ -200,7 +198,7 @@ usec_t timespec_load(const struct timespec *ts) { (usec_t) ts->tv_nsec / NSEC_PER_USEC; } -static nsec_t timespec_load_nsec(const struct timespec *ts) { +nsec_t timespec_load_nsec(const struct timespec *ts) { assert(ts); if (ts->tv_sec == (time_t) -1 && ts->tv_nsec == (long) -1) @@ -314,7 +312,7 @@ static char *format_timestamp_internal( if (n + 8 > l) return NULL; /* Microseconds part doesn't fit. */ - sprintf(buf + n, ".%06llu", (unsigned long long) (t % USEC_PER_SEC)); + sprintf(buf + n, ".%06"PRI_USEC, t % USEC_PER_SEC); } /* Append the timezone */ @@ -505,11 +503,11 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { if (j > 0) { k = snprintf(p, l, - "%s"USEC_FMT".%0*llu%s", + "%s"USEC_FMT".%0*"PRI_USEC"%s", p > buf ? " " : "", a, j, - (unsigned long long) b, + b, table[i].suffix); t = 0; @@ -890,6 +888,7 @@ static char* extract_multiplier(char *p, usec_t *multiplier) { { "y", USEC_PER_YEAR }, { "usec", 1ULL }, { "us", 1ULL }, + { "µs", 1ULL }, }; unsigned i; @@ -1023,6 +1022,7 @@ int parse_nsec(const char *t, nsec_t *nsec) { { "y", NSEC_PER_YEAR }, { "usec", NSEC_PER_USEC }, { "us", NSEC_PER_USEC }, + { "µs", NSEC_PER_USEC }, { "nsec", 1ULL }, { "ns", 1ULL }, { "", 1ULL }, /* default is nsec */ @@ -1329,7 +1329,7 @@ unsigned long usec_to_jiffies(usec_t u) { r = sysconf(_SC_CLK_TCK); assert(r > 0); - hz = (unsigned long) r; + hz = r; } return DIV_ROUND_UP(u , USEC_PER_SEC / hz); diff --git a/src/systemd/src/basic/time-util.h b/src/systemd/src/basic/time-util.h index 99be5ce6..f67a4474 100644 --- a/src/systemd/src/basic/time-util.h +++ b/src/systemd/src/basic/time-util.h @@ -29,8 +29,10 @@ typedef uint64_t usec_t; typedef uint64_t nsec_t; -#define NSEC_FMT "%" PRIu64 -#define USEC_FMT "%" PRIu64 +#define PRI_NSEC PRIu64 +#define PRI_USEC PRIu64 +#define NSEC_FMT "%" PRI_NSEC +#define USEC_FMT "%" PRI_USEC #include "macro.h" @@ -111,6 +113,7 @@ static inline bool triple_timestamp_is_set(triple_timestamp *ts) { usec_t triple_timestamp_by_clock(triple_timestamp *ts, clockid_t clock); usec_t timespec_load(const struct timespec *ts) _pure_; +nsec_t timespec_load_nsec(const struct timespec *ts) _pure_; struct timespec *timespec_store(struct timespec *ts, usec_t u); usec_t timeval_load(const struct timeval *tv) _pure_; diff --git a/src/systemd/src/basic/util.c b/src/systemd/src/basic/util.c index 79c7aa46..09651e7d 100644 --- a/src/systemd/src/basic/util.c +++ b/src/systemd/src/basic/util.c @@ -20,7 +20,6 @@ #include "nm-sd-adapt.h" #include -#include #include #include #include @@ -43,7 +42,7 @@ #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" -#include "formats-util.h" +#include "format-util.h" #include "hashmap.h" #include "hostname-util.h" #include "log.h" @@ -136,7 +135,7 @@ static int do_execute(char **directories, usec_t timeout, char *argv[]) { if (r < 0) return log_oom(); - path = strjoin(*directory, "/", de->d_name, NULL); + path = strjoin(*directory, "/", de->d_name); if (!path) return log_oom(); @@ -472,7 +471,7 @@ bool in_initrd(void) { * 2. the root file system must be a memory file system * * The second check is extra paranoia, since misdetecting an - * initrd can have bad bad consequences due the initrd + * initrd can have bad consequences due the initrd * emptying when transititioning to the main systemd. */ @@ -498,7 +497,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, u = nmemb; while (l < u) { idx = (l + u) / 2; - p = (void *)(((const char *) base) + (idx * size)); + p = (const char *) base + idx * size; comparison = compar(key, p, arg); if (comparison < 0) u = idx; @@ -513,28 +512,17 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, int on_ac_power(void) { bool found_offline = false, found_online = false; _cleanup_closedir_ DIR *d = NULL; + struct dirent *de; d = opendir("/sys/class/power_supply"); if (!d) return errno == ENOENT ? true : -errno; - for (;;) { - struct dirent *de; + FOREACH_DIRENT(de, d, return -errno) { _cleanup_close_ int fd = -1, device = -1; char contents[6]; ssize_t n; - errno = 0; - de = readdir(d); - if (!de && errno > 0) - return -errno; - - if (!de) - break; - - if (hidden_or_backup_file(de->d_name)) - continue; - device = openat(dirfd(d), de->d_name, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_NOCTTY); if (device < 0) { if (errno == ENOENT || errno == ENOTDIR) diff --git a/src/systemd/src/basic/util.h b/src/systemd/src/basic/util.h index bb2fc318..c3802a81 100644 --- a/src/systemd/src/basic/util.h +++ b/src/systemd/src/basic/util.h @@ -41,7 +41,7 @@ #include #include -#include "formats-util.h" +#include "format-util.h" #include "macro.h" #include "missing.h" #include "time-util.h" diff --git a/src/systemd/src/libsystemd-network/dhcp-internal.h b/src/systemd/src/libsystemd-network/dhcp-internal.h index 99f69089..3fdf02da 100644 --- a/src/systemd/src/libsystemd-network/dhcp-internal.h +++ b/src/systemd/src/libsystemd-network/dhcp-internal.h @@ -30,10 +30,11 @@ #include "dhcp-protocol.h" #include "socket-util.h" -int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link, +int dhcp_network_bind_raw_socket(int ifindex, union sockaddr_union *link, uint32_t xid, const uint8_t *mac_addr, - size_t mac_addr_len, uint16_t arp_type); -int dhcp_network_bind_udp_socket(be32_t address, uint16_t port); + size_t mac_addr_len, uint16_t arp_type, + uint16_t port); +int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port); int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link, const void *packet, size_t len); int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port, @@ -57,7 +58,7 @@ void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr, uint16_t source, be32_t destination_addr, uint16_t destination, uint16_t len); -int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum); +int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, uint16_t port); /* If we are invoking callbacks of a dhcp-client, ensure unreffing the * client from the callback doesn't destroy the object we are working diff --git a/src/systemd/src/libsystemd-network/dhcp-network.c b/src/systemd/src/libsystemd-network/dhcp-network.c index f1856d0a..7ad0ec37 100644 --- a/src/systemd/src/libsystemd-network/dhcp-network.c +++ b/src/systemd/src/libsystemd-network/dhcp-network.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -38,7 +39,8 @@ static int _bind_raw_socket(int ifindex, union sockaddr_union *link, size_t mac_addr_len, const uint8_t *bcast_addr, const struct ether_addr *eth_mac, - uint16_t arp_type, uint8_t dhcp_hlen) { + uint16_t arp_type, uint8_t dhcp_hlen, + uint16_t port) { struct sock_filter filter[] = { BPF_STMT(BPF_LD + BPF_W + BPF_LEN, 0), /* A <- packet length */ BPF_JUMP(BPF_JMP + BPF_JGE + BPF_K, sizeof(DHCPPacket), 1, 0), /* packet >= DHCPPacket ? */ @@ -55,7 +57,7 @@ static int _bind_raw_socket(int ifindex, union sockaddr_union *link, BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 1, 0), /* A == 0 ? */ BPF_STMT(BPF_RET + BPF_K, 0), /* ignore */ BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(DHCPPacket, udp.dest)), /* A <- UDP destination port */ - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, DHCP_PORT_CLIENT, 1, 0), /* UDP destination port == DHCP client port ? */ + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, port, 1, 0), /* UDP destination port == DHCP client port ? */ BPF_STMT(BPF_RET + BPF_K, 0), /* ignore */ BPF_STMT(BPF_LD + BPF_B + BPF_ABS, offsetof(DHCPPacket, dhcp.op)), /* A <- DHCP op */ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, BOOTREPLY, 1, 0), /* op == BOOTREPLY ? */ @@ -127,7 +129,8 @@ static int _bind_raw_socket(int ifindex, union sockaddr_union *link, int dhcp_network_bind_raw_socket(int ifindex, union sockaddr_union *link, uint32_t xid, const uint8_t *mac_addr, - size_t mac_addr_len, uint16_t arp_type) { + size_t mac_addr_len, uint16_t arp_type, + uint16_t port) { static const uint8_t eth_bcast[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; /* Default broadcast address for IPoIB */ static const uint8_t ib_bcast[] = { @@ -153,16 +156,17 @@ int dhcp_network_bind_raw_socket(int ifindex, union sockaddr_union *link, return -EINVAL; return _bind_raw_socket(ifindex, link, xid, mac_addr, mac_addr_len, - bcast_addr, ð_mac, arp_type, dhcp_hlen); + bcast_addr, ð_mac, arp_type, dhcp_hlen, port); } -int dhcp_network_bind_udp_socket(be32_t address, uint16_t port) { +int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port) { union sockaddr_union src = { .in.sin_family = AF_INET, .in.sin_port = htobe16(port), .in.sin_addr.s_addr = address, }; _cleanup_close_ int s = -1; + char ifname[IF_NAMESIZE] = ""; int r, on = 1, tos = IPTOS_CLASS_CS6; s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); @@ -177,6 +181,15 @@ int dhcp_network_bind_udp_socket(be32_t address, uint16_t port) { if (r < 0) return -errno; + if (ifindex > 0) { + if (if_indextoname(ifindex, ifname) == 0) + return -errno; + + r = setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, ifname, strlen(ifname)); + if (r < 0) + return -errno; + } + if (address == INADDR_ANY) { r = setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on)); if (r < 0) @@ -185,6 +198,7 @@ int dhcp_network_bind_udp_socket(be32_t address, uint16_t port) { r = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)); if (r < 0) return -errno; + } else { r = setsockopt(s, IPPROTO_IP, IP_FREEBIND, &on, sizeof(on)); if (r < 0) diff --git a/src/systemd/src/libsystemd-network/dhcp-packet.c b/src/systemd/src/libsystemd-network/dhcp-packet.c index 90d09912..27410520 100644 --- a/src/systemd/src/libsystemd-network/dhcp-packet.c +++ b/src/systemd/src/libsystemd-network/dhcp-packet.c @@ -116,7 +116,7 @@ void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr, packet->ip.check = dhcp_packet_checksum((uint8_t*)&packet->ip, DHCP_IP_SIZE); } -int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum) { +int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, uint16_t port) { size_t hdrlen; assert(packet); @@ -162,10 +162,10 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum) { return -EINVAL; } - if (be16toh(packet->udp.dest) != DHCP_PORT_CLIENT) { + if (be16toh(packet->udp.dest) != port) { log_debug("ignoring packet: to port %u, which " "is not the DHCP client port (%u)", - be16toh(packet->udp.dest), DHCP_PORT_CLIENT); + be16toh(packet->udp.dest), port); return -EINVAL; } diff --git a/src/systemd/src/libsystemd-network/network-internal.c b/src/systemd/src/libsystemd-network/network-internal.c index 46bddfeb..285a73e3 100644 --- a/src/systemd/src/libsystemd-network/network-internal.c +++ b/src/systemd/src/libsystemd-network/network-internal.c @@ -89,6 +89,28 @@ int net_get_unique_predictable_data(struct udev_device *device, uint64_t *result return 0; } +static bool net_condition_test_strv(char * const *raw_patterns, + const char *string) { + if (strv_isempty(raw_patterns)) + return true; + + /* If the patterns begin with "!", edit it out and negate the test. */ + if (raw_patterns[0][0] == '!') { + char **patterns; + unsigned i, length; + + length = strv_length(raw_patterns) + 1; /* Include the NULL. */ + patterns = newa(char*, length); + patterns[0] = raw_patterns[0] + 1; /* Skip the "!". */ + for (i = 1; i < length; i++) + patterns[i] = raw_patterns[i]; + + return !string || !strv_fnmatch(patterns, string, 0); + } + + return string && strv_fnmatch(raw_patterns, string, 0); +} + bool net_match_config(const struct ether_addr *match_mac, char * const *match_paths, char * const *match_drivers, @@ -120,20 +142,16 @@ bool net_match_config(const struct ether_addr *match_mac, if (match_mac && (!dev_mac || memcmp(match_mac, dev_mac, ETH_ALEN))) return false; - if (!strv_isempty(match_paths) && - (!dev_path || !strv_fnmatch(match_paths, dev_path, 0))) + if (!net_condition_test_strv(match_paths, dev_path)) return false; - if (!strv_isempty(match_drivers) && - (!dev_driver || !strv_fnmatch(match_drivers, dev_driver, 0))) + if (!net_condition_test_strv(match_drivers, dev_driver)) return false; - if (!strv_isempty(match_types) && - (!dev_type || !strv_fnmatch_or_empty(match_types, dev_type, 0))) + if (!net_condition_test_strv(match_types, dev_type)) return false; - if (!strv_isempty(match_names) && - (!dev_name || !strv_fnmatch_or_empty(match_names, dev_name, 0))) + if (!net_condition_test_strv(match_names, dev_name)) return false; return true; diff --git a/src/systemd/src/libsystemd-network/sd-dhcp-client.c b/src/systemd/src/libsystemd-network/sd-dhcp-client.c index f740075a..7809a812 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp-client.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp-client.c @@ -57,6 +57,7 @@ struct sd_dhcp_client { sd_event_source *timeout_resend; int ifindex; int fd; + uint16_t port; union sockaddr_union link; sd_event_source *receive_message; bool request_broadcast; @@ -389,43 +390,32 @@ int sd_dhcp_client_set_hostname( sd_dhcp_client *client, const char *hostname) { - char *new_hostname = NULL; - assert_return(client, -EINVAL); - if (!hostname_is_valid(hostname, false) && !dns_name_is_valid(hostname)) + /* Refuse hostnames that neither qualify as DNS nor as Linux hosntames */ + if (hostname && + !(hostname_is_valid(hostname, false) || dns_name_is_valid(hostname) > 0)) return -EINVAL; - if (streq_ptr(client->hostname, hostname)) - return 0; - - if (hostname) { - new_hostname = strdup(hostname); - if (!new_hostname) - return -ENOMEM; - } - - free(client->hostname); - client->hostname = new_hostname; - - return 0; + return free_and_strdup(&client->hostname, hostname); } int sd_dhcp_client_set_vendor_class_identifier( sd_dhcp_client *client, const char *vci) { - char *new_vci = NULL; - assert_return(client, -EINVAL); - new_vci = strdup(vci); - if (!new_vci) - return -ENOMEM; + return free_and_strdup(&client->vendor_class_identifier, vci); +} - free(client->vendor_class_identifier); +int sd_dhcp_client_set_client_port( + sd_dhcp_client *client, + uint16_t port) { + + assert_return(client, -EINVAL); - client->vendor_class_identifier = new_vci; + client->port = port; return 0; } @@ -672,7 +662,7 @@ static int dhcp_client_send_raw( DHCPPacket *packet, size_t len) { - dhcp_packet_append_ip_headers(packet, INADDR_ANY, DHCP_PORT_CLIENT, + dhcp_packet_append_ip_headers(packet, INADDR_ANY, client->port, INADDR_BROADCAST, DHCP_PORT_SERVER, len); return dhcp_network_send_raw_socket(client->fd, &client->link, @@ -1124,7 +1114,7 @@ static int client_start_delayed(sd_dhcp_client *client) { r = dhcp_network_bind_raw_socket(client->ifindex, &client->link, client->xid, client->mac_addr, - client->mac_addr_len, client->arp_type); + client->mac_addr_len, client->arp_type, client->port); if (r < 0) { client_stop(client, r); return r; @@ -1174,7 +1164,8 @@ static int client_timeout_t2(sd_event_source *s, uint64_t usec, void *userdata) r = dhcp_network_bind_raw_socket(client->ifindex, &client->link, client->xid, client->mac_addr, - client->mac_addr_len, client->arp_type); + client->mac_addr_len, client->arp_type, + client->port); if (r < 0) { client_stop(client, r); return 0; @@ -1559,8 +1550,7 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i goto error; } - r = dhcp_network_bind_udp_socket(client->lease->address, - DHCP_PORT_CLIENT); + r = dhcp_network_bind_udp_socket(client->ifindex, client->lease->address, client->port); if (r < 0) { log_dhcp_client(client, "could not bind UDP socket"); goto error; @@ -1770,7 +1760,7 @@ static int client_receive_message_raw( } } - r = dhcp_packet_verify_headers(packet, len, checksum); + r = dhcp_packet_verify_headers(packet, len, checksum, client->port); if (r < 0) return 0; @@ -1877,9 +1867,7 @@ sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client) { free(client->req_opts); free(client->hostname); free(client->vendor_class_identifier); - free(client); - - return NULL; + return mfree(client); } int sd_dhcp_client_new(sd_dhcp_client **ret) { @@ -1897,6 +1885,7 @@ int sd_dhcp_client_new(sd_dhcp_client **ret) { client->fd = -1; client->attempt = 1; client->mtu = DHCP_DEFAULT_MIN_SIZE; + client->port = DHCP_PORT_CLIENT; client->req_opts_size = ELEMENTSOF(default_req_opts); client->req_opts = memdup(default_req_opts, client->req_opts_size); diff --git a/src/systemd/src/libsystemd-network/sd-dhcp-lease.c b/src/systemd/src/libsystemd-network/sd-dhcp-lease.c index b0f0a844..5a3bff2f 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp-lease.c @@ -284,9 +284,7 @@ sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease) { free(lease->static_route); free(lease->client_id); free(lease->vendor_specific); - free(lease); - - return NULL; + return mfree(lease); } static int lease_parse_u32(const uint8_t *option, size_t len, uint32_t *ret, uint32_t min) { @@ -387,6 +385,23 @@ static int lease_parse_domain(const uint8_t *option, size_t len, char **ret) { return 0; } +static void filter_bogus_addresses(struct in_addr *addresses, size_t *n) { + size_t i, j; + + /* Silently filter DNS/NTP servers supplied to us that do not make outside of the local scope. */ + + for (i = 0, j = 0; i < *n; i ++) { + + if (in4_addr_is_null(addresses+i) || + in4_addr_is_localhost(addresses+i)) + continue; + + addresses[j++] = addresses[i]; + } + + *n = j; +} + static int lease_parse_in_addrs(const uint8_t *option, size_t len, struct in_addr **ret, size_t *n_ret) { assert(option); assert(ret); @@ -408,6 +423,8 @@ static int lease_parse_in_addrs(const uint8_t *option, size_t len, struct in_add if (!addresses) return -ENOMEM; + filter_bogus_addresses(addresses, &n_addresses); + free(*ret); *ret = addresses; *n_ret = n_addresses; diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c index a05bde63..4615cb40 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c @@ -1304,9 +1304,7 @@ sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client) { sd_dhcp6_client_detach_event(client); free(client->req_opts); - free(client); - - return NULL; + return mfree(client); } int sd_dhcp6_client_new(sd_dhcp6_client **ret) { diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c b/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c index 0070a78f..5419048f 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp6-lease.c @@ -391,9 +391,7 @@ sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease) { free(lease->ntp); lease->ntp_fqdn = strv_free(lease->ntp_fqdn); - free(lease); - - return NULL; + return mfree(lease); } int dhcp6_lease_new(sd_dhcp6_lease **ret) { diff --git a/src/systemd/src/libsystemd-network/sd-ipv4acd.c b/src/systemd/src/libsystemd-network/sd-ipv4acd.c index 59830795..913c1adb 100644 --- a/src/systemd/src/libsystemd-network/sd-ipv4acd.c +++ b/src/systemd/src/libsystemd-network/sd-ipv4acd.c @@ -137,9 +137,7 @@ sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *acd) { ipv4acd_reset(acd); sd_ipv4acd_detach_event(acd); - free(acd); - - return NULL; + return mfree(acd); } int sd_ipv4acd_new(sd_ipv4acd **ret) { diff --git a/src/systemd/src/libsystemd-network/sd-ipv4ll.c b/src/systemd/src/libsystemd-network/sd-ipv4ll.c index dc2fa370..2420c99f 100644 --- a/src/systemd/src/libsystemd-network/sd-ipv4ll.c +++ b/src/systemd/src/libsystemd-network/sd-ipv4ll.c @@ -92,9 +92,7 @@ sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll) { return NULL; sd_ipv4acd_unref(ll->acd); - free(ll); - - return NULL; + return mfree(ll); } int sd_ipv4ll_new(sd_ipv4ll **ret) { diff --git a/src/systemd/src/libsystemd-network/sd-lldp.c b/src/systemd/src/libsystemd-network/sd-lldp.c index f1ae6dac..66c9780e 100644 --- a/src/systemd/src/libsystemd-network/sd-lldp.c +++ b/src/systemd/src/libsystemd-network/sd-lldp.c @@ -376,9 +376,7 @@ _public_ sd_lldp* sd_lldp_unref(sd_lldp *lldp) { hashmap_free(lldp->neighbor_by_id); prioq_free(lldp->neighbor_by_expiry); - free(lldp); - - return NULL; + return mfree(lldp); } _public_ int sd_lldp_new(sd_lldp **ret) { diff --git a/src/systemd/src/libsystemd/sd-event/sd-event.c b/src/systemd/src/libsystemd/sd-event/sd-event.c index 0d400661..a51ab9e6 100644 --- a/src/systemd/src/libsystemd/sd-event/sd-event.c +++ b/src/systemd/src/libsystemd/sd-event/sd-event.c @@ -1543,7 +1543,8 @@ _public_ int sd_event_source_get_priority(sd_event_source *s, int64_t *priority) assert_return(s, -EINVAL); assert_return(!event_pid_changed(s->event), -ECHILD); - return s->priority; + *priority = s->priority; + return 0; } _public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority) { diff --git a/src/systemd/src/libsystemd/sd-id128/id128-util.c b/src/systemd/src/libsystemd/sd-id128/id128-util.c index c16052d8..57525ddb 100644 --- a/src/systemd/src/libsystemd/sd-id128/id128-util.c +++ b/src/systemd/src/libsystemd/sd-id128/id128-util.c @@ -191,10 +191,23 @@ int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) { int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync) { _cleanup_close_ int fd = -1; - fd = open(p, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444); + fd = open(p, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY|O_TRUNC, 0444); if (fd < 0) return -errno; return id128_write_fd(fd, f, id, do_sync); } + +void id128_hash_func(const void *p, struct siphash *state) { + siphash24_compress(p, 16, state); +} + +int id128_compare_func(const void *a, const void *b) { + return memcmp(a, b, 16); +} + +const struct hash_ops id128_hash_ops = { + .hash = id128_hash_func, + .compare = id128_compare_func, +}; #endif /* NM_IGNORED */ diff --git a/src/systemd/src/libsystemd/sd-id128/id128-util.h b/src/systemd/src/libsystemd/sd-id128/id128-util.h index 3ba59acb..6b3855ac 100644 --- a/src/systemd/src/libsystemd/sd-id128/id128-util.h +++ b/src/systemd/src/libsystemd/sd-id128/id128-util.h @@ -22,6 +22,8 @@ #include #include "sd-id128.h" + +#include "hash-funcs.h" #include "macro.h" char *id128_to_uuid_string(sd_id128_t id, char s[37]); @@ -43,3 +45,7 @@ int id128_read(const char *p, Id128Format f, sd_id128_t *ret); int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync); int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync); + +void id128_hash_func(const void *p, struct siphash *state); +int id128_compare_func(const void *a, const void *b) _pure_; +extern const struct hash_ops id128_hash_ops; diff --git a/src/systemd/src/libsystemd/sd-id128/sd-id128.c b/src/systemd/src/libsystemd/sd-id128/sd-id128.c index 9408c32b..9920bfdf 100644 --- a/src/systemd/src/libsystemd/sd-id128/sd-id128.c +++ b/src/systemd/src/libsystemd/sd-id128/sd-id128.c @@ -25,12 +25,16 @@ #include "sd-id128.h" +#include "alloc-util.h" #include "fd-util.h" #include "hexdecoct.h" #include "id128-util.h" #include "io-util.h" +#include "khash.h" #include "macro.h" +#include "missing.h" #include "random-util.h" +#include "user-util.h" #include "util.h" #if 0 /* NM_IGNORED */ @@ -134,6 +138,143 @@ _public_ int sd_id128_get_boot(sd_id128_t *ret) { } #if 0 /* NM_IGNORED */ +static int get_invocation_from_keyring(sd_id128_t *ret) { + + _cleanup_free_ char *description = NULL; + char *d, *p, *g, *u, *e; + unsigned long perms; + key_serial_t key; + size_t sz = 256; + uid_t uid; + gid_t gid; + int r, c; + +#define MAX_PERMS ((unsigned long) (KEY_POS_VIEW|KEY_POS_READ|KEY_POS_SEARCH| \ + KEY_USR_VIEW|KEY_USR_READ|KEY_USR_SEARCH)) + + assert(ret); + + key = request_key("user", "invocation_id", NULL, 0); + if (key == -1) { + /* Keyring support not available? No invocation key stored? */ + if (IN_SET(errno, ENOSYS, ENOKEY)) + return 0; + + return -errno; + } + + for (;;) { + description = new(char, sz); + if (!description) + return -ENOMEM; + + c = keyctl(KEYCTL_DESCRIBE, key, (unsigned long) description, sz, 0); + if (c < 0) + return -errno; + + if ((size_t) c <= sz) + break; + + sz = c; + free(description); + } + + /* The kernel returns a final NUL in the string, verify that. */ + assert(description[c-1] == 0); + + /* Chop off the final description string */ + d = strrchr(description, ';'); + if (!d) + return -EIO; + *d = 0; + + /* Look for the permissions */ + p = strrchr(description, ';'); + if (!p) + return -EIO; + + errno = 0; + perms = strtoul(p + 1, &e, 16); + if (errno > 0) + return -errno; + if (e == p + 1) /* Read at least one character */ + return -EIO; + if (e != d) /* Must reached the end */ + return -EIO; + + if ((perms & ~MAX_PERMS) != 0) + return -EPERM; + + *p = 0; + + /* Look for the group ID */ + g = strrchr(description, ';'); + if (!g) + return -EIO; + r = parse_gid(g + 1, &gid); + if (r < 0) + return r; + if (gid != 0) + return -EPERM; + *g = 0; + + /* Look for the user ID */ + u = strrchr(description, ';'); + if (!u) + return -EIO; + r = parse_uid(u + 1, &uid); + if (r < 0) + return r; + if (uid != 0) + return -EPERM; + + c = keyctl(KEYCTL_READ, key, (unsigned long) ret, sizeof(sd_id128_t), 0); + if (c < 0) + return -errno; + if (c != sizeof(sd_id128_t)) + return -EIO; + + return 1; +} + +_public_ int sd_id128_get_invocation(sd_id128_t *ret) { + static thread_local sd_id128_t saved_invocation_id = {}; + int r; + + assert_return(ret, -EINVAL); + + if (sd_id128_is_null(saved_invocation_id)) { + + /* We first try to read the invocation ID from the kernel keyring. This has the benefit that it is not + * fakeable by unprivileged code. If the information is not available in the keyring, we use + * $INVOCATION_ID but ignore the data if our process was called by less privileged code + * (i.e. secure_getenv() instead of getenv()). + * + * The kernel keyring is only relevant for system services (as for user services we don't store the + * invocation ID in the keyring, as there'd be no trust benefit in that). The environment variable is + * primarily relevant for user services, and sufficiently safe as no privilege boundary is involved. */ + + r = get_invocation_from_keyring(&saved_invocation_id); + if (r < 0) + return r; + + if (r == 0) { + const char *e; + + e = secure_getenv("INVOCATION_ID"); + if (!e) + return -ENXIO; + + r = sd_id128_from_string(e, &saved_invocation_id); + if (r < 0) + return r; + } + } + + *ret = saved_invocation_id; + return 0; +} + static sd_id128_t make_v4_uuid(sd_id128_t id) { /* Stolen from generate_random_uuid() of drivers/char/random.c * in the kernel sources */ @@ -164,4 +305,35 @@ _public_ int sd_id128_randomize(sd_id128_t *ret) { *ret = make_v4_uuid(t); return 0; } + +_public_ int sd_id128_get_machine_app_specific(sd_id128_t app_id, sd_id128_t *ret) { + _cleanup_(khash_unrefp) khash *h = NULL; + sd_id128_t m, result; + const void *p; + int r; + + assert_return(ret, -EINVAL); + + r = sd_id128_get_machine(&m); + if (r < 0) + return r; + + r = khash_new_with_key(&h, "hmac(sha256)", &m, sizeof(m)); + if (r < 0) + return r; + + r = khash_put(h, &app_id, sizeof(app_id)); + if (r < 0) + return r; + + r = khash_digest_data(h, &p); + if (r < 0) + return r; + + /* We chop off the trailing 16 bytes */ + memcpy(&result, p, MIN(khash_get_size(h), sizeof(result))); + + *ret = make_v4_uuid(result); + return 0; +} #endif /* NM_IGNORED */ diff --git a/src/systemd/src/shared/dns-domain.c b/src/systemd/src/shared/dns-domain.c index e147637b..5ed27191 100644 --- a/src/systemd/src/shared/dns-domain.c +++ b/src/systemd/src/shared/dns-domain.c @@ -133,6 +133,10 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) { if (r == 0 && *n) return -EINVAL; + /* More than one trailing dot? */ + if (*n == '.') + return -EINVAL; + if (sz >= 1 && d) *d = 0; @@ -1077,7 +1081,7 @@ int dns_service_split(const char *joined, char **_name, char **_type, char **_do if (!name) return -ENOMEM; - type = strjoin(b, ".", c, NULL); + type = strjoin(b, ".", c); if (!type) return -ENOMEM; @@ -1091,7 +1095,7 @@ int dns_service_split(const char *joined, char **_name, char **_type, char **_do name = NULL; - type = strjoin(a, ".", b, NULL); + type = strjoin(a, ".", b); if (!type) return -ENOMEM; @@ -1325,4 +1329,16 @@ int dns_name_apply_idna(const char *name, char **ret) { return (int) n; } + +int dns_name_is_valid_or_address(const char *name) { + /* Returns > 0 if the specified name is either a valid IP address formatted as string or a valid DNS name */ + + if (isempty(name)) + return 0; + + if (in_addr_from_string_auto(name, NULL, NULL) >= 0) + return 1; + + return dns_name_is_valid(name); +} #endif /* NM_IGNORED */ diff --git a/src/systemd/src/shared/dns-domain.h b/src/systemd/src/shared/dns-domain.h index af780f0b..03f16036 100644 --- a/src/systemd/src/shared/dns-domain.h +++ b/src/systemd/src/shared/dns-domain.h @@ -107,3 +107,5 @@ int dns_name_equal_skip(const char *a, unsigned n_labels, const char *b); int dns_name_common_suffix(const char *a, const char *b, const char **ret); int dns_name_apply_idna(const char *name, char **ret); + +int dns_name_is_valid_or_address(const char *name); diff --git a/src/systemd/src/systemd/sd-dhcp-client.h b/src/systemd/src/systemd/sd-dhcp-client.h index 9a90c2ed..ffe7f836 100644 --- a/src/systemd/src/systemd/sd-dhcp-client.h +++ b/src/systemd/src/systemd/sd-dhcp-client.h @@ -126,6 +126,9 @@ int sd_dhcp_client_get_client_id( int sd_dhcp_client_set_mtu( sd_dhcp_client *client, uint32_t mtu); +int sd_dhcp_client_set_client_port( + sd_dhcp_client *client, + uint16_t port); int sd_dhcp_client_set_hostname( sd_dhcp_client *client, const char *hostname); diff --git a/src/systemd/src/systemd/sd-id128.h b/src/systemd/src/systemd/sd-id128.h index 4dff0b9b..6cc8e4ac 100644 --- a/src/systemd/src/systemd/sd-id128.h +++ b/src/systemd/src/systemd/sd-id128.h @@ -39,14 +39,14 @@ union sd_id128 { #define SD_ID128_STRING_MAX 33 char *sd_id128_to_string(sd_id128_t id, char s[SD_ID128_STRING_MAX]); - int sd_id128_from_string(const char *s, sd_id128_t *ret); int sd_id128_randomize(sd_id128_t *ret); int sd_id128_get_machine(sd_id128_t *ret); - +int sd_id128_get_machine_app_specific(sd_id128_t app_id, sd_id128_t *ret); int sd_id128_get_boot(sd_id128_t *ret); +int sd_id128_get_invocation(sd_id128_t *ret); #define SD_ID128_MAKE(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) \ ((const sd_id128_t) { .bytes = { 0x##v0, 0x##v1, 0x##v2, 0x##v3, 0x##v4, 0x##v5, 0x##v6, 0x##v7, \ diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am deleted file mode 100644 index 8851c242..00000000 --- a/src/tests/Makefile.am +++ /dev/null @@ -1,187 +0,0 @@ -SUBDIRS = config - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/dhcp-manager \ - -I$(top_srcdir)/src/devices \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) - -AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) - -noinst_PROGRAMS = \ - test-general \ - test-general-with-expect \ - test-ip4-config \ - test-ip6-config \ - test-route-manager-linux \ - test-route-manager-fake \ - test-dcb \ - test-systemd \ - test-resolvconf-capture \ - test-wired-defname \ - test-utils - -####### ip4 config test ####### - -test_ip4_config_SOURCES = \ - test-ip4-config.c - -test_ip4_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### ip6 config test ####### - -test_ip6_config_SOURCES = \ - test-ip6-config.c - -test_ip6_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### route manager test ####### - -test_route_manager_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(GUDEV_CFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 - -test_route_manager_fake_SOURCES = \ - $(top_srcdir)/src/platform/tests/test-common.c \ - test-route-manager.c - -test_route_manager_fake_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -test_route_manager_linux_SOURCES = \ - $(top_srcdir)/src/platform/tests/test-common.c \ - test-route-manager.c - -test_route_manager_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(GUDEV_CFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 - -test_route_manager_linux_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### DCB test ####### - -test_dcb_SOURCES = \ - test-dcb.c - -test_dcb_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### resolv.conf capture test ####### - -test_resolvconf_capture_SOURCES = \ - test-resolvconf-capture.c - -test_resolvconf_capture_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### general test ####### - -test_general_SOURCES = \ - test-general.c - -test_general_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### general-with-expect test ####### - -test_general_with_expect_SOURCES = \ - test-general-with-expect.c - -test_general_with_expect_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### wired defname test ####### - -test_wired_defname_SOURCES = \ - test-wired-defname.c - -test_wired_defname_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### systemd test ####### - -test_systemd_CFLAGS = \ - "-I$(srcdir)/../" \ - "-I$(srcdir)/../platform" \ - "-I$(srcdir)/../systemd" \ - "-I$(srcdir)/../systemd/src/systemd" - -test_systemd_SOURCES = \ - test-systemd.c - -test_systemd_LDADD = \ - $(top_builddir)/src/libsystemd-nm.la - -####### utils test ####### - -test_utils_SOURCES = \ - test-utils.c - -test_utils_DEPENDENCIES = \ - $(top_srcdir)/src/NetworkManagerUtils.c - -test_utils_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DPREFIX=\"/nonexistent\" \ - -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DNMSTATEDIR=\"/nonsense\" - -test_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### secret agent interface test ####### - -EXTRA_DIST = test-secret-agent.py - -########################################### - -@VALGRIND_RULES@ -TESTS = \ - test-ip4-config \ - test-ip6-config \ - test-route-manager-fake \ - test-route-manager-linux \ - test-dcb \ - test-resolvconf-capture \ - test-general \ - test-general-with-expect \ - test-systemd \ - test-wired-defname \ - test-utils - - -if ENABLE_TESTS - -check-local: - @for t in bond bridge ethernet infiniband ip_tunnel macvlan tun veth vlan vxlan; do \ - # Ensure the device subclass factory registration constructors exist \ - # which could inadvertently break if src/Makefile.am gets changed \ - if ! LC_ALL=C nm $(top_builddir)/src/NetworkManager | LC_ALL=C grep -q "register_device_factory_internal_$$t" ; then \ - echo "Testing device factory symbols... FAILED" ; \ - exit 1 ; \ - fi \ - done - @echo "Testing device factory symbols... PASSED" - -endif - diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in deleted file mode 100644 index a115170e..00000000 --- a/src/tests/Makefile.in +++ /dev/null @@ -1,1664 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-general$(EXEEXT) \ - test-general-with-expect$(EXEEXT) test-ip4-config$(EXEEXT) \ - test-ip6-config$(EXEEXT) test-route-manager-linux$(EXEEXT) \ - test-route-manager-fake$(EXEEXT) test-dcb$(EXEEXT) \ - test-systemd$(EXEEXT) test-resolvconf-capture$(EXEEXT) \ - test-wired-defname$(EXEEXT) test-utils$(EXEEXT) -TESTS = test-ip4-config$(EXEEXT) test-ip6-config$(EXEEXT) \ - test-route-manager-fake$(EXEEXT) \ - test-route-manager-linux$(EXEEXT) test-dcb$(EXEEXT) \ - test-resolvconf-capture$(EXEEXT) test-general$(EXEEXT) \ - test-general-with-expect$(EXEEXT) test-systemd$(EXEEXT) \ - test-wired-defname$(EXEEXT) test-utils$(EXEEXT) -subdir = src/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_dcb_OBJECTS = test-dcb.$(OBJEXT) -test_dcb_OBJECTS = $(am_test_dcb_OBJECTS) -test_dcb_DEPENDENCIES = $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -am_test_general_OBJECTS = test-general.$(OBJEXT) -test_general_OBJECTS = $(am_test_general_OBJECTS) -test_general_DEPENDENCIES = $(top_builddir)/src/libNetworkManager.la -am_test_general_with_expect_OBJECTS = \ - test-general-with-expect.$(OBJEXT) -test_general_with_expect_OBJECTS = \ - $(am_test_general_with_expect_OBJECTS) -test_general_with_expect_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -am_test_ip4_config_OBJECTS = test-ip4-config.$(OBJEXT) -test_ip4_config_OBJECTS = $(am_test_ip4_config_OBJECTS) -test_ip4_config_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -am_test_ip6_config_OBJECTS = test-ip6-config.$(OBJEXT) -test_ip6_config_OBJECTS = $(am_test_ip6_config_OBJECTS) -test_ip6_config_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -am_test_resolvconf_capture_OBJECTS = \ - test-resolvconf-capture.$(OBJEXT) -test_resolvconf_capture_OBJECTS = \ - $(am_test_resolvconf_capture_OBJECTS) -test_resolvconf_capture_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -am_test_route_manager_fake_OBJECTS = \ - test_route_manager_fake-test-common.$(OBJEXT) \ - test_route_manager_fake-test-route-manager.$(OBJEXT) -test_route_manager_fake_OBJECTS = \ - $(am_test_route_manager_fake_OBJECTS) -test_route_manager_fake_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManagerTest.la -am_test_route_manager_linux_OBJECTS = \ - test_route_manager_linux-test-common.$(OBJEXT) \ - test_route_manager_linux-test-route-manager.$(OBJEXT) -test_route_manager_linux_OBJECTS = \ - $(am_test_route_manager_linux_OBJECTS) -test_route_manager_linux_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -am_test_systemd_OBJECTS = test_systemd-test-systemd.$(OBJEXT) -test_systemd_OBJECTS = $(am_test_systemd_OBJECTS) -test_systemd_DEPENDENCIES = $(top_builddir)/src/libsystemd-nm.la -test_systemd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_systemd_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -am_test_utils_OBJECTS = test_utils-test-utils.$(OBJEXT) -test_utils_OBJECTS = $(am_test_utils_OBJECTS) -am_test_wired_defname_OBJECTS = test-wired-defname.$(OBJEXT) -test_wired_defname_OBJECTS = $(am_test_wired_defname_OBJECTS) -test_wired_defname_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManager.la -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_dcb_SOURCES) $(test_general_SOURCES) \ - $(test_general_with_expect_SOURCES) $(test_ip4_config_SOURCES) \ - $(test_ip6_config_SOURCES) $(test_resolvconf_capture_SOURCES) \ - $(test_route_manager_fake_SOURCES) \ - $(test_route_manager_linux_SOURCES) $(test_systemd_SOURCES) \ - $(test_utils_SOURCES) $(test_wired_defname_SOURCES) -DIST_SOURCES = $(test_dcb_SOURCES) $(test_general_SOURCES) \ - $(test_general_with_expect_SOURCES) $(test_ip4_config_SOURCES) \ - $(test_ip6_config_SOURCES) $(test_resolvconf_capture_SOURCES) \ - $(test_route_manager_fake_SOURCES) \ - $(test_route_manager_linux_SOURCES) $(test_systemd_SOURCES) \ - $(test_utils_SOURCES) $(test_wired_defname_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - check recheck distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = config -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/dhcp-manager \ - -I$(top_srcdir)/src/devices \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) - -AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) - -####### ip4 config test ####### -test_ip4_config_SOURCES = \ - test-ip4-config.c - -test_ip4_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### ip6 config test ####### -test_ip6_config_SOURCES = \ - test-ip6-config.c - -test_ip6_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### route manager test ####### -test_route_manager_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(GUDEV_CFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 - -test_route_manager_fake_SOURCES = \ - $(top_srcdir)/src/platform/tests/test-common.c \ - test-route-manager.c - -test_route_manager_fake_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -test_route_manager_linux_SOURCES = \ - $(top_srcdir)/src/platform/tests/test-common.c \ - test-route-manager.c - -test_route_manager_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(GUDEV_CFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 - -test_route_manager_linux_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### DCB test ####### -test_dcb_SOURCES = \ - test-dcb.c - -test_dcb_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### resolv.conf capture test ####### -test_resolvconf_capture_SOURCES = \ - test-resolvconf-capture.c - -test_resolvconf_capture_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### general test ####### -test_general_SOURCES = \ - test-general.c - -test_general_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### general-with-expect test ####### -test_general_with_expect_SOURCES = \ - test-general-with-expect.c - -test_general_with_expect_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### wired defname test ####### -test_wired_defname_SOURCES = \ - test-wired-defname.c - -test_wired_defname_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### systemd test ####### -test_systemd_CFLAGS = \ - "-I$(srcdir)/../" \ - "-I$(srcdir)/../platform" \ - "-I$(srcdir)/../systemd" \ - "-I$(srcdir)/../systemd/src/systemd" - -test_systemd_SOURCES = \ - test-systemd.c - -test_systemd_LDADD = \ - $(top_builddir)/src/libsystemd-nm.la - - -####### utils test ####### -test_utils_SOURCES = \ - test-utils.c - -test_utils_DEPENDENCIES = \ - $(top_srcdir)/src/NetworkManagerUtils.c - -test_utils_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DPREFIX=\"/nonexistent\" \ - -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DNMSTATEDIR=\"/nonsense\" - -test_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - - -####### secret agent interface test ####### -EXTRA_DIST = test-secret-agent.py -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-dcb$(EXEEXT): $(test_dcb_OBJECTS) $(test_dcb_DEPENDENCIES) $(EXTRA_test_dcb_DEPENDENCIES) - @rm -f test-dcb$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_dcb_OBJECTS) $(test_dcb_LDADD) $(LIBS) - -test-general$(EXEEXT): $(test_general_OBJECTS) $(test_general_DEPENDENCIES) $(EXTRA_test_general_DEPENDENCIES) - @rm -f test-general$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_general_OBJECTS) $(test_general_LDADD) $(LIBS) - -test-general-with-expect$(EXEEXT): $(test_general_with_expect_OBJECTS) $(test_general_with_expect_DEPENDENCIES) $(EXTRA_test_general_with_expect_DEPENDENCIES) - @rm -f test-general-with-expect$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_general_with_expect_OBJECTS) $(test_general_with_expect_LDADD) $(LIBS) - -test-ip4-config$(EXEEXT): $(test_ip4_config_OBJECTS) $(test_ip4_config_DEPENDENCIES) $(EXTRA_test_ip4_config_DEPENDENCIES) - @rm -f test-ip4-config$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ip4_config_OBJECTS) $(test_ip4_config_LDADD) $(LIBS) - -test-ip6-config$(EXEEXT): $(test_ip6_config_OBJECTS) $(test_ip6_config_DEPENDENCIES) $(EXTRA_test_ip6_config_DEPENDENCIES) - @rm -f test-ip6-config$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ip6_config_OBJECTS) $(test_ip6_config_LDADD) $(LIBS) - -test-resolvconf-capture$(EXEEXT): $(test_resolvconf_capture_OBJECTS) $(test_resolvconf_capture_DEPENDENCIES) $(EXTRA_test_resolvconf_capture_DEPENDENCIES) - @rm -f test-resolvconf-capture$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_resolvconf_capture_OBJECTS) $(test_resolvconf_capture_LDADD) $(LIBS) - -test-route-manager-fake$(EXEEXT): $(test_route_manager_fake_OBJECTS) $(test_route_manager_fake_DEPENDENCIES) $(EXTRA_test_route_manager_fake_DEPENDENCIES) - @rm -f test-route-manager-fake$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_route_manager_fake_OBJECTS) $(test_route_manager_fake_LDADD) $(LIBS) - -test-route-manager-linux$(EXEEXT): $(test_route_manager_linux_OBJECTS) $(test_route_manager_linux_DEPENDENCIES) $(EXTRA_test_route_manager_linux_DEPENDENCIES) - @rm -f test-route-manager-linux$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_route_manager_linux_OBJECTS) $(test_route_manager_linux_LDADD) $(LIBS) - -test-systemd$(EXEEXT): $(test_systemd_OBJECTS) $(test_systemd_DEPENDENCIES) $(EXTRA_test_systemd_DEPENDENCIES) - @rm -f test-systemd$(EXEEXT) - $(AM_V_CCLD)$(test_systemd_LINK) $(test_systemd_OBJECTS) $(test_systemd_LDADD) $(LIBS) - -test-utils$(EXEEXT): $(test_utils_OBJECTS) $(test_utils_DEPENDENCIES) $(EXTRA_test_utils_DEPENDENCIES) - @rm -f test-utils$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_utils_OBJECTS) $(test_utils_LDADD) $(LIBS) - -test-wired-defname$(EXEEXT): $(test_wired_defname_OBJECTS) $(test_wired_defname_DEPENDENCIES) $(EXTRA_test_wired_defname_DEPENDENCIES) - @rm -f test-wired-defname$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_wired_defname_OBJECTS) $(test_wired_defname_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dcb.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-general-with-expect.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-general.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ip4-config.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ip6-config.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-resolvconf-capture.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wired-defname.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_manager_fake-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_manager_fake-test-route-manager.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_manager_linux-test-common.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_route_manager_linux-test-route-manager.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_systemd-test-systemd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_utils-test-utils.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -test_route_manager_fake-test-common.o: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_fake-test-common.o -MD -MP -MF $(DEPDIR)/test_route_manager_fake-test-common.Tpo -c -o test_route_manager_fake-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_fake-test-common.Tpo $(DEPDIR)/test_route_manager_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_route_manager_fake-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_fake-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c - -test_route_manager_fake-test-common.obj: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_fake-test-common.obj -MD -MP -MF $(DEPDIR)/test_route_manager_fake-test-common.Tpo -c -o test_route_manager_fake-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_fake-test-common.Tpo $(DEPDIR)/test_route_manager_fake-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_route_manager_fake-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_fake-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` - -test_route_manager_fake-test-route-manager.o: test-route-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_fake-test-route-manager.o -MD -MP -MF $(DEPDIR)/test_route_manager_fake-test-route-manager.Tpo -c -o test_route_manager_fake-test-route-manager.o `test -f 'test-route-manager.c' || echo '$(srcdir)/'`test-route-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_fake-test-route-manager.Tpo $(DEPDIR)/test_route_manager_fake-test-route-manager.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route-manager.c' object='test_route_manager_fake-test-route-manager.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_fake-test-route-manager.o `test -f 'test-route-manager.c' || echo '$(srcdir)/'`test-route-manager.c - -test_route_manager_fake-test-route-manager.obj: test-route-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_fake-test-route-manager.obj -MD -MP -MF $(DEPDIR)/test_route_manager_fake-test-route-manager.Tpo -c -o test_route_manager_fake-test-route-manager.obj `if test -f 'test-route-manager.c'; then $(CYGPATH_W) 'test-route-manager.c'; else $(CYGPATH_W) '$(srcdir)/test-route-manager.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_fake-test-route-manager.Tpo $(DEPDIR)/test_route_manager_fake-test-route-manager.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route-manager.c' object='test_route_manager_fake-test-route-manager.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_fake_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_fake-test-route-manager.obj `if test -f 'test-route-manager.c'; then $(CYGPATH_W) 'test-route-manager.c'; else $(CYGPATH_W) '$(srcdir)/test-route-manager.c'; fi` - -test_route_manager_linux-test-common.o: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_linux-test-common.o -MD -MP -MF $(DEPDIR)/test_route_manager_linux-test-common.Tpo -c -o test_route_manager_linux-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_linux-test-common.Tpo $(DEPDIR)/test_route_manager_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_route_manager_linux-test-common.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_linux-test-common.o `test -f '$(top_srcdir)/src/platform/tests/test-common.c' || echo '$(srcdir)/'`$(top_srcdir)/src/platform/tests/test-common.c - -test_route_manager_linux-test-common.obj: $(top_srcdir)/src/platform/tests/test-common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_linux-test-common.obj -MD -MP -MF $(DEPDIR)/test_route_manager_linux-test-common.Tpo -c -o test_route_manager_linux-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_linux-test-common.Tpo $(DEPDIR)/test_route_manager_linux-test-common.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/platform/tests/test-common.c' object='test_route_manager_linux-test-common.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_linux-test-common.obj `if test -f '$(top_srcdir)/src/platform/tests/test-common.c'; then $(CYGPATH_W) '$(top_srcdir)/src/platform/tests/test-common.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/platform/tests/test-common.c'; fi` - -test_route_manager_linux-test-route-manager.o: test-route-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_linux-test-route-manager.o -MD -MP -MF $(DEPDIR)/test_route_manager_linux-test-route-manager.Tpo -c -o test_route_manager_linux-test-route-manager.o `test -f 'test-route-manager.c' || echo '$(srcdir)/'`test-route-manager.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_linux-test-route-manager.Tpo $(DEPDIR)/test_route_manager_linux-test-route-manager.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route-manager.c' object='test_route_manager_linux-test-route-manager.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_linux-test-route-manager.o `test -f 'test-route-manager.c' || echo '$(srcdir)/'`test-route-manager.c - -test_route_manager_linux-test-route-manager.obj: test-route-manager.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_route_manager_linux-test-route-manager.obj -MD -MP -MF $(DEPDIR)/test_route_manager_linux-test-route-manager.Tpo -c -o test_route_manager_linux-test-route-manager.obj `if test -f 'test-route-manager.c'; then $(CYGPATH_W) 'test-route-manager.c'; else $(CYGPATH_W) '$(srcdir)/test-route-manager.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_route_manager_linux-test-route-manager.Tpo $(DEPDIR)/test_route_manager_linux-test-route-manager.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-route-manager.c' object='test_route_manager_linux-test-route-manager.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_route_manager_linux_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_route_manager_linux-test-route-manager.obj `if test -f 'test-route-manager.c'; then $(CYGPATH_W) 'test-route-manager.c'; else $(CYGPATH_W) '$(srcdir)/test-route-manager.c'; fi` - -test_systemd-test-systemd.o: test-systemd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_systemd_CFLAGS) $(CFLAGS) -MT test_systemd-test-systemd.o -MD -MP -MF $(DEPDIR)/test_systemd-test-systemd.Tpo -c -o test_systemd-test-systemd.o `test -f 'test-systemd.c' || echo '$(srcdir)/'`test-systemd.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_systemd-test-systemd.Tpo $(DEPDIR)/test_systemd-test-systemd.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-systemd.c' object='test_systemd-test-systemd.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_systemd_CFLAGS) $(CFLAGS) -c -o test_systemd-test-systemd.o `test -f 'test-systemd.c' || echo '$(srcdir)/'`test-systemd.c - -test_systemd-test-systemd.obj: test-systemd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_systemd_CFLAGS) $(CFLAGS) -MT test_systemd-test-systemd.obj -MD -MP -MF $(DEPDIR)/test_systemd-test-systemd.Tpo -c -o test_systemd-test-systemd.obj `if test -f 'test-systemd.c'; then $(CYGPATH_W) 'test-systemd.c'; else $(CYGPATH_W) '$(srcdir)/test-systemd.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_systemd-test-systemd.Tpo $(DEPDIR)/test_systemd-test-systemd.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-systemd.c' object='test_systemd-test-systemd.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_systemd_CFLAGS) $(CFLAGS) -c -o test_systemd-test-systemd.obj `if test -f 'test-systemd.c'; then $(CYGPATH_W) 'test-systemd.c'; else $(CYGPATH_W) '$(srcdir)/test-systemd.c'; fi` - -test_utils-test-utils.o: test-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_utils_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_utils-test-utils.o -MD -MP -MF $(DEPDIR)/test_utils-test-utils.Tpo -c -o test_utils-test-utils.o `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_utils-test-utils.Tpo $(DEPDIR)/test_utils-test-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-utils.c' object='test_utils-test-utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_utils_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_utils-test-utils.o `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c - -test_utils-test-utils.obj: test-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_utils_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_utils-test-utils.obj -MD -MP -MF $(DEPDIR)/test_utils-test-utils.Tpo -c -o test_utils-test-utils.obj `if test -f 'test-utils.c'; then $(CYGPATH_W) 'test-utils.c'; else $(CYGPATH_W) '$(srcdir)/test-utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_utils-test-utils.Tpo $(DEPDIR)/test_utils-test-utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-utils.c' object='test_utils-test-utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_utils_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_utils-test-utils.obj `if test -f 'test-utils.c'; then $(CYGPATH_W) 'test-utils.c'; else $(CYGPATH_W) '$(srcdir)/test-utils.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-ip4-config.log: test-ip4-config$(EXEEXT) - @p='test-ip4-config$(EXEEXT)'; \ - b='test-ip4-config'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-ip6-config.log: test-ip6-config$(EXEEXT) - @p='test-ip6-config$(EXEEXT)'; \ - b='test-ip6-config'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-route-manager-fake.log: test-route-manager-fake$(EXEEXT) - @p='test-route-manager-fake$(EXEEXT)'; \ - b='test-route-manager-fake'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-route-manager-linux.log: test-route-manager-linux$(EXEEXT) - @p='test-route-manager-linux$(EXEEXT)'; \ - b='test-route-manager-linux'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-dcb.log: test-dcb$(EXEEXT) - @p='test-dcb$(EXEEXT)'; \ - b='test-dcb'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-resolvconf-capture.log: test-resolvconf-capture$(EXEEXT) - @p='test-resolvconf-capture$(EXEEXT)'; \ - b='test-resolvconf-capture'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-general.log: test-general$(EXEEXT) - @p='test-general$(EXEEXT)'; \ - b='test-general'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-general-with-expect.log: test-general-with-expect$(EXEEXT) - @p='test-general-with-expect$(EXEEXT)'; \ - b='test-general-with-expect'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-systemd.log: test-systemd$(EXEEXT) - @p='test-systemd$(EXEEXT)'; \ - b='test-systemd'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-wired-defname.log: test-wired-defname$(EXEEXT) - @p='test-wired-defname$(EXEEXT)'; \ - b='test-wired-defname'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-utils.log: test-utils$(EXEEXT) - @p='test-utils$(EXEEXT)'; \ - b='test-utils'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local -check: check-recursive -all-am: Makefile $(PROGRAMS) -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) check-am install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-TESTS check-am check-local clean clean-generic \ - clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -########################################### - -@VALGRIND_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ @for t in bond bridge ethernet infiniband ip_tunnel macvlan tun veth vlan vxlan; do \ -@ENABLE_TESTS_TRUE@ # Ensure the device subclass factory registration constructors exist \ -@ENABLE_TESTS_TRUE@ # which could inadvertently break if src/Makefile.am gets changed \ -@ENABLE_TESTS_TRUE@ if ! LC_ALL=C nm $(top_builddir)/src/NetworkManager | LC_ALL=C grep -q "register_device_factory_internal_$$t" ; then \ -@ENABLE_TESTS_TRUE@ echo "Testing device factory symbols... FAILED" ; \ -@ENABLE_TESTS_TRUE@ exit 1 ; \ -@ENABLE_TESTS_TRUE@ fi \ -@ENABLE_TESTS_TRUE@ done -@ENABLE_TESTS_TRUE@ @echo "Testing device factory symbols... PASSED" - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/tests/config/Makefile.am b/src/tests/config/Makefile.am deleted file mode 100644 index d0cb797d..00000000 --- a/src/tests/config/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/devices \ - -I${top_srcdir}/src/platform \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DSRCDIR=\""$(abs_srcdir)"\" \ - -DBUILDDIR=\""$(abs_builddir)"\" - -noinst_PROGRAMS = \ - test-config - -test_config_SOURCES = \ - nm-test-device.c \ - nm-test-device.h \ - test-config.c - -test_config_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -@VALGRIND_RULES@ -TESTS = test-config - -EXTRA_DIST = \ - NetworkManager.conf \ - NetworkManager.state \ - bad.conf \ - global-dns-invalid.conf \ - conf.d/00-overrides.conf \ - conf.d/10-more.conf \ - conf.d/20-config-enable-1.conf \ - conf.d/90-last.conf diff --git a/src/tests/config/Makefile.in b/src/tests/config/Makefile.in deleted file mode 100644 index 738788cf..00000000 --- a/src/tests/config/Makefile.in +++ /dev/null @@ -1,1156 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = test-config$(EXEEXT) -TESTS = test-config$(EXEEXT) -subdir = src/tests/config -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_test_config_OBJECTS = nm-test-device.$(OBJEXT) \ - test-config.$(OBJEXT) -test_config_OBJECTS = $(am_test_config_OBJECTS) -test_config_DEPENDENCIES = \ - $(top_builddir)/src/libNetworkManagerTest.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_config_SOURCES) -DIST_SOURCES = $(test_config_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/devices \ - -I${top_srcdir}/src/platform \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - -DSRCDIR=\""$(abs_srcdir)"\" \ - -DBUILDDIR=\""$(abs_builddir)"\" - -test_config_SOURCES = \ - nm-test-device.c \ - nm-test-device.h \ - test-config.c - -test_config_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -EXTRA_DIST = \ - NetworkManager.conf \ - NetworkManager.state \ - bad.conf \ - global-dns-invalid.conf \ - conf.d/00-overrides.conf \ - conf.d/10-more.conf \ - conf.d/20-config-enable-1.conf \ - conf.d/90-last.conf - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tests/config/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/tests/config/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-config$(EXEEXT): $(test_config_OBJECTS) $(test_config_DEPENDENCIES) $(EXTRA_test_config_DEPENDENCIES) - @rm -f test-config$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_config_OBJECTS) $(test_config_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-test-device.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-config.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-config.log: test-config$(EXEEXT) - @p='test-config$(EXEEXT)'; \ - b='test-config'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@VALGRIND_RULES@ - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/tests/config/nm-test-device.c b/src/tests/config/nm-test-device.c index 1ae964ee..3ec866f5 100644 --- a/src/tests/config/nm-test-device.c +++ b/src/tests/config/nm-test-device.c @@ -20,16 +20,37 @@ #include "nm-default.h" +#include "nm-test-device.h" + #include -#include "nm-test-device.h" -#include "nm-device-private.h" +#include "devices/nm-device-private.h" #include "nm-utils.h" +/*****************************************************************************/ + +struct _NMTestDevice { + NMDevice parent; +}; + +struct _NMTestDeviceClass { + NMDeviceClass parent; +}; + G_DEFINE_TYPE (NMTestDevice, nm_test_device, NM_TYPE_DEVICE) #define PARENT_CLASS (G_OBJECT_CLASS (g_type_class_peek_parent (nm_test_device_parent_class))) +/*****************************************************************************/ + +static NMDeviceCapabilities +get_generic_capabilities (NMDevice *device) +{ + return NM_DEVICE_CAP_IS_NON_KERNEL; +} + +/*****************************************************************************/ + static void nm_test_device_init (NMTestDevice *self) { @@ -50,10 +71,13 @@ dispose (GObject *object) PARENT_CLASS->dispose (object); } -static NMDeviceCapabilities -get_generic_capabilities (NMDevice *device) +NMDevice * +nm_test_device_new (const char *hwaddr) { - return NM_DEVICE_CAP_IS_NON_KERNEL; + return g_object_new (NM_TYPE_TEST_DEVICE, + NM_DEVICE_IFACE, "dummy", + NM_DEVICE_PERM_HW_ADDRESS, hwaddr, + NULL); } static void @@ -67,12 +91,3 @@ nm_test_device_class_init (NMTestDeviceClass *klass) device_class->get_generic_capabilities = get_generic_capabilities; } - -NMDevice * -nm_test_device_new (const char *hwaddr) -{ - return g_object_new (NM_TYPE_TEST_DEVICE, - NM_DEVICE_IFACE, "dummy", - NM_DEVICE_PERM_HW_ADDRESS, hwaddr, - NULL); -} diff --git a/src/tests/config/nm-test-device.h b/src/tests/config/nm-test-device.h index dfb8ff78..c193b860 100644 --- a/src/tests/config/nm-test-device.h +++ b/src/tests/config/nm-test-device.h @@ -21,7 +21,7 @@ #ifndef __NETWORKMANAGER_TEST_DEVICE_H__ #define __NETWORKMANAGER_TEST_DEVICE_H__ -#include "nm-device.h" +#include "devices/nm-device.h" #define NM_TYPE_TEST_DEVICE (nm_test_device_get_type ()) #define NM_TEST_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_TEST_DEVICE, NMTestDevice)) @@ -30,14 +30,8 @@ #define NM_IS_TEST_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_TEST_DEVICE)) #define NM_TEST_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_TEST_DEVICE, NMTestDeviceClass)) -typedef struct { - NMDevice parent; - -} NMTestDevice; - -typedef struct { - NMDeviceClass parent; -} NMTestDeviceClass; +typedef struct _NMTestDevice NMTestDevice; +typedef struct _NMTestDeviceClass NMTestDeviceClass; GType nm_test_device_get_type (void); diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c index 73358d02..dd2a58a0 100644 --- a/src/tests/config/test-config.c +++ b/src/tests/config/test-config.c @@ -24,12 +24,12 @@ #include "nm-config.h" #include "nm-test-device.h" -#include "nm-fake-platform.h" +#include "platform/nm-fake-platform.h" #include "nm-bus-manager.h" #include "nm-test-utils-core.h" -/********************************************************************************/ +/*****************************************************************************/ static void _assert_config_value (const NMConfigData *config_data, const char *group, const char *key, const char *expected_value, const char *file, int line) @@ -46,7 +46,18 @@ _assert_config_value (const NMConfigData *config_data, const char *group, const } #define assert_config_value(config_data, group, key, expected_value) _assert_config_value (config_data, group, key, expected_value, __FILE__, __LINE__) -/********************************************************************************/ +#define _config_get_dhcp_client_a(config) \ + ({ \ + gs_free char *_s = NULL; \ + \ + _s = nm_config_data_get_value (nm_config_get_data_orig (config), \ + NM_CONFIG_KEYFILE_GROUP_MAIN, \ + NM_CONFIG_KEYFILE_KEY_MAIN_DHCP, \ + NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); \ + _s ? nm_sprintf_bufa (100, "%s", _s) : NULL; \ + }) + +/*****************************************************************************/ static NMConfig * setup_config (GError **error, const char *config_file, const char *intern_config, const char *const* atomic_section_prefixes, const char *config_dir, const char *system_config_dir, ...) @@ -114,8 +125,8 @@ setup_config (GError **error, const char *config_file, const char *intern_config static void test_config_simple (void) { - NMConfig *config; - const char **plugins; + gs_unref_object NMConfig *config = NULL; + gs_strfreev char **plugins = NULL; char *value; gs_unref_object NMDevice *dev50 = nm_test_device_new ("00:00:00:00:00:50"); gs_unref_object NMDevice *dev51 = nm_test_device_new ("00:00:00:00:00:51"); @@ -124,11 +135,11 @@ test_config_simple (void) config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL); g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf"); - g_assert_cmpstr (nm_config_get_dhcp_client (config), ==, "dhclient"); + g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhclient"); g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO"); g_assert_cmpint (nm_config_data_get_connectivity_interval (nm_config_get_data_orig (config)), ==, 100); - plugins = nm_config_get_plugins (config); + plugins = nm_config_data_get_plugins (nm_config_get_data_orig (config), FALSE); g_assert_cmpint (g_strv_length ((char **)plugins), ==, 3); g_assert_cmpstr (plugins[0], ==, "foo"); g_assert_cmpstr (plugins[1], ==, "bar"); @@ -190,9 +201,6 @@ test_config_simple (void) value = nm_config_data_get_connection_default (nm_config_get_data_orig (config), "dummy.test2", dev50); g_assert_cmpstr (value, ==, "no"); g_free (value); - - - g_object_unref (config); } static void @@ -218,8 +226,8 @@ test_config_parse_error (void) static void test_config_override (void) { - NMConfig *config; - const char **plugins; + gs_unref_object NMConfig *config = NULL; + gs_strfreev char **plugins = NULL; config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", "--plugins", "alpha,beta,gamma,delta", @@ -227,18 +235,16 @@ test_config_override (void) NULL); g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf"); - g_assert_cmpstr (nm_config_get_dhcp_client (config), ==, "dhclient"); + g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhclient"); g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO"); g_assert_cmpint (nm_config_data_get_connectivity_interval (nm_config_get_data_orig (config)), ==, 12); - plugins = nm_config_get_plugins (config); + plugins = nm_config_data_get_plugins (nm_config_get_data_orig (config), FALSE); g_assert_cmpint (g_strv_length ((char **)plugins), ==, 4); g_assert_cmpstr (plugins[0], ==, "alpha"); g_assert_cmpstr (plugins[1], ==, "beta"); g_assert_cmpstr (plugins[2], ==, "gamma"); g_assert_cmpstr (plugins[3], ==, "delta"); - - g_object_unref (config); } static void @@ -374,21 +380,21 @@ test_config_no_auto_default (void) static void test_config_confdir (void) { - NMConfig *config; - const char **plugins; + gs_unref_object NMConfig *config = NULL; + gs_strfreev char **plugins = NULL; char *value; GSList *specs; config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL); g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf"); - g_assert_cmpstr (nm_config_get_dhcp_client (config), ==, "dhcpcd"); + g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhcpcd"); g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO"); g_assert_cmpstr (nm_config_get_log_domains (config), ==, "PLATFORM,DNS,WIFI"); g_assert_cmpstr (nm_config_data_get_connectivity_uri (nm_config_get_data_orig (config)), ==, "http://example.net"); g_assert_cmpint (nm_config_data_get_connectivity_interval (nm_config_get_data_orig (config)), ==, 100); - plugins = nm_config_get_plugins (config); + plugins = nm_config_data_get_plugins (nm_config_get_data_orig (config), FALSE); g_assert_cmpint (g_strv_length ((char **)plugins), ==, 5); g_assert_cmpstr (plugins[0], ==, "foo"); g_assert_cmpstr (plugins[1], ==, "bar"); @@ -475,8 +481,6 @@ test_config_confdir (void) g_free (value); nm_config_data_log (nm_config_get_data_orig (config), ">>> TEST: ", " ", NULL); - - g_object_unref (config); } static void diff --git a/src/tests/test-dcb.c b/src/tests/test-dcb.c index 0a133de3..2ab0f890 100644 --- a/src/tests/test-dcb.c +++ b/src/tests/test-dcb.c @@ -334,7 +334,7 @@ test_fcoe_cleanup (void) g_assert (success); } -/*******************************************/ +/*****************************************************************************/ NMTST_DEFINE (); diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index f04c147f..fbed7799 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -37,7 +37,7 @@ #define CLOCK_BOOTTIME 7 #endif -/*******************************************/ +/*****************************************************************************/ static void test_nm_utils_monotonic_timestamp_as_boottime (void) @@ -63,7 +63,7 @@ test_nm_utils_monotonic_timestamp_as_boottime (void) now_boottime_2 = nm_utils_monotonic_timestamp_as_boottime (now, 1); g_assert_cmpint (now_boottime_2, >=, 0); g_assert_cmpint (now_boottime_2, >=, now_boottime); - g_assert_cmpint (now_boottime_2 - now_boottime, <=, NM_UTILS_NS_PER_SECOND / 1000); + g_assert_cmpint (now_boottime_2 - now_boottime, <=, NM_UTILS_NS_PER_SECOND / 10); for (timestamp_ns_per_tick = 1; timestamp_ns_per_tick <= NM_UTILS_NS_PER_SECOND; timestamp_ns_per_tick *= 10) { now_boottime_3 = nm_utils_monotonic_timestamp_as_boottime (now / timestamp_ns_per_tick, timestamp_ns_per_tick); @@ -73,7 +73,7 @@ test_nm_utils_monotonic_timestamp_as_boottime (void) } } -/*******************************************/ +/*****************************************************************************/ struct test_nm_utils_kill_child_async_data { @@ -371,7 +371,7 @@ test_nm_utils_kill_child (void) g_test_assert_expected_messages (); } -/*******************************************/ +/*****************************************************************************/ static void _remove_at_indexes_init_random_idx (GArray *idx, guint array_len, guint idx_len) @@ -470,7 +470,7 @@ test_nm_utils_array_remove_at_indexes (void) } } -/*******************************************/ +/*****************************************************************************/ static void test_nm_ethernet_address_is_valid (void) @@ -497,7 +497,7 @@ test_nm_ethernet_address_is_valid (void) g_assert ( nm_ethernet_address_is_valid (((guint8[8]) { 0x02,0x30,0xb4,0x00,0x00,0x01 }), ETH_ALEN)); } -/*******************************************/ +/*****************************************************************************/ typedef struct { union { @@ -853,7 +853,7 @@ test_nm_multi_index (void) _mi_test_run (50, 18); } -/*******************************************/ +/*****************************************************************************/ static void test_nm_utils_new_vlan_name (void) @@ -896,7 +896,7 @@ test_nm_utils_new_vlan_name (void) } } -/*******************************************/ +/*****************************************************************************/ NMTST_DEFINE (); diff --git a/src/tests/test-general.c b/src/tests/test-general.c index 9769ead1..ed2f4e51 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -29,7 +29,7 @@ #include "nm-test-utils-core.h" /* Reference implementation for nm_utils_ip6_address_clear_host_address. - * Taken originally from set_address_masked(), src/rdisc/nm-lndp-rdisc.c + * Taken originally from set_address_masked(), src/ndisc/nm-lndp-ndisc.c **/ static void ip6_address_clear_host_address_reference (struct in6_addr *dst, struct in6_addr *src, guint8 plen) @@ -267,7 +267,7 @@ test_nm_utils_log_connection_diff (void) g_clear_object (&connection); } -/*******************************************/ +/*****************************************************************************/ static NMConnection * _match_connection_new (void) @@ -953,7 +953,7 @@ test_connection_sort_autoconnect_priority (void) _test_connection_sort_autoconnect_priority_free (c2); } -/*******************************************/ +/*****************************************************************************/ static const char *_test_match_spec_all[] = { "e", @@ -1085,7 +1085,7 @@ test_nm_match_spec_interface_name (void) #undef S } -/*******************************************/ +/*****************************************************************************/ static void _do_test_match_spec_match_config (const char *file, gint line, const char *spec_str, guint version, guint v_maj, guint v_min, guint v_mic, NMMatchSpecMatchType expected) @@ -1227,7 +1227,7 @@ test_nm_match_spec_match_config (void) do_test_match_spec_match_config ("nm-version-min:1.6,nm-version-min:1.4.6,nm-version-min:1.2.16,except:nm-version:1.4.8", 1, 8, 8, NM_MATCH_SPEC_MATCH); } -/*******************************************/ +/*****************************************************************************/ static void test_nm_utils_strbuf_append (void) @@ -1481,6 +1481,89 @@ test_reverse_dns_ip6 (void) /*****************************************************************************/ +static void +do_test_stable_id_parse (const char *stable_id, + NMUtilsStableType expected_stable_type, + const char *expected_generated) +{ + gs_free char *generated = NULL; + NMUtilsStableType stable_type; + + if (expected_stable_type == NM_UTILS_STABLE_TYPE_GENERATED) + g_assert (expected_generated); + else + g_assert (!expected_generated); + + if (expected_stable_type == NM_UTILS_STABLE_TYPE_UUID) + g_assert (!stable_id); + else + g_assert (stable_id); + + stable_type = nm_utils_stable_id_parse (stable_id, "_CONNECTION", "_BOOT", &generated); + + g_assert_cmpint (expected_stable_type, ==, stable_type); + + if (stable_type == NM_UTILS_STABLE_TYPE_GENERATED) { + g_assert_cmpstr (expected_generated, ==, generated); + g_assert (generated); + } else + g_assert (!generated); +} + +static void +test_stable_id_parse (void) +{ +#define _parse_stable_id(stable_id) do_test_stable_id_parse (""stable_id"", NM_UTILS_STABLE_TYPE_STABLE_ID, NULL) +#define _parse_generated(stable_id, expected_generated) do_test_stable_id_parse (""stable_id"", NM_UTILS_STABLE_TYPE_GENERATED, ""expected_generated"") +#define _parse_random(stable_id) do_test_stable_id_parse (""stable_id"", NM_UTILS_STABLE_TYPE_RANDOM, NULL) + do_test_stable_id_parse (NULL, NM_UTILS_STABLE_TYPE_UUID, NULL); + _parse_stable_id (""); + _parse_stable_id ("a"); + _parse_stable_id ("a$"); + _parse_stable_id ("a$x"); + _parse_stable_id (" ${a$x"); + _parse_stable_id ("${"); + _parse_stable_id ("${="); + _parse_stable_id ("${a"); + _parse_stable_id ("${a$x"); + _parse_stable_id ("a$$"); + _parse_stable_id ("a$$x"); + _parse_stable_id ("a$${CONNECTION}"); + _parse_stable_id ("a$${CONNECTION}x"); + _parse_generated ("${CONNECTION}", "${CONNECTION}=11{_CONNECTION}"); + _parse_generated ("${${CONNECTION}", "${${CONNECTION}=11{_CONNECTION}"); + _parse_generated ("${CONNECTION}x", "${CONNECTION}=11{_CONNECTION}x"); + _parse_generated ("x${CONNECTION}", "x${CONNECTION}=11{_CONNECTION}"); + _parse_generated ("${BOOT}x", "${BOOT}=5{_BOOT}x"); + _parse_generated ("x${BOOT}", "x${BOOT}=5{_BOOT}"); + _parse_generated ("x${BOOT}${CONNECTION}", "x${BOOT}=5{_BOOT}${CONNECTION}=11{_CONNECTION}"); + _parse_generated ("xX${BOOT}yY${CONNECTION}zZ", "xX${BOOT}=5{_BOOT}yY${CONNECTION}=11{_CONNECTION}zZ"); + _parse_random ("${RANDOM}"); + _parse_random (" ${RANDOM}"); + _parse_random ("${BOOT}${RANDOM}"); +} + +/*****************************************************************************/ + +static void +test_stable_id_generated_complete (void) +{ +#define ASSERT(str, expected) \ + G_STMT_START { \ + gs_free char *_s = NULL; \ + \ + _s = nm_utils_stable_id_generated_complete ((str)); \ + g_assert_cmpstr ((expected), ==, _s); \ + } G_STMT_END + + ASSERT ("", "2jmj7l5rSw0yVb/vlWAYkK/YBwk"); + ASSERT ("a", "hvfkN/qlp/zhXR3cuerq6jd2Z7g"); + ASSERT ("password", "W6ph5Mm5Pz8GgiULbPgzG37mj9g"); +#undef ASSERT +} + +/*****************************************************************************/ + NMTST_DEFINE (); int @@ -1518,6 +1601,9 @@ main (int argc, char **argv) g_test_add_func ("/general/reverse_dns/ip4", test_reverse_dns_ip4); g_test_add_func ("/general/reverse_dns/ip6", test_reverse_dns_ip6); + g_test_add_func ("/general/stable-id/parse", test_stable_id_parse); + g_test_add_func ("/general/stable-id/generated-complete", test_stable_id_generated_complete); + return g_test_run (); } diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index 95b221bc..bff715e0 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -24,7 +24,7 @@ #include #include "nm-ip4-config.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-test-utils-core.h" @@ -322,7 +322,7 @@ test_strip_search_trailing_dot (void) g_object_unref (config); } -/*******************************************/ +/*****************************************************************************/ NMTST_DEFINE (); diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c index de890141..505f9a5d 100644 --- a/src/tests/test-ip6-config.c +++ b/src/tests/test-ip6-config.c @@ -25,7 +25,7 @@ #include "nm-ip6-config.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-test-utils-core.h" static NMIP6Config * @@ -291,7 +291,7 @@ test_nm_ip6_config_addresses_sort (void) nm_ip6_config_reset_addresses (config); ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_IP_CONFIG_SOURCE_RDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); + ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_IP_CONFIG_SOURCE_NDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); ADDR_ADD("2607:f0d0:1002:51::3", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::8", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, IFA_F_SECONDARY); @@ -310,7 +310,7 @@ test_nm_ip6_config_addresses_sort (void) ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); ADDR_ADD("2607:f0d0:1002:51::8", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_IP_CONFIG_SOURCE_RDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); + ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_IP_CONFIG_SOURCE_NDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); @@ -343,7 +343,7 @@ test_strip_search_trailing_dot (void) g_object_unref (config); } -/*******************************************/ +/*****************************************************************************/ NMTST_DEFINE(); diff --git a/src/tests/test-resolvconf-capture.c b/src/tests/test-resolvconf-capture.c index 32bc9734..ccbdafa6 100644 --- a/src/tests/test-resolvconf-capture.c +++ b/src/tests/test-resolvconf-capture.c @@ -26,7 +26,7 @@ #include "NetworkManagerUtils.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-test-utils-core.h" @@ -287,7 +287,7 @@ test_capture_dns_options_valid6 (void) g_array_free (ns6, TRUE); g_ptr_array_free (dns_options, TRUE); } -/*******************************************/ +/*****************************************************************************/ NMTST_DEFINE (); diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c index b81c263c..df43dd98 100644 --- a/src/tests/test-route-manager.c +++ b/src/tests/test-route-manager.c @@ -23,11 +23,11 @@ #include #include -#include "nm-platform.h" -#include "nm-platform-utils.h" +#include "platform/nm-platform.h" +#include "platform/nm-platform-utils.h" #include "nm-route-manager.h" -#include "test-common.h" +#include "platform/tests/test-common.h" typedef struct { int ifindex0, ifindex1; @@ -912,6 +912,8 @@ fixture_teardown (test_fixture *fixture, gconstpointer user_data) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/tests/test-secret-agent.py b/src/tests/test-secret-agent.py index 3b21c610..d3f82802 100755 --- a/src/tests/test-secret-agent.py +++ b/src/tests/test-secret-agent.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -import glib -import gobject +from gi.repository import GLib import sys import dbus import dbus.service @@ -31,7 +30,7 @@ class Agent(dbus.service.Object): if uid != 0: raise NotAuthorizedException("UID %d not authorized" % uid) - print "Secrets requested path '%s' setting '%s' hints '%s' new %d" % (connection_path, setting_name, str(hints), request_new) + print("Secrets requested path '%s' setting '%s' hints '%s' new %d" % (connection_path, setting_name, str(hints), request_new)) # return some random GSM secrets s_gsm = dbus.Dictionary({'password': 'asdfadfasdfaf'}) @@ -40,7 +39,7 @@ class Agent(dbus.service.Object): def register(proxy): proxy.Register("test.agent.id", dbus_interface=IFACE_AGENT_MANAGER) - print "Registered!" + print("Registered!") return False def unregister(proxy, loop): @@ -56,17 +55,17 @@ def main(): proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/AgentManager") - mainloop = gobject.MainLoop() + mainloop = GLib.MainLoop() - gobject.idle_add(register, proxy) - print "Running test secret agent" + GLib.idle_add(register, proxy) + print("Running test secret agent") try: mainloop.run() - except KeyboardInterrupt, e: + except KeyboardInterrupt: pass - print "Unregistering..." + print("Unregistering...") unregister(proxy, mainloop); if __name__ == '__main__': diff --git a/src/tests/test-systemd.c b/src/tests/test-systemd.c index 744b55c9..07887960 100644 --- a/src/tests/test-systemd.c +++ b/src/tests/test-systemd.c @@ -19,11 +19,7 @@ #include "nm-default.h" -#include "nm-sd.h" - -#include "sd-dhcp-client.h" -#include "sd-lldp.h" -#include "sd-event.h" +#include "systemd/nm-sd.h" #include "nm-test-utils-core.h" diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c index 000a9d1e..16eb3aec 100644 --- a/src/tests/test-utils.c +++ b/src/tests/test-utils.c @@ -24,8 +24,6 @@ #include #include -#include "nm-core-utils.c" - #include "nm-test-utils-core.h" static void @@ -34,25 +32,25 @@ test_stable_privacy (void) struct in6_addr addr1; inet_pton (AF_INET6, "1234::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1234::4ceb:14cd:3d54:793f"); /* We get an address without the UUID. */ inet_pton (AF_INET6, "1::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", NULL, 384, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", "", 384, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1::11aa:2530:9144:dafa"); /* We get a different address in a different network. */ inet_pton (AF_INET6, "2::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", NULL, 384, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", "", 384, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "2::338e:8d:c11:8726"); inet_pton (AF_INET6, "1234::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1234::ad4c:ae44:3d30:af1e"); inet_pton (AF_INET6, "1234::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "stable-id-1", 0, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "stable-id-1", 0, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1234::4944:67b0:7a6c:1cf"); } @@ -77,13 +75,13 @@ _do_test_hw_addr (NMUtilsStableType stable_type, g_assert (nm_utils_hwaddr_valid (*e, ETH_ALEN)); } - generated = _hw_addr_gen_stable_eth (stable_type, - stable_id, - secret_key, - key_len, - ifname, - current_mac_address, - generate_mac_address_mask); + generated = nm_utils_hw_addr_gen_stable_eth_impl (stable_type, + stable_id, + secret_key, + key_len, + ifname, + current_mac_address, + generate_mac_address_mask); g_assert (generated); g_assert (nm_utils_hwaddr_valid (generated, ETH_ALEN)); diff --git a/src/tests/test-wired-defname.c b/src/tests/test-wired-defname.c index 3ae3a19d..a966ed21 100644 --- a/src/tests/test-wired-defname.c +++ b/src/tests/test-wired-defname.c @@ -22,7 +22,7 @@ #include "nm-simple-connection.h" #include "nm-setting-connection.h" -#include "nm-device-ethernet-utils.h" +#include "devices/nm-device-ethernet-utils.h" #include "nm-test-utils-core.h" @@ -39,7 +39,7 @@ _new_connection (const char *id) return a; } -/*******************************************/ +/*****************************************************************************/ static char * _get_default_wired_name (GSList *list) @@ -55,7 +55,7 @@ _get_default_wired_name (GSList *list) return nm_device_ethernet_utils_get_default_wired_name (v); } -/*******************************************/ +/*****************************************************************************/ static void test_defname_no_connections (void) @@ -66,7 +66,7 @@ test_defname_no_connections (void) g_assert_cmpstr (name, ==, "Wired connection 1"); } -/*******************************************/ +/*****************************************************************************/ static void test_defname_no_conflict (void) @@ -84,7 +84,7 @@ test_defname_no_conflict (void) g_slist_free_full (list, g_object_unref); } -/*******************************************/ +/*****************************************************************************/ static void test_defname_conflict (void) @@ -102,7 +102,7 @@ test_defname_conflict (void) g_slist_free_full (list, g_object_unref); } -/*******************************************/ +/*****************************************************************************/ static void test_defname_multiple_conflicts (void) @@ -124,7 +124,7 @@ test_defname_multiple_conflicts (void) g_slist_free_full (list, g_object_unref); } -/*******************************************/ +/*****************************************************************************/ NMTST_DEFINE (); diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c deleted file mode 100644 index 1441c3c6..00000000 --- a/src/vpn-manager/nm-vpn-connection.c +++ /dev/null @@ -1,2728 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2013 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#include "nm-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nm-vpn-connection.h" -#include "nm-ip4-config.h" -#include "nm-ip6-config.h" -#include "nm-platform.h" -#include "nm-active-connection.h" -#include "NetworkManagerUtils.h" -#include "settings/nm-settings-connection.h" -#include "nm-dispatcher.h" -#include "nm-agent-manager.h" -#include "nm-core-internal.h" -#include "nm-default-route-manager.h" -#include "nm-route-manager.h" -#include "nm-firewall-manager.h" -#include "nm-config.h" -#include "nm-vpn-plugin-info.h" -#include "nm-vpn-manager.h" -#include "nm-dns-manager.h" - -#include "nmdbus-vpn-connection.h" - -typedef enum { - /* Only system secrets */ - SECRETS_REQ_SYSTEM = 0, - /* All existing secrets including agent secrets */ - SECRETS_REQ_EXISTING = 1, - /* New secrets required; ask an agent */ - SECRETS_REQ_NEW = 2, - /* Plugin requests secrets interactively */ - SECRETS_REQ_INTERACTIVE = 3, - /* Placeholder for bounds checking */ - SECRETS_REQ_LAST -} SecretsReq; - -/* Internal VPN states, private to NMVpnConnection */ -typedef enum { - STATE_UNKNOWN = 0, - STATE_WAITING, - STATE_PREPARE, - STATE_NEED_AUTH, - STATE_CONNECT, - STATE_IP_CONFIG_GET, - STATE_PRE_UP, - STATE_ACTIVATED, - STATE_DEACTIVATING, - STATE_DISCONNECTED, - STATE_FAILED, -} VpnState; - -enum { - VPN_STATE_CHANGED, - INTERNAL_STATE_CHANGED, - INTERNAL_RETRY_AFTER_FAILURE, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -NM_GOBJECT_PROPERTIES_DEFINE (NMVpnConnection, - PROP_VPN_STATE, - PROP_BANNER, -#define PROP_IP4_CONFIG 2000 -#define PROP_IP6_CONFIG 2001 -#define PROP_MASTER 2002 -); - -typedef struct { - gboolean service_can_persist; - gboolean connection_can_persist; - - NMSettingsConnectionCallId secrets_id; - SecretsReq secrets_idx; - char *username; - - VpnState vpn_state; - guint dispatcher_id; - NMVpnConnectionStateReason failure_reason; - - NMVpnServiceState service_state; - guint start_timeout; - gboolean service_running; - NMVpnPluginInfo *plugin_info; - char *bus_name; - - /* Firewall */ - NMFirewallManagerCallId fw_call; - - NMDefaultRouteManager *default_route_manager; - NMRouteManager *route_manager; - GDBusProxy *proxy; - GCancellable *cancellable; - GVariant *connect_hash; - guint connect_timeout; - gboolean has_ip4; - NMIP4Config *ip4_config; - guint32 ip4_internal_gw; - guint32 ip4_external_gw; - gboolean has_ip6; - NMIP6Config *ip6_config; - - /* These config instances are passed on to NMDevice and modified by NMDevice. - * This pointer is only useful for nm_device_replace_vpn4_config() to clear the - * previous configuration. Consider these instances to be owned by NMDevice. */ - NMIP4Config *last_device_ip4_config; - NMIP6Config *last_device_ip6_config; - - struct in6_addr *ip6_internal_gw; - struct in6_addr *ip6_external_gw; - char *ip_iface; - int ip_ifindex; - char *banner; - guint32 mtu; -} NMVpnConnectionPrivate; - -struct _NMVpnConnection { - NMActiveConnection parent; - NMVpnConnectionPrivate _priv; -}; - -struct _NMVpnConnectionClass { - NMActiveConnectionClass parent; - - /* Signals */ - void (*vpn_state_changed) (NMVpnConnection *self, - NMVpnConnectionState new_state, - NMVpnConnectionStateReason reason); - - /* not exported over D-Bus */ - void (*internal_state_changed) (NMVpnConnection *self, - NMVpnConnectionState new_state, - NMVpnConnectionState old_state, - NMVpnConnectionStateReason reason); - - void (*internal_failed_retry) (NMVpnConnection *self); -}; - -G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION) - -#define NM_VPN_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMVpnConnection, NM_IS_VPN_CONNECTION) - -/*****************************************************************************/ - -static NMSettingsConnection *_get_settings_connection (NMVpnConnection *self, - gboolean allow_missing); - -static void get_secrets (NMVpnConnection *self, - SecretsReq secrets_idx, - const char **hints); - -static void plugin_interactive_secrets_required (NMVpnConnection *self, - const char *message, - const char **secrets); - -static void _set_vpn_state (NMVpnConnection *self, - VpnState vpn_state, - NMVpnConnectionStateReason reason, - gboolean quitting); - -/*********************************************************************/ - -#define _NMLOG_DOMAIN LOGD_VPN -#define _NMLOG_PREFIX_NAME "vpn-connection" - -#define __NMLOG_prefix_buf_len 128 - -static const char * -__LOG_create_prefix (char *buf, NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv; - NMConnection *con; - const char *id; - - if (!self) - return _NMLOG_PREFIX_NAME; - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - con = NM_CONNECTION (_get_settings_connection (self, TRUE)); - id = con ? nm_connection_get_id (con) : NULL; - - g_snprintf (buf, __NMLOG_prefix_buf_len, - "%s[" - "%p" /*self*/ - "%s%s" /*con-uuid*/ - "%s%s%s%s" /*con-id*/ - ",%d" /*ifindex*/ - "%s%s%s" /*iface*/ - "]", - _NMLOG_PREFIX_NAME, - self, - con ? "," : "--", con ? (nm_connection_get_uuid (con) ?: "??") : "", - con ? "," : "", NM_PRINT_FMT_QUOTED (id, "\"", id, "\"", con ? "??" : ""), - priv->ip_ifindex, - NM_PRINT_FMT_QUOTED (priv->ip_iface, ":(", priv->ip_iface, ")", "") - ); - - return buf; -} - -#define _NMLOG(level, ...) \ - G_STMT_START { \ - const NMLogLevel __level = (level); \ - \ - if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ - char __prefix[__NMLOG_prefix_buf_len]; \ - \ - _nm_log (__level, _NMLOG_DOMAIN, 0, \ - "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ - __LOG_create_prefix (__prefix, self) \ - _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ - } \ - } G_STMT_END - -/*********************************************************************/ - -static void -cancel_get_secrets (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (priv->secrets_id) { - nm_settings_connection_cancel_secrets (_get_settings_connection (self, FALSE), - priv->secrets_id); - g_warn_if_fail (!priv->secrets_id); - priv->secrets_id = NULL; - } -} - -static NMVpnConnectionState -_state_to_nm_vpn_state (VpnState state) -{ - switch (state) { - case STATE_WAITING: - case STATE_PREPARE: - return NM_VPN_CONNECTION_STATE_PREPARE; - case STATE_NEED_AUTH: - return NM_VPN_CONNECTION_STATE_NEED_AUTH; - case STATE_CONNECT: - return NM_VPN_CONNECTION_STATE_CONNECT; - case STATE_IP_CONFIG_GET: - case STATE_PRE_UP: - return NM_VPN_CONNECTION_STATE_IP_CONFIG_GET; - case STATE_ACTIVATED: - return NM_VPN_CONNECTION_STATE_ACTIVATED; - case STATE_DEACTIVATING: { - /* Map DEACTIVATING to ACTIVATED to preserve external API behavior, - * since our API has no DEACTIVATING state of its own. Since this can - * take some time, and the VPN isn't actually disconnected until it - * hits the DISCONNECTED state, to clients it should still appear - * connected. - */ - return NM_VPN_CONNECTION_STATE_ACTIVATED; - } - case STATE_DISCONNECTED: - return NM_VPN_CONNECTION_STATE_DISCONNECTED; - case STATE_FAILED: - return NM_VPN_CONNECTION_STATE_FAILED; - default: - return NM_VPN_CONNECTION_STATE_UNKNOWN; - } -} - -static NMActiveConnectionState -_state_to_ac_state (VpnState vpn_state) -{ - /* Set the NMActiveConnection state based on VPN state */ - switch (vpn_state) { - case STATE_WAITING: - case STATE_PREPARE: - case STATE_NEED_AUTH: - case STATE_CONNECT: - case STATE_IP_CONFIG_GET: - case STATE_PRE_UP: - return NM_ACTIVE_CONNECTION_STATE_ACTIVATING; - case STATE_ACTIVATED: - return NM_ACTIVE_CONNECTION_STATE_ACTIVATED; - case STATE_DEACTIVATING: - return NM_ACTIVE_CONNECTION_STATE_DEACTIVATING; - case STATE_DISCONNECTED: - case STATE_FAILED: - return NM_ACTIVE_CONNECTION_STATE_DEACTIVATED; - default: - break; - } - return NM_ACTIVE_CONNECTION_STATE_UNKNOWN; -} - -static NMSettingsConnection * -_get_settings_connection (NMVpnConnection *self, gboolean allow_missing) -{ - NMSettingsConnection *con; - - /* Currently we operate on the assumption, that the settings-connection - * never changes after it is set (though initially, it might be unset). - * Later we might want to change that, but then we need fixes here too. */ - - con = _nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (self)); - if (!con && !allow_missing) - g_return_val_if_reached (NULL); - return con; -} - -static NMConnection * -_get_applied_connection (NMVpnConnection *connection) -{ - NMConnection *con; - - con = nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (connection)); - g_return_val_if_fail (con, NULL); - return con; -} - -static void -disconnect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - g_dbus_proxy_call_finish (proxy, result, NULL); - g_object_unref (user_data); -} - -static void -call_plugin_disconnect (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - g_dbus_proxy_call (priv->proxy, - "Disconnect", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) disconnect_cb, - g_object_ref (self)); -} - -static void -fw_call_cleanup (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (priv->fw_call) { - nm_firewall_manager_cancel_call (priv->fw_call); - g_warn_if_fail (!priv->fw_call); - priv->fw_call = NULL; - } -} - -static void -remove_parent_device_config (NMVpnConnection *connection, NMDevice *device) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); - - if (priv->last_device_ip4_config) { - nm_device_replace_vpn4_config (device, priv->last_device_ip4_config, NULL); - g_clear_object (&priv->last_device_ip4_config); - } - - if (priv->last_device_ip6_config) { - nm_device_replace_vpn6_config (device, priv->last_device_ip6_config, NULL); - g_clear_object (&priv->last_device_ip6_config); - } -} - -static void -vpn_cleanup (NMVpnConnection *self, NMDevice *parent_dev) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (priv->ip_ifindex) { - nm_platform_link_set_down (NM_PLATFORM_GET, priv->ip_ifindex); - nm_route_manager_route_flush (priv->route_manager, priv->ip_ifindex); - nm_platform_address_flush (NM_PLATFORM_GET, priv->ip_ifindex); - } - - remove_parent_device_config (self, parent_dev); - - /* Remove zone from firewall */ - if (priv->ip_iface) { - nm_firewall_manager_remove_from_zone (nm_firewall_manager_get (), - priv->ip_iface, - NULL, - NULL, - NULL); - } - /* Cancel pending firewall call */ - fw_call_cleanup (self); - - g_free (priv->banner); - priv->banner = NULL; - - g_free (priv->ip_iface); - priv->ip_iface = NULL; - priv->ip_ifindex = 0; - - g_free (priv->bus_name); - priv->bus_name = NULL; - - /* Clear out connection secrets to ensure that the settings service - * gets asked for them next time the connection is activated. - */ - nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (self)); -} - -static void -dispatcher_pre_down_done (guint call_id, gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - priv->dispatcher_id = 0; - _set_vpn_state (self, STATE_DISCONNECTED, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); -} - -static void -dispatcher_pre_up_done (guint call_id, gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - priv->dispatcher_id = 0; - _set_vpn_state (self, STATE_ACTIVATED, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); -} - -static void -dispatcher_cleanup (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (priv->dispatcher_id) { - nm_dispatcher_call_cancel (priv->dispatcher_id); - priv->dispatcher_id = 0; - } -} - -static void -_set_vpn_state (NMVpnConnection *self, - VpnState vpn_state, - NMVpnConnectionStateReason reason, - gboolean quitting) -{ - NMVpnConnectionPrivate *priv; - VpnState old_vpn_state; - NMVpnConnectionState new_external_state, old_external_state; - NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (self)); - - g_return_if_fail (NM_IS_VPN_CONNECTION (self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (vpn_state == priv->vpn_state) - return; - - old_vpn_state = priv->vpn_state; - priv->vpn_state = vpn_state; - - /* The device gets destroyed by active connection when it enters - * the deactivated state, so we need to ref it for usage below. - */ - if (parent_dev) - g_object_ref (parent_dev); - - /* Update active connection base class state */ - nm_active_connection_set_state (NM_ACTIVE_CONNECTION (self), - _state_to_ac_state (vpn_state)); - - /* Clear any in-progress secrets request */ - cancel_get_secrets (self); - - dispatcher_cleanup (self); - - nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self); - nm_default_route_manager_ip6_update_default_route (priv->default_route_manager, self); - - /* The connection gets destroyed by the VPN manager when it enters the - * disconnected/failed state, but we need to keep it around for a bit - * to send out signals and handle the dispatcher. So ref it. - */ - g_object_ref (self); - - old_external_state = _state_to_nm_vpn_state (old_vpn_state); - new_external_state = _state_to_nm_vpn_state (priv->vpn_state); - if (new_external_state != old_external_state) { - g_signal_emit (self, signals[VPN_STATE_CHANGED], 0, new_external_state, reason); - g_signal_emit (self, signals[INTERNAL_STATE_CHANGED], 0, - new_external_state, - old_external_state, - reason); - _notify (self, PROP_VPN_STATE); - } - - switch (vpn_state) { - case STATE_NEED_AUTH: - /* Do nothing; not part of 'default' because we don't want to touch - * priv->secrets_req as NEED_AUTH is re-entered during interactive - * secrets. - */ - break; - case STATE_PRE_UP: - if (!nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_PRE_UP, - _get_settings_connection (self, FALSE), - _get_applied_connection (self), - parent_dev, - priv->ip_iface, - priv->ip4_config, - priv->ip6_config, - dispatcher_pre_up_done, - self, - &priv->dispatcher_id)) { - /* Just proceed on errors */ - dispatcher_pre_up_done (0, self); - } - break; - case STATE_ACTIVATED: - /* Secrets no longer needed now that we're connected */ - nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (self)); - - /* Let dispatcher scripts know we're up and running */ - nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_UP, - _get_settings_connection (self, FALSE), - _get_applied_connection (self), - parent_dev, - priv->ip_iface, - priv->ip4_config, - priv->ip6_config, - NULL, - NULL, - NULL); - break; - case STATE_DEACTIVATING: - if (quitting) { - nm_dispatcher_call_vpn_sync (DISPATCHER_ACTION_VPN_PRE_DOWN, - _get_settings_connection (self, FALSE), - _get_applied_connection (self), - parent_dev, - priv->ip_iface, - priv->ip4_config, - priv->ip6_config); - } else { - if (!nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_PRE_DOWN, - _get_settings_connection (self, FALSE), - _get_applied_connection (self), - parent_dev, - priv->ip_iface, - priv->ip4_config, - priv->ip6_config, - dispatcher_pre_down_done, - self, - &priv->dispatcher_id)) { - /* Just proceed on errors */ - dispatcher_pre_down_done (0, self); - } - } - break; - case STATE_FAILED: - case STATE_DISCONNECTED: - if ( old_vpn_state >= STATE_ACTIVATED - && old_vpn_state <= STATE_DEACTIVATING) { - /* Let dispatcher scripts know we're about to go down */ - if (quitting) { - nm_dispatcher_call_vpn_sync (DISPATCHER_ACTION_VPN_DOWN, - _get_settings_connection (self, FALSE), - _get_applied_connection (self), - parent_dev, - priv->ip_iface, - NULL, - NULL); - } else { - nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_DOWN, - _get_settings_connection (self, FALSE), - _get_applied_connection (self), - parent_dev, - priv->ip_iface, - NULL, - NULL, - NULL, - NULL, - NULL); - } - } - - /* Tear down and clean up the connection */ - call_plugin_disconnect (self); - vpn_cleanup (self, parent_dev); - /* Fall through */ - default: - priv->secrets_idx = SECRETS_REQ_SYSTEM; - break; - } - - g_object_unref (self); - if (parent_dev) - g_object_unref (parent_dev); -} - -static gboolean -_service_and_connection_can_persist (NMVpnConnection *self) -{ - return NM_VPN_CONNECTION_GET_PRIVATE (self)->connection_can_persist && - NM_VPN_CONNECTION_GET_PRIVATE (self)->service_can_persist; -} - -static gboolean -_connection_only_can_persist (NMVpnConnection *self) -{ - return NM_VPN_CONNECTION_GET_PRIVATE (self)->connection_can_persist && - !NM_VPN_CONNECTION_GET_PRIVATE (self)->service_can_persist; -} - -static void -device_state_changed (NMActiveConnection *active, - NMDevice *device, - NMDeviceState new_state, - NMDeviceState old_state) -{ - if (_service_and_connection_can_persist (NM_VPN_CONNECTION (active))) { - if (new_state <= NM_DEVICE_STATE_DISCONNECTED || - new_state == NM_DEVICE_STATE_FAILED) { - nm_active_connection_set_device (active, NULL); - } - return; - } - - if (new_state <= NM_DEVICE_STATE_DISCONNECTED) { - _set_vpn_state (NM_VPN_CONNECTION (active), - STATE_DISCONNECTED, - NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED, - FALSE); - } else if (new_state == NM_DEVICE_STATE_FAILED) { - _set_vpn_state (NM_VPN_CONNECTION (active), - STATE_FAILED, - NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED, - FALSE); - } - - /* FIXME: map device DEACTIVATING state to VPN DEACTIVATING state and - * block device deactivation on VPN deactivation. - */ -} - -static void -add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32 vpn_gw) -{ - NMIP4Config *parent_config; - guint32 parent_gw; - NMPlatformIP4Route route; - guint32 route_metric; - - g_return_if_fail (NM_IS_IP4_CONFIG (config)); - g_return_if_fail (NM_IS_DEVICE (parent_device)); - g_return_if_fail (vpn_gw != 0); - - /* Set up a route to the VPN gateway's public IP address through the default - * network device if the VPN gateway is on a different subnet. - */ - - parent_config = nm_device_get_ip4_config (parent_device); - g_return_if_fail (parent_config != NULL); - parent_gw = nm_ip4_config_get_gateway (parent_config); - if (!parent_gw) - return; - - route_metric = nm_device_get_ip4_route_metric (parent_device); - - memset (&route, 0, sizeof (route)); - route.network = vpn_gw; - route.plen = 32; - route.gateway = parent_gw; - - /* If the VPN gateway is in the same subnet as one of the parent device's - * IP addresses, don't add the host route to it, but a route through the - * parent device. - */ - if (nm_ip4_config_destination_is_direct (parent_config, vpn_gw, 32)) - route.gateway = 0; - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - nm_ip4_config_add_route (config, &route); - - /* Ensure there's a route to the parent device's gateway through the - * parent device, since if the VPN claims the default route and the VPN - * routes include a subnet that matches the parent device's subnet, - * the parent device's gateway would get routed through the VPN and fail. - */ - memset (&route, 0, sizeof (route)); - route.network = parent_gw; - route.plen = 32; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - - nm_ip4_config_add_route (config, &route); -} - -static void -add_ip6_vpn_gateway_route (NMIP6Config *config, - NMDevice *parent_device, - const struct in6_addr *vpn_gw) -{ - NMIP6Config *parent_config; - const struct in6_addr *parent_gw; - NMPlatformIP6Route route; - guint32 route_metric; - - g_return_if_fail (NM_IS_IP6_CONFIG (config)); - g_return_if_fail (NM_IS_DEVICE (parent_device)); - g_return_if_fail (vpn_gw != NULL); - - parent_config = nm_device_get_ip6_config (parent_device); - g_return_if_fail (parent_config != NULL); - parent_gw = nm_ip6_config_get_gateway (parent_config); - if (!parent_gw) - return; - - route_metric = nm_device_get_ip6_route_metric (parent_device); - - memset (&route, 0, sizeof (route)); - route.network = *vpn_gw; - route.plen = 128; - route.gateway = *parent_gw; - - /* If the VPN gateway is in the same subnet as one of the parent device's - * IP addresses, don't add the host route to it, but a route through the - * parent device. - */ - if (nm_ip6_config_destination_is_direct (parent_config, vpn_gw, 128)) - route.gateway = in6addr_any; - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - nm_ip6_config_add_route (config, &route); - - /* Ensure there's a route to the parent device's gateway through the - * parent device, since if the VPN claims the default route and the VPN - * routes include a subnet that matches the parent device's subnet, - * the parent device's gateway would get routed through the VPN and fail. - */ - memset (&route, 0, sizeof (route)); - route.network = *parent_gw; - route.plen = 128; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - route.metric = route_metric; - - nm_ip6_config_add_route (config, &route); -} - -NMVpnConnection * -nm_vpn_connection_new (NMSettingsConnection *settings_connection, - NMDevice *parent_device, - const char *specific_object, - NMAuthSubject *subject) -{ - g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL); - g_return_val_if_fail (NM_IS_DEVICE (parent_device), NULL); - - return (NMVpnConnection *) g_object_new (NM_TYPE_VPN_CONNECTION, - NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, settings_connection, - NM_ACTIVE_CONNECTION_INT_DEVICE, parent_device, - NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, - NM_ACTIVE_CONNECTION_INT_SUBJECT, subject, - NM_ACTIVE_CONNECTION_VPN, TRUE, - NULL); -} - -const char * -nm_vpn_connection_get_service (NMVpnConnection *self) -{ - NMSettingVpn *s_vpn; - - s_vpn = nm_connection_get_setting_vpn (_get_applied_connection (self)); - return nm_setting_vpn_get_service_type (s_vpn); -} - -NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_plugin_failure_to_string, NMVpnPluginFailure, - NM_UTILS_LOOKUP_DEFAULT (NULL), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED, "login-failed"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED, "connect-failed"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG, "bad-ip-config"), -); -#define vpn_plugin_failure_to_string(failure) NM_UTILS_LOOKUP_STR (_vpn_plugin_failure_to_string, failure) - -static void -plugin_failed (NMVpnConnection *self, guint reason) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - _LOGW ("VPN plugin: failed: %s (%d)", vpn_plugin_failure_to_string (reason), reason); - - switch (reason) { - case NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED: - priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED; - break; - case NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG: - priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID; - break; - default: - priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_UNKNOWN; - break; - } -} - -NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_service_state_to_string, NMVpnServiceState, - NM_UTILS_LOOKUP_DEFAULT (NULL), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_UNKNOWN, "unknown"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_INIT, "init"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_SHUTDOWN, "shutdown"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STARTING, "starting"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STARTED, "started"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STOPPING, "stopping"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STOPPED, "stopped"), -); -#define vpn_service_state_to_string(state) NM_UTILS_LOOKUP_STR (_vpn_service_state_to_string, state) - -NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_state_to_string, VpnState, - NM_UTILS_LOOKUP_DEFAULT (NULL), - NM_UTILS_LOOKUP_STR_ITEM (STATE_UNKNOWN, "unknown"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_WAITING, "waiting"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_PREPARE, "prepare"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_NEED_AUTH, "need-auth"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_CONNECT, "connect"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_IP_CONFIG_GET, "ip-config-get"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_PRE_UP, "pre-up"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_ACTIVATED, "activated"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_DEACTIVATING, "deactivating"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_DISCONNECTED, "disconnected"), - NM_UTILS_LOOKUP_STR_ITEM (STATE_FAILED, "failed"), -); -#define vpn_state_to_string(state) NM_UTILS_LOOKUP_STR (_vpn_state_to_string, state) - -NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_reason_to_string, NMVpnConnectionStateReason, - NM_UTILS_LOOKUP_DEFAULT (NULL), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_UNKNOWN, "unknown"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_NONE, "none"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED, "user-disconnected"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED, "device-disconnected"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED, "service-stopped"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, "ip-config-invalid"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, "connect-timeout"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT, "service-start-timeout"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, "service-start-failed"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, "no-secrets"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED, "login-failed"), - NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED, "connection-removed"), -); -#define vpn_reason_to_string(reason) NM_UTILS_LOOKUP_STR (_vpn_reason_to_string, reason) - -static void -plugin_state_changed (NMVpnConnection *self, NMVpnServiceState new_service_state) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - NMVpnServiceState old_service_state = priv->service_state; - - _LOGI ("VPN plugin: state changed: %s (%d)", - vpn_service_state_to_string (new_service_state), new_service_state); - priv->service_state = new_service_state; - - if (new_service_state == NM_VPN_SERVICE_STATE_STOPPED) { - /* Clear connection secrets to ensure secrets get requested each time the - * connection is activated. - */ - nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (self)); - - if ((priv->vpn_state >= STATE_WAITING) && (priv->vpn_state <= STATE_ACTIVATED)) { - VpnState old_state = priv->vpn_state; - - _LOGI ("VPN plugin: state change reason: %s (%d)", - vpn_reason_to_string (priv->failure_reason), priv->failure_reason); - _set_vpn_state (self, STATE_FAILED, priv->failure_reason, FALSE); - - /* Reset the failure reason */ - priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_UNKNOWN; - - /* If the connection failed, the service cannot persist, but the - * connection can persist, ask listeners to re-activate the connection. - */ - if ( old_state == STATE_ACTIVATED - && priv->vpn_state == STATE_FAILED - && _connection_only_can_persist (self)) - g_signal_emit (self, signals[INTERNAL_RETRY_AFTER_FAILURE], 0); - } - } else if (new_service_state == NM_VPN_SERVICE_STATE_STARTING && - old_service_state == NM_VPN_SERVICE_STATE_STARTED) { - /* The VPN service got disconnected and is attempting to reconnect */ - _set_vpn_state (self, STATE_CONNECT, NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, FALSE); - } -} - -static void -print_vpn_config (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - const NMPlatformIP4Address *address4; - const NMPlatformIP6Address *address6; - char *dns_domain = NULL; - guint32 num, i; - char buf[NM_UTILS_INET_ADDRSTRLEN]; - - if (priv->ip4_external_gw) { - _LOGI ("Data: VPN Gateway: %s", - nm_utils_inet4_ntop (priv->ip4_external_gw, NULL)); - } else if (priv->ip6_external_gw) { - _LOGI ("Data: VPN Gateway: %s", - nm_utils_inet6_ntop (priv->ip6_external_gw, NULL)); - } - - _LOGI ("Data: Tunnel Device: %s%s%s", NM_PRINT_FMT_QUOTE_STRING (priv->ip_iface)); - - if (priv->ip4_config) { - _LOGI ("Data: IPv4 configuration:"); - - address4 = nm_ip4_config_get_address (priv->ip4_config, 0); - - if (priv->ip4_internal_gw) - _LOGI ("Data: Internal Gateway: %s", nm_utils_inet4_ntop (priv->ip4_internal_gw, NULL)); - _LOGI ("Data: Internal Address: %s", nm_utils_inet4_ntop (address4->address, NULL)); - _LOGI ("Data: Internal Prefix: %d", address4->plen); - _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet4_ntop (address4->peer_address, NULL)); - _LOGI ("Data: Maximum Segment Size (MSS): %d", nm_ip4_config_get_mss (priv->ip4_config)); - - num = nm_ip4_config_get_num_routes (priv->ip4_config); - for (i = 0; i < num; i++) { - const NMPlatformIP4Route *route = nm_ip4_config_get_route (priv->ip4_config, i); - - _LOGI ("Data: Static Route: %s/%d Next Hop: %s", - nm_utils_inet4_ntop (route->network, NULL), - route->plen, - nm_utils_inet4_ntop (route->gateway, buf)); - } - - _LOGI ("Data: Forbid Default Route: %s", - nm_ip4_config_get_never_default (priv->ip4_config) ? "yes" : "no"); - - num = nm_ip4_config_get_num_nameservers (priv->ip4_config); - for (i = 0; i < num; i++) { - _LOGI ("Data: Internal DNS: %s", - nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (priv->ip4_config, i), NULL)); - } - - if (nm_ip4_config_get_num_domains (priv->ip4_config) > 0) - dns_domain = (char *) nm_ip4_config_get_domain (priv->ip4_config, 0); - - _LOGI ("Data: DNS Domain: '%s'", dns_domain ? dns_domain : "(none)"); - } else - _LOGI ("Data: No IPv4 configuration"); - - if (priv->ip6_config) { - _LOGI ("Data: IPv6 configuration:"); - - address6 = nm_ip6_config_get_address (priv->ip6_config, 0); - - if (priv->ip6_internal_gw) - _LOGI ("Data: Internal Gateway: %s", nm_utils_inet6_ntop (priv->ip6_internal_gw, NULL)); - _LOGI ("Data: Internal Address: %s", nm_utils_inet6_ntop (&address6->address, NULL)); - _LOGI ("Data: Internal Prefix: %d", address6->plen); - _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet6_ntop (&address6->peer_address, NULL)); - _LOGI ("Data: Maximum Segment Size (MSS): %d", nm_ip6_config_get_mss (priv->ip6_config)); - - num = nm_ip6_config_get_num_routes (priv->ip6_config); - for (i = 0; i < num; i++) { - const NMPlatformIP6Route *route = nm_ip6_config_get_route (priv->ip6_config, i); - - _LOGI ("Data: Static Route: %s/%d Next Hop: %s", - nm_utils_inet6_ntop (&route->network, NULL), - route->plen, - nm_utils_inet6_ntop (&route->gateway, buf)); - } - - _LOGI ("Data: Forbid Default Route: %s", - nm_ip6_config_get_never_default (priv->ip6_config) ? "yes" : "no"); - - num = nm_ip6_config_get_num_nameservers (priv->ip6_config); - for (i = 0; i < num; i++) { - _LOGI ("Data: Internal DNS: %s", - nm_utils_inet6_ntop (nm_ip6_config_get_nameserver (priv->ip6_config, i), NULL)); - } - - if (nm_ip6_config_get_num_domains (priv->ip6_config) > 0) - dns_domain = (char *) nm_ip6_config_get_domain (priv->ip6_config, 0); - - _LOGI ("Data: DNS Domain: '%s'", dns_domain ? dns_domain : "(none)"); - } else - _LOGI ("Data: No IPv6 configuration"); - - if (priv->banner && strlen (priv->banner)) { - _LOGI ("Data: Login Banner:"); - _LOGI ("Data: -----------------------------------------"); - _LOGI ("Data: %s", priv->banner); - _LOGI ("Data: -----------------------------------------"); - } -} - -static void -apply_parent_device_config (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (self)); - NMIP4Config *vpn4_parent_config = NULL; - NMIP6Config *vpn6_parent_config = NULL; - - if (priv->ip_ifindex > 0) { - if (priv->ip4_config) - vpn4_parent_config = nm_ip4_config_new (priv->ip_ifindex); - if (priv->ip6_config) - vpn6_parent_config = nm_ip6_config_new (priv->ip_ifindex); - } else { - int ifindex; - - /* If the VPN didn't return a network interface, it is a route-based - * VPN (like kernel IPSec) and all IP addressing and routing should - * be done on the parent interface instead. - */ - - /* Also clear the gateway. We don't configure the gateway as part of the - * vpn-config. Instead we tell NMDefaultRouteManager directly about the - * default route. */ - ifindex = nm_device_get_ip_ifindex (parent_dev); - if (priv->ip4_config) { - vpn4_parent_config = nm_ip4_config_new (ifindex); - nm_ip4_config_merge (vpn4_parent_config, priv->ip4_config, NM_IP_CONFIG_MERGE_NO_DNS); - } - if (priv->ip6_config) { - vpn6_parent_config = nm_ip6_config_new (ifindex); - nm_ip6_config_merge (vpn6_parent_config, priv->ip6_config, NM_IP_CONFIG_MERGE_NO_DNS); - nm_ip6_config_set_gateway (vpn6_parent_config, NULL); - } - } - - /* Add any explicit route to the VPN gateway through the parent device */ - if (vpn4_parent_config && priv->ip4_external_gw) - add_ip4_vpn_gateway_route (vpn4_parent_config, parent_dev, priv->ip4_external_gw); - if (vpn6_parent_config && priv->ip6_external_gw) - add_ip6_vpn_gateway_route (vpn6_parent_config, parent_dev, priv->ip6_external_gw); - - nm_device_replace_vpn4_config (parent_dev, priv->last_device_ip4_config, vpn4_parent_config); - g_clear_object (&priv->last_device_ip4_config); - priv->last_device_ip4_config = vpn4_parent_config; - - nm_device_replace_vpn6_config (parent_dev, priv->last_device_ip6_config, vpn6_parent_config); - g_clear_object (&priv->last_device_ip6_config); - priv->last_device_ip6_config = vpn6_parent_config; -} - -static gboolean -nm_vpn_connection_apply_config (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (priv->ip_ifindex > 0) { - nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL); - - if (priv->ip4_config) { - if (!nm_ip4_config_commit (priv->ip4_config, priv->ip_ifindex, - TRUE, - nm_vpn_connection_get_ip4_route_metric (self))) - return FALSE; - } - - if (priv->ip6_config) { - if (!nm_ip6_config_commit (priv->ip6_config, - priv->ip_ifindex, - TRUE)) - return FALSE; - } - - if (priv->mtu && priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ip_ifindex)) - nm_platform_link_set_mtu (NM_PLATFORM_GET, priv->ip_ifindex, priv->mtu); - } - - apply_parent_device_config (self); - - nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self); - nm_default_route_manager_ip6_update_default_route (priv->default_route_manager, self); - - _LOGI ("VPN connection: (IP Config Get) complete"); - if (priv->vpn_state < STATE_PRE_UP) - _set_vpn_state (self, STATE_PRE_UP, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); - return TRUE; -} - -static void -_cleanup_failed_config (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - nm_exported_object_clear_and_unexport (&priv->ip4_config); - nm_exported_object_clear_and_unexport (&priv->ip6_config); - - _LOGW ("VPN connection: did not receive valid IP config information"); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, FALSE); -} - -static void -fw_change_zone_cb (NMFirewallManager *firewall_manager, - NMFirewallManagerCallId call_id, - GError *error, - gpointer user_data) -{ - NMVpnConnection *self = user_data; - NMVpnConnectionPrivate *priv; - - g_return_if_fail (NM_IS_VPN_CONNECTION (self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - g_return_if_fail (priv->fw_call == call_id); - - priv->fw_call = NULL; - - if (nm_utils_error_is_cancelled (error, FALSE)) - return; - - if (error) { - // FIXME: fail the activation? - } - - if (!nm_vpn_connection_apply_config (self)) - _cleanup_failed_config (self); -} - -static void -nm_vpn_connection_config_maybe_complete (NMVpnConnection *self, - gboolean success) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - NMConnection *base_con; - NMSettingConnection *s_con; - const char *zone; - - if (priv->vpn_state < STATE_IP_CONFIG_GET || priv->vpn_state > STATE_ACTIVATED) - return; - - if (success) { - if ( (priv->has_ip4 && !priv->ip4_config) - || (priv->has_ip6 && !priv->ip6_config)) { - /* Need to wait for other config */ - return; - } - } - - nm_clear_g_source (&priv->connect_timeout); - - if (success) { - print_vpn_config (self); - - /* Add the tunnel interface to the specified firewall zone */ - if (priv->ip_iface) { - base_con = _get_applied_connection (self); - s_con = nm_connection_get_setting_connection (base_con); - zone = nm_setting_connection_get_zone (s_con); - - _LOGD ("setting firewall zone %s%s%s for '%s'", - NM_PRINT_FMT_QUOTED (zone, "'", zone, "'", "(default)"), - priv->ip_iface); - fw_call_cleanup (self); - priv->fw_call = nm_firewall_manager_add_or_change_zone (nm_firewall_manager_get (), - priv->ip_iface, - zone, - FALSE, - fw_change_zone_cb, - self); - return; - } else - if (nm_vpn_connection_apply_config (self)) - return; - } - - _cleanup_failed_config (self); -} - -static gboolean -ip6_addr_from_variant (GVariant *v, struct in6_addr *addr) -{ - const guint8 *bytes; - gsize len; - - g_return_val_if_fail (v, FALSE); - g_return_val_if_fail (addr, FALSE); - - if (g_variant_is_of_type (v, G_VARIANT_TYPE ("ay"))) { - bytes = g_variant_get_fixed_array (v, &len, sizeof (guint8)); - if (len == sizeof (struct in6_addr) && !IN6_IS_ADDR_UNSPECIFIED (bytes)) { - memcpy (addr, bytes, len); - return TRUE; - } - } - return FALSE; -} - -static struct in6_addr * -ip6_addr_dup_from_variant (GVariant *v) -{ - struct in6_addr *addr; - - addr = g_malloc0 (sizeof (*addr)); - if (ip6_addr_from_variant (v, addr)) - return addr; - g_free (addr); - return NULL; -} - -static gboolean -process_generic_config (NMVpnConnection *self, GVariant *dict) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - const char *str; - GVariant *v; - guint32 u32; - gboolean b; - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_CAN_PERSIST, "b", &b) && b) { - /* Defaults to FALSE, so only let service indicate TRUE */ - priv->service_can_persist = TRUE; - } - - g_clear_pointer (&priv->ip_iface, g_free); - priv->ip_ifindex = 0; - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_TUNDEV, "&s", &str)) { - /* Backwards compat with NM-openswan */ - if (g_strcmp0 (str, "_none_") != 0) - priv->ip_iface = g_strdup (str); - } - - if (priv->ip_iface) { - /* Grab the interface index for address/routing operations */ - priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface); - if (priv->ip_ifindex <= 0) { - nm_platform_process_events (NM_PLATFORM_GET); - priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface); - } - if (priv->ip_ifindex <= 0) { - _LOGE ("failed to look up VPN interface index for \"%s\"", priv->ip_iface); - g_clear_pointer (&priv->ip_iface, g_free); - priv->ip_ifindex = 0; - nm_vpn_connection_config_maybe_complete (self, FALSE); - return FALSE; - } - } - - g_clear_pointer (&priv->banner, g_free); - if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_BANNER, "&s", &str)) { - priv->banner = g_strdup (str); - _notify (self, PROP_BANNER); - } - - /* External world-visible address of the VPN server */ - priv->ip4_external_gw = 0; - g_clear_pointer (&priv->ip6_external_gw, g_free); - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, "u", &u32)) { - priv->ip4_external_gw = u32; - } else if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, "@ay", &v)) { - priv->ip6_external_gw = ip6_addr_dup_from_variant (v); - g_variant_unref (v); - - if (!priv->ip6_external_gw) { - _LOGE ("Invalid IPv6 VPN gateway address received"); - nm_vpn_connection_config_maybe_complete (self, FALSE); - return FALSE; - } - } - - priv->mtu = 0; - if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_MTU, "u", &u32)) - priv->mtu = u32; - - return TRUE; -} - -static void -nm_vpn_connection_config_get (NMVpnConnection *self, GVariant *dict) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - gboolean b; - - g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT)); - - _LOGI ("VPN connection: (IP Config Get) reply received."); - - if (priv->vpn_state == STATE_CONNECT) - _set_vpn_state (self, STATE_IP_CONFIG_GET, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); - - if (!process_generic_config (self, dict)) - return; - - /* Note whether to expect IPv4 and IPv6 configs */ - priv->has_ip4 = FALSE; - if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP4, "b", &b)) - priv->has_ip4 = b; - nm_exported_object_clear_and_unexport (&priv->ip4_config); - - priv->has_ip6 = FALSE; - if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP6, "b", &b)) - priv->has_ip6 = b; - nm_exported_object_clear_and_unexport (&priv->ip6_config); - - nm_vpn_connection_config_maybe_complete (self, TRUE); -} - -guint32 -nm_vpn_connection_get_ip4_route_metric (NMVpnConnection *self) -{ - gint64 route_metric; - NMConnection *applied; - - applied = _get_applied_connection (self); - route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip4_config (applied)); - - return (route_metric >= 0) ? route_metric : NM_VPN_ROUTE_METRIC_DEFAULT; -} - -guint32 -nm_vpn_connection_get_ip6_route_metric (NMVpnConnection *self) -{ - gint64 route_metric; - NMConnection *applied; - - applied = _get_applied_connection (self); - route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip6_config (applied)); - - return (route_metric >= 0) ? route_metric : NM_VPN_ROUTE_METRIC_DEFAULT; -} - -static void -nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - NMPlatformIP4Address address; - NMIP4Config *config; - guint32 u32, route_metric; - GVariantIter *iter; - const char *str; - GVariant *v; - gboolean b; - guint i, n; - int ip_ifindex; - - g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT)); - - if (priv->vpn_state == STATE_CONNECT) - _set_vpn_state (self, STATE_IP_CONFIG_GET, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); - - if (priv->vpn_state > STATE_ACTIVATED) { - _LOGI ("VPN connection: (IP4 Config Get) ignoring, the connection is no longer active"); - return; - } - - if (priv->has_ip4) { - _LOGI ("VPN connection: (IP4 Config Get) reply received"); - - if (g_variant_n_children (dict) == 0) { - priv->has_ip4 = FALSE; - nm_vpn_connection_config_maybe_complete (self, TRUE); - return; - } - } else { - _LOGI ("VPN connection: (IP4 Config Get) reply received from old-style plugin"); - - /* In the old API, the generic and IPv4 configuration items - * were mixed together. - */ - if (!process_generic_config (self, dict)) - return; - - priv->has_ip4 = TRUE; - priv->has_ip6 = FALSE; - } - - ip_ifindex = nm_vpn_connection_get_ip_ifindex (self, TRUE); - if (ip_ifindex <= 0) - g_return_if_reached (); - - config = nm_ip4_config_new (ip_ifindex); - nm_ip4_config_set_dns_priority (config, NM_DNS_PRIORITY_DEFAULT_VPN); - - memset (&address, 0, sizeof (address)); - address.plen = 24; - - /* Internal address of the VPN subnet's gateway */ - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY, "u", &u32)) { - priv->ip4_internal_gw = u32; - nm_ip4_config_set_gateway (config, priv->ip4_internal_gw); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, "u", &u32)) - address.address = u32; - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_PTP, "u", &u32)) - address.peer_address = u32; - else - address.peer_address = address.address; - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, "u", &u32)) - address.plen = u32; - - if (address.address && address.plen && address.plen <= 32) { - address.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_address (config, &address); - } else { - _LOGW ("invalid IP4 config received!"); - g_object_unref (config); - nm_vpn_connection_config_maybe_complete (self, FALSE); - return; - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_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); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_NBNS, "au", &iter)) { - while (g_variant_iter_next (iter, "u", &u32)) - nm_ip4_config_add_wins (config, u32); - g_variant_iter_free (iter); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_MSS, "u", &u32)) - nm_ip4_config_set_mss (config, u32); - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_DOMAIN, "&s", &str)) - nm_ip4_config_add_domain (config, str); - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS, "as", &iter)) { - while (g_variant_iter_next (iter, "&s", &str)) - nm_ip4_config_add_domain (config, str); - g_variant_iter_free (iter); - } - - route_metric = nm_vpn_connection_get_ip4_route_metric (self); - - if ( g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_PRESERVE_ROUTES, "b", &b) - && b) { - if (priv->ip4_config) { - n = nm_ip4_config_get_num_routes (priv->ip4_config); - for (i = 0; i < n; i++) - nm_ip4_config_add_route (config, nm_ip4_config_get_route (priv->ip4_config, i)); - } - } else if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, "aau", &iter)) { - while (g_variant_iter_next (iter, "@au", &v)) { - NMPlatformIP4Route route = { 0, }; - guint32 plen; - - switch (g_variant_n_children (v)) { - case 5: - g_variant_get_child (v, 4, "u", &route.pref_src); - /* fallthrough */ - case 4: - g_variant_get_child (v, 0, "u", &route.network); - g_variant_get_child (v, 1, "u", &plen); - g_variant_get_child (v, 2, "u", &route.gateway); - /* 4th item is unused route metric */ - route.metric = route_metric; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - - if (plen > 32 || plen == 0) - break; - route.plen = plen; - - /* Ignore host routes to the VPN gateway since NM adds one itself - * below. Since NM knows more about the routing situation than - * the VPN server, we want to use the NM created route instead of - * whatever the server provides. - */ - if (!(priv->ip4_external_gw && route.network == priv->ip4_external_gw && route.plen == 32)) - nm_ip4_config_add_route (config, &route); - break; - default: - break; - } - g_variant_unref (v); - } - g_variant_iter_free (iter); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT, "b", &b)) - nm_ip4_config_set_never_default (config, b); - - /* Merge in user overrides from the NMConnection's IPv4 setting */ - nm_ip4_config_merge_setting (config, - nm_connection_get_setting_ip4_config (_get_applied_connection (self)), - route_metric); - - if (priv->ip4_config) { - nm_ip4_config_replace (priv->ip4_config, config, NULL); - g_object_unref (config); - } else { - priv->ip4_config = config; - nm_exported_object_export (NM_EXPORTED_OBJECT (config)); - g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP4_CONFIG); - } - - nm_vpn_connection_config_maybe_complete (self, TRUE); -} - -static void -nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - NMPlatformIP6Address address; - guint32 u32, route_metric; - NMIP6Config *config; - GVariantIter *iter; - const char *str; - GVariant *v; - gboolean b; - guint i, n; - int ip_ifindex; - - g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT)); - - _LOGI ("VPN connection: (IP6 Config Get) reply received"); - - if (priv->vpn_state == STATE_CONNECT) - _set_vpn_state (self, STATE_IP_CONFIG_GET, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); - - if (priv->vpn_state > STATE_ACTIVATED) { - _LOGI ("VPN connection: (IP6 Config Get) ignoring, the connection is no longer active"); - return; - } - - if (g_variant_n_children (dict) == 0) { - priv->has_ip6 = FALSE; - nm_vpn_connection_config_maybe_complete (self, TRUE); - return; - } - - ip_ifindex = nm_vpn_connection_get_ip_ifindex (self, TRUE); - if (ip_ifindex <= 0) - g_return_if_reached (); - - config = nm_ip6_config_new (ip_ifindex); - nm_ip6_config_set_dns_priority (config, NM_DNS_PRIORITY_DEFAULT_VPN); - - memset (&address, 0, sizeof (address)); - address.plen = 128; - - /* Internal address of the VPN subnet's gateway */ - g_clear_pointer (&priv->ip6_internal_gw, g_free); - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY, "@ay", &v)) { - priv->ip6_internal_gw = ip6_addr_dup_from_variant (v); - nm_ip6_config_set_gateway (config, priv->ip6_internal_gw); - g_variant_unref (v); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_ADDRESS, "@ay", &v)) { - ip6_addr_from_variant (v, &address.address); - g_variant_unref (v); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_PTP, "@ay", &v)) { - ip6_addr_from_variant (v, &address.peer_address); - g_variant_unref (v); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_PREFIX, "u", &u32)) - address.plen = u32; - - if (!IN6_IS_ADDR_UNSPECIFIED (&address.address) && address.plen && address.plen <= 128) { - address.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_address (config, &address); - } else { - _LOGW ("invalid IP6 config received!"); - g_object_unref (config); - nm_vpn_connection_config_maybe_complete (self, FALSE); - return; - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_DNS, "aay", &iter)) { - while (g_variant_iter_next (iter, "@ay", &v)) { - struct in6_addr dns; - - if (ip6_addr_from_variant (v, &dns)) - nm_ip6_config_add_nameserver (config, &dns); - g_variant_unref (v); - } - g_variant_iter_free (iter); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_MSS, "u", &u32)) - nm_ip6_config_set_mss (config, u32); - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_DOMAIN, "&s", &str)) - nm_ip6_config_add_domain (config, str); - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_DOMAINS, "as", &iter)) { - while (g_variant_iter_next (iter, "&s", &str)) - nm_ip6_config_add_domain (config, str); - g_variant_iter_free (iter); - } - - route_metric = nm_vpn_connection_get_ip6_route_metric (self); - - if ( g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES, "b", &b) - && b) { - if (priv->ip6_config) { - n = nm_ip6_config_get_num_routes (priv->ip6_config); - for (i = 0; i < n; i++) - nm_ip6_config_add_route (config, nm_ip6_config_get_route (priv->ip6_config, i)); - } - } else if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_ROUTES, "a(ayuayu)", &iter)) { - GVariant *dest, *next_hop; - guint32 prefix, metric; - - while (g_variant_iter_next (iter, "(@ayu@ayu)", &dest, &prefix, &next_hop, &metric)) { - NMPlatformIP6Route route; - - memset (&route, 0, sizeof (route)); - - if (!ip6_addr_from_variant (dest, &route.network)) - goto next; - - if (prefix > 128 || prefix == 0) - goto next; - - route.plen = prefix; - ip6_addr_from_variant (next_hop, &route.gateway); - route.metric = route_metric; - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - - /* Ignore host routes to the VPN gateway since NM adds one itself. - * Since NM knows more about the routing situation than the VPN - * server, we want to use the NM created route instead of whatever - * the server provides. - */ - if (!(priv->ip6_external_gw && IN6_ARE_ADDR_EQUAL (&route.network, priv->ip6_external_gw) && route.plen == 128)) - nm_ip6_config_add_route (config, &route); - -next: - g_variant_unref (dest); - g_variant_unref (next_hop); - } - g_variant_iter_free (iter); - } - - if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_NEVER_DEFAULT, "b", &b)) - nm_ip6_config_set_never_default (config, b); - - /* Merge in user overrides from the NMConnection's IPv6 setting */ - nm_ip6_config_merge_setting (config, - nm_connection_get_setting_ip6_config (_get_applied_connection (self)), - route_metric); - - if (priv->ip6_config) { - nm_ip6_config_replace (priv->ip6_config, config, NULL); - g_object_unref (config); - } else { - priv->ip6_config = config; - nm_exported_object_export (NM_EXPORTED_OBJECT (config)); - g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP6_CONFIG); - } - - nm_vpn_connection_config_maybe_complete (self, TRUE); -} - -static gboolean -connect_timeout_cb (gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - priv->connect_timeout = 0; - - /* Cancel activation if it's taken too long */ - if (priv->vpn_state == STATE_CONNECT || - priv->vpn_state == STATE_IP_CONFIG_GET) { - _LOGW ("VPN connection: connect timeout exceeded."); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, FALSE); - } - - return FALSE; -} - -static void -connect_success (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - NMSettingVpn *s_vpn; - guint32 timeout; - - s_vpn = nm_connection_get_setting_vpn (_get_applied_connection (self)); - g_assert (s_vpn); - - /* Timeout waiting for IP config signal from VPN service - * It is a configured value or 60 seconds */ - timeout = nm_setting_vpn_get_timeout (s_vpn); - if (timeout == 0) { - char *value; - - value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, - "vpn.timeout", NULL); - timeout = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, 60); - timeout = timeout == 0 ? 60 : timeout; - g_free (value); - } - priv->connect_timeout = g_timeout_add_seconds (timeout, connect_timeout_cb, self); - - g_clear_pointer (&priv->connect_hash, g_variant_unref); -} - -static void -connect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection *self; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_VPN_CONNECTION (user_data); - - if (error) { - g_dbus_error_strip_remote_error (error); - _LOGW ("VPN connection: failed to connect: '%s'", - error->message); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, FALSE); - } else - connect_success (self); -} - -static void -connect_interactive_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection *self; - NMVpnConnectionPrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_VPN_CONNECTION (user_data); - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - _LOGI ("VPN connection: (ConnectInteractive) reply received"); - - if (g_error_matches (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED)) { - _LOGD ("VPN connection: falling back to non-interactive connect"); - - /* Fall back to Connect() */ - g_dbus_proxy_call (priv->proxy, - "Connect", - g_variant_new ("(@a{sa{sv}})", priv->connect_hash), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) connect_cb, - self); - } else if (error) { - g_dbus_error_strip_remote_error (error); - _LOGW ("VPN connection: failed to connect interactively: '%s'", - error->message); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, FALSE); - } else - connect_success (self); -} - -/* Add a username to a hashed connection */ -static GVariant * -_hash_with_username (NMConnection *connection, const char *username) -{ - gs_unref_object NMConnection *dup = NULL; - NMSettingVpn *s_vpn; - - /* Shortcut if we weren't given a username or if there already was one in - * the VPN setting; don't bother duplicating the connection and everything. - */ - s_vpn = nm_connection_get_setting_vpn (connection); - g_assert (s_vpn); - if (username == NULL || nm_setting_vpn_get_user_name (s_vpn)) - return nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL); - - dup = nm_simple_connection_new_clone (connection); - g_assert (dup); - s_vpn = nm_connection_get_setting_vpn (dup); - g_assert (s_vpn); - g_object_set (s_vpn, NM_SETTING_VPN_USER_NAME, username, NULL); - return nm_connection_to_dbus (dup, NM_CONNECTION_SERIALIZE_ALL); -} - -static void -really_activate (NMVpnConnection *self, const char *username) -{ - NMVpnConnectionPrivate *priv; - GVariantBuilder details; - - g_return_if_fail (NM_IS_VPN_CONNECTION (self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - g_return_if_fail (priv->vpn_state == STATE_NEED_AUTH); - - g_clear_pointer (&priv->connect_hash, g_variant_unref); - priv->connect_hash = _hash_with_username (_get_applied_connection (self), username); - g_variant_ref_sink (priv->connect_hash); - - /* If at least one agent doesn't support VPN hints, then we can't use - * ConnectInteractive(), because that agent won't be able to pass hints - * from the VPN plugin's interactive secrets requests to the VPN authentication - * dialog and we won't get the secrets we need. In this case fall back to - * the old Connect() call. - */ - if (nm_agent_manager_all_agents_have_capability (nm_agent_manager_get (), - nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (self)), - NM_SECRET_AGENT_CAPABILITY_VPN_HINTS)) { - _LOGD ("Allowing interactive secrets as all agents have that capability"); - - g_variant_builder_init (&details, G_VARIANT_TYPE_VARDICT); - g_dbus_proxy_call (priv->proxy, - "ConnectInteractive", - g_variant_new ("(@a{sa{sv}}a{sv})", priv->connect_hash, &details), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) connect_interactive_cb, - self); - } else { - _LOGD ("Calling old Connect function as not all agents support interactive secrets"); - g_dbus_proxy_call (priv->proxy, - "Connect", - g_variant_new ("(@a{sa{sv}})", priv->connect_hash), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) connect_cb, - self); - } - - _set_vpn_state (self, STATE_CONNECT, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); -} - -static void -failure_cb (GDBusProxy *proxy, - guint32 reason, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - - plugin_failed (self, reason); -} - -static void -state_changed_cb (GDBusProxy *proxy, - guint32 new_service_state, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - - plugin_state_changed (self, new_service_state); -} - -static void -secrets_required_cb (GDBusProxy *proxy, - const char *message, - const char **secrets, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - - plugin_interactive_secrets_required (self, message, secrets); -} - -static void -config_cb (GDBusProxy *proxy, - GVariant *dict, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - /* Only list to this signals during and after connection */ - if (priv->vpn_state >= STATE_NEED_AUTH) - nm_vpn_connection_config_get (self, dict); -} - -static void -ip4_config_cb (GDBusProxy *proxy, - GVariant *dict, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - /* Only list to this signals during and after connection */ - if (priv->vpn_state >= STATE_NEED_AUTH) - nm_vpn_connection_ip4_config_get (self, dict); -} - -static void -ip6_config_cb (GDBusProxy *proxy, - GVariant *dict, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - /* Only list to this signals during and after connection */ - if (priv->vpn_state >= STATE_NEED_AUTH) - nm_vpn_connection_ip6_config_get (self, dict); -} - -static void -_name_owner_changed (GObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - char *owner; - - owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object)); - - if (owner && !priv->service_running) { - /* service appeared */ - priv->service_running = TRUE; - _LOGI ("Saw the service appear; activating connection"); - - /* No need to wait for the timeout any longer */ - nm_clear_g_source (&priv->start_timeout); - - /* Expect success because the VPN service has already appeared */ - _nm_dbus_signal_connect (priv->proxy, "Failure", G_VARIANT_TYPE ("(u)"), - G_CALLBACK (failure_cb), self); - _nm_dbus_signal_connect (priv->proxy, "StateChanged", G_VARIANT_TYPE ("(u)"), - G_CALLBACK (state_changed_cb), self); - _nm_dbus_signal_connect (priv->proxy, "SecretsRequired", G_VARIANT_TYPE ("(sas)"), - G_CALLBACK (secrets_required_cb), self); - _nm_dbus_signal_connect (priv->proxy, "Config", G_VARIANT_TYPE ("(a{sv})"), - G_CALLBACK (config_cb), self); - _nm_dbus_signal_connect (priv->proxy, "Ip4Config", G_VARIANT_TYPE ("(a{sv})"), - G_CALLBACK (ip4_config_cb), self); - _nm_dbus_signal_connect (priv->proxy, "Ip6Config", G_VARIANT_TYPE ("(a{sv})"), - G_CALLBACK (ip6_config_cb), self); - - _set_vpn_state (self, STATE_NEED_AUTH, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); - - /* Kick off the secrets requests; first we get existing system secrets - * and ask the plugin if these are sufficient, next we get all existing - * secrets from system and from user agents and ask the plugin again, - * and last we ask the user for new secrets if required. - */ - get_secrets (self, SECRETS_REQ_SYSTEM, NULL); - } else if (!owner && priv->service_running) { - /* service went away */ - priv->service_running = FALSE; - _LOGI ("VPN service disappeared"); - nm_vpn_connection_disconnect (self, NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED, FALSE); - } - - g_free (owner); -} - - -static gboolean -_daemon_exec_timeout (gpointer data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (data); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - _LOGW ("Timed out waiting for the service to start"); - priv->start_timeout = 0; - nm_vpn_connection_disconnect (self, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT, FALSE); - return G_SOURCE_REMOVE; -} - -static int -_get_log_level (void) -{ - NMLogLevel level; - - /* curiously enough, nm-logging also uses syslog. But it - * maps NMLogLevel differently to the syslog levels then we - * do here. - * - * The reason is, that LOG_NOTICE is already something worth - * highlighting in the journal, but we have 3 levels that are - * lower then LOG_NOTICE (LOGL_TRACE, LOGL_DEBUG, LOGL_INFO), - * On the other hand, syslog only defines LOG_DEBUG and LOG_INFO. - * Thus, we must map them differently. - * - * Inside the VPN plugin, you might want to treat LOG_NOTICE as - * as low severity, not worthy to be highlighted (like NM does). */ - - level = nm_logging_get_level (LOGD_VPN_PLUGIN); - if (level != _LOGL_OFF) { - if (level <= LOGL_TRACE) - return LOG_DEBUG; - if (level <= LOGL_DEBUG) - return LOG_INFO; - if (level <= LOGL_INFO) - return LOG_NOTICE; - if (level <= LOGL_WARN) - return LOG_WARNING; - if (level <= LOGL_ERR) - return LOG_ERR; - } - - return LOG_EMERG; -} - -static gboolean -nm_vpn_service_daemon_exec (NMVpnConnection *self, GError **error) -{ - NMVpnConnectionPrivate *priv; - GPid pid; - char *vpn_argv[4]; - gboolean success = FALSE; - GError *spawn_error = NULL; - guint i, j, n_environ; - gs_free char **envp = NULL; - char env_log_level[NM_STRLEN ("NM_VPN_LOG_LEVEL=") + 100]; - char env_log_syslog[NM_STRLEN ("NM_VPN_LOG_SYSLOG=") + 10]; - const int N_ENVIRON_EXTRA = 3; - char **p_environ; - - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), FALSE); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - i = 0; - vpn_argv[i++] = (char *) nm_vpn_plugin_info_get_program (priv->plugin_info); - g_return_val_if_fail (vpn_argv[0], FALSE); - if (nm_vpn_plugin_info_supports_multiple (priv->plugin_info)) { - vpn_argv[i++] = "--bus-name"; - vpn_argv[i++] = priv->bus_name; - } - vpn_argv[i++] = NULL; - - /* we include and "config.h" defines _GNU_SOURCE for us. So, we have @environ. */ - p_environ = environ; - n_environ = p_environ ? g_strv_length (p_environ) : 0; - envp = g_new (char *, n_environ + N_ENVIRON_EXTRA); - for (i = 0, j = 0; j < n_environ; j++) { - if ( g_str_has_prefix (p_environ[j], "NM_VPN_LOG_LEVEL=") - || g_str_has_prefix (p_environ[j], "NM_VPN_LOG_SYSLOG=")) - continue; - envp[i++] = p_environ[j]; - } - - /* NM_VPN_LOG_LEVEL: the syslog logging level for the plugin. */ - envp[i++] = nm_sprintf_buf (env_log_level, "NM_VPN_LOG_LEVEL=%d", _get_log_level ()); - - /* NM_VPN_LOG_SYSLOG: whether to log to stdout or syslog. If NetworkManager itself runs in - * foreground, we also want the plugin to log to stdout. - * If the plugin runs in background, the plugin should prefer logging to syslog. Otherwise - * logging messages will be lost (unless using journald, in which case it wouldn't matter). */ - envp[i++] = nm_sprintf_buf (env_log_syslog, "NM_VPN_LOG_SYSLOG=%c", nm_logging_syslog_enabled () ? '1' : '0'); - - envp[i++] = NULL; - nm_assert (i <= n_environ + N_ENVIRON_EXTRA); - - success = g_spawn_async (NULL, vpn_argv, envp, 0, nm_utils_setpgid, NULL, &pid, &spawn_error); - - if (success) { - _LOGI ("Started the VPN service, PID %ld", (long int) pid); - priv->start_timeout = g_timeout_add_seconds (5, _daemon_exec_timeout, self); - } else { - g_set_error (error, - NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, - "%s", spawn_error ? spawn_error->message : "unknown g_spawn_async() error"); - - if (spawn_error) - g_error_free (spawn_error); - } - - return success; -} - -static void -on_proxy_acquired (GObject *object, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection *self; - NMVpnConnectionPrivate *priv; - gs_free_error GError *error = NULL; - GDBusProxy *proxy; - - proxy = g_dbus_proxy_new_for_bus_finish (result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_VPN_CONNECTION (user_data); - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (error) { - _LOGE ("failed to acquire dbus proxy for VPN service: %s", - error->message); - _set_vpn_state (self, - STATE_FAILED, - NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, - FALSE); - return; - } - - priv->proxy = proxy; - - g_signal_connect (priv->proxy, "notify::g-name-owner", - G_CALLBACK (_name_owner_changed), self); - _name_owner_changed (G_OBJECT (priv->proxy), NULL, self); - - if (priv->service_running) - return; - - if (!nm_vpn_service_daemon_exec (self, &error)) { - _LOGW ("Could not launch the VPN service. error: %s.", - error->message); - - nm_vpn_connection_disconnect (self, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, FALSE); - } -} - -void -nm_vpn_connection_activate (NMVpnConnection *self, - NMVpnPluginInfo *plugin_info) -{ - NMVpnConnectionPrivate *priv; - NMSettingVpn *s_vpn; - const char *service; - - g_return_if_fail (NM_IS_VPN_CONNECTION (self)); - g_return_if_fail (NM_IS_VPN_PLUGIN_INFO (plugin_info)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - g_return_if_fail (!priv->plugin_info); - - s_vpn = nm_connection_get_setting_vpn (_get_applied_connection (self)); - g_return_if_fail (s_vpn); - - service = nm_vpn_plugin_info_get_service (plugin_info); - nm_assert (service); - - if (nm_vpn_plugin_info_supports_multiple (plugin_info)) { - const char *path; - - path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)); - if (path) - path = strrchr (path, '/'); - g_return_if_fail (path); - - priv->bus_name = g_strdup_printf ("%s.Connection_%s", service, &path[1]); - } else - priv->bus_name = g_strdup (service); - - priv->connection_can_persist = nm_setting_vpn_get_persistent (s_vpn); - priv->plugin_info = g_object_ref (plugin_info); - priv->cancellable = g_cancellable_new (); - - g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, - NULL, - priv->bus_name, - NM_VPN_DBUS_PLUGIN_PATH, - NM_VPN_DBUS_PLUGIN_INTERFACE, - priv->cancellable, - (GAsyncReadyCallback) on_proxy_acquired, - self); - - _set_vpn_state (self, STATE_PREPARE, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); -} - -NMVpnConnectionState -nm_vpn_connection_get_vpn_state (NMVpnConnection *self) -{ - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NM_VPN_CONNECTION_STATE_UNKNOWN); - - return _state_to_nm_vpn_state (NM_VPN_CONNECTION_GET_PRIVATE (self)->vpn_state); -} - -const char * -nm_vpn_connection_get_banner (NMVpnConnection *self) -{ - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); - - return NM_VPN_CONNECTION_GET_PRIVATE (self)->banner; -} - -NMIP4Config * -nm_vpn_connection_get_ip4_config (NMVpnConnection *self) -{ - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); - - return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip4_config; -} - -NMIP6Config * -nm_vpn_connection_get_ip6_config (NMVpnConnection *self) -{ - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); - - return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip6_config; -} - -static int -_get_ip_iface_for_device (NMVpnConnection *self, const char **out_iface) -{ - NMDevice *parent_dev; - int ifindex; - const char *iface; - - nm_assert (NM_IS_VPN_CONNECTION (self)); - - /* the ifindex and the ifname in this case should come together. - * They either must be both set, or none. */ - - parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (self)); - if (!parent_dev) - goto none; - ifindex = nm_device_get_ip_ifindex (parent_dev); - if (ifindex <= 0) - goto none; - iface = nm_device_get_ip_iface (parent_dev); - if (!iface) - goto none; - - NM_SET_OUT (out_iface, iface); - return ifindex; -none: - NM_SET_OUT (out_iface, NULL); - return 0; -} - -const char * -nm_vpn_connection_get_ip_iface (NMVpnConnection *self, gboolean fallback_device) -{ - NMVpnConnectionPrivate *priv; - const char *iface; - - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (priv->ip_iface || !fallback_device) - return priv->ip_iface; - - _get_ip_iface_for_device (self, &iface); - return iface; -} - -int -nm_vpn_connection_get_ip_ifindex (NMVpnConnection *self, gboolean fallback_device) -{ - NMVpnConnectionPrivate *priv; - - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), 0); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (priv->ip_ifindex > 0) - return priv->ip_ifindex; - if (!fallback_device) - return 0; - - return _get_ip_iface_for_device (self, NULL); -} - -guint32 -nm_vpn_connection_get_ip4_internal_gateway (NMVpnConnection *self) -{ - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), 0); - - return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip4_internal_gw; -} - -struct in6_addr * -nm_vpn_connection_get_ip6_internal_gateway (NMVpnConnection *self) -{ - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), 0); - - return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip6_internal_gw; -} - -void -nm_vpn_connection_disconnect (NMVpnConnection *self, - NMVpnConnectionStateReason reason, - gboolean quitting) -{ - g_return_if_fail (NM_IS_VPN_CONNECTION (self)); - - _set_vpn_state (self, STATE_DISCONNECTED, reason, quitting); -} - -gboolean -nm_vpn_connection_deactivate (NMVpnConnection *self, - NMVpnConnectionStateReason reason, - gboolean quitting) -{ - NMVpnConnectionPrivate *priv; - gboolean success = FALSE; - - g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), FALSE); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - if (priv->vpn_state > STATE_UNKNOWN && priv->vpn_state <= STATE_DEACTIVATING) { - _set_vpn_state (self, STATE_DEACTIVATING, reason, quitting); - success = TRUE; - } - return success; -} - -/******************************************************************************/ - -static void -plugin_need_secrets_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection *self; - NMVpnConnectionPrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - const char *setting_name; - - reply = _nm_dbus_proxy_call_finish (proxy, result, G_VARIANT_TYPE ("(s)"), &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_VPN_CONNECTION (user_data); - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (error) { - g_dbus_error_strip_remote_error (error); - _LOGE ("plugin NeedSecrets request #%d failed: %s", - priv->secrets_idx + 1, - error->message); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - return; - } - - g_variant_get (reply, "(&s)", &setting_name); - if (!strlen (setting_name)) { - _LOGD ("service indicated no additional secrets required"); - - /* No secrets required; we can start the VPN */ - really_activate (self, priv->username); - return; - } - - /* More secrets required */ - if (priv->secrets_idx == SECRETS_REQ_NEW) { - _LOGE ("final secrets request failed to provide sufficient secrets"); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - } else { - _LOGD ("service indicated additional secrets required"); - get_secrets (self, priv->secrets_idx + 1, NULL); - } -} - -static void -plugin_new_secrets_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) -{ - NMVpnConnection *self; - NMVpnConnectionPrivate *priv; - gs_unref_variant GVariant *reply = NULL; - gs_free_error GError *error = NULL; - - reply = g_dbus_proxy_call_finish (proxy, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - self = NM_VPN_CONNECTION (user_data); - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - if (error) { - g_dbus_error_strip_remote_error (error); - _LOGE ("sending new secrets to the plugin failed: %s", - error->message); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - } else - _set_vpn_state (self, STATE_CONNECT, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); -} - -static void -get_secrets_cb (NMSettingsConnection *connection, - NMSettingsConnectionCallId call_id, - const char *agent_username, - const char *setting_name, - GError *error, - gpointer user_data) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (user_data); - NMVpnConnectionPrivate *priv; - GVariant *dict; - - g_return_if_fail (NM_IS_VPN_CONNECTION (self)); - - priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - g_return_if_fail (connection && connection == _get_settings_connection (self, FALSE)); - g_return_if_fail (call_id == priv->secrets_id); - - priv->secrets_id = NULL; - - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - if (error && priv->secrets_idx >= SECRETS_REQ_NEW) { - _LOGE ("Failed to request VPN secrets #%d: %s", - priv->secrets_idx + 1, error->message); - _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); - return; - } - - /* Cache the username for later */ - if (agent_username) { - g_free (priv->username); - priv->username = g_strdup (agent_username); - } - - dict = _hash_with_username (_get_applied_connection (self), priv->username); - - if (priv->secrets_idx == SECRETS_REQ_INTERACTIVE) { - _LOGD ("sending secrets to the plugin"); - - /* Send the secrets back to the plugin */ - g_dbus_proxy_call (priv->proxy, - "NewSecrets", - g_variant_new ("(@a{sa{sv}})", dict), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) plugin_new_secrets_cb, - self); - } else { - _LOGD ("asking service if additional secrets are required"); - - /* Ask the VPN service if more secrets are required */ - g_dbus_proxy_call (priv->proxy, - "NeedSecrets", - g_variant_new ("(@a{sa{sv}})", dict), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->cancellable, - (GAsyncReadyCallback) plugin_need_secrets_cb, - self); - } -} - -static void -get_secrets (NMVpnConnection *self, - SecretsReq secrets_idx, - const char **hints) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; - - g_return_if_fail (secrets_idx < SECRETS_REQ_LAST); - priv->secrets_idx = secrets_idx; - - cancel_get_secrets (self); - - _LOGD ("requesting VPN secrets pass #%d", - priv->secrets_idx + 1); - - switch (priv->secrets_idx) { - case SECRETS_REQ_SYSTEM: - flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM; - break; - case SECRETS_REQ_EXISTING: - flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; - break; - case SECRETS_REQ_NEW: - case SECRETS_REQ_INTERACTIVE: - flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; - break; - default: - g_assert_not_reached (); - } - - if (nm_active_connection_get_user_requested (NM_ACTIVE_CONNECTION (self))) - flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED; - - priv->secrets_id = nm_settings_connection_get_secrets (_get_settings_connection (self, FALSE), - _get_applied_connection (self), - nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (self)), - NM_SETTING_VPN_SETTING_NAME, - flags, - hints, - get_secrets_cb, - self); - g_return_if_fail (priv->secrets_id); -} - -static void -plugin_interactive_secrets_required (NMVpnConnection *self, - const char *message, - const char **secrets) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - guint32 secrets_len = secrets ? g_strv_length ((char **) secrets) : 0; - char **hints; - guint32 i; - - _LOGI ("VPN plugin: requested secrets; state %s (%d)", - vpn_state_to_string (priv->vpn_state), priv->vpn_state); - - g_return_if_fail (priv->vpn_state == STATE_CONNECT || - priv->vpn_state == STATE_NEED_AUTH); - - priv->secrets_idx = SECRETS_REQ_INTERACTIVE; - _set_vpn_state (self, STATE_NEED_AUTH, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); - - /* Copy hints and add message to the end */ - hints = g_malloc0 (sizeof (char *) * (secrets_len + 2)); - for (i = 0; i < secrets_len; i++) - hints[i] = g_strdup (secrets[i]); - if (message) - hints[i] = g_strdup_printf ("x-vpn-message:%s", message); - - get_secrets (self, SECRETS_REQ_INTERACTIVE, (const char **) hints); - g_strfreev (hints); -} - -/******************************************************************************/ - -static void -device_changed (NMActiveConnection *active, - NMDevice *new_device, - NMDevice *old_device) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE ((NMVpnConnection *) active); - - if (!_service_and_connection_can_persist (NM_VPN_CONNECTION (active))) - return; - if (priv->vpn_state < STATE_CONNECT || priv->vpn_state > STATE_ACTIVATED) - return; - - /* Route-based VPNs must update their routing and send a new IP config - * since all their routes need to be adjusted for new_device. - */ - if (priv->ip_ifindex <= 0) - return; - - /* Device changed underneath the VPN connection. Let the plugin figure - * out that connectivity is down and start its reconnect attempt if it - * needs to. - */ - if (old_device) - remove_parent_device_config (NM_VPN_CONNECTION (active), old_device); - - if (new_device) - apply_parent_device_config (NM_VPN_CONNECTION (active)); -} - -/******************************************************************************/ - -static void -nm_vpn_connection_init (NMVpnConnection *self) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - priv->vpn_state = STATE_WAITING; - priv->secrets_idx = SECRETS_REQ_SYSTEM; - priv->default_route_manager = g_object_ref (nm_default_route_manager_get ()); - priv->route_manager = g_object_ref (nm_route_manager_get ()); -} - -static void -dispose (GObject *object) -{ - NMVpnConnection *self = NM_VPN_CONNECTION (object); - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - - nm_clear_g_source (&priv->start_timeout); - - g_clear_pointer (&priv->connect_hash, g_variant_unref); - - nm_clear_g_source (&priv->connect_timeout); - - dispatcher_cleanup (self); - - cancel_get_secrets (self); - - if (priv->cancellable) { - g_cancellable_cancel (priv->cancellable); - g_clear_object (&priv->cancellable); - } - nm_exported_object_clear_and_unexport (&priv->ip4_config); - nm_exported_object_clear_and_unexport (&priv->ip6_config); - g_clear_object (&priv->proxy); - g_clear_object (&priv->plugin_info); - - fw_call_cleanup (self); - - G_OBJECT_CLASS (nm_vpn_connection_parent_class)->dispose (object); - - g_clear_object (&priv->default_route_manager); - g_clear_object (&priv->route_manager); -} - -static void -finalize (GObject *object) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE ((NMVpnConnection *) object); - - g_free (priv->banner); - g_free (priv->ip_iface); - g_free (priv->username); - g_free (priv->ip6_internal_gw); - g_free (priv->ip6_external_gw); - - G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object); -} - -static gboolean -ip_config_valid (VpnState state) -{ - return (state == STATE_PRE_UP || state == STATE_ACTIVATED); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE ((NMVpnConnection *) object); - NMDevice *parent_dev; - - switch (prop_id) { - case PROP_VPN_STATE: - g_value_set_uint (value, _state_to_nm_vpn_state (priv->vpn_state)); - break; - case PROP_BANNER: - g_value_set_string (value, priv->banner ? priv->banner : ""); - break; - case PROP_IP4_CONFIG: - nm_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip4_config : NULL); - break; - case PROP_IP6_CONFIG: - nm_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip6_config : NULL); - break; - case PROP_MASTER: - parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object)); - nm_utils_g_value_set_object_path (value, parent_dev); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (connection_class); - NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS (connection_class); - - /* virtual methods */ - object_class->get_property = get_property; - object_class->dispose = dispose; - object_class->finalize = finalize; - active_class->device_state_changed = device_state_changed; - active_class->device_changed = device_changed; - - obj_properties[PROP_VPN_STATE] = - g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE, "", "", - NM_VPN_CONNECTION_STATE_UNKNOWN, - NM_VPN_CONNECTION_STATE_DISCONNECTED, - NM_VPN_CONNECTION_STATE_UNKNOWN, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - - obj_properties[PROP_BANNER] = - g_param_spec_string (NM_VPN_CONNECTION_BANNER, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - - g_object_class_override_property (object_class, PROP_MASTER, - NM_ACTIVE_CONNECTION_MASTER); - g_object_class_override_property (object_class, PROP_IP4_CONFIG, - NM_ACTIVE_CONNECTION_IP4_CONFIG); - g_object_class_override_property (object_class, PROP_IP6_CONFIG, - NM_ACTIVE_CONNECTION_IP6_CONFIG); - - signals[VPN_STATE_CHANGED] = - g_signal_new ("vpn-state-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - - signals[INTERNAL_STATE_CHANGED] = - g_signal_new (NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, NULL, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); - - signals[INTERNAL_RETRY_AFTER_FAILURE] = - g_signal_new (NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, NULL, - G_TYPE_NONE, 0); - - nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (connection_class), - NMDBUS_TYPE_VPN_CONNECTION_SKELETON, - NULL); -} diff --git a/src/vpn-manager/nm-vpn-connection.h b/src/vpn-manager/nm-vpn-connection.h deleted file mode 100644 index 3fe56054..00000000 --- a/src/vpn-manager/nm-vpn-connection.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2011 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#ifndef __NETWORKMANAGER_VPN_CONNECTION_H__ -#define __NETWORKMANAGER_VPN_CONNECTION_H__ - -#include "nm-vpn-dbus-interface.h" -#include "nm-device.h" -#include "nm-auth-subject.h" -#include "nm-active-connection.h" -#include "nm-vpn-plugin-info.h" - -#define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ()) -#define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVpnConnection)) -#define NM_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_CONNECTION, NMVpnConnectionClass)) -#define NM_IS_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_CONNECTION)) -#define NM_IS_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_CONNECTION)) -#define NM_VPN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION, NMVpnConnectionClass)) - -/* Properties */ -#define NM_VPN_CONNECTION_VPN_STATE "vpn-state" -#define NM_VPN_CONNECTION_BANNER "banner" - -/* Signals */ -/* not exported: includes old reason code */ -#define NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED "internal-state-changed" -#define NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE "internal-retry-after-failure" - - -#define NM_VPN_ROUTE_METRIC_DEFAULT 50 - -typedef struct _NMVpnConnectionClass NMVpnConnectionClass; - -GType nm_vpn_connection_get_type (void); - -NMVpnConnection * nm_vpn_connection_new (NMSettingsConnection *settings_connection, - NMDevice *parent_device, - const char *specific_object, - NMAuthSubject *subject); - -void nm_vpn_connection_activate (NMVpnConnection *self, - NMVpnPluginInfo *plugin_info); -NMVpnConnectionState nm_vpn_connection_get_vpn_state (NMVpnConnection *self); -const char * nm_vpn_connection_get_banner (NMVpnConnection *self); -const gchar * nm_vpn_connection_get_service (NMVpnConnection *self); - -gboolean nm_vpn_connection_deactivate (NMVpnConnection *self, - NMVpnConnectionStateReason reason, - gboolean quitting); -void nm_vpn_connection_disconnect (NMVpnConnection *self, - NMVpnConnectionStateReason reason, - gboolean quitting); - -NMIP4Config * nm_vpn_connection_get_ip4_config (NMVpnConnection *self); -NMIP6Config * nm_vpn_connection_get_ip6_config (NMVpnConnection *self); -const char * nm_vpn_connection_get_ip_iface (NMVpnConnection *self, gboolean fallback_device); -int nm_vpn_connection_get_ip_ifindex (NMVpnConnection *self, gboolean fallback_device); -guint32 nm_vpn_connection_get_ip4_internal_gateway (NMVpnConnection *self); -struct in6_addr * nm_vpn_connection_get_ip6_internal_gateway (NMVpnConnection *self); - -guint32 nm_vpn_connection_get_ip4_route_metric (NMVpnConnection *self); -guint32 nm_vpn_connection_get_ip6_route_metric (NMVpnConnection *self); - -#endif /* __NETWORKMANAGER_VPN_CONNECTION_H__ */ diff --git a/src/vpn-manager/nm-vpn-manager.c b/src/vpn-manager/nm-vpn-manager.c deleted file mode 100644 index 6dcd5463..00000000 --- a/src/vpn-manager/nm-vpn-manager.c +++ /dev/null @@ -1,289 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2012 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#include "nm-default.h" - -#include - -#include "nm-vpn-manager.h" -#include "nm-vpn-plugin-info.h" -#include "nm-vpn-connection.h" -#include "nm-setting-vpn.h" -#include "nm-vpn-dbus-interface.h" -#include "nm-core-internal.h" -#include "nm-enum-types.h" - -G_DEFINE_TYPE (NMVpnManager, nm_vpn_manager, G_TYPE_OBJECT) - -#define NM_VPN_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_MANAGER, NMVpnManagerPrivate)) - -typedef struct { - GSList *plugins; - GFileMonitor *monitor_etc; - GFileMonitor *monitor_lib; - gulong monitor_id_etc; - gulong monitor_id_lib; - - /* This is only used for services that don't support multiple - * connections, to guard access to them. */ - GHashTable *active_services; -} NMVpnManagerPrivate; - -/******************************************************************************/ - -static void -vpn_state_changed (NMVpnConnection *vpn, - GParamSpec *pspec, - NMVpnManager *manager) -{ - NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (manager); - NMActiveConnectionState state = nm_active_connection_get_state (NM_ACTIVE_CONNECTION (vpn)); - const char *service_name = nm_vpn_connection_get_service (vpn); - - if (state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { - g_hash_table_remove (priv->active_services, service_name); - g_signal_handlers_disconnect_by_func (vpn, vpn_state_changed, manager); - g_object_unref (manager); - } -} - -gboolean -nm_vpn_manager_activate_connection (NMVpnManager *manager, - NMVpnConnection *vpn, - GError **error) -{ - NMVpnManagerPrivate *priv; - NMVpnPluginInfo *plugin_info; - const char *service_name; - NMDevice *device; - - g_return_val_if_fail (NM_IS_VPN_MANAGER (manager), FALSE); - g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), FALSE); - g_return_val_if_fail (!error || !*error, FALSE); - - priv = NM_VPN_MANAGER_GET_PRIVATE (manager); - device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (vpn)); - g_assert (device); - if ( nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED - && nm_device_get_state (device) != NM_DEVICE_STATE_SECONDARIES) { - g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_DEPENDENCY_FAILED, - "The base device for the VPN connection was not active."); - return FALSE; - } - - service_name = nm_vpn_connection_get_service (vpn); - - plugin_info = nm_vpn_plugin_info_list_find_by_service (priv->plugins, service_name); - if (!plugin_info) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, - "The VPN service '%s' was not installed.", - service_name); - return FALSE; - } - - if ( !nm_vpn_plugin_info_supports_multiple (plugin_info) - && g_hash_table_contains (priv->active_services, service_name)) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, - "The '%s' plugin only supports a single active connection.", - nm_vpn_plugin_info_get_name (plugin_info)); - return FALSE; - } - - nm_vpn_connection_activate (vpn, plugin_info); - - if (!nm_vpn_plugin_info_supports_multiple (plugin_info)) { - /* Block activations of the connections of the same service type. */ - g_hash_table_add (priv->active_services, g_strdup (service_name)); - g_signal_connect (vpn, "notify::" NM_ACTIVE_CONNECTION_STATE, - G_CALLBACK (vpn_state_changed), - g_object_ref (manager)); - } - - return TRUE; -} - -/******************************************************************************/ - -static void -try_add_plugin (NMVpnManager *self, NMVpnPluginInfo *plugin_info) -{ - NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); - const char *program; - - program = nm_vpn_plugin_info_get_program (plugin_info); - if (!program || !*program) - return; - - /* Make sure we don't add dupes. - * We don't really allow reload of the same file. What we do allow is however to - * delete a file and re-add it. */ - if (nm_vpn_plugin_info_list_find_by_filename (priv->plugins, - nm_vpn_plugin_info_get_filename (plugin_info))) - return; - if (!nm_vpn_plugin_info_list_add (&priv->plugins, plugin_info, NULL)) - return; -} - -static void -vpn_dir_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) -{ - NMVpnManager *self = NM_VPN_MANAGER (user_data); - NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); - NMVpnPluginInfo *plugin_info; - gs_free char *path = NULL; - GError *error = NULL; - - path = g_file_get_path (file); - if (!nm_vpn_plugin_info_validate_filename (path)) - return; - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - plugin_info = nm_vpn_plugin_info_list_find_by_filename (priv->plugins, path); - if (!plugin_info) - break; - - nm_log_dbg (LOGD_VPN, "vpn: service file %s deleted", path); - nm_vpn_plugin_info_list_remove (&priv->plugins, plugin_info); - break; - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - plugin_info = nm_vpn_plugin_info_list_find_by_filename (priv->plugins, path); - if (plugin_info) { - /* we don't support reloading an existing plugin. You can only remove the file - * and re-add it. By reloading we want to support the use case of installing - * a VPN plugin after NM started. No need to burden ourself with a complete - * reload. */ - break; - } - - if (!_nm_vpn_plugin_info_check_file (path, TRUE, TRUE, 0, - NULL, NULL, &error)) { - nm_log_dbg (LOGD_VPN, "vpn: ignore changed service file %s (%s)", path, error->message); - g_clear_error (&error); - break; - } - plugin_info = nm_vpn_plugin_info_new_from_file (path, &error); - if (!plugin_info) { - nm_log_dbg (LOGD_VPN, "vpn: ignore changed service file %s due to invalid content (%s)", path, error->message); - g_clear_error (&error); - break; - } - - nm_log_dbg (LOGD_VPN, "vpn: service file %s created or modified", path); - try_add_plugin (self, plugin_info); - g_object_unref (plugin_info); - break; - default: - nm_log_dbg (LOGD_VPN, "vpn: service file %s change event %d", path, event_type); - break; - } -} - -/******************************************************************************/ - -NM_DEFINE_SINGLETON_GETTER (NMVpnManager, nm_vpn_manager_get, NM_TYPE_VPN_MANAGER); - -static void -nm_vpn_manager_init (NMVpnManager *self) -{ - NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); - GFile *file; - GSList *infos, *info; - const char *conf_dir_etc = _nm_vpn_plugin_info_get_default_dir_etc (); - const char *conf_dir_lib = _nm_vpn_plugin_info_get_default_dir_lib (); - - /* Watch the VPN directory for changes */ - file = g_file_new_for_path (conf_dir_lib); - priv->monitor_lib = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - if (priv->monitor_lib) { - priv->monitor_id_lib = g_signal_connect (priv->monitor_lib, "changed", - G_CALLBACK (vpn_dir_changed), self); - } - - file = g_file_new_for_path (conf_dir_etc); - priv->monitor_etc = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - if (priv->monitor_etc) { - priv->monitor_id_etc = g_signal_connect (priv->monitor_etc, "changed", - G_CALLBACK (vpn_dir_changed), self); - } - - /* first read conf_dir_lib. The name files are not really user configuration, but - * plugin configuration. Hence we expect ~newer~ plugins to install their files - * in /usr/lib/NetworkManager. We want to prefer those files. - * In case of no-conflict, the order doesn't matter. */ - infos = _nm_vpn_plugin_info_list_load_dir (conf_dir_lib, TRUE, 0, NULL, NULL); - for (info = infos; info; info = info->next) - try_add_plugin (self, info->data); - g_slist_free_full (infos, g_object_unref); - - infos = _nm_vpn_plugin_info_list_load_dir (conf_dir_etc, TRUE, 0, NULL, NULL); - for (info = infos; info; info = info->next) - try_add_plugin (self, info->data); - g_slist_free_full (infos, g_object_unref); - - priv->active_services = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); -} - -static void -dispose (GObject *object) -{ - NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (object); - - if (priv->monitor_etc) { - if (priv->monitor_id_etc) - g_signal_handler_disconnect (priv->monitor_etc, priv->monitor_id_etc); - g_file_monitor_cancel (priv->monitor_etc); - g_clear_object (&priv->monitor_etc); - } - - if (priv->monitor_lib) { - if (priv->monitor_id_lib) - g_signal_handler_disconnect (priv->monitor_lib, priv->monitor_id_lib); - g_file_monitor_cancel (priv->monitor_lib); - g_clear_object (&priv->monitor_lib); - } - - while (priv->plugins) - nm_vpn_plugin_info_list_remove (&priv->plugins, priv->plugins->data); - - g_hash_table_unref (priv->active_services); - - G_OBJECT_CLASS (nm_vpn_manager_parent_class)->dispose (object); -} - -static void -nm_vpn_manager_class_init (NMVpnManagerClass *manager_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (manager_class); - - g_type_class_add_private (manager_class, sizeof (NMVpnManagerPrivate)); - - /* virtual methods */ - object_class->dispose = dispose; -} - diff --git a/src/vpn-manager/nm-vpn-manager.h b/src/vpn-manager/nm-vpn-manager.h deleted file mode 100644 index 9ccd882d..00000000 --- a/src/vpn-manager/nm-vpn-manager.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2011 Red Hat, Inc. - * Copyright (C) 2006 - 2008 Novell, Inc. - */ - -#ifndef __NETWORKMANAGER_VPN_MANAGER_H__ -#define __NETWORKMANAGER_VPN_MANAGER_H__ - -#include "nm-vpn-connection.h" - -#define NM_TYPE_VPN_MANAGER (nm_vpn_manager_get_type ()) -#define NM_VPN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_MANAGER, NMVpnManager)) -#define NM_VPN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_MANAGER, NMVpnManagerClass)) -#define NM_IS_VPN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_MANAGER)) -#define NM_IS_VPN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_MANAGER)) -#define NM_VPN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_MANAGER, NMVpnManagerClass)) - -typedef struct { - GObject parent; -} NMVpnManager; - -typedef struct { - GObjectClass parent; -} NMVpnManagerClass; - -GType nm_vpn_manager_get_type (void); - -NMVpnManager *nm_vpn_manager_get (void); - -gboolean nm_vpn_manager_activate_connection (NMVpnManager *manager, - NMVpnConnection *vpn, - GError **error); - -#endif /* __NETWORKMANAGER_VPN_MANAGER_H__ */ diff --git a/src/vpn/nm-vpn-connection.c b/src/vpn/nm-vpn-connection.c new file mode 100644 index 00000000..fb9aae8a --- /dev/null +++ b/src/vpn/nm-vpn-connection.c @@ -0,0 +1,2778 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2013 Red Hat, Inc. + * Copyright (C) 2006 - 2008 Novell, Inc. + */ + +#include "nm-default.h" + +#include "nm-vpn-connection.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nm-proxy-config.h" +#include "nm-ip4-config.h" +#include "nm-ip6-config.h" +#include "platform/nm-platform.h" +#include "nm-active-connection.h" +#include "NetworkManagerUtils.h" +#include "settings/nm-settings-connection.h" +#include "nm-dispatcher.h" +#include "settings/nm-agent-manager.h" +#include "nm-core-internal.h" +#include "nm-pacrunner-manager.h" +#include "nm-default-route-manager.h" +#include "nm-route-manager.h" +#include "nm-firewall-manager.h" +#include "nm-config.h" +#include "nm-vpn-plugin-info.h" +#include "nm-vpn-manager.h" +#include "dns/nm-dns-manager.h" + +#include "introspection/org.freedesktop.NetworkManager.VPN.Connection.h" + +typedef enum { + /* Only system secrets */ + SECRETS_REQ_SYSTEM = 0, + /* All existing secrets including agent secrets */ + SECRETS_REQ_EXISTING = 1, + /* New secrets required; ask an agent */ + SECRETS_REQ_NEW = 2, + /* Plugin requests secrets interactively */ + SECRETS_REQ_INTERACTIVE = 3, + /* Placeholder for bounds checking */ + SECRETS_REQ_LAST +} SecretsReq; + +/* Internal VPN states, private to NMVpnConnection */ +typedef enum { + STATE_UNKNOWN = 0, + STATE_WAITING, + STATE_PREPARE, + STATE_NEED_AUTH, + STATE_CONNECT, + STATE_IP_CONFIG_GET, + STATE_PRE_UP, + STATE_ACTIVATED, + STATE_DEACTIVATING, + STATE_DISCONNECTED, + STATE_FAILED, +} VpnState; + +enum { + VPN_STATE_CHANGED, + INTERNAL_STATE_CHANGED, + INTERNAL_RETRY_AFTER_FAILURE, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +NM_GOBJECT_PROPERTIES_DEFINE (NMVpnConnection, + PROP_VPN_STATE, + PROP_BANNER, +#define PROP_IP4_CONFIG 2000 +#define PROP_IP6_CONFIG 2001 +#define PROP_MASTER 2002 +); + +typedef struct { + gboolean service_can_persist; + gboolean connection_can_persist; + + NMSettingsConnectionCallId secrets_id; + SecretsReq secrets_idx; + char *username; + + VpnState vpn_state; + guint dispatcher_id; + NMVpnConnectionStateReason failure_reason; + + NMVpnServiceState service_state; + guint start_timeout; + gboolean service_running; + NMVpnPluginInfo *plugin_info; + char *bus_name; + + /* Firewall */ + NMFirewallManagerCallId fw_call; + + NMDefaultRouteManager *default_route_manager; + NMRouteManager *route_manager; + GDBusProxy *proxy; + GCancellable *cancellable; + GVariant *connect_hash; + guint connect_timeout; + NMProxyConfig *proxy_config; + gboolean has_ip4; + NMIP4Config *ip4_config; + guint32 ip4_internal_gw; + guint32 ip4_external_gw; + gboolean has_ip6; + NMIP6Config *ip6_config; + + /* These config instances are passed on to NMDevice and modified by NMDevice. + * This pointer is only useful for nm_device_replace_vpn4_config() to clear the + * previous configuration. Consider these instances to be owned by NMDevice. */ + NMIP4Config *last_device_ip4_config; + NMIP6Config *last_device_ip6_config; + + struct in6_addr *ip6_internal_gw; + struct in6_addr *ip6_external_gw; + char *ip_iface; + int ip_ifindex; + char *banner; + guint32 mtu; +} NMVpnConnectionPrivate; + +struct _NMVpnConnection { + NMActiveConnection parent; + NMVpnConnectionPrivate _priv; +}; + +struct _NMVpnConnectionClass { + NMActiveConnectionClass parent; + + /* Signals */ + void (*vpn_state_changed) (NMVpnConnection *self, + NMVpnConnectionState new_state, + NMVpnConnectionStateReason reason); + + /* not exported over D-Bus */ + void (*internal_state_changed) (NMVpnConnection *self, + NMVpnConnectionState new_state, + NMVpnConnectionState old_state, + NMVpnConnectionStateReason reason); + + void (*internal_failed_retry) (NMVpnConnection *self); +}; + +G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION) + +#define NM_VPN_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMVpnConnection, NM_IS_VPN_CONNECTION) + +/*****************************************************************************/ + +static NMSettingsConnection *_get_settings_connection (NMVpnConnection *self, + gboolean allow_missing); + +static void get_secrets (NMVpnConnection *self, + SecretsReq secrets_idx, + const char **hints); + +static void plugin_interactive_secrets_required (NMVpnConnection *self, + const char *message, + const char **secrets); + +static void _set_vpn_state (NMVpnConnection *self, + VpnState vpn_state, + NMVpnConnectionStateReason reason, + gboolean quitting); + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_VPN +#define _NMLOG_PREFIX_NAME "vpn-connection" + +#define __NMLOG_prefix_buf_len 128 + +static const char * +__LOG_create_prefix (char *buf, NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv; + NMConnection *con; + const char *id; + + if (!self) + return _NMLOG_PREFIX_NAME; + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + con = NM_CONNECTION (_get_settings_connection (self, TRUE)); + id = con ? nm_connection_get_id (con) : NULL; + + g_snprintf (buf, __NMLOG_prefix_buf_len, + "%s[" + "%p" /*self*/ + "%s%s" /*con-uuid*/ + "%s%s%s%s" /*con-id*/ + ",%d" /*ifindex*/ + "%s%s%s" /*iface*/ + "]", + _NMLOG_PREFIX_NAME, + self, + con ? "," : "--", con ? (nm_connection_get_uuid (con) ?: "??") : "", + con ? "," : "", NM_PRINT_FMT_QUOTED (id, "\"", id, "\"", con ? "??" : ""), + priv->ip_ifindex, + NM_PRINT_FMT_QUOTED (priv->ip_iface, ":(", priv->ip_iface, ")", "") + ); + + return buf; +} + +#define _NMLOG(level, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + \ + if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ + char __prefix[__NMLOG_prefix_buf_len]; \ + \ + _nm_log (__level, _NMLOG_DOMAIN, 0, \ + "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + __LOG_create_prefix (__prefix, self) \ + _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END + +/*****************************************************************************/ + +static void +cancel_get_secrets (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (priv->secrets_id) { + nm_settings_connection_cancel_secrets (_get_settings_connection (self, FALSE), + priv->secrets_id); + g_warn_if_fail (!priv->secrets_id); + priv->secrets_id = NULL; + } +} + +static NMVpnConnectionState +_state_to_nm_vpn_state (VpnState state) +{ + switch (state) { + case STATE_WAITING: + case STATE_PREPARE: + return NM_VPN_CONNECTION_STATE_PREPARE; + case STATE_NEED_AUTH: + return NM_VPN_CONNECTION_STATE_NEED_AUTH; + case STATE_CONNECT: + return NM_VPN_CONNECTION_STATE_CONNECT; + case STATE_IP_CONFIG_GET: + case STATE_PRE_UP: + return NM_VPN_CONNECTION_STATE_IP_CONFIG_GET; + case STATE_ACTIVATED: + return NM_VPN_CONNECTION_STATE_ACTIVATED; + case STATE_DEACTIVATING: { + /* Map DEACTIVATING to ACTIVATED to preserve external API behavior, + * since our API has no DEACTIVATING state of its own. Since this can + * take some time, and the VPN isn't actually disconnected until it + * hits the DISCONNECTED state, to clients it should still appear + * connected. + */ + return NM_VPN_CONNECTION_STATE_ACTIVATED; + } + case STATE_DISCONNECTED: + return NM_VPN_CONNECTION_STATE_DISCONNECTED; + case STATE_FAILED: + return NM_VPN_CONNECTION_STATE_FAILED; + default: + return NM_VPN_CONNECTION_STATE_UNKNOWN; + } +} + +static NMActiveConnectionState +_state_to_ac_state (VpnState vpn_state) +{ + /* Set the NMActiveConnection state based on VPN state */ + switch (vpn_state) { + case STATE_WAITING: + case STATE_PREPARE: + case STATE_NEED_AUTH: + case STATE_CONNECT: + case STATE_IP_CONFIG_GET: + case STATE_PRE_UP: + return NM_ACTIVE_CONNECTION_STATE_ACTIVATING; + case STATE_ACTIVATED: + return NM_ACTIVE_CONNECTION_STATE_ACTIVATED; + case STATE_DEACTIVATING: + return NM_ACTIVE_CONNECTION_STATE_DEACTIVATING; + case STATE_DISCONNECTED: + case STATE_FAILED: + return NM_ACTIVE_CONNECTION_STATE_DEACTIVATED; + default: + break; + } + return NM_ACTIVE_CONNECTION_STATE_UNKNOWN; +} + +static NMSettingsConnection * +_get_settings_connection (NMVpnConnection *self, gboolean allow_missing) +{ + NMSettingsConnection *con; + + /* Currently we operate on the assumption, that the settings-connection + * never changes after it is set (though initially, it might be unset). + * Later we might want to change that, but then we need fixes here too. */ + + con = _nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (self)); + if (!con && !allow_missing) + g_return_val_if_reached (NULL); + return con; +} + +static NMConnection * +_get_applied_connection (NMVpnConnection *connection) +{ + NMConnection *con; + + con = nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (connection)); + g_return_val_if_fail (con, NULL); + return con; +} + +static void +disconnect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + GVariant *variant; + + variant = g_dbus_proxy_call_finish (proxy, result, NULL); + if (variant) + g_variant_unref (variant); + g_object_unref (user_data); +} + +static void +call_plugin_disconnect (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + g_dbus_proxy_call (priv->proxy, + "Disconnect", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->cancellable, + (GAsyncReadyCallback) disconnect_cb, + g_object_ref (self)); +} + +static void +fw_call_cleanup (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (priv->fw_call) { + nm_firewall_manager_cancel_call (priv->fw_call); + g_warn_if_fail (!priv->fw_call); + priv->fw_call = NULL; + } +} + +static void +remove_parent_device_config (NMVpnConnection *connection, NMDevice *device) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); + + if (priv->last_device_ip4_config) { + nm_device_replace_vpn4_config (device, priv->last_device_ip4_config, NULL); + g_clear_object (&priv->last_device_ip4_config); + } + + if (priv->last_device_ip6_config) { + nm_device_replace_vpn6_config (device, priv->last_device_ip6_config, NULL); + g_clear_object (&priv->last_device_ip6_config); + } +} + +static void +vpn_cleanup (NMVpnConnection *self, NMDevice *parent_dev) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (priv->ip_ifindex) { + nm_platform_link_set_down (NM_PLATFORM_GET, priv->ip_ifindex); + nm_route_manager_route_flush (priv->route_manager, priv->ip_ifindex); + nm_platform_address_flush (NM_PLATFORM_GET, priv->ip_ifindex); + } + + remove_parent_device_config (self, parent_dev); + + /* Remove zone from firewall */ + if (priv->ip_iface) { + nm_firewall_manager_remove_from_zone (nm_firewall_manager_get (), + priv->ip_iface, + NULL, + NULL, + NULL); + } + /* Cancel pending firewall call */ + fw_call_cleanup (self); + + g_free (priv->banner); + priv->banner = NULL; + + g_free (priv->ip_iface); + priv->ip_iface = NULL; + priv->ip_ifindex = 0; + + g_free (priv->bus_name); + priv->bus_name = NULL; + + /* Clear out connection secrets to ensure that the settings service + * gets asked for them next time the connection is activated. + */ + nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (self)); +} + +static void +dispatcher_pre_down_done (guint call_id, gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + priv->dispatcher_id = 0; + _set_vpn_state (self, STATE_DISCONNECTED, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); +} + +static void +dispatcher_pre_up_done (guint call_id, gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + priv->dispatcher_id = 0; + _set_vpn_state (self, STATE_ACTIVATED, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); +} + +static void +dispatcher_cleanup (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (priv->dispatcher_id) { + nm_dispatcher_call_cancel (priv->dispatcher_id); + priv->dispatcher_id = 0; + } +} + +static void +_set_vpn_state (NMVpnConnection *self, + VpnState vpn_state, + NMVpnConnectionStateReason reason, + gboolean quitting) +{ + NMVpnConnectionPrivate *priv; + VpnState old_vpn_state; + NMVpnConnectionState new_external_state, old_external_state; + NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (self)); + + g_return_if_fail (NM_IS_VPN_CONNECTION (self)); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (vpn_state == priv->vpn_state) + return; + + old_vpn_state = priv->vpn_state; + priv->vpn_state = vpn_state; + + /* The device gets destroyed by active connection when it enters + * the deactivated state, so we need to ref it for usage below. + */ + if (parent_dev) + g_object_ref (parent_dev); + + /* Update active connection base class state */ + nm_active_connection_set_state (NM_ACTIVE_CONNECTION (self), + _state_to_ac_state (vpn_state)); + + /* Clear any in-progress secrets request */ + cancel_get_secrets (self); + + dispatcher_cleanup (self); + + nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self); + nm_default_route_manager_ip6_update_default_route (priv->default_route_manager, self); + + /* The connection gets destroyed by the VPN manager when it enters the + * disconnected/failed state, but we need to keep it around for a bit + * to send out signals and handle the dispatcher. So ref it. + */ + g_object_ref (self); + + old_external_state = _state_to_nm_vpn_state (old_vpn_state); + new_external_state = _state_to_nm_vpn_state (priv->vpn_state); + if (new_external_state != old_external_state) { + g_signal_emit (self, signals[VPN_STATE_CHANGED], 0, new_external_state, reason); + g_signal_emit (self, signals[INTERNAL_STATE_CHANGED], 0, + new_external_state, + old_external_state, + reason); + _notify (self, PROP_VPN_STATE); + } + + switch (vpn_state) { + case STATE_NEED_AUTH: + /* Do nothing; not part of 'default' because we don't want to touch + * priv->secrets_req as NEED_AUTH is re-entered during interactive + * secrets. + */ + break; + case STATE_PRE_UP: + if (!nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_PRE_UP, + _get_settings_connection (self, FALSE), + _get_applied_connection (self), + parent_dev, + priv->ip_iface, + priv->proxy_config, + priv->ip4_config, + priv->ip6_config, + dispatcher_pre_up_done, + self, + &priv->dispatcher_id)) { + /* Just proceed on errors */ + dispatcher_pre_up_done (0, self); + } + break; + case STATE_ACTIVATED: + /* Secrets no longer needed now that we're connected */ + nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (self)); + + /* Let dispatcher scripts know we're up and running */ + nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_UP, + _get_settings_connection (self, FALSE), + _get_applied_connection (self), + parent_dev, + priv->ip_iface, + priv->proxy_config, + priv->ip4_config, + priv->ip6_config, + NULL, + NULL, + NULL); + + if (priv->proxy_config) { + nm_pacrunner_manager_send (nm_pacrunner_manager_get (), + priv->ip_iface, + priv->proxy_config, + priv->ip4_config, + priv->ip6_config); + } + break; + case STATE_DEACTIVATING: + if (quitting) { + nm_dispatcher_call_vpn_sync (DISPATCHER_ACTION_VPN_PRE_DOWN, + _get_settings_connection (self, FALSE), + _get_applied_connection (self), + parent_dev, + priv->ip_iface, + priv->proxy_config, + priv->ip4_config, + priv->ip6_config); + } else { + if (!nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_PRE_DOWN, + _get_settings_connection (self, FALSE), + _get_applied_connection (self), + parent_dev, + priv->ip_iface, + priv->proxy_config, + priv->ip4_config, + priv->ip6_config, + dispatcher_pre_down_done, + self, + &priv->dispatcher_id)) { + /* Just proceed on errors */ + dispatcher_pre_down_done (0, self); + } + } + + /* Remove config from PacRunner */ + nm_pacrunner_manager_remove (nm_pacrunner_manager_get(), priv->ip_iface); + break; + case STATE_FAILED: + case STATE_DISCONNECTED: + if ( old_vpn_state >= STATE_ACTIVATED + && old_vpn_state <= STATE_DEACTIVATING) { + /* Let dispatcher scripts know we're about to go down */ + if (quitting) { + nm_dispatcher_call_vpn_sync (DISPATCHER_ACTION_VPN_DOWN, + _get_settings_connection (self, FALSE), + _get_applied_connection (self), + parent_dev, + priv->ip_iface, + NULL, + NULL, + NULL); + } else { + nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_DOWN, + _get_settings_connection (self, FALSE), + _get_applied_connection (self), + parent_dev, + priv->ip_iface, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + } + } + + /* Tear down and clean up the connection */ + call_plugin_disconnect (self); + vpn_cleanup (self, parent_dev); + /* Fall through */ + default: + priv->secrets_idx = SECRETS_REQ_SYSTEM; + break; + } + + g_object_unref (self); + if (parent_dev) + g_object_unref (parent_dev); +} + +static gboolean +_service_and_connection_can_persist (NMVpnConnection *self) +{ + return NM_VPN_CONNECTION_GET_PRIVATE (self)->connection_can_persist && + NM_VPN_CONNECTION_GET_PRIVATE (self)->service_can_persist; +} + +static gboolean +_connection_only_can_persist (NMVpnConnection *self) +{ + return NM_VPN_CONNECTION_GET_PRIVATE (self)->connection_can_persist && + !NM_VPN_CONNECTION_GET_PRIVATE (self)->service_can_persist; +} + +static void +device_state_changed (NMActiveConnection *active, + NMDevice *device, + NMDeviceState new_state, + NMDeviceState old_state) +{ + if (_service_and_connection_can_persist (NM_VPN_CONNECTION (active))) { + if (new_state <= NM_DEVICE_STATE_DISCONNECTED || + new_state == NM_DEVICE_STATE_FAILED) { + nm_active_connection_set_device (active, NULL); + } + return; + } + + if (new_state <= NM_DEVICE_STATE_DISCONNECTED) { + _set_vpn_state (NM_VPN_CONNECTION (active), + STATE_DISCONNECTED, + NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED, + FALSE); + } else if (new_state == NM_DEVICE_STATE_FAILED) { + _set_vpn_state (NM_VPN_CONNECTION (active), + STATE_FAILED, + NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED, + FALSE); + } + + /* FIXME: map device DEACTIVATING state to VPN DEACTIVATING state and + * block device deactivation on VPN deactivation. + */ +} + +static void +add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32 vpn_gw) +{ + NMIP4Config *parent_config; + guint32 parent_gw; + NMPlatformIP4Route route; + guint32 route_metric; + + g_return_if_fail (NM_IS_IP4_CONFIG (config)); + g_return_if_fail (NM_IS_DEVICE (parent_device)); + g_return_if_fail (vpn_gw != 0); + + /* Set up a route to the VPN gateway's public IP address through the default + * network device if the VPN gateway is on a different subnet. + */ + parent_config = nm_device_get_ip4_config (parent_device); + g_return_if_fail (parent_config != NULL); + parent_gw = nm_ip4_config_get_gateway (parent_config); + + route_metric = nm_device_get_ip4_route_metric (parent_device); + + memset (&route, 0, sizeof (route)); + route.network = vpn_gw; + route.plen = 32; + route.gateway = parent_gw; + /* Set up a device route if the parent device has no gateway */ + if (!parent_gw) + route.ifindex = nm_device_get_ip_ifindex (parent_device); + + /* If the VPN gateway is in the same subnet as one of the parent device's + * IP addresses, don't add the host route to it, but a route through the + * parent device. + */ + if (nm_ip4_config_destination_is_direct (parent_config, vpn_gw, 32)) + route.gateway = 0; + + route.rt_source = NM_IP_CONFIG_SOURCE_VPN; + route.metric = route_metric; + nm_ip4_config_add_route (config, &route); + + if (parent_gw) { + /* Ensure there's a route to the parent device's gateway through the + * parent device, since if the VPN claims the default route and the VPN + * routes include a subnet that matches the parent device's subnet, + * the parent device's gateway would get routed through the VPN and fail. + */ + memset (&route, 0, sizeof (route)); + route.network = parent_gw; + route.plen = 32; + route.rt_source = NM_IP_CONFIG_SOURCE_VPN; + route.metric = route_metric; + + nm_ip4_config_add_route (config, &route); + } +} + +static void +add_ip6_vpn_gateway_route (NMIP6Config *config, + NMDevice *parent_device, + const struct in6_addr *vpn_gw) +{ + NMIP6Config *parent_config; + const struct in6_addr *parent_gw; + NMPlatformIP6Route route; + guint32 route_metric; + + g_return_if_fail (NM_IS_IP6_CONFIG (config)); + g_return_if_fail (NM_IS_DEVICE (parent_device)); + g_return_if_fail (vpn_gw != NULL); + + parent_config = nm_device_get_ip6_config (parent_device); + g_return_if_fail (parent_config != NULL); + parent_gw = nm_ip6_config_get_gateway (parent_config); + if (!parent_gw) + return; + + route_metric = nm_device_get_ip6_route_metric (parent_device); + + memset (&route, 0, sizeof (route)); + route.network = *vpn_gw; + route.plen = 128; + route.gateway = *parent_gw; + + /* If the VPN gateway is in the same subnet as one of the parent device's + * IP addresses, don't add the host route to it, but a route through the + * parent device. + */ + if (nm_ip6_config_destination_is_direct (parent_config, vpn_gw, 128)) + route.gateway = in6addr_any; + + route.rt_source = NM_IP_CONFIG_SOURCE_VPN; + route.metric = route_metric; + nm_ip6_config_add_route (config, &route); + + /* Ensure there's a route to the parent device's gateway through the + * parent device, since if the VPN claims the default route and the VPN + * routes include a subnet that matches the parent device's subnet, + * the parent device's gateway would get routed through the VPN and fail. + */ + memset (&route, 0, sizeof (route)); + route.network = *parent_gw; + route.plen = 128; + route.rt_source = NM_IP_CONFIG_SOURCE_VPN; + route.metric = route_metric; + + nm_ip6_config_add_route (config, &route); +} + +NMVpnConnection * +nm_vpn_connection_new (NMSettingsConnection *settings_connection, + NMDevice *parent_device, + const char *specific_object, + NMAuthSubject *subject) +{ + g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL); + g_return_val_if_fail (NM_IS_DEVICE (parent_device), NULL); + + return (NMVpnConnection *) g_object_new (NM_TYPE_VPN_CONNECTION, + NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, settings_connection, + NM_ACTIVE_CONNECTION_INT_DEVICE, parent_device, + NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, + NM_ACTIVE_CONNECTION_INT_SUBJECT, subject, + NM_ACTIVE_CONNECTION_VPN, TRUE, + NULL); +} + +const char * +nm_vpn_connection_get_service (NMVpnConnection *self) +{ + NMSettingVpn *s_vpn; + + s_vpn = nm_connection_get_setting_vpn (_get_applied_connection (self)); + return nm_setting_vpn_get_service_type (s_vpn); +} + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_plugin_failure_to_string, NMVpnPluginFailure, + NM_UTILS_LOOKUP_DEFAULT (NULL), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED, "login-failed"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED, "connect-failed"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG, "bad-ip-config"), +); +#define vpn_plugin_failure_to_string(failure) NM_UTILS_LOOKUP_STR (_vpn_plugin_failure_to_string, failure) + +static void +plugin_failed (NMVpnConnection *self, guint reason) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + _LOGW ("VPN plugin: failed: %s (%d)", vpn_plugin_failure_to_string (reason), reason); + + switch (reason) { + case NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED: + priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED; + break; + case NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG: + priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID; + break; + default: + priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_UNKNOWN; + break; + } +} + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_service_state_to_string, NMVpnServiceState, + NM_UTILS_LOOKUP_DEFAULT (NULL), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_INIT, "init"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_SHUTDOWN, "shutdown"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STARTING, "starting"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STARTED, "started"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STOPPING, "stopping"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STOPPED, "stopped"), +); +#define vpn_service_state_to_string(state) NM_UTILS_LOOKUP_STR (_vpn_service_state_to_string, state) + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_state_to_string, VpnState, + NM_UTILS_LOOKUP_DEFAULT (NULL), + NM_UTILS_LOOKUP_STR_ITEM (STATE_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_WAITING, "waiting"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_PREPARE, "prepare"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_NEED_AUTH, "need-auth"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_CONNECT, "connect"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_IP_CONFIG_GET, "ip-config-get"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_PRE_UP, "pre-up"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_ACTIVATED, "activated"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_DEACTIVATING, "deactivating"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_DISCONNECTED, "disconnected"), + NM_UTILS_LOOKUP_STR_ITEM (STATE_FAILED, "failed"), +); +#define vpn_state_to_string(state) NM_UTILS_LOOKUP_STR (_vpn_state_to_string, state) + +NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_reason_to_string, NMVpnConnectionStateReason, + NM_UTILS_LOOKUP_DEFAULT (NULL), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_NONE, "none"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED, "user-disconnected"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED, "device-disconnected"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED, "service-stopped"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, "ip-config-invalid"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, "connect-timeout"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT, "service-start-timeout"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, "service-start-failed"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, "no-secrets"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED, "login-failed"), + NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED, "connection-removed"), +); +#define vpn_reason_to_string(reason) NM_UTILS_LOOKUP_STR (_vpn_reason_to_string, reason) + +static void +plugin_state_changed (NMVpnConnection *self, NMVpnServiceState new_service_state) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMVpnServiceState old_service_state = priv->service_state; + + _LOGI ("VPN plugin: state changed: %s (%d)", + vpn_service_state_to_string (new_service_state), new_service_state); + priv->service_state = new_service_state; + + if (new_service_state == NM_VPN_SERVICE_STATE_STOPPED) { + /* Clear connection secrets to ensure secrets get requested each time the + * connection is activated. + */ + nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (self)); + + if ((priv->vpn_state >= STATE_WAITING) && (priv->vpn_state <= STATE_ACTIVATED)) { + VpnState old_state = priv->vpn_state; + + _LOGI ("VPN plugin: state change reason: %s (%d)", + vpn_reason_to_string (priv->failure_reason), priv->failure_reason); + _set_vpn_state (self, STATE_FAILED, priv->failure_reason, FALSE); + + /* Reset the failure reason */ + priv->failure_reason = NM_VPN_CONNECTION_STATE_REASON_UNKNOWN; + + /* If the connection failed, the service cannot persist, but the + * connection can persist, ask listeners to re-activate the connection. + */ + if ( old_state == STATE_ACTIVATED + && priv->vpn_state == STATE_FAILED + && _connection_only_can_persist (self)) + g_signal_emit (self, signals[INTERNAL_RETRY_AFTER_FAILURE], 0); + } + } else if (new_service_state == NM_VPN_SERVICE_STATE_STARTING && + old_service_state == NM_VPN_SERVICE_STATE_STARTED) { + /* The VPN service got disconnected and is attempting to reconnect */ + _set_vpn_state (self, STATE_CONNECT, NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, FALSE); + } +} + +static void +print_vpn_config (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + const NMPlatformIP4Address *address4; + const NMPlatformIP6Address *address6; + char *dns_domain = NULL; + guint32 num, i; + char buf[NM_UTILS_INET_ADDRSTRLEN]; + + if (priv->ip4_external_gw) { + _LOGI ("Data: VPN Gateway: %s", + nm_utils_inet4_ntop (priv->ip4_external_gw, NULL)); + } else if (priv->ip6_external_gw) { + _LOGI ("Data: VPN Gateway: %s", + nm_utils_inet6_ntop (priv->ip6_external_gw, NULL)); + } + + _LOGI ("Data: Tunnel Device: %s%s%s", NM_PRINT_FMT_QUOTE_STRING (priv->ip_iface)); + + if (priv->ip4_config) { + _LOGI ("Data: IPv4 configuration:"); + + address4 = nm_ip4_config_get_address (priv->ip4_config, 0); + + if (priv->ip4_internal_gw) + _LOGI ("Data: Internal Gateway: %s", nm_utils_inet4_ntop (priv->ip4_internal_gw, NULL)); + _LOGI ("Data: Internal Address: %s", nm_utils_inet4_ntop (address4->address, NULL)); + _LOGI ("Data: Internal Prefix: %d", address4->plen); + _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet4_ntop (address4->peer_address, NULL)); + _LOGI ("Data: Maximum Segment Size (MSS): %d", nm_ip4_config_get_mss (priv->ip4_config)); + + num = nm_ip4_config_get_num_routes (priv->ip4_config); + for (i = 0; i < num; i++) { + const NMPlatformIP4Route *route = nm_ip4_config_get_route (priv->ip4_config, i); + + _LOGI ("Data: Static Route: %s/%d Next Hop: %s", + nm_utils_inet4_ntop (route->network, NULL), + route->plen, + nm_utils_inet4_ntop (route->gateway, buf)); + } + + _LOGI ("Data: Forbid Default Route: %s", + nm_ip4_config_get_never_default (priv->ip4_config) ? "yes" : "no"); + + num = nm_ip4_config_get_num_nameservers (priv->ip4_config); + for (i = 0; i < num; i++) { + _LOGI ("Data: Internal DNS: %s", + nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (priv->ip4_config, i), NULL)); + } + + if (nm_ip4_config_get_num_domains (priv->ip4_config) > 0) + dns_domain = (char *) nm_ip4_config_get_domain (priv->ip4_config, 0); + + _LOGI ("Data: DNS Domain: '%s'", dns_domain ? dns_domain : "(none)"); + } else + _LOGI ("Data: No IPv4 configuration"); + + if (priv->ip6_config) { + _LOGI ("Data: IPv6 configuration:"); + + address6 = nm_ip6_config_get_address (priv->ip6_config, 0); + + if (priv->ip6_internal_gw) + _LOGI ("Data: Internal Gateway: %s", nm_utils_inet6_ntop (priv->ip6_internal_gw, NULL)); + _LOGI ("Data: Internal Address: %s", nm_utils_inet6_ntop (&address6->address, NULL)); + _LOGI ("Data: Internal Prefix: %d", address6->plen); + _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet6_ntop (&address6->peer_address, NULL)); + _LOGI ("Data: Maximum Segment Size (MSS): %d", nm_ip6_config_get_mss (priv->ip6_config)); + + num = nm_ip6_config_get_num_routes (priv->ip6_config); + for (i = 0; i < num; i++) { + const NMPlatformIP6Route *route = nm_ip6_config_get_route (priv->ip6_config, i); + + _LOGI ("Data: Static Route: %s/%d Next Hop: %s", + nm_utils_inet6_ntop (&route->network, NULL), + route->plen, + nm_utils_inet6_ntop (&route->gateway, buf)); + } + + _LOGI ("Data: Forbid Default Route: %s", + nm_ip6_config_get_never_default (priv->ip6_config) ? "yes" : "no"); + + num = nm_ip6_config_get_num_nameservers (priv->ip6_config); + for (i = 0; i < num; i++) { + _LOGI ("Data: Internal DNS: %s", + nm_utils_inet6_ntop (nm_ip6_config_get_nameserver (priv->ip6_config, i), NULL)); + } + + if (nm_ip6_config_get_num_domains (priv->ip6_config) > 0) + dns_domain = (char *) nm_ip6_config_get_domain (priv->ip6_config, 0); + + _LOGI ("Data: DNS Domain: '%s'", dns_domain ? dns_domain : "(none)"); + } else + _LOGI ("Data: No IPv6 configuration"); + + if (priv->banner && strlen (priv->banner)) { + _LOGI ("Data: Login Banner:"); + _LOGI ("Data: -----------------------------------------"); + _LOGI ("Data: %s", priv->banner); + _LOGI ("Data: -----------------------------------------"); + } +} + +static void +apply_parent_device_config (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (self)); + NMIP4Config *vpn4_parent_config = NULL; + NMIP6Config *vpn6_parent_config = NULL; + + if (priv->ip_ifindex > 0) { + if (priv->ip4_config) + vpn4_parent_config = nm_ip4_config_new (priv->ip_ifindex); + if (priv->ip6_config) + vpn6_parent_config = nm_ip6_config_new (priv->ip_ifindex); + } else { + int ifindex; + + /* If the VPN didn't return a network interface, it is a route-based + * VPN (like kernel IPSec) and all IP addressing and routing should + * be done on the parent interface instead. + */ + + /* Also clear the gateway. We don't configure the gateway as part of the + * vpn-config. Instead we tell NMDefaultRouteManager directly about the + * default route. */ + ifindex = nm_device_get_ip_ifindex (parent_dev); + if (priv->ip4_config) { + vpn4_parent_config = nm_ip4_config_new (ifindex); + nm_ip4_config_merge (vpn4_parent_config, priv->ip4_config, NM_IP_CONFIG_MERGE_NO_DNS); + } + if (priv->ip6_config) { + vpn6_parent_config = nm_ip6_config_new (ifindex); + nm_ip6_config_merge (vpn6_parent_config, priv->ip6_config, NM_IP_CONFIG_MERGE_NO_DNS); + nm_ip6_config_set_gateway (vpn6_parent_config, NULL); + } + } + + /* Add any explicit route to the VPN gateway through the parent device */ + if (vpn4_parent_config && priv->ip4_external_gw) + add_ip4_vpn_gateway_route (vpn4_parent_config, parent_dev, priv->ip4_external_gw); + if (vpn6_parent_config && priv->ip6_external_gw) + add_ip6_vpn_gateway_route (vpn6_parent_config, parent_dev, priv->ip6_external_gw); + + nm_device_replace_vpn4_config (parent_dev, priv->last_device_ip4_config, vpn4_parent_config); + g_clear_object (&priv->last_device_ip4_config); + priv->last_device_ip4_config = vpn4_parent_config; + + nm_device_replace_vpn6_config (parent_dev, priv->last_device_ip6_config, vpn6_parent_config); + g_clear_object (&priv->last_device_ip6_config); + priv->last_device_ip6_config = vpn6_parent_config; +} + +static gboolean +nm_vpn_connection_apply_config (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (priv->ip_ifindex > 0) { + nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL); + + if (priv->ip4_config) { + if (!nm_ip4_config_commit (priv->ip4_config, priv->ip_ifindex, + TRUE, + nm_vpn_connection_get_ip4_route_metric (self))) + return FALSE; + } + + if (priv->ip6_config) { + if (!nm_ip6_config_commit (priv->ip6_config, + priv->ip_ifindex, + TRUE)) + return FALSE; + } + + if (priv->mtu && priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ip_ifindex)) + nm_platform_link_set_mtu (NM_PLATFORM_GET, priv->ip_ifindex, priv->mtu); + } + + apply_parent_device_config (self); + + nm_default_route_manager_ip4_update_default_route (priv->default_route_manager, self); + nm_default_route_manager_ip6_update_default_route (priv->default_route_manager, self); + + _LOGI ("VPN connection: (IP Config Get) complete"); + if (priv->vpn_state < STATE_PRE_UP) + _set_vpn_state (self, STATE_PRE_UP, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); + return TRUE; +} + +static void +_cleanup_failed_config (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + nm_exported_object_clear_and_unexport (&priv->ip4_config); + nm_exported_object_clear_and_unexport (&priv->ip6_config); + + _LOGW ("VPN connection: did not receive valid IP config information"); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID, FALSE); +} + +static void +fw_change_zone_cb (NMFirewallManager *firewall_manager, + NMFirewallManagerCallId call_id, + GError *error, + gpointer user_data) +{ + NMVpnConnection *self = user_data; + NMVpnConnectionPrivate *priv; + + g_return_if_fail (NM_IS_VPN_CONNECTION (self)); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + g_return_if_fail (priv->fw_call == call_id); + + priv->fw_call = NULL; + + if (nm_utils_error_is_cancelled (error, FALSE)) + return; + + if (error) { + // FIXME: fail the activation? + } + + if (!nm_vpn_connection_apply_config (self)) + _cleanup_failed_config (self); +} + +static void +nm_vpn_connection_config_maybe_complete (NMVpnConnection *self, + gboolean success) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMConnection *base_con; + NMSettingConnection *s_con; + const char *zone; + + if (priv->vpn_state < STATE_IP_CONFIG_GET || priv->vpn_state > STATE_ACTIVATED) + return; + + if (success) { + if ( (priv->has_ip4 && !priv->ip4_config) + || (priv->has_ip6 && !priv->ip6_config)) { + /* Need to wait for other config */ + return; + } + } + + nm_clear_g_source (&priv->connect_timeout); + + if (success) { + print_vpn_config (self); + + /* Add the tunnel interface to the specified firewall zone */ + if (priv->ip_iface) { + base_con = _get_applied_connection (self); + s_con = nm_connection_get_setting_connection (base_con); + zone = nm_setting_connection_get_zone (s_con); + + _LOGD ("setting firewall zone %s%s%s for '%s'", + NM_PRINT_FMT_QUOTED (zone, "'", zone, "'", "(default)"), + priv->ip_iface); + fw_call_cleanup (self); + priv->fw_call = nm_firewall_manager_add_or_change_zone (nm_firewall_manager_get (), + priv->ip_iface, + zone, + FALSE, + fw_change_zone_cb, + self); + return; + } else + if (nm_vpn_connection_apply_config (self)) + return; + } + + _cleanup_failed_config (self); +} + +static gboolean +ip6_addr_from_variant (GVariant *v, struct in6_addr *addr) +{ + const guint8 *bytes; + gsize len; + + g_return_val_if_fail (v, FALSE); + g_return_val_if_fail (addr, FALSE); + + if (g_variant_is_of_type (v, G_VARIANT_TYPE ("ay"))) { + bytes = g_variant_get_fixed_array (v, &len, sizeof (guint8)); + if (len == sizeof (struct in6_addr) && !IN6_IS_ADDR_UNSPECIFIED (bytes)) { + memcpy (addr, bytes, len); + return TRUE; + } + } + return FALSE; +} + +static struct in6_addr * +ip6_addr_dup_from_variant (GVariant *v) +{ + struct in6_addr *addr; + + addr = g_malloc0 (sizeof (*addr)); + if (ip6_addr_from_variant (v, addr)) + return addr; + g_free (addr); + return NULL; +} + +static gboolean +process_generic_config (NMVpnConnection *self, GVariant *dict) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + const char *str; + GVariant *v; + guint32 u32; + gboolean b; + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CAN_PERSIST, "b", &b) && b) { + /* Defaults to FALSE, so only let service indicate TRUE */ + priv->service_can_persist = TRUE; + } + + g_clear_pointer (&priv->ip_iface, g_free); + priv->ip_ifindex = 0; + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_TUNDEV, "&s", &str)) { + /* Backwards compat with NM-openswan */ + if (g_strcmp0 (str, "_none_") != 0) + priv->ip_iface = g_strdup (str); + } + + if (priv->ip_iface) { + /* Grab the interface index for address/routing operations */ + priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface); + if (priv->ip_ifindex <= 0) { + nm_platform_process_events (NM_PLATFORM_GET); + priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface); + } + if (priv->ip_ifindex <= 0) { + _LOGE ("failed to look up VPN interface index for \"%s\"", priv->ip_iface); + g_clear_pointer (&priv->ip_iface, g_free); + priv->ip_ifindex = 0; + nm_vpn_connection_config_maybe_complete (self, FALSE); + return FALSE; + } + } + + g_clear_pointer (&priv->banner, g_free); + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_BANNER, "&s", &str)) { + priv->banner = g_strdup (str); + _notify (self, PROP_BANNER); + } + + /* Proxy Config */ + g_clear_object (&priv->proxy_config); + priv->proxy_config = nm_proxy_config_new (); + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_PROXY_PAC, "&s", &str)) { + nm_proxy_config_set_method (priv->proxy_config, NM_PROXY_CONFIG_METHOD_AUTO); + nm_proxy_config_set_pac_url (priv->proxy_config, str); + } else + nm_proxy_config_set_method (priv->proxy_config, NM_PROXY_CONFIG_METHOD_NONE); + + /* User overrides if any from the NMConnection's Proxy settings */ + nm_proxy_config_merge_setting (priv->proxy_config, + nm_connection_get_setting_proxy (_get_applied_connection (self))); + + /* External world-visible address of the VPN server */ + priv->ip4_external_gw = 0; + g_clear_pointer (&priv->ip6_external_gw, g_free); + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, "u", &u32)) { + priv->ip4_external_gw = u32; + } else if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, "@ay", &v)) { + priv->ip6_external_gw = ip6_addr_dup_from_variant (v); + g_variant_unref (v); + + if (!priv->ip6_external_gw) { + _LOGE ("Invalid IPv6 VPN gateway address received"); + nm_vpn_connection_config_maybe_complete (self, FALSE); + return FALSE; + } + } + + priv->mtu = 0; + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_MTU, "u", &u32)) + priv->mtu = u32; + + return TRUE; +} + +static void +nm_vpn_connection_config_get (NMVpnConnection *self, GVariant *dict) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + gboolean b; + + g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT)); + + _LOGI ("VPN connection: (IP Config Get) reply received."); + + if (priv->vpn_state == STATE_CONNECT) + _set_vpn_state (self, STATE_IP_CONFIG_GET, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); + + if (!process_generic_config (self, dict)) + return; + + /* Note whether to expect IPv4 and IPv6 configs */ + priv->has_ip4 = FALSE; + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP4, "b", &b)) + priv->has_ip4 = b; + nm_exported_object_clear_and_unexport (&priv->ip4_config); + + priv->has_ip6 = FALSE; + if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_HAS_IP6, "b", &b)) + priv->has_ip6 = b; + nm_exported_object_clear_and_unexport (&priv->ip6_config); + + nm_vpn_connection_config_maybe_complete (self, TRUE); +} + +guint32 +nm_vpn_connection_get_ip4_route_metric (NMVpnConnection *self) +{ + gint64 route_metric; + NMConnection *applied; + + applied = _get_applied_connection (self); + route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip4_config (applied)); + + return (route_metric >= 0) ? route_metric : NM_VPN_ROUTE_METRIC_DEFAULT; +} + +guint32 +nm_vpn_connection_get_ip6_route_metric (NMVpnConnection *self) +{ + gint64 route_metric; + NMConnection *applied; + + applied = _get_applied_connection (self); + route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip6_config (applied)); + + return (route_metric >= 0) ? route_metric : NM_VPN_ROUTE_METRIC_DEFAULT; +} + +static void +nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMPlatformIP4Address address; + NMIP4Config *config; + guint32 u32, route_metric; + GVariantIter *iter; + const char *str; + GVariant *v; + gboolean b; + guint i, n; + int ip_ifindex; + + g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT)); + + if (priv->vpn_state == STATE_CONNECT) + _set_vpn_state (self, STATE_IP_CONFIG_GET, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); + + if (priv->vpn_state > STATE_ACTIVATED) { + _LOGI ("VPN connection: (IP4 Config Get) ignoring, the connection is no longer active"); + return; + } + + if (priv->has_ip4) { + _LOGI ("VPN connection: (IP4 Config Get) reply received"); + + if (g_variant_n_children (dict) == 0) { + priv->has_ip4 = FALSE; + nm_vpn_connection_config_maybe_complete (self, TRUE); + return; + } + } else { + _LOGI ("VPN connection: (IP4 Config Get) reply received from old-style plugin"); + + /* In the old API, the generic and IPv4 configuration items + * were mixed together. + */ + if (!process_generic_config (self, dict)) + return; + + priv->has_ip4 = TRUE; + priv->has_ip6 = FALSE; + } + + ip_ifindex = nm_vpn_connection_get_ip_ifindex (self, TRUE); + if (ip_ifindex <= 0) + g_return_if_reached (); + + config = nm_ip4_config_new (ip_ifindex); + nm_ip4_config_set_dns_priority (config, NM_DNS_PRIORITY_DEFAULT_VPN); + + memset (&address, 0, sizeof (address)); + address.plen = 24; + + /* Internal address of the VPN subnet's gateway */ + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY, "u", &u32)) { + priv->ip4_internal_gw = u32; + nm_ip4_config_set_gateway (config, priv->ip4_internal_gw); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, "u", &u32)) + address.address = u32; + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_PTP, "u", &u32)) + address.peer_address = u32; + else + address.peer_address = address.address; + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, "u", &u32)) + address.plen = u32; + + if (address.address && address.plen && address.plen <= 32) { + address.addr_source = NM_IP_CONFIG_SOURCE_VPN; + nm_ip4_config_add_address (config, &address); + } else { + _LOGW ("invalid IP4 config received!"); + g_object_unref (config); + nm_vpn_connection_config_maybe_complete (self, FALSE); + return; + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_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); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_NBNS, "au", &iter)) { + while (g_variant_iter_next (iter, "u", &u32)) + nm_ip4_config_add_wins (config, u32); + g_variant_iter_free (iter); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_MSS, "u", &u32)) + nm_ip4_config_set_mss (config, u32); + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_DOMAIN, "&s", &str)) + nm_ip4_config_add_domain (config, str); + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS, "as", &iter)) { + while (g_variant_iter_next (iter, "&s", &str)) + nm_ip4_config_add_domain (config, str); + g_variant_iter_free (iter); + } + + route_metric = nm_vpn_connection_get_ip4_route_metric (self); + + if ( g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_PRESERVE_ROUTES, "b", &b) + && b) { + if (priv->ip4_config) { + n = nm_ip4_config_get_num_routes (priv->ip4_config); + for (i = 0; i < n; i++) + nm_ip4_config_add_route (config, nm_ip4_config_get_route (priv->ip4_config, i)); + } + } else if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, "aau", &iter)) { + while (g_variant_iter_next (iter, "@au", &v)) { + NMPlatformIP4Route route = { 0, }; + guint32 plen; + + switch (g_variant_n_children (v)) { + case 5: + g_variant_get_child (v, 4, "u", &route.pref_src); + /* fallthrough */ + case 4: + g_variant_get_child (v, 0, "u", &route.network); + g_variant_get_child (v, 1, "u", &plen); + g_variant_get_child (v, 2, "u", &route.gateway); + /* 4th item is unused route metric */ + route.metric = route_metric; + route.rt_source = NM_IP_CONFIG_SOURCE_VPN; + + if (plen > 32 || plen == 0) + break; + route.plen = plen; + + /* Ignore host routes to the VPN gateway since NM adds one itself + * below. Since NM knows more about the routing situation than + * the VPN server, we want to use the NM created route instead of + * whatever the server provides. + */ + if (!(priv->ip4_external_gw && route.network == priv->ip4_external_gw && route.plen == 32)) + nm_ip4_config_add_route (config, &route); + break; + default: + break; + } + g_variant_unref (v); + } + g_variant_iter_free (iter); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT, "b", &b)) + nm_ip4_config_set_never_default (config, b); + + /* Merge in user overrides from the NMConnection's IPv4 setting */ + nm_ip4_config_merge_setting (config, + nm_connection_get_setting_ip4_config (_get_applied_connection (self)), + route_metric); + + if (priv->ip4_config) { + nm_ip4_config_replace (priv->ip4_config, config, NULL); + g_object_unref (config); + } else { + priv->ip4_config = config; + nm_exported_object_export (NM_EXPORTED_OBJECT (config)); + g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP4_CONFIG); + } + + nm_vpn_connection_config_maybe_complete (self, TRUE); +} + +static void +nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMPlatformIP6Address address; + guint32 u32, route_metric; + NMIP6Config *config; + GVariantIter *iter; + const char *str; + GVariant *v; + gboolean b; + guint i, n; + int ip_ifindex; + + g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT)); + + _LOGI ("VPN connection: (IP6 Config Get) reply received"); + + if (priv->vpn_state == STATE_CONNECT) + _set_vpn_state (self, STATE_IP_CONFIG_GET, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); + + if (priv->vpn_state > STATE_ACTIVATED) { + _LOGI ("VPN connection: (IP6 Config Get) ignoring, the connection is no longer active"); + return; + } + + if (g_variant_n_children (dict) == 0) { + priv->has_ip6 = FALSE; + nm_vpn_connection_config_maybe_complete (self, TRUE); + return; + } + + ip_ifindex = nm_vpn_connection_get_ip_ifindex (self, TRUE); + if (ip_ifindex <= 0) + g_return_if_reached (); + + config = nm_ip6_config_new (ip_ifindex); + nm_ip6_config_set_dns_priority (config, NM_DNS_PRIORITY_DEFAULT_VPN); + + memset (&address, 0, sizeof (address)); + address.plen = 128; + + /* Internal address of the VPN subnet's gateway */ + g_clear_pointer (&priv->ip6_internal_gw, g_free); + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY, "@ay", &v)) { + priv->ip6_internal_gw = ip6_addr_dup_from_variant (v); + nm_ip6_config_set_gateway (config, priv->ip6_internal_gw); + g_variant_unref (v); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_ADDRESS, "@ay", &v)) { + ip6_addr_from_variant (v, &address.address); + g_variant_unref (v); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_PTP, "@ay", &v)) { + ip6_addr_from_variant (v, &address.peer_address); + g_variant_unref (v); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_PREFIX, "u", &u32)) + address.plen = u32; + + if (!IN6_IS_ADDR_UNSPECIFIED (&address.address) && address.plen && address.plen <= 128) { + address.addr_source = NM_IP_CONFIG_SOURCE_VPN; + nm_ip6_config_add_address (config, &address); + } else { + _LOGW ("invalid IP6 config received!"); + g_object_unref (config); + nm_vpn_connection_config_maybe_complete (self, FALSE); + return; + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_DNS, "aay", &iter)) { + while (g_variant_iter_next (iter, "@ay", &v)) { + struct in6_addr dns; + + if (ip6_addr_from_variant (v, &dns)) + nm_ip6_config_add_nameserver (config, &dns); + g_variant_unref (v); + } + g_variant_iter_free (iter); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_MSS, "u", &u32)) + nm_ip6_config_set_mss (config, u32); + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_DOMAIN, "&s", &str)) + nm_ip6_config_add_domain (config, str); + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_DOMAINS, "as", &iter)) { + while (g_variant_iter_next (iter, "&s", &str)) + nm_ip6_config_add_domain (config, str); + g_variant_iter_free (iter); + } + + route_metric = nm_vpn_connection_get_ip6_route_metric (self); + + if ( g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES, "b", &b) + && b) { + if (priv->ip6_config) { + n = nm_ip6_config_get_num_routes (priv->ip6_config); + for (i = 0; i < n; i++) + nm_ip6_config_add_route (config, nm_ip6_config_get_route (priv->ip6_config, i)); + } + } else if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_ROUTES, "a(ayuayu)", &iter)) { + GVariant *dest, *next_hop; + guint32 prefix, metric; + + while (g_variant_iter_next (iter, "(@ayu@ayu)", &dest, &prefix, &next_hop, &metric)) { + NMPlatformIP6Route route; + + memset (&route, 0, sizeof (route)); + + if (!ip6_addr_from_variant (dest, &route.network)) + goto next; + + if (prefix > 128 || prefix == 0) + goto next; + + route.plen = prefix; + ip6_addr_from_variant (next_hop, &route.gateway); + route.metric = route_metric; + route.rt_source = NM_IP_CONFIG_SOURCE_VPN; + + /* Ignore host routes to the VPN gateway since NM adds one itself. + * Since NM knows more about the routing situation than the VPN + * server, we want to use the NM created route instead of whatever + * the server provides. + */ + if (!(priv->ip6_external_gw && IN6_ARE_ADDR_EQUAL (&route.network, priv->ip6_external_gw) && route.plen == 128)) + nm_ip6_config_add_route (config, &route); + +next: + g_variant_unref (dest); + g_variant_unref (next_hop); + } + g_variant_iter_free (iter); + } + + if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_NEVER_DEFAULT, "b", &b)) + nm_ip6_config_set_never_default (config, b); + + /* Merge in user overrides from the NMConnection's IPv6 setting */ + nm_ip6_config_merge_setting (config, + nm_connection_get_setting_ip6_config (_get_applied_connection (self)), + route_metric); + + if (priv->ip6_config) { + nm_ip6_config_replace (priv->ip6_config, config, NULL); + g_object_unref (config); + } else { + priv->ip6_config = config; + nm_exported_object_export (NM_EXPORTED_OBJECT (config)); + g_object_notify ((GObject *) self, NM_ACTIVE_CONNECTION_IP6_CONFIG); + } + + nm_vpn_connection_config_maybe_complete (self, TRUE); +} + +static gboolean +connect_timeout_cb (gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + priv->connect_timeout = 0; + + /* Cancel activation if it's taken too long */ + if (priv->vpn_state == STATE_CONNECT || + priv->vpn_state == STATE_IP_CONFIG_GET) { + _LOGW ("VPN connection: connect timeout exceeded."); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT, FALSE); + } + + return FALSE; +} + +static void +connect_success (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMSettingVpn *s_vpn; + guint32 timeout; + + s_vpn = nm_connection_get_setting_vpn (_get_applied_connection (self)); + g_assert (s_vpn); + + /* Timeout waiting for IP config signal from VPN service + * It is a configured value or 60 seconds */ + timeout = nm_setting_vpn_get_timeout (s_vpn); + if (timeout == 0) { + char *value; + + value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, + "vpn.timeout", NULL); + timeout = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, 60); + timeout = timeout == 0 ? 60 : timeout; + g_free (value); + } + priv->connect_timeout = g_timeout_add_seconds (timeout, connect_timeout_cb, self); + + g_clear_pointer (&priv->connect_hash, g_variant_unref); +} + +static void +connect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection *self; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_VPN_CONNECTION (user_data); + + if (error) { + g_dbus_error_strip_remote_error (error); + _LOGW ("VPN connection: failed to connect: '%s'", + error->message); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, FALSE); + } else + connect_success (self); +} + +static void +connect_interactive_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection *self; + NMVpnConnectionPrivate *priv; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_VPN_CONNECTION (user_data); + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + _LOGI ("VPN connection: (ConnectInteractive) reply received"); + + if (g_error_matches (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED)) { + _LOGD ("VPN connection: falling back to non-interactive connect"); + + /* Fall back to Connect() */ + g_dbus_proxy_call (priv->proxy, + "Connect", + g_variant_new ("(@a{sa{sv}})", priv->connect_hash), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->cancellable, + (GAsyncReadyCallback) connect_cb, + self); + } else if (error) { + g_dbus_error_strip_remote_error (error); + _LOGW ("VPN connection: failed to connect interactively: '%s'", + error->message); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, FALSE); + } else + connect_success (self); +} + +/* Add a username to a hashed connection */ +static GVariant * +_hash_with_username (NMConnection *connection, const char *username) +{ + gs_unref_object NMConnection *dup = NULL; + NMSettingVpn *s_vpn; + + /* Shortcut if we weren't given a username or if there already was one in + * the VPN setting; don't bother duplicating the connection and everything. + */ + s_vpn = nm_connection_get_setting_vpn (connection); + g_assert (s_vpn); + if (username == NULL || nm_setting_vpn_get_user_name (s_vpn)) + return nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL); + + dup = nm_simple_connection_new_clone (connection); + g_assert (dup); + s_vpn = nm_connection_get_setting_vpn (dup); + g_assert (s_vpn); + g_object_set (s_vpn, NM_SETTING_VPN_USER_NAME, username, NULL); + return nm_connection_to_dbus (dup, NM_CONNECTION_SERIALIZE_ALL); +} + +static void +really_activate (NMVpnConnection *self, const char *username) +{ + NMVpnConnectionPrivate *priv; + GVariantBuilder details; + + g_return_if_fail (NM_IS_VPN_CONNECTION (self)); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + g_return_if_fail (priv->vpn_state == STATE_NEED_AUTH); + + g_clear_pointer (&priv->connect_hash, g_variant_unref); + priv->connect_hash = _hash_with_username (_get_applied_connection (self), username); + g_variant_ref_sink (priv->connect_hash); + + /* If at least one agent doesn't support VPN hints, then we can't use + * ConnectInteractive(), because that agent won't be able to pass hints + * from the VPN plugin's interactive secrets requests to the VPN authentication + * dialog and we won't get the secrets we need. In this case fall back to + * the old Connect() call. + */ + if (nm_agent_manager_all_agents_have_capability (nm_agent_manager_get (), + nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (self)), + NM_SECRET_AGENT_CAPABILITY_VPN_HINTS)) { + _LOGD ("Allowing interactive secrets as all agents have that capability"); + + g_variant_builder_init (&details, G_VARIANT_TYPE_VARDICT); + g_dbus_proxy_call (priv->proxy, + "ConnectInteractive", + g_variant_new ("(@a{sa{sv}}a{sv})", priv->connect_hash, &details), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->cancellable, + (GAsyncReadyCallback) connect_interactive_cb, + self); + } else { + _LOGD ("Calling old Connect function as not all agents support interactive secrets"); + g_dbus_proxy_call (priv->proxy, + "Connect", + g_variant_new ("(@a{sa{sv}})", priv->connect_hash), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->cancellable, + (GAsyncReadyCallback) connect_cb, + self); + } + + _set_vpn_state (self, STATE_CONNECT, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); +} + +static void +failure_cb (GDBusProxy *proxy, + guint32 reason, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + + plugin_failed (self, reason); +} + +static void +state_changed_cb (GDBusProxy *proxy, + guint32 new_service_state, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + + plugin_state_changed (self, new_service_state); +} + +static void +secrets_required_cb (GDBusProxy *proxy, + const char *message, + const char **secrets, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + + plugin_interactive_secrets_required (self, message, secrets); +} + +static void +config_cb (GDBusProxy *proxy, + GVariant *dict, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + /* Only list to this signals during and after connection */ + if (priv->vpn_state >= STATE_NEED_AUTH) + nm_vpn_connection_config_get (self, dict); +} + +static void +ip4_config_cb (GDBusProxy *proxy, + GVariant *dict, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + /* Only list to this signals during and after connection */ + if (priv->vpn_state >= STATE_NEED_AUTH) + nm_vpn_connection_ip4_config_get (self, dict); +} + +static void +ip6_config_cb (GDBusProxy *proxy, + GVariant *dict, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + /* Only list to this signals during and after connection */ + if (priv->vpn_state >= STATE_NEED_AUTH) + nm_vpn_connection_ip6_config_get (self, dict); +} + +static void +_name_owner_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + char *owner; + + owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object)); + + if (owner && !priv->service_running) { + /* service appeared */ + priv->service_running = TRUE; + _LOGI ("Saw the service appear; activating connection"); + + /* No need to wait for the timeout any longer */ + nm_clear_g_source (&priv->start_timeout); + + /* Expect success because the VPN service has already appeared */ + _nm_dbus_signal_connect (priv->proxy, "Failure", G_VARIANT_TYPE ("(u)"), + G_CALLBACK (failure_cb), self); + _nm_dbus_signal_connect (priv->proxy, "StateChanged", G_VARIANT_TYPE ("(u)"), + G_CALLBACK (state_changed_cb), self); + _nm_dbus_signal_connect (priv->proxy, "SecretsRequired", G_VARIANT_TYPE ("(sas)"), + G_CALLBACK (secrets_required_cb), self); + _nm_dbus_signal_connect (priv->proxy, "Config", G_VARIANT_TYPE ("(a{sv})"), + G_CALLBACK (config_cb), self); + _nm_dbus_signal_connect (priv->proxy, "Ip4Config", G_VARIANT_TYPE ("(a{sv})"), + G_CALLBACK (ip4_config_cb), self); + _nm_dbus_signal_connect (priv->proxy, "Ip6Config", G_VARIANT_TYPE ("(a{sv})"), + G_CALLBACK (ip6_config_cb), self); + + _set_vpn_state (self, STATE_NEED_AUTH, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); + + /* Kick off the secrets requests; first we get existing system secrets + * and ask the plugin if these are sufficient, next we get all existing + * secrets from system and from user agents and ask the plugin again, + * and last we ask the user for new secrets if required. + */ + get_secrets (self, SECRETS_REQ_SYSTEM, NULL); + } else if (!owner && priv->service_running) { + /* service went away */ + priv->service_running = FALSE; + _LOGI ("VPN service disappeared"); + nm_vpn_connection_disconnect (self, NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED, FALSE); + } + + g_free (owner); +} + + +static gboolean +_daemon_exec_timeout (gpointer data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (data); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + _LOGW ("Timed out waiting for the service to start"); + priv->start_timeout = 0; + nm_vpn_connection_disconnect (self, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT, FALSE); + return G_SOURCE_REMOVE; +} + +static int +_get_log_level (void) +{ + NMLogLevel level; + + /* curiously enough, nm-logging also uses syslog. But it + * maps NMLogLevel differently to the syslog levels then we + * do here. + * + * The reason is, that LOG_NOTICE is already something worth + * highlighting in the journal, but we have 3 levels that are + * lower then LOG_NOTICE (LOGL_TRACE, LOGL_DEBUG, LOGL_INFO), + * On the other hand, syslog only defines LOG_DEBUG and LOG_INFO. + * Thus, we must map them differently. + * + * Inside the VPN plugin, you might want to treat LOG_NOTICE as + * as low severity, not worthy to be highlighted (like NM does). */ + + level = nm_logging_get_level (LOGD_VPN_PLUGIN); + if (level != _LOGL_OFF) { + if (level <= LOGL_TRACE) + return LOG_DEBUG; + if (level <= LOGL_DEBUG) + return LOG_INFO; + if (level <= LOGL_INFO) + return LOG_NOTICE; + if (level <= LOGL_WARN) + return LOG_WARNING; + if (level <= LOGL_ERR) + return LOG_ERR; + } + + return LOG_EMERG; +} + +static gboolean +nm_vpn_service_daemon_exec (NMVpnConnection *self, GError **error) +{ + NMVpnConnectionPrivate *priv; + GPid pid; + char *vpn_argv[4]; + gboolean success = FALSE; + GError *spawn_error = NULL; + guint i, j, n_environ; + gs_free char **envp = NULL; + char env_log_level[NM_STRLEN ("NM_VPN_LOG_LEVEL=") + 100]; + char env_log_syslog[NM_STRLEN ("NM_VPN_LOG_SYSLOG=") + 10]; + const int N_ENVIRON_EXTRA = 3; + char **p_environ; + + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), FALSE); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + i = 0; + vpn_argv[i++] = (char *) nm_vpn_plugin_info_get_program (priv->plugin_info); + g_return_val_if_fail (vpn_argv[0], FALSE); + if (nm_vpn_plugin_info_supports_multiple (priv->plugin_info)) { + vpn_argv[i++] = "--bus-name"; + vpn_argv[i++] = priv->bus_name; + } + vpn_argv[i++] = NULL; + + /* we include and "config.h" defines _GNU_SOURCE for us. So, we have @environ. */ + p_environ = environ; + n_environ = p_environ ? g_strv_length (p_environ) : 0; + envp = g_new (char *, n_environ + N_ENVIRON_EXTRA); + for (i = 0, j = 0; j < n_environ; j++) { + if ( g_str_has_prefix (p_environ[j], "NM_VPN_LOG_LEVEL=") + || g_str_has_prefix (p_environ[j], "NM_VPN_LOG_SYSLOG=")) + continue; + envp[i++] = p_environ[j]; + } + + /* NM_VPN_LOG_LEVEL: the syslog logging level for the plugin. */ + envp[i++] = nm_sprintf_buf (env_log_level, "NM_VPN_LOG_LEVEL=%d", _get_log_level ()); + + /* NM_VPN_LOG_SYSLOG: whether to log to stdout or syslog. If NetworkManager itself runs in + * foreground, we also want the plugin to log to stdout. + * If the plugin runs in background, the plugin should prefer logging to syslog. Otherwise + * logging messages will be lost (unless using journald, in which case it wouldn't matter). */ + envp[i++] = nm_sprintf_buf (env_log_syslog, "NM_VPN_LOG_SYSLOG=%c", nm_logging_syslog_enabled () ? '1' : '0'); + + envp[i++] = NULL; + nm_assert (i <= n_environ + N_ENVIRON_EXTRA); + + success = g_spawn_async (NULL, vpn_argv, envp, 0, nm_utils_setpgid, NULL, &pid, &spawn_error); + + if (success) { + _LOGI ("Started the VPN service, PID %ld", (long int) pid); + priv->start_timeout = g_timeout_add_seconds (5, _daemon_exec_timeout, self); + } else { + g_set_error (error, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, + "%s", spawn_error ? spawn_error->message : "unknown g_spawn_async() error"); + + if (spawn_error) + g_error_free (spawn_error); + } + + return success; +} + +static void +on_proxy_acquired (GObject *object, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection *self; + NMVpnConnectionPrivate *priv; + gs_free_error GError *error = NULL; + GDBusProxy *proxy; + + proxy = g_dbus_proxy_new_for_bus_finish (result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_VPN_CONNECTION (user_data); + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (error) { + _LOGE ("failed to acquire dbus proxy for VPN service: %s", + error->message); + _set_vpn_state (self, + STATE_FAILED, + NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, + FALSE); + return; + } + + priv->proxy = proxy; + + g_signal_connect (priv->proxy, "notify::g-name-owner", + G_CALLBACK (_name_owner_changed), self); + _name_owner_changed (G_OBJECT (priv->proxy), NULL, self); + + if (priv->service_running) + return; + + if (!nm_vpn_service_daemon_exec (self, &error)) { + _LOGW ("Could not launch the VPN service. error: %s.", + error->message); + + nm_vpn_connection_disconnect (self, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED, FALSE); + } +} + +void +nm_vpn_connection_activate (NMVpnConnection *self, + NMVpnPluginInfo *plugin_info) +{ + NMVpnConnectionPrivate *priv; + NMSettingVpn *s_vpn; + const char *service; + + g_return_if_fail (NM_IS_VPN_CONNECTION (self)); + g_return_if_fail (NM_IS_VPN_PLUGIN_INFO (plugin_info)); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + g_return_if_fail (!priv->plugin_info); + + s_vpn = nm_connection_get_setting_vpn (_get_applied_connection (self)); + g_return_if_fail (s_vpn); + + service = nm_vpn_plugin_info_get_service (plugin_info); + nm_assert (service); + + if (nm_vpn_plugin_info_supports_multiple (plugin_info)) { + const char *path; + + path = nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)); + if (path) + path = strrchr (path, '/'); + g_return_if_fail (path); + + priv->bus_name = g_strdup_printf ("%s.Connection_%s", service, &path[1]); + } else + priv->bus_name = g_strdup (service); + + priv->connection_can_persist = nm_setting_vpn_get_persistent (s_vpn); + priv->plugin_info = g_object_ref (plugin_info); + priv->cancellable = g_cancellable_new (); + + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + NULL, + priv->bus_name, + NM_VPN_DBUS_PLUGIN_PATH, + NM_VPN_DBUS_PLUGIN_INTERFACE, + priv->cancellable, + (GAsyncReadyCallback) on_proxy_acquired, + self); + + _set_vpn_state (self, STATE_PREPARE, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); +} + +NMVpnConnectionState +nm_vpn_connection_get_vpn_state (NMVpnConnection *self) +{ + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NM_VPN_CONNECTION_STATE_UNKNOWN); + + return _state_to_nm_vpn_state (NM_VPN_CONNECTION_GET_PRIVATE (self)->vpn_state); +} + +const char * +nm_vpn_connection_get_banner (NMVpnConnection *self) +{ + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); + + return NM_VPN_CONNECTION_GET_PRIVATE (self)->banner; +} + +NMProxyConfig * +nm_vpn_connection_get_proxy_config (NMVpnConnection *self) +{ + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); + + return NM_VPN_CONNECTION_GET_PRIVATE (self)->proxy_config; +} + +NMIP4Config * +nm_vpn_connection_get_ip4_config (NMVpnConnection *self) +{ + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); + + return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip4_config; +} + +NMIP6Config * +nm_vpn_connection_get_ip6_config (NMVpnConnection *self) +{ + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); + + return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip6_config; +} + +static int +_get_ip_iface_for_device (NMVpnConnection *self, const char **out_iface) +{ + NMDevice *parent_dev; + int ifindex; + const char *iface; + + nm_assert (NM_IS_VPN_CONNECTION (self)); + + /* the ifindex and the ifname in this case should come together. + * They either must be both set, or none. */ + + parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (self)); + if (!parent_dev) + goto none; + ifindex = nm_device_get_ip_ifindex (parent_dev); + if (ifindex <= 0) + goto none; + iface = nm_device_get_ip_iface (parent_dev); + if (!iface) + goto none; + + NM_SET_OUT (out_iface, iface); + return ifindex; +none: + NM_SET_OUT (out_iface, NULL); + return 0; +} + +const char * +nm_vpn_connection_get_ip_iface (NMVpnConnection *self, gboolean fallback_device) +{ + NMVpnConnectionPrivate *priv; + const char *iface; + + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), NULL); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (priv->ip_iface || !fallback_device) + return priv->ip_iface; + + _get_ip_iface_for_device (self, &iface); + return iface; +} + +int +nm_vpn_connection_get_ip_ifindex (NMVpnConnection *self, gboolean fallback_device) +{ + NMVpnConnectionPrivate *priv; + + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), 0); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (priv->ip_ifindex > 0) + return priv->ip_ifindex; + if (!fallback_device) + return 0; + + return _get_ip_iface_for_device (self, NULL); +} + +guint32 +nm_vpn_connection_get_ip4_internal_gateway (NMVpnConnection *self) +{ + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), 0); + + return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip4_internal_gw; +} + +struct in6_addr * +nm_vpn_connection_get_ip6_internal_gateway (NMVpnConnection *self) +{ + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), 0); + + return NM_VPN_CONNECTION_GET_PRIVATE (self)->ip6_internal_gw; +} + +void +nm_vpn_connection_disconnect (NMVpnConnection *self, + NMVpnConnectionStateReason reason, + gboolean quitting) +{ + g_return_if_fail (NM_IS_VPN_CONNECTION (self)); + + _set_vpn_state (self, STATE_DISCONNECTED, reason, quitting); +} + +gboolean +nm_vpn_connection_deactivate (NMVpnConnection *self, + NMVpnConnectionStateReason reason, + gboolean quitting) +{ + NMVpnConnectionPrivate *priv; + gboolean success = FALSE; + + g_return_val_if_fail (NM_IS_VPN_CONNECTION (self), FALSE); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + if (priv->vpn_state > STATE_UNKNOWN && priv->vpn_state <= STATE_DEACTIVATING) { + _set_vpn_state (self, STATE_DEACTIVATING, reason, quitting); + success = TRUE; + } + return success; +} + +/*****************************************************************************/ + +static void +plugin_need_secrets_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection *self; + NMVpnConnectionPrivate *priv; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + const char *setting_name; + + reply = _nm_dbus_proxy_call_finish (proxy, result, G_VARIANT_TYPE ("(s)"), &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_VPN_CONNECTION (user_data); + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (error) { + g_dbus_error_strip_remote_error (error); + _LOGE ("plugin NeedSecrets request #%d failed: %s", + priv->secrets_idx + 1, + error->message); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); + return; + } + + g_variant_get (reply, "(&s)", &setting_name); + if (!strlen (setting_name)) { + _LOGD ("service indicated no additional secrets required"); + + /* No secrets required; we can start the VPN */ + really_activate (self, priv->username); + return; + } + + /* More secrets required */ + if (priv->secrets_idx == SECRETS_REQ_NEW) { + _LOGE ("final secrets request failed to provide sufficient secrets"); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); + } else { + _LOGD ("service indicated additional secrets required"); + get_secrets (self, priv->secrets_idx + 1, NULL); + } +} + +static void +plugin_new_secrets_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) +{ + NMVpnConnection *self; + NMVpnConnectionPrivate *priv; + gs_unref_variant GVariant *reply = NULL; + gs_free_error GError *error = NULL; + + reply = g_dbus_proxy_call_finish (proxy, result, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_VPN_CONNECTION (user_data); + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + if (error) { + g_dbus_error_strip_remote_error (error); + _LOGE ("sending new secrets to the plugin failed: %s", + error->message); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); + } else + _set_vpn_state (self, STATE_CONNECT, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); +} + +static void +get_secrets_cb (NMSettingsConnection *connection, + NMSettingsConnectionCallId call_id, + const char *agent_username, + const char *setting_name, + GError *error, + gpointer user_data) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (user_data); + NMVpnConnectionPrivate *priv; + GVariant *dict; + + g_return_if_fail (NM_IS_VPN_CONNECTION (self)); + + priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + g_return_if_fail (connection && connection == _get_settings_connection (self, FALSE)); + g_return_if_fail (call_id == priv->secrets_id); + + priv->secrets_id = NULL; + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + if (error && priv->secrets_idx >= SECRETS_REQ_NEW) { + _LOGE ("Failed to request VPN secrets #%d: %s", + priv->secrets_idx + 1, error->message); + _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); + return; + } + + /* Cache the username for later */ + if (agent_username) { + g_free (priv->username); + priv->username = g_strdup (agent_username); + } + + dict = _hash_with_username (_get_applied_connection (self), priv->username); + + if (priv->secrets_idx == SECRETS_REQ_INTERACTIVE) { + _LOGD ("sending secrets to the plugin"); + + /* Send the secrets back to the plugin */ + g_dbus_proxy_call (priv->proxy, + "NewSecrets", + g_variant_new ("(@a{sa{sv}})", dict), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->cancellable, + (GAsyncReadyCallback) plugin_new_secrets_cb, + self); + } else { + _LOGD ("asking service if additional secrets are required"); + + /* Ask the VPN service if more secrets are required */ + g_dbus_proxy_call (priv->proxy, + "NeedSecrets", + g_variant_new ("(@a{sa{sv}})", dict), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->cancellable, + (GAsyncReadyCallback) plugin_need_secrets_cb, + self); + } +} + +static void +get_secrets (NMVpnConnection *self, + SecretsReq secrets_idx, + const char **hints) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; + + g_return_if_fail (secrets_idx < SECRETS_REQ_LAST); + priv->secrets_idx = secrets_idx; + + cancel_get_secrets (self); + + _LOGD ("requesting VPN secrets pass #%d", + priv->secrets_idx + 1); + + switch (priv->secrets_idx) { + case SECRETS_REQ_SYSTEM: + flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM; + break; + case SECRETS_REQ_EXISTING: + flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE; + break; + case SECRETS_REQ_NEW: + case SECRETS_REQ_INTERACTIVE: + flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION; + break; + default: + g_assert_not_reached (); + } + + if (nm_active_connection_get_user_requested (NM_ACTIVE_CONNECTION (self))) + flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED; + + priv->secrets_id = nm_settings_connection_get_secrets (_get_settings_connection (self, FALSE), + _get_applied_connection (self), + nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (self)), + NM_SETTING_VPN_SETTING_NAME, + flags, + hints, + get_secrets_cb, + self); + g_return_if_fail (priv->secrets_id); +} + +static void +plugin_interactive_secrets_required (NMVpnConnection *self, + const char *message, + const char **secrets) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + guint32 secrets_len = secrets ? g_strv_length ((char **) secrets) : 0; + char **hints; + guint32 i; + + _LOGI ("VPN plugin: requested secrets; state %s (%d)", + vpn_state_to_string (priv->vpn_state), priv->vpn_state); + + g_return_if_fail (priv->vpn_state == STATE_CONNECT || + priv->vpn_state == STATE_NEED_AUTH); + + priv->secrets_idx = SECRETS_REQ_INTERACTIVE; + _set_vpn_state (self, STATE_NEED_AUTH, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE); + + /* Copy hints and add message to the end */ + hints = g_malloc0 (sizeof (char *) * (secrets_len + 2)); + for (i = 0; i < secrets_len; i++) + hints[i] = g_strdup (secrets[i]); + if (message) + hints[i] = g_strdup_printf ("x-vpn-message:%s", message); + + get_secrets (self, SECRETS_REQ_INTERACTIVE, (const char **) hints); + g_strfreev (hints); +} + +/*****************************************************************************/ + +static void +device_changed (NMActiveConnection *active, + NMDevice *new_device, + NMDevice *old_device) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE ((NMVpnConnection *) active); + + if (!_service_and_connection_can_persist (NM_VPN_CONNECTION (active))) + return; + if (priv->vpn_state < STATE_CONNECT || priv->vpn_state > STATE_ACTIVATED) + return; + + /* Route-based VPNs must update their routing and send a new IP config + * since all their routes need to be adjusted for new_device. + */ + if (priv->ip_ifindex <= 0) + return; + + /* Device changed underneath the VPN connection. Let the plugin figure + * out that connectivity is down and start its reconnect attempt if it + * needs to. + */ + if (old_device) + remove_parent_device_config (NM_VPN_CONNECTION (active), old_device); + + if (new_device) + apply_parent_device_config (NM_VPN_CONNECTION (active)); +} + +/*****************************************************************************/ + +static void +nm_vpn_connection_init (NMVpnConnection *self) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + priv->vpn_state = STATE_WAITING; + priv->secrets_idx = SECRETS_REQ_SYSTEM; + priv->default_route_manager = g_object_ref (nm_default_route_manager_get ()); + priv->route_manager = g_object_ref (nm_route_manager_get ()); +} + +static void +dispose (GObject *object) +{ + NMVpnConnection *self = NM_VPN_CONNECTION (object); + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + + nm_clear_g_source (&priv->start_timeout); + + g_clear_pointer (&priv->connect_hash, g_variant_unref); + + nm_clear_g_source (&priv->connect_timeout); + + dispatcher_cleanup (self); + + cancel_get_secrets (self); + + if (priv->cancellable) { + g_cancellable_cancel (priv->cancellable); + g_clear_object (&priv->cancellable); + } + g_clear_object (&priv->proxy_config); + nm_exported_object_clear_and_unexport (&priv->ip4_config); + nm_exported_object_clear_and_unexport (&priv->ip6_config); + g_clear_object (&priv->proxy); + g_clear_object (&priv->plugin_info); + + fw_call_cleanup (self); + + G_OBJECT_CLASS (nm_vpn_connection_parent_class)->dispose (object); + + g_clear_object (&priv->default_route_manager); + g_clear_object (&priv->route_manager); +} + +static void +finalize (GObject *object) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE ((NMVpnConnection *) object); + + g_free (priv->banner); + g_free (priv->ip_iface); + g_free (priv->username); + g_free (priv->ip6_internal_gw); + g_free (priv->ip6_external_gw); + + G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object); +} + +static gboolean +ip_config_valid (VpnState state) +{ + return (state == STATE_PRE_UP || state == STATE_ACTIVATED); +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE ((NMVpnConnection *) object); + NMDevice *parent_dev; + + switch (prop_id) { + case PROP_VPN_STATE: + g_value_set_uint (value, _state_to_nm_vpn_state (priv->vpn_state)); + break; + case PROP_BANNER: + g_value_set_string (value, priv->banner ? priv->banner : ""); + break; + case PROP_IP4_CONFIG: + nm_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip4_config : NULL); + break; + case PROP_IP6_CONFIG: + nm_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip6_config : NULL); + break; + case PROP_MASTER: + parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object)); + nm_utils_g_value_set_object_path (value, parent_dev); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (connection_class); + NMActiveConnectionClass *active_class = NM_ACTIVE_CONNECTION_CLASS (connection_class); + + /* virtual methods */ + object_class->get_property = get_property; + object_class->dispose = dispose; + object_class->finalize = finalize; + active_class->device_state_changed = device_state_changed; + active_class->device_changed = device_changed; + + obj_properties[PROP_VPN_STATE] = + g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE, "", "", + NM_VPN_CONNECTION_STATE_UNKNOWN, + NM_VPN_CONNECTION_STATE_DISCONNECTED, + NM_VPN_CONNECTION_STATE_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_BANNER] = + g_param_spec_string (NM_VPN_CONNECTION_BANNER, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + g_object_class_override_property (object_class, PROP_MASTER, + NM_ACTIVE_CONNECTION_MASTER); + g_object_class_override_property (object_class, PROP_IP4_CONFIG, + NM_ACTIVE_CONNECTION_IP4_CONFIG); + g_object_class_override_property (object_class, PROP_IP6_CONFIG, + NM_ACTIVE_CONNECTION_IP6_CONFIG); + + signals[VPN_STATE_CHANGED] = + g_signal_new ("vpn-state-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); + + signals[INTERNAL_STATE_CHANGED] = + g_signal_new (NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); + + signals[INTERNAL_RETRY_AFTER_FAILURE] = + g_signal_new (NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); + + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (connection_class), + NMDBUS_TYPE_VPN_CONNECTION_SKELETON, + NULL); +} diff --git a/src/vpn/nm-vpn-connection.h b/src/vpn/nm-vpn-connection.h new file mode 100644 index 00000000..8393f081 --- /dev/null +++ b/src/vpn/nm-vpn-connection.h @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2011 Red Hat, Inc. + * Copyright (C) 2006 - 2008 Novell, Inc. + */ + +#ifndef __NM_VPN_CONNECTION_H__ +#define __NM_VPN_CONNECTION_H__ + +#include "nm-vpn-dbus-interface.h" +#include "devices/nm-device.h" +#include "nm-auth-subject.h" +#include "nm-active-connection.h" +#include "nm-vpn-plugin-info.h" + +#define NM_VPN_ROUTE_METRIC_DEFAULT 50 + +#define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ()) +#define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVpnConnection)) +#define NM_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_CONNECTION, NMVpnConnectionClass)) +#define NM_IS_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_CONNECTION)) +#define NM_IS_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_CONNECTION)) +#define NM_VPN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION, NMVpnConnectionClass)) + +/* Properties */ +#define NM_VPN_CONNECTION_VPN_STATE "vpn-state" +#define NM_VPN_CONNECTION_BANNER "banner" + +/* Signals */ +/* not exported: includes old reason code */ +#define NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED "internal-state-changed" +#define NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE "internal-retry-after-failure" + +typedef struct _NMVpnConnectionClass NMVpnConnectionClass; + +GType nm_vpn_connection_get_type (void); + +NMVpnConnection * nm_vpn_connection_new (NMSettingsConnection *settings_connection, + NMDevice *parent_device, + const char *specific_object, + NMAuthSubject *subject); + +void nm_vpn_connection_activate (NMVpnConnection *self, + NMVpnPluginInfo *plugin_info); +NMVpnConnectionState nm_vpn_connection_get_vpn_state (NMVpnConnection *self); +const char * nm_vpn_connection_get_banner (NMVpnConnection *self); +const gchar * nm_vpn_connection_get_service (NMVpnConnection *self); + +gboolean nm_vpn_connection_deactivate (NMVpnConnection *self, + NMVpnConnectionStateReason reason, + gboolean quitting); +void nm_vpn_connection_disconnect (NMVpnConnection *self, + NMVpnConnectionStateReason reason, + gboolean quitting); + +NMProxyConfig * nm_vpn_connection_get_proxy_config (NMVpnConnection *self); + +NMIP4Config * nm_vpn_connection_get_ip4_config (NMVpnConnection *self); +NMIP6Config * nm_vpn_connection_get_ip6_config (NMVpnConnection *self); +const char * nm_vpn_connection_get_ip_iface (NMVpnConnection *self, gboolean fallback_device); +int nm_vpn_connection_get_ip_ifindex (NMVpnConnection *self, gboolean fallback_device); +guint32 nm_vpn_connection_get_ip4_internal_gateway (NMVpnConnection *self); +struct in6_addr * nm_vpn_connection_get_ip6_internal_gateway (NMVpnConnection *self); + +guint32 nm_vpn_connection_get_ip4_route_metric (NMVpnConnection *self); +guint32 nm_vpn_connection_get_ip6_route_metric (NMVpnConnection *self); + +#endif /* __NM_VPN_CONNECTION_H__ */ diff --git a/src/vpn/nm-vpn-manager.c b/src/vpn/nm-vpn-manager.c new file mode 100644 index 00000000..8e708d12 --- /dev/null +++ b/src/vpn/nm-vpn-manager.c @@ -0,0 +1,295 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2012 Red Hat, Inc. + * Copyright (C) 2006 - 2008 Novell, Inc. + */ + +#include "nm-default.h" + +#include "nm-vpn-manager.h" + +#include + +#include "nm-vpn-plugin-info.h" +#include "nm-vpn-connection.h" +#include "nm-setting-vpn.h" +#include "nm-vpn-dbus-interface.h" +#include "nm-core-internal.h" + +typedef struct { + GSList *plugins; + GFileMonitor *monitor_etc; + GFileMonitor *monitor_lib; + gulong monitor_id_etc; + gulong monitor_id_lib; + + /* This is only used for services that don't support multiple + * connections, to guard access to them. */ + GHashTable *active_services; +} NMVpnManagerPrivate; + +struct _NMVpnManager { + GObject parent; + NMVpnManagerPrivate _priv; +}; + +struct _NMVpnManagerClass { + GObjectClass parent; +}; + +G_DEFINE_TYPE (NMVpnManager, nm_vpn_manager, G_TYPE_OBJECT) + +#define NM_VPN_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMVpnManager, NM_IS_VPN_MANAGER) + +/*****************************************************************************/ + +static void +vpn_state_changed (NMVpnConnection *vpn, + GParamSpec *pspec, + NMVpnManager *manager) +{ + NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (manager); + NMActiveConnectionState state = nm_active_connection_get_state (NM_ACTIVE_CONNECTION (vpn)); + const char *service_name = nm_vpn_connection_get_service (vpn); + + if (state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { + g_hash_table_remove (priv->active_services, service_name); + g_signal_handlers_disconnect_by_func (vpn, vpn_state_changed, manager); + g_object_unref (manager); + } +} + +gboolean +nm_vpn_manager_activate_connection (NMVpnManager *manager, + NMVpnConnection *vpn, + GError **error) +{ + NMVpnManagerPrivate *priv; + NMVpnPluginInfo *plugin_info; + const char *service_name; + NMDevice *device; + + g_return_val_if_fail (NM_IS_VPN_MANAGER (manager), FALSE); + g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), FALSE); + g_return_val_if_fail (!error || !*error, FALSE); + + priv = NM_VPN_MANAGER_GET_PRIVATE (manager); + device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (vpn)); + g_assert (device); + if ( nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED + && nm_device_get_state (device) != NM_DEVICE_STATE_SECONDARIES) { + g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_DEPENDENCY_FAILED, + "The base device for the VPN connection was not active."); + return FALSE; + } + + service_name = nm_vpn_connection_get_service (vpn); + + plugin_info = nm_vpn_plugin_info_list_find_by_service (priv->plugins, service_name); + if (!plugin_info) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, + "The VPN service '%s' was not installed.", + service_name); + return FALSE; + } + + if ( !nm_vpn_plugin_info_supports_multiple (plugin_info) + && g_hash_table_contains (priv->active_services, service_name)) { + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, + "The '%s' plugin only supports a single active connection.", + nm_vpn_plugin_info_get_name (plugin_info)); + return FALSE; + } + + nm_vpn_connection_activate (vpn, plugin_info); + + if (!nm_vpn_plugin_info_supports_multiple (plugin_info)) { + /* Block activations of the connections of the same service type. */ + g_hash_table_add (priv->active_services, g_strdup (service_name)); + g_signal_connect (vpn, "notify::" NM_ACTIVE_CONNECTION_STATE, + G_CALLBACK (vpn_state_changed), + g_object_ref (manager)); + } + + return TRUE; +} + +/*****************************************************************************/ + +static void +try_add_plugin (NMVpnManager *self, NMVpnPluginInfo *plugin_info) +{ + NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); + const char *program; + + program = nm_vpn_plugin_info_get_program (plugin_info); + if (!program || !*program) + return; + + /* Make sure we don't add dupes. + * We don't really allow reload of the same file. What we do allow is however to + * delete a file and re-add it. */ + if (nm_vpn_plugin_info_list_find_by_filename (priv->plugins, + nm_vpn_plugin_info_get_filename (plugin_info))) + return; + if (!nm_vpn_plugin_info_list_add (&priv->plugins, plugin_info, NULL)) + return; +} + +static void +vpn_dir_changed (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type, + gpointer user_data) +{ + NMVpnManager *self = NM_VPN_MANAGER (user_data); + NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); + NMVpnPluginInfo *plugin_info; + gs_free char *path = NULL; + GError *error = NULL; + + path = g_file_get_path (file); + if (!nm_vpn_plugin_info_validate_filename (path)) + return; + + switch (event_type) { + case G_FILE_MONITOR_EVENT_DELETED: + plugin_info = nm_vpn_plugin_info_list_find_by_filename (priv->plugins, path); + if (!plugin_info) + break; + + nm_log_dbg (LOGD_VPN, "vpn: service file %s deleted", path); + nm_vpn_plugin_info_list_remove (&priv->plugins, plugin_info); + break; + case G_FILE_MONITOR_EVENT_CREATED: + case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: + plugin_info = nm_vpn_plugin_info_list_find_by_filename (priv->plugins, path); + if (plugin_info) { + /* we don't support reloading an existing plugin. You can only remove the file + * and re-add it. By reloading we want to support the use case of installing + * a VPN plugin after NM started. No need to burden ourself with a complete + * reload. */ + break; + } + + if (!_nm_vpn_plugin_info_check_file (path, TRUE, TRUE, 0, + NULL, NULL, &error)) { + nm_log_dbg (LOGD_VPN, "vpn: ignore changed service file %s (%s)", path, error->message); + g_clear_error (&error); + break; + } + plugin_info = nm_vpn_plugin_info_new_from_file (path, &error); + if (!plugin_info) { + nm_log_dbg (LOGD_VPN, "vpn: ignore changed service file %s due to invalid content (%s)", path, error->message); + g_clear_error (&error); + break; + } + + nm_log_dbg (LOGD_VPN, "vpn: service file %s created or modified", path); + try_add_plugin (self, plugin_info); + g_object_unref (plugin_info); + break; + default: + nm_log_dbg (LOGD_VPN, "vpn: service file %s change event %d", path, event_type); + break; + } +} + +/*****************************************************************************/ + +NM_DEFINE_SINGLETON_GETTER (NMVpnManager, nm_vpn_manager_get, NM_TYPE_VPN_MANAGER); + +static void +nm_vpn_manager_init (NMVpnManager *self) +{ + NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); + GFile *file; + GSList *infos, *info; + const char *conf_dir_etc = _nm_vpn_plugin_info_get_default_dir_etc (); + const char *conf_dir_lib = _nm_vpn_plugin_info_get_default_dir_lib (); + + /* Watch the VPN directory for changes */ + file = g_file_new_for_path (conf_dir_lib); + priv->monitor_lib = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); + g_object_unref (file); + if (priv->monitor_lib) { + priv->monitor_id_lib = g_signal_connect (priv->monitor_lib, "changed", + G_CALLBACK (vpn_dir_changed), self); + } + + file = g_file_new_for_path (conf_dir_etc); + priv->monitor_etc = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); + g_object_unref (file); + if (priv->monitor_etc) { + priv->monitor_id_etc = g_signal_connect (priv->monitor_etc, "changed", + G_CALLBACK (vpn_dir_changed), self); + } + + /* first read conf_dir_lib. The name files are not really user configuration, but + * plugin configuration. Hence we expect ~newer~ plugins to install their files + * in /usr/lib/NetworkManager. We want to prefer those files. + * In case of no-conflict, the order doesn't matter. */ + infos = _nm_vpn_plugin_info_list_load_dir (conf_dir_lib, TRUE, 0, NULL, NULL); + for (info = infos; info; info = info->next) + try_add_plugin (self, info->data); + g_slist_free_full (infos, g_object_unref); + + infos = _nm_vpn_plugin_info_list_load_dir (conf_dir_etc, TRUE, 0, NULL, NULL); + for (info = infos; info; info = info->next) + try_add_plugin (self, info->data); + g_slist_free_full (infos, g_object_unref); + + priv->active_services = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); +} + +static void +dispose (GObject *object) +{ + NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE ((NMVpnManager *) object); + + if (priv->monitor_etc) { + if (priv->monitor_id_etc) + g_signal_handler_disconnect (priv->monitor_etc, priv->monitor_id_etc); + g_file_monitor_cancel (priv->monitor_etc); + g_clear_object (&priv->monitor_etc); + } + + if (priv->monitor_lib) { + if (priv->monitor_id_lib) + g_signal_handler_disconnect (priv->monitor_lib, priv->monitor_id_lib); + g_file_monitor_cancel (priv->monitor_lib); + g_clear_object (&priv->monitor_lib); + } + + while (priv->plugins) + nm_vpn_plugin_info_list_remove (&priv->plugins, priv->plugins->data); + + g_hash_table_unref (priv->active_services); + + G_OBJECT_CLASS (nm_vpn_manager_parent_class)->dispose (object); +} + +static void +nm_vpn_manager_class_init (NMVpnManagerClass *manager_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (manager_class); + + object_class->dispose = dispose; +} + diff --git a/src/vpn/nm-vpn-manager.h b/src/vpn/nm-vpn-manager.h new file mode 100644 index 00000000..8b1bec1e --- /dev/null +++ b/src/vpn/nm-vpn-manager.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2005 - 2011 Red Hat, Inc. + * Copyright (C) 2006 - 2008 Novell, Inc. + */ + +#ifndef __NM_VPN_MANAGER_H__ +#define __NM_VPN_MANAGER_H__ + +#include "nm-vpn-connection.h" + +#define NM_TYPE_VPN_MANAGER (nm_vpn_manager_get_type ()) +#define NM_VPN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_MANAGER, NMVpnManager)) +#define NM_VPN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_MANAGER, NMVpnManagerClass)) +#define NM_IS_VPN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_MANAGER)) +#define NM_IS_VPN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_MANAGER)) +#define NM_VPN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_MANAGER, NMVpnManagerClass)) + +typedef struct _NMVpnManager NMVpnManager; +typedef struct _NMVpnManagerClass NMVpnManagerClass; + +GType nm_vpn_manager_get_type (void); + +NMVpnManager *nm_vpn_manager_get (void); + +gboolean nm_vpn_manager_activate_connection (NMVpnManager *manager, + NMVpnConnection *vpn, + GError **error); + +#endif /* __NM_VPN_MANAGER_H__ */ -- cgit 1.3.0-6-gf8a5