diff options
Diffstat (limited to 'src/settings/plugins')
103 files changed, 2510 insertions, 5363 deletions
diff --git a/src/settings/plugins/Makefile.am b/src/settings/plugins/Makefile.am index 568da7f6..278d455d 100644 --- a/src/settings/plugins/Makefile.am +++ b/src/settings/plugins/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=keyfile example +SUBDIRS=keyfile @GNOME_CODE_COVERAGE_RULES@ @@ -10,10 +10,6 @@ if CONFIG_PLUGIN_IFCFG_RH SUBDIRS+=ifcfg-rh endif -if CONFIG_PLUGIN_IFCFG_SUSE -SUBDIRS+=ifcfg-suse -endif - if CONFIG_PLUGIN_IFUPDOWN SUBDIRS+=ifupdown endif diff --git a/src/settings/plugins/Makefile.in b/src/settings/plugins/Makefile.in index c706214b..643e0da7 100644 --- a/src/settings/plugins/Makefile.in +++ b/src/settings/plugins/Makefile.in @@ -89,9 +89,8 @@ 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_IFCFG_SUSE_TRUE@am__append_3 = ifcfg-suse -@CONFIG_PLUGIN_IFUPDOWN_TRUE@am__append_4 = ifupdown -@CONFIG_PLUGIN_IFNET_TRUE@am__append_5 = ifnet +@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/ax_lib_readline.m4 \ @@ -168,8 +167,8 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = keyfile example ibft ifcfg-rh ifcfg-suse ifupdown ifnet -am__DIST_COMMON = $(srcdir)/Makefile.in +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`; \ @@ -211,7 +210,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -223,8 +221,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -234,6 +230,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -288,16 +285,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -334,6 +328,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -362,7 +358,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -377,6 +372,8 @@ 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@ @@ -437,6 +434,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -444,6 +442,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -459,8 +458,8 @@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ -SUBDIRS = keyfile example $(am__append_1) $(am__append_2) \ - $(am__append_3) $(am__append_4) $(am__append_5) +SUBDIRS = keyfile $(am__append_1) $(am__append_2) $(am__append_3) \ + $(am__append_4) all: all-recursive .SUFFIXES: diff --git a/src/settings/plugins/README b/src/settings/plugins/README new file mode 100644 index 00000000..307d0bb1 --- /dev/null +++ b/src/settings/plugins/README @@ -0,0 +1,33 @@ +Plugins generally have three components: + +1) plugin object: manages the individual "connections", which are + just objects wrapped around on-disk config data. The plugin handles requests + to add new connections via the NM D-Bus API, and also watches config + directories for changes to configuration data. Plugins implement the + NMSettingsPlugin interface. See plugin.c. + +2) "connections": subclasses of NMSettingsConnection. They handle updates to + configuration data, deletion, etc. See NMKeyfileConnection. + +3) reader/writer code: typically a separate static library that gets linked + into the main plugin shared object, so they can be unit tested separately + from the plugin. This code should read config data from disk and create + an NMConnection from it, and be capable of taking an NMConnection and writing + out appropriate configuration data to disk. + +NM will first call the "factory" function that every module must provide, which +is nm_settings_plugin_factory(). That function creates and returns a singleton +instance of the plugin's main object, which implements NMSettingsPlugin. +That interface is implemented via the object definition in G_DEFINE_TYPE_EXTENDED +in plugin.c, which registers the interface setup function +settings_plugin_interface_init(), which when called actually sets up the vtables +for the functions defined by NMSettingsPluginInterface. Thus there are two +entry points into the plugin: nm_settings_plugin_factory() and +the NMSettingsPluginInterface methods. + +The plugin also emits various signals (defined by NMSettingsPluginInterface) +which NetworkManager listens for. These include notifications of new +connections if they were created via changes to the on-disk files. The +"connection" objects can also emit signals (defined by the NMSettingsConnection +and NMConnection superclasses) when the connections' backing storage gets +changed or deleted. diff --git a/src/settings/plugins/example/Makefile.am b/src/settings/plugins/example/Makefile.am deleted file mode 100644 index 7ce8eaea..00000000 --- a/src/settings/plugins/example/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-example"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ - -DNMCONFDIR=\"$(nmconfdir)\" - -# 'noinst' here because this is an example plugin we don't want to install -noinst_LTLIBRARIES = libnm-settings-plugin-example.la - -# The actual plugins typically pull reader.c and writer.c out into -# their own static library so that unit tests can use them without -# having to build the entire plugin. But since this is a simple -# plugin we don't do that yet. - -libnm_settings_plugin_example_la_SOURCES = \ - nm-example-connection.c \ - nm-example-connection.h \ - plugin.c \ - plugin.h \ - common.h \ - reader.c \ - writer.c - -libnm_settings_plugin_example_la_LDFLAGS = -module -avoid-version - diff --git a/src/settings/plugins/example/Makefile.in b/src/settings/plugins/example/Makefile.in deleted file mode 100644 index 5f16d186..00000000 --- a/src/settings/plugins/example/Makefile.in +++ /dev/null @@ -1,779 +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/example -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_warnings.m4 \ - $(top_srcdir)/m4/gettext.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) -libnm_settings_plugin_example_la_LIBADD = -am_libnm_settings_plugin_example_la_OBJECTS = \ - nm-example-connection.lo plugin.lo reader.lo writer.lo -libnm_settings_plugin_example_la_OBJECTS = \ - $(am_libnm_settings_plugin_example_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_example_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_example_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_settings_plugin_example_la_SOURCES) -DIST_SOURCES = $(libnm_settings_plugin_example_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 README -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@ -CKDB_PATH = @CKDB_PATH@ -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_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ -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@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -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@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_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@ -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_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@ -PPPOE_PATH = @PPPOE_PATH@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -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_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@ -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@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -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_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-example"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ - -DNMCONFDIR=\"$(nmconfdir)\" - - -# 'noinst' here because this is an example plugin we don't want to install -noinst_LTLIBRARIES = libnm-settings-plugin-example.la - -# The actual plugins typically pull reader.c and writer.c out into -# their own static library so that unit tests can use them without -# having to build the entire plugin. But since this is a simple -# plugin we don't do that yet. -libnm_settings_plugin_example_la_SOURCES = \ - nm-example-connection.c \ - nm-example-connection.h \ - plugin.c \ - plugin.h \ - common.h \ - reader.c \ - writer.c - -libnm_settings_plugin_example_la_LDFLAGS = -module -avoid-version -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/settings/plugins/example/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/example/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}; \ - } - -libnm-settings-plugin-example.la: $(libnm_settings_plugin_example_la_OBJECTS) $(libnm_settings_plugin_example_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_example_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_example_la_LINK) $(libnm_settings_plugin_example_la_OBJECTS) $(libnm_settings_plugin_example_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-example-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)/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 - -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: -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-noinstLTLIBRARIES \ - 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: install-am install-strip - -.PHONY: 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-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 \ - 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/settings/plugins/example/README b/src/settings/plugins/example/README deleted file mode 100644 index 224814d1..00000000 --- a/src/settings/plugins/example/README +++ /dev/null @@ -1,35 +0,0 @@ -Plugins generally have three components: - -1) plugin object: manages the individual "connections", which are - just objects wrapped around on-disk config data. The plugin handles requests - to add new connections via the NM D-Bus API, and also watches config - directories for changes to configuration data. It also handles reading and - writing the persistent hostname, if the plugin supports hostnames. Plugins - implement the NMSystemConfigInterface interface. See plugin.c. - -2) "connections": subclasses of NMSettingsConnection. They handle updates to - configuration data, deletion, etc. See NMExampleConnection.c. - -3) reader/writer code: typically a separate static library that gets linked - into the main plugin shared object, so they can be unit tested separately - from the plugin. This code should read config data from disk and create - an NMConnection from it, and be capable of taking an NMConnection and writing - out appropriate configuration data to disk. - -NM will first call the "factory" function that every module must provide, which -is nm_system_config_factory(). That function creates and returns a singleton -instance of the plugin's main object, which implements NMSystemConfigInterface. -That interface is implemented via the object definition in G_DEFINE_TYPE_EXTENDED -in plugin.c, which registers the interface setup function -system_config_interface_init(), which when called actually sets up the vtables -for the functions defined by NMSystemConfigInterface. Thus there are two -entry points into the plugin: nm_system_config_factory() and -the NMSystemConfigInterface methods. - -The plugin also emits various signals (defined by NMSystemConfigInterface) -which NetworkManager listens for. These include persistent hostname changes -(if something modified the file in which the persistent hostname is stored) -and notifications of new connections if they were created via changes to -the on-disk files. The "connection" objects can also emit signals -(defined by the NMSettingsConnection and NMConnection superclasses) when the -connections' backing storage gets changed or deleted. diff --git a/src/settings/plugins/example/common.h b/src/settings/plugins/example/common.h deleted file mode 100644 index cf209fe0..00000000 --- a/src/settings/plugins/example/common.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. - * - * (C) Copyright 2012 Red Hat, Inc. - */ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#include <glib.h> - -#include <nm-connection.h> - -/* General info about the plugin that the code may want to use for logging - * purposes. - */ -#define EXAMPLE_PLUGIN_NAME "example" -#define EXAMPLE_PLUGIN_INFO "(c) 2012 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." - -#define EXAMPLE_DIR NMCONFDIR "/example-plugin" - -/* Prototypes for the reader/writer functions */ -NMConnection *connection_from_file (const char *filename, GError **error); - -gboolean write_connection (NMConnection *connection, - const char *existing_path, - char **out_path, - GError **error); - -#endif /* __COMMON_H__ */ - diff --git a/src/settings/plugins/example/nm-example-connection.c b/src/settings/plugins/example/nm-example-connection.c deleted file mode 100644 index e1259611..00000000 --- a/src/settings/plugins/example/nm-example-connection.c +++ /dev/null @@ -1,189 +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) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <string.h> -#include <glib/gstdio.h> -#include <nm-dbus-interface.h> -#include <nm-setting-connection.h> -#include <nm-utils.h> - -#include "nm-system-config-interface.h" -#include "nm-dbus-glib-types.h" -#include "nm-example-connection.h" -#include "common.h" - -/* GObject boilerplate; this object is a subclass of NMSettingsConnection - * which is specified by the NM_TYPE_SETTINGS_CONNECTION bit here. That - * in turn is a subclass of NMConnection, so it ends up that NMExampleConnection - * is a subclass of NMConnection too. - */ -G_DEFINE_TYPE (NMExampleConnection, nm_example_connection, NM_TYPE_SETTINGS_CONNECTION) - -#define NM_EXAMPLE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnectionPrivate)) - -/* Object private instance data */ -typedef struct { - char *path; -} NMExampleConnectionPrivate; - - -/* Creates a new object which encapsulates an on-disk connection and any - * plugin-specific operations or data. - */ -NMExampleConnection * -nm_example_connection_new (const char *full_path, - NMConnection *source, - GError **error) -{ - GObject *object; - NMExampleConnectionPrivate *priv; - NMConnection *tmp; - const char *uuid; - - g_return_val_if_fail (full_path != NULL, NULL); - - /* If we're given a connection already, prefer that instead of re-reading */ - if (source) - tmp = g_object_ref (source); - else { - /* Read the data offdisk and translate it into a simple NMConnection object */ - tmp = connection_from_file (full_path, error); - if (!tmp) - return NULL; - } - - /* Actually create the new NMExampleConnection object */ - object = (GObject *) g_object_new (NM_TYPE_EXAMPLE_CONNECTION, NULL); - priv = NM_EXAMPLE_CONNECTION_GET_PRIVATE (object); - priv->path = g_strdup (full_path); - - /* Update our settings with what was read from the file or what got passed - * in as a source NMConnection. - */ - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - TRUE, - NULL, - error)) { - g_object_unref (object); - object = NULL; - goto out; - } - - /* Make sure we have a UUID; just a sanity check */ - uuid = nm_connection_get_uuid (NM_CONNECTION (object)); - 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 (object); - object = NULL; - } - -out: - g_object_unref (tmp); - return (NMExampleConnection *) object; -} - -const char * -nm_example_connection_get_path (NMExampleConnection *self) -{ - g_return_val_if_fail (NM_IS_EXAMPLE_CONNECTION (self), NULL); - - /* Simple accessor that returns the file path from our private instance data */ - return NM_EXAMPLE_CONNECTION_GET_PRIVATE (self)->path; -} - -static void -commit_changes (NMSettingsConnection *connection, - NMSettingsConnectionCommitFunc callback, - gpointer user_data) -{ - NMExampleConnectionPrivate *priv = NM_EXAMPLE_CONNECTION_GET_PRIVATE (connection); - char *path = NULL; - GError *error = NULL; - - /* Write the new connection data out to disk. This function passes - * back the path of the file it wrote out so that we know what that - * path is if the connection is a completely new one. - */ - if (!write_connection (NM_CONNECTION (connection), priv->path, &path, &error)) { - callback (connection, error, user_data); - g_clear_error (&error); - return; - } - - /* Update the filename if it changed */ - if (path) { - g_free (priv->path); - priv->path = path; - } - - /* Chain up to parent for generic commit stuff */ - NM_SETTINGS_CONNECTION_CLASS (nm_example_connection_parent_class)->commit_changes (connection, - callback, - user_data); -} - -static void -do_delete (NMSettingsConnection *connection, - NMSettingsConnectionDeleteFunc callback, - gpointer user_data) -{ - NMExampleConnectionPrivate *priv = NM_EXAMPLE_CONNECTION_GET_PRIVATE (connection); - - g_unlink (priv->path); - - /* Chain up to parent for generic deletion stuff */ - NM_SETTINGS_CONNECTION_CLASS (nm_example_connection_parent_class)->delete (connection, - callback, - user_data); -} - -/**************************************************************/ - -static void -nm_example_connection_init (NMExampleConnection *connection) -{ -} - -static void -finalize (GObject *object) -{ - g_free (NM_EXAMPLE_CONNECTION_GET_PRIVATE (object)->path); - - G_OBJECT_CLASS (nm_example_connection_parent_class)->finalize (object); -} - -static void -nm_example_connection_class_init (NMExampleConnectionClass *keyfile_connection_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (keyfile_connection_class); - NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (keyfile_connection_class); - - /* Tells GObject to allocate and zero our instance data pointer */ - g_type_class_add_private (keyfile_connection_class, sizeof (NMExampleConnectionPrivate)); - - /* Overrides of various superclass methods */ - object_class->finalize = finalize; - settings_class->commit_changes = commit_changes; - settings_class->delete = do_delete; -} diff --git a/src/settings/plugins/example/nm-example-connection.h b/src/settings/plugins/example/nm-example-connection.h deleted file mode 100644 index ddbd7ac2..00000000 --- a/src/settings/plugins/example/nm-example-connection.h +++ /dev/null @@ -1,55 +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) 2012 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_EXAMPLE_CONNECTION_H__ -#define __NETWORKMANAGER_EXAMPLE_CONNECTION_H__ - -#include <nm-settings-connection.h> - -G_BEGIN_DECLS - -/* GObject boilerplate */ -#define NM_TYPE_EXAMPLE_CONNECTION (nm_example_connection_get_type ()) -#define NM_EXAMPLE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnection)) -#define NM_EXAMPLE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnectionClass)) -#define NM_IS_EXAMPLE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXAMPLE_CONNECTION)) -#define NM_IS_EXAMPLE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_EXAMPLE_CONNECTION)) -#define NM_EXAMPLE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnectionClass)) - -typedef struct { - NMSettingsConnection parent; -} NMExampleConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMExampleConnectionClass; - -GType nm_example_connection_get_type (void); - -/* Actual API that plugin.c will call */ -NMExampleConnection *nm_example_connection_new (const char *filename, - NMConnection *source, - GError **error); - -const char *nm_example_connection_get_path (NMExampleConnection *self); - -G_END_DECLS - -#endif /* __NETWORKMANAGER_EXAMPLE_CONNECTION_H__ */ diff --git a/src/settings/plugins/example/plugin.c b/src/settings/plugins/example/plugin.c deleted file mode 100644 index 0bcb38fc..00000000 --- a/src/settings/plugins/example/plugin.c +++ /dev/null @@ -1,858 +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) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <sys/stat.h> -#include <unistd.h> -#include <sys/types.h> -#include <string.h> - -#include <gmodule.h> -#include <glib.h> -#include <glib/gstdio.h> -#include <gio/gio.h> - -#include <nm-connection.h> -#include <nm-setting.h> -#include <nm-setting-connection.h> -#include <nm-utils.h> -#include <nm-config.h> -#include <nm-logging.h> - -#include "plugin.h" -#include "nm-system-config-interface.h" -#include "common.h" -#include "nm-example-connection.h" - -static char *plugin_get_hostname (SCPluginExample *plugin); -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); - -/* GObject object definition. This actually defines the object and tells - * GObject about the interfaces this object provides. Here we provide - * the "system config interface" which is the API that NetworkManager uses - * to communicate with this plugin. - * - * Interface and super/sub-class access with GObject works via casting and - * GObject magically figures out what needs to be called. So, given: - * - * SCPluginExample *plugin = <new plugin>; - * - * you can call GObject methods since SCPluginExample inherits from GObject - * via the G_TYPE_OBJECT argument of G_DEFINE_TYPE_EXTENDED below: - * - * g_object_set_data (G_OBJECT (plugin), ...); - * - * and since SCPluginExample implements NMSystemConfigInterface via the - * G_IMPLEMENT_INTERFACE bit below, we can also call any methods of - * NMSystemConfigInterface (defined in NM sources in nm-system-config-interface.c): - * - * connections = nm_system_config_interface_get_connections (NM_SYSTEM_CONFIG_INTERFACE (plugin)); - * - * For the call to nm_system_config_interface_get_connections() that eventually - * ends up in the get_connections() method in this file because the - * system_config_interface_init() function sets up the vtable for this objects - * implementation of NMSystemConfigInterface. - */ -G_DEFINE_TYPE_EXTENDED (SCPluginExample, sc_plugin_example, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init)) - -/* Quick define to access the object's private data pointer; this pointer - * points to the object's instance data. - */ -#define SC_PLUGIN_EXAMPLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExamplePrivate)) - -/* Instance data. When the object is created, a new structure of this type - * will be created and zeroed for this instance of the object to use. This - * is actually done by g_type_class_add_private() when called from the object's - * class init function. - */ -typedef struct { - /* This hash holds each connection known to this plugin */ - GHashTable *connections; - - /* A watch for changes on the directory that holds the configuration files - * so the plugin can respond to configuration changes on-the-fly and - * tell NM that the connection data has changed. Typically the plugin - * needs to monitor the directory itself (to watch for completely new files) - * while the individual connections watch their individual config files. - */ - GFileMonitor *monitor; - guint monitor_id; - - /* Tracks changes to the global NM config file, just in case our - * plugin has some specific options (like unmanaged devices) that - * might be changed at runtime. - */ - const char *conf_file; - GFileMonitor *conf_file_monitor; - guint conf_file_monitor_id; - - /* Persistent hostname if the plugin supports hostnames. Normally used - * for distro plugins; ie Red Hat uses /etc/sysconfig/hostname while - * Debian uses /etc/hostname. Plugins can abstract the storage location - * and just tell NM what the persisten hostname is and when its backing - * file has changed. NM handles actually setting the hostname. - */ - char *hostname; -} SCPluginExamplePrivate; - -static NMSettingsConnection * -_internal_new_connection (SCPluginExample *self, - const char *full_path, - NMConnection *source, - GError **error) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - NMExampleConnection *connection; - - g_return_val_if_fail (full_path != NULL, NULL); - - /* 'source' will usually be NULL if we're going to read the connection - * off disk. But if the new connection is coming from NetworkManager - * (ie, from a D-Bus AddConnection request) then we'll have 'source' too. - * This function expects the connection to already be written to disk - * so that the NMExampleConnection object can re-read it and intialize - * state in the same manner as when getting a change notification from - * the config directory. That simplifies things somewhat. - */ - - connection = nm_example_connection_new (full_path, source, error); - if (connection) { - g_hash_table_insert (priv->connections, - g_strdup (nm_example_connection_get_path (connection)), - connection); - } - - return (NMSettingsConnection *) connection; -} - -/* Read each file in our config directory and try to create a new - * NMExamplePlugin for it. - */ -static void -read_connections (NMSystemConfigInterface *config) -{ - SCPluginExample *self = SC_PLUGIN_EXAMPLE (config); - GDir *dir; - GError *error = NULL; - const char *item; - - dir = g_dir_open (EXAMPLE_DIR, 0, &error); - if (!dir) { - nm_log_warn (LOGD_SETTINGS, "Cannot read directory '%s': (%d) %s", - EXAMPLE_DIR, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); - g_clear_error (&error); - return; - } - - while ((item = g_dir_read_name (dir))) { - NMSettingsConnection *connection; - char *full_path; - - /* XXX: Check file extension and ignore "~", ".tmp", ".bak", etc */ - - full_path = g_build_filename (EXAMPLE_DIR, item, NULL); - nm_log_info (LOGD_SETTINGS, "parsing %s ... ", item); - - connection = _internal_new_connection (self, full_path, NULL, &error); - if (connection) { - nm_log_info (LOGD_SETTINGS, " read connection '%s'", - nm_connection_get_id (NM_CONNECTION (connection))); - } else { - nm_log_info (LOGD_SETTINGS, " error: %s", - (error && error->message) ? error->message : "(unknown)"); - } - g_clear_error (&error); - g_free (full_path); - } - g_dir_close (dir); -} - -static void -update_connection_settings_commit_cb (NMSettingsConnection *orig, GError *error, gpointer user_data) -{ - /* If there was an error updating the connection's internal stuff, then - * we can't do anything except log it and remove the connection. This might - * happen due to invalid data, but as the data would already have been - * verified before it ever got to this plugin, we shouldn't ever get - * an error here. - */ - if (error) { - nm_log_warn (LOGD_SETTINGS, "%s: connection invalid: %s", - __func__, error->message); - g_clear_error (&error); - - nm_settings_connection_signal_remove (orig); - } -} - -static void -update_connection_settings (NMExampleConnection *orig, - NMExampleConnection *new) -{ - /* This just replaces the orig's internal settings with those from new */ - nm_settings_connection_replace_and_commit (NM_SETTINGS_CONNECTION (orig), - NM_CONNECTION (new), - update_connection_settings_commit_cb, NULL); -} - -/* Monitoring */ - -static void -remove_connection (SCPluginExample *self, - NMExampleConnection *connection, - const char *name) -{ - g_return_if_fail (connection != NULL); - g_return_if_fail (name != NULL); - - /* Removing from the hash table should drop the last reference, but since - * we need the object to stay alive across the signal emission to NM, - * we grab a temporary reference. - */ - g_object_ref (connection); - g_hash_table_remove (SC_PLUGIN_EXAMPLE_GET_PRIVATE (self)->connections, name); - - /* Tell NM the connection is gone */ - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); - - /* Remove the temporary reference; connection will now be destroyed */ - g_object_unref (connection); -} - -/* Look through all connections we know about and return one with a given UUID */ -static NMExampleConnection * -find_by_uuid (SCPluginExample *self, const char *uuid) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - GHashTableIter iter; - gpointer data = NULL; - - g_return_val_if_fail (uuid != NULL, NULL); - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, &data)) { - NMConnection *candidate = NM_CONNECTION (data); - - if (strcmp (uuid, nm_connection_get_uuid (candidate)) == 0) - return NM_EXAMPLE_CONNECTION (candidate); - } - return NULL; -} - - -static void -dir_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) -{ - NMSystemConfigInterface *config = NM_SYSTEM_CONFIG_INTERFACE (user_data); - SCPluginExample *self = SC_PLUGIN_EXAMPLE (config); - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - char *full_path; - NMExampleConnection *connection; - GError *error = NULL; - - full_path = g_file_get_path (file); - /* XXX: Check here if you need to ignore this file, ie by checking for - * extensions like "~" and ".bak" or ".tmp". If so just return; - */ - - /* Check if we know about this connection already */ - connection = g_hash_table_lookup (priv->connections, full_path); - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - if (connection) { - nm_log_info (LOGD_SETTINGS, "removed %s.", full_path); - remove_connection (SC_PLUGIN_EXAMPLE (config), connection, full_path); - } - break; - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - if (connection) { - /* Update of an existing connection. Here we re-read the file and - * compare it against the existing connection to check if anything - * actually changed. - */ - NMExampleConnection *tmp; - - tmp = nm_example_connection_new (full_path, NULL, &error); - if (tmp) { - if (!nm_connection_compare (NM_CONNECTION (connection), - NM_CONNECTION (tmp), - NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | - NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { - /* Connection changed; update our internal connection object */ - nm_log_info (LOGD_SETTINGS, "updating %s", full_path); - update_connection_settings (connection, tmp); - } - g_object_unref (tmp); - } else { - /* There was an error parsing the updated connection; it may - * no longer be valid and thus we've got to delete it. If it - * becomes valid again later we'll get another change - * notification, we'll re-read it, and we'll treat it as new. - */ - nm_log_info (LOGD_SETTINGS, " error: %s", - (error && error->message) ? error->message : "(unknown)"); - remove_connection (SC_PLUGIN_EXAMPLE (config), connection, full_path); - } - g_clear_error (&error); - } else { - nm_log_info (LOGD_SETTINGS, "updating %s", full_path); - - /* We don't know about the connection yet, so the change represents - * a completely new connection. - */ - connection = nm_example_connection_new (full_path, NULL, &error); - if (connection) { - NMExampleConnection *found = NULL; - - /* Connection renames will show up as different files but with - * the same UUID. Try to find the original connection. - * A connection rename is treated just like an update except - * there's a bit more housekeeping with the hash table. - */ - found = find_by_uuid (self, nm_connection_get_uuid (NM_CONNECTION (connection))); - if (found) { - const char *old_path = nm_example_connection_get_path (connection); - - /* Removing from the hash table should drop the last reference, - * but of course we want to keep the connection around. - */ - g_object_ref (found); - g_hash_table_remove (priv->connections, old_path); - - /* Updating settings should update the NMExampleConnection's - * filename property too. - */ - update_connection_settings (found, connection); - - /* Re-insert the connection back into the hash with the new filename */ - g_hash_table_insert (priv->connections, - g_strdup (nm_example_connection_get_path (found)), - found); - - /* Get rid of the temporary connection */ - g_object_unref (connection); - } else { - /* Completely new connection, not a rename. */ - g_hash_table_insert (priv->connections, - g_strdup (nm_example_connection_get_path (connection)), - connection); - /* Tell NM we found a new connection */ - g_signal_emit_by_name (config, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection); - } - } else { - nm_log_info (LOGD_SETTINGS, " error: %s", (error && error->message) ? error->message : "(unknown)"); - g_clear_error (&error); - } - } - break; - default: - break; - } - - g_free (full_path); -} - -static void -conf_file_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer data) -{ - SCPluginExample *self = SC_PLUGIN_EXAMPLE (data); - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - char *tmp; - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - /* Unmanaged devices option may have changed; just emit the changed - * signal for unmanaged specs and when NM calls back in to get the - * updated specs we'll re-read the config file then. - */ - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); - - /* Hostname may also have changed; read it and if it did actually - * change, notify NM. - */ - tmp = plugin_get_hostname (self); - if (g_strcmp0 (tmp, priv->hostname) != 0) { - g_free (priv->hostname); - priv->hostname = tmp; - tmp = NULL; - g_object_notify (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } - g_free (tmp); - break; - default: - break; - } -} - -/* This function starts the inotify monitors that watch the plugin's config - * file directory for new connections and changes to existing connections - * (if not disabled by NetworkManager.conf), and for changes to the plugin's - * non-connection config files. - */ -static void -setup_monitoring (NMSystemConfigInterface *config) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (config); - GFileMonitor *monitor; - GFile *file; - - /* Initialize connection hash here; we use the connection hash as the - * "are we initialized yet" variable. - */ - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - - if (nm_config_get_monitor_connection_files (nm_config_get ())) { - /* Set up the watch for our config directory */ - file = g_file_new_for_path (EXAMPLE_DIR); - monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - if (monitor) { - /* This registers the dir_changed() function to be called whenever - * the GFileMonitor object notices a change in the directory. - */ - priv->monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), config); - priv->monitor = monitor; - } - } - - /* Set up a watch on our configuration file, basically just for watching - * whether the user has changed the unmanaged devices option or the - * persistent hostname. - */ - if (priv->conf_file) { - file = g_file_new_for_path (priv->conf_file); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - - if (monitor) { - priv->conf_file_monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (conf_file_changed), config); - priv->conf_file_monitor = monitor; - } - } -} - -/*******************************************************************/ - -/* Return to NM the full list of connections this plugin owns */ -static GSList * -get_connections (NMSystemConfigInterface *config) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (config); - GHashTableIter iter; - NMSettingsConnection *connection; - GSList *list = NULL; - - if (!priv->connections) { - /* If we haven't read connections in yet, do so now */ - setup_monitoring (config); - read_connections (config); - } - - /* Add each connection from our internal hash table to a list returned - * to NetworkManager. - */ - 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; -} - -/* Called by NetworkManager when a user adds a new connection via D-Bus. - * The plugin should convert the data in 'connection' to its on-disk format - * write it out to disk, and return an object that's a subclass of - * NMSettingsConnection. Typically plugins will subclass NMSettingsConnection - * and use that class to handle any plugin-specific stuff like monitoring - * the on-disk config files for changes, and/or parsing the file-format and - * converting back and forth from that to NMConnection. - */ -static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, - NMConnection *connection, - gboolean save_to_disk, - GError **error) -{ - SCPluginExample *self = SC_PLUGIN_EXAMPLE (config); - NMSettingsConnection *added = NULL; - char *path = NULL; - - /* Write it out first, then add the connection to our internal list; that - * way we don't trigger the new NMSettingsConnection subclass' file watch - * functions needlessly. - */ - if (save_to_disk && !write_connection (connection, NULL, &path, error)) - return NULL; - - added = _internal_new_connection (self, path, connection, error); - g_free (path); - return added; -} - -/* This function returns a list of "unmanaged device specs" which represent - * a list of devices that NetworkManager should not manage. Each unmanaged - * spec item has a specific format starting with a "tag" and followed by - * tag-specific data. The only currently specified items are "mac:" followed - * by the MAC address of the interface NM should not manage, or "interface-name:" - * followed by the name of the interface NM should not manage. This function - * reads the list of unmanaged devices from wherever the plugin wants to - * store them and returns that list to NetworkManager. - */ -static GSList * -get_unmanaged_specs (NMSystemConfigInterface *config) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (config); - GKeyFile *key_file; - GSList *specs = NULL; - GError *error = NULL; - char *str, **ids; - int i; - - if (!priv->conf_file) - return NULL; - - key_file = g_key_file_new (); - if (!g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &error)) { - nm_log_warn (LOGD_SETTINGS, "Error parsing file '%s': %s", priv->conf_file, error->message); - g_error_free (error); - goto out; - } - - - str = g_key_file_get_value (key_file, "keyfile", "unmanaged-devices", NULL); - if (!str) - goto out; - - ids = g_strsplit (str, ";", -1); - for (i = 0; ids[i] != NULL; i++) { - /* Verify unmanaged specification and add it to the list */ - if (!strncmp (ids[i], "mac:", 4) && nm_utils_hwaddr_valid (ids[i] + 4, -1)) { - specs = g_slist_append (specs, ids[i]); - } else if (!strncmp (ids[i], "interface-name:", 15) && nm_utils_iface_valid_name (ids[i] + 15)) { - specs = g_slist_append (specs, ids[i]); - } else { - nm_log_warn (LOGD_SETTINGS, "Error in file '%s': invalid unmanaged-devices entry: '%s'", priv->conf_file, ids[i]); - g_free (ids[i]); - } - } - - g_free (ids); /* Yes, g_free, not g_strfreev because we need the strings in the list */ - g_free (str); - -out: - g_key_file_free (key_file); - return specs; -} - - -static char * -plugin_get_hostname (SCPluginExample *plugin) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (plugin); - GKeyFile *key_file; - char *hostname = NULL; - GError *error = NULL; - - if (!priv->conf_file) - return NULL; - - /* Read the persistent hostname out of backing storage, which happens - * to be the NM config file. Other plugins (like distro-specific ones) - * should read it from the distro-specific location like /etc/hostname. - */ - key_file = g_key_file_new (); - if (g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &error)) - hostname = g_key_file_get_value (key_file, "keyfile", "hostname", NULL); - else { - nm_log_warn (LOGD_SETTINGS, "Error parsing file '%s': %s", priv->conf_file, error->message); - g_error_free (error); - } - - g_key_file_free (key_file); - return hostname; -} - -static gboolean -plugin_set_hostname (SCPluginExample *plugin, const char *hostname) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (plugin); - GKeyFile *key_file; - GError *error = NULL; - gboolean success = FALSE; - char *data; - gsize len; - - if (!priv->conf_file) { - nm_log_warn (LOGD_SETTINGS, "Error saving hostname: no config file"); - return FALSE; - } - - /* This just saves the hostname to the NM config file in a section - * private to this plugin. - */ - key_file = g_key_file_new (); - if (!g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &error)) { - nm_log_warn (LOGD_SETTINGS, "Error parsing file '%s': %s", priv->conf_file, error->message); - g_error_free (error); - goto out; - } - - g_key_file_set_string (key_file, "example", "hostname", hostname); - - data = g_key_file_to_data (key_file, &len, &error); - if (data) { - /* Save updated file to disk */ - g_file_set_contents (priv->conf_file, data, len, &error); - g_free (data); - - /* Update internal copy of hostname */ - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); - success = TRUE; - } - - if (error) { - nm_log_warn (LOGD_SETTINGS, "Error saving hostname: %s", error->message); - g_error_free (error); - } - -out: - g_key_file_free (key_file); - return success; -} - -/* GObject */ - -static void -sc_plugin_example_init (SCPluginExample *plugin) -{ - /* Here we'd do any instance-specific initialization like setting - * members of SCPluginExamplePrivate to default values. But we - * don't have anything to do here since most initialization is done - * when NM calls the various entry points. - */ -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: - g_value_set_string (value, EXAMPLE_PLUGIN_NAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: - g_value_set_string (value, EXAMPLE_PLUGIN_INFO); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - /* Return capabilities to NM; this plugin supports changing connections - * as well as being capable of saving the hostname to persistent storage. - * If the plugin can't write out updated configuration, then obviously - * it shouldn't advertise that capability. If it can't save hostnames - * to persistent storage, it shouldn't advertise that capability either. - */ - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS | - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - /* Return the hostname we've read from persistent storage */ - g_value_set_string (value, SC_PLUGIN_EXAMPLE_GET_PRIVATE (object)->hostname); - 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) -{ - const char *hostname; - - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - /* We'll get here when the user has changed the hostname via NM's - * D-Bus interface and we're requested to save this hostname to - * persistent storage. - */ - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_EXAMPLE (object), hostname); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (object); - - /* GObject has a two-stage object destruction process: dispose and finalize. - * In dispose the object should free any references it might have on other - * objects to break circular refs, then it's finally cleaned up by finalize. - * We don't bother to implement a finalize, so we just make sure that we - * clean everything up (including clearing pointers) in dispose so that - * if GObject decides to revive this object post-dispose (yes, legal) - * we don't crash on dangling pointers. - */ - - if (priv->monitor) { - if (priv->monitor_id) { - g_signal_handler_disconnect (priv->monitor, priv->monitor_id); - priv->monitor_id = 0; - } - - g_file_monitor_cancel (priv->monitor); - g_object_unref (priv->monitor); - priv->monitor = NULL; - } - - if (priv->conf_file_monitor) { - if (priv->conf_file_monitor_id) { - g_signal_handler_disconnect (priv->conf_file_monitor, priv->conf_file_monitor_id); - priv->conf_file_monitor_id = 0; - } - - g_file_monitor_cancel (priv->conf_file_monitor); - g_object_unref (priv->conf_file_monitor); - priv->conf_file_monitor = NULL; - } - - if (priv->connections) { - /* Destroying the connections hash unrefs each connection in it - * due to the GHashTable value_destroy_func that we passed into - * g_hash_table_new_full(). - */ - g_hash_table_destroy (priv->connections); - priv->connections = NULL; - } - - g_free (priv->hostname); - priv->hostname = NULL; - - /* Chain up to the superclass */ - G_OBJECT_CLASS (sc_plugin_example_parent_class)->dispose (object); -} - -/* This function gets called to set up any method and property overrides - * of superclasses, and also (if we actually had any) to set up any - * custom properties and signals this object might have. This is called before - * the object is actually instantiated; it just sets up the generic class - * stuff, not anything related to a specific object instance. - */ -static void -sc_plugin_example_class_init (SCPluginExampleClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - /* This actually creates and zeros the object's instance data struct */ - g_type_class_add_private (req_class, sizeof (SCPluginExamplePrivate)); - - /* Override GObject base class methods with our custom implementations */ - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - /* Override various GObject properties that we need to change. Here we - * just tell GObject that we will be handling the get/set operations for - * these specific properties. They are actually defined by the - * NMSystemConfigInterface interface in nm-system-config-interface.c. - * What happens here is that we tell GObject that for a given property - * name (ie NM_SYSTEM_CONFIG_INTERFACE_NAME) we'll be using the enum value - * NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME locally in get_property() and - * set_property(). - */ - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -system_config_interface_init (NMSystemConfigInterface *sci_intf) -{ - /* Interface implementation for NMSystemConfigInterface. This sets - * up the GInterface vtable that lets GObject know what functions to - * call for each method of the NMSystemConfigInterface interface. - */ - sci_intf->get_connections = get_connections; - sci_intf->add_connection = add_connection; - sci_intf->get_unmanaged_specs = get_unmanaged_specs; -} - -/*******************************************************************/ - -/* Factory function: this is the first entry point for NetworkManager, which - * gets called during NM startup to create the instance of this plugin - * that NetworkManager will actually use. Since every plugin is a singleton - * we just return a singleton instance. This function should never be called - * twice. - */ -G_MODULE_EXPORT GObject * -nm_system_config_factory (void) -{ - static SCPluginExample *singleton = NULL; - SCPluginExamplePrivate *priv; - - if (!singleton) { - /* Instantiate our plugin */ - singleton = SC_PLUGIN_EXAMPLE (g_object_new (SC_TYPE_PLUGIN_EXAMPLE, NULL)); - priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (singleton); - - /* Cache the config file path */ - priv->conf_file = nm_config_data_get_config_main_file (nm_config_get_data (nm_config_get ())); - } else { - /* This function should never be called twice */ - g_assert_not_reached (); - } - - return G_OBJECT (singleton); -} - diff --git a/src/settings/plugins/example/plugin.h b/src/settings/plugins/example/plugin.h deleted file mode 100644 index f10ee1c4..00000000 --- a/src/settings/plugins/example/plugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - example 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) 2012 Red Hat, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#include <glib-object.h> - -/* GObject boilerplate: you usually only need to rename 'example' here to - * your plugin's name. These functions get used when casting pointers - * to your plugin's object type. - */ -#define SC_TYPE_PLUGIN_EXAMPLE (sc_plugin_example_get_type ()) -#define SC_PLUGIN_EXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExample)) -#define SC_PLUGIN_EXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExampleClass)) -#define SC_IS_PLUGIN_EXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_EXAMPLE)) -#define SC_IS_PLUGIN_EXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_EXAMPLE)) -#define SC_PLUGIN_EXAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExampleClass)) - -typedef struct { - /* GObject instance structure for the plugin; we don't do anything special - * here so this object's instance is exactly the same as its parent. - */ - GObject parent; -} SCPluginExample; - -typedef struct { - /* GObject class structure; we don't do anything special here - * so this object's class is exactly the same as its parent. Typically - * if the plugin implemented custom signals their prototypes would go - * here, but most plugins don't need to do this. - */ - GObjectClass parent; -} SCPluginExampleClass; - -GType sc_plugin_example_get_type (void); - -#endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/example/reader.c b/src/settings/plugins/example/reader.c deleted file mode 100644 index ee45440a..00000000 --- a/src/settings/plugins/example/reader.c +++ /dev/null @@ -1,47 +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) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <glib.h> - -#include <nm-connection.h> -#include <nm-dbus-interface.h> - -#include "common.h" - -NMConnection * -connection_from_file (const char *filename, GError **error) -{ - /* This function should, given a file path, read that file and convert its - * data into an NMConnection. There are two approaches to this. First, - * if the plugin data format is similar to the NMConnection internal - * format, you can get away with calling nm_connection_for_each_setting_value() - * to iterate through every possible setting's keys and read that value - * from the plugin's format. If the plugin's format is siginificantly - * different then you may have to build up the connection manually by - * determining the type of connection from the on-disk data, creating - * each setting object, adding the values, then adding that setting to - * the NMConnection. - */ - - return NULL; -} - diff --git a/src/settings/plugins/example/writer.c b/src/settings/plugins/example/writer.c deleted file mode 100644 index 41e5c498..00000000 --- a/src/settings/plugins/example/writer.c +++ /dev/null @@ -1,56 +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) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <glib.h> - -#include <nm-connection.h> - -#include "common.h" - -gboolean -write_connection (NMConnection *connection, - const char *existing_path, - char **out_path, - GError **error) -{ - /* This function should take the NMConnection and convert it to the format - * which this plugin uses on-disk and then write out that data. It returns - * the file path of the file that represents this connection data so that - * the plugin can track it for change notification and updates. If - * 'existing_path' is given we can assume that this is an update of an - * existing connection and not a completely new one. - */ - - /* There are two approaches to converting the data. The first more manual - * approach consists of grabbing each setting value from the NMConnection - * and converting it into the appropriate value for the plugin's data - * format. This is usually taken by distro plugins because their format - * is significantly different than NetworkManager's internal format. - * The second uses nm_connection_for_each_setting_value() to iterate - * through each value of each setting in the NMConnection, convert it to - * the required format, and write it out, but this requires that the - * plugin format more closely follow the NetworkManager internal format. - */ - - return FALSE; -} - diff --git a/src/settings/plugins/ibft/Makefile.am b/src/settings/plugins/ibft/Makefile.am index 6bc9d05d..a994808d 100644 --- a/src/settings/plugins/ibft/Makefile.am +++ b/src/settings/plugins/ibft/Makefile.am @@ -14,14 +14,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DSBINDIR=\"$(sbindir)\" diff --git a/src/settings/plugins/ibft/Makefile.in b/src/settings/plugins/ibft/Makefile.in index 1f5b8eb4..024442b1 100644 --- a/src/settings/plugins/ibft/Makefile.in +++ b/src/settings/plugins/ibft/Makefile.in @@ -277,7 +277,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -289,8 +288,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -300,6 +297,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -354,16 +352,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -400,6 +395,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -428,7 +425,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -443,6 +439,8 @@ 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@ @@ -503,6 +501,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -510,6 +509,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -536,14 +536,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DSBINDIR=\"$(sbindir)\" diff --git a/src/settings/plugins/ibft/plugin.c b/src/settings/plugins/ibft/plugin.c index 632c4df1..555725d1 100644 --- a/src/settings/plugins/ibft/plugin.c +++ b/src/settings/plugins/ibft/plugin.c @@ -25,39 +25,38 @@ #include <errno.h> #include <gmodule.h> -#include <glib-object.h> -#include <glib/gi18n.h> -#include <gio/gio.h> #include <nm-setting-connection.h> -#include "nm-dbus-glib-types.h" -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-default.h" +#include "nm-settings-plugin.h" #include "NetworkManagerUtils.h" #include "plugin.h" #include "reader.h" #include "nm-ibft-connection.h" -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -G_DEFINE_TYPE_EXTENDED (SCPluginIbft, sc_plugin_ibft, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +G_DEFINE_TYPE_EXTENDED (SettingsPluginIbft, settings_plugin_ibft, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) -#define SC_PLUGIN_IBFT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IBFT, SCPluginIbftPrivate)) +#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; -} SCPluginIbftPrivate; +} 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 (SCPluginIbft *self) +read_connections (SettingsPluginIbft *self) { - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (self); + SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); GSList *blocks = NULL, *iter; GError *error = NULL; NMIbftConnection *connection; @@ -86,10 +85,10 @@ read_connections (SCPluginIbft *self) } static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginIbft *self = SC_PLUGIN_IBFT (config); - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (self); + SettingsPluginIbft *self = SETTINGS_PLUGIN_IBFT (config); + SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); GSList *list = NULL; GHashTableIter iter; NMIbftConnection *connection; @@ -107,14 +106,14 @@ get_connections (NMSystemConfigInterface *config) } static void -init (NMSystemConfigInterface *config) +init (NMSettingsPlugin *config) { } static void -sc_plugin_ibft_init (SCPluginIbft *self) +settings_plugin_ibft_init (SettingsPluginIbft *self) { - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (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); } @@ -122,15 +121,15 @@ sc_plugin_ibft_init (SCPluginIbft *self) static void dispose (GObject *object) { - SCPluginIbft *self = SC_PLUGIN_IBFT (object); - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (self); + 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 (sc_plugin_ibft_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ibft_parent_class)->dispose (object); } static void @@ -138,14 +137,14 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, "iBFT"); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + 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_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE); + 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); @@ -161,50 +160,39 @@ set_property (GObject *object, guint prop_id, } static void -sc_plugin_ibft_class_init (SCPluginIbftClass *req_class) +settings_plugin_ibft_class_init (SettingsPluginIbftClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIbftPrivate)); + 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_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - system_config_interface_class->get_connections = get_connections; - system_config_interface_class->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->init = init; } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIbft *singleton = NULL; - - if (!singleton) - singleton = SC_PLUGIN_IBFT (g_object_new (SC_TYPE_PLUGIN_IBFT, NULL)); - else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ibft_get ()); } diff --git a/src/settings/plugins/ibft/plugin.h b/src/settings/plugins/ibft/plugin.h index 2c811359..3fc58c7f 100644 --- a/src/settings/plugins/ibft/plugin.h +++ b/src/settings/plugins/ibft/plugin.h @@ -21,27 +21,27 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" -#define SC_TYPE_PLUGIN_IBFT (sc_plugin_ibft_get_type ()) -#define SC_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IBFT, SCPluginIbft)) -#define SC_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IBFT, SCPluginIbftClass)) -#define SC_IS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IBFT)) -#define SC_IS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IBFT)) -#define SC_PLUGIN_IBFT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IBFT, SCPluginIbftClass)) +#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 _SCPluginIbft SCPluginIbft; -typedef struct _SCPluginIbftClass SCPluginIbftClass; +typedef struct _SettingsPluginIbft SettingsPluginIbft; +typedef struct _SettingsPluginIbftClass SettingsPluginIbftClass; -struct _SCPluginIbft { +struct _SettingsPluginIbft { GObject parent; }; -struct _SCPluginIbftClass { +struct _SettingsPluginIbftClass { GObjectClass parent; }; -GType sc_plugin_ibft_get_type (void); +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 index 9bc63462..195c2641 100644 --- a/src/settings/plugins/ibft/reader.c +++ b/src/settings/plugins/ibft/reader.c @@ -31,13 +31,10 @@ #include <sys/ioctl.h> #include <unistd.h> -#include <glib.h> -#include <glib/gi18n.h> - +#include "nm-default.h" #include "nm-core-internal.h" #include "nm-platform.h" #include "NetworkManagerUtils.h" -#include "nm-logging.h" #include "reader.h" diff --git a/src/settings/plugins/ibft/reader.h b/src/settings/plugins/ibft/reader.h index 0b2f22b6..42969ae0 100644 --- a/src/settings/plugins/ibft/reader.h +++ b/src/settings/plugins/ibft/reader.h @@ -21,9 +21,10 @@ #ifndef __READER_H__ #define __READER_H__ -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" + gboolean read_ibft_blocks (const char *iscsiadm_path, GSList **out_blocks, GError **error); diff --git a/src/settings/plugins/ibft/tests/Makefile.am b/src/settings/plugins/ibft/tests/Makefile.am index 9901119e..29881e85 100644 --- a/src/settings/plugins/ibft/tests/Makefile.am +++ b/src/settings/plugins/ibft/tests/Makefile.am @@ -5,8 +5,8 @@ if ENABLE_TESTS AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src/ \ @@ -14,14 +14,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_IBFT_DIR=\"$(abs_srcdir)\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" AM_LDFLAGS = \ $(GLIB_LIBS) \ - $(DBUS_LIBS) \ $(CODE_COVERAGE_LDFLAGS) noinst_PROGRAMS = test-ibft diff --git a/src/settings/plugins/ibft/tests/Makefile.in b/src/settings/plugins/ibft/tests/Makefile.in index 30bd78df..7ac2bdc1 100644 --- a/src/settings/plugins/ibft/tests/Makefile.in +++ b/src/settings/plugins/ibft/tests/Makefile.in @@ -405,7 +405,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -417,8 +416,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -428,6 +425,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -482,16 +480,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -528,6 +523,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -556,7 +553,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -571,6 +567,8 @@ 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@ @@ -631,6 +629,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -638,6 +637,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -656,8 +656,8 @@ 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)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@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/ \ @@ -665,14 +665,13 @@ with_valgrind = @with_valgrind@ @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 \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @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@ $(DBUS_LIBS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) @ENABLE_TESTS_TRUE@test_ibft_SOURCES = \ diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c index 980a9cee..c7aef050 100644 --- a/src/settings/plugins/ibft/tests/test-ibft.c +++ b/src/settings/plugins/ibft/tests/test-ibft.c @@ -33,7 +33,7 @@ #include "NetworkManagerUtils.h" #include "reader.h" -#include "nm-logging.h" +#include "nm-default.h" #include "nm-test-utils.h" diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am index 08ffa0ec..ab96a328 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/Makefile.am @@ -2,15 +2,31 @@ SUBDIRS = . tests @GNOME_CODE_COVERAGE_RULES@ -nm-ifcfg-rh-glue.h: nm-ifcfg-rh.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_ifcfg_rh --mode=glib-server --output=$@ $< +# See note about gdbus-codegen in introspection/Makefile.am -BUILT_SOURCES = \ - nm-ifcfg-rh-glue.h +noinst_LTLIBRARIES = libnmdbus-ifcfg-rh.la + +nodist_libnmdbus_ifcfg_rh_la_SOURCES = \ + nmdbus-ifcfg-rh.c \ + nmdbus-ifcfg-rh.h + +libnmdbus_ifcfg_rh_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS)) + +nmdbus-ifcfg-rh.h: nm-ifcfg-rh.xml + $(AM_V_GEN) gdbus-codegen \ + --generate-c-code $(basename $@) \ + --c-namespace NMDBus \ + --interface-prefix com.redhat \ + $< + +nmdbus-ifcfg-rh.c: nmdbus-ifcfg-rh.h + @true + +BUILT_SOURCES = nmdbus-ifcfg-rh.h nmdbus-ifcfg-rh.c pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la -noinst_LTLIBRARIES = libifcfg-rh-io.la +noinst_LTLIBRARIES += libifcfg-rh-io.la libifcfg_rh_io_la_SOURCES = \ shvar.c \ @@ -27,14 +43,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ $(NSS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -47,7 +62,7 @@ libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ nm-ifcfg-connection.h libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la +libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la libnmdbus-ifcfg-rh.la dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = nm-ifcfg-rh.conf diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in index eaa456bb..3fc3495a 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/Makefile.in @@ -148,7 +148,8 @@ 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 +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 = \ @@ -157,6 +158,11 @@ 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 @@ -192,7 +198,8 @@ 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) + $(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 \ @@ -280,7 +287,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -292,8 +298,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -303,6 +307,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -357,16 +362,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -403,6 +405,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -431,7 +435,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -446,6 +449,8 @@ 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@ @@ -506,6 +511,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -513,6 +519,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -529,11 +536,16 @@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ SUBDIRS = . tests -BUILT_SOURCES = \ - nm-ifcfg-rh-glue.h +# 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 -noinst_LTLIBRARIES = libifcfg-rh-io.la libifcfg_rh_io_la_SOURCES = \ shvar.c \ shvar.h \ @@ -549,14 +561,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ $(NSS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -569,7 +580,7 @@ libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ nm-ifcfg-connection.h libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la +libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la libnmdbus-ifcfg-rh.la dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = nm-ifcfg-rh.conf EXTRA_DIST = \ @@ -664,12 +675,16 @@ libifcfg-rh-io.la: $(libifcfg_rh_io_la_OBJECTS) $(libifcfg_rh_io_la_DEPENDENCIES 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@ @@ -698,6 +713,13 @@ distclean-compile: @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 @@ -1017,8 +1039,15 @@ uninstall-am: uninstall-dbusserviceDATA uninstall-pkglibLTLIBRARIES @GNOME_CODE_COVERAGE_RULES@ -nm-ifcfg-rh-glue.h: nm-ifcfg-rh.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_ifcfg_rh --mode=glib-server --output=$@ $< +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. diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/common.h index 0ec355ee..5d6ebe6d 100644 --- a/src/settings/plugins/ifcfg-rh/common.h +++ b/src/settings/plugins/ifcfg-rh/common.h @@ -21,7 +21,7 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#include <glib.h> +#include "nm-default.h" #define IFCFG_TAG "ifcfg-" #define KEYS_TAG "keys-" diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index 9499d8ce..336d9d66 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -33,8 +33,9 @@ #include <nm-setting-pppoe.h> #include <nm-setting-wireless-security.h> #include <nm-setting-8021x.h> -#include <nm-platform.h> -#include <nm-logging.h> +#include "nm-platform.h" + +#include "nm-default.h" #include "common.h" #include "nm-config.h" @@ -107,7 +108,7 @@ devtimeout_ready (gpointer user_data) static void link_changed (NMPlatform *platform, NMPObjectType *obj_type, int ifindex, const NMPlatformLink *link, - NMPlatformSignalChangeType change_type, NMPlatformReason reason, + NMPlatformSignalChangeType change_type, NMConnection *self) { NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); @@ -143,7 +144,7 @@ devtimeout_expired (gpointer user_data) 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); + g_signal_handler_disconnect (NM_PLATFORM_GET, priv->devtimeout_link_changed_handler); priv->devtimeout_link_changed_handler = 0; priv->devtimeout_timeout_id = 0; @@ -187,7 +188,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self) 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_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); } @@ -276,10 +277,7 @@ path_watch_stop (NMIfcfgConnection *self) ih = _get_inotify_helper (priv); - if (priv->ih_event_id) { - g_signal_handler_disconnect (ih, priv->ih_event_id); - priv->ih_event_id = 0; - } + nm_clear_g_signal_handler (ih, &priv->ih_event_id); if (priv->file_wd >= 0) { nm_inotify_helper_remove_watch (ih, priv->file_wd); @@ -380,6 +378,7 @@ replace_and_commit (NMSettingsConnection *connection, static void commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data) { @@ -407,7 +406,7 @@ commit_changes (NMSettingsConnection *connection, /* 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, callback, user_data); + NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); return; } } @@ -430,7 +429,7 @@ commit_changes (NMSettingsConnection *connection, if (success) { /* Chain up to parent to handle success */ - NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, callback, user_data); + 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); @@ -514,15 +513,8 @@ dispose (GObject *object) path_watch_stop (NM_IFCFG_CONNECTION (object)); - if (priv->devtimeout_link_changed_handler) { - g_signal_handler_disconnect (nm_platform_get (), - priv->devtimeout_link_changed_handler); - priv->devtimeout_link_changed_handler = 0; - } - if (priv->devtimeout_timeout_id) { - g_source_remove (priv->devtimeout_timeout_id); - priv->devtimeout_timeout_id = 0; - } + 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); diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf index cade31dd..8fefaf18 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf @@ -7,7 +7,6 @@ <allow send_destination="com.redhat.ifcfgrh1"/> </policy> <policy at_console="true"> - <deny own="com.redhat.ifcfgrh1"/> <allow send_destination="com.redhat.ifcfgrh1"/> </policy> <policy context="default"> diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml index 52793452..1f308dd4 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml @@ -10,7 +10,6 @@ <tp:docstring> Given an ifcfg file, return various internal information about it. </tp:docstring> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ifcfgrh_get_ifcfg_details"/> <arg name="ifcfg" type="s" direction="in"> <tp:docstring> The full path to an ifcfg file. diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index 526cdafe..5afc46d6 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -30,39 +30,28 @@ #include <sys/stat.h> #include <gmodule.h> -#include <glib-object.h> -#include <glib/gi18n.h> -#include <gio/gio.h> - -#include <dbus/dbus.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - -#if HAVE_SELINUX -#include <selinux/selinux.h> -#endif #include "nm-setting-connection.h" +#include "nm-default.h" #include "common.h" -#include "nm-dbus-glib-types.h" #include "plugin.h" -#include "nm-system-config-interface.h" +#include "nm-settings-plugin.h" #include "nm-config.h" -#include "nm-logging.h" #include "NetworkManagerUtils.h" #include "nm-ifcfg-connection.h" -#include "nm-inotify-helper.h" #include "shvar.h" #include "reader.h" #include "writer.h" #include "utils.h" -#include "gsystem-local-alloc.h" +#include "nm-dbus-compat.h" +#include "nm-exported-object.h" -#define DBUS_SERVICE_NAME "com.redhat.ifcfgrh1" -#define DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1" +#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, ...) \ @@ -76,15 +65,7 @@ #define ERR_GET_MSG(err) (((err) && (err)->message) ? (err)->message : "(unknown)") -static gboolean impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, - const char *in_ifcfg, - const char **out_uuid, - const char **out_path, - GError **error); - -#include "nm-ifcfg-rh-glue.h" - -static NMIfcfgConnection *update_connection (SCPluginIfcfg *plugin, +static NMIfcfgConnection *update_connection (SettingsPluginIfcfg *plugin, NMConnection *source, const char *full_path, NMIfcfgConnection *connection, @@ -92,37 +73,40 @@ static NMIfcfgConnection *update_connection (SCPluginIfcfg *plugin, GHashTable *protected_connections, GError **error); -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) -#define SC_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgPrivate)) +#define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgPrivate)) typedef struct { - GHashTable *connections; /* uuid::connection */ + NMConfig *config; + + struct { + GDBusConnection *connection; + GDBusInterfaceSkeleton *interface; + GCancellable *cancellable; + gulong signal_id; + } dbus; + GHashTable *connections; /* uuid::connection */ gboolean initialized; - gulong ih_event_id; - int sc_network_wd; - GFileMonitor *hostname_monitor; - guint hostname_monitor_id; - char *hostname; GFileMonitor *ifcfg_monitor; - guint ifcfg_monitor_id; - - DBusGConnection *bus; -} SCPluginIfcfgPrivate; + 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) { - SCPluginIfcfg *self = SC_PLUGIN_IFCFG (user_data); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + 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)); @@ -142,14 +126,14 @@ connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SC_PLUGIN_IFCFG_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } static void -remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection) +remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); gboolean unmanaged, unrecognized; g_return_if_fail (self != NULL); @@ -168,15 +152,15 @@ remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection) /* Emit changes _after_ removing the connection */ if (unmanaged) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); if (unrecognized) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); } static NMIfcfgConnection * -find_by_path (SCPluginIfcfg *self, const char *path) +find_by_path (SettingsPluginIfcfg *self, const char *path) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); GHashTableIter iter; NMSettingsConnection *candidate = NULL; @@ -191,7 +175,7 @@ find_by_path (SCPluginIfcfg *self, const char *path) } static NMIfcfgConnection * -update_connection (SCPluginIfcfg *self, +update_connection (SettingsPluginIfcfg *self, NMConnection *source, const char *full_path, NMIfcfgConnection *connection, @@ -199,7 +183,7 @@ update_connection (SCPluginIfcfg *self, GHashTable *protected_connections, GError **error) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); NMIfcfgConnection *connection_new; NMIfcfgConnection *connection_by_uuid; GError *local = NULL; @@ -346,18 +330,18 @@ update_connection (SCPluginIfcfg *self, 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_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_by_uuid); + 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_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_by_uuid); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid); } } if (unmanaged_changed) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); if (unrecognized_changed) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_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); @@ -401,11 +385,11 @@ update_connection (SCPluginIfcfg *self, /* 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_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + 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_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); else - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); } return connection_new; } @@ -418,7 +402,7 @@ ifcfg_dir_changed (GFileMonitor *monitor, GFileMonitorEvent event_type, gpointer user_data) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (user_data); char *path, *ifcfg_path; NMIfcfgConnection *connection; @@ -447,9 +431,9 @@ ifcfg_dir_changed (GFileMonitor *monitor, } static void -setup_ifcfg_monitoring (SCPluginIfcfg *plugin) +setup_ifcfg_monitoring (SettingsPluginIfcfg *plugin) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); GFile *file; GFileMonitor *monitor; @@ -502,9 +486,9 @@ _sort_paths (const char **f1, const char **f2, GHashTable *paths) } static void -read_connections (SCPluginIfcfg *plugin) +read_connections (SettingsPluginIfcfg *plugin) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); GDir *dir; GError *err = NULL; const char *item; @@ -574,10 +558,10 @@ read_connections (SCPluginIfcfg *plugin) } static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); GSList *list = NULL; GHashTableIter iter; NMIfcfgConnection *connection; @@ -600,10 +584,10 @@ get_connections (NMSystemConfigInterface *config) } static gboolean -load_connection (NMSystemConfigInterface *config, +load_connection (NMSettingsPlugin *config, const char *filename) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); NMIfcfgConnection *connection; int dir_len = strlen (IFCFG_DIR); char *ifcfg_path; @@ -629,18 +613,18 @@ load_connection (NMSystemConfigInterface *config, } static void -reload_connections (NMSystemConfigInterface *config) +reload_connections (NMSettingsPlugin *config) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); read_connections (plugin); } static GSList * -get_unhandled_specs (NMSystemConfigInterface *config, +get_unhandled_specs (NMSettingsPlugin *config, const char *property) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (config); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (config); GSList *list = NULL, *list_iter; GHashTableIter iter; gpointer connection; @@ -668,24 +652,24 @@ get_unhandled_specs (NMSystemConfigInterface *config, } static GSList * -get_unmanaged_specs (NMSystemConfigInterface *config) +get_unmanaged_specs (NMSettingsPlugin *config) { return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNMANAGED_SPEC); } static GSList * -get_unrecognized_specs (NMSystemConfigInterface *config) +get_unrecognized_specs (NMSettingsPlugin *config) { return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC); } static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, +add_connection (NMSettingsPlugin *config, NMConnection *connection, gboolean save_to_disk, GError **error) { - SCPluginIfcfg *self = SC_PLUGIN_IFCFG (config); + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (config); gs_free char *path = NULL; /* Ensure we reject attempts to add the connection long before we're @@ -701,312 +685,316 @@ add_connection (NMSystemConfigInterface *config, return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); } -#define SC_NETWORK_FILE "/etc/sysconfig/network" -#define HOSTNAME_FILE "/etc/hostname" - -static char * -plugin_get_hostname (SCPluginIfcfg *plugin) +static void +impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin, + GDBusMethodInvocation *context, + const char *in_ifcfg) { - shvarFile *network; - char *hostname; - gboolean ignore_localhost; + NMIfcfgConnection *connection; + NMSettingConnection *s_con; + const char *uuid; + const char *path; + gs_free char *ifcfg_path = NULL; - if (g_file_get_contents (HOSTNAME_FILE, &hostname, NULL, NULL)) { - g_strchomp (hostname); - return hostname; + 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; } - network = svOpenFile (SC_NETWORK_FILE, NULL); - if (!network) { - _LOGW ("Could not get hostname: failed to read " SC_NETWORK_FILE); - return NULL; + 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; } - hostname = svGetValue (network, "HOSTNAME", FALSE); - ignore_localhost = svTrueValue (network, "NM_IGNORE_HOSTNAME_LOCALHOST", FALSE); - if (ignore_localhost) { - /* Ignore a default hostname ('localhost[6]' or 'localhost[6].localdomain[6]') - * to preserve 'network' service behavior. - */ - if (hostname && !nm_utils_is_specific_hostname (hostname)) { - g_free (hostname); - hostname = NULL; - } + 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; } - svCloseFile (network); - return hostname; -} - -static gboolean -plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - shvarFile *network; - char *hostname_eol; - gboolean ret; -#if HAVE_SELINUX - security_context_t se_ctx_prev = NULL, se_ctx = NULL; - struct stat file_stat = { .st_mode = 0 }; - mode_t st_mode = 0; - - /* Get default context for HOSTNAME_FILE and set it for fscreate */ - if (stat (HOSTNAME_FILE, &file_stat) == 0) - st_mode = file_stat.st_mode; - matchpathcon (HOSTNAME_FILE, st_mode, &se_ctx); - matchpathcon_fini (); - getfscreatecon (&se_ctx_prev); - setfscreatecon (se_ctx); -#endif - - hostname_eol = g_strdup_printf ("%s\n", hostname); - ret = g_file_set_contents (HOSTNAME_FILE, hostname_eol, -1, NULL); - -#if HAVE_SELINUX - /* Restore previous context and cleanup */ - setfscreatecon (se_ctx_prev); - freecon (se_ctx); - freecon (se_ctx_prev); -#endif - - if (!ret) { - _LOGW ("Could not save hostname: failed to create/open " HOSTNAME_FILE); - g_free (hostname_eol); - return FALSE; + 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; } - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); - g_free (hostname_eol); + 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; + } - /* Remove "HOSTNAME" from SC_NETWORK_FILE, if present */ - network = svOpenFile (SC_NETWORK_FILE, NULL); - if (network) { - svSetValue (network, "HOSTNAME", NULL, FALSE); - svWriteFile (network, 0644, NULL); - svCloseFile (network); + 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; } - return TRUE; + g_dbus_method_invocation_return_value (context, + g_variant_new ("(so)", uuid, path)); } -static void -hostname_maybe_changed (SCPluginIfcfg *plugin) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - char *new_hostname; - - new_hostname = plugin_get_hostname (plugin); - if ( (new_hostname && !priv->hostname) - || (!new_hostname && priv->hostname) - || (priv->hostname && new_hostname && strcmp (priv->hostname, new_hostname))) { - g_free (priv->hostname); - priv->hostname = new_hostname; - g_object_notify (G_OBJECT (plugin), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } else - g_free (new_hostname); -} +/*****************************************************************************/ static void -sc_network_changed_cb (NMInotifyHelper *ih, - struct inotify_event *evt, - const char *path, - gpointer user_data) +_dbus_clear (SettingsPluginIfcfg *self) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - if (evt->wd != priv->sc_network_wd) - return; + 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; + } - hostname_maybe_changed (plugin); + g_clear_object (&priv->dbus.connection); } static void -hostname_changed_cb (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) +_dbus_connection_closed (GDBusConnection *connection, + gboolean remote_peer_vanished, + GError *error, + gpointer user_data) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); + _LOGW ("dbus: %s bus closed", IFCFGRH1_DBUS_SERVICE_NAME); + _dbus_clear (SETTINGS_PLUGIN_IFCFG (user_data)); - hostname_maybe_changed (plugin); + /* Retry or recover? */ } -static gboolean -impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, - const char *in_ifcfg, - const char **out_uuid, - const char **out_path, - GError **error) +static void +_dbus_request_name_done (GObject *source_object, + GAsyncResult *res, + gpointer user_data) { - NMIfcfgConnection *connection; - NMSettingConnection *s_con; - const char *uuid; - const char *path; + 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; - if (!g_path_is_absolute (in_ifcfg)) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "ifcfg path '%s' is not absolute", in_ifcfg); - return FALSE; - } + self = SETTINGS_PLUGIN_IFCFG (user_data); + priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - connection = find_by_path (plugin, in_ifcfg); - if ( !connection - || nm_ifcfg_connection_get_unmanaged_spec (connection) - || nm_ifcfg_connection_get_unrecognized_spec (connection)) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "ifcfg file '%s' unknown", in_ifcfg); - return FALSE; - } + g_clear_object (&priv->dbus.cancellable); - s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); - if (!s_con) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_FAILED, - "unable to retrieve the connection setting"); - return FALSE; + if (!ret) { + _LOGW ("dbus: couldn't acquire D-Bus service: %s", error->message); + _dbus_clear (self); + return; } - uuid = nm_setting_connection_get_uuid (s_con); - if (!uuid) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_FAILED, - "unable to get the UUID"); - return FALSE; - } - - path = nm_connection_get_path (NM_CONNECTION (connection)); - if (!path) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_FAILED, - "unable to get the connection D-Bus path"); - return FALSE; + g_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; } - *out_uuid = g_strdup (uuid); - *out_path = g_strdup (path); + { + 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; + } + } - return TRUE; + _LOGD ("dbus: aquired D-Bus service %s and exported %s object", + IFCFGRH1_DBUS_SERVICE_NAME, + IFCFGRH1_DBUS_OBJECT_PATH); } static void -init (NMSystemConfigInterface *config) +_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 -sc_plugin_ifcfg_init (SCPluginIfcfg *plugin) +_dbus_setup (SettingsPluginIfcfg *self) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - NMInotifyHelper *ih; - GError *error = NULL; - gboolean success = FALSE; - GFile *file; - GFileMonitor *monitor; - - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + gs_free char *address = NULL; + gs_free_error GError *error = NULL; - /* We watch SC_NETWORK_FILE via NMInotifyHelper (which doesn't track file creation but - * *does* track modifications made via other hard links), since we expect it to always - * exist. But we watch HOSTNAME_FILE via GFileMonitor (which has the opposite - * semantics), since /etc/hostname might not exist, but is unlikely to have hard - * links. bgo 532815 is the bug for being able to just use GFileMonitor for both. - */ - - ih = nm_inotify_helper_get (); - priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (sc_network_changed_cb), plugin); - priv->sc_network_wd = nm_inotify_helper_add_watch (ih, SC_NETWORK_FILE); + g_return_if_fail (!priv->dbus.connection); - file = g_file_new_for_path (HOSTNAME_FILE); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - if (monitor) { - priv->hostname_monitor_id = - g_signal_connect (monitor, "changed", G_CALLBACK (hostname_changed_cb), plugin); - priv->hostname_monitor = monitor; + 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->hostname = plugin_get_hostname (plugin); + priv->dbus.cancellable = g_cancellable_new (); - priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - if (!priv->bus) { - _LOGW ("Couldn't connect to D-Bus: %s", error->message); - g_clear_error (&error); - } else { - DBusConnection *tmp; - DBusGProxy *proxy; - int result; - - tmp = dbus_g_connection_get_connection (priv->bus); - dbus_connection_set_exit_on_disconnect (tmp, FALSE); - - proxy = dbus_g_proxy_new_for_name (priv->bus, - "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus"); - - if (!dbus_g_proxy_call (proxy, "RequestName", &error, - G_TYPE_STRING, DBUS_SERVICE_NAME, - G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE, - G_TYPE_INVALID, - G_TYPE_UINT, &result, - G_TYPE_INVALID)) { - _LOGW ("Couldn't acquire D-Bus service: %s", error->message); - g_clear_error (&error); - } else if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - _LOGW ("Couldn't acquire ifcfgrh1 D-Bus service (already taken)"); - } else - success = TRUE; - } + 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); +} - if (!success) { - if (priv->bus) { - dbus_g_connection_unref (priv->bus); - priv->bus = NULL; - } +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_HAS (changes, NM_CONFIG_CHANGE_SIGHUP) + || NM_FLAGS_HAS (changes, NM_CONFIG_CHANGE_SIGUSR1)) { + if (!SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self)->dbus.connection) + _dbus_setup (self); } } +/*****************************************************************************/ + static void -dispose (GObject *object) +init (NMSettingsPlugin *config) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - NMInotifyHelper *ih; +} - if (priv->bus) { - dbus_g_connection_unref (priv->bus); - priv->bus = NULL; - } +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); +} - if (priv->ih_event_id) { - ih = nm_inotify_helper_get (); +static void +constructed (GObject *object) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - g_signal_handler_disconnect (ih, priv->ih_event_id); - priv->ih_event_id = 0; + G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->constructed (object); - if (priv->sc_network_wd >= 0) - nm_inotify_helper_remove_watch (ih, priv->sc_network_wd); - } + 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); - if (priv->hostname_monitor) { - if (priv->hostname_monitor_id) - g_signal_handler_disconnect (priv->hostname_monitor, priv->hostname_monitor_id); + _dbus_setup (self); +} + +static void +dispose (GObject *object) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - g_file_monitor_cancel (priv->hostname_monitor); - g_object_unref (priv->hostname_monitor); + 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; } - g_free (priv->hostname); + _dbus_clear (self); if (priv->connections) { g_hash_table_destroy (priv->connections); @@ -1021,27 +1009,22 @@ dispose (GObject *object) g_object_unref (priv->ifcfg_monitor); } - G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->dispose (object); } static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (object); - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, IFCFG_PLUGIN_NAME); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, IFCFG_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS | NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, priv->hostname); + 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); @@ -1053,15 +1036,7 @@ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - const char *hostname; - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_IFCFG (object), hostname); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1069,65 +1044,45 @@ set_property (GObject *object, guint prop_id, } static void -sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class) +settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIfcfgPrivate)); + 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_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (req_class), - &dbus_glib_nm_ifcfg_rh_object_info); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - system_config_interface_class->get_connections = get_connections; - system_config_interface_class->add_connection = add_connection; - system_config_interface_class->load_connection = load_connection; - system_config_interface_class->reload_connections = reload_connections; - system_config_interface_class->get_unmanaged_specs = get_unmanaged_specs; - system_config_interface_class->get_unrecognized_specs = get_unrecognized_specs; - system_config_interface_class->init = init; + 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_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIfcfg *singleton = NULL; - SCPluginIfcfgPrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL)); - priv = SC_PLUGIN_IFCFG_GET_PRIVATE (singleton); - if (priv->bus) - dbus_g_connection_register_g_object (priv->bus, - DBUS_OBJECT_PATH, - G_OBJECT (singleton)); - _LOGD ("Acquired D-Bus service %s", DBUS_SERVICE_NAME); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + 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 index d37decfd..eba734cf 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.h +++ b/src/settings/plugins/ifcfg-rh/plugin.h @@ -24,27 +24,27 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-exported-object.h" -#define SC_TYPE_PLUGIN_IFCFG (sc_plugin_ifcfg_get_type ()) -#define SC_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfg)) -#define SC_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) -#define SC_IS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFCFG)) -#define SC_IS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFCFG)) -#define SC_PLUGIN_IFCFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) +#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 _SCPluginIfcfg SCPluginIfcfg; -typedef struct _SCPluginIfcfgClass SCPluginIfcfgClass; +typedef struct _SettingsPluginIfcfg SettingsPluginIfcfg; +typedef struct _SettingsPluginIfcfgClass SettingsPluginIfcfgClass; -struct _SCPluginIfcfg { +struct _SettingsPluginIfcfg { GObject parent; }; -struct _SCPluginIfcfgClass { +struct _SettingsPluginIfcfgClass { GObjectClass parent; }; -GType sc_plugin_ifcfg_get_type (void); +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 index 271b7bb1..bcb726aa 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright 2008 - 2014 Red Hat, Inc. + * Copyright 2008 - 2015 Red Hat, Inc. */ #include "config.h" @@ -31,8 +31,6 @@ #include <sys/ioctl.h> #include <unistd.h> -#include <glib.h> -#include <glib/gi18n.h> #include <nm-connection.h> #include <nm-dbus-interface.h> #include <nm-setting-connection.h> @@ -49,13 +47,12 @@ #include <nm-setting-bridge-port.h> #include <nm-setting-dcb.h> #include <nm-setting-generic.h> +#include "nm-default.h" #include "nm-core-internal.h" #include <nm-utils.h> #include "nm-platform.h" #include "NetworkManagerUtils.h" -#include "nm-logging.h" -#include "gsystem-local-alloc.h" #include "common.h" #include "shvar.h" @@ -131,6 +128,7 @@ make_connection_setting (const char *file, const char *prefix) { NMSettingConnection *s_con; + NMSettingConnectionLldp lldp; const char *ifcfg_name = NULL; char *new_id, *uuid = NULL, *zone = NULL, *value; @@ -168,17 +166,25 @@ make_connection_setting (const char *file, 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, - svTrueValue (ifcfg, "ONBOOT", TRUE), + 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, - svTrueValue (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), + svGetValueBoolean (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), + NM_SETTING_CONNECTION_LLDP, lldp, NULL); value = svGetValue (ifcfg, "USERS", FALSE); @@ -250,7 +256,7 @@ make_connection_setting (const char *file, g_free (value); } - switch (svTrueValue (ifcfg, "CONNECTION_METERED", -1)) { + switch (svGetValueBoolean (ifcfg, "CONNECTION_METERED", -1)) { case TRUE: g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_YES, NULL); break; @@ -274,8 +280,7 @@ read_ip4_address (shvarFile *ifcfg, 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); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); *out_addr = NULL; @@ -363,8 +368,7 @@ read_full_ip4_address (shvarFile *ifcfg, 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); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); ip_tag = get_numbered_tag ("IPADDR", which); prefix_tag = get_numbered_tag ("PREFIX", which); @@ -462,8 +466,7 @@ read_one_ip4_route (shvarFile *ifcfg, 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); - if (error) - g_return_val_if_fail (*error == 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); @@ -559,8 +562,7 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError * g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (s_ip4 != NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); /* Read the route file */ if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { @@ -678,6 +680,32 @@ error: 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, @@ -693,8 +721,7 @@ parse_full_ip6_address (shvarFile *ifcfg, 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); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); /* Split the address and prefix */ list = g_strsplit_set (addr_str, "/", 2); @@ -758,8 +785,7 @@ read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (s_ip6 != NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); /* Read the route file */ if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { @@ -892,6 +918,7 @@ make_ip4_setting (shvarFile *ifcfg, char *value = NULL; char *route_path = NULL; char *method; + char *dns_options = NULL; gs_free char *gateway = NULL; gint32 i; shvarFile *network_ifcfg; @@ -905,7 +932,7 @@ make_ip4_setting (shvarFile *ifcfg, * specified is DEFROUTE=yes which means that this connection can be used * as a default route */ - never_default = !svTrueValue (ifcfg, "DEFROUTE", TRUE); + never_default = !svGetValueBoolean (ifcfg, "DEFROUTE", TRUE); /* Then check if GATEWAYDEV; it's global and overrides DEFROUTE */ network_ifcfg = svOpenFile (network_file, NULL); @@ -915,6 +942,7 @@ make_ip4_setting (shvarFile *ifcfg, /* 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. @@ -979,10 +1007,10 @@ make_ip4_setting (shvarFile *ifcfg, g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "PEERDNS", TRUE), - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "PEERROUTES", TRUE), + 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, !svTrueValue (ifcfg, "IPV4_FAILURE_FATAL", FALSE), + 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); @@ -993,13 +1021,22 @@ make_ip4_setting (shvarFile *ifcfg, /* Handle DHCP settings */ if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); - if (value && strlen (value)) + 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, - svTrueValue (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), + NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), + NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXUINT32, 0), NULL); value = svGetValue (ifcfg, "DHCP_CLIENT_ID", FALSE); @@ -1101,6 +1138,14 @@ make_ip4_setting (shvarFile *ifcfg, 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; + /* Static routes - route-<name> file */ route_path = utils_get_route_path (ifcfg->fileName); @@ -1157,6 +1202,7 @@ make_ip4_setting (shvarFile *ifcfg, return NM_SETTING (s_ip4); done: + g_free (dns_options); g_free (route_path); g_object_unref (s_ip4); return NULL; @@ -1271,6 +1317,7 @@ make_ip6_setting (shvarFile *ifcfg, 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; @@ -1279,8 +1326,9 @@ make_ip6_setting (shvarFile *ifcfg, shvarFile *network_ifcfg; gboolean never_default = FALSE; gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip; - char *ip6_privacy_str; NMSettingIP6ConfigPrivacy ip6_privacy_val; + NMSettingIP6ConfigAddrGenMode addr_gen_mode; + char *tmp; s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); @@ -1289,7 +1337,7 @@ make_ip6_setting (shvarFile *ifcfg, * specified is IPV6_DEFROUTE=yes which means that this connection can be used * as a default route */ - never_default = !svTrueValue (ifcfg, "IPV6_DEFROUTE", TRUE); + never_default = !svGetValueBoolean (ifcfg, "IPV6_DEFROUTE", TRUE); /* Then check if IPV6_DEFAULTGW or IPV6_DEFAULTDEV is specified; * they are global and override IPV6_DEFROUTE @@ -1304,6 +1352,7 @@ make_ip6_setting (shvarFile *ifcfg, 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, '%'); @@ -1328,11 +1377,11 @@ make_ip6_setting (shvarFile *ifcfg, /* Find out method property */ /* Is IPV6 enabled? Set method to "ignored", when not enabled */ str_value = svGetValue (ifcfg, "IPV6INIT", FALSE); - ipv6init = svTrueValue (ifcfg, "IPV6INIT", FALSE); + ipv6init = svGetValueBoolean (ifcfg, "IPV6INIT", FALSE); if (!str_value) { network_ifcfg = svOpenFile (network_file, NULL); if (network_ifcfg) { - ipv6init = svTrueValue (network_ifcfg, "IPV6INIT", FALSE); + ipv6init = svGetValueBoolean (network_ifcfg, "IPV6INIT", FALSE); svCloseFile (network_ifcfg); } } @@ -1341,9 +1390,9 @@ make_ip6_setting (shvarFile *ifcfg, if (!ipv6init) method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; /* IPv6 is disabled */ else { - ipv6forwarding = svTrueValue (ifcfg, "IPV6FORWARDING", FALSE); - ipv6_autoconf = svTrueValue (ifcfg, "IPV6_AUTOCONF", !ipv6forwarding); - dhcp6 = svTrueValue (ifcfg, "DHCPV6C", FALSE); + 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; @@ -1363,27 +1412,27 @@ make_ip6_setting (shvarFile *ifcfg, /* TODO - handle other methods */ /* Read IPv6 Privacy Extensions configuration */ - ip6_privacy_str = svGetValue (ifcfg, "IPV6_PRIVACY", FALSE); - if (ip6_privacy_str) { - ip6_privacy = svTrueValue (ifcfg, "IPV6_PRIVACY", FALSE); + tmp = svGetValue (ifcfg, "IPV6_PRIVACY", FALSE); + if (tmp) { + ip6_privacy = svGetValueBoolean (ifcfg, "IPV6_PRIVACY", FALSE); if (!ip6_privacy) - ip6_privacy = g_strcmp0 (ip6_privacy_str, "rfc4941") == 0 || - g_strcmp0 (ip6_privacy_str, "rfc3041") == 0; + ip6_privacy = g_strcmp0 (tmp, "rfc4941") == 0 || + g_strcmp0 (tmp, "rfc3041") == 0; } - ip6_privacy_prefer_public_ip = svTrueValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", FALSE); - ip6_privacy_val = ip6_privacy_str ? + 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 (ip6_privacy_str); + g_free (tmp); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "IPV6_PEERDNS", TRUE), - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "IPV6_PEERROUTES", TRUE), + 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, !svTrueValue (ifcfg, "IPV6_FAILURE_FATAL", FALSE), + 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, @@ -1460,6 +1509,22 @@ make_ip6_setting (shvarFile *ifcfg, } } + /* 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); + } + /* DNS servers * Pick up just IPv6 addresses (IPv4 addresses are taken by make_ip4_setting()) */ @@ -1500,9 +1565,17 @@ make_ip6_setting (shvarFile *ifcfg, 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); + return NM_SETTING (s_ip6); error: + g_free (dns_options); g_free (route6_path); g_object_unref (s_ip6); return NULL; @@ -1579,11 +1652,11 @@ read_dcb_flags (shvarFile *ifcfg, DcbFlagsProperty *property) { NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; - if (svTrueValue (ifcfg, property->enable_key, FALSE)) + if (svGetValueBoolean (ifcfg, property->enable_key, FALSE)) flags |= NM_SETTING_DCB_FLAG_ENABLE; - if (svTrueValue (ifcfg, property->advertise_key, FALSE)) + if (svGetValueBoolean (ifcfg, property->advertise_key, FALSE)) flags |= NM_SETTING_DCB_FLAG_ADVERTISE; - if (svTrueValue (ifcfg, property->willing_key, FALSE)) + if (svGetValueBoolean (ifcfg, property->willing_key, FALSE)) flags |= NM_SETTING_DCB_FLAG_WILLING; return flags; @@ -1813,7 +1886,7 @@ make_dcb_setting (shvarFile *ifcfg, g_return_val_if_fail (out_setting != NULL, FALSE); - dcb_on = !!svTrueValue (ifcfg, "DCB", FALSE); + dcb_on = !!svGetValueBoolean (ifcfg, "DCB", FALSE); if (!dcb_on) return TRUE; @@ -2611,7 +2684,7 @@ eap_peap_reader (const char *eap_method, } } - if (svTrueValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", FALSE)) + 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); @@ -3052,9 +3125,9 @@ make_wpa_setting (shvarFile *ifcfg, allow_wpa = svGetValue (ifcfg, "WPA_ALLOW_WPA", FALSE); allow_rsn = svGetValue (ifcfg, "WPA_ALLOW_WPA2", FALSE); - if (allow_wpa && svTrueValue (ifcfg, "WPA_ALLOW_WPA", TRUE)) + if (allow_wpa && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA", TRUE)) nm_setting_wireless_security_add_proto (wsec, "wpa"); - if (allow_rsn && svTrueValue (ifcfg, "WPA_ALLOW_WPA2", TRUE)) + if (allow_rsn && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA2", TRUE)) nm_setting_wireless_security_add_proto (wsec, "rsn"); /* If neither WPA_ALLOW_WPA or WPA_ALLOW_WPA2 were present, default @@ -3250,6 +3323,7 @@ make_wireless_setting (shvarFile *ifcfg, NMSettingWireless *s_wireless; char *value = NULL; gint64 chan = 0; + NMSettingMacRandomization mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); @@ -3424,7 +3498,34 @@ make_wireless_setting (shvarFile *ifcfg, g_object_set (s_wireless, NM_SETTING_WIRELESS_HIDDEN, - svTrueValue (ifcfg, "SSID_HIDDEN", FALSE), + svGetValueBoolean (ifcfg, "SSID_HIDDEN", FALSE), + NULL); + + g_object_set (s_wireless, + NM_SETTING_WIRELESS_POWERSAVE, + svGetValueBoolean (ifcfg, "POWERSAVE", FALSE) ? 1 : 0, + 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); + 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); @@ -3907,12 +4008,12 @@ make_infiniband_setting (shvarFile *ifcfg, g_free (value); } - if (svTrueValue (ifcfg, "CONNECTED_MODE", FALSE)) + 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 (svTrueValue (ifcfg, "PKEY", FALSE)) { + if (svGetValueBoolean (ifcfg, "PKEY", FALSE)) { int p_key; char *parent; @@ -4230,6 +4331,12 @@ handle_bridge_option (NMSetting *setting, 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); } @@ -4443,7 +4550,7 @@ 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 (svTrueValue (parsed, "BONDING_MASTER", FALSE)) + if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE)) return TRUE; /* XXX: Check for "bond[\d]+"? */ @@ -4457,7 +4564,7 @@ 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 (svTrueValue (parsed, "VLAN", FALSE)) + if (svGetValueBoolean (parsed, "VLAN", FALSE)) return TRUE; return FALSE; @@ -4517,6 +4624,7 @@ make_vlan_setting (shvarFile *ifcfg, char *end = NULL; gint vlan_id = -1; guint32 vlan_flags = 0; + gint gvrp; value = svGetValue (ifcfg, "VLAN_ID", FALSE); if (value) { @@ -4591,17 +4699,25 @@ make_vlan_setting (shvarFile *ifcfg, g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, parent, NULL); g_clear_pointer (&parent, g_free); - if (svTrueValue (ifcfg, "REORDER_HDR", FALSE)) + if (svGetValueBoolean (ifcfg, "REORDER_HDR", FALSE)) 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) { - if (g_strstr_len (value, -1, "GVRP")) + /* Prefer GVRP variable; only take VLAN_FLAG=GVRP when GVRP is not specified */ + if (g_strstr_len (value, -1, "GVRP") && gvrp == -1) vlan_flags |= NM_VLAN_FLAG_GVRP; if (g_strstr_len (value, -1, "LOOSE_BINDING")) vlan_flags |= NM_VLAN_FLAG_LOOSE_BINDING; } + 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); @@ -4807,7 +4923,7 @@ connection_from_file_full (const char *filename, if (!parsed) return NULL; - if (!svTrueValue (parsed, "NM_CONTROLLED", TRUE)) { + if (!svGetValueBoolean (parsed, "NM_CONTROLLED", TRUE)) { g_assert (out_unhandled != NULL); connection = create_unhandled_connection (filename, parsed, "unmanaged", out_unhandled); @@ -4886,7 +5002,7 @@ connection_from_file_full (const char *filename, } } - if (svTrueValue (parsed, "BONDING_MASTER", FALSE) && + 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"); diff --git a/src/settings/plugins/ifcfg-rh/reader.h b/src/settings/plugins/ifcfg-rh/reader.h index 2096ffc4..88f9a720 100644 --- a/src/settings/plugins/ifcfg-rh/reader.h +++ b/src/settings/plugins/ifcfg-rh/reader.h @@ -21,9 +21,9 @@ #ifndef __READER_H__ #define __READER_H__ -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" #include "shvar.h" NMConnection *connection_from_file (const char *filename, diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 5fd7755f..43068c67 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -36,9 +36,8 @@ #include "shvar.h" -#include "gsystem-local-alloc.h" #include "nm-core-internal.h" -#include "nm-logging.h" +#include "nm-default.h" #define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg) @@ -299,35 +298,55 @@ svGetValueFull (shvarFile *s, const char *key, gboolean verbatim) return value; } -/* return TRUE if <key> resolves to any truth value (e.g. "yes", "true", "y", "t", "1") - * return FALSE if <key> resolves to any non-truth value (e.g. "no", "false", "n", "f", "0") - * return <default> otherwise +/** + * 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. */ gint -svTrueValue (shvarFile *s, const char *key, gint def) +svParseBoolean (const char *value, gint fallback) { - char *tmp; - gint returnValue = def; + if (!value) + return fallback; - tmp = svGetValue (s, key, FALSE); - if (!tmp) - return returnValue; - - if ( !g_ascii_strcasecmp ("yes", tmp) - || !g_ascii_strcasecmp ("true", tmp) - || !g_ascii_strcasecmp ("t", tmp) - || !g_ascii_strcasecmp ("y", tmp) - || !g_ascii_strcasecmp ("1", tmp)) - returnValue = TRUE; - else if ( !g_ascii_strcasecmp ("no", tmp) - || !g_ascii_strcasecmp ("false", tmp) - || !g_ascii_strcasecmp ("f", tmp) - || !g_ascii_strcasecmp ("n", tmp) - || !g_ascii_strcasecmp ("0", tmp)) - returnValue = FALSE; + 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; +} - g_free (tmp); - return returnValue; +/* svGetValueBoolean: + * @s: fhe file + * @key: the name of the key to read + * @fallback: the fallback value in any error case + * + * Reads a value @key and converts it to a boolean using svParseBoolean(). + * + * Returns: the parsed boolean value or @fallback. + */ +gint +svGetValueBoolean (shvarFile *s, const char *key, gint fallback) +{ + gs_free char *tmp = NULL; + + tmp = svGetValue (s, key, FALSE); + return svParseBoolean (tmp, fallback); } /* svGetValueInt64: @@ -426,6 +445,15 @@ svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verba g_free (keyValue); } +void +svSetValueInt64 (shvarFile *s, const char *key, gint64 value) +{ + gs_free char *v = NULL; + + v = g_strdup_printf ("%"G_GINT64_FORMAT, value); + svSetValueFull (s, key, v, TRUE); +} + /* 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 diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index de7a3585..227a44db 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -31,7 +31,7 @@ #ifndef _SHVAR_H #define _SHVAR_H -#include <glib.h> +#include "nm-default.h" G_BEGIN_DECLS @@ -58,11 +58,13 @@ shvarFile *svOpenFile (const char *name, GError **error); char *svGetValue (shvarFile *s, const char *key, gboolean verbatim); char *svGetValueFull (shvarFile *s, const char *key, gboolean verbatim); +gint svParseBoolean (const char *value, gint def); + /* return TRUE if <key> resolves to any truth value (e.g. "yes", "y", "true") * return FALSE if <key> resolves to any non-truth value (e.g. "no", "n", "false") * return <def> otherwise */ -gint svTrueValue (shvarFile *s, const char *key, gint def); +gint svGetValueBoolean (shvarFile *s, const char *key, gint def); gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback); @@ -73,6 +75,7 @@ gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, g */ 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 svSetValueInt64 (shvarFile *s, const char *key, gint64 value); /* Write the current contents iff modified. Returns FALSE on error diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am index 73f3b5d8..25d27197 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am @@ -7,8 +7,8 @@ SUBDIRS=network-scripts AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src/ \ @@ -16,7 +16,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @@ -25,7 +25,6 @@ AM_CPPFLAGS = \ AM_LDFLAGS = \ $(GLIB_LIBS) \ - $(DBUS_LIBS) \ $(CODE_COVERAGE_LDFLAGS) noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in index da25c8b9..00636de9 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.in @@ -459,7 +459,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -471,8 +470,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -482,6 +479,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -536,16 +534,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -582,6 +577,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -610,7 +607,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -625,6 +621,8 @@ 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@ @@ -685,6 +683,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -692,6 +691,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -711,8 +711,8 @@ 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)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@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/ \ @@ -720,7 +720,7 @@ with_valgrind = @with_valgrind@ @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 \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ @ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @@ -729,7 +729,6 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_LDFLAGS = \ @ENABLE_TESTS_TRUE@ $(GLIB_LIBS) \ -@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) @ENABLE_TESTS_TRUE@test_ifcfg_rh_SOURCES = \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index c3fde548..a1b414fd 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -67,6 +67,10 @@ EXTRA_DIST = \ 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 \ @@ -102,6 +106,8 @@ EXTRA_DIST = \ ifcfg-test-vlan-only-device \ ifcfg-test-vlan-physdev \ ifcfg-test-vlan-reorder-hdr-1 \ + 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 \ @@ -127,6 +133,7 @@ EXTRA_DIST = \ ifcfg-test-team-port \ 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 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in index 4add27b7..cae7067e 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in @@ -146,7 +146,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -158,8 +157,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -169,6 +166,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -223,16 +221,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -269,6 +264,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -297,7 +294,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -312,6 +308,8 @@ 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@ @@ -372,6 +370,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -379,6 +378,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -463,6 +463,10 @@ EXTRA_DIST = \ 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 \ @@ -498,6 +502,8 @@ EXTRA_DIST = \ ifcfg-test-vlan-only-device \ ifcfg-test-vlan-physdev \ ifcfg-test-vlan-reorder-hdr-1 \ + 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 \ @@ -523,6 +529,7 @@ EXTRA_DIST = \ ifcfg-test-team-port \ 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 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main index ee7a8dc6..1d31b5ba 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main @@ -4,5 +4,5 @@ TYPE=Bridge BOOTPROTO=dhcp STP=on DELAY=2 -BRIDGING_OPTS="priority=32744 hello_time=7 max_age=39 ageing_time=235352" +BRIDGING_OPTS="priority=32744 hello_time=7 max_age=39 ageing_time=235352 multicast_snooping=0" MACADDR=00:16:41:11:22:33 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-dns-options b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-dns-options new file mode 100644 index 00000000..62e301e3 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-dns-options @@ -0,0 +1,15 @@ +TYPE=Ethernet +DEVICE=eth2 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=dhcp +ONBOOT=yes +USERCTL=yes +NM_CONTROLLED=yes +PEERDNS=yes +DNS1=10.2.0.4 +DOMAIN="lorem.com ipsum.org dolor.edu" +RES_OPTIONS="ndots:3 single-request-reopen inet6" +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR="1001:abba::1234/56" +IPV6ADDR_SECONDARIES="2001:abba::2234/64 3001:abba::3234/96" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-1 new file mode 100644 index 00000000..5ff87891 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-1 @@ -0,0 +1,14 @@ +VLAN=yes +TYPE=Vlan +DEVICE=super-vlan +VLAN_ID=44 +PHYSDEV=eth9 +REORDER_HDR=yes +GVRP=no +VLAN_FLAGS="GVRP LOOSE_BINDING" +VLAN_INGRESS_PRIORITY_MAP=0:1,2:5 +VLAN_EGRESS_PRIORITY_MAP=12:3,14:7,3:1 +ONBOOT=yes +BOOTPROTO=static +IPADDR=192.168.43.149 +NETMASK=255.255.255.0 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-2 new file mode 100644 index 00000000..3b536a66 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-2 @@ -0,0 +1,11 @@ +VLAN=yes +TYPE=Vlan +DEVICE=super-vlan +VLAN_ID=44 +PHYSDEV=eth9 +REORDER_HDR=no +VLAN_FLAGS="GVRP LOOSE_BINDING" +ONBOOT=yes +BOOTPROTO=static +IPADDR=192.168.43.149 +NETMASK=255.255.255.0 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-always b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-always new file mode 100644 index 00000000..9dcb5bf8 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-always @@ -0,0 +1,7 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes +MAC_ADDRESS_RANDOMIZATION=always + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-default b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-default new file mode 100644 index 00000000..3709c493 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-default @@ -0,0 +1,6 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes +MAC_ADDRESS_RANDOMIZATION=default diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-missing b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-missing new file mode 100644 index 00000000..f896eb0f --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-missing @@ -0,0 +1,6 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-never b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-never new file mode 100644 index 00000000..aa12d749 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-never @@ -0,0 +1,6 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes +MAC_ADDRESS_RANDOMIZATION=never diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static index c8315f45..6d49c01c 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static @@ -18,3 +18,4 @@ IPV6ADDR=dead:beaf::1 IPV6ADDR_SECONDARIES="dead:beaf::2/56" DNS3=1:2:3:4::a DNS4=1:2:3:4::b +RES_OPTIONS= diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto index ee821503..a01f6558 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto @@ -13,3 +13,4 @@ DNS2=4.2.2.2 IPADDR=192.168.1.5 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 +RES_OPTIONS= 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 cd2d0417..b7a887d0 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -54,10 +54,16 @@ #include "reader.h" #include "writer.h" #include "utils.h" -#include "nm-logging.h" +#include "nm-default.h" #include "nm-test-utils.h" +typedef struct { + const char *name; + const NMSettingMacRandomization value; + const char *write_expected; +} WifiMacRandomData; + #if 0 static void connection_diff (NMConnection *a, NMConnection *b) @@ -484,6 +490,9 @@ test_read_wired_static (const char *file, g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); g_assert (nm_setting_ip_config_get_may_fail (s_ip4)); + g_assert (nm_setting_ip_config_has_dns_options (s_ip4)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip4), ==, 0); + /* DNS Addresses */ g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 2); g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 0), ==, "4.2.2.1"); @@ -506,6 +515,9 @@ test_read_wired_static (const char *file, g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_MANUAL); g_assert (nm_setting_ip_config_get_may_fail (s_ip6)); + g_assert (nm_setting_ip_config_has_dns_options (s_ip6)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip6), ==, 0); + /* DNS Addresses */ g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 2); g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip6, 0), ==, "1:2:3:4::a"); @@ -525,6 +537,7 @@ test_read_wired_static (const char *file, g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "dead:beaf::2"); } else { g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); + g_assert (!nm_setting_ip_config_has_dns_options (s_ip6)); } g_object_unref (connection); @@ -563,6 +576,9 @@ test_read_wired_static_no_prefix (gconstpointer user_data) g_assert (s_ip4); g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); + g_assert (!nm_setting_ip_config_has_dns_options (s_ip4)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip4), ==, 0); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1); ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); g_assert (ip4_addr); @@ -2535,6 +2551,165 @@ test_read_wired_aliases_bad_2 (void) test_read_wired_aliases_bad (TEST_IFCFG_ALIASES_BAD_2, "System aliasem2"); } +#define TEST_IFCFG_DNS_OPTIONS TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dns-options" + +static void +test_read_dns_options (void) +{ + NMConnection *connection; + NMSettingIPConfig *s_ip4, *s_ip6; + char *unmanaged = NULL; + const char *option; + GError *error = NULL; + const char *options[] = { "ndots:3", "single-request-reopen", "inet6" }; + guint32 i, options_len = sizeof (options) / sizeof (options[0]); + + connection = connection_from_file_test (TEST_IFCFG_DNS_OPTIONS, + NULL, + TYPE_ETHERNET, + &unmanaged, + &error); + g_assert (connection); + g_assert (nm_connection_verify (connection, &error)); + g_assert_cmpstr (unmanaged, ==, NULL); + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + g_assert (s_ip4); + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + g_assert (s_ip6); + + i = nm_setting_ip_config_get_num_dns_options (s_ip4); + g_assert_cmpint (i, ==, options_len); + + i = nm_setting_ip_config_get_num_dns_options (s_ip6); + g_assert_cmpint (i, ==, options_len); + + for (i = 0; i < options_len; i++) { + option = nm_setting_ip_config_get_dns_option (s_ip4, i); + g_assert_cmpstr (options[i], ==, option); + + option = nm_setting_ip_config_get_dns_option (s_ip6, i); + g_assert_cmpstr (options[i], ==, option); + } + + g_object_unref (connection); +} + +static void +test_write_dns_options (void) +{ + NMConnection *connection; + NMConnection *reread; + 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; + gboolean success; + GError *error = NULL; + char *testfile = NULL; + + 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 DNS options", + NM_SETTING_CONNECTION_UUID, uuid, + 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 (); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + g_object_set (s_wired, + NM_SETTING_WIRED_MAC_ADDRESS, mac, + NM_SETTING_WIRED_MTU, mtu, + 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_MANUAL, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) 204, + NULL); + + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); + + /* IP6 setting */ + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ip6)); + + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) 206, + NULL); + + /* Add addresses */ + addr6 = nm_ip_address_new (AF_INET6, "1003:1234:abcd::1", 11, &error); + nm_setting_ip_config_add_address (s_ip6, addr6); + nm_ip_address_unref (addr6); + + nm_setting_ip_config_add_dns_option (s_ip4, "debug"); + nm_setting_ip_config_add_dns_option (s_ip6, "timeout:3"); + + g_assert (nm_connection_verify (connection, &error)); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert (success); + g_assert (testfile); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (testfile, + NULL, + TYPE_ETHERNET, + NULL, + &error); + unlink (testfile); + + /* RES_OPTIONS is copied to both IPv4 and IPv6 settings */ + nm_setting_ip_config_clear_dns_options (s_ip4, TRUE); + nm_setting_ip_config_add_dns_option (s_ip4, "debug"); + nm_setting_ip_config_add_dns_option (s_ip4, "timeout:3"); + + nm_setting_ip_config_clear_dns_options (s_ip6, TRUE); + nm_setting_ip_config_add_dns_option (s_ip6, "debug"); + nm_setting_ip_config_add_dns_option (s_ip6, "timeout:3"); + + g_assert (reread); + g_assert (nm_connection_verify (reread, &error)); + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + g_free (testfile); + g_object_unref (connection); + g_object_unref (reread); +} + #define TEST_IFCFG_WIFI_OPEN TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open" static void @@ -5297,6 +5472,117 @@ test_write_wifi_hidden (void) } static void +test_read_wifi_mac_random (gconstpointer user_data) +{ + const WifiMacRandomData *test_data = user_data; + NMConnection *connection; + NMSettingWireless *s_wifi; + gboolean success; + GError *error = NULL; + char *path; + + path = g_strdup_printf (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-mac-random-%s", test_data->name); + connection = connection_from_file_test (path, NULL, TYPE_WIRELESS, NULL, &error); + g_free (path); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + s_wifi = nm_connection_get_setting_wireless (connection); + g_assert (s_wifi); + g_assert_cmpint (nm_setting_wireless_get_mac_address_randomization (s_wifi), ==, test_data->value); + + g_object_unref (connection); +} + +static void +test_write_wifi_mac_random (gconstpointer user_data) +{ + const WifiMacRandomData *test_data = user_data; + NMConnection *connection, *reread; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + char *uuid, *testfile = NULL, *val; + gboolean success; + GError *error = NULL; + shvarFile *f; + GBytes *ssid; + const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; + + 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 (); + val = g_strdup_printf ("Test Write WiFi MAC %s", test_data->name); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, val, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + g_free (val); + + /* 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_MODE, "infrastructure", + NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, test_data->value, + NULL); + g_bytes_unref (ssid); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert_no_error (error); + g_assert (success); + + 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, ==, test_data->write_expected); + g_free (val); + svCloseFile (f); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (testfile, NULL, TYPE_WIRELESS, NULL, &error); + unlink (testfile); + g_assert_no_error (error); + g_assert (reread); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + g_assert (success); + + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + g_free (testfile); + g_object_unref (connection); + g_object_unref (reread); +} + +static void test_write_wired_wake_on_lan (void) { NMConnection *connection, *reread; @@ -6356,7 +6642,6 @@ test_write_wired_static_ip6_only (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -6441,7 +6726,6 @@ test_write_wired_static_ip6_only (void) "wired-static-ip6-only-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -6592,8 +6876,8 @@ test_read_write_static_routes_legacy (void) NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; char *testfile = NULL; - char *routefile2 = NULL; - char *route6file2 = NULL; + char *routefile = NULL; + char *route6file = NULL; gboolean success; GError *error = NULL; const char *tmp; @@ -6689,17 +6973,14 @@ test_read_write_static_routes_legacy (void) NULL, &error); unlink (testfile); - routefile2 = utils_get_route_path (testfile); - unlink (routefile2); - route6file2 = utils_get_route6_path (testfile); - unlink (route6file2); + routefile = utils_get_route_path (testfile); + unlink (routefile); + route6file = utils_get_route6_path (testfile); + unlink (route6file); ASSERT (reread != NULL, "read-write-static-routes-legacy-reread", "failed to read %s: %s", testfile, error->message); - ASSERT (routefile2 != NULL, - "read-write-static-routes-legacy-reread", "expected routefile for '%s'", testfile); - ASSERT (nm_connection_verify (reread, &error), "read-write-static-routes-legacy-reread-verify", "failed to verify %s: %s", testfile, error->message); @@ -6707,8 +6988,8 @@ test_read_write_static_routes_legacy (void) "read-write-static-routes-legacy-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (routefile2); - g_free (route6file2); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9859,7 +10140,6 @@ test_write_wired_qeth_dhcp (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -9947,7 +10227,6 @@ test_write_wired_qeth_dhcp (void) "wired-qeth-dhcp-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9966,7 +10245,6 @@ test_write_wired_ctc_dhcp (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; shvarFile *ifcfg; char *tmp; @@ -10066,7 +10344,6 @@ test_write_wired_ctc_dhcp (void) g_assert (success); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10084,7 +10361,6 @@ test_write_permissions (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -10164,7 +10440,6 @@ test_write_permissions (void) "permissions-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10185,7 +10460,6 @@ test_write_wifi_wep_agent_keys (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); g_assert (connection != NULL); @@ -10290,7 +10564,6 @@ test_write_wifi_wep_agent_keys (void) g_assert (success); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10544,6 +10817,7 @@ test_read_bridge_main (void) g_assert_cmpuint (nm_setting_bridge_get_hello_time (s_bridge), ==, 7); 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 (!nm_setting_bridge_get_multicast_snooping (s_bridge)); /* MAC address */ mac = nm_setting_bridge_get_mac_address (s_bridge); @@ -10702,7 +10976,6 @@ test_write_bridge_component (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); g_assert (connection); @@ -10773,7 +11046,6 @@ test_write_bridge_component (void) g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10849,17 +11121,17 @@ test_read_vlan_interface (void) g_assert_cmpint (nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP), ==, 3); g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 0, &from, &to)); + g_assert_cmpint (from, ==, 3); + g_assert_cmpint (to, ==, 1); + + g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 1, &from, &to)); g_assert_cmpint (from, ==, 12); g_assert_cmpint (to, ==, 3); - g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 1, &from, &to)); + g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 2, &from, &to)); g_assert_cmpint (from, ==, 14); g_assert_cmpint (to, ==, 7); - g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 2, &from, &to)); - g_assert_cmpint (from, ==, 3); - g_assert_cmpint (to, ==, 1); - g_object_unref (connection); } @@ -10976,6 +11248,62 @@ test_read_vlan_reorder_hdr_1 (void) } static void +test_read_vlan_flags_1 (void) +{ + NMConnection *connection; + GError *error = NULL; + NMSettingVlan *s_vlan; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-1", + NULL, + TYPE_ETHERNET, + NULL, + &error); + g_assert_no_error (error); + g_assert (connection != NULL); + + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "super-vlan"); + + s_vlan = nm_connection_get_setting_vlan (connection); + g_assert (s_vlan); + + g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9"); + g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 44); + /* reorder_hdr and loose_binding */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 5); + + g_object_unref (connection); +} + +static void +test_read_vlan_flags_2 (void) +{ + NMConnection *connection; + GError *error = NULL; + NMSettingVlan *s_vlan; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-2", + NULL, + TYPE_ETHERNET, + NULL, + &error); + g_assert_no_error (error); + g_assert (connection != NULL); + + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "super-vlan"); + + s_vlan = nm_connection_get_setting_vlan (connection); + g_assert (s_vlan); + + g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9"); + g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 44); + /* gvrp and loose_binding */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 6); + + g_object_unref (connection); +} + +static void test_write_vlan (void) { NMConnection *connection; @@ -11003,6 +11331,54 @@ test_write_vlan (void) } static void +test_write_vlan_flags (void) +{ + NMConnection *connection, *reread; + char *written = NULL; + GError *error = NULL; + gboolean success = FALSE; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-2", + NULL, + TYPE_VLAN, + NULL, + &error); + g_assert (connection != NULL); + + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &written, + &error); + g_assert (success); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (written, + NULL, + TYPE_ETHERNET, + NULL, + &error); + + unlink (written); + g_free (written); + + g_assert_no_error (error); + g_assert (reread != NULL); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + g_assert (success); + + success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT); + g_assert (success); + + g_object_unref (connection); + g_object_unref (reread); +} + +static void test_write_vlan_only_vlanid (void) { NMConnection *connection, *reread; @@ -11434,7 +11810,6 @@ test_write_bond_slave (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -11499,7 +11874,6 @@ test_write_bond_slave (void) "bond-slave-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -11724,7 +12098,6 @@ test_write_bond_slave_ib (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -11790,7 +12163,6 @@ test_write_bond_slave_ib (void) "bond-slave-write-ib", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -12741,6 +13113,7 @@ int main (int argc, char **argv) g_test_add_data_func (TPATH "static-ip6-only-gw/::", "::", test_write_wired_static_ip6_only_gw); g_test_add_data_func (TPATH "static-ip6-only-gw/2001:db8:8:4::2", "2001:db8:8:4::2", test_write_wired_static_ip6_only_gw); g_test_add_data_func (TPATH "static-ip6-only-gw/::ffff:255.255.255.255", "::ffff:255.255.255.255", test_write_wired_static_ip6_only_gw); + g_test_add_func (TPATH "read-dns-options", test_read_dns_options); test_read_wired_static (TEST_IFCFG_WIRED_STATIC, "System test-wired-static", TRUE); test_read_wired_static (TEST_IFCFG_WIRED_STATIC_BOOTPROTO, "System test-wired-static-bootproto", FALSE); @@ -12805,6 +13178,35 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wifi/read-band-a-channel-mismatch", test_read_wifi_band_a_channel_mismatch); g_test_add_func (TPATH "wifi/read-band-bg-channel-mismatch", test_read_wifi_band_bg_channel_mismatch); g_test_add_func (TPATH "wifi/read-hidden", test_read_wifi_hidden); + + { + static const WifiMacRandomData test_wifi_mac_random[] = { + { "always", NM_SETTING_MAC_RANDOMIZATION_ALWAYS, "always" }, + { "never", NM_SETTING_MAC_RANDOMIZATION_NEVER, "never" }, + { "default", NM_SETTING_MAC_RANDOMIZATION_DEFAULT, "default" }, + { "missing", NM_SETTING_MAC_RANDOMIZATION_NEVER, "never" }, + }; + int i; + + for (i = 0; i < G_N_ELEMENTS (test_wifi_mac_random); i++) { + char *tpath; + + tpath = g_strdup_printf (TPATH "wifi/read-mac-random-%s", test_wifi_mac_random[i].name); + g_test_add_data_func_full (tpath, + g_memdup (&test_wifi_mac_random[i], sizeof (test_wifi_mac_random[i])), + test_read_wifi_mac_random, + g_free); + g_free (tpath); + + tpath = g_strdup_printf (TPATH "wifi/write-mac-random-%s", test_wifi_mac_random[i].name); + g_test_add_data_func_full (tpath, + g_memdup (&test_wifi_mac_random[i], sizeof (test_wifi_mac_random[i])), + test_write_wifi_mac_random, + g_free); + g_free (tpath); + } + } + test_read_wired_qeth_static (); test_read_wired_ctc_static (); test_read_wifi_wep_no_keys (); @@ -12812,6 +13214,8 @@ int main (int argc, char **argv) test_read_wifi_wep_agent_keys (); test_read_infiniband (); test_read_vlan_interface (); + g_test_add_func (TPATH "vlan/read-flags-1", test_read_vlan_flags_1); + g_test_add_func (TPATH "vlan/read-flags-2", test_read_vlan_flags_2); test_read_vlan_only_vlan_id (); test_read_vlan_only_device (); g_test_add_func (TPATH "vlan/physdev", test_read_vlan_physdev); @@ -12894,9 +13298,11 @@ int main (int argc, char **argv) test_write_wifi_wep_agent_keys (); test_write_infiniband (); test_write_vlan (); + g_test_add_func (TPATH "vlan/write-flags", test_write_vlan_flags); test_write_vlan_only_vlanid (); g_test_add_func (TPATH "vlan/write-vlan-reorder-hdr", test_write_vlan_reorder_hdr); test_write_ethernet_missing_ipv6 (); + g_test_add_func (TPATH "write-dns-options", test_write_dns_options); /* iSCSI / ibft */ g_test_add_func (TPATH "ibft/ignored", test_read_ibft_ignored); diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c index a793288d..599e3a49 100644 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ b/src/settings/plugins/ifcfg-rh/utils.c @@ -20,14 +20,13 @@ #include "config.h" -#include <glib.h> #include <stdlib.h> #include <string.h> +#include "nm-default.h" #include "nm-core-internal.h" #include "nm-macros-internal.h" #include "NetworkManagerUtils.h" -#include "gsystem-local-alloc.h" #include "utils.h" #include "shvar.h" diff --git a/src/settings/plugins/ifcfg-rh/utils.h b/src/settings/plugins/ifcfg-rh/utils.h index 547bfcb2..329f4547 100644 --- a/src/settings/plugins/ifcfg-rh/utils.h +++ b/src/settings/plugins/ifcfg-rh/utils.h @@ -21,11 +21,10 @@ #ifndef _UTILS_H_ #define _UTILS_H_ -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" #include "shvar.h" #include "common.h" -#include "nm-logging.h" #define NM_IFCFG_CONNECTION_LOG_PATH(path) str_if_set (path,"in-memory") #define NM_IFCFG_CONNECTION_LOG_FMT "%s (%s,\"%s\")" diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 3640a104..5770d668 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright 2009 - 2014 Red Hat, Inc. + * Copyright 2009 - 2015 Red Hat, Inc. */ #include "config.h" @@ -45,8 +45,7 @@ #include "nm-core-internal.h" #include "nm-macros-internal.h" -#include "nm-logging.h" -#include "gsystem-local-alloc.h" +#include "nm-default.h" #include "common.h" #include "shvar.h" #include "reader.h" @@ -968,7 +967,7 @@ write_wireless_setting (NMConnection *connection, 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); @@ -988,6 +987,21 @@ write_wireless_setting (NMConnection *connection, } svSetValue (ifcfg, "SSID_HIDDEN", nm_setting_wireless_get_hidden (s_wireless) ? "yes" : NULL, TRUE); + svSetValue (ifcfg, "POWERSAVE", nm_setting_wireless_get_powersave (s_wireless) ? "yes" : NULL, TRUE); + + 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); @@ -1268,15 +1282,14 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, else svSetValue (ifcfg, "REORDER_HDR", "no", FALSE); + svSetValue (ifcfg, "GVRP", vlan_flags & NM_VLAN_FLAG_GVRP ? "yes" : "no", FALSE); + svSetValue (ifcfg, "VLAN_FLAGS", NULL, FALSE); - if (vlan_flags & NM_VLAN_FLAG_GVRP) { - if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) - svSetValue (ifcfg, "VLAN_FLAGS", "GVRP,LOOSE_BINDING", FALSE); - else - svSetValue (ifcfg, "VLAN_FLAGS", "GVRP", FALSE); - } else if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) + if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) svSetValue (ifcfg, "VLAN_FLAGS", "LOOSE_BINDING", 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); @@ -1380,7 +1393,7 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, } static guint32 -get_setting_default (NMSetting *setting, const char *prop) +get_setting_default_uint (NMSetting *setting, const char *prop) { GParamSpec *pspec; GValue val = G_VALUE_INIT; @@ -1397,11 +1410,29 @@ get_setting_default (NMSetting *setting, const char *prop) } 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; @@ -1435,7 +1466,7 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error svSetValue (ifcfg, "STP", "yes", FALSE); i = nm_setting_bridge_get_forward_delay (s_bridge); - if (i != get_setting_default (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_FORWARD_DELAY)) { + 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); @@ -1444,14 +1475,14 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error 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 (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_HELLO_TIME)) { + 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 (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MAX_AGE)) { + 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); @@ -1459,12 +1490,19 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error } i = nm_setting_bridge_get_ageing_time (s_bridge); - if (i != get_setting_default (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_AGEING_TIME)) { + 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); @@ -1491,11 +1529,11 @@ write_bridge_port_setting (NMConnection *connection, shvarFile *ifcfg, GError ** opts = g_string_sized_new (32); i = nm_setting_bridge_port_get_priority (s_port); - if (i != get_setting_default (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PRIORITY)) + 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 (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PATH_COST)) { + 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); @@ -1753,6 +1791,18 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) 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); @@ -1897,6 +1947,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) gint32 j; guint32 i, n, num; gint64 route_metric; + int dhcp_timeout; GString *searches; gboolean success = FALSE; gboolean fake_ip4 = FALSE; @@ -2090,6 +2141,10 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) 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 */ @@ -2100,6 +2155,11 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)); if (value) svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE); + + dhcp_timeout = nm_setting_ip4_config_get_dhcp_timeout (NM_SETTING_IP4_CONFIG (s_ip4)); + tmp = dhcp_timeout ? g_strdup_printf ("%d", dhcp_timeout) : NULL; + svSetValue (ifcfg, "IPV4_DHCP_TIMEOUT", tmp, FALSE); + g_free (tmp); } svSetValue (ifcfg, "IPV4_FAILURE_FATAL", @@ -2353,6 +2413,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) 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) { @@ -2365,6 +2426,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (ifcfg, "IPV6_PEERROUTES", "yes", FALSE); svSetValue (ifcfg, "IPV6_FAILURE_FATAL", "no", FALSE); svSetValue (ifcfg, "IPV6_ROUTE_METRIC", NULL, FALSE); + svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", "stable-privacy", FALSE); return TRUE; } @@ -2502,6 +2564,15 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) 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); + } + /* Static routes go to route6-<dev> file */ route6_path = utils_get_route6_path (ifcfg->fileName); if (!route6_path) { @@ -2520,6 +2591,63 @@ 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; + GPtrArray *array; + GString *value; + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + s_ip6 = nm_connection_get_setting_ip6_config (connection); + array = g_ptr_array_new (); + + if (s_ip4) { + 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)); + } + } + + if (s_ip6) { + 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 + || (s_ip4 && nm_setting_ip_config_has_dns_options (s_ip4)) + || (s_ip6 && 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); + + g_ptr_array_unref (array); + return TRUE; +} + static char * escape_id (const char *id) { @@ -2660,6 +2788,7 @@ write_connection (NMConnection *connection, if (!utils_ignore_ip_config (connection)) { svSetValue (ifcfg, "DHCP_HOSTNAME", NULL, FALSE); + svSetValue (ifcfg, "DHCP_FQDN", NULL, FALSE); if (!write_ip4_setting (connection, ifcfg, error)) goto out; @@ -2667,6 +2796,9 @@ write_connection (NMConnection *connection, if (!write_ip6_setting (connection, ifcfg, error)) goto out; + + if (!write_res_options (connection, ifcfg, error)) + goto out; } write_connection_setting (s_con, ifcfg); diff --git a/src/settings/plugins/ifcfg-rh/writer.h b/src/settings/plugins/ifcfg-rh/writer.h index 894313dd..69389361 100644 --- a/src/settings/plugins/ifcfg-rh/writer.h +++ b/src/settings/plugins/ifcfg-rh/writer.h @@ -22,9 +22,11 @@ #define _WRITER_H_ #include <sys/types.h> -#include <glib.h> + #include <nm-connection.h> +#include "nm-default.h" + gboolean writer_can_write_connection (NMConnection *connection, GError **error); diff --git a/src/settings/plugins/ifcfg-suse/Makefile.am b/src/settings/plugins/ifcfg-suse/Makefile.am deleted file mode 100644 index 55494536..00000000 --- a/src/settings/plugins/ifcfg-suse/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - -I${top_srcdir}/src \ - -I${top_srcdir}/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-suse"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-suse.la - -libnm_settings_plugin_ifcfg_suse_la_SOURCES = \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifcfg_suse_la_LDFLAGS = -module -avoid-version diff --git a/src/settings/plugins/ifcfg-suse/Makefile.in b/src/settings/plugins/ifcfg-suse/Makefile.in deleted file mode 100644 index fa51b0aa..00000000 --- a/src/settings/plugins/ifcfg-suse/Makefile.in +++ /dev/null @@ -1,819 +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-suse -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_warnings.m4 \ - $(top_srcdir)/m4/gettext.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) -libnm_settings_plugin_ifcfg_suse_la_LIBADD = -am_libnm_settings_plugin_ifcfg_suse_la_OBJECTS = plugin.lo -libnm_settings_plugin_ifcfg_suse_la_OBJECTS = \ - $(am_libnm_settings_plugin_ifcfg_suse_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_suse_la_LINK = $(LIBTOOL) $(AM_V_lt) \ - --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ - $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_ifcfg_suse_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_settings_plugin_ifcfg_suse_la_SOURCES) -DIST_SOURCES = $(libnm_settings_plugin_ifcfg_suse_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@ -CKDB_PATH = @CKDB_PATH@ -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_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ -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@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -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@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_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@ -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_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@ -PPPOE_PATH = @PPPOE_PATH@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -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_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@ -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@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -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 = \ - $(GLIB_CFLAGS) \ - -I${top_srcdir}/src \ - -I${top_srcdir}/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-suse"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-suse.la -libnm_settings_plugin_ifcfg_suse_la_SOURCES = \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifcfg_suse_la_LDFLAGS = -module -avoid-version -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/settings/plugins/ifcfg-suse/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-suse/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-settings-plugin-ifcfg-suse.la: $(libnm_settings_plugin_ifcfg_suse_la_OBJECTS) $(libnm_settings_plugin_ifcfg_suse_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ifcfg_suse_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_ifcfg_suse_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ifcfg_suse_la_OBJECTS) $(libnm_settings_plugin_ifcfg_suse_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@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 - -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)$(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: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am 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 - - -# 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-suse/plugin.c b/src/settings/plugins/ifcfg-suse/plugin.c deleted file mode 100644 index a1667f64..00000000 --- a/src/settings/plugins/ifcfg-suse/plugin.c +++ /dev/null @@ -1,312 +0,0 @@ -/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ - -/* NetworkManager system settings service - * - * Søren Sandmann <sandmann@daimi.au.dk> - * - * 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 - 2011 Red Hat, Inc. - * (C) Copyright 2007 - 2008 Novell, Inc. - */ - -#include "config.h" - -#include <string.h> - -#include <gmodule.h> -#include <glib-object.h> -#include <gio/gio.h> - -#include "plugin.h" -#include "nm-system-config-interface.h" - -#define IFCFG_PLUGIN_NAME "ifcfg-suse" -#define IFCFG_PLUGIN_INFO "(C) 2008 Novell, Inc. To report bugs please use the NetworkManager mailing list." -#define IFCFG_DIR SYSCONFDIR "/sysconfig/network" -#define CONF_DHCP IFCFG_DIR "/dhcp" -#define HOSTNAME_FILE "/etc/HOSTNAME" - -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); - -G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) - -#define SC_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgPrivate)) - - -#define IFCFG_FILE_PATH_TAG "ifcfg-file-path" - -typedef struct { - GFileMonitor *hostname_monitor; - GFileMonitor *dhcp_monitor; - char *hostname; -} SCPluginIfcfgPrivate; - -typedef void (*FileChangedFn) (gpointer user_data); - -typedef struct { - FileChangedFn callback; - gpointer user_data; -} FileMonitorInfo; - -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: - case G_FILE_MONITOR_EVENT_DELETED: - 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; - - file = g_file_new_for_path (filename); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - 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); - } - - return monitor; -} - -static gboolean -hostname_is_dynamic (void) -{ - GIOChannel *channel; - const char *pattern = "DHCLIENT_SET_HOSTNAME="; - char *str = NULL; - int pattern_len; - gboolean dynamic = FALSE; - - channel = g_io_channel_new_file (CONF_DHCP, "r", NULL); - if (!channel) - return dynamic; - - pattern_len = strlen (pattern); - - while (g_io_channel_read_line (channel, &str, NULL, NULL, NULL) != G_IO_STATUS_EOF) { - if (!strncmp (str, pattern, pattern_len)) { - if (!strncmp (str + pattern_len, "\"yes\"", 5)) - dynamic = TRUE; - break; - } - g_free (str); - } - - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - - return dynamic; -} - -static char * -hostname_read (void) -{ - GIOChannel *channel; - char *hostname = NULL; - - channel = g_io_channel_new_file (HOSTNAME_FILE, "r", NULL); - if (channel) { - g_io_channel_read_line (channel, &hostname, NULL, NULL, NULL); - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - - if (hostname) - hostname = g_strchomp (hostname); - } - - return hostname; -} - -static void -hostname_changed (gpointer data) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (data); - - g_free (priv->hostname); - if (hostname_is_dynamic ()) - priv->hostname = NULL; - else - priv->hostname = hostname_read (); - - g_object_notify (G_OBJECT (data), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - GIOChannel *channel; - - channel = g_io_channel_new_file (HOSTNAME_FILE, "w", NULL); - if (channel) { - g_io_channel_write_chars (channel, hostname, -1, NULL, NULL); - g_io_channel_write_chars (channel, "\n", -1, NULL, NULL); - g_io_channel_shutdown (channel, TRUE, NULL); - g_io_channel_unref (channel); - } - - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); -} - -static void -init (NMSystemConfigInterface *config) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (config); - - priv->hostname_monitor = monitor_file_changes (HOSTNAME_FILE, hostname_changed, config); - priv->dhcp_monitor = monitor_file_changes (CONF_DHCP, hostname_changed, config); - - if (!hostname_is_dynamic ()) - priv->hostname = hostname_read (); -} - -static void -sc_plugin_ifcfg_init (SCPluginIfcfg *self) -{ -} - -static void -dispose (GObject *object) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (object); - - if (priv->dhcp_monitor) - g_object_unref (priv->dhcp_monitor); - - if (priv->hostname_monitor) - g_object_unref (priv->hostname_monitor); - - g_free (priv->hostname); - - G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: - g_value_set_string (value, IFCFG_PLUGIN_NAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: - g_value_set_string (value, IFCFG_PLUGIN_INFO); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, SC_PLUGIN_IFCFG_GET_PRIVATE (object)->hostname); - 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) -{ - const char *hostname; - - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_IFCFG (object), hostname); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (SCPluginIfcfgPrivate)); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->dispose = dispose; - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) -{ - /* interface implementation */ - system_config_interface_class->init = init; -} - -G_MODULE_EXPORT GObject * -nm_system_config_factory (void) -{ - static SCPluginIfcfg *singleton = NULL; - - if (!singleton) - singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL)); - else - g_object_ref (singleton); - - return G_OBJECT (singleton); -} diff --git a/src/settings/plugins/ifcfg-suse/plugin.h b/src/settings/plugins/ifcfg-suse/plugin.h deleted file mode 100644 index 24dbff95..00000000 --- a/src/settings/plugins/ifcfg-suse/plugin.h +++ /dev/null @@ -1,50 +0,0 @@ -/* NetworkManager system settings service - * - * Søren Sandmann <sandmann@daimi.au.dk> - * - * 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 Red Hat, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#include <glib-object.h> - -#define PLUGIN_NAME "ifcfg-suse" - -#define SC_TYPE_PLUGIN_IFCFG (sc_plugin_ifcfg_get_type ()) -#define SC_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfg)) -#define SC_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) -#define SC_IS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFCFG)) -#define SC_IS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFCFG)) -#define SC_PLUGIN_IFCFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) - -typedef struct _SCPluginIfcfg SCPluginIfcfg; -typedef struct _SCPluginIfcfgClass SCPluginIfcfgClass; - -struct _SCPluginIfcfg { - GObject parent; -}; - -struct _SCPluginIfcfgClass { - GObjectClass parent; -}; - -GType sc_plugin_ifcfg_get_type (void); - -#endif /* _PLUGIN_H_ */ - diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am index 84e2e697..ffd8ab3c 100644 --- a/src/settings/plugins/ifnet/Makefile.am +++ b/src/settings/plugins/ifnet/Makefile.am @@ -6,12 +6,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" diff --git a/src/settings/plugins/ifnet/Makefile.in b/src/settings/plugins/ifnet/Makefile.in index 589f1f22..c6e13316 100644 --- a/src/settings/plugins/ifnet/Makefile.in +++ b/src/settings/plugins/ifnet/Makefile.in @@ -278,7 +278,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -290,8 +289,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -301,6 +298,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -355,16 +353,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -401,6 +396,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -429,7 +426,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -444,6 +440,8 @@ 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@ @@ -504,6 +502,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -511,6 +510,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -531,12 +531,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c index 888ee589..51ff9da6 100644 --- a/src/settings/plugins/ifnet/connection_parser.c +++ b/src/settings/plugins/ifnet/connection_parser.c @@ -25,10 +25,9 @@ #include <arpa/inet.h> #include <stdlib.h> #include <errno.h> -#include <glib/gi18n.h> -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-settings-plugin.h" +#include "nm-default.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c index 8f528d0f..ee66ff53 100644 --- a/src/settings/plugins/ifnet/net_parser.c +++ b/src/settings/plugins/ifnet/net_parser.c @@ -26,8 +26,8 @@ #include <sys/ioctl.h> #include <unistd.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "plugin.h" #include "nm-platform.h" diff --git a/src/settings/plugins/ifnet/net_parser.h b/src/settings/plugins/ifnet/net_parser.h index d10979cc..968feaf5 100644 --- a/src/settings/plugins/ifnet/net_parser.h +++ b/src/settings/plugins/ifnet/net_parser.h @@ -22,7 +22,7 @@ #ifndef _NET_PARSER_H #define _NET_PARSER_H -#include <glib.h> +#include "nm-default.h" #define CONF_NET_FILE SYSCONFDIR "/conf.d/net" diff --git a/src/settings/plugins/ifnet/net_utils.c b/src/settings/plugins/ifnet/net_utils.c index adb23c43..1c72e0b2 100644 --- a/src/settings/plugins/ifnet/net_utils.c +++ b/src/settings/plugins/ifnet/net_utils.c @@ -26,11 +26,10 @@ #include <string.h> #include <errno.h> #include <nm-utils.h> -#include <NetworkManagerUtils.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> -#include <nm-config.h> -#include <gio/gio.h> +#include "NetworkManagerUtils.h" +#include <nm-settings-plugin.h> +#include "nm-config.h" +#include "nm-default.h" #include "net_utils.h" #include "wpa_parser.h" #include "net_parser.h" @@ -136,47 +135,6 @@ reload_parsers (void) return TRUE; } -gchar * -read_hostname (const char *path) -{ - gchar *contents = NULL, *result = NULL, *tmp; - gchar **all_lines = NULL; - guint line_num, i; - - if (!g_file_get_contents (path, &contents, NULL, NULL)) - return NULL; - all_lines = g_strsplit (contents, "\n", 0); - line_num = g_strv_length (all_lines); - for (i = 0; i < line_num; i++) { - g_strstrip (all_lines[i]); - if (all_lines[i][0] == '#' || all_lines[i][0] == '\0') - continue; - if (g_str_has_prefix (all_lines[i], "hostname")) { - tmp = strstr (all_lines[i], "="); - tmp++; - result = g_shell_unquote (tmp, NULL); - break; - } - - } - g_strfreev (all_lines); - g_free (contents); - return result; -} - -gboolean -write_hostname (const char *path, const gchar *hostname) -{ - gboolean result; - char *contents; - - contents = g_strdup_printf ("#Generated by NetworkManager\n" - "hostname=\"%s\"\n", hostname); - result = g_file_set_contents (path, contents, -1, NULL); - g_free (contents); - return result; -} - gboolean is_static_ip4 (const char *conn_name) { diff --git a/src/settings/plugins/ifnet/net_utils.h b/src/settings/plugins/ifnet/net_utils.h index d58e7ec6..45969369 100644 --- a/src/settings/plugins/ifnet/net_utils.h +++ b/src/settings/plugins/ifnet/net_utils.h @@ -21,11 +21,11 @@ #ifndef _IFNET_UTILS_H #define _IFNET_UTILS_H -#define IFNET_PLUGIN_NAME "SCPlugin-Ifnet" -#include <glib.h> +#define IFNET_PLUGIN_NAME "SettingsPlugin-Ifnet" #include <arpa/inet.h> #include <nm-setting-ip6-config.h> #include <nm-setting-ip4-config.h> +#include "nm-default.h" #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) @@ -37,8 +37,6 @@ typedef struct _ip_block { struct _ip_block *next; } ip_block; -gchar *read_hostname (const char *path); -gboolean write_hostname (const char *path, const char *hostname); gboolean is_static_ip4 (const char *conn_name); gboolean is_static_ip6 (const char *conn_name); gboolean is_ip4_address (const char *in_address); diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.c b/src/settings/plugins/ifnet/nm-ifnet-connection.c index 693e6532..450fe931 100644 --- a/src/settings/plugins/ifnet/nm-ifnet-connection.c +++ b/src/settings/plugins/ifnet/nm-ifnet-connection.c @@ -27,8 +27,8 @@ #include <nm-utils.h> #include <nm-setting-wireless-security.h> #include <nm-settings-connection.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "nm-ifnet-connection.h" #include "connection_parser.h" #include "net_parser.h" @@ -50,7 +50,7 @@ static guint signals[IFNET_LAST_SIGNAL] = { 0 }; typedef struct { gchar *conn_name; - NMSystemConfigInterface *config; + NMSettingsPlugin *config; } NMIfnetConnectionPrivate; NMIfnetConnection * @@ -102,8 +102,9 @@ nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection) static void commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, - gpointer user_data) + gpointer user_data) { GError *error = NULL; NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE (connection); @@ -139,7 +140,7 @@ commit_changes (NMSettingsConnection *connection, g_free (priv->conn_name); priv->conn_name = new_name; - NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, callback, user_data); + 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", diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c index 5eab31ab..b670cdac 100644 --- a/src/settings/plugins/ifnet/plugin.c +++ b/src/settings/plugins/ifnet/plugin.c @@ -25,17 +25,16 @@ #include <string.h> #include <gmodule.h> -#include <glib.h> -#include <gio/gio.h> #include <nm-utils.h> #include <nm-setting-connection.h> +#include "nm-default.h" #include "nm-dbus-interface.h" -#include "nm-system-config-interface.h" -#include "nm-logging.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" @@ -45,19 +44,16 @@ #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_SYSTEM_HOSTNAME_FILE "/etc/conf.d/hostname" #define IFNET_MANAGE_WELL_KNOWN_DEFAULT TRUE typedef struct { GHashTable *connections; /* uuid::connection */ - gchar *hostname; gboolean unmanaged_well_known; - GFileMonitor *hostname_monitor; GFileMonitor *net_monitor; GFileMonitor *wpa_monitor; -} SCPluginIfnetPrivate; +} SettingsPluginIfnetPrivate; typedef void (*FileChangedFn) (gpointer user_data); @@ -66,56 +62,17 @@ typedef struct { gpointer user_data; } FileMonitorInfo; -static void system_config_interface_init (NMSystemConfigInterface *class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -static void reload_connections (NMSystemConfigInterface *config); +static void reload_connections (NMSettingsPlugin *config); -G_DEFINE_TYPE_EXTENDED (SCPluginIfnet, sc_plugin_ifnet, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init)) -#define SC_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetPrivate)) -/* -static void -ignore_cb(NMSettingsConnectionInterface * connection, - GError * error, gpointer user_data) -{ -} -*/ -static const char * -get_hostname (NMSystemConfigInterface * config) -{ - return SC_PLUGIN_IFNET_GET_PRIVATE (config)->hostname; -} - -static void -update_system_hostname (gpointer config) -{ - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); - - if (priv->hostname) - g_free (priv->hostname); - priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE); +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)) - g_object_notify (G_OBJECT (config), - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - nm_log_info (LOGD_SETTINGS, "Hostname updated to: %s", priv->hostname); -} - -static void -write_system_hostname (NMSystemConfigInterface * config, - const gchar * newhostname) -{ - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); - - g_return_if_fail (newhostname); - nm_log_info (LOGD_SETTINGS, "Write system hostname: %s", newhostname); - if (write_hostname (IFNET_SYSTEM_HOSTNAME_FILE, newhostname)) { - g_free (priv->hostname); - priv->hostname = g_strdup (newhostname); - g_object_notify (G_OBJECT (config), - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } else - nm_log_warn (LOGD_SETTINGS, "Write system hostname: %s failed", newhostname); -} +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) @@ -177,12 +134,9 @@ monitor_file_changes (const char *filename, static void setup_monitors (NMIfnetConnection * connection, gpointer user_data) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - priv->hostname_monitor = - monitor_file_changes (IFNET_SYSTEM_HOSTNAME_FILE, - update_system_hostname, user_data); if (nm_config_get_monitor_connection_files (nm_config_get ())) { priv->net_monitor = monitor_file_changes (CONF_NET_FILE, (FileChangedFn) reload_connections, @@ -196,13 +150,9 @@ setup_monitors (NMIfnetConnection * connection, gpointer user_data) static void cancel_monitors (NMIfnetConnection * connection, gpointer user_data) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - if (priv->hostname_monitor) { - g_file_monitor_cancel (priv->hostname_monitor); - g_object_unref (priv->hostname_monitor); - } if (priv->net_monitor) { g_file_monitor_cancel (priv->net_monitor); g_object_unref (priv->net_monitor); @@ -216,14 +166,14 @@ cancel_monitors (NMIfnetConnection * connection, gpointer user_data) static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SC_PLUGIN_IFNET_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } static void -track_new_connection (SCPluginIfnet *self, NMIfnetConnection *connection) +track_new_connection (SettingsPluginIfnet *self, NMIfnetConnection *connection) { - g_hash_table_insert (SC_PLUGIN_IFNET_GET_PRIVATE (self)->connections, + 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, @@ -232,10 +182,10 @@ track_new_connection (SCPluginIfnet *self, NMIfnetConnection *connection) } static void -reload_connections (NMSystemConfigInterface *config) +reload_connections (NMSettingsPlugin *config) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (config); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + 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; @@ -293,7 +243,7 @@ reload_connections (NMSystemConfigInterface *config) 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_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); } } else { /* Update existing connection with new settings */ @@ -310,11 +260,11 @@ reload_connections (NMSystemConfigInterface *config) nm_log_info (LOGD_SETTINGS, "Connection %s updated", nm_connection_get_id (NM_CONNECTION (new))); } - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + 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_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); } /* Track all valid connections so we can remove deleted ones later */ @@ -341,12 +291,12 @@ reload_connections (NMSystemConfigInterface *config) } static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, +add_connection (NMSettingsPlugin *config, NMConnection *source, gboolean save_to_disk, GError **error) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); NMIfnetConnection *new = NULL; /* Ensure we reject attempts to add the connection long before we're @@ -363,7 +313,7 @@ add_connection (NMSystemConfigInterface *config, } else { new = nm_ifnet_connection_new (source, NULL); if (new) { - track_new_connection (SC_PLUGIN_IFNET (config), new); + track_new_connection (SETTINGS_PLUGIN_IFNET (config), new); /* track_new_connection refs 'new' */ g_object_unref (new); } @@ -406,9 +356,9 @@ check_unmanaged (gpointer key, gpointer data, gpointer user_data) } static GSList * -get_unmanaged_specs (NMSystemConfigInterface * config) +get_unmanaged_specs (NMSettingsPlugin * config) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); GSList *list = NULL; nm_log_info (LOGD_SETTINGS, "getting unmanaged specs..."); @@ -417,10 +367,10 @@ get_unmanaged_specs (NMSystemConfigInterface * config) } static void -init (NMSystemConfigInterface *config) +init (NMSettingsPlugin *config) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (config); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); nm_log_info (LOGD_SETTINGS, "Initializing!"); @@ -431,15 +381,14 @@ init (NMSystemConfigInterface *config) setup_monitors (NULL, config); reload_connections (config); - update_system_hostname (self); nm_log_info (LOGD_SETTINGS, "Initialzation complete!"); } static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); GSList *connections = NULL; GHashTableIter iter; NMIfnetConnection *connection; @@ -459,17 +408,17 @@ get_connections (NMSystemConfigInterface *config) } static void -system_config_interface_init (NMSystemConfigInterface *class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - class->init = init; - class->get_connections = get_connections; - class->get_unmanaged_specs = get_unmanaged_specs; - class->add_connection = add_connection; - class->reload_connections = reload_connections; + 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 -sc_plugin_ifnet_init (SCPluginIfnet * plugin) +settings_plugin_ifnet_init (SettingsPluginIfnet * plugin) { } @@ -477,23 +426,16 @@ static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - NMSystemConfigInterface *self = NM_SYSTEM_CONFIG_INTERFACE (object); - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, IFNET_PLUGIN_NAME_PRINT); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, IFNET_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: g_value_set_uint (value, - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS - | - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, get_hostname (self)); + NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -506,15 +448,6 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:{ - const gchar *hostname = g_value_get_string (value); - - if (hostname && strlen (hostname) < 1) - hostname = NULL; - write_system_hostname (NM_SYSTEM_CONFIG_INTERFACE - (object), hostname); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -524,8 +457,8 @@ set_property (GObject * object, guint prop_id, const GValue * value, static void dispose (GObject * object) { - SCPluginIfnet *plugin = SC_PLUGIN_IFNET (object); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (plugin); + SettingsPluginIfnet *plugin = SETTINGS_PLUGIN_IFNET (object); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (plugin); cancel_monitors (NULL, object); if (priv->connections) { @@ -533,53 +466,37 @@ dispose (GObject * object) priv->connections = NULL; } - g_free (priv->hostname); - priv->hostname = NULL; - ifnet_destroy (); wpa_parser_destroy (); - G_OBJECT_CLASS (sc_plugin_ifnet_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ifnet_parent_class)->dispose (object); } static void -sc_plugin_ifnet_class_init (SCPluginIfnetClass * req_class) +settings_plugin_ifnet_class_init (SettingsPluginIfnetClass * req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIfnetPrivate)); + 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_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIfnet *singleton = NULL; - SCPluginIfnetPrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_IFNET (g_object_new (SC_TYPE_PLUGIN_IFNET, NULL)); - priv = SC_PLUGIN_IFNET_GET_PRIVATE (singleton); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ifnet_get ()); } diff --git a/src/settings/plugins/ifnet/plugin.h b/src/settings/plugins/ifnet/plugin.h index 6ac0f482..33dcc201 100644 --- a/src/settings/plugins/ifnet/plugin.h +++ b/src/settings/plugins/ifnet/plugin.h @@ -23,25 +23,25 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" -#define SC_TYPE_PLUGIN_IFNET (sc_plugin_ifnet_get_type ()) -#define SC_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFNET, SCPluginIfnet)) -#define SC_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetClass)) -#define SC_IS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFNET)) -#define SC_IS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFNET)) -#define SC_PLUGIN_IFNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetClass)) +#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 _SCPluginIfnet SCPluginIfnet; -typedef struct _SCPluginIfnetClass SCPluginIfnetClass; +typedef struct _SettingsPluginIfnet SettingsPluginIfnet; +typedef struct _SettingsPluginIfnetClass SettingsPluginIfnetClass; -struct _SCPluginIfnet { +struct _SettingsPluginIfnet { GObject parent; }; -struct _SCPluginIfnetClass { +struct _SettingsPluginIfnetClass { GObjectClass parent; }; -GType sc_plugin_ifnet_get_type (void); +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 index 754bb182..1919f141 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ b/src/settings/plugins/ifnet/tests/Makefile.am @@ -4,42 +4,43 @@ if ENABLE_TESTS AM_CPPFLAGS= \ -I$(srcdir)/../ \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(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 = check_ifnet -check_ifnet_SOURCES = \ - test_all.c \ +noinst_PROGRAMS = test-ifnet +test_ifnet_SOURCES = \ + test-ifnet.c \ ../connection_parser.c \ ../net_parser.c \ ../net_utils.c \ ../wpa_parser.c -check_ifnet_LDFLAGS = \ +test_ifnet_LDFLAGS = \ $(CODE_COVERAGE_LDFLAGS) -check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la +test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la -check-local: check_ifnet - $(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir) +#@VALGRIND_RULES@ +TESTS = test-ifnet endif EXTRA_DIST = \ - hostname \ net \ net.all \ nm-system-settings.conf \ diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in index d331ecee..1e08b955 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.in +++ b/src/settings/plugins/ifnet/tests/Makefile.in @@ -88,7 +88,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = check_ifnet$(EXEEXT) +@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/ax_lib_readline.m4 \ @@ -112,22 +113,22 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am__check_ifnet_SOURCES_DIST = test_all.c ../connection_parser.c \ +am__test_ifnet_SOURCES_DIST = test-ifnet.c ../connection_parser.c \ ../net_parser.c ../net_utils.c ../wpa_parser.c -@ENABLE_TESTS_TRUE@am_check_ifnet_OBJECTS = test_all.$(OBJEXT) \ +@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) -check_ifnet_OBJECTS = $(am_check_ifnet_OBJECTS) -@ENABLE_TESTS_TRUE@check_ifnet_DEPENDENCIES = \ +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 = -check_ifnet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ +test_ifnet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(check_ifnet_LDFLAGS) $(LDFLAGS) -o $@ + $(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 @@ -162,8 +163,8 @@ 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 = $(check_ifnet_SOURCES) -DIST_SOURCES = $(am__check_ifnet_SOURCES_DIST) +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;; \ @@ -188,8 +189,212 @@ am__define_uniq_tagged_files = \ 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='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + 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/depcomp \ + $(top_srcdir)/build-aux/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ @@ -206,7 +411,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -218,8 +422,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -229,6 +431,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -283,16 +486,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -329,6 +529,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -357,7 +559,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -372,6 +573,8 @@ 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@ @@ -432,6 +635,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -439,6 +643,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -456,35 +661,36 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@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 \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @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@check_ifnet_SOURCES = \ -@ENABLE_TESTS_TRUE@ test_all.c \ +@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@check_ifnet_LDFLAGS = \ +@ENABLE_TESTS_TRUE@test_ifnet_LDFLAGS = \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) -@ENABLE_TESTS_TRUE@check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la +@ENABLE_TESTS_TRUE@test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la EXTRA_DIST = \ - hostname \ net \ net.all \ nm-system-settings.conf \ @@ -494,7 +700,7 @@ EXTRA_DIST = \ all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.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 \ @@ -534,9 +740,9 @@ clean-noinstPROGRAMS: echo " rm -f" $$list; \ rm -f $$list -check_ifnet$(EXEEXT): $(check_ifnet_OBJECTS) $(check_ifnet_DEPENDENCIES) $(EXTRA_check_ifnet_DEPENDENCIES) - @rm -f check_ifnet$(EXEEXT) - $(AM_V_CCLD)$(check_ifnet_LINK) $(check_ifnet_OBJECTS) $(check_ifnet_LDADD) $(LIBS) +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) @@ -547,7 +753,7 @@ distclean-compile: @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_all.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: @@ -685,6 +891,169 @@ cscopelist-am: $(am__tagged_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'`; \ @@ -715,9 +1084,8 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done -@ENABLE_TESTS_FALSE@check-local: check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(PROGRAMS) installdirs: @@ -741,6 +1109,9 @@ install-strip: "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: @@ -824,7 +1195,7 @@ uninstall-am: .MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ +.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 \ @@ -836,16 +1207,13 @@ uninstall-am: 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 + recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile @ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ -@ENABLE_TESTS_TRUE@check-local: check_ifnet -@ENABLE_TESTS_TRUE@ $(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir) - # 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/hostname b/src/settings/plugins/ifnet/tests/hostname deleted file mode 100644 index 25c76165..00000000 --- a/src/settings/plugins/ifnet/tests/hostname +++ /dev/null @@ -1,2 +0,0 @@ -#Generated by NetworkManager -hostname="gentoo" diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test-ifnet.c index 55e7e283..96fb5dd3 100644 --- a/src/settings/plugins/ifnet/tests/test_all.c +++ b/src/settings/plugins/ifnet/tests/test-ifnet.c @@ -24,14 +24,13 @@ #include <stdio.h> #include <string.h> -#include <glib.h> #include <arpa/inet.h> #include <stdlib.h> #include <unistd.h> #include <nm-utils.h> +#include "nm-default.h" #include "nm-linux-platform.h" -#include "nm-logging.h" #include "net_parser.h" #include "net_utils.h" @@ -59,82 +58,38 @@ nm_config_get_dhcp_client (NMConfig *config) static void test_getdata (void) { - ASSERT (ifnet_get_data ("eth1", "config") - && strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0, - "get data", "config_eth1 is not correct"); - ASSERT (ifnet_get_data ("ppp0", "username") - && strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0, - "get data", "config_ppp0 username is not correctly read"); - ASSERT (ifnet_get_data ("ppp0", "password") - && strcmp (ifnet_get_data ("ppp0", "password"), - "password") == 0, "get data", - "config_ppp0 password is not correctly read"); - ASSERT (ifnet_get_global_data ("modules") - && strcmp ("!wpa_supplicant", ifnet_get_global_data ("modules")) == 0, - "get data", "config_eth1 is not correct"); -} - -static void -test_read_hostname (const char *base_path) -{ - char *hostname_path, *hostname; - - hostname_path = g_build_filename (base_path, "hostname", NULL); - hostname = read_hostname (hostname_path); - - g_assert_cmpstr (hostname, ==, "gentoo"); - - g_free (hostname); - g_free (hostname_path); -} - -static void -test_write_hostname (const char *temp_path) -{ - char *hostname_path, *hostname; - - hostname_path = g_build_filename (temp_path, "hostname-test", NULL); - write_hostname (hostname_path, "gentoo-nm"); - hostname = read_hostname (hostname_path); - - g_assert_cmpstr (hostname, ==, "gentoo-nm"); - - g_free (hostname); - unlink (hostname_path); - g_free (hostname_path); + g_assert (ifnet_get_data ("eth1", "config") && + strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0); + g_assert (ifnet_get_data ("ppp0", "username") && + strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0); + g_assert (ifnet_get_data ("ppp0", "password") && + strcmp (ifnet_get_data ("ppp0", "password"), "password") == 0); + g_assert (ifnet_get_global_data ("modules") && + strcmp ("!wpa_supplicant", ifnet_get_global_data ("modules")) == 0); } static void test_is_static (void) { - ASSERT (is_static_ip4 ("eth1") == FALSE, "is static", - "a dhcp interface is recognized as static"); - ASSERT (is_static_ip4 ("eth0") == TRUE, "is static", - "a static interface is recognized as dhcp"); - ASSERT (is_static_ip6 ("eth0") == FALSE, "is static", - "a dhcp interface is recognized as static"); + g_assert (!is_static_ip4 ("eth1")); + g_assert (is_static_ip4 ("eth0")); + g_assert (!is_static_ip6 ("eth0")); } static void test_has_default_route (void) { - ASSERT (has_default_ip4_route ("eth0"), - "has default route", "eth0 should have a default ipv4 route"); - ASSERT (has_default_ip6_route ("eth4"), - "has default route", "eth4 should have a default ipv6 route"); - ASSERT (!has_default_ip4_route ("eth5") - && !has_default_ip6_route ("eth5"), - "has default route", "eth5 shouldn't have a default route"); + g_assert (has_default_ip4_route ("eth0")); + g_assert (has_default_ip6_route ("eth4")); + g_assert (!has_default_ip4_route ("eth5") && + !has_default_ip6_route ("eth5")); } static void test_has_ip6_address (void) { - ASSERT (has_ip6_address ("eth2"), "has ip6 address", - "eth2 should have a ipv6 address"); - ASSERT (!has_ip6_address ("eth0"), "has ip6 address", - "eth0 shouldn't have a ipv6 address") - + g_assert (has_ip6_address ("eth2")); + g_assert (!has_ip6_address ("eth0")); } static void @@ -144,12 +99,9 @@ test_is_ip4_address (void) gchar *address2 = "192.168.100.{1..254}/24"; gchar *address3 = "192.168.4.2555/24"; - ASSERT (is_ip4_address (address1), "is ip4 address", - "%s should be a valid address", address1); - ASSERT (is_ip4_address (address2), "is ip4 address", - "%s should be a valid address", address2); - ASSERT (!is_ip4_address (address3), "is ip4 address", - "%s should be an invalid address", address3); + g_assert (is_ip4_address (address1)); + g_assert (is_ip4_address (address2)); + g_assert (!is_ip4_address (address3)); } static void @@ -157,19 +109,15 @@ test_is_ip6_address (void) { gchar *address1 = "4321:0:1:2:3:4:567:89ac/24"; - ASSERT (is_ip6_address (address1), "is ip6 address", - "%s should be a valid address", address1); + g_assert (is_ip6_address (address1)); } static void check_ip_block (ip_block * iblock, gchar * ip, guint32 prefix, gchar * gateway) { - ASSERT (strcmp (ip, iblock->ip) == 0, "check ip", - "ip expected:%s, find:%s", ip, iblock->ip); - ASSERT (prefix == iblock->prefix, "check netmask", - "prefix expected:%d, find:%d", prefix, iblock->prefix); - ASSERT (g_strcmp0 (gateway, iblock->next_hop) == 0, "check gateway", - "gateway expected:%s, find:%s", gateway, iblock->next_hop); + g_assert_cmpstr (ip, ==, iblock->ip); + g_assert (prefix == iblock->prefix); + g_assert_cmpstr (gateway, ==, iblock->next_hop); } static void @@ -178,13 +126,11 @@ test_convert_ipv4_config_block (void) ip_block *iblock = convert_ip4_config_block ("eth0"); ip_block *tmp = iblock; - ASSERT (iblock != NULL, "convert ipv4 block", - "block eth0 should not be NULL"); + g_assert (iblock != NULL); check_ip_block (iblock, "202.117.16.121", 24, "202.117.16.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock != NULL, "convert ipv4 block", - "block eth0 should have a second IP address"); + g_assert (iblock != NULL); check_ip_block (iblock, "192.168.4.121", 24, "202.117.16.1"); destroy_ip_block (iblock); @@ -192,17 +138,14 @@ test_convert_ipv4_config_block (void) "*Can't handle IPv4 address*202.117.16.1211*"); iblock = convert_ip4_config_block ("eth2"); g_test_assert_expected_messages (); - ASSERT (iblock != NULL - && iblock->next == NULL, - "convert error IPv4 address", "should only get one address"); + g_assert (iblock != NULL && iblock->next == NULL); check_ip_block (iblock, "192.168.4.121", 24, NULL); destroy_ip_block (iblock); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*missing netmask or prefix*"); iblock = convert_ip4_config_block ("eth3"); - ASSERT (iblock == NULL, "convert config_block", - "convert error configuration"); + g_assert (iblock == NULL); } static void @@ -211,22 +154,20 @@ test_convert_ipv4_routes_block (void) ip_block *iblock = convert_ip4_routes_block ("eth0"); ip_block *tmp = iblock; - ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); + g_assert (iblock != NULL); check_ip_block (iblock, "192.168.4.0", 24, "192.168.4.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock == NULL, "convert ip4 routes", - "should only get one route"); + g_assert (iblock == NULL); iblock = convert_ip4_routes_block ("eth9"); tmp = iblock; - ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); + g_assert (iblock != NULL); check_ip_block (iblock, "10.0.0.0", 8, "192.168.0.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock == NULL, "convert ip4 routes", - "should only get one route"); + g_assert (iblock == NULL); } static void @@ -258,19 +199,15 @@ test_strip_string (void) result = strip_string (result, '('); result = strip_string (result, ')'); result = strip_string (result, '"'); - ASSERT (strcmp (result, "default via 202.117.16.1") == - 0, "strip_string", - "string isn't stripped, result is: %s", result); + g_assert_cmpstr (result, ==, "default via 202.117.16.1"); g_free (result_b); } static void test_is_unmanaged (void) { - ASSERT (is_managed ("eth0"), "test_is_unmanaged", - "eth0 should be managed"); - ASSERT (!is_managed ("eth4"), "test_is_unmanaged", - "eth4 should be unmanaged"); + g_assert (is_managed ("eth0")); + g_assert (!is_managed ("eth4")); } static void @@ -285,33 +222,23 @@ test_new_connection (void) "*Can't handle IPv6 address*202.117.16.1211*"); connection = ifnet_update_connection_from_config_block ("eth2", NULL, &error); g_test_assert_expected_messages (); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("qiaomuf", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("myxjtu2", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("eth9", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection(eth9) failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("eth10", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection(eth10) failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); } @@ -329,17 +256,16 @@ kill_backup (char **path) #define SUP_GEN_NAME "wpa_supplicant.conf.generate" static void -test_update_connection (const char *basepath) +test_update_connection (void) { GError *error = NULL; NMConnection *connection; gboolean success; char *backup = NULL; + char *basepath = TEST_IFNET_DIR; connection = ifnet_update_connection_from_config_block ("eth0", basepath, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); success = ifnet_update_parsers_by_connection (connection, "eth0", NET_GEN_NAME, @@ -348,12 +274,11 @@ test_update_connection (const char *basepath) &backup, &error); kill_backup (&backup); - ASSERT (success, "update connection", "update connection failed %s", "eth0"); + g_assert (success); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("0xab3ace", basepath, &error); - ASSERT (connection != NULL, "get connection", "get connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); success = ifnet_update_parsers_by_connection (connection, "0xab3ace", NET_GEN_NAME, @@ -362,7 +287,7 @@ test_update_connection (const char *basepath) &backup, &error); kill_backup (&backup); - ASSERT (success, "update connection", "update connection failed %s", "0xab3ace"); + g_assert (success); g_object_unref (connection); unlink (NET_GEN_NAME); @@ -370,14 +295,14 @@ test_update_connection (const char *basepath) } static void -test_add_connection (const char *basepath) +test_add_connection (void) { NMConnection *connection; char *backup = NULL; + const char *basepath = TEST_IFNET_DIR; connection = ifnet_update_connection_from_config_block ("eth0", basepath, NULL); - ASSERT (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL), - "add connection", "add connection failed: %s", "eth0"); + g_assert (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL)); kill_backup (&backup); g_object_unref (connection); @@ -387,8 +312,7 @@ test_add_connection (const char *basepath) "*Can't handle ipv4 address: 202.117.16.255, missing netmask or prefix*"); connection = ifnet_update_connection_from_config_block ("myxjtu2", basepath, NULL); g_test_assert_expected_messages (); - ASSERT (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL), - "add connection", "add connection failed: %s", "myxjtu2"); + g_assert (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL)); kill_backup (&backup); g_object_unref (connection); @@ -404,20 +328,14 @@ test_delete_connection (void) char *backup = NULL; connection = ifnet_update_connection_from_config_block ("eth7", NULL, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); - ASSERT (ifnet_delete_connection_in_parsers ("eth7", NET_GEN_NAME, SUP_GEN_NAME, &backup), - "delete connection", "delete connection failed: %s", "eth7"); + g_assert (connection != NULL); + g_assert (ifnet_delete_connection_in_parsers ("eth7", NET_GEN_NAME, SUP_GEN_NAME, &backup)); kill_backup (&backup); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("qiaomuf", NULL, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); - ASSERT (ifnet_delete_connection_in_parsers ("qiaomuf", NET_GEN_NAME, SUP_GEN_NAME, &backup), - "delete connection", "delete connection failed: %s", "qiaomuf"); + g_assert (connection != NULL); + g_assert (ifnet_delete_connection_in_parsers ("qiaomuf", NET_GEN_NAME, SUP_GEN_NAME, &backup)); kill_backup (&backup); g_object_unref (connection); @@ -435,54 +353,46 @@ test_missing_config (void) "*Unknown config for eth8*"); connection = ifnet_update_connection_from_config_block ("eth8", NULL, &error); g_test_assert_expected_messages (); - ASSERT (connection == NULL && error != NULL, "get connection", - "get connection should fail with 'Unknown config for eth8'"); + g_assert (connection == NULL && error != NULL); } NMTST_DEFINE (); +#define TPATH "/settings/plugins/ifnet/" + int main (int argc, char **argv) { - char *f; + int ret; nm_linux_platform_setup (); nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); - f = g_build_filename (argv[1], "net", NULL); - ifnet_init (f); - g_free (f); - - f = g_build_filename (argv[1], "wpa_supplicant.conf", NULL); - wpa_parser_init (f); - g_free (f); - - test_strip_string (); - test_is_static (); - test_has_ip6_address (); - test_has_default_route (); - test_getdata (); - test_read_hostname (argv[1]); - test_write_hostname (argv[2]); - test_is_ip4_address (); - test_is_ip6_address (); - test_convert_ipv4_config_block (); - test_convert_ipv4_routes_block (); - test_is_unmanaged (); - test_wpa_parser (); - test_convert_ipv4_routes_block (); - test_new_connection (); - test_update_connection (argv[1]); - test_add_connection (argv[1]); - test_delete_connection (); - test_missing_config (); + ifnet_init (TEST_IFNET_DIR "/net"); + wpa_parser_init (TEST_IFNET_DIR "/wpa_supplicant.conf"); + + g_test_add_func (TPATH "strip-string", test_strip_string); + g_test_add_func (TPATH "is-static", test_is_static); + g_test_add_func (TPATH "has-ip6-address", test_has_ip6_address); + g_test_add_func (TPATH "has-default-route", test_has_default_route); + g_test_add_func (TPATH "get-data", test_getdata); + g_test_add_func (TPATH "is-ip4-address", test_is_ip4_address); + g_test_add_func (TPATH "is-ip6-address", test_is_ip6_address); + g_test_add_func (TPATH "convert-ip4-config", test_convert_ipv4_config_block); + g_test_add_func (TPATH "convert-ip4-routes", test_convert_ipv4_routes_block); + g_test_add_func (TPATH "is-unmanaged", test_is_unmanaged); + g_test_add_func (TPATH "wpa-parser", test_wpa_parser); + g_test_add_func (TPATH "new-connection", test_new_connection); + g_test_add_func (TPATH "update-connection", test_update_connection); + g_test_add_func (TPATH "add-connection", test_add_connection); + g_test_add_func (TPATH "delete-connection", test_delete_connection); + g_test_add_func (TPATH "missing-config", test_missing_config); + + ret = g_test_run (); ifnet_destroy (); wpa_parser_destroy (); - f = g_path_get_basename (argv[0]); - fprintf (stdout, "%s: SUCCESS\n", f); - g_free (f); - return 0; + return ret; } diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c index 3f912da8..9f228d0b 100644 --- a/src/settings/plugins/ifnet/wpa_parser.c +++ b/src/settings/plugins/ifnet/wpa_parser.c @@ -23,8 +23,8 @@ #include <string.h> #include <stdlib.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "wpa_parser.h" #include "net_parser.h" #include "net_utils.h" diff --git a/src/settings/plugins/ifnet/wpa_parser.h b/src/settings/plugins/ifnet/wpa_parser.h index 3a0d377e..8099d19c 100644 --- a/src/settings/plugins/ifnet/wpa_parser.h +++ b/src/settings/plugins/ifnet/wpa_parser.h @@ -22,7 +22,7 @@ #ifndef _WPA_PARSER_H #define _WPA_PARSER_H -#include <glib.h> +#include "nm-default.h" #define WPA_SUPPLICANT_CONF SYSCONFDIR "/wpa_supplicant/wpa_supplicant.conf" diff --git a/src/settings/plugins/ifupdown/Makefile.am b/src/settings/plugins/ifupdown/Makefile.am index e1f2b339..c5c645d3 100644 --- a/src/settings/plugins/ifupdown/Makefile.am +++ b/src/settings/plugins/ifupdown/Makefile.am @@ -5,12 +5,12 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ $(GUDEV_CFLAGS) \ diff --git a/src/settings/plugins/ifupdown/Makefile.in b/src/settings/plugins/ifupdown/Makefile.in index 3bd19afc..b16c3053 100644 --- a/src/settings/plugins/ifupdown/Makefile.in +++ b/src/settings/plugins/ifupdown/Makefile.in @@ -277,7 +277,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -289,8 +288,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -300,6 +297,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -354,16 +352,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -400,6 +395,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -428,7 +425,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -443,6 +439,8 @@ 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@ @@ -503,6 +501,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -510,6 +509,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -529,12 +529,12 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ $(GUDEV_CFLAGS) \ diff --git a/src/settings/plugins/ifupdown/interface_parser.c b/src/settings/plugins/ifupdown/interface_parser.c index 32d27c57..4606f5ab 100644 --- a/src/settings/plugins/ifupdown/interface_parser.c +++ b/src/settings/plugins/ifupdown/interface_parser.c @@ -29,7 +29,7 @@ #include <wordexp.h> #include <libgen.h> #include "nm-utils.h" -#include "nm-logging.h" +#include "nm-default.h" if_block* first; if_block* last; diff --git a/src/settings/plugins/ifupdown/interface_parser.h b/src/settings/plugins/ifupdown/interface_parser.h index e68abcf6..4034d44c 100644 --- a/src/settings/plugins/ifupdown/interface_parser.h +++ b/src/settings/plugins/ifupdown/interface_parser.h @@ -24,7 +24,7 @@ #ifndef _INTERFACE_PARSER_H #define _INTERFACE_PARSER_H -#include <glib.h> +#include "nm-default.h" typedef struct _if_data { diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c index c6073bd7..2c8504b0 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -29,8 +29,8 @@ #include <nm-utils.h> #include <nm-setting-wireless-security.h> #include <nm-settings-connection.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "nm-ifupdown-connection.h" #include "parser.h" diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h index be2ebc0a..54c219f4 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h @@ -25,6 +25,7 @@ #define __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ #include <nm-settings-connection.h> +#include "nm-default.h" #include "interface_parser.h" G_BEGIN_DECLS diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c index 15081a4c..8a3d4551 100644 --- a/src/settings/plugins/ifupdown/parser.c +++ b/src/settings/plugins/ifupdown/parser.c @@ -30,8 +30,8 @@ #include <ctype.h> #include "nm-core-internal.h" -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-settings-plugin.h" +#include "nm-default.h" #include "parser.h" #include "plugin.h" diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c index 8652dd8d..fc361de5 100644 --- a/src/settings/plugins/ifupdown/plugin.c +++ b/src/settings/plugins/ifupdown/plugin.c @@ -25,32 +25,27 @@ #include "config.h" #include <string.h> -#include <sys/inotify.h> - #include <gmodule.h> -#include <glib-object.h> -#include <glib/gi18n.h> -#include <glib.h> #include <nm-setting-connection.h> +#include "nm-default.h" #include "interface_parser.h" #include "nm-dbus-interface.h" -#include "nm-system-config-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-inotify-helper.h" -#include "nm-logging.h" #include "nm-config.h" #include <arpa/inet.h> @@ -61,7 +56,6 @@ #define IFUPDOWN_PLUGIN_NAME "ifupdown" #define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd. To report bugs please use the NetworkManager mailing list." -#define IFUPDOWN_SYSTEM_HOSTNAME_FILE "/etc/hostname" #define IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT TRUE @@ -74,7 +68,6 @@ typedef struct { GUdevClient *client; GHashTable *connections; /* /e/n/i block name :: NMIfupdownConnection */ - gchar* hostname; /* Stores all blocks/interfaces read from /e/n/i regardless of whether * there is an NMIfupdownConnection for block. @@ -85,31 +78,31 @@ typedef struct { GHashTable *kernel_ifaces; gboolean unmanage_well_known; - - gulong inotify_event_id; - int inotify_system_hostname_wd; -} SCPluginIfupdownPrivate; +} SettingsPluginIfupdownPrivate; static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +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)) -G_DEFINE_TYPE_EXTENDED (SCPluginIfupdown, sc_plugin_ifupdown, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +#define SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownPrivate)) -#define SC_PLUGIN_IFUPDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdownPrivate)) +static SettingsPluginIfupdown *settings_plugin_ifupdown_get (void); +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfupdown, settings_plugin_ifupdown_get, SETTINGS_TYPE_PLUGIN_IFUPDOWN); static void -sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class); +settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class); static void -SCPluginIfupdown_init (NMSystemConfigInterface *config); +SettingsPluginIfupdown_init (NMSettingsPlugin *config); /* Returns the plugins currently known list of connections. The returned * list is freed by the system settings service. */ static GSList* -SCPluginIfupdown_get_connections (NMSystemConfigInterface *config); +SettingsPluginIfupdown_get_connections (NMSettingsPlugin *config); /* * Return a list of device specifications which NetworkManager should not @@ -117,7 +110,7 @@ SCPluginIfupdown_get_connections (NMSystemConfigInterface *config); * each element must be allocated using g_malloc() or its variants. */ static GSList* -SCPluginIfupdown_get_unmanaged_specs (NMSystemConfigInterface *config); +SettingsPluginIfupdown_get_unmanaged_specs (NMSettingsPlugin *config); /* GObject */ @@ -132,56 +125,40 @@ GObject__set_property (GObject *object, guint prop_id, static void GObject__dispose (GObject *object); -/* other helpers */ -static const char * -get_hostname (NMSystemConfigInterface *config); - - -static void -update_system_hostname(NMInotifyHelper *inotify_helper, - struct inotify_event *evt, - const char *path, - NMSystemConfigInterface *config); - - static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - system_config_interface_class->init = SCPluginIfupdown_init; - system_config_interface_class->get_connections = SCPluginIfupdown_get_connections; - system_config_interface_class->get_unmanaged_specs = SCPluginIfupdown_get_unmanaged_specs; + plugin_iface->init = SettingsPluginIfupdown_init; + plugin_iface->get_connections = SettingsPluginIfupdown_get_connections; + plugin_iface->get_unmanaged_specs = SettingsPluginIfupdown_get_unmanaged_specs; } static void -sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class) +settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIfupdownPrivate)); + g_type_class_add_private (req_class, sizeof (SettingsPluginIfupdownPrivate)); object_class->dispose = GObject__dispose; object_class->get_property = GObject__get_property; object_class->set_property = GObject__set_property; g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -bind_device_to_connection (SCPluginIfupdown *self, +bind_device_to_connection (SettingsPluginIfupdown *self, GUdevDevice *device, NMIfupdownConnection *exported) { @@ -217,13 +194,13 @@ bind_device_to_connection (SCPluginIfupdown *self, g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, address, NULL); } - nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), NULL, NULL); + nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL, NULL); } static void -udev_device_added (SCPluginIfupdown *self, GUdevDevice *device) +udev_device_added (SettingsPluginIfupdown *self, GUdevDevice *device) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); const char *iface, *path; NMIfupdownConnection *exported; @@ -250,13 +227,13 @@ udev_device_added (SCPluginIfupdown *self, GUdevDevice *device) bind_device_to_connection (self, device, exported); if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void -udev_device_removed (SCPluginIfupdown *self, GUdevDevice *device) +udev_device_removed (SettingsPluginIfupdown *self, GUdevDevice *device) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); const char *iface, *path; iface = g_udev_device_get_name (device); @@ -270,13 +247,13 @@ udev_device_removed (SCPluginIfupdown *self, GUdevDevice *device) return; if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void -udev_device_changed (SCPluginIfupdown *self, GUdevDevice *device) +udev_device_changed (SettingsPluginIfupdown *self, GUdevDevice *device) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); const char *iface, *path; iface = g_udev_device_get_name (device); @@ -290,7 +267,7 @@ udev_device_changed (SCPluginIfupdown *self, GUdevDevice *device) return; if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void @@ -299,7 +276,7 @@ handle_uevent (GUdevClient *client, GUdevDevice *device, gpointer user_data) { - SCPluginIfupdown *self = SC_PLUGIN_IFUPDOWN (user_data); + SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (user_data); const char *subsys; g_return_if_fail (action != NULL); @@ -318,13 +295,12 @@ handle_uevent (GUdevClient *client, } static void -SCPluginIfupdown_init (NMSystemConfigInterface *config) +SettingsPluginIfupdown_init (NMSettingsPlugin *config) { - SCPluginIfupdown *self = SC_PLUGIN_IFUPDOWN (config); - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (config); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); GHashTable *auto_ifaces; if_block *block = NULL; - NMInotifyHelper *inotify_helper; GList *keys, *iter; GHashTableIter con_iter; const char *block_name; @@ -350,17 +326,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) } else g_signal_connect (priv->client, "uevent", G_CALLBACK (handle_uevent), self); - inotify_helper = nm_inotify_helper_get (); - priv->inotify_event_id = g_signal_connect (inotify_helper, - "event", - G_CALLBACK (update_system_hostname), - config); - - priv->inotify_system_hostname_wd = - nm_inotify_helper_add_watch (inotify_helper, IFUPDOWN_SYSTEM_HOSTNAME_FILE); - - update_system_hostname (inotify_helper, NULL, NULL, config); - /* Read in all the interfaces */ ifparser_init (ENI_INTERFACES_FILE, 0); block = ifparser_getfirst (); @@ -471,7 +436,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) { g_signal_emit_by_name (self, - NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, + NM_SETTINGS_PLUGIN_CONNECTION_ADDED, NM_SETTINGS_CONNECTION (cl_iter->data)); } g_list_free (con_list); @@ -485,9 +450,9 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) * list is freed by the system settings service. */ static GSList* -SCPluginIfupdown_get_connections (NMSystemConfigInterface *config) +SettingsPluginIfupdown_get_connections (NMSettingsPlugin *config) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (config); GSList *connections; nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections.", GPOINTER_TO_UINT(config)); @@ -509,9 +474,9 @@ SCPluginIfupdown_get_connections (NMSystemConfigInterface *config) * each element must be allocated using g_malloc() or its variants. */ static GSList* -SCPluginIfupdown_get_unmanaged_specs (NMSystemConfigInterface *config) +SettingsPluginIfupdown_get_unmanaged_specs (NMSettingsPlugin *config) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (config); GSList *specs = NULL; GHashTableIter iter; GUdevDevice *device; @@ -536,78 +501,8 @@ SCPluginIfupdown_get_unmanaged_specs (NMSystemConfigInterface *config) return specs; } - -static const char * -get_hostname (NMSystemConfigInterface *config) -{ - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - return priv->hostname; -} - static void -update_system_hostname(NMInotifyHelper *inotify_helper, - struct inotify_event *evt, - const char *path, - NMSystemConfigInterface *config) -{ - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - gchar *hostname_file = NULL; - gsize hostname_file_len = 0; - GError *error = NULL; - - nm_log_info (LOGD_SETTINGS, "update_system_hostname"); - - if (evt && evt->wd != priv->inotify_system_hostname_wd) - return; - - if(!g_file_get_contents ( IFUPDOWN_SYSTEM_HOSTNAME_FILE, - &hostname_file, - &hostname_file_len, - &error)) { - nm_log_warn (LOGD_SETTINGS, "update_system_hostname() - couldn't read " - IFUPDOWN_SYSTEM_HOSTNAME_FILE " (%d/%s)", - error->code, error->message); - return; - } - - g_free(priv->hostname); - priv->hostname = g_strstrip(hostname_file); - - /* We shouldn't return a zero-length hostname, but NULL */ - if (priv->hostname && !strlen (priv->hostname)) { - g_free (priv->hostname); - priv->hostname = NULL; - } - - g_object_notify (G_OBJECT (config), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -write_system_hostname(NMSystemConfigInterface *config, - const char *newhostname) -{ - GError *error = NULL; - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - nm_log_info (LOGD_SETTINGS, "write_system_hostname: %s", newhostname); - - g_return_if_fail (newhostname); - - if(!g_file_set_contents ( IFUPDOWN_SYSTEM_HOSTNAME_FILE, - newhostname, - -1, - &error)) { - nm_log_warn (LOGD_SETTINGS, "update_system_hostname() - couldn't write hostname (%s) to " - IFUPDOWN_SYSTEM_HOSTNAME_FILE " (%d/%s)", - newhostname, error->code, error->message); - } else { - priv->hostname = g_strdup (newhostname); - } - g_object_notify (G_OBJECT (config), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - - -static void -sc_plugin_ifupdown_init (SCPluginIfupdown *plugin) +settings_plugin_ifupdown_init (SettingsPluginIfupdown *plugin) { } @@ -615,23 +510,16 @@ static void GObject__get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSystemConfigInterface *self = NM_SYSTEM_CONFIG_INTERFACE (object); - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, IFUPDOWN_PLUGIN_NAME); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, IFUPDOWN_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_NONE); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - { - g_value_set_string (value, get_hostname(self)); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -643,15 +531,6 @@ GObject__set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - { - const gchar *hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - write_system_hostname(NM_SYSTEM_CONFIG_INTERFACE(object), - hostname); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -661,14 +540,8 @@ GObject__set_property (GObject *object, guint prop_id, static void GObject__dispose (GObject *object) { - SCPluginIfupdown *plugin = SC_PLUGIN_IFUPDOWN (object); - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (plugin); - NMInotifyHelper *inotify_helper = nm_inotify_helper_get (); - - g_signal_handler_disconnect (inotify_helper, priv->inotify_event_id); - - if (priv->inotify_system_hostname_wd >= 0) - nm_inotify_helper_remove_watch (inotify_helper, priv->inotify_system_hostname_wd); + 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); @@ -680,21 +553,12 @@ GObject__dispose (GObject *object) g_object_unref (priv->client); - G_OBJECT_CLASS (sc_plugin_ifupdown_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ifupdown_parent_class)->dispose (object); } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIfupdown *singleton = NULL; - SCPluginIfupdownPrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_IFUPDOWN (g_object_new (SC_TYPE_PLUGIN_IFUPDOWN, NULL)); - priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (singleton); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ifupdown_get ()); } diff --git a/src/settings/plugins/ifupdown/plugin.h b/src/settings/plugins/ifupdown/plugin.h index 943b8b9f..090178f2 100644 --- a/src/settings/plugins/ifupdown/plugin.h +++ b/src/settings/plugins/ifupdown/plugin.h @@ -24,28 +24,28 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" #define PLUGIN_NAME "ifupdown" -#define SC_TYPE_PLUGIN_IFUPDOWN (sc_plugin_ifupdown_get_type ()) -#define SC_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdown)) -#define SC_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdownClass)) -#define SC_IS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFUPDOWN)) -#define SC_IS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFUPDOWN)) -#define SC_PLUGIN_IFUPDOWN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdownClass)) +#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 _SCPluginIfupdown SCPluginIfupdown; -typedef struct _SCPluginIfupdownClass SCPluginIfupdownClass; +typedef struct _SettingsPluginIfupdown SettingsPluginIfupdown; +typedef struct _SettingsPluginIfupdownClass SettingsPluginIfupdownClass; -struct _SCPluginIfupdown { +struct _SettingsPluginIfupdown { GObject parent; }; -struct _SCPluginIfupdownClass { +struct _SettingsPluginIfupdownClass { GObjectClass parent; }; -GType sc_plugin_ifupdown_get_type (void); +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 index 4ae44a0b..29e9a7ed 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.am +++ b/src/settings/plugins/ifupdown/tests/Makefile.am @@ -1,15 +1,15 @@ if ENABLE_TESTS AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DTEST_ENI_DIR=\"$(abs_srcdir)\" diff --git a/src/settings/plugins/ifupdown/tests/Makefile.in b/src/settings/plugins/ifupdown/tests/Makefile.in index 2387a257..8ad1c0ab 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.in +++ b/src/settings/plugins/ifupdown/tests/Makefile.in @@ -406,7 +406,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -418,8 +417,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -429,6 +426,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -483,16 +481,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -529,6 +524,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -557,7 +554,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -572,6 +568,8 @@ 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@ @@ -632,6 +630,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -639,6 +638,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -655,15 +655,15 @@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@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 \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ -DTEST_ENI_DIR=\"$(abs_srcdir)\" diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 1c100ac2..24e8afdc 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -20,11 +20,10 @@ #include "config.h" -#include <glib.h> #include <string.h> +#include "nm-default.h" #include "nm-core-internal.h" -#include "nm-logging.h" #include "interface_parser.h" #include "parser.h" @@ -844,16 +843,12 @@ test20_source_stanza (const char *path) expected_free (e); } +NMTST_DEFINE (); + int main (int argc, char **argv) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - nm_logging_setup ("WARN", "DEFAULT", NULL, NULL); - - g_test_init (&argc, &argv, NULL); + nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); if (0) dump_blocks (); diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am index 919b0805..ddcd15b2 100644 --- a/src/settings/plugins/keyfile/Makefile.am +++ b/src/settings/plugins/keyfile/Makefile.am @@ -5,15 +5,14 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DNMCONFDIR=\"$(nmconfdir)\" noinst_LTLIBRARIES = \ @@ -28,8 +27,7 @@ libkeyfile_io_la_SOURCES = \ writer.c \ writer.h \ utils.c \ - utils.h \ - common.h + utils.h libkeyfile_io_la_LIBADD = $(GLIB_LIBS) diff --git a/src/settings/plugins/keyfile/Makefile.in b/src/settings/plugins/keyfile/Makefile.in index 1514768b..9c078ca4 100644 --- a/src/settings/plugins/keyfile/Makefile.in +++ b/src/settings/plugins/keyfile/Makefile.in @@ -246,7 +246,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -258,8 +257,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -269,6 +266,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -323,16 +321,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -369,6 +364,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -397,7 +394,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -412,6 +408,8 @@ 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@ @@ -472,6 +470,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -479,6 +478,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -498,15 +498,14 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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 \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DNMCONFDIR=\"$(nmconfdir)\" noinst_LTLIBRARIES = \ @@ -521,8 +520,7 @@ libkeyfile_io_la_SOURCES = \ writer.c \ writer.h \ utils.c \ - utils.h \ - common.h + utils.h libkeyfile_io_la_LIBADD = $(GLIB_LIBS) diff --git a/src/settings/plugins/keyfile/common.h b/src/settings/plugins/keyfile/common.h deleted file mode 100644 index 86fe0028..00000000 --- a/src/settings/plugins/keyfile/common.h +++ /dev/null @@ -1,32 +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__ - -#include <glib.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 KEYFILE_DIR NMCONFDIR "/system-connections" - -#endif /* __COMMON_H__ */ - diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c index 8fb94302..c217de68 100644 --- a/src/settings/plugins/keyfile/nm-keyfile-connection.c +++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c @@ -27,12 +27,13 @@ #include <nm-setting-connection.h> #include <nm-utils.h> -#include "nm-system-config-interface.h" -#include "nm-dbus-glib-types.h" +#include "nm-default.h" +#include "nm-settings-plugin.h" #include "nm-keyfile-connection.h" #include "reader.h" #include "writer.h" -#include "common.h" +#include "utils.h" +#include "nm-logging.h" G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION) @@ -88,6 +89,7 @@ nm_keyfile_connection_new (NMConnection *source, static void commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data) { @@ -96,6 +98,8 @@ commit_changes (NMSettingsConnection *connection, 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); @@ -104,10 +108,28 @@ commit_changes (NMSettingsConnection *connection, } /* Update the filename if it changed */ - if (path) + 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); } diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index 7f21e71e..e352e523 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -27,62 +27,51 @@ #include <string.h> #include <gmodule.h> -#include <glib.h> #include <glib/gstdio.h> -#include <gio/gio.h> #include <nm-connection.h> #include <nm-setting.h> #include <nm-setting-connection.h> #include <nm-utils.h> -#include <nm-config.h> -#include <nm-logging.h> +#include "nm-config.h" +#include "nm-default.h" #include "nm-core-internal.h" #include "plugin.h" -#include "nm-system-config-interface.h" +#include "nm-settings-plugin.h" #include "nm-keyfile-connection.h" #include "writer.h" -#include "common.h" #include "utils.h" -#include "gsystem-local-alloc.h" -static char *plugin_get_hostname (SCPluginKeyfile *plugin); -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -G_DEFINE_TYPE_EXTENDED (SCPluginKeyfile, sc_plugin_keyfile, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +G_DEFINE_TYPE_EXTENDED (SettingsPluginKeyfile, settings_plugin_keyfile, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) -#define SC_PLUGIN_KEYFILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfilePrivate)) +#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; - guint monitor_id; + gulong monitor_id; - const char *conf_file; - GFileMonitor *conf_file_monitor; - guint conf_file_monitor_id; - - char *hostname; - - gboolean disposed; -} SCPluginKeyfilePrivate; + NMConfig *config; +} SettingsPluginKeyfilePrivate; static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SC_PLUGIN_KEYFILE_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } /* Monitoring */ static void -remove_connection (SCPluginKeyfile *self, NMKeyfileConnection *connection) +remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection) { gboolean removed; @@ -93,7 +82,7 @@ remove_connection (SCPluginKeyfile *self, NMKeyfileConnection *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 (SC_PLUGIN_KEYFILE_GET_PRIVATE (self)->connections, + 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); @@ -102,9 +91,9 @@ remove_connection (SCPluginKeyfile *self, NMKeyfileConnection *connection) } static NMKeyfileConnection * -find_by_path (SCPluginKeyfile *self, const char *path) +find_by_path (SettingsPluginKeyfile *self, const char *path) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); GHashTableIter iter; NMSettingsConnection *candidate = NULL; @@ -150,7 +139,7 @@ find_by_path (SCPluginKeyfile *self, const char *path) * Returns: the updated connection. * */ static NMKeyfileConnection * -update_connection (SCPluginKeyfile *self, +update_connection (SettingsPluginKeyfile *self, NMConnection *source, const char *full_path, NMKeyfileConnection *connection, @@ -158,7 +147,7 @@ update_connection (SCPluginKeyfile *self, GHashTable *protected_connections, GError **error) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); NMKeyfileConnection *connection_new; NMKeyfileConnection *connection_by_uuid; GError *local = NULL; @@ -274,7 +263,7 @@ update_connection (SCPluginKeyfile *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_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); } return connection_new; } @@ -287,8 +276,8 @@ dir_changed (GFileMonitor *monitor, GFileMonitorEvent event_type, gpointer user_data) { - NMSystemConfigInterface *config = NM_SYSTEM_CONFIG_INTERFACE (user_data); - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); + NMSettingsPlugin *config = NM_SETTINGS_PLUGIN (user_data); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); NMKeyfileConnection *connection; char *full_path; gboolean exists; @@ -307,12 +296,12 @@ dir_changed (GFileMonitor *monitor, switch (event_type) { case G_FILE_MONITOR_EVENT_DELETED: if (!exists && connection) - remove_connection (SC_PLUGIN_KEYFILE (config), 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 (SC_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL); + update_connection (SETTINGS_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL); break; default: break; @@ -322,51 +311,30 @@ dir_changed (GFileMonitor *monitor, } static void -conf_file_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer data) +config_changed_cb (NMConfig *config, + NMConfigData *config_data, + NMConfigChangeFlags changes, + NMConfigData *old_data, + SettingsPluginKeyfile *self) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (data); - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); - char *tmp; - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); - - /* hostname */ - tmp = plugin_get_hostname (self); - if ((tmp && !priv->hostname) - || (!tmp && priv->hostname) - || (priv->hostname && tmp && strcmp (priv->hostname, tmp))) { - - g_free (priv->hostname); - priv->hostname = tmp; - tmp = NULL; - g_object_notify (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } + gs_free char *old_value = NULL, *new_value = NULL; - g_free (tmp); + 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); - break; - default: - break; - } + if (g_strcmp0 (old_value, new_value) != 0) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void -setup_monitoring (NMSystemConfigInterface *config) +setup_monitoring (NMSettingsPlugin *config) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (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 (KEYFILE_DIR); + 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); @@ -376,16 +344,10 @@ setup_monitoring (NMSystemConfigInterface *config) } } - if (priv->conf_file) { - file = g_file_new_for_path (priv->conf_file); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - - if (monitor) { - priv->conf_file_monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (conf_file_changed), config); - priv->conf_file_monitor = monitor; - } - } + g_signal_connect (G_OBJECT (priv->config), + NM_CONFIG_SIGNAL_CONFIG_CHANGED, + G_CALLBACK (config_changed_cb), + config); } static GHashTable * @@ -426,10 +388,10 @@ _sort_paths (const char **f1, const char **f2, GHashTable *paths) } static void -read_connections (NMSystemConfigInterface *config) +read_connections (NMSettingsPlugin *config) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); GDir *dir; GError *error = NULL; const char *item; @@ -441,10 +403,10 @@ read_connections (NMSystemConfigInterface *config) GPtrArray *filenames; GHashTable *paths; - dir = g_dir_open (KEYFILE_DIR, 0, &error); + dir = g_dir_open (nm_keyfile_plugin_get_path (), 0, &error); if (!dir) { nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': (%d) %s", - KEYFILE_DIR, + nm_keyfile_plugin_get_path (), error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); @@ -457,7 +419,7 @@ read_connections (NMSystemConfigInterface *config) 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 (KEYFILE_DIR, item, NULL)); + g_ptr_array_add (filenames, g_build_filename (nm_keyfile_plugin_get_path (), item, NULL)); } g_dir_close (dir); @@ -499,9 +461,9 @@ read_connections (NMSystemConfigInterface *config) /* Plugin */ static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (config); if (!priv->initialized) { setup_monitoring (config); @@ -512,14 +474,14 @@ get_connections (NMSystemConfigInterface *config) } static gboolean -load_connection (NMSystemConfigInterface *config, +load_connection (NMSettingsPlugin *config, const char *filename) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); NMKeyfileConnection *connection; - int dir_len = strlen (KEYFILE_DIR); + int dir_len = strlen (nm_keyfile_plugin_get_path ()); - if ( strncmp (filename, KEYFILE_DIR, dir_len) != 0 + if ( strncmp (filename, nm_keyfile_plugin_get_path (), dir_len) != 0 || filename[dir_len] != '/' || strchr (filename + dir_len + 1, '/') != NULL) return FALSE; @@ -533,157 +495,46 @@ load_connection (NMSystemConfigInterface *config, } static void -reload_connections (NMSystemConfigInterface *config) +reload_connections (NMSettingsPlugin *config) { read_connections (config); } static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, +add_connection (NMSettingsPlugin *config, NMConnection *connection, gboolean save_to_disk, GError **error) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); gs_free char *path = NULL; if (save_to_disk) { - if (!nm_keyfile_plugin_write_connection (connection, NULL, &path, error)) + 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 gboolean -parse_key_file_allow_none (SCPluginKeyfilePrivate *priv, - GKeyFile *key_file, - GError **error) -{ - gboolean ret = FALSE; - GError *local_error = NULL; - - if (!g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &local_error)) { - if (g_error_matches (local_error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) - g_clear_error (&local_error); - else { - g_propagate_prefixed_error (error, local_error, - "Error parsing file '%s': ", - priv->conf_file); - goto out; - } - } - ret = TRUE; - - out: - return ret; -} - static GSList * -get_unmanaged_specs (NMSystemConfigInterface *config) -{ - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config); - GKeyFile *key_file; - GSList *specs = NULL; - GError *error = NULL; - - if (!priv->conf_file) - return NULL; - - key_file = nm_config_create_keyfile (); - if (parse_key_file_allow_none (priv, key_file, &error)) - specs = nm_config_get_device_match_spec (key_file, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "unmanaged-devices", NULL); - - if (error) { - nm_log_warn (LOGD_SETTINGS, "keyfile: error getting unmanaged specs: %s", error->message); - g_error_free (error); - } - g_key_file_free (key_file); - - return specs; -} - -static char * -plugin_get_hostname (SCPluginKeyfile *plugin) -{ - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (plugin); - GKeyFile *key_file; - char *hostname = NULL; - GError *error = NULL; - - if (!priv->conf_file) - return NULL; - - key_file = g_key_file_new (); - if (!parse_key_file_allow_none (priv, key_file, &error)) - goto out; - - hostname = g_key_file_get_value (key_file, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "hostname", NULL); - - out: - if (error) { - nm_log_warn (LOGD_SETTINGS, "keyfile: error getting hostname: %s", error->message); - g_error_free (error); - } - if (key_file) - g_key_file_free (key_file); - - return hostname; -} - -static gboolean -plugin_set_hostname (SCPluginKeyfile *plugin, const char *hostname) +get_unmanaged_specs (NMSettingsPlugin *config) { - gboolean ret = FALSE; - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (plugin); - GKeyFile *key_file = NULL; - GError *error = NULL; - char *data = NULL; - gsize len; - - if (!priv->conf_file) { - g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Error saving hostname: no config file"); - goto out; - } - - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); - - key_file = g_key_file_new (); - if (!parse_key_file_allow_none (priv, key_file, &error)) - goto out; - - g_key_file_set_string (key_file, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "hostname", hostname); - - data = g_key_file_to_data (key_file, &len, &error); - if (!data) - goto out; - - if (!g_file_set_contents (priv->conf_file, data, len, &error)) { - g_prefix_error (&error, "Error saving hostname: "); - goto out; - } - - ret = TRUE; - - out: - if (error) { - nm_log_warn (LOGD_SETTINGS, "keyfile: error setting hostname: %s", error->message); - g_error_free (error); - } - g_free (data); - if (key_file) - g_key_file_free (key_file); - - return ret; + 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 -sc_plugin_keyfile_init (SCPluginKeyfile *plugin) +settings_plugin_keyfile_init (SettingsPluginKeyfile *plugin) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (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); } @@ -693,18 +544,14 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, KEYFILE_PLUGIN_NAME); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, KEYFILE_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS | - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, SC_PLUGIN_KEYFILE_GET_PRIVATE (object)->hostname); + 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); @@ -716,15 +563,7 @@ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - const char *hostname; - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_KEYFILE (object), hostname); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -732,97 +571,81 @@ set_property (GObject *object, guint prop_id, } static void -dispose (GObject *object) +constructed (GObject *object) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (object); - - if (priv->disposed) - goto out; + 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"); +} - priv->disposed = TRUE; +static void +dispose (GObject *object) +{ + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (object); if (priv->monitor) { - if (priv->monitor_id) - g_signal_handler_disconnect (priv->monitor, priv->monitor_id); + nm_clear_g_signal_handler (priv->monitor, &priv->monitor_id); g_file_monitor_cancel (priv->monitor); - g_object_unref (priv->monitor); - } - - if (priv->conf_file_monitor) { - if (priv->conf_file_monitor_id) - g_signal_handler_disconnect (priv->conf_file_monitor, priv->conf_file_monitor_id); - - g_file_monitor_cancel (priv->conf_file_monitor); - g_object_unref (priv->conf_file_monitor); + g_clear_object (&priv->monitor); } - g_free (priv->hostname); - if (priv->connections) { g_hash_table_destroy (priv->connections); priv->connections = NULL; } -out: - G_OBJECT_CLASS (sc_plugin_keyfile_parent_class)->dispose (object); + 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 -sc_plugin_keyfile_class_init (SCPluginKeyfileClass *req_class) +settings_plugin_keyfile_class_init (SettingsPluginKeyfileClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginKeyfilePrivate)); + 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_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - system_config_interface_class->get_connections = get_connections; - system_config_interface_class->load_connection = load_connection; - system_config_interface_class->reload_connections = reload_connections; - system_config_interface_class->add_connection = add_connection; - system_config_interface_class->get_unmanaged_specs = get_unmanaged_specs; + 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) { - static SCPluginKeyfile *singleton = NULL; - SCPluginKeyfilePrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_KEYFILE (g_object_new (SC_TYPE_PLUGIN_KEYFILE, NULL)); - priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (singleton); - - priv->conf_file = nm_config_data_get_config_main_file (nm_config_get_data (nm_config_get ())); - - /* plugin_set_hostname() has to be called *after* priv->conf_file is set */ - priv->hostname = plugin_get_hostname (singleton); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + 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 index 48579785..07403270 100644 --- a/src/settings/plugins/keyfile/plugin.h +++ b/src/settings/plugins/keyfile/plugin.h @@ -22,24 +22,24 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" -#define SC_TYPE_PLUGIN_KEYFILE (sc_plugin_keyfile_get_type ()) -#define SC_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfile)) -#define SC_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfileClass)) -#define SC_IS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_KEYFILE)) -#define SC_IS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_KEYFILE)) -#define SC_PLUGIN_KEYFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfileClass)) +#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; -} SCPluginKeyfile; +} SettingsPluginKeyfile; typedef struct { GObjectClass parent; -} SCPluginKeyfileClass; +} SettingsPluginKeyfileClass; -GType sc_plugin_keyfile_get_type (void); +GType settings_plugin_keyfile_get_type (void); GObject *nm_settings_keyfile_plugin_new (void); diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c index bd08c17d..1c984a16 100644 --- a/src/settings/plugins/keyfile/reader.c +++ b/src/settings/plugins/keyfile/reader.c @@ -25,7 +25,7 @@ #include "reader.h" -#include "nm-logging.h" +#include "nm-default.h" #include "nm-keyfile-internal.h" #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/keyfile/reader.h b/src/settings/plugins/keyfile/reader.h index 55819630..a8021cb7 100644 --- a/src/settings/plugins/keyfile/reader.h +++ b/src/settings/plugins/keyfile/reader.h @@ -22,9 +22,10 @@ #ifndef _KEYFILE_PLUGIN_READER_H #define _KEYFILE_PLUGIN_READER_H -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" + 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 index cbe3f73b..4d85f09a 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.am +++ b/src/settings/plugins/keyfile/tests/Makefile.am @@ -5,18 +5,17 @@ SUBDIRS=keyfiles @GNOME_CODE_COVERAGE_RULES@ AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -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) \ - $(DBUS_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ @@ -32,7 +31,6 @@ test_keyfile_SOURCES = \ test_keyfile_LDADD = \ $(top_builddir)/src/libNetworkManager.la \ - $(DBUS_LIBS) \ $(CODE_COVERAGE_LDFLAGS) @VALGRIND_RULES@ diff --git a/src/settings/plugins/keyfile/tests/Makefile.in b/src/settings/plugins/keyfile/tests/Makefile.in index 6dfaf110..7577df57 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.in +++ b/src/settings/plugins/keyfile/tests/Makefile.in @@ -122,7 +122,7 @@ 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__DEPENDENCIES_1) +@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 @@ -450,7 +450,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -462,8 +461,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -473,6 +470,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -527,16 +525,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -573,6 +568,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -601,7 +598,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -616,6 +612,8 @@ 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@ @@ -676,6 +674,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -683,6 +682,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -700,18 +700,17 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@SUBDIRS = keyfiles @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@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@ $(DBUS_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ @ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ @@ -725,7 +724,6 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@test_keyfile_LDADD = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ -@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) all: all-recursive diff --git a/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain b/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain index 902b8427..11e1ec6f 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain +++ b/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain @@ -15,6 +15,9 @@ password=CINGULAR1 apn=ISP.CINGULAR network-id=24005 pin=2345 +device-id=da812de91eec16620b06cd0ca5cbc7ea25245222 +sim-id=89148000000060671234 +sim-operator-id=310260 [serial] baud=115200 diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in index 33d0e0c5..56f0735f 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in +++ b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in @@ -146,7 +146,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -158,8 +157,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -169,6 +166,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -223,16 +221,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -269,6 +264,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +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@ @@ -297,7 +294,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -312,6 +308,8 @@ 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@ @@ -372,6 +370,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -379,6 +378,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main b/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main index 3b9fcb28..fc9fd8f8 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main @@ -11,6 +11,7 @@ priority=32744 hello-time=7 max-age=39 ageing-time=235352 +multicast-snooping=false [ipv4] method=auto diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index 785ad4cb..250bad36 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -29,7 +29,7 @@ #include <sys/socket.h> #include "nm-core-internal.h" -#include "nm-logging.h" +#include "nm-default.h" #include "reader.h" #include "writer.h" @@ -1882,153 +1882,43 @@ test_read_gsm_connection (void) NMSettingConnection *s_con; NMSettingSerial *s_serial; NMSettingGsm *s_gsm; - NMSettingBluetooth *s_bluetooth; GError *error = NULL; - const char *tmp; - NMSettingSerialParity parity; - const char *expected_id = "AT&T Data Connect"; - const char *expected_apn = "ISP.CINGULAR"; - const char *expected_username = "ISP@CINGULARGPRS.COM"; - const char *expected_password = "CINGULAR1"; - const char *expected_network_id = "24005"; - const char *expected_pin = "2345"; + gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_GSM_FILE, NULL); - ASSERT (connection != NULL, - "connection-read", "failed to read %s", TEST_GSM_FILE); + connection = nm_keyfile_plugin_connection_from_file (TEST_GSM_FILE, &error); + g_assert_no_error (error); + g_assert (connection); - ASSERT (nm_connection_verify (connection, &error), - "connection-verify", "failed to verify %s: %s", TEST_GSM_FILE, error->message); + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection (connection); - ASSERT (s_con != NULL, - "connection-verify-connection", "failed to verify %s: missing %s setting", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME); - - /* ID */ - tmp = nm_setting_connection_get_id (s_con); - ASSERT (tmp != NULL, - "connection-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, expected_id) == 0, - "connection-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - - tmp = nm_setting_connection_get_connection_type (s_con); - ASSERT (tmp != NULL, - "connection-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, NM_SETTING_GSM_SETTING_NAME) == 0, - "connection-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_TYPE); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "AT&T Data Connect"); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_GSM_SETTING_NAME); /* ===== BLUETOOTH SETTING ===== */ - /* Plain GSM, so no BT setting expected */ - s_bluetooth = nm_connection_get_setting_bluetooth (connection); - ASSERT (s_bluetooth == NULL, - "connection-verify-bt", "unexpected %s setting", - TEST_GSM_FILE, - NM_SETTING_BLUETOOTH_SETTING_NAME); + g_assert (nm_connection_get_setting_bluetooth (connection) == NULL); /* ===== GSM SETTING ===== */ - s_gsm = nm_connection_get_setting_gsm (connection); - ASSERT (s_gsm != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s setting", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME); - - /* APN */ - tmp = nm_setting_gsm_get_apn (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_APN); - ASSERT (strcmp (tmp, expected_apn) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_APN); - - /* Username */ - tmp = nm_setting_gsm_get_username (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_USERNAME); - ASSERT (strcmp (tmp, expected_username) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_USERNAME); - - /* Password */ - tmp = nm_setting_gsm_get_password (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PASSWORD); - ASSERT (strcmp (tmp, expected_password) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PASSWORD); - - /* Network ID */ - tmp = nm_setting_gsm_get_network_id (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_NETWORK_ID); - ASSERT (strcmp (tmp, expected_network_id) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_NETWORK_ID); - - /* PIN */ - tmp = nm_setting_gsm_get_pin (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PIN); - ASSERT (strcmp (tmp, expected_pin) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PIN); + g_assert (s_gsm); + g_assert_cmpstr (nm_setting_gsm_get_apn (s_gsm), ==, "ISP.CINGULAR"); + g_assert_cmpstr (nm_setting_gsm_get_username (s_gsm), ==, "ISP@CINGULARGPRS.COM"); + g_assert_cmpstr (nm_setting_gsm_get_password (s_gsm), ==, "CINGULAR1"); + g_assert_cmpstr (nm_setting_gsm_get_network_id (s_gsm), ==, "24005"); + g_assert_cmpstr (nm_setting_gsm_get_pin (s_gsm), ==, "2345"); + g_assert_cmpstr (nm_setting_gsm_get_device_id (s_gsm), ==, "da812de91eec16620b06cd0ca5cbc7ea25245222"); + g_assert_cmpstr (nm_setting_gsm_get_sim_id (s_gsm), ==, "89148000000060671234"); + g_assert_cmpstr (nm_setting_gsm_get_sim_operator_id (s_gsm), ==, "310260"); /* ===== SERIAL SETTING ===== */ - s_serial = nm_connection_get_setting_serial (connection); - ASSERT (s_serial != NULL, - "connection-verify-serial", "failed to verify %s: missing %s setting", - TEST_GSM_FILE, - NM_SETTING_SERIAL_SETTING_NAME); - - parity = nm_setting_serial_get_parity (s_serial); - ASSERT (parity == NM_SETTING_SERIAL_PARITY_ODD, - "connection-verify-serial", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_SERIAL_SETTING_NAME, - NM_SETTING_SERIAL_PARITY); + g_assert (s_serial); + g_assert_cmpint (nm_setting_serial_get_parity (s_serial), ==, NM_SETTING_SERIAL_PARITY_ODD); g_object_unref (connection); } @@ -2087,22 +1977,23 @@ test_write_gsm_connection (void) NM_SETTING_GSM_PIN, "123456", NM_SETTING_GSM_NETWORK_ID, "254098", NM_SETTING_GSM_HOME_ONLY, TRUE, + NM_SETTING_GSM_DEVICE_ID, "da812de91eec16620b06cd0ca5cbc7ea25245222", + NM_SETTING_GSM_SIM_ID, "89148000000060671234", + 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); - ASSERT (success == TRUE, - "connection-write", "failed to write keyfile: %s", - error ? error->message : "(none)"); - - ASSERT (testfile != NULL, - "connection-write", "didn't get keyfile name back after writing connection"); + 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, NULL); - ASSERT (reread != NULL, "connection-write", "failed to re-read test connection"); + 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); @@ -2821,6 +2712,7 @@ test_read_bridge_main (void) g_assert_cmpuint (nm_setting_bridge_get_hello_time (s_bridge), ==, 7); 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); } diff --git a/src/settings/plugins/keyfile/utils.c b/src/settings/plugins/keyfile/utils.c index 4809c642..48795ffb 100644 --- a/src/settings/plugins/keyfile/utils.c +++ b/src/settings/plugins/keyfile/utils.c @@ -20,15 +20,16 @@ #include "config.h" -#include <glib.h> #include <stdlib.h> #include <string.h> -#include "gsystem-local-alloc.h" +#include "nm-default.h" #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"; @@ -146,3 +147,23 @@ nm_keyfile_plugin_utils_escape_filename (const char *filename) 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 index d0862284..0b2b6f4e 100644 --- a/src/settings/plugins/keyfile/utils.h +++ b/src/settings/plugins/keyfile/utils.h @@ -21,9 +21,12 @@ #ifndef _UTILS_H_ #define _UTILS_H_ -#include <glib.h> +#include "nm-default.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) str_if_set (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)) @@ -34,5 +37,7 @@ 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 index b6a8786d..db00b061 100644 --- a/src/settings/plugins/keyfile/writer.c +++ b/src/settings/plugins/keyfile/writer.c @@ -27,15 +27,11 @@ #include <errno.h> #include <string.h> -#include "nm-glib-compat.h" - -#include "nm-logging.h" +#include "nm-default.h" #include "writer.h" -#include "common.h" #include "utils.h" #include "nm-keyfile-internal.h" - typedef struct { const char *keyfile_dir; } WriteInfo; @@ -233,17 +229,18 @@ _internal_write_connection (NMConnection *connection, uid_t owner_uid, pid_t owner_grp, const char *existing_path, + gboolean force_rename, char **out_path, GError **error) { GKeyFile *key_file; - char *data; + gs_free char *data = NULL; gsize len; - gboolean success = FALSE; - char *path; + 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); @@ -267,7 +264,7 @@ _internal_write_connection (NMConnection *connection, /* If we have existing file path, use it. Else generate one from * connection's ID. */ - if (existing_path != NULL) { + if (existing_path != NULL && !force_rename) { path = g_strdup (existing_path); } else { char *filename_escaped = nm_keyfile_plugin_utils_escape_filename (id); @@ -312,8 +309,7 @@ _internal_write_connection (NMConnection *connection, /* 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); - g_free (path); - goto out; + return FALSE; } /* Both our preferred path based on connection id and id-uuid are taken. * Fallback to @existing_path */ @@ -331,49 +327,49 @@ _internal_write_connection (NMConnection *connection, g_file_set_contents (path, data, len, &local_err); if (local_err) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "%s.%d: error writing to file '%s': %s", __FILE__, __LINE__, + "error writing to file '%s': %s", path, local_err->message); g_error_free (local_err); - g_free (path); - goto out; + return FALSE; } if (chown (path, owner_uid, owner_grp) < 0) { + errsv = errno; g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "%s.%d: error chowning '%s': %d", __FILE__, __LINE__, - path, errno); + "error chowning '%s': %s (%d)", + path, g_strerror (errsv), errsv); unlink (path); - } else { - if (chmod (path, S_IRUSR | S_IWUSR) < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "%s.%d: error setting permissions on '%s': %d", __FILE__, - __LINE__, path, errno); - unlink (path); - } else { - if (out_path && g_strcmp0 (existing_path, path)) { - *out_path = path; /* pass path out to caller */ - path = NULL; - } - success = TRUE; - } + return FALSE; } - g_free (path); -out: - g_free (data); - return success; + if (chmod (path, S_IRUSR | S_IWUSR) < 0) { + errsv = errno; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "error setting permissions on '%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 nm_keyfile_plugin_write_connection (NMConnection *connection, const char *existing_path, + gboolean force_rename, char **out_path, GError **error) { return _internal_write_connection (connection, - KEYFILE_DIR, + nm_keyfile_plugin_get_path (), 0, 0, existing_path, + force_rename, out_path, error); } @@ -390,6 +386,7 @@ nm_keyfile_plugin_write_test_connection (NMConnection *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 index 8b08812d..25f44e94 100644 --- a/src/settings/plugins/keyfile/writer.h +++ b/src/settings/plugins/keyfile/writer.h @@ -22,11 +22,13 @@ #ifndef _KEYFILE_PLUGIN_WRITER_H #define _KEYFILE_PLUGIN_WRITER_H -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" + gboolean nm_keyfile_plugin_write_connection (NMConnection *connection, const char *existing_path, + gboolean force_rename, char **out_path, GError **error); |