diff options
| author | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
| commit | 58f8be580039b0575b197b9573a1c92745d96d30 (patch) | |
| tree | 2c226233f623a0dcb529be0eb8cdf97e4a2ae0c0 /src/settings/plugins/ifcfg-rh | |
| parent | 45cb5bb3c0e6edb887cf69b417fcaf7053814a9b (diff) | |
New upstream version 1.5.90 upstream/1.5.90
Diffstat (limited to 'src/settings/plugins/ifcfg-rh')
36 files changed, 3572 insertions, 6350 deletions
diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am deleted file mode 100644 index d2899a26..00000000 --- a/src/settings/plugins/ifcfg-rh/Makefile.am +++ /dev/null @@ -1,74 +0,0 @@ -SUBDIRS = . tests - -@GNOME_CODE_COVERAGE_RULES@ - -# See note about gdbus-codegen in introspection/Makefile.am - -noinst_LTLIBRARIES = libnmdbus-ifcfg-rh.la - -nodist_libnmdbus_ifcfg_rh_la_SOURCES = \ - nmdbus-ifcfg-rh.c \ - nmdbus-ifcfg-rh.h - -libnmdbus_ifcfg_rh_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS)) - -nmdbus-ifcfg-rh.h: nm-ifcfg-rh.xml - $(AM_V_GEN) gdbus-codegen \ - --generate-c-code $(basename $@) \ - --c-namespace NMDBus \ - --interface-prefix com.redhat \ - $< - -nmdbus-ifcfg-rh.c: nmdbus-ifcfg-rh.h - @true - -BUILT_SOURCES = nmdbus-ifcfg-rh.h nmdbus-ifcfg-rh.c - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la - -noinst_LTLIBRARIES += libifcfg-rh-io.la - -libifcfg_rh_io_la_SOURCES = \ - shvar.c \ - shvar.h \ - reader.c \ - reader.h \ - writer.c \ - writer.h \ - common.h \ - utils.c \ - utils.h - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(NSS_CFLAGS) \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" - -libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ - plugin.c \ - plugin.h \ - nm-ifcfg-connection.c \ - nm-ifcfg-connection.h - -libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la libnmdbus-ifcfg-rh.la - -dbusservicedir = $(DBUS_SYS_DIR) -dbusservice_DATA = nm-ifcfg-rh.conf - -EXTRA_DIST = \ - $(dbusservice_DATA) \ - nm-ifcfg-rh.xml - -CLEANFILES = $(BUILT_SOURCES) - diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in deleted file mode 100644 index 200289e5..00000000 --- a/src/settings/plugins/ifcfg-rh/Makefile.in +++ /dev/null @@ -1,1062 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ifcfg-rh -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" \ - "$(DESTDIR)$(dbusservicedir)" -LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES) -libifcfg_rh_io_la_LIBADD = -am_libifcfg_rh_io_la_OBJECTS = shvar.lo reader.lo writer.lo utils.lo -libifcfg_rh_io_la_OBJECTS = $(am_libifcfg_rh_io_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES = libifcfg-rh-io.la \ - libnmdbus-ifcfg-rh.la -am_libnm_settings_plugin_ifcfg_rh_la_OBJECTS = plugin.lo \ - nm-ifcfg-connection.lo -libnm_settings_plugin_ifcfg_rh_la_OBJECTS = \ - $(am_libnm_settings_plugin_ifcfg_rh_la_OBJECTS) -libnm_settings_plugin_ifcfg_rh_la_LINK = $(LIBTOOL) $(AM_V_lt) \ - --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ - $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_ifcfg_rh_la_LDFLAGS) $(LDFLAGS) -o $@ -libnmdbus_ifcfg_rh_la_LIBADD = -nodist_libnmdbus_ifcfg_rh_la_OBJECTS = \ - libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo -libnmdbus_ifcfg_rh_la_OBJECTS = \ - $(nodist_libnmdbus_ifcfg_rh_la_OBJECTS) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libifcfg_rh_io_la_SOURCES) \ - $(libnm_settings_plugin_ifcfg_rh_la_SOURCES) \ - $(nodist_libnmdbus_ifcfg_rh_la_SOURCES) -DIST_SOURCES = $(libifcfg_rh_io_la_SOURCES) \ - $(libnm_settings_plugin_ifcfg_rh_la_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -DATA = $(dbusservice_DATA) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -SUBDIRS = . tests - -# See note about gdbus-codegen in introspection/Makefile.am -noinst_LTLIBRARIES = libnmdbus-ifcfg-rh.la libifcfg-rh-io.la -nodist_libnmdbus_ifcfg_rh_la_SOURCES = \ - nmdbus-ifcfg-rh.c \ - nmdbus-ifcfg-rh.h - -libnmdbus_ifcfg_rh_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS)) -BUILT_SOURCES = nmdbus-ifcfg-rh.h nmdbus-ifcfg-rh.c -pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la -libifcfg_rh_io_la_SOURCES = \ - shvar.c \ - shvar.h \ - reader.c \ - reader.h \ - writer.c \ - writer.h \ - common.h \ - utils.c \ - utils.h - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(NSS_CFLAGS) \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" - -libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ - plugin.c \ - plugin.h \ - nm-ifcfg-connection.c \ - nm-ifcfg-connection.h - -libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la libnmdbus-ifcfg-rh.la -dbusservicedir = $(DBUS_SYS_DIR) -dbusservice_DATA = nm-ifcfg-rh.conf -EXTRA_DIST = \ - $(dbusservice_DATA) \ - nm-ifcfg-rh.xml - -CLEANFILES = $(BUILT_SOURCES) -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libifcfg-rh-io.la: $(libifcfg_rh_io_la_OBJECTS) $(libifcfg_rh_io_la_DEPENDENCIES) $(EXTRA_libifcfg_rh_io_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libifcfg_rh_io_la_OBJECTS) $(libifcfg_rh_io_la_LIBADD) $(LIBS) - -libnm-settings-plugin-ifcfg-rh.la: $(libnm_settings_plugin_ifcfg_rh_la_OBJECTS) $(libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_ifcfg_rh_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ifcfg_rh_la_OBJECTS) $(libnm_settings_plugin_ifcfg_rh_la_LIBADD) $(LIBS) - -libnmdbus-ifcfg-rh.la: $(libnmdbus_ifcfg_rh_la_OBJECTS) $(libnmdbus_ifcfg_rh_la_DEPENDENCIES) $(EXTRA_libnmdbus_ifcfg_rh_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libnmdbus_ifcfg_rh_la_OBJECTS) $(libnmdbus_ifcfg_rh_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ifcfg-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shvar.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo: nmdbus-ifcfg-rh.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnmdbus_ifcfg_rh_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo -MD -MP -MF $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Tpo -c -o libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo `test -f 'nmdbus-ifcfg-rh.c' || echo '$(srcdir)/'`nmdbus-ifcfg-rh.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Tpo $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nmdbus-ifcfg-rh.c' object='libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnmdbus_ifcfg_rh_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo `test -f 'nmdbus-ifcfg-rh.c' || echo '$(srcdir)/'`nmdbus-ifcfg-rh.c - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-dbusserviceDATA: $(dbusservice_DATA) - @$(NORMAL_INSTALL) - @list='$(dbusservice_DATA)'; test -n "$(dbusservicedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(dbusservicedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(dbusservicedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dbusservicedir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(dbusservicedir)" || exit $$?; \ - done - -uninstall-dbusserviceDATA: - @$(NORMAL_UNINSTALL) - @list='$(dbusservice_DATA)'; test -n "$(dbusservicedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(dbusservicedir)'; $(am__uninstall_files_from_dir) - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-recursive -all-am: Makefile $(LTLIBRARIES) $(DATA) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(dbusservicedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - clean-pkglibLTLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-dbusserviceDATA - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-dbusserviceDATA uninstall-pkglibLTLIBRARIES - -.MAKE: $(am__recursive_targets) all check install install-am \ - install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dbusserviceDATA install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-pkglibLTLIBRARIES \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-dbusserviceDATA \ - uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - - -@GNOME_CODE_COVERAGE_RULES@ - -nmdbus-ifcfg-rh.h: nm-ifcfg-rh.xml - $(AM_V_GEN) gdbus-codegen \ - --generate-c-code $(basename $@) \ - --c-namespace NMDBus \ - --interface-prefix com.redhat \ - $< - -nmdbus-ifcfg-rh.c: nmdbus-ifcfg-rh.h - @true - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h index d850ac4e..d850ac4e 100644 --- a/src/settings/plugins/ifcfg-rh/common.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c index a83bd35d..33f4847e 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c @@ -20,10 +20,10 @@ #include "nm-default.h" -#include "nm-ifcfg-connection.h" +#include "nms-ifcfg-rh-connection.h" #include <string.h> - +#include <sys/inotify.h> #include <glib/gstdio.h> #include "nm-dbus-interface.h" @@ -35,18 +35,28 @@ #include "nm-setting-pppoe.h" #include "nm-setting-wireless-security.h" #include "nm-setting-8021x.h" -#include "nm-platform.h" - -#include "common.h" +#include "platform/nm-platform.h" +#include "settings/nm-inotify-helper.h" #include "nm-config.h" -#include "reader.h" -#include "writer.h" -#include "nm-inotify-helper.h" -#include "utils.h" -G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SETTINGS_CONNECTION) +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-reader.h" +#include "nms-ifcfg-rh-writer.h" +#include "nms-ifcfg-rh-utils.h" + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_UNMANAGED_SPEC, + PROP_UNRECOGNIZED_SPEC, +); + +enum { + IFCFG_CHANGED, + LAST_SIGNAL +}; -#define NM_IFCFG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionPrivate)) +static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { gulong ih_event_id; @@ -71,20 +81,20 @@ typedef struct { NMInotifyHelper *inotify_helper; } NMIfcfgConnectionPrivate; -enum { - PROP_0, - PROP_UNMANAGED_SPEC, - PROP_UNRECOGNIZED_SPEC, - LAST_PROP +struct _NMIfcfgConnection { + NMSettingsConnection parent; + NMIfcfgConnectionPrivate _priv; }; -/* Signals */ -enum { - IFCFG_CHANGED, - LAST_SIGNAL +struct _NMIfcfgConnectionClass { + NMSettingsConnectionClass parent; }; -static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SETTINGS_CONNECTION) + +#define NM_IFCFG_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMIfcfgConnection, NM_IS_IFCFG_CONNECTION) + +/*****************************************************************************/ static NMInotifyHelper * _get_inotify_helper (NMIfcfgConnectionPrivate *priv) @@ -106,11 +116,12 @@ devtimeout_ready (gpointer user_data) } static void -link_changed (NMPlatform *platform, NMPObjectType obj_type, int ifindex, const NMPlatformLink *link, - NMPlatformSignalChangeType change_type, +link_changed (NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformLink *link, + int change_type_i, NMConnection *self) { - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); + const NMPlatformSignalChangeType change_type = change_type_i; + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) self); const char *ifname; ifname = nm_connection_get_interface_name (self); @@ -186,8 +197,8 @@ 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_CALLBACK (link_changed), self); + 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); } @@ -210,63 +221,6 @@ files_changed_cb (NMInotifyHelper *ih, g_signal_emit (self, signals[IFCFG_CHANGED], 0); } -NMIfcfgConnection * -nm_ifcfg_connection_new (NMConnection *source, - const char *full_path, - GError **error, - gboolean *out_ignore_error) -{ - GObject *object; - NMConnection *tmp; - char *unhandled_spec = NULL; - const char *unmanaged_spec = NULL, *unrecognized_spec = NULL; - gboolean update_unsaved = TRUE; - - g_assert (source || full_path); - - if (out_ignore_error) - *out_ignore_error = FALSE; - - /* If we're given a connection already, prefer that instead of re-reading */ - if (source) - tmp = g_object_ref (source); - else { - tmp = connection_from_file (full_path, - &unhandled_spec, - error, - out_ignore_error); - if (!tmp) - return NULL; - - /* If we just read the connection from disk, it's clearly not Unsaved */ - update_unsaved = FALSE; - } - - if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unmanaged:")) - unmanaged_spec = unhandled_spec + strlen ("unmanaged:"); - else if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unrecognized:")) - unrecognized_spec = unhandled_spec + strlen ("unrecognized:"); - - object = (GObject *) g_object_new (NM_TYPE_IFCFG_CONNECTION, - NM_SETTINGS_CONNECTION_FILENAME, full_path, - NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec, - NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec, - NULL); - /* Update our settings with what was read from the file */ - if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - update_unsaved, - NULL, - error)) - nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object)); - else - g_clear_object (&object); - - g_object_unref (tmp); - g_free (unhandled_spec); - return (NMIfcfgConnection *) object; -} - static void path_watch_stop (NMIfcfgConnection *self) { @@ -381,7 +335,6 @@ commit_changes (NMSettingsConnection *connection, NMSettingsConnectionCommitFunc callback, gpointer user_data) { - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); GError *error = NULL; NMConnection *reread; gboolean same = FALSE, success = FALSE; @@ -415,7 +368,6 @@ commit_changes (NMSettingsConnection *connection, success = writer_update_connection (NM_CONNECTION (connection), IFCFG_DIR, filename, - priv->keyfile, &error); } else { success = writer_new_connection (NM_CONNECTION (connection), @@ -443,7 +395,7 @@ do_delete (NMSettingsConnection *connection, NMSettingsConnectionDeleteFunc callback, gpointer user_data) { - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) connection); const char *filename; filename = nm_settings_connection_get_filename (connection); @@ -460,27 +412,20 @@ do_delete (NMSettingsConnection *connection, NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->delete (connection, callback, user_data); } -/* GObject */ +/*****************************************************************************/ static void -nm_ifcfg_connection_init (NMIfcfgConnection *connection) -{ - g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_FILENAME, - G_CALLBACK (filename_changed), NULL); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object); + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) object); switch (prop_id) { case PROP_UNMANAGED_SPEC: - priv->unmanaged_spec = g_value_dup_string (value); + g_value_set_string (value, priv->unmanaged_spec); break; case PROP_UNRECOGNIZED_SPEC: - priv->unrecognized_spec = g_value_dup_string (value); + g_value_set_string (value, priv->unrecognized_spec); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -489,17 +434,17 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object); + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) object); switch (prop_id) { case PROP_UNMANAGED_SPEC: - g_value_set_string (value, priv->unmanaged_spec); + priv->unmanaged_spec = g_value_dup_string (value); break; case PROP_UNRECOGNIZED_SPEC: - g_value_set_string (value, priv->unrecognized_spec); + priv->unrecognized_spec = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -507,10 +452,76 @@ get_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + +static void +nm_ifcfg_connection_init (NMIfcfgConnection *connection) +{ + g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_FILENAME, + G_CALLBACK (filename_changed), NULL); +} + +NMIfcfgConnection * +nm_ifcfg_connection_new (NMConnection *source, + const char *full_path, + GError **error, + gboolean *out_ignore_error) +{ + GObject *object; + NMConnection *tmp; + char *unhandled_spec = NULL; + const char *unmanaged_spec = NULL, *unrecognized_spec = NULL; + gboolean update_unsaved = TRUE; + + g_assert (source || full_path); + + if (out_ignore_error) + *out_ignore_error = FALSE; + + /* If we're given a connection already, prefer that instead of re-reading */ + if (source) + tmp = g_object_ref (source); + else { + tmp = connection_from_file (full_path, + &unhandled_spec, + error, + out_ignore_error); + if (!tmp) + return NULL; + + /* If we just read the connection from disk, it's clearly not Unsaved */ + update_unsaved = FALSE; + } + + if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unmanaged:")) + unmanaged_spec = unhandled_spec + strlen ("unmanaged:"); + else if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unrecognized:")) + unrecognized_spec = unhandled_spec + strlen ("unrecognized:"); + + object = (GObject *) g_object_new (NM_TYPE_IFCFG_CONNECTION, + NM_SETTINGS_CONNECTION_FILENAME, full_path, + NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec, + NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec, + NULL); + /* Update our settings with what was read from the file */ + if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), + tmp, + update_unsaved, + NULL, + error)) + nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object)); + else + g_clear_object (&object); + + g_object_unref (tmp); + g_free (unhandled_spec); + return (NMIfcfgConnection *) object; +} + static void dispose (GObject *object) { - NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object); + NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) object); path_watch_stop (NM_IFCFG_CONNECTION (object)); @@ -531,36 +542,34 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) GObjectClass *object_class = G_OBJECT_CLASS (ifcfg_connection_class); NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (ifcfg_connection_class); - g_type_class_add_private (ifcfg_connection_class, sizeof (NMIfcfgConnectionPrivate)); - - /* Virtual methods */ object_class->set_property = set_property; object_class->get_property = get_property; object_class->dispose = dispose; + settings_class->delete = do_delete; settings_class->replace_and_commit = replace_and_commit; settings_class->commit_changes = commit_changes; - /* Properties */ - g_object_class_install_property - (object_class, PROP_UNMANAGED_SPEC, - g_param_spec_string (NM_IFCFG_CONNECTION_UNMANAGED_SPEC, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); - g_object_class_install_property - (object_class, PROP_UNRECOGNIZED_SPEC, - g_param_spec_string (NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_UNMANAGED_SPEC] = + g_param_spec_string (NM_IFCFG_CONNECTION_UNMANAGED_SPEC, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_UNRECOGNIZED_SPEC] = + g_param_spec_string (NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[IFCFG_CHANGED] = - g_signal_new ("ifcfg-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + g_signal_new ("ifcfg-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.h index 57db059b..fd68f2d3 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.h @@ -22,7 +22,7 @@ #define __NETWORKMANAGER_IFCFG_CONNECTION_H__ #include "nm-dbus-interface.h" -#include "nm-settings-connection.h" +#include "settings/nm-settings-connection.h" #define NM_TYPE_IFCFG_CONNECTION (nm_ifcfg_connection_get_type ()) #define NM_IFCFG_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnection)) @@ -34,13 +34,8 @@ #define NM_IFCFG_CONNECTION_UNMANAGED_SPEC "unmanaged-spec" #define NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC "unrecognized-spec" -typedef struct { - NMSettingsConnection parent; -} NMIfcfgConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMIfcfgConnectionClass; +typedef struct _NMIfcfgConnection NMIfcfgConnection; +typedef struct _NMIfcfgConnectionClass NMIfcfgConnectionClass; GType nm_ifcfg_connection_get_type (void); diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c index c2956d22..414f593b 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c @@ -23,62 +23,35 @@ #include "nm-default.h" -#include "plugin.h" +#include "nms-ifcfg-rh-plugin.h" #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> - #include <gmodule.h> #include "nm-dbus-compat.h" #include "nm-setting-connection.h" - -#include "nm-settings-plugin.h" +#include "settings/nm-settings-plugin.h" #include "nm-config.h" #include "NetworkManagerUtils.h" +#include "nm-exported-object.h" -#include "nm-ifcfg-connection.h" +#include "nms-ifcfg-rh-connection.h" +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-reader.h" +#include "nms-ifcfg-rh-writer.h" +#include "nms-ifcfg-rh-utils.h" #include "shvar.h" -#include "common.h" -#include "reader.h" -#include "writer.h" -#include "utils.h" -#include "nm-exported-object.h" -#include "nmdbus-ifcfg-rh.h" +#include "settings/plugins/ifcfg-rh/nmdbus-ifcfg-rh.h" #define IFCFGRH1_DBUS_SERVICE_NAME "com.redhat.ifcfgrh1" #define IFCFGRH1_DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1" -#define _NMLOG_DOMAIN LOGD_SETTINGS -#define _NMLOG(level, ...) \ - G_STMT_START { \ - nm_log ((level), (_NMLOG_DOMAIN), \ - "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - "ifcfg-rh: " \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ - } G_STMT_END - - -static NMIfcfgConnection *update_connection (SettingsPluginIfcfg *plugin, - NMConnection *source, - const char *full_path, - NMIfcfgConnection *connection, - gboolean protect_existing_connection, - GHashTable *protected_connections, - GError **error); - -static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); - -G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_interface_init)) - -#define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgPrivate)) - +/*****************************************************************************/ typedef struct { NMConfig *config; @@ -97,9 +70,52 @@ typedef struct { gulong ifcfg_monitor_id; } SettingsPluginIfcfgPrivate; +struct _SettingsPluginIfcfg { + GObject parent; + SettingsPluginIfcfgPrivate _priv; +}; + +struct _SettingsPluginIfcfgClass { + GObjectClass parent; +}; + +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); + +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) + +#define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginIfcfg, SETTINGS_IS_PLUGIN_IFCFG) + +/*****************************************************************************/ + static SettingsPluginIfcfg *settings_plugin_ifcfg_get (void); + NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfcfg, settings_plugin_ifcfg_get, SETTINGS_TYPE_PLUGIN_IFCFG); +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_SETTINGS +#define _NMLOG(level, ...) \ + G_STMT_START { \ + nm_log ((level), (_NMLOG_DOMAIN), \ + "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + "ifcfg-rh: " \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + +/*****************************************************************************/ + +static NMIfcfgConnection *update_connection (SettingsPluginIfcfg *plugin, + NMConnection *source, + const char *full_path, + NMIfcfgConnection *connection, + gboolean protect_existing_connection, + GHashTable *protected_connections, + GError **error); + +/*****************************************************************************/ + static void connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) { @@ -124,7 +140,7 @@ connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } @@ -145,7 +161,7 @@ remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection) g_object_ref (connection); g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection))); if (!unmanaged && !unrecognized) - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection), FALSE); g_object_unref (connection); /* Emit changes _after_ removing the connection */ @@ -314,7 +330,7 @@ update_connection (SettingsPluginIfcfg *self, /* Unexport the connection by telling the settings service it's * been removed. */ - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid)); + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid), TRUE); /* Remove the path so that claim_connection() doesn't complain later when * interface gets managed and connection is re-added. */ nm_connection_set_path (NM_CONNECTION (connection_by_uuid), NULL); @@ -616,7 +632,7 @@ static GSList * get_unhandled_specs (NMSettingsPlugin *config, const char *property) { - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (config); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) config); GSList *list = NULL, *list_iter; GHashTableIter iter; gpointer connection; @@ -944,6 +960,28 @@ config_changed_cb (NMConfig *config, /*****************************************************************************/ static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case NM_SETTINGS_PLUGIN_PROP_NAME: + g_value_set_string (value, IFCFG_PLUGIN_NAME); + break; + case NM_SETTINGS_PLUGIN_PROP_INFO: + g_value_set_string (value, IFCFG_PLUGIN_INFO); + break; + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void init (NMSettingsPlugin *config) { } @@ -951,7 +989,7 @@ init (NMSettingsPlugin *config) static void settings_plugin_ifcfg_init (SettingsPluginIfcfg *plugin) { - SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) plugin); priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); } @@ -1005,47 +1043,13 @@ dispose (GObject *object) } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, IFCFG_PLUGIN_NAME); - break; - case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, IFCFG_PLUGIN_INFO); - break; - case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SettingsPluginIfcfgPrivate)); - object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; - object_class->set_property = set_property; g_object_class_override_property (object_class, NM_SETTINGS_PLUGIN_PROP_NAME, @@ -1063,7 +1067,6 @@ settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class) static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - /* interface implementation */ plugin_iface->get_connections = get_connections; plugin_iface->add_connection = add_connection; plugin_iface->load_connection = load_connection; @@ -1073,6 +1076,8 @@ settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) plugin_iface->init = init; } +/*****************************************************************************/ + G_MODULE_EXPORT GObject * nm_settings_plugin_factory (void) { diff --git a/src/settings/plugins/ifcfg-rh/plugin.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h index 74c4b00a..d815cc51 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h @@ -34,15 +34,6 @@ typedef struct _SettingsPluginIfcfg SettingsPluginIfcfg; typedef struct _SettingsPluginIfcfgClass SettingsPluginIfcfgClass; -struct _SettingsPluginIfcfg { - GObject parent; -}; - -struct _SettingsPluginIfcfgClass { - GObjectClass parent; -}; - GType settings_plugin_ifcfg_get_type (void); #endif /* _PLUGIN_H_ */ - diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 5a351cfa..b64cad35 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -20,7 +20,7 @@ #include "nm-default.h" -#include "reader.h" +#include "nms-ifcfg-rh-reader.h" #include <stdlib.h> #include <string.h> @@ -48,16 +48,17 @@ #include "nm-setting-bridge.h" #include "nm-setting-bridge-port.h" #include "nm-setting-dcb.h" +#include "nm-setting-proxy.h" #include "nm-setting-generic.h" #include "nm-core-internal.h" #include "nm-utils.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "NetworkManagerUtils.h" -#include "common.h" +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-utils.h" #include "shvar.h" -#include "utils.h" /*****************************************************************************/ @@ -96,7 +97,7 @@ make_connection_name (shvarFile *ifcfg, char *full_name = NULL, *name; /* If the ifcfg file already has a NAME, always use that */ - name = svGetValue (ifcfg, "NAME", FALSE); + name = svGetValueString (ifcfg, "NAME"); if (name && strlen (name)) return name; @@ -141,13 +142,13 @@ make_connection_setting (const char *file, g_free (new_id); /* Try for a UUID key before falling back to hashing the file name */ - uuid = svGetValue (ifcfg, "UUID", FALSE); + uuid = svGetValueString (ifcfg, "UUID"); if (!uuid || !strlen (uuid)) { g_free (uuid); - uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); + uuid = nm_utils_uuid_generate_from_string (svFileGetName (ifcfg), -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); } - stable_id = svGetValue (ifcfg, "STABLE_ID", FALSE); + stable_id = svGetValueString (ifcfg, "STABLE_ID"); g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, type, @@ -156,18 +157,22 @@ make_connection_setting (const char *file, NULL); g_free (uuid); - value = svGetValue (ifcfg, "DEVICE", FALSE); + value = svGetValueString (ifcfg, "DEVICE"); if (value) { - if (nm_utils_iface_valid_name (value)) { + GError *error = NULL; + + if (nm_utils_is_valid_iface_name (value, &error)) { g_object_set (s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, value, NULL); - } else - PARSE_WARNING ("invalid DEVICE name '%s'", value); + } else { + PARSE_WARNING ("invalid DEVICE name '%s': %s", value, error->message); + g_error_free (error); + } g_free (value); } - value = svGetValue (ifcfg, "LLDP", FALSE); + value = svGetValueString (ifcfg, "LLDP"); if (!g_strcmp0 (value, "rx")) lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX; else @@ -183,12 +188,15 @@ make_connection_setting (const char *file, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT), + NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, + (gint) svGetValueInt64 (ifcfg, "AUTOCONNECT_RETRIES", 10, + -1, G_MAXINT32, -1), NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, svGetValueBoolean (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), NM_SETTING_CONNECTION_LLDP, lldp, NULL); - value = svGetValue (ifcfg, "USERS", FALSE); + value = svGetValueString (ifcfg, "USERS"); if (value) { char **items, **iter; @@ -204,7 +212,7 @@ make_connection_setting (const char *file, } - zone = svGetValue(ifcfg, "ZONE", FALSE); + zone = svGetValueString (ifcfg, "ZONE"); if (!zone || !strlen (zone)) { g_free (zone); zone = NULL; @@ -212,7 +220,7 @@ make_connection_setting (const char *file, g_object_set (s_con, NM_SETTING_CONNECTION_ZONE, zone, NULL); g_free (zone); - value = svGetValue (ifcfg, "SECONDARY_UUIDS", FALSE); + value = svGetValueString (ifcfg, "SECONDARY_UUIDS"); if (value) { char **items, **iter; @@ -227,7 +235,9 @@ make_connection_setting (const char *file, g_strfreev (items); } - value = svGetValue (ifcfg, "BRIDGE", FALSE); + value = svGetValueString (ifcfg, "BRIDGE_UUID"); + if (!value) + value = svGetValueString (ifcfg, "BRIDGE"); if (value) { const char *old_value; @@ -242,7 +252,7 @@ make_connection_setting (const char *file, g_free (value); } - value = svGetValue (ifcfg, "GATEWAY_PING_TIMEOUT", FALSE); + value = svGetValueString (ifcfg, "GATEWAY_PING_TIMEOUT"); if (value) { gint64 tmp; @@ -282,7 +292,7 @@ read_ip4_address (shvarFile *ifcfg, *out_addr = NULL; - value = svGetValue (ifcfg, tag, FALSE); + value = svGetValueString (ifcfg, tag); if (!value) return TRUE; @@ -317,7 +327,7 @@ is_any_ip4_address_defined (shvarFile *ifcfg, int *idx) char *value; tag = get_numbered_tag ("IPADDR", i); - value = svGetValue (ifcfg, tag, FALSE); + value = svGetValueString (ifcfg, tag); g_free (tag); if (value) { g_free (value); @@ -326,7 +336,7 @@ is_any_ip4_address_defined (shvarFile *ifcfg, int *idx) } tag = get_numbered_tag ("PREFIX", i); - value = svGetValue (ifcfg, tag, FALSE); + value = svGetValueString (ifcfg, tag); g_free(tag); if (value) { g_free (value); @@ -335,7 +345,7 @@ is_any_ip4_address_defined (shvarFile *ifcfg, int *idx) } tag = get_numbered_tag ("NETMASK", i); - value = svGetValue (ifcfg, tag, FALSE); + value = svGetValueString (ifcfg, tag); g_free(tag); if (value) { g_free (value); @@ -392,7 +402,7 @@ read_full_ip4_address (shvarFile *ifcfg, } /* Prefix */ - value = svGetValue (ifcfg, prefix_tag, FALSE); + value = svGetValueString (ifcfg, prefix_tag); if (value) { prefix = _nm_utils_ascii_str_to_int64 (value, 10, 0, 32, -1); if (prefix < 0) { @@ -470,7 +480,7 @@ read_one_ip4_route (shvarFile *ifcfg, if (!dest) { /* Check whether IP is missing or 0.0.0.0 */ char *val; - val = svGetValue (ifcfg, ip_tag, FALSE); + val = svGetValueString (ifcfg, ip_tag); if (!val) { *out_route = NULL; success = TRUE; /* missing route = success */ @@ -505,7 +515,7 @@ read_one_ip4_route (shvarFile *ifcfg, } /* Metric */ - value = svGetValue (ifcfg, metric_tag, FALSE); + value = svGetValueString (ifcfg, metric_tag); if (value) { metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1); if (metric < 0) { @@ -674,7 +684,7 @@ error: } static void -parse_dns_options (NMSettingIPConfig *ip_config, char *value) +parse_dns_options (NMSettingIPConfig *ip_config, const char *value) { char **options = NULL; @@ -899,6 +909,62 @@ error: return success; } +static NMSetting * +make_proxy_setting (shvarFile *ifcfg, GError **error) +{ + NMSettingProxy *s_proxy = NULL; + char *value = NULL; + NMSettingProxyMethod method; + + value = svGetValueString (ifcfg, "PROXY_METHOD"); + if (!value) + return NULL; + + if (!g_ascii_strcasecmp (value, "auto")) + method = NM_SETTING_PROXY_METHOD_AUTO; + else + method = NM_SETTING_PROXY_METHOD_NONE; + g_free (value); + + s_proxy = (NMSettingProxy *) nm_setting_proxy_new (); + + switch (method) { + case NM_SETTING_PROXY_METHOD_AUTO: + g_object_set (s_proxy, + NM_SETTING_PROXY_METHOD, (int) NM_SETTING_PROXY_METHOD_AUTO, + NULL); + + value = svGetValueString (ifcfg, "PAC_URL"); + if (value) { + value = g_strstrip (value); + g_object_set (s_proxy, NM_SETTING_PROXY_PAC_URL, value, NULL); + g_free (value); + } + + value = svGetValueString (ifcfg, "PAC_SCRIPT"); + if (value) { + value = g_strstrip (value); + g_object_set (s_proxy, NM_SETTING_PROXY_PAC_SCRIPT, value, NULL); + g_free (value); + } + + break; + case NM_SETTING_PROXY_METHOD_NONE: + g_object_set (s_proxy, + NM_SETTING_PROXY_METHOD, (int) NM_SETTING_PROXY_METHOD_NONE, + NULL); + break; + } + + value = svGetValueString (ifcfg, "BROWSER_ONLY"); + if (value) { + if (!g_ascii_strcasecmp (value, "yes")) + g_object_set (s_proxy, NM_SETTING_PROXY_BROWSER_ONLY, TRUE, NULL); + g_free (value); + } + + return NM_SETTING (s_proxy); +} static NMSetting * make_ip4_setting (shvarFile *ifcfg, @@ -909,7 +975,8 @@ make_ip4_setting (shvarFile *ifcfg, char *value = NULL; char *route_path = NULL; char *method; - char *dns_options = NULL; + gs_free char *dns_options_free = NULL; + const char *dns_options = NULL; gs_free char *gateway = NULL; gint32 i; shvarFile *network_ifcfg; @@ -933,9 +1000,9 @@ make_ip4_setting (shvarFile *ifcfg, char *gatewaydev; /* Get the connection ifcfg device name and the global gateway device */ - value = svGetValue (ifcfg, "DEVICE", FALSE); - gatewaydev = svGetValue (network_ifcfg, "GATEWAYDEV", FALSE); - dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE); + value = svGetValueString (ifcfg, "DEVICE"); + gatewaydev = svGetValueString (network_ifcfg, "GATEWAYDEV"); + dns_options = svGetValue (network_ifcfg, "RES_OPTIONS", &dns_options_free); /* If there was a global gateway device specified, then only connections * for that device can be the default connection. @@ -948,7 +1015,7 @@ make_ip4_setting (shvarFile *ifcfg, svCloseFile (network_ifcfg); } - value = svGetValue (ifcfg, "BOOTPROTO", FALSE); + value = svGetValueString (ifcfg, "BOOTPROTO"); if (!value || !*value || !g_ascii_strcasecmp (value, "none")) { if (is_any_ip4_address_defined (ifcfg, NULL)) @@ -1009,31 +1076,29 @@ make_ip4_setting (shvarFile *ifcfg, return NM_SETTING (s_ip4); /* Handle DHCP settings */ - if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); - if (value && *value) - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); - g_free (value); - - value = svGetValue (ifcfg, "DHCP_FQDN", FALSE); - if (value && *value) { - g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NULL, - NM_SETTING_IP4_CONFIG_DHCP_FQDN, value, - NULL); - } - g_free (value); + value = svGetValueString (ifcfg, "DHCP_HOSTNAME"); + if (value && *value) + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); + g_free (value); + value = svGetValueString (ifcfg, "DHCP_FQDN"); + if (value && *value) { g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), - NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXINT32, 0), - NULL); - - value = svGetValue (ifcfg, "DHCP_CLIENT_ID", FALSE); - if (value && strlen (value)) - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, value, NULL); - g_free (value); + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NULL, + NM_SETTING_IP4_CONFIG_DHCP_FQDN, value, + NULL); } + g_free (value); + + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), + NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXINT32, 0), + NULL); + + value = svGetValueString (ifcfg, "DHCP_CLIENT_ID"); + if (value && strlen (value)) + g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, value, NULL); + g_free (value); /* Read static IP addresses. * Read them even for AUTO method - in this case the addresses are @@ -1073,7 +1138,7 @@ make_ip4_setting (shvarFile *ifcfg, goto done; if (gateway && nm_setting_ip_config_get_num_addresses (s_ip4) == 0) { - gs_free char *f = g_path_get_basename (ifcfg->fileName); + gs_free char *f = g_path_get_basename (svFileGetName (ifcfg)); PARSE_WARNING ("ignoring GATEWAY (/etc/sysconfig/network) for %s " "because the connection has no static addresses", f); g_clear_pointer (&gateway, g_free); @@ -1092,7 +1157,7 @@ make_ip4_setting (shvarFile *ifcfg, char *tag; tag = g_strdup_printf ("DNS%u", i); - value = svGetValue (ifcfg, tag, FALSE); + value = svGetValueString (ifcfg, tag); if (value) { if (nm_utils_ipaddr_valid (AF_INET, value)) { if (!nm_setting_ip_config_add_dns (s_ip4, value)) @@ -1113,7 +1178,7 @@ make_ip4_setting (shvarFile *ifcfg, } /* DNS searches */ - value = svGetValue (ifcfg, "DOMAIN", FALSE); + value = svGetValueString (ifcfg, "DOMAIN"); if (value) { char **searches = NULL; @@ -1132,12 +1197,9 @@ make_ip4_setting (shvarFile *ifcfg, } /* DNS options */ - value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE); - parse_dns_options (s_ip4, value); + parse_dns_options (s_ip4, svGetValue (ifcfg, "RES_OPTIONS", &value)); parse_dns_options (s_ip4, dns_options); g_free (value); - g_free (dns_options); - dns_options = NULL; /* DNS priority */ priority = svGetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0); @@ -1147,13 +1209,13 @@ make_ip4_setting (shvarFile *ifcfg, NULL); /* Static routes - route-<name> file */ - route_path = utils_get_route_path (ifcfg->fileName); + route_path = utils_get_route_path (svFileGetName (ifcfg)); if (utils_has_complex_routes (route_path)) { PARSE_WARNING ("'rule-' or 'rule6-' file is present; you will need to use a dispatcher script to apply these routes"); } else if (utils_has_route_file_new_syntax (route_path)) { /* Parse route file in new syntax */ - route_ifcfg = utils_get_route_ifcfg (ifcfg->fileName, FALSE); + route_ifcfg = utils_get_route_ifcfg (svFileGetName (ifcfg), FALSE); if (route_ifcfg) { for (i = 0; i < 256; i++) { NMIPRoute *route = NULL; @@ -1180,7 +1242,7 @@ make_ip4_setting (shvarFile *ifcfg, /* Legacy value NM used for a while but is incorrect (rh #459370) */ if (!nm_setting_ip_config_get_num_dns_searches (s_ip4)) { - value = svGetValue (ifcfg, "SEARCH", FALSE); + value = svGetValueString (ifcfg, "SEARCH"); if (value) { char **searches = NULL; @@ -1207,7 +1269,6 @@ 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; @@ -1268,7 +1329,7 @@ read_aliases (NMSettingIPConfig *s_ip4, const char *filename) continue; } - device = svGetValue (parsed, "DEVICE", FALSE); + device = svGetValueString (parsed, "DEVICE"); if (!device) { PARSE_WARNING ("alias file '%s' has no DEVICE", full_path); svCloseFile (parsed); @@ -1322,8 +1383,9 @@ 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; + gs_free char *dns_options_free = NULL; + const char *dns_options = NULL; + gboolean ipv6init, ipv6forwarding, dhcp6 = FALSE; char *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; char *ipv6addr, *ipv6addr_secondaries; char **list = NULL, **iter; @@ -1334,7 +1396,6 @@ make_ip6_setting (shvarFile *ifcfg, gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip; NMSettingIP6ConfigPrivacy ip6_privacy_val; NMSettingIP6ConfigAddrGenMode addr_gen_mode; - char *tmp; s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); @@ -1355,10 +1416,10 @@ make_ip6_setting (shvarFile *ifcfg, char *default_dev = NULL; /* Get the connection ifcfg device name and the global default route device */ - value = svGetValue (ifcfg, "DEVICE", FALSE); - ipv6_defaultgw = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); - ipv6_defaultdev = svGetValue (network_ifcfg, "IPV6_DEFAULTDEV", FALSE); - dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE); + value = svGetValueString (ifcfg, "DEVICE"); + ipv6_defaultgw = svGetValueString (network_ifcfg, "IPV6_DEFAULTGW"); + ipv6_defaultdev = svGetValueString (network_ifcfg, "IPV6_DEFAULTDEV"); + dns_options = svGetValue (network_ifcfg, "RES_OPTIONS", &dns_options_free); if (ipv6_defaultgw) { default_dev = strchr (ipv6_defaultgw, '%'); @@ -1382,7 +1443,7 @@ 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); + str_value = svGetValueString (ifcfg, "IPV6INIT"); ipv6init = svGetValueBoolean (ifcfg, "IPV6INIT", FALSE); if (!str_value) { network_ifcfg = svOpenFile (network_file, NULL); @@ -1397,41 +1458,44 @@ make_ip6_setting (shvarFile *ifcfg, method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; /* IPv6 is disabled */ else { ipv6forwarding = svGetValueBoolean (ifcfg, "IPV6FORWARDING", FALSE); - ipv6_autoconf = svGetValueBoolean (ifcfg, "IPV6_AUTOCONF", !ipv6forwarding); + str_value = svGetValueString (ifcfg, "IPV6_AUTOCONF"); dhcp6 = svGetValueBoolean (ifcfg, "DHCPV6C", FALSE); - if (ipv6_autoconf) + if (!g_strcmp0 (str_value, "shared")) + method = NM_SETTING_IP6_CONFIG_METHOD_SHARED; + else if (svParseBoolean (str_value, !ipv6forwarding)) method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; else if (dhcp6) method = NM_SETTING_IP6_CONFIG_METHOD_DHCP; else { /* IPV6_AUTOCONF=no and no IPv6 address -> method 'link-local' */ - str_value = svGetValue (ifcfg, "IPV6ADDR", FALSE); + g_free (str_value); + str_value = svGetValueString (ifcfg, "IPV6ADDR"); if (!str_value) - str_value = svGetValue (ifcfg, "IPV6ADDR_SECONDARIES", FALSE); + str_value = svGetValueString (ifcfg, "IPV6ADDR_SECONDARIES"); if (!str_value) method = NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL; - g_free (str_value); } + g_free (str_value); } /* TODO - handle other methods */ /* Read IPv6 Privacy Extensions configuration */ - tmp = svGetValue (ifcfg, "IPV6_PRIVACY", FALSE); - if (tmp) { - ip6_privacy = svGetValueBoolean (ifcfg, "IPV6_PRIVACY", FALSE); + str_value = svGetValueString (ifcfg, "IPV6_PRIVACY"); + if (str_value) { + ip6_privacy = svParseBoolean (str_value, FALSE); if (!ip6_privacy) - ip6_privacy = g_strcmp0 (tmp, "rfc4941") == 0 || - g_strcmp0 (tmp, "rfc3041") == 0; + ip6_privacy = (g_strcmp0 (str_value, "rfc4941") == 0) || + (g_strcmp0 (str_value, "rfc3041") == 0); } ip6_privacy_prefer_public_ip = svGetValueBoolean (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", FALSE); - ip6_privacy_val = tmp ? + ip6_privacy_val = str_value ? (ip6_privacy ? (ip6_privacy_prefer_public_ip ? NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR : NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) : NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED) : NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; - g_free (tmp); + g_free (str_value); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, method, @@ -1448,22 +1512,30 @@ make_ip6_setting (shvarFile *ifcfg, if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) return NM_SETTING (s_ip6); - if ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) - || !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { - /* METHOD_AUTO may trigger DHCPv6, so save the hostname to send to DHCP */ - value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); - if (value && value[0]) - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); - g_free (value); - } + value = svGetValueString (ifcfg, "DHCPV6_HOSTNAME"); + /* Use DHCP_HOSTNAME as fallback if it is in FQDN format and ipv6.method is + * auto or dhcp: this is required to support old ifcfg files + */ + if (!value && ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) + || !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP))) { + value = svGetValueString (ifcfg, "DHCP_HOSTNAME"); + if (value && !strchr (value, '.')) + g_clear_pointer (&value, g_free); + } + if (value) + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); + g_free (value); + + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, + svGetValueBoolean (ifcfg, "DHCPV6_SEND_HOSTNAME", TRUE), NULL); /* Read static IP addresses. * Read them even for AUTO and DHCP methods - in this case the addresses are * added to the automatic ones. Note that this is not currently supported by * the legacy 'network' service (ifup-eth). */ - ipv6addr = svGetValue (ifcfg, "IPV6ADDR", FALSE); - ipv6addr_secondaries = svGetValue (ifcfg, "IPV6ADDR_SECONDARIES", FALSE); + ipv6addr = svGetValueString (ifcfg, "IPV6ADDR"); + ipv6addr_secondaries = svGetValueString (ifcfg, "IPV6ADDR_SECONDARIES"); value = g_strjoin (ipv6addr && ipv6addr_secondaries ? " " : NULL, ipv6addr ? ipv6addr : "", @@ -1490,12 +1562,12 @@ make_ip6_setting (shvarFile *ifcfg, /* Gateway */ if (nm_setting_ip_config_get_num_addresses (s_ip6)) { - value = svGetValue (ifcfg, "IPV6_DEFAULTGW", FALSE); + value = svGetValueString (ifcfg, "IPV6_DEFAULTGW"); if (!value) { /* If no gateway in the ifcfg, try global /etc/sysconfig/network instead */ network_ifcfg = svOpenFile (network_file, NULL); if (network_ifcfg) { - value = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); + value = svGetValueString (network_ifcfg, "IPV6_DEFAULTGW"); svCloseFile (network_ifcfg); } } @@ -1516,14 +1588,14 @@ 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, + str_value = svGetValueString (ifcfg, "IPV6_ADDR_GEN_MODE"); + if (str_value) { + if (nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), str_value, (int *) &addr_gen_mode, NULL)) g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, addr_gen_mode, NULL); else PARSE_WARNING ("Invalid IPV6_ADDR_GEN_MODE"); - g_free (tmp); + g_free (str_value); } else { g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, @@ -1532,10 +1604,10 @@ make_ip6_setting (shvarFile *ifcfg, } /* IPv6 tokenized interface identifier */ - tmp = svGetValue (ifcfg, "IPV6_TOKEN", FALSE); - if (tmp) { - g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, tmp, NULL); - g_free (tmp); + str_value = svGetValueString (ifcfg, "IPV6_TOKEN"); + if (str_value) { + g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, str_value, NULL); + g_free (str_value); } /* DNS servers @@ -1545,7 +1617,7 @@ make_ip6_setting (shvarFile *ifcfg, char *tag; tag = g_strdup_printf ("DNS%u", i); - value = svGetValue (ifcfg, tag, FALSE); + value = svGetValueString (ifcfg, tag); if (!value) { g_free (tag); break; /* all done */ @@ -1569,9 +1641,9 @@ make_ip6_setting (shvarFile *ifcfg, /* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */ - if (!utils_has_complex_routes (ifcfg->fileName)) { + if (!utils_has_complex_routes (svFileGetName (ifcfg))) { /* Read static routes from route6-<interface> file */ - route6_path = utils_get_route6_path (ifcfg->fileName); + route6_path = utils_get_route6_path (svFileGetName (ifcfg)); if (!read_route6_file (route6_path, s_ip6, error)) goto error; @@ -1579,11 +1651,9 @@ make_ip6_setting (shvarFile *ifcfg, } /* DNS options */ - value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE); - parse_dns_options (s_ip6, value); + parse_dns_options (s_ip6, svGetValue (ifcfg, "RES_OPTIONS", &value)); parse_dns_options (s_ip6, dns_options); g_free (value); - g_free (dns_options); /* DNS priority */ priority = svGetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0); @@ -1595,7 +1665,6 @@ make_ip6_setting (shvarFile *ifcfg, return NM_SETTING (s_ip6); error: - g_free (dns_options); g_free (route6_path); g_object_unref (s_ip6); return NULL; @@ -1607,7 +1676,10 @@ check_if_bond_slave (shvarFile *ifcfg, { char *value; - value = svGetValue (ifcfg, "MASTER", FALSE); + value = svGetValueString (ifcfg, "MASTER_UUID"); + if (!value) + value = svGetValueString (ifcfg, "MASTER"); + if (value) { g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); g_object_set (s_con, @@ -1627,9 +1699,12 @@ check_if_team_slave (shvarFile *ifcfg, { gs_free char *value = NULL; - value = svGetValue (ifcfg, "TEAM_MASTER", FALSE); + value = svGetValueString (ifcfg, "TEAM_MASTER_UUID"); + if (!value) + value = svGetValueString (ifcfg, "TEAM_MASTER"); if (!value) return FALSE; + g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); return TRUE; @@ -1702,7 +1777,7 @@ read_dcb_app (shvarFile *ifcfg, /* Priority */ tmp = g_strdup_printf ("DCB_APP_%s_PRIORITY", app); - val = svGetValue (ifcfg, tmp, FALSE); + val = svGetValueString (ifcfg, tmp); if (val) { priority = _nm_utils_ascii_str_to_int64 (val, 0, 0, 7, -1); if (priority < 0) { @@ -1743,7 +1818,7 @@ read_dcb_bool_array (shvarFile *ifcfg, gboolean success = FALSE; guint i; - val = svGetValue (ifcfg, prop, FALSE); + val = svGetValueString (ifcfg, prop); if (!val) return TRUE; @@ -1794,7 +1869,7 @@ read_dcb_uint_array (shvarFile *ifcfg, gboolean success = FALSE; guint i; - val = svGetValue (ifcfg, prop, FALSE); + val = svGetValueString (ifcfg, prop); if (!val) return TRUE; @@ -1848,7 +1923,7 @@ read_dcb_percent_array (shvarFile *ifcfg, char **split = NULL, **iter; guint i, sum = 0; - val = svGetValue (ifcfg, prop, FALSE); + val = svGetValueString (ifcfg, prop); if (!val) return TRUE; @@ -1926,7 +2001,7 @@ make_dcb_setting (shvarFile *ifcfg, return FALSE; } if (nm_setting_dcb_get_app_fcoe_flags (s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) { - val = svGetValue (ifcfg, KEY_DCB_APP_FCOE_MODE, FALSE); + val = svGetValueString (ifcfg, KEY_DCB_APP_FCOE_MODE); if (val) { if (strcmp (val, NM_SETTING_DCB_FCOE_MODE_FABRIC) == 0 || strcmp (val, NM_SETTING_DCB_FCOE_MODE_VN2VN) == 0) @@ -2063,7 +2138,7 @@ add_one_wep_key (shvarFile *ifcfg, g_return_val_if_fail (key_idx <= 3, FALSE); g_return_val_if_fail (s_wsec != NULL, FALSE); - value = svGetValue (ifcfg, shvar_key, FALSE); + value = svGetValueString (ifcfg, shvar_key); if (!value || !strlen (value)) { g_free (value); return TRUE; @@ -2170,7 +2245,7 @@ read_secret_flags (shvarFile *ifcfg, const char *flags_key) g_return_val_if_fail (flags_key[0] != '\0', NM_SETTING_SECRET_FLAG_NONE); g_return_val_if_fail (g_str_has_suffix (flags_key, "_FLAGS"), NM_SETTING_SECRET_FLAG_NONE); - val = svGetValue (ifcfg, flags_key, FALSE); + val = svGetValueString (ifcfg, flags_key); if (val) { if (strstr (val, SECRET_FLAG_AGENT)) flags |= NM_SETTING_SECRET_FLAG_AGENT_OWNED; @@ -2199,7 +2274,7 @@ make_wep_setting (shvarFile *ifcfg, s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NULL); - value = svGetValue (ifcfg, "DEFAULTKEY", FALSE); + value = svGetValueString (ifcfg, "DEFAULTKEY"); if (value) { default_key_idx = _nm_utils_ascii_str_to_int64 (value, 0, 1, 4, 0); if (default_key_idx == 0) { @@ -2235,7 +2310,7 @@ make_wep_setting (shvarFile *ifcfg, } } - value = svGetValue (ifcfg, "SECURITYMODE", FALSE); + value = svGetValueString (ifcfg, "SECURITYMODE"); if (value) { char *lcase; @@ -2298,16 +2373,10 @@ fill_wpa_ciphers (shvarFile *ifcfg, char **list = NULL, **iter; int i = 0; - p = value = svGetValue (ifcfg, group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", TRUE); + p = value = svGetValueString (ifcfg, group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE"); if (!value) return TRUE; - /* Strip quotes */ - if (p[0] == '"') - p++; - if (p[strlen (p) - 1] == '"') - p[strlen (p) - 1] = '\0'; - list = g_strsplit_set (p, " ", 0); for (iter = list; iter && *iter; iter++, i++) { /* Ad-Hoc configurations cannot have pairwise ciphers, and can only @@ -2362,9 +2431,8 @@ parse_wpa_psk (shvarFile *ifcfg, GError **error) { shvarFile *keys_ifcfg; - char *psk = NULL, *p, *hashed = NULL; + gs_free char *psk = NULL; size_t plen; - gboolean quoted = FALSE; /* Passphrase must be between 10 and 66 characters in length because WPA * hex keys are exactly 64 characters (no quoting), and WPA passphrases @@ -2375,64 +2443,36 @@ parse_wpa_psk (shvarFile *ifcfg, /* Try to get keys from the "shadow" key file */ keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); if (keys_ifcfg) { - psk = svGetValue (keys_ifcfg, "WPA_PSK", TRUE); + psk = svGetValueString (keys_ifcfg, "WPA_PSK"); svCloseFile (keys_ifcfg); } /* Fall back to the original ifcfg */ if (!psk) - psk = svGetValue (ifcfg, "WPA_PSK", TRUE); + psk = svGetValueString (ifcfg, "WPA_PSK"); if (!psk) return NULL; - p = psk; - plen = strlen (p); - - if ( (plen >= 2 && (p[0] == '"' || p[0] == '\'') && p[0] == p[plen - 1]) - || (plen >= 3 && p[0] == '$' && p[1] == '\'' && p[1] == p[plen - 1])) - quoted = TRUE; + plen = strlen (psk); - if (!quoted && (strlen (psk) == 64)) { + if (plen == 64) { /* Verify the hex PSK; 64 digits */ - while (*p) { - if (!g_ascii_isxdigit (*p++)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (contains non-hexadecimal characters)"); - goto out; - } + if (!NM_STRCHAR_ALL (psk, ch, g_ascii_isxdigit (ch))) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WPA_PSK (contains non-hexadecimal characters)"); + return NULL; } - hashed = g_strdup (psk); } else { - /* Prior to 4f6eef9e77265484555663cf666cde4fa8323469 and - * 28e2e446868b94b92edc4a82aa0bf1e3eda8ec54 the writer may not have - * properly quoted passphrases, so just handle anything that's unquoted - * and between 8 and 63 characters as a passphrase. - */ - - /* Get rid of the quotes */ - hashed = utils_single_unquote_string (p); - - /* Length check */ - if (strlen (hashed) < 8 || strlen (hashed) > 63) { + if (plen < 8 || plen > 63) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (passphrases must be between " "8 and 63 characters long (inclusive))"); - g_free (hashed); - hashed = NULL; - goto out; + return NULL; } } - if (!hashed) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid WPA_PSK (doesn't look like a passphrase or hex key)"); - goto out; - } - -out: - g_free (psk); - return hashed; + return g_steal_pointer (&psk); } static gboolean @@ -2446,7 +2486,7 @@ eap_simple_reader (const char *eap_method, NMSettingSecretFlags flags; char *value; - value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_IDENTITY"); if (!value) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", @@ -2461,10 +2501,10 @@ eap_simple_reader (const char *eap_method, /* Only read the password if it's system-owned */ if (flags == NM_SETTING_SECRET_FLAG_NONE) { - value = svGetValue (ifcfg, "IEEE_8021X_PASSWORD", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_PASSWORD"); if (!value && keys) { /* Try the lookaside keys file */ - value = svGetValue (keys, "IEEE_8021X_PASSWORD", FALSE); + value = svGetValueString (keys, "IEEE_8021X_PASSWORD"); } if (!value) { @@ -2527,19 +2567,15 @@ eap_tls_reader (const char *eap_method, const char *pk_pw_flags_prop = phase2 ? NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS : NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS; NMSettingSecretFlags flags; - value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); - if (!value) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", - eap_method); - return FALSE; + value = svGetValueString (ifcfg, "IEEE_8021X_IDENTITY"); + if (value) { + g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); + g_free (value); } - g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, value, NULL); - g_free (value); - ca_cert = svGetValue (ifcfg, ca_cert_key, FALSE); + ca_cert = svGetValueString (ifcfg, ca_cert_key); if (ca_cert) { - real_path = get_full_file_path (ifcfg->fileName, ca_cert); + real_path = get_full_file_path (svFileGetName (ifcfg), ca_cert); if (phase2) { if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, real_path, @@ -2569,10 +2605,10 @@ eap_tls_reader (const char *eap_method, /* Read the private key password if it's system-owned */ if (flags == NM_SETTING_SECRET_FLAG_NONE) { /* Private key password */ - privkey_password = svGetValue (ifcfg, pk_pw_key, FALSE); + privkey_password = svGetValueString (ifcfg, pk_pw_key); if (!privkey_password && keys) { /* Try the lookaside keys file */ - privkey_password = svGetValue (keys, pk_pw_key, FALSE); + privkey_password = svGetValueString (keys, pk_pw_key); } if (!privkey_password) { @@ -2585,7 +2621,7 @@ eap_tls_reader (const char *eap_method, } /* The private key itself */ - privkey = svGetValue (ifcfg, pk_key, FALSE); + privkey = svGetValueString (ifcfg, pk_key); if (!privkey) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", @@ -2594,7 +2630,7 @@ eap_tls_reader (const char *eap_method, goto done; } - real_path = get_full_file_path (ifcfg->fileName, privkey); + real_path = get_full_file_path (svFileGetName (ifcfg), privkey); if (phase2) { if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, real_path, @@ -2622,7 +2658,7 @@ eap_tls_reader (const char *eap_method, */ if ( privkey_format == NM_SETTING_802_1X_CK_FORMAT_RAW_KEY || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { - client_cert = svGetValue (ifcfg, cli_cert_key, FALSE); + client_cert = svGetValueString (ifcfg, cli_cert_key); if (!client_cert) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", @@ -2631,7 +2667,7 @@ eap_tls_reader (const char *eap_method, goto done; } - real_path = get_full_file_path (ifcfg->fileName, client_cert); + real_path = get_full_file_path (svFileGetName (ifcfg), client_cert); if (phase2) { if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, real_path, @@ -2679,9 +2715,9 @@ eap_peap_reader (const char *eap_method, char **list = NULL, **iter; gboolean success = FALSE; - ca_cert = svGetValue (ifcfg, "IEEE_8021X_CA_CERT", FALSE); + ca_cert = svGetValueString (ifcfg, "IEEE_8021X_CA_CERT"); if (ca_cert) { - real_cert_path = get_full_file_path (ifcfg->fileName, ca_cert); + real_cert_path = get_full_file_path (svFileGetName (ifcfg), ca_cert); if (!nm_setting_802_1x_set_ca_cert (s_8021x, real_cert_path, NM_SETTING_802_1X_CK_SCHEME_PATH, @@ -2693,7 +2729,7 @@ eap_peap_reader (const char *eap_method, eap_method); } - peapver = svGetValue (ifcfg, "IEEE_8021X_PEAP_VERSION", FALSE); + peapver = svGetValueString (ifcfg, "IEEE_8021X_PEAP_VERSION"); if (peapver) { if (!strcmp (peapver, "0")) g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "0", NULL); @@ -2710,11 +2746,11 @@ eap_peap_reader (const char *eap_method, 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); + anon_ident = svGetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY"); if (anon_ident && strlen (anon_ident)) g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); - inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); + inner_auth = svGetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); if (!inner_auth) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); @@ -2783,9 +2819,9 @@ eap_ttls_reader (const char *eap_method, char *tmp; char **list = NULL, **iter; - ca_cert = svGetValue (ifcfg, "IEEE_8021X_CA_CERT", FALSE); + ca_cert = svGetValueString (ifcfg, "IEEE_8021X_CA_CERT"); if (ca_cert) { - real_cert_path = get_full_file_path (ifcfg->fileName, ca_cert); + real_cert_path = get_full_file_path (svFileGetName (ifcfg), ca_cert); if (!nm_setting_802_1x_set_ca_cert (s_8021x, real_cert_path, NM_SETTING_802_1X_CK_SCHEME_PATH, @@ -2797,11 +2833,11 @@ eap_ttls_reader (const char *eap_method, eap_method); } - anon_ident = svGetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", FALSE); + anon_ident = svGetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY"); if (anon_ident && strlen (anon_ident)) g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); - tmp = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); + tmp = svGetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); if (!tmp) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); @@ -2874,13 +2910,13 @@ eap_fast_reader (const char *eap_method, gboolean allow_unauth = FALSE, allow_auth = FALSE; gboolean success = FALSE; - pac_file = svGetValue (ifcfg, "IEEE_8021X_PAC_FILE", FALSE); + pac_file = svGetValueString (ifcfg, "IEEE_8021X_PAC_FILE"); if (pac_file) { - real_pac_path = get_full_file_path (ifcfg->fileName, pac_file); + real_pac_path = get_full_file_path (svFileGetName (ifcfg), pac_file); g_object_set (s_8021x, NM_SETTING_802_1X_PAC_FILE, real_pac_path, NULL); } - fast_provisioning = svGetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", FALSE); + fast_provisioning = svGetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING"); if (fast_provisioning) { list = g_strsplit_set (fast_provisioning, " \t", 0); for (iter = list; iter && *iter; iter++) { @@ -2908,11 +2944,11 @@ eap_fast_reader (const char *eap_method, goto done; } - anon_ident = svGetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", FALSE); + anon_ident = svGetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY"); if (anon_ident && strlen (anon_ident)) g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, anon_ident, NULL); - inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); + inner_auth = svGetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); if (!inner_auth) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); @@ -2999,7 +3035,7 @@ read_8021x_list_value (shvarFile *ifcfg, g_return_if_fail (ifcfg_var_name != NULL); g_return_if_fail (prop_name != NULL); - value = svGetValue (ifcfg, ifcfg_var_name, FALSE); + value = svGetValueString (ifcfg, ifcfg_var_name); if (!value) return; @@ -3022,7 +3058,7 @@ fill_8021x (shvarFile *ifcfg, char *value; char **list = NULL, **iter; - value = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_EAP_METHODS"); if (!value) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_EAP_METHODS for key management '%s'", @@ -3083,11 +3119,11 @@ fill_8021x (shvarFile *ifcfg, goto error; } - value = svGetValue (ifcfg, "IEEE_8021X_SUBJECT_MATCH", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_SUBJECT_MATCH"); g_object_set (s_8021x, NM_SETTING_802_1X_SUBJECT_MATCH, value, NULL); g_free (value); - value = svGetValue (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH"); g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, value, NULL); g_free (value); @@ -3096,10 +3132,10 @@ fill_8021x (shvarFile *ifcfg, read_8021x_list_value (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", s_8021x, NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES); - value = svGetValue (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH"); g_object_set (s_8021x, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, value, NULL); g_free (value); - value = svGetValue (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH"); g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, value, NULL); g_free (value); @@ -3132,7 +3168,7 @@ make_wpa_setting (shvarFile *ifcfg, wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - value = svGetValue (ifcfg, "KEY_MGMT", FALSE); + value = svGetValueString (ifcfg, "KEY_MGMT"); wpa_psk = !g_strcmp0 (value, "WPA-PSK"); wpa_eap = !g_strcmp0 (value, "WPA-EAP"); ieee8021x = !g_strcmp0 (value, "IEEE8021X"); @@ -3152,8 +3188,8 @@ make_wpa_setting (shvarFile *ifcfg, } else { char *allow_wpa, *allow_rsn; - allow_wpa = svGetValue (ifcfg, "WPA_ALLOW_WPA", FALSE); - allow_rsn = svGetValue (ifcfg, "WPA_ALLOW_WPA2", FALSE); + allow_wpa = svGetValueString (ifcfg, "WPA_ALLOW_WPA"); + allow_rsn = svGetValueString (ifcfg, "WPA_ALLOW_WPA2"); if (allow_wpa && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA", TRUE)) nm_setting_wireless_security_add_proto (wsec, "wpa"); @@ -3207,7 +3243,7 @@ make_wpa_setting (shvarFile *ifcfg, g_free (value); - value = svGetValue (ifcfg, "SECURITYMODE", FALSE); + value = svGetValueString (ifcfg, "SECURITYMODE"); if (NM_IN_STRSET (value, NULL, "open")) g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, value, NULL); @@ -3233,12 +3269,12 @@ make_leap_setting (shvarFile *ifcfg, wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); - value = svGetValue (ifcfg, "KEY_MGMT", FALSE); + value = svGetValueString (ifcfg, "KEY_MGMT"); if (!value || strcmp (value, "IEEE8021X")) goto error; /* Not LEAP */ g_free (value); - value = svGetValue (ifcfg, "SECURITYMODE", FALSE); + value = svGetValueString (ifcfg, "SECURITYMODE"); if (!value || strcasecmp (value, "leap")) goto error; /* Not LEAP */ @@ -3249,12 +3285,12 @@ make_leap_setting (shvarFile *ifcfg, /* Read LEAP password if it's system-owned */ if (flags == NM_SETTING_SECRET_FLAG_NONE) { - value = svGetValue (ifcfg, "IEEE_8021X_PASSWORD", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_PASSWORD"); if (!value) { /* Try to get keys from the "shadow" key file */ keys_ifcfg = utils_get_keys_ifcfg (file, FALSE); if (keys_ifcfg) { - value = svGetValue (keys_ifcfg, "IEEE_8021X_PASSWORD", FALSE); + value = svGetValueString (keys_ifcfg, "IEEE_8021X_PASSWORD"); svCloseFile (keys_ifcfg); } } @@ -3263,7 +3299,7 @@ make_leap_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); + value = svGetValueString (ifcfg, "IEEE_8021X_IDENTITY"); if (!value || !strlen (value)) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing LEAP identity"); @@ -3348,6 +3384,7 @@ make_wireless_setting (shvarFile *ifcfg, GError **error) { NMSettingWireless *s_wireless; + const char *cvalue; char *value = NULL; gint64 chan = 0; NMSettingMacRandomization mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; @@ -3355,25 +3392,25 @@ make_wireless_setting (shvarFile *ifcfg, s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); - value = svGetValue (ifcfg, "HWADDR", FALSE); + value = svGetValueString (ifcfg, "HWADDR"); if (value) { value = g_strstrip (value); g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS, value, NULL); g_free (value); } - value = svGetValue (ifcfg, "MACADDR", FALSE); + value = svGetValueString (ifcfg, "MACADDR"); if (value) { value = g_strstrip (value); g_object_set (s_wireless, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, value, NULL); g_free (value); } - value = svGetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", FALSE); + value = svGetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK"); g_object_set (s_wireless, NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK, value, NULL); g_free (value); - value = svGetValue (ifcfg, "HWADDR_BLACKLIST", FALSE); + value = svGetValueString (ifcfg, "HWADDR_BLACKLIST"); if (value) { char **strv; @@ -3383,39 +3420,19 @@ make_wireless_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "ESSID", TRUE); + value = svGetValueString (ifcfg, "ESSID"); if (value) { - GBytes *bytes = NULL; + gs_unref_bytes GBytes *bytes = NULL; gsize ssid_len = 0; gsize value_len = strlen (value); - if ( (value_len >= 2) - && (value[0] == '"') - && (value[value_len - 1] == '"')) { - /* Strip the quotes and unescape */ - char *p = value + 1; - - value[value_len - 1] = '\0'; - svUnescape (p); - bytes = g_bytes_new (p, strlen (p)); - } else if ((value_len > 2) && (strncmp (value, "0x", 2) == 0)) { - /* Hex representation */ - if (value_len % 2) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' size (looks like hex but length not multiple of 2)", - value); - g_free (value); - goto error; - } - - bytes = nm_utils_hexstr2bin (value); - if (!bytes) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid SSID '%s' (looks like hex SSID but isn't)", - value); - g_free (value); - goto error; - } + if ( value_len > 2 + && (value_len % 2) == 0 + && g_str_has_prefix (value, "0x") + && NM_STRCHAR_ALL (&value[2], ch, g_ascii_isxdigit (ch))) { + /* interpret the value as hex-digits iff value starts + * with "0x" followed by pairs of hex digits */ + bytes = nm_utils_hexstr2bin (&value[2]); } else bytes = g_bytes_new (value, value_len); @@ -3424,17 +3441,15 @@ make_wireless_setting (shvarFile *ifcfg, g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", value, ssid_len); - g_bytes_unref (bytes); g_free (value); goto error; } g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, bytes, NULL); - g_bytes_unref (bytes); g_free (value); } - value = svGetValue (ifcfg, "MODE", FALSE); + value = svGetValueString (ifcfg, "MODE"); if (value) { char *lcase; const char *mode = NULL; @@ -3460,14 +3475,14 @@ make_wireless_setting (shvarFile *ifcfg, g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, mode, NULL); } - value = svGetValue (ifcfg, "BSSID", FALSE); + value = svGetValueString (ifcfg, "BSSID"); if (value) { value = g_strstrip (value); g_object_set (s_wireless, NM_SETTING_WIRELESS_BSSID, value, NULL); g_free (value); } - value = svGetValue (ifcfg, "CHANNEL", FALSE); + value = svGetValueString (ifcfg, "CHANNEL"); if (value) { errno = 0; chan = _nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0); @@ -3481,7 +3496,7 @@ make_wireless_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "BAND", FALSE); + value = svGetValueString (ifcfg, "BAND"); if (value) { if (!strcmp (value, "a")) { if (chan && chan <= 14) { @@ -3512,7 +3527,7 @@ make_wireless_setting (shvarFile *ifcfg, g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "bg", NULL); } - value = svGetValue (ifcfg, "MTU", FALSE); + value = svGetValueString (ifcfg, "MTU"); if (value) { int mtu; @@ -3532,19 +3547,19 @@ make_wireless_setting (shvarFile *ifcfg, svGetValueBoolean (ifcfg, "SSID_HIDDEN", FALSE), NULL); - value = svGetValueFull (ifcfg, "POWERSAVE", FALSE); - if (value) { - if (!strcmp (value, "default")) + cvalue = svGetValue (ifcfg, "POWERSAVE", &value); + if (cvalue) { + if (!strcmp (cvalue, "default")) powersave = NM_SETTING_WIRELESS_POWERSAVE_DEFAULT; - else if (!strcmp (value, "ignore")) + else if (!strcmp (cvalue, "ignore")) powersave = NM_SETTING_WIRELESS_POWERSAVE_IGNORE; - else if (!strcmp (value, "disable") || !strcmp (value, "no")) + else if (!strcmp (cvalue, "disable") || !strcmp (cvalue, "no")) powersave = NM_SETTING_WIRELESS_POWERSAVE_DISABLE; - else if (!strcmp (value, "enable") || !strcmp (value, "yes")) + else if (!strcmp (cvalue, "enable") || !strcmp (cvalue, "yes")) powersave = NM_SETTING_WIRELESS_POWERSAVE_ENABLE; else { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid POWERSAVE value '%s'", value); + "Invalid POWERSAVE value '%s'", cvalue); g_free (value); goto error; } @@ -3556,17 +3571,17 @@ make_wireless_setting (shvarFile *ifcfg, powersave, NULL); - value = svGetValueFull (ifcfg, "MAC_ADDRESS_RANDOMIZATION", FALSE); - if (value) { - if (strcmp (value, "default") == 0) + cvalue = svGetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", &value); + if (cvalue) { + if (strcmp (cvalue, "default") == 0) mac_randomization = NM_SETTING_MAC_RANDOMIZATION_DEFAULT; - else if (strcmp (value, "never") == 0) + else if (strcmp (cvalue, "never") == 0) mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; - else if (strcmp (value, "always") == 0) + else if (strcmp (cvalue, "always") == 0) mac_randomization = NM_SETTING_MAC_RANDOMIZATION_ALWAYS; else { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid MAC_ADDRESS_RANDOMIZATION value '%s'", value); + "Invalid MAC_ADDRESS_RANDOMIZATION value '%s'", cvalue); g_free (value); goto error; } @@ -3659,10 +3674,120 @@ wireless_connection_from_ifcfg (const char *file, } static void -parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, char **out_password) +parse_ethtool_option_autoneg (const char *value, gboolean *out_autoneg) +{ + if (!value) { + PARSE_WARNING ("Auto-negotiation option missing"); + return; + } + + if (g_str_equal (value, "off")) + *out_autoneg = FALSE; + else if (g_str_equal (value, "on")) + *out_autoneg = TRUE; + else + PARSE_WARNING ("Auto-negotiation unknown value: %s", value); +} + +static void +parse_ethtool_option_speed (const char *value, guint32 *out_speed) +{ + if (!value) { + PARSE_WARNING ("Speed option missing"); + return; + } + + *out_speed = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, 0); + if (errno) + PARSE_WARNING ("Speed value '%s' is invalid", value); +} + +static void +parse_ethtool_option_duplex (const char *value, const char **out_duplex) +{ + if (!value) { + PARSE_WARNING ("Duplex option missing"); + return; + } + + if (g_str_equal (value, "half")) + *out_duplex = "half"; + else if (g_str_equal (value, "full")) + *out_duplex = "full"; + else + PARSE_WARNING ("Duplex unknown value: %s", value); + +} + +static void +parse_ethtool_option_wol (const char *value, NMSettingWiredWakeOnLan *out_flags) +{ + NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; + + if (!value) { + PARSE_WARNING ("Wake-on-LAN options missing"); + return; + } + + for (; *value; value++) { + switch (*value) { + case 'p': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY; + break; + case 'u': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST; + break; + case 'm': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST; + break; + case 'b': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST; + break; + case 'a': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_ARP; + break; + case 'g': + wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; + break; + case 's': + break; + case 'd': + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; + break; + default: + PARSE_WARNING ("unrecognized Wake-on-LAN option '%c'", *value); + } + } + + *out_flags = wol_flags; +} + +static void parse_ethtool_option_sopass (const char *value, char **out_password) +{ + if (!value) { + PARSE_WARNING ("Wake-on-LAN password missing"); + return; + } + + g_clear_pointer (out_password, g_free); + if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { + PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", value); + return; + } + + *out_password = g_strdup (value); +} + +static void +parse_ethtool_option (const char *value, + NMSettingWiredWakeOnLan *out_flags, + char **out_password, + gboolean *out_autoneg, + guint32 *out_speed, + const char **out_duplex) { gs_strfreev char **words = NULL; - const char **iter = NULL, *flag; + const char **iter = NULL, *opt_val, *opt; if (!value || !value[0]) return; @@ -3671,77 +3796,37 @@ parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, cha iter = (const char **) words; while (iter[0]) { - gboolean is_wol; - - if (g_str_equal (iter[0], "wol")) - is_wol = TRUE; - else if (g_str_equal (iter[0], "sopass")) - is_wol = FALSE; - else { - /* Silently skip unknown options */ + /* g_strsplit_set() returns empty tokens when extra spaces are found: skip them */ + if (!*iter[0]) { iter++; continue; } - iter++; + opt = iter++[0]; - /* g_strsplit_set() returns empty tokens, meaning that we must skip over repeated - * space characters like to parse "wol d". */ + /* skip over repeated space characters like to parse "wol d". */ while (iter[0] && !*iter[0]) iter++; - if (is_wol) { - NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; - - if (!iter[0]) { - PARSE_WARNING ("Wake-on-LAN options missing"); - break; - } - - for (flag = iter[0]; *flag; flag++) { - switch (*flag) { - case 'p': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY; - break; - case 'u': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST; - break; - case 'm': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST; - break; - case 'b': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST; - break; - case 'a': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_ARP; - break; - case 'g': - wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; - break; - case 's': - break; - case 'd': - wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; - break; - default: - PARSE_WARNING ("unrecognized Wake-on-LAN option '%c'", *flag); - } - } - - *out_flags = wol_flags; - } else { - if (!iter[0]) { - PARSE_WARNING ("Wake-on-LAN password missing"); - break; - } - - g_clear_pointer (out_password, g_free); - if (nm_utils_hwaddr_valid (iter[0], ETH_ALEN)) - *out_password = g_strdup (iter[0]); - else - PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", iter[0]); + opt_val = iter[0]; + + if (g_str_equal (opt, "autoneg")) + parse_ethtool_option_autoneg (opt_val, out_autoneg); + else if (g_str_equal (opt, "speed")) + parse_ethtool_option_speed (opt_val, out_speed); + else if (g_str_equal (opt, "duplex")) + parse_ethtool_option_duplex (opt_val, out_duplex); + else if (g_str_equal (opt, "wol")) + parse_ethtool_option_wol (opt_val, out_flags); + else if (g_str_equal (opt, "sopass")) + parse_ethtool_option_sopass (opt_val, out_password); + else { + /* Silently skip unknown options */ + continue; } - iter++; + + if (iter[0]) + iter++; } } @@ -3749,31 +3834,48 @@ static void parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, const char *value) { NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; - gs_free char *wol_password = NULL; - gboolean ignore_wol_password = FALSE; + gs_free char *wol_password = NULL, *wol_value = NULL; + gboolean ignore_wol_password = FALSE, autoneg = FALSE; + guint32 speed = 0; + const char *duplex = NULL; if (value) { gs_strfreev char **opts = NULL; const char **iter; - wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; + /* WAKE_ON_LAN_IGNORE is inferred from a specified but empty ETHTOOL_OPTS */ + if (!value[0]) + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; opts = g_strsplit_set (value, ";", 0); for (iter = (const char **) opts; iter[0]; iter++) { /* in case of repeated wol_passwords, parse_ethtool_option() * will do the right thing and clear wol_password before resetting. */ - parse_ethtool_option (iter[0], &wol_flags, &wol_password); + parse_ethtool_option (iter[0], &wol_flags, &wol_password, &autoneg, &speed, &duplex); } } + /* ETHTOOL_WAKE_ON_LAN = ignore overrides WoL settings in ETHTOOL_OPTS */ + wol_value = svGetValueString (ifcfg, "ETHTOOL_WAKE_ON_LAN"); + if (wol_value) { + if (strcmp (wol_value, "ignore") == 0) + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; + else + PARSE_WARNING ("invalid ETHTOOL_WAKE_ON_LAN value '%s'", wol_value); + } + if ( wol_password && !NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { PARSE_WARNING ("Wake-on-LAN password not expected"); ignore_wol_password = TRUE; } + g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, ignore_wol_password ? NULL : wol_password, + NM_SETTING_WIRED_AUTO_NEGOTIATE, autoneg, + NM_SETTING_WIRED_SPEED, autoneg ? 0 : speed, + NM_SETTING_WIRED_DUPLEX, autoneg ? NULL : duplex, NULL); } @@ -3789,7 +3891,7 @@ make_wired_setting (shvarFile *ifcfg, s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); - value = svGetValue (ifcfg, "MTU", FALSE); + value = svGetValueString (ifcfg, "MTU"); if (value) { int mtu; @@ -3801,14 +3903,14 @@ make_wired_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "HWADDR", FALSE); + value = svGetValueString (ifcfg, "HWADDR"); if (value) { value = g_strstrip (value); g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, value, NULL); g_free (value); } - value = svGetValue (ifcfg, "SUBCHANNELS", FALSE); + value = svGetValueString (ifcfg, "SUBCHANNELS"); if (value) { const char *p = value; gboolean success = TRUE; @@ -3839,18 +3941,18 @@ make_wired_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "PORTNAME", FALSE); + value = svGetValueString (ifcfg, "PORTNAME"); if (value && strlen (value)) { nm_setting_wired_add_s390_option (s_wired, "portname", value); } g_free (value); - value = svGetValue (ifcfg, "CTCPROT", FALSE); + value = svGetValueString (ifcfg, "CTCPROT"); if (value && strlen (value)) nm_setting_wired_add_s390_option (s_wired, "ctcprot", value); g_free (value); - nettype = svGetValue (ifcfg, "NETTYPE", FALSE); + nettype = svGetValueString (ifcfg, "NETTYPE"); if (nettype && strlen (nettype)) { if (!strcmp (nettype, "qeth") || !strcmp (nettype, "lcs") || !strcmp (nettype, "ctc")) g_object_set (s_wired, NM_SETTING_WIRED_S390_NETTYPE, nettype, NULL); @@ -3859,7 +3961,7 @@ make_wired_setting (shvarFile *ifcfg, } g_free (nettype); - value = svGetValue (ifcfg, "OPTIONS", FALSE); + value = svGetValueString (ifcfg, "OPTIONS"); if (value && strlen (value)) { char **options, **iter; @@ -3880,18 +3982,18 @@ make_wired_setting (shvarFile *ifcfg, } g_free (value); - value = svGetValue (ifcfg, "MACADDR", FALSE); + value = svGetValueString (ifcfg, "MACADDR"); if (value) { value = g_strstrip (value); g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, value, NULL); g_free (value); } - value = svGetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", FALSE); + value = svGetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK"); g_object_set (s_wired, NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, value, NULL); g_free (value); - value = svGetValue (ifcfg, "HWADDR_BLACKLIST", FALSE); + value = svGetValueString (ifcfg, "HWADDR_BLACKLIST"); if (value) { char **strv; @@ -3901,7 +4003,7 @@ make_wired_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "KEY_MGMT", FALSE); + value = svGetValueString (ifcfg, "KEY_MGMT"); if (value) { if (!strcmp (value, "IEEE8021X")) { *s_8021x = fill_8021x (ifcfg, file, value, FALSE, error); @@ -3915,8 +4017,8 @@ make_wired_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValueFull (ifcfg, "ETHTOOL_OPTS", FALSE); - parse_ethtool_options (ifcfg, s_wired, value); + parse_ethtool_options (ifcfg, s_wired, + svGetValue (ifcfg, "ETHTOOL_OPTS", &value)); g_free (value); return (NMSetting *) s_wired; @@ -3976,19 +4078,19 @@ parse_infiniband_p_key (shvarFile *ifcfg, int id; gboolean ret = FALSE; - device = svGetValue (ifcfg, "DEVICE", FALSE); + device = svGetValueString (ifcfg, "DEVICE"); if (!device) { PARSE_WARNING ("InfiniBand connection specified PKEY but not DEVICE"); goto done; } - physdev = svGetValue (ifcfg, "PHYSDEV", FALSE); + physdev = svGetValueString (ifcfg, "PHYSDEV"); if (!physdev) { PARSE_WARNING ("InfiniBand connection specified PKEY but not PHYSDEV"); goto done; } - pkey_id = svGetValue (ifcfg, "PKEY_ID", FALSE); + pkey_id = svGetValueString (ifcfg, "PKEY_ID"); if (!pkey_id) { PARSE_WARNING ("InfiniBand connection specified PKEY but not PKEY_ID"); goto done; @@ -4036,7 +4138,7 @@ make_infiniband_setting (shvarFile *ifcfg, s_infiniband = NM_SETTING_INFINIBAND (nm_setting_infiniband_new ()); - value = svGetValue (ifcfg, "MTU", FALSE); + value = svGetValueString (ifcfg, "MTU"); if (value) { int mtu; @@ -4048,7 +4150,7 @@ make_infiniband_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "HWADDR", FALSE); + value = svGetValueString (ifcfg, "HWADDR"); if (value) { value = g_strstrip (value); g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, value, NULL); @@ -4148,7 +4250,7 @@ make_bond_setting (shvarFile *ifcfg, s_bond = NM_SETTING_BOND (nm_setting_bond_new ()); - value = svGetValue (ifcfg, "DEVICE", FALSE); + value = svGetValueString (ifcfg, "DEVICE"); if (!value || !strlen (value)) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "mandatory DEVICE keyword missing"); @@ -4156,7 +4258,7 @@ make_bond_setting (shvarFile *ifcfg, } g_free (value); - value = svGetValue (ifcfg, "BONDING_OPTS", FALSE); + value = svGetValueString (ifcfg, "BONDING_OPTS"); if (value) { char **items, **iter; @@ -4237,33 +4339,26 @@ static char * read_team_config (shvarFile *ifcfg, const char *key, GError **error) { gs_free_error GError *local_error = NULL; - char *value; + gs_free char *value = NULL; size_t l; - /* FIXME: validate the JSON at some point */ - value = svGetValue (ifcfg, key, TRUE); + value = svGetValueString (ifcfg, key); if (!value) return NULL; - /* No reason Team config should be over 20k. The config is read - * verbatim, length-checked, then unescaped. svUnescape() does not - * deal well with extremely long strings. - */ l = strlen (value); - if (l > 20000) { + if (l > 1*1024*1024) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "%s too long (size %zd)", key, l); - g_free (value); return NULL; } - svUnescape (value); - if (value && value[0] && !_nm_utils_check_valid_json (value, &local_error)) { + if (!nm_utils_is_json_object (value, &local_error)) { PARSE_WARNING ("ignoring invalid team configuration: %s", local_error->message); - g_clear_pointer (&value, g_free); + return NULL; } - return value; + return g_steal_pointer (&value); } static NMSetting * @@ -4277,7 +4372,7 @@ make_team_setting (shvarFile *ifcfg, s_team = NM_SETTING_TEAM (nm_setting_team_new ()); - value = svGetValue (ifcfg, "DEVICE", FALSE); + value = svGetValueString (ifcfg, "DEVICE"); if (!value || !strlen (value)) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "mandatory DEVICE keyword missing"); @@ -4434,7 +4529,7 @@ make_bridge_setting (shvarFile *ifcfg, s_bridge = NM_SETTING_BRIDGE (nm_setting_bridge_new ()); - value = svGetValue (ifcfg, "DEVICE", FALSE); + value = svGetValueString (ifcfg, "DEVICE"); if (!value || !strlen (value)) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "mandatory DEVICE keyword missing"); @@ -4442,14 +4537,14 @@ make_bridge_setting (shvarFile *ifcfg, } g_free (value); - value = svGetValue (ifcfg, "MACADDR", FALSE); + value = svGetValueString (ifcfg, "MACADDR"); if (value) { value = g_strstrip (value); g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, value, NULL); g_free (value); } - value = svGetValue (ifcfg, "STP", FALSE); + value = svGetValueString (ifcfg, "STP"); if (value) { if (!strcasecmp (value, "on") || !strcasecmp (value, "yes")) { g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, TRUE, NULL); @@ -4468,7 +4563,7 @@ make_bridge_setting (shvarFile *ifcfg, g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL); } - value = svGetValue (ifcfg, "DELAY", FALSE); + value = svGetValueString (ifcfg, "DELAY"); if (value) { if (stp) { if (get_uint (value, &u)) @@ -4480,7 +4575,7 @@ make_bridge_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "BRIDGING_OPTS", FALSE); + value = svGetValueString (ifcfg, "BRIDGING_OPTS"); if (value) { handle_bridging_opts (NM_SETTING (s_bridge), stp, value, handle_bridge_option); g_free (value); @@ -4563,12 +4658,14 @@ make_bridge_port_setting (shvarFile *ifcfg) g_return_val_if_fail (ifcfg != NULL, FALSE); - value = svGetValue (ifcfg, "BRIDGE", FALSE); + value = svGetValueString (ifcfg, "BRIDGE_UUID"); + if (!value) + value = svGetValueString (ifcfg, "BRIDGE"); if (value) { g_free (value); s_port = nm_setting_bridge_port_new (); - value = svGetValue (ifcfg, "BRIDGING_OPTS", FALSE); + value = svGetValueString (ifcfg, "BRIDGING_OPTS"); if (value) handle_bridging_opts (s_port, FALSE, value, handle_bridge_port_option); g_free (value); @@ -4645,7 +4742,7 @@ parse_prio_map_list (NMSettingVlan *s_vlan, char *value; gchar **list = NULL, **iter; - value = svGetValue (ifcfg, key, FALSE); + value = svGetValueString (ifcfg, key); if (!value) return; @@ -4676,7 +4773,7 @@ make_vlan_setting (shvarFile *ifcfg, guint32 vlan_flags = 0; gint gvrp, reorder_hdr; - value = svGetValue (ifcfg, "VLAN_ID", FALSE); + value = svGetValueString (ifcfg, "VLAN_ID"); if (value) { vlan_id = _nm_utils_ascii_str_to_int64 (value, 10, 0, 4095, -1); if (vlan_id == -1) { @@ -4689,7 +4786,7 @@ make_vlan_setting (shvarFile *ifcfg, } /* Need DEVICE if we don't have a separate VLAN_ID property */ - iface_name = svGetValue (ifcfg, "DEVICE", FALSE); + iface_name = svGetValueString (ifcfg, "DEVICE"); if (!iface_name && vlan_id < 0) { g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing DEVICE property; cannot determine VLAN ID."); @@ -4699,7 +4796,7 @@ make_vlan_setting (shvarFile *ifcfg, s_vlan = NM_SETTING_VLAN (nm_setting_vlan_new ()); /* Parent interface from PHYSDEV takes precedence if it exists */ - parent = svGetValue (ifcfg, "PHYSDEV", FALSE); + parent = svGetValueString (ifcfg, "PHYSDEV"); if (iface_name) { p = strchr (iface_name, '.'); @@ -4755,7 +4852,7 @@ make_vlan_setting (shvarFile *ifcfg, if (gvrp > 0) vlan_flags |= NM_VLAN_FLAG_GVRP; - value = svGetValue (ifcfg, "VLAN_FLAGS", FALSE); + value = svGetValueString (ifcfg, "VLAN_FLAGS"); if (value) { gs_strfreev char **strv = NULL; char **ptr; @@ -4866,7 +4963,7 @@ create_unhandled_connection (const char *filename, shvarFile *ifcfg, nm_connection_add_setting (connection, nm_setting_generic_new ()); /* Get a spec */ - value = svGetValue (ifcfg, "HWADDR", FALSE); + value = svGetValueString (ifcfg, "HWADDR"); if (value) { char *lower = g_ascii_strdown (value, -1); *out_spec = g_strdup_printf ("%s:mac:%s", type, lower); @@ -4875,14 +4972,14 @@ create_unhandled_connection (const char *filename, shvarFile *ifcfg, return connection; } - value = svGetValue (ifcfg, "SUBCHANNELS", FALSE); + value = svGetValueString (ifcfg, "SUBCHANNELS"); if (value) { *out_spec = g_strdup_printf ("%s:s390-subchannels:%s", type, value); g_free (value); return connection; } - value = svGetValue (ifcfg, "DEVICE", FALSE); + value = svGetValueString (ifcfg, "DEVICE"); if (value) { *out_spec = g_strdup_printf ("%s:interface-name:%s", type, value); g_free (value); @@ -4911,10 +5008,10 @@ uuid_from_file (const char *filename) return NULL; /* Try for a UUID key before falling back to hashing the file name */ - uuid = svGetValue (ifcfg, "UUID", FALSE); + uuid = svGetValueString (ifcfg, "UUID"); if (!uuid || !strlen (uuid)) { g_free (uuid); - uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); + uuid = nm_utils_uuid_generate_from_string (svFileGetName (ifcfg), -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); } svCloseFile (ifcfg); @@ -4932,7 +5029,7 @@ check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) */ if (!s_ip4 || nm_setting_ip_config_get_num_dns_searches (NM_SETTING_IP_CONFIG (s_ip4)) == 0) { /* DNS searches */ - char *value = svGetValue (ifcfg, "DOMAIN", FALSE); + char *value = svGetValueString (ifcfg, "DOMAIN"); if (value) { char **searches = g_strsplit (value, " ", 0); if (searches) { @@ -4962,7 +5059,7 @@ connection_from_file_full (const char *filename, shvarFile *parsed; gs_free char *type = NULL; char *devtype, *bootproto; - NMSetting *s_ip4, *s_ip6, *s_port, *s_dcb = NULL; + NMSetting *s_ip4, *s_ip6, *s_proxy, *s_port, *s_dcb = NULL; const char *ifcfg_name = NULL; g_return_val_if_fail (filename != NULL, NULL); @@ -4992,7 +5089,7 @@ connection_from_file_full (const char *filename, } /* iBFT is handled by the iBFT settings plugin */ - bootproto = svGetValue (parsed, "BOOTPROTO", FALSE); + bootproto = svGetValueString (parsed, "BOOTPROTO"); if (bootproto && !g_ascii_strcasecmp (bootproto, "ibft")) { if (out_ignore_error) *out_ignore_error = TRUE; @@ -5003,7 +5100,7 @@ connection_from_file_full (const char *filename, } g_free (bootproto); - devtype = svGetValue (parsed, "DEVICETYPE", FALSE); + devtype = svGetValueString (parsed, "DEVICETYPE"); if (devtype) { if (!strcasecmp (devtype, TYPE_TEAM)) type = g_strdup (TYPE_TEAM); @@ -5017,19 +5114,19 @@ connection_from_file_full (const char *filename, /* Team and TeamPort types are also accepted by the mere * presense of TEAM_CONFIG/TEAM_MASTER. They don't require * DEVICETYPE. */ - t = svGetValue (parsed, "TEAM_CONFIG", FALSE); + t = svGetValueString (parsed, "TEAM_CONFIG"); if (t) type = g_strdup (TYPE_TEAM); } if (!type) - type = svGetValue (parsed, "TYPE", FALSE); + type = svGetValueString (parsed, "TYPE"); if (!type) { gs_free char *tmp = NULL; char *device; - if ((tmp = svGetValue (parsed, "IPV6TUNNELIPV4", FALSE))) { + if ((tmp = svGetValueString (parsed, "IPV6TUNNELIPV4"))) { if (out_ignore_error) *out_ignore_error = TRUE; g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, @@ -5037,7 +5134,7 @@ connection_from_file_full (const char *filename, goto done; } - device = svGetValue (parsed, "DEVICE", FALSE); + device = svGetValueString (parsed, "DEVICE"); if (!device) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "File '%s' had neither TYPE nor DEVICE keys.", filename); @@ -5179,6 +5276,10 @@ connection_from_file_full (const char *filename, */ check_dns_search_domains (parsed, s_ip4, s_ip6); + s_proxy = make_proxy_setting (parsed, error); + if (s_proxy) + nm_connection_add_setting (connection, s_proxy); + /* Bridge port? */ s_port = make_bridge_port_setting (parsed); if (s_port) @@ -5247,7 +5348,7 @@ devtimeout_from_file (const char *filename) if (!ifcfg) return 0; - devtimeout_str = svGetValue (ifcfg, "DEVTIMEOUT", FALSE); + devtimeout_str = svGetValueString (ifcfg, "DEVTIMEOUT"); if (devtimeout_str) { devtimeout = _nm_utils_ascii_str_to_int64 (devtimeout_str, 10, 0, G_MAXUINT, 0); g_free (devtimeout_str); diff --git a/src/settings/plugins/ifcfg-rh/reader.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h index 35464474..35464474 100644 --- a/src/settings/plugins/ifcfg-rh/reader.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c index b9d52b7f..d1c00976 100644 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c @@ -20,7 +20,7 @@ #include "nm-default.h" -#include "utils.h" +#include "nms-ifcfg-rh-utils.h" #include <stdlib.h> #include <string.h> @@ -28,88 +28,7 @@ #include "nm-core-internal.h" #include "NetworkManagerUtils.h" -#include "common.h" - -/* - * utils_single_quote_string - * - * Put string inside single quotes and remove CR, LF characters. If single quote - * is present, escape it with a backslash and prepend the whole string with $ - * in order to have $'string'. That allows us to use single quote inside - * single quotes without breaking bash syntax. (man bash, section QUOTING). - * - * Caller is responsible for freeing the returned string. - */ -char * -utils_single_quote_string (const char *str) -{ - static const char *drop_chars = "\r\n"; /* drop CR and LF */ - static const char escape_char = '\\'; /* escape char is backslash */ - static const char quote_char = '\''; /* quote char is single quote */ - size_t i, slen, j = 0; - size_t drop = 0, extra = 0; - char *new_str; - - slen = strlen (str); - for (i = 0; i < slen; i++) { - if (str[i] == quote_char) - extra++; - if (strchr (drop_chars, str[i])) - drop++; - } - new_str = g_malloc0 (slen + extra - drop + 4); /* 4 is for $''\0*/ - - if (extra > 0) - new_str[j++] = '$'; - new_str[j++] = quote_char; - for (i = 0; i < slen; i++) { - if (strchr (drop_chars, str[i])) - continue; - if (str[i] == quote_char) - new_str[j++] = escape_char; - new_str[j++] = str[i]; - } - new_str[j] = quote_char; - - return new_str; -} - -/* - * utils_single_unquote_string - * - * Remove string from single (or double) quotes, and remove escaping of '. - * Also remove first $ if the string is in the form of $'string'. - * - * Caller is responsible for freeing the returned string. - */ -char * -utils_single_unquote_string (const char *str) -{ - static const char escape_char = '\\'; /* escape char is backslash */ - static const char q_char = '\''; /* quote char is single quote */ - static const char dq_char = '"'; /* double quote char */ - size_t i, slen, j = 0, quote = 0, dollar = 0; - char *new_str; - - slen = strlen (str); - new_str = g_malloc0 (slen + 1); - - if ( (slen >= 2 && (str[0] == dq_char || str[0] == q_char) && str[0] == str[slen-1]) - || (slen >= 3 && str[0] == '$' && str[1] == q_char && str[1] == str[slen-1])) { - quote = 1; - if (str[0] == '$') dollar = 1; - } - - i = quote + dollar; - while (i < slen - quote) { - if (str[i] == escape_char && str[i+1] == q_char && i+1 < slen-quote) - i++; - new_str[j++] = str[i++]; - } - new_str[j] = '\0'; - - return new_str; -} +#include "nms-ifcfg-rh-common.h" /* * Check ';[a-fA-F0-9]{8}' file suffix used for temporary files by rpm when diff --git a/src/settings/plugins/ifcfg-rh/utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h index c105487a..af0469e6 100644 --- a/src/settings/plugins/ifcfg-rh/utils.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h @@ -31,10 +31,6 @@ #define NM_IFCFG_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" #define NM_IFCFG_CONNECTION_LOG_ARGD(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con) -char *utils_single_quote_string (const char *str); - -char *utils_single_unquote_string (const char *str); - char *utils_cert_path (const char *parent, const char *suffix); const char *utils_get_ifcfg_name (const char *file, gboolean only_ifcfg); diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index dcc48f2a..90a8e7ac 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -20,7 +20,7 @@ #include "nm-default.h" -#include "writer.h" +#include "nms-ifcfg-rh-writer.h" #include <string.h> #include <sys/types.h> @@ -32,10 +32,12 @@ #include <unistd.h> #include <stdio.h> +#include "nm-manager.h" #include "nm-setting-connection.h" #include "nm-setting-wired.h" #include "nm-setting-wireless.h" #include "nm-setting-8021x.h" +#include "nm-setting-proxy.h" #include "nm-setting-ip4-config.h" #include "nm-setting-ip6-config.h" #include "nm-setting-pppoe.h" @@ -46,10 +48,10 @@ #include "nm-core-internal.h" #include "NetworkManagerUtils.h" -#include "common.h" +#include "nms-ifcfg-rh-common.h" +#include "nms-ifcfg-rh-reader.h" +#include "nms-ifcfg-rh-utils.h" #include "shvar.h" -#include "reader.h" -#include "utils.h" /*****************************************************************************/ @@ -76,7 +78,7 @@ save_secret_flags (shvarFile *ifcfg, g_return_if_fail (key != NULL); if (flags == NM_SETTING_SECRET_FLAG_NONE) { - svSetValue (ifcfg, key, NULL, FALSE); + svUnsetValue (ifcfg, key); return; } @@ -97,7 +99,7 @@ save_secret_flags (shvarFile *ifcfg, g_string_append (str, SECRET_FLAG_NOT_REQUIRED); } - svSetValue (ifcfg, key, str->len ? str->str : NULL, FALSE); + svSetValueString (ifcfg, key, str->len ? str->str : NULL); g_string_free (str, TRUE); } @@ -106,34 +108,32 @@ set_secret (shvarFile *ifcfg, const char *key, const char *value, const char *flags_key, - NMSettingSecretFlags flags, - gboolean verbatim) + NMSettingSecretFlags flags) { shvarFile *keyfile; GError *error = NULL; /* Clear the secret from the ifcfg and the associated "keys" file */ - svSetValue (ifcfg, key, NULL, FALSE); + svUnsetValue (ifcfg, key); /* Save secret flags */ save_secret_flags (ifcfg, flags_key, flags); - keyfile = utils_get_keys_ifcfg (ifcfg->fileName, TRUE); + keyfile = utils_get_keys_ifcfg (svFileGetName (ifcfg), TRUE); if (!keyfile) { - _LOGW ("could not create ifcfg file for '%s'", ifcfg->fileName); + _LOGW ("could not create ifcfg file for '%s'", svFileGetName (ifcfg)); goto error; } - /* Clear the secret from the associated "keys" file */ - svSetValue (keyfile, key, NULL, FALSE); - /* Only write the secret if it's system owned and supposed to be saved */ if (flags == NM_SETTING_SECRET_FLAG_NONE) - svSetValue (keyfile, key, value, verbatim); + svSetValueString (keyfile, key, value); + else + svUnsetValue (keyfile, key); if (!svWriteFile (keyfile, 0600, &error)) { _LOGW ("could not update ifcfg file '%s': %s", - keyfile->fileName, error->message); + svFileGetName (keyfile), error->message); g_clear_error (&error); svCloseFile (keyfile); goto error; @@ -143,63 +143,7 @@ set_secret (shvarFile *ifcfg, error: /* Try setting the secret in the actual ifcfg */ - svSetValue (ifcfg, key, value, FALSE); -} - -static gboolean -write_secret_file (const char *path, - const char *data, - gsize len, - GError **error) -{ - char *tmppath; - int fd = -1, written; - gboolean success = FALSE; - mode_t saved_umask; - - tmppath = g_malloc0 (strlen (path) + 10); - memcpy (tmppath, path, strlen (path)); - strcat (tmppath, ".XXXXXX"); - - /* Only readable by root */ - saved_umask = umask (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); - - errno = 0; - fd = mkstemp (tmppath); - if (fd < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not create temporary file for '%s': %d", - path, errno); - goto out; - } - - errno = 0; - written = write (fd, data, len); - if (written != len) { - close (fd); - unlink (tmppath); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not write temporary file for '%s': %d", - path, errno); - goto out; - } - close (fd); - - /* Try to rename */ - errno = 0; - if (rename (tmppath, path)) { - unlink (tmppath); - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not rename temporary file to '%s': %d", - path, errno); - goto out; - } - success = TRUE; - -out: - umask (saved_umask); - g_free (tmppath); - return success; + svSetValueString (ifcfg, key, value); } typedef struct ObjectType { @@ -298,6 +242,8 @@ write_object (NMSetting8021x *s_8021x, scheme = (*(objtype->scheme_func))(s_8021x); switch (scheme) { + case NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: + break; case NM_SETTING_802_1X_CK_SCHEME_BLOB: blob = (*(objtype->blob_func))(s_8021x); break; @@ -305,7 +251,9 @@ write_object (NMSetting8021x *s_8021x, path = (*(objtype->path_func))(s_8021x); break; default: - break; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Unhandled certificate object scheme"); + return FALSE; } /* If certificate/private key wasn't sent, the connection may no longer be @@ -321,12 +269,12 @@ write_object (NMSetting8021x *s_8021x, * /etc/sysconfig/network-scripts/ca-cert-Test_Write_Wifi_WPA_EAP-TLS.der * will be deleted, but /etc/pki/tls/cert.pem will not. */ - standard_file = utils_cert_path (ifcfg->fileName, objtype->suffix); + standard_file = utils_cert_path (svFileGetName (ifcfg), objtype->suffix); if (g_file_test (standard_file, G_FILE_TEST_EXISTS)) ignored = unlink (standard_file); g_free (standard_file); - svSetValue (ifcfg, objtype->ifcfg_key, NULL, FALSE); + svUnsetValue (ifcfg, objtype->ifcfg_key); return TRUE; } @@ -334,7 +282,7 @@ write_object (NMSetting8021x *s_8021x, * may have been sent. */ if (path) { - svSetValue (ifcfg, objtype->ifcfg_key, path, FALSE); + svSetValueString (ifcfg, objtype->ifcfg_key, path); return TRUE; } @@ -344,7 +292,7 @@ write_object (NMSetting8021x *s_8021x, char *new_file; GError *write_error = NULL; - new_file = utils_cert_path (ifcfg->fileName, objtype->suffix); + new_file = utils_cert_path (svFileGetName (ifcfg), objtype->suffix); if (!new_file) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create file path for %s / %s", @@ -356,12 +304,13 @@ write_object (NMSetting8021x *s_8021x, * can use paths from now on instead of pushing around the certificate * data itself. */ - success = write_secret_file (new_file, - (const char *) g_bytes_get_data (blob, NULL), - g_bytes_get_size (blob), - &write_error); + success = nm_utils_file_set_contents (new_file, + (const char *) g_bytes_get_data (blob, NULL), + g_bytes_get_size (blob), + 0600, + &write_error); if (success) { - svSetValue (ifcfg, objtype->ifcfg_key, new_file, FALSE); + svSetValueString (ifcfg, objtype->ifcfg_key, new_file); g_free (new_file); return TRUE; } else { @@ -421,15 +370,13 @@ write_8021x_certs (NMSetting8021x *s_8021x, "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD", password, "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD_FLAGS", - flags, - FALSE); + flags); } else { set_secret (ifcfg, "IEEE_8021X_PRIVATE_KEY_PASSWORD", password, "IEEE_8021X_PRIVATE_KEY_PASSWORD_FLAGS", - flags, - FALSE); + flags); } /* Client certificate */ @@ -437,9 +384,9 @@ write_8021x_certs (NMSetting8021x *s_8021x, /* Don't need a client certificate with PKCS#12 since the file is both * the client certificate and the private key in one file. */ - svSetValue (ifcfg, - phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT", - NULL, FALSE); + svSetValueString (ifcfg, + phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT", + NULL); } else { /* Save the client certificate */ if (!write_object (s_8021x, ifcfg, phase2 ? &phase2_client_type : &client_type, error)) @@ -470,13 +417,13 @@ write_8021x_setting (NMConnection *connection, if (!s_8021x) { /* If wired, clear KEY_MGMT */ if (wired) - svSetValue (ifcfg, "KEY_MGMT", NULL, FALSE); + svUnsetValue (ifcfg, "KEY_MGMT"); return TRUE; } /* If wired, write KEY_MGMT */ if (wired) - svSetValue (ifcfg, "KEY_MGMT", "IEEE8021X", FALSE); + svSetValueString (ifcfg, "KEY_MGMT", "IEEE8021X"); /* EAP method */ if (nm_setting_802_1x_get_num_eap_methods (s_8021x)) { @@ -484,56 +431,53 @@ write_8021x_setting (NMConnection *connection, if (value) tmp = g_ascii_strup (value, -1); } - svSetValue (ifcfg, "IEEE_8021X_EAP_METHODS", tmp ? tmp : NULL, FALSE); + svSetValueString (ifcfg, "IEEE_8021X_EAP_METHODS", tmp); g_free (tmp); - svSetValue (ifcfg, "IEEE_8021X_IDENTITY", - nm_setting_802_1x_get_identity (s_8021x), - FALSE); + svSetValueString (ifcfg, "IEEE_8021X_IDENTITY", + nm_setting_802_1x_get_identity (s_8021x)); - svSetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", - nm_setting_802_1x_get_anonymous_identity (s_8021x), - FALSE); + svSetValueString (ifcfg, "IEEE_8021X_ANON_IDENTITY", + nm_setting_802_1x_get_anonymous_identity (s_8021x)); set_secret (ifcfg, "IEEE_8021X_PASSWORD", nm_setting_802_1x_get_password (s_8021x), "IEEE_8021X_PASSWORD_FLAGS", - nm_setting_802_1x_get_password_flags (s_8021x), - FALSE); + nm_setting_802_1x_get_password_flags (s_8021x)); /* PEAP version */ value = nm_setting_802_1x_get_phase1_peapver (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_PEAP_VERSION", NULL, FALSE); + svUnsetValue (ifcfg, "IEEE_8021X_PEAP_VERSION"); if (value && (!strcmp (value, "0") || !strcmp (value, "1"))) - svSetValue (ifcfg, "IEEE_8021X_PEAP_VERSION", value, FALSE); + svSetValueString (ifcfg, "IEEE_8021X_PEAP_VERSION", value); /* Force new PEAP label */ value = nm_setting_802_1x_get_phase1_peaplabel (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", NULL, FALSE); + svUnsetValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL"); if (value && !strcmp (value, "1")) - svSetValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", "yes", FALSE); + svSetValueString (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", "yes"); /* PAC file */ value = nm_setting_802_1x_get_pac_file (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_PAC_FILE", NULL, FALSE); + svUnsetValue (ifcfg, "IEEE_8021X_PAC_FILE"); if (value) - svSetValue (ifcfg, "IEEE_8021X_PAC_FILE", value, FALSE); + svSetValueString (ifcfg, "IEEE_8021X_PAC_FILE", value); /* FAST PAC provisioning */ value = nm_setting_802_1x_get_phase1_fast_provisioning (s_8021x); - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", NULL, FALSE); + svUnsetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING"); if (value) { if (strcmp (value, "1") == 0) - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth", FALSE); + svSetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth"); else if (strcmp (value, "2") == 0) - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-auth", FALSE); + svSetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-auth"); else if (strcmp (value, "3") == 0) - svSetValue (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth allow-auth", FALSE); + svSetValueString (ifcfg, "IEEE_8021X_FAST_PROVISIONING", "allow-unauth allow-auth"); } /* Phase2 auth methods */ - svSetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", NULL, FALSE); + svUnsetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS"); phase2_auth = g_string_new (NULL); value = nm_setting_802_1x_get_phase2_auth (s_8021x); @@ -553,21 +497,18 @@ write_8021x_setting (NMConnection *connection, g_free (tmp); } - svSetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", - phase2_auth->len ? phase2_auth->str : NULL, - FALSE); + svSetValueString (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", + phase2_auth->len ? phase2_auth->str : NULL); g_string_free (phase2_auth, TRUE); - svSetValue (ifcfg, "IEEE_8021X_SUBJECT_MATCH", - nm_setting_802_1x_get_subject_match (s_8021x), - FALSE); + svSetValueString (ifcfg, "IEEE_8021X_SUBJECT_MATCH", + nm_setting_802_1x_get_subject_match (s_8021x)); - svSetValue (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH", - nm_setting_802_1x_get_phase2_subject_match (s_8021x), - FALSE); + svSetValueString (ifcfg, "IEEE_8021X_PHASE2_SUBJECT_MATCH", + nm_setting_802_1x_get_phase2_subject_match (s_8021x)); - svSetValue (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", NULL, FALSE); + svUnsetValue (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES"); str = g_string_new (NULL); num = nm_setting_802_1x_get_num_altsubject_matches (s_8021x); for (i = 0; i < num; i++) { @@ -577,10 +518,10 @@ write_8021x_setting (NMConnection *connection, g_string_append (str, match); } if (str->len > 0) - svSetValue (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", str->str, FALSE); + svSetValueString (ifcfg, "IEEE_8021X_ALTSUBJECT_MATCHES", str->str); g_string_free (str, TRUE); - svSetValue (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", NULL, FALSE); + svUnsetValue (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES"); str = g_string_new (NULL); num = nm_setting_802_1x_get_num_phase2_altsubject_matches (s_8021x); for (i = 0; i < num; i++) { @@ -590,15 +531,13 @@ write_8021x_setting (NMConnection *connection, g_string_append (str, match); } if (str->len > 0) - svSetValue (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", str->str, FALSE); + svSetValueString (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", str->str); g_string_free (str, TRUE); - svSetValue (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", - nm_setting_802_1x_get_domain_suffix_match (s_8021x), - FALSE); - svSetValue (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", - nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x), - FALSE); + svSetValueString (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", + nm_setting_802_1x_get_domain_suffix_match (s_8021x)); + svSetValueString (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", + nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x)); success = write_8021x_certs (s_8021x, FALSE, ifcfg, error); if (success) { @@ -617,7 +556,8 @@ write_wireless_security_setting (NMConnection *connection, GError **error) { NMSettingWirelessSecurity *s_wsec; - const char *key_mgmt, *auth_alg, *key, *proto, *cipher, *psk; + const char *key_mgmt, *auth_alg, *key, *proto, *cipher; + const char *psk = NULL; gboolean wep = FALSE, wpa = FALSE, dynamic_wep = FALSE; char *tmp; guint32 i, num; @@ -635,41 +575,39 @@ write_wireless_security_setting (NMConnection *connection, auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); - svSetValue (ifcfg, "DEFAULTKEY", NULL, FALSE); + svUnsetValue (ifcfg, "DEFAULTKEY"); if (!strcmp (key_mgmt, "none")) { - svSetValue (ifcfg, "KEY_MGMT", NULL, FALSE); + svUnsetValue (ifcfg, "KEY_MGMT"); wep = TRUE; *no_8021x = TRUE; } else if (!strcmp (key_mgmt, "wpa-none") || !strcmp (key_mgmt, "wpa-psk")) { - svSetValue (ifcfg, "KEY_MGMT", "WPA-PSK", FALSE); + svSetValueString (ifcfg, "KEY_MGMT", "WPA-PSK"); wpa = TRUE; *no_8021x = TRUE; } else if (!strcmp (key_mgmt, "ieee8021x")) { - svSetValue (ifcfg, "KEY_MGMT", "IEEE8021X", FALSE); + svSetValueString (ifcfg, "KEY_MGMT", "IEEE8021X"); dynamic_wep = TRUE; } else if (!strcmp (key_mgmt, "wpa-eap")) { - svSetValue (ifcfg, "KEY_MGMT", "WPA-EAP", FALSE); + svSetValueString (ifcfg, "KEY_MGMT", "WPA-EAP"); wpa = TRUE; } - svSetValue (ifcfg, "SECURITYMODE", NULL, FALSE); + svUnsetValue (ifcfg, "SECURITYMODE"); if (auth_alg) { if (!strcmp (auth_alg, "shared")) - svSetValue (ifcfg, "SECURITYMODE", "restricted", FALSE); + svSetValueString (ifcfg, "SECURITYMODE", "restricted"); else if (!strcmp (auth_alg, "open")) - svSetValue (ifcfg, "SECURITYMODE", "open", FALSE); + svSetValueString (ifcfg, "SECURITYMODE", "open"); else if (!strcmp (auth_alg, "leap")) { - svSetValue (ifcfg, "SECURITYMODE", "leap", FALSE); - svSetValue (ifcfg, "IEEE_8021X_IDENTITY", - nm_setting_wireless_security_get_leap_username (s_wsec), - FALSE); + svSetValueString (ifcfg, "SECURITYMODE", "leap"); + svSetValueString (ifcfg, "IEEE_8021X_IDENTITY", + nm_setting_wireless_security_get_leap_username (s_wsec)); set_secret (ifcfg, "IEEE_8021X_PASSWORD", nm_setting_wireless_security_get_leap_password (s_wsec), "IEEE_8021X_PASSWORD_FLAGS", - nm_setting_wireless_security_get_leap_password_flags (s_wsec), - FALSE); + nm_setting_wireless_security_get_leap_password_flags (s_wsec)); *no_8021x = TRUE; } } @@ -677,16 +615,16 @@ write_wireless_security_setting (NMConnection *connection, /* WEP keys */ /* Clear any default key */ - set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); /* Clear existing keys */ for (i = 0; i < 4; i++) { tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); g_free (tmp); tmp = g_strdup_printf ("KEY%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); g_free (tmp); } @@ -694,7 +632,7 @@ write_wireless_security_setting (NMConnection *connection, if (wep) { /* Default WEP TX key index */ tmp = g_strdup_printf ("%d", nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec) + 1); - svSetValue (ifcfg, "DEFAULTKEY", tmp, FALSE); + svSetValueString (ifcfg, "DEFAULTKEY", tmp); g_free (tmp); for (i = 0; i < 4; i++) { @@ -735,8 +673,7 @@ write_wireless_security_setting (NMConnection *connection, tmp, key, "WEP_KEY_FLAGS", - nm_setting_wireless_security_get_wep_key_flags (s_wsec), - FALSE); + nm_setting_wireless_security_get_wep_key_flags (s_wsec)); } g_free (tmp); g_free (ascii_key); @@ -745,19 +682,19 @@ write_wireless_security_setting (NMConnection *connection, } /* WPA protos */ - svSetValue (ifcfg, "WPA_ALLOW_WPA", NULL, FALSE); - svSetValue (ifcfg, "WPA_ALLOW_WPA2", NULL, FALSE); + svUnsetValue (ifcfg, "WPA_ALLOW_WPA"); + svUnsetValue (ifcfg, "WPA_ALLOW_WPA2"); num = nm_setting_wireless_security_get_num_protos (s_wsec); for (i = 0; i < num; i++) { proto = nm_setting_wireless_security_get_proto (s_wsec, i); if (proto && !strcmp (proto, "wpa")) - svSetValue (ifcfg, "WPA_ALLOW_WPA", "yes", FALSE); + svSetValueString (ifcfg, "WPA_ALLOW_WPA", "yes"); else if (proto && !strcmp (proto, "rsn")) - svSetValue (ifcfg, "WPA_ALLOW_WPA2", "yes", FALSE); + svSetValueString (ifcfg, "WPA_ALLOW_WPA2", "yes"); } /* WPA Pairwise ciphers */ - svSetValue (ifcfg, "CIPHER_PAIRWISE", NULL, FALSE); + svUnsetValue (ifcfg, "CIPHER_PAIRWISE"); str = g_string_new (NULL); num = nm_setting_wireless_security_get_num_pairwise (s_wsec); for (i = 0; i < num; i++) { @@ -775,11 +712,11 @@ write_wireless_security_setting (NMConnection *connection, } } if (strlen (str->str) && (dynamic_wep == FALSE)) - svSetValue (ifcfg, "CIPHER_PAIRWISE", str->str, FALSE); + svSetValueString (ifcfg, "CIPHER_PAIRWISE", str->str); g_string_free (str, TRUE); /* WPA Group ciphers */ - svSetValue (ifcfg, "CIPHER_GROUP", NULL, FALSE); + svUnsetValue (ifcfg, "CIPHER_GROUP"); str = g_string_new (NULL); num = nm_setting_wireless_security_get_num_groups (s_wsec); for (i = 0; i < num; i++) { @@ -791,33 +728,17 @@ write_wireless_security_setting (NMConnection *connection, g_free (tmp); } if (strlen (str->str) && (dynamic_wep == FALSE)) - svSetValue (ifcfg, "CIPHER_GROUP", str->str, FALSE); + svSetValueString (ifcfg, "CIPHER_GROUP", str->str); g_string_free (str, TRUE); - /* WPA Passphrase */ - if (wpa) { - char *quoted = NULL; - + if (wpa) psk = nm_setting_wireless_security_get_psk (s_wsec); - if (psk && (strlen (psk) != 64)) { - /* Quote the PSK since it's a passphrase */ - quoted = utils_single_quote_string (psk); - } - set_secret (ifcfg, - "WPA_PSK", - quoted ? quoted : psk, - "WPA_PSK_FLAGS", - nm_setting_wireless_security_get_psk_flags (s_wsec), - TRUE); - g_free (quoted); - } else { - set_secret (ifcfg, - "WPA_PSK", - NULL, - "WPA_PSK_FLAGS", - NM_SETTING_SECRET_FLAG_NONE, - FALSE); - } + + set_secret (ifcfg, + "WPA_PSK", + psk, + "WPA_PSK_FLAGS", + wpa ? nm_setting_wireless_security_get_psk_flags (s_wsec) : NM_SETTING_SECRET_FLAG_NONE); return TRUE; } @@ -829,13 +750,12 @@ write_wireless_setting (NMConnection *connection, GError **error) { NMSettingWireless *s_wireless; - char *tmp, *tmp2; + char *tmp; GBytes *ssid; const guint8 *ssid_data; gsize ssid_len; const char *mode, *bssid; const char *device_mac, *cloned_mac; - char buf[33]; guint32 mtu, chan, i; gboolean adhoc = FALSE, hex_ssid = FALSE; const char * const *macaddr_blacklist; @@ -848,30 +768,29 @@ write_wireless_setting (NMConnection *connection, } device_mac = nm_setting_wireless_get_mac_address (s_wireless); - svSetValue (ifcfg, "HWADDR", device_mac, FALSE); + svSetValueString (ifcfg, "HWADDR", device_mac); cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless); - svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); + svSetValueString (ifcfg, "MACADDR", cloned_mac); - svSetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", - nm_setting_wireless_get_generate_mac_address_mask (s_wireless), - FALSE); + svSetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK", + nm_setting_wireless_get_generate_mac_address_mask (s_wireless)); - svSetValue (ifcfg, "HWADDR_BLACKLIST", NULL, FALSE); + svUnsetValue (ifcfg, "HWADDR_BLACKLIST"); macaddr_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless); if (macaddr_blacklist[0]) { char *blacklist_str; blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); - svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str, FALSE); + svSetValueString (ifcfg, "HWADDR_BLACKLIST", blacklist_str); g_free (blacklist_str); } - svSetValue (ifcfg, "MTU", NULL, FALSE); + svUnsetValue (ifcfg, "MTU"); mtu = nm_setting_wireless_get_mtu (s_wireless); if (mtu) { tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); + svSetValueString (ifcfg, "MTU", tmp); g_free (tmp); } @@ -891,10 +810,23 @@ write_wireless_setting (NMConnection *connection, /* If the SSID contains any non-printable characters, we need to use the * hex notation of the SSID instead. */ - for (i = 0; i < ssid_len; i++) { - if (!g_ascii_isprint (ssid_data[i])) { - hex_ssid = TRUE; - break; + if ( ssid_len > 2 + && ssid_data[0] == '0' + && ssid_data[1] == 'x') { + hex_ssid = TRUE; + for (i = 2; i < ssid_len; i++) { + if (!g_ascii_isxdigit (ssid_data[i])) { + hex_ssid = FALSE; + break; + } + } + } + if (!hex_ssid) { + for (i = 0; i < ssid_len; i++) { + if (!g_ascii_isprint (ssid_data[i])) { + hex_ssid = TRUE; + break; + } } } @@ -906,36 +838,25 @@ write_wireless_setting (NMConnection *connection, g_string_append (str, "0x"); for (i = 0; i < ssid_len; i++) g_string_append_printf (str, "%02X", ssid_data[i]); - svSetValue (ifcfg, "ESSID", str->str, TRUE); + svSetValueString (ifcfg, "ESSID", str->str); g_string_free (str, TRUE); } else { - const char *tmp_escaped; + char buf[33]; - /* Printable SSIDs always get quoted */ - memset (buf, 0, sizeof (buf)); + nm_assert (ssid_len <= 32); memcpy (buf, ssid_data, ssid_len); - tmp_escaped = svEscape (buf, &tmp); - - /* svEscape will usually quote the string, but just for consistency, - * if svEscape doesn't quote the ESSID, we quote it ourselves. - */ - if (tmp_escaped[0] != '"' && tmp_escaped[strlen (tmp_escaped) - 1] != '"') { - tmp2 = g_strdup_printf ("\"%s\"", tmp_escaped); - svSetValue (ifcfg, "ESSID", tmp2, TRUE); - g_free (tmp2); - } else - svSetValue (ifcfg, "ESSID", tmp_escaped, TRUE); - g_free (tmp); + buf[ssid_len] = '\0'; + svSetValueString (ifcfg, "ESSID", buf); } mode = nm_setting_wireless_get_mode (s_wireless); if (!mode || !strcmp (mode, "infrastructure")) { - svSetValue (ifcfg, "MODE", "Managed", FALSE); + svSetValueString (ifcfg, "MODE", "Managed"); } else if (!strcmp (mode, "adhoc")) { - svSetValue (ifcfg, "MODE", "Ad-Hoc", FALSE); + svSetValueString (ifcfg, "MODE", "Ad-Hoc"); adhoc = TRUE; } else if (!strcmp (mode, "ap")) { - svSetValue (ifcfg, "MODE", "Ap", FALSE); + svSetValueString (ifcfg, "MODE", "Ap"); } else { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Invalid mode '%s' in '%s' setting", @@ -943,27 +864,27 @@ write_wireless_setting (NMConnection *connection, return FALSE; } - svSetValue (ifcfg, "CHANNEL", NULL, FALSE); - svSetValue (ifcfg, "BAND", NULL, FALSE); + svUnsetValue (ifcfg, "CHANNEL"); + svUnsetValue (ifcfg, "BAND"); chan = nm_setting_wireless_get_channel (s_wireless); if (chan) { tmp = g_strdup_printf ("%u", chan); - svSetValue (ifcfg, "CHANNEL", tmp, FALSE); + svSetValueString (ifcfg, "CHANNEL", tmp); g_free (tmp); } else { /* Band only set if channel is not, since channel implies band */ - svSetValue (ifcfg, "BAND", nm_setting_wireless_get_band (s_wireless), FALSE); + svSetValueString (ifcfg, "BAND", nm_setting_wireless_get_band (s_wireless)); } bssid = nm_setting_wireless_get_bssid (s_wireless); - svSetValue (ifcfg, "BSSID", bssid, FALSE); + svSetValueString (ifcfg, "BSSID", bssid); /* Ensure DEFAULTKEY and SECURITYMODE are cleared unless there's security; * otherwise there's no way to detect WEP vs. open when WEP keys aren't * saved. */ - svSetValue (ifcfg, "DEFAULTKEY", NULL, FALSE); - svSetValue (ifcfg, "SECURITYMODE", NULL, FALSE); + svUnsetValue (ifcfg, "DEFAULTKEY"); + svUnsetValue (ifcfg, "SECURITYMODE"); if (nm_connection_get_setting_wireless_security (connection)) { if (!write_wireless_security_setting (connection, ifcfg, adhoc, no_8021x, error)) @@ -972,69 +893,69 @@ write_wireless_setting (NMConnection *connection, char *keys_path; /* Clear out wifi security keys */ - svSetValue (ifcfg, "KEY_MGMT", NULL, FALSE); - svSetValue (ifcfg, "IEEE_8021X_IDENTITY", NULL, FALSE); - set_secret (ifcfg, "IEEE_8021X_PASSWORD", NULL, "IEEE_8021X_PASSWORD_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); - svSetValue (ifcfg, "SECURITYMODE", NULL, FALSE); + svUnsetValue (ifcfg, "KEY_MGMT"); + svUnsetValue (ifcfg, "IEEE_8021X_IDENTITY"); + set_secret (ifcfg, "IEEE_8021X_PASSWORD", NULL, "IEEE_8021X_PASSWORD_FLAGS", NM_SETTING_SECRET_FLAG_NONE); + svUnsetValue (ifcfg, "SECURITYMODE"); /* Clear existing keys */ - set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); for (i = 0; i < 4; i++) { tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); g_free (tmp); tmp = g_strdup_printf ("KEY%d", i + 1); - set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE); g_free (tmp); } - svSetValue (ifcfg, "DEFAULTKEY", NULL, FALSE); - svSetValue (ifcfg, "WPA_ALLOW_WPA", NULL, FALSE); - svSetValue (ifcfg, "WPA_ALLOW_WPA2", NULL, FALSE); - svSetValue (ifcfg, "CIPHER_PAIRWISE", NULL, FALSE); - svSetValue (ifcfg, "CIPHER_GROUP", NULL, FALSE); - set_secret (ifcfg, "WPA_PSK", NULL, "WPA_PSK_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + svUnsetValue (ifcfg, "DEFAULTKEY"); + svUnsetValue (ifcfg, "WPA_ALLOW_WPA"); + svUnsetValue (ifcfg, "WPA_ALLOW_WPA2"); + svUnsetValue (ifcfg, "CIPHER_PAIRWISE"); + svUnsetValue (ifcfg, "CIPHER_GROUP"); + set_secret (ifcfg, "WPA_PSK", NULL, "WPA_PSK_FLAGS", NM_SETTING_SECRET_FLAG_NONE); /* Kill any old keys file */ - keys_path = utils_get_keys_path (ifcfg->fileName); + keys_path = utils_get_keys_path (svFileGetName (ifcfg)); (void) unlink (keys_path); g_free (keys_path); } - svSetValue (ifcfg, "SSID_HIDDEN", nm_setting_wireless_get_hidden (s_wireless) ? "yes" : NULL, TRUE); + svSetValueString (ifcfg, "SSID_HIDDEN", nm_setting_wireless_get_hidden (s_wireless) ? "yes" : NULL); switch (nm_setting_wireless_get_powersave (s_wireless)) { case NM_SETTING_WIRELESS_POWERSAVE_IGNORE: - svSetValue (ifcfg, "POWERSAVE", "ignore", TRUE); + svSetValueString (ifcfg, "POWERSAVE", "ignore"); break; case NM_SETTING_WIRELESS_POWERSAVE_DISABLE: - svSetValue (ifcfg, "POWERSAVE", "disable", TRUE); + svSetValueString (ifcfg, "POWERSAVE", "disable"); break; case NM_SETTING_WIRELESS_POWERSAVE_ENABLE: - svSetValue (ifcfg, "POWERSAVE", "enable", TRUE); + svSetValueString (ifcfg, "POWERSAVE", "enable"); break; default: case NM_SETTING_WIRELESS_POWERSAVE_DEFAULT: - svSetValue (ifcfg, "POWERSAVE", NULL, TRUE); + svUnsetValue (ifcfg, "POWERSAVE"); break; } - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", NULL, TRUE); + svUnsetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION"); switch (nm_setting_wireless_get_mac_address_randomization (s_wireless)) { case NM_SETTING_MAC_RANDOMIZATION_DEFAULT: - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "default", TRUE); + svSetValueString (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "default"); break; case NM_SETTING_MAC_RANDOMIZATION_ALWAYS: - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "always", TRUE); + svSetValueString (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "always"); break; default: case NM_SETTING_MAC_RANDOMIZATION_NEVER: - svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "never", TRUE); + svSetValueString (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "never"); break; } - svSetValue (ifcfg, "TYPE", TYPE_WIRELESS, FALSE); + svSetValueString (ifcfg, "TYPE", TYPE_WIRELESS); return TRUE; } @@ -1056,34 +977,32 @@ write_infiniband_setting (NMConnection *connection, shvarFile *ifcfg, GError **e } mac = nm_setting_infiniband_get_mac_address (s_infiniband); - svSetValue (ifcfg, "HWADDR", mac, FALSE); + svSetValueString (ifcfg, "HWADDR", mac); - svSetValue (ifcfg, "MTU", NULL, FALSE); + svUnsetValue (ifcfg, "MTU"); mtu = nm_setting_infiniband_get_mtu (s_infiniband); if (mtu) { tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); + svSetValueString (ifcfg, "MTU", tmp); g_free (tmp); } transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband); - svSetValue (ifcfg, "CONNECTED_MODE", - strcmp (transport_mode, "connected") == 0 ? "yes" : "no", - FALSE); + svSetValueBoolean (ifcfg, "CONNECTED_MODE", nm_streq (transport_mode, "connected")); p_key = nm_setting_infiniband_get_p_key (s_infiniband); if (p_key != -1) { - svSetValue (ifcfg, "PKEY", "yes", FALSE); + svSetValueString (ifcfg, "PKEY", "yes"); tmp = g_strdup_printf ("%u", p_key); - svSetValue (ifcfg, "PKEY_ID", tmp, FALSE); + svSetValueString (ifcfg, "PKEY_ID", tmp); g_free (tmp); parent = nm_setting_infiniband_get_parent (s_infiniband); if (parent) - svSetValue (ifcfg, "PHYSDEV", parent, FALSE); + svSetValueString (ifcfg, "PHYSDEV", parent); } - svSetValue (ifcfg, "TYPE", TYPE_INFINIBAND, FALSE); + svSetValueString (ifcfg, "TYPE", TYPE_INFINIBAND); return TRUE; } @@ -1094,11 +1013,12 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) NMSettingWired *s_wired; const char *device_mac, *cloned_mac; char *tmp; - const char *nettype, *portname, *ctcprot, *s390_key, *s390_val; - guint32 mtu, num_opts, i; + const char *nettype, *portname, *ctcprot, *s390_key, *s390_val, *duplex; + guint32 mtu, num_opts, speed, i; const char *const *s390_subchannels; - GString *str; + GString *str = NULL; const char * const *macaddr_blacklist; + gboolean auto_negotiate; NMSettingWiredWakeOnLan wol; const char *wol_password; @@ -1110,34 +1030,33 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) } device_mac = nm_setting_wired_get_mac_address (s_wired); - svSetValue (ifcfg, "HWADDR", device_mac, FALSE); + svSetValueString (ifcfg, "HWADDR", device_mac); cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); + svSetValueString (ifcfg, "MACADDR", cloned_mac); - svSetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", - nm_setting_wired_get_generate_mac_address_mask (s_wired), - FALSE); + svSetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK", + nm_setting_wired_get_generate_mac_address_mask (s_wired)); - svSetValue (ifcfg, "HWADDR_BLACKLIST", NULL, FALSE); + svUnsetValue (ifcfg, "HWADDR_BLACKLIST"); macaddr_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired); if (macaddr_blacklist[0]) { char *blacklist_str; blacklist_str = g_strjoinv (" ", (char **) macaddr_blacklist); - svSetValue (ifcfg, "HWADDR_BLACKLIST", blacklist_str, FALSE); + svSetValueString (ifcfg, "HWADDR_BLACKLIST", blacklist_str); g_free (blacklist_str); } - svSetValue (ifcfg, "MTU", NULL, FALSE); + svUnsetValue (ifcfg, "MTU"); mtu = nm_setting_wired_get_mtu (s_wired); if (mtu) { tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); + svSetValueString (ifcfg, "MTU", tmp); g_free (tmp); } - svSetValue (ifcfg, "SUBCHANNELS", NULL, FALSE); + svUnsetValue (ifcfg, "SUBCHANNELS"); s390_subchannels = nm_setting_wired_get_s390_subchannels (s_wired); if (s390_subchannels) { int len = g_strv_length ((char **)s390_subchannels); @@ -1149,26 +1068,26 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) tmp = g_strdup_printf ("%s,%s,%s", s390_subchannels[0], s390_subchannels[1], s390_subchannels[2]); } - svSetValue (ifcfg, "SUBCHANNELS", tmp, FALSE); + svSetValueString (ifcfg, "SUBCHANNELS", tmp); g_free (tmp); } - svSetValue (ifcfg, "NETTYPE", NULL, FALSE); + svUnsetValue (ifcfg, "NETTYPE"); nettype = nm_setting_wired_get_s390_nettype (s_wired); if (nettype) - svSetValue (ifcfg, "NETTYPE", nettype, FALSE); + svSetValueString (ifcfg, "NETTYPE", nettype); - svSetValue (ifcfg, "PORTNAME", NULL, FALSE); + svUnsetValue (ifcfg, "PORTNAME"); portname = nm_setting_wired_get_s390_option_by_key (s_wired, "portname"); if (portname) - svSetValue (ifcfg, "PORTNAME", portname, FALSE); + svSetValueString (ifcfg, "PORTNAME", portname); - svSetValue (ifcfg, "CTCPROT", NULL, FALSE); + svUnsetValue (ifcfg, "CTCPROT"); ctcprot = nm_setting_wired_get_s390_option_by_key (s_wired, "ctcprot"); if (ctcprot) - svSetValue (ifcfg, "CTCPROT", ctcprot, FALSE); + svSetValueString (ifcfg, "CTCPROT", ctcprot); - svSetValue (ifcfg, "OPTIONS", NULL, FALSE); + svUnsetValue (ifcfg, "OPTIONS"); num_opts = nm_setting_wired_get_num_s390_options (s_wired); if (s390_subchannels && num_opts) { str = g_string_sized_new (30); @@ -1184,18 +1103,48 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_string_append_printf (str, "%s=%s", s390_key, s390_val); } if (str->len) - svSetValue (ifcfg, "OPTIONS", str->str, FALSE); + svSetValueString (ifcfg, "OPTIONS", str->str); g_string_free (str, TRUE); } + /* Stuff ETHTOOL_OPT with required options */ + str = NULL; + auto_negotiate = nm_setting_wired_get_auto_negotiate (s_wired); + /* autoneg off + speed 0 + duplex NULL, means we want NM + * to skip link configuration which is default. So write + * down link config only if we have auto-negotiate true or + * a valid value for one among speed and duplex. + */ + if (auto_negotiate) { + str = g_string_sized_new (64); + g_string_printf (str, "autoneg on"); + } else { + speed = nm_setting_wired_get_speed (s_wired); + duplex = nm_setting_wired_get_duplex (s_wired); + if (speed || duplex) { + str = g_string_sized_new (64); + g_string_printf (str, "autoneg off"); + if (speed) + g_string_append_printf (str, " speed %u", speed); + if (duplex) + g_string_append_printf (str, " duplex %s", duplex); + } + } + wol = nm_setting_wired_get_wake_on_lan (s_wired); wol_password = nm_setting_wired_get_wake_on_lan_password (s_wired); + if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE) - svSetValueFull (ifcfg, "ETHTOOL_OPTS", "", FALSE); - else if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) - svSetValue (ifcfg, "ETHTOOL_OPTS", NULL, FALSE); - else { - str = g_string_sized_new (30); + svSetValue (ifcfg, "ETHTOOL_WAKE_ON_LAN", "ignore"); + else if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) { + if (!str) + svUnsetValue (ifcfg, "ETHTOOL_OPTS"); + } else { + if (!str) + str = g_string_sized_new (30); + else + g_string_append (str, " "); + g_string_append (str, "wol "); if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_PHY)) @@ -1216,12 +1165,14 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) if (wol_password && NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) g_string_append_printf (str, "s sopass %s", wol_password); - - svSetValue (ifcfg, "ETHTOOL_OPTS", str->str, FALSE); + } + if (str) { + svSetValueString (ifcfg, "ETHTOOL_OPTS", str->str); g_string_free (str, TRUE); } + /* End ETHTOOL_OPT stuffing */ - svSetValue (ifcfg, "TYPE", TYPE_ETHERNET, FALSE); + svSetValueString (ifcfg, "TYPE", TYPE_ETHERNET); return TRUE; } @@ -1263,22 +1214,21 @@ write_wired_for_virtual (NMConnection *connection, shvarFile *ifcfg) has_wired = TRUE; device_mac = nm_setting_wired_get_mac_address (s_wired); - svSetValue (ifcfg, "HWADDR", device_mac, FALSE); + svSetValueString (ifcfg, "HWADDR", device_mac); cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE); + svSetValueString (ifcfg, "MACADDR", cloned_mac); - svSetValue (ifcfg, "GENERATE_MAC_ADDRESS_MASK", - nm_setting_wired_get_generate_mac_address_mask (s_wired), - FALSE); + svSetValueString (ifcfg, "GENERATE_MAC_ADDRESS_MASK", + nm_setting_wired_get_generate_mac_address_mask (s_wired)); mtu = nm_setting_wired_get_mtu (s_wired); if (mtu) { tmp = g_strdup_printf ("%u", mtu); - svSetValue (ifcfg, "MTU", tmp, FALSE); + svSetValueString (ifcfg, "MTU", tmp); g_free (tmp); } else - svSetValue (ifcfg, "MTU", NULL, FALSE); + svUnsetValue (ifcfg, "MTU"); } return has_wired; } @@ -1307,22 +1257,18 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, return FALSE; } - svSetValue (ifcfg, "VLAN", "yes", FALSE); - svSetValue (ifcfg, "TYPE", TYPE_VLAN, FALSE); - svSetValue (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con), FALSE); - svSetValue (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan), FALSE); + svSetValueString (ifcfg, "VLAN", "yes"); + svSetValueString (ifcfg, "TYPE", TYPE_VLAN); + svSetValueString (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con)); + svSetValueString (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan)); tmp = g_strdup_printf ("%d", nm_setting_vlan_get_id (s_vlan)); - svSetValue (ifcfg, "VLAN_ID", tmp, FALSE); + svSetValueString (ifcfg, "VLAN_ID", tmp); g_free (tmp); vlan_flags = nm_setting_vlan_get_flags (s_vlan); - if (vlan_flags & NM_VLAN_FLAG_REORDER_HEADERS) - svSetValue (ifcfg, "REORDER_HDR", "yes", FALSE); - else - svSetValue (ifcfg, "REORDER_HDR", "no", FALSE); - - svSetValue (ifcfg, "GVRP", vlan_flags & NM_VLAN_FLAG_GVRP ? "yes" : "no", FALSE); + svSetValueBoolean (ifcfg, "REORDER_HDR", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)); + svSetValueBoolean (ifcfg, "GVRP", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_GVRP)); nm_utils_strbuf_init (s_buf, &s_buf_ptr, &s_buf_len); @@ -1331,21 +1277,21 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, if (!NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)) nm_utils_strbuf_append (&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : ""); - svSetValue (ifcfg, "VLAN_FLAGS", s_buf, FALSE); + svSetValueString (ifcfg, "VLAN_FLAGS", s_buf); - svSetValue (ifcfg, "MVRP", vlan_flags & NM_VLAN_FLAG_MVRP ? "yes" : "no", FALSE); + svSetValueBoolean (ifcfg, "MVRP", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_MVRP)); tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_INGRESS_MAP); - svSetValue (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", tmp, FALSE); + svSetValueString (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", tmp); g_free (tmp); tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_EGRESS_MAP); - svSetValue (ifcfg, "VLAN_EGRESS_PRIORITY_MAP", tmp, FALSE); + svSetValueString (ifcfg, "VLAN_EGRESS_PRIORITY_MAP", tmp); g_free (tmp); - svSetValue (ifcfg, "HWADDR", NULL, FALSE); - svSetValue (ifcfg, "MACADDR", NULL, FALSE); - svSetValue (ifcfg, "MTU", NULL, FALSE); + svUnsetValue (ifcfg, "HWADDR"); + svUnsetValue (ifcfg, "MACADDR"); + svUnsetValue (ifcfg, "MTU"); *wired = write_wired_for_virtual (connection, ifcfg); @@ -1373,8 +1319,8 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wir return FALSE; } - svSetValue (ifcfg, "DEVICE", iface, FALSE); - svSetValue (ifcfg, "BONDING_OPTS", NULL, FALSE); + svSetValueString (ifcfg, "DEVICE", iface); + svUnsetValue (ifcfg, "BONDING_OPTS"); num_opts = nm_setting_bond_get_num_options (s_bond); if (num_opts > 0) { @@ -1393,13 +1339,13 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wir } if (str->len) - svSetValue (ifcfg, "BONDING_OPTS", str->str, FALSE); + svSetValueString (ifcfg, "BONDING_OPTS", str->str); g_string_free (str, TRUE); } - svSetValue (ifcfg, "TYPE", TYPE_BOND, FALSE); - svSetValue (ifcfg, "BONDING_MASTER", "yes", FALSE); + svSetValueString (ifcfg, "TYPE", TYPE_BOND); + svSetValueString (ifcfg, "BONDING_MASTER", "yes"); *wired = write_wired_for_virtual (connection, ifcfg); @@ -1427,9 +1373,9 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, return FALSE; } - svSetValue (ifcfg, "DEVICE", iface, FALSE); + svSetValueString (ifcfg, "DEVICE", iface); config = nm_setting_team_get_config (s_team); - svSetValue (ifcfg, "TEAM_CONFIG", config, FALSE); + svSetValueString (ifcfg, "TEAM_CONFIG", config); *wired = write_wired_for_virtual (connection, ifcfg); @@ -1495,24 +1441,24 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error return FALSE; } - svSetValue (ifcfg, "DEVICE", iface, FALSE); - svSetValue (ifcfg, "BRIDGING_OPTS", NULL, FALSE); - svSetValue (ifcfg, "STP", "no", FALSE); - svSetValue (ifcfg, "DELAY", NULL, FALSE); + svSetValueString (ifcfg, "DEVICE", iface); + svUnsetValue (ifcfg, "BRIDGING_OPTS"); + svSetValueBoolean (ifcfg, "STP", FALSE); + svUnsetValue (ifcfg, "DELAY"); mac = nm_setting_bridge_get_mac_address (s_bridge); - svSetValue (ifcfg, "MACADDR", mac, FALSE); + svSetValueString (ifcfg, "MACADDR", mac); /* Bridge options */ opts = g_string_sized_new (32); if (nm_setting_bridge_get_stp (s_bridge)) { - svSetValue (ifcfg, "STP", "yes", FALSE); + svSetValueString (ifcfg, "STP", "yes"); i = nm_setting_bridge_get_forward_delay (s_bridge); if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_FORWARD_DELAY)) { s = g_strdup_printf ("%u", i); - svSetValue (ifcfg, "DELAY", s, FALSE); + svSetValueString (ifcfg, "DELAY", s); g_free (s); } @@ -1548,10 +1494,10 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error } if (opts->len) - svSetValue (ifcfg, "BRIDGING_OPTS", opts->str, FALSE); + svSetValueString (ifcfg, "BRIDGING_OPTS", opts->str); g_string_free (opts, TRUE); - svSetValue (ifcfg, "TYPE", TYPE_BRIDGE, FALSE); + svSetValueString (ifcfg, "TYPE", TYPE_BRIDGE); return TRUE; } @@ -1567,7 +1513,7 @@ write_bridge_port_setting (NMConnection *connection, shvarFile *ifcfg, GError ** if (!s_port) return TRUE; - svSetValue (ifcfg, "BRIDGING_OPTS", NULL, FALSE); + svUnsetValue (ifcfg, "BRIDGING_OPTS"); /* Bridge options */ opts = g_string_sized_new (32); @@ -1590,7 +1536,7 @@ write_bridge_port_setting (NMConnection *connection, shvarFile *ifcfg, GError ** } if (opts->len) - svSetValue (ifcfg, "BRIDGING_OPTS", opts->str, FALSE); + svSetValueString (ifcfg, "BRIDGING_OPTS", opts->str); g_string_free (opts, TRUE); return TRUE; @@ -1607,7 +1553,7 @@ write_team_port_setting (NMConnection *connection, shvarFile *ifcfg, GError **er return TRUE; config = nm_setting_team_port_get_config (s_port); - svSetValue (ifcfg, "TEAM_PORT_CONFIG", config, FALSE); + svSetValueString (ifcfg, "TEAM_PORT_CONFIG", config); return TRUE; } @@ -1615,19 +1561,16 @@ write_team_port_setting (NMConnection *connection, shvarFile *ifcfg, GError **er static void write_dcb_flags (shvarFile *ifcfg, const char *tag, NMSettingDcbFlags flags) { - char *prop; + char prop[NM_STRLEN ("DCB_xxxxxxxxxxxxxxxxxxxxxxx_yyyyyyyyyyyyyyyyyyyy")]; - prop = g_strdup_printf ("DCB_%s_ENABLE", tag); - svSetValue (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ENABLE) ? "yes" : NULL, FALSE); - g_free (prop); + nm_sprintf_buf (prop, "DCB_%s_ENABLE", tag); + svSetValueString (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ENABLE) ? "yes" : NULL); - prop = g_strdup_printf ("DCB_%s_ADVERTISE", tag); - svSetValue (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ADVERTISE) ? "yes" : NULL, FALSE); - g_free (prop); + nm_sprintf_buf (prop, "DCB_%s_ADVERTISE", tag); + svSetValueString (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_ADVERTISE) ? "yes" : NULL); - prop = g_strdup_printf ("DCB_%s_WILLING", tag); - svSetValue (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_WILLING) ? "yes" : NULL, FALSE); - g_free (prop); + nm_sprintf_buf (prop, "DCB_%s_WILLING", tag); + svSetValueString (ifcfg, prop, (flags & NM_SETTING_DCB_FLAG_WILLING) ? "yes" : NULL); } static void @@ -1636,16 +1579,15 @@ write_dcb_app (shvarFile *ifcfg, NMSettingDcbFlags flags, gint priority) { - char *prop, *tmp = NULL; + char prop[NM_STRLEN ("DCB_xxxxxxxxxxxxxxxxxxxxxxx_yyyyyyyyyyyyyyyyyyyy")]; write_dcb_flags (ifcfg, tag, flags); + nm_sprintf_buf (prop, "DCB_%s_PRIORITY", tag); if ((flags & NM_SETTING_DCB_FLAG_ENABLE) && (priority >= 0)) - tmp = g_strdup_printf ("%d", priority); - prop = g_strdup_printf ("DCB_%s_PRIORITY", tag); - svSetValue (ifcfg, prop, tmp, FALSE); - g_free (prop); - g_free (tmp); + svSetValueInt64 (ifcfg, prop, priority); + else + svUnsetValue (ifcfg, prop); } typedef gboolean (*DcbGetBoolFunc) (NMSettingDcb *, guint); @@ -1661,14 +1603,14 @@ write_dcb_bool_array (shvarFile *ifcfg, guint i; if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - svSetValue (ifcfg, key, NULL, FALSE); + svUnsetValue (ifcfg, key); return; } str[8] = 0; for (i = 0; i < 8; i++) str[i] = get_func (s_dcb, i) ? '1' : '0'; - svSetValue (ifcfg, key, str, FALSE); + svSetValueString (ifcfg, key, str); } typedef guint (*DcbGetUintFunc) (NMSettingDcb *, guint); @@ -1684,7 +1626,7 @@ write_dcb_uint_array (shvarFile *ifcfg, guint i, num; if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - svSetValue (ifcfg, key, NULL, FALSE); + svUnsetValue (ifcfg, key); return; } @@ -1698,7 +1640,7 @@ write_dcb_uint_array (shvarFile *ifcfg, else g_assert_not_reached (); } - svSetValue (ifcfg, key, str, FALSE); + svSetValueString (ifcfg, key, str); } static void @@ -1712,7 +1654,7 @@ write_dcb_percent_array (shvarFile *ifcfg, guint i; if (!(flags & NM_SETTING_DCB_FLAG_ENABLE)) { - svSetValue (ifcfg, key, NULL, FALSE); + svUnsetValue (ifcfg, key); return; } @@ -1722,7 +1664,7 @@ write_dcb_percent_array (shvarFile *ifcfg, g_string_append_c (str, ','); g_string_append_printf (str, "%d", get_func (s_dcb, i)); } - svSetValue (ifcfg, key, str->str, FALSE); + svSetValueString (ifcfg, key, str->str); g_string_free (str, TRUE); } @@ -1762,19 +1704,19 @@ write_dcb_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) const char **iter; for (iter = clear_keys; *iter; iter++) - svSetValue (ifcfg, *iter, NULL, FALSE); + svUnsetValue (ifcfg, *iter); return TRUE; } - svSetValue (ifcfg, "DCB", "yes", FALSE); + svSetValueString (ifcfg, "DCB", "yes"); write_dcb_app (ifcfg, "APP_FCOE", nm_setting_dcb_get_app_fcoe_flags (s_dcb), nm_setting_dcb_get_app_fcoe_priority (s_dcb)); if (nm_setting_dcb_get_app_fcoe_flags (s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) - svSetValue (ifcfg, KEY_DCB_APP_FCOE_MODE, nm_setting_dcb_get_app_fcoe_mode (s_dcb), FALSE); + svSetValueString (ifcfg, KEY_DCB_APP_FCOE_MODE, nm_setting_dcb_get_app_fcoe_mode (s_dcb)); else - svSetValue (ifcfg, KEY_DCB_APP_FCOE_MODE, NULL, FALSE); + svUnsetValue (ifcfg, KEY_DCB_APP_FCOE_MODE); write_dcb_app (ifcfg, "APP_ISCSI", nm_setting_dcb_get_app_iscsi_flags (s_dcb), @@ -1804,41 +1746,39 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) { guint32 n, i; GString *str; - const char *master, *type; + const char *master, *master_iface = NULL, *type; char *tmp; gint i_int; - const char *v_master = NULL; - const char *v_slave = NULL; - const char *v_bridge = NULL; - const char *v_team_master = NULL; - - svSetValue (ifcfg, "NAME", nm_setting_connection_get_id (s_con), FALSE); - svSetValue (ifcfg, "UUID", nm_setting_connection_get_uuid (s_con), FALSE); - svSetValue (ifcfg, "STABLE_ID", nm_setting_connection_get_stable_id (s_con), FALSE); - svSetValue (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con), FALSE); - svSetValue (ifcfg, "ONBOOT", - nm_setting_connection_get_autoconnect (s_con) ? "yes" : "no", - FALSE); + + svSetValueString (ifcfg, "NAME", nm_setting_connection_get_id (s_con)); + svSetValueString (ifcfg, "UUID", nm_setting_connection_get_uuid (s_con)); + svSetValueString (ifcfg, "STABLE_ID", nm_setting_connection_get_stable_id (s_con)); + svSetValueString (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con)); + svSetValueBoolean (ifcfg, "ONBOOT", nm_setting_connection_get_autoconnect (s_con)); i_int = nm_setting_connection_get_autoconnect_priority (s_con); tmp = i_int != NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT ? g_strdup_printf ("%d", i_int) : NULL; - svSetValue (ifcfg, "AUTOCONNECT_PRIORITY", tmp, FALSE); + svSetValueString (ifcfg, "AUTOCONNECT_PRIORITY", tmp); + g_free (tmp); + + i_int = nm_setting_connection_get_autoconnect_retries (s_con); + tmp = i_int != -1 ? g_strdup_printf ("%d", i_int) : NULL; + svSetValueString (ifcfg, "AUTOCONNECT_RETRIES", tmp); g_free (tmp); /* Only save the value for master connections */ - svSetValue (ifcfg, "AUTOCONNECT_SLAVES", NULL, FALSE); type = nm_setting_connection_get_connection_type (s_con); if ( !g_strcmp0 (type, NM_SETTING_BOND_SETTING_NAME) || !g_strcmp0 (type, NM_SETTING_TEAM_SETTING_NAME) || !g_strcmp0 (type, NM_SETTING_BRIDGE_SETTING_NAME)) { NMSettingConnectionAutoconnectSlaves autoconnect_slaves; autoconnect_slaves = nm_setting_connection_get_autoconnect_slaves (s_con); - svSetValue (ifcfg, "AUTOCONNECT_SLAVES", - autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES ? "yes" : - autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO ? "no" : NULL, - FALSE); - } + svSetValueString (ifcfg, "AUTOCONNECT_SLAVES", + autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES ? "yes" : + autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO ? "no" : NULL); + } else + svUnsetValue (ifcfg, "AUTOCONNECT_SLAVES"); switch (nm_setting_connection_get_lldp (s_con)) { case NM_SETTING_CONNECTION_LLDP_ENABLE_RX: @@ -1850,10 +1790,10 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) default: tmp = NULL; } - svSetValue (ifcfg, "LLDP", tmp, FALSE); + svSetValueString (ifcfg, "LLDP", tmp); /* Permissions */ - svSetValue (ifcfg, "USERS", NULL, FALSE); + svUnsetValue (ifcfg, "USERS"); n = nm_setting_connection_get_num_permissions (s_con); if (n > 0) { str = g_string_sized_new (n * 20); @@ -1870,39 +1810,57 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) if (nm_setting_connection_get_permission (s_con, i, NULL, &puser, NULL)) g_string_append (str, puser); } - svSetValue (ifcfg, "USERS", str->str, FALSE); + svSetValueString (ifcfg, "USERS", str->str); g_string_free (str, TRUE); } - svSetValue (ifcfg, "ZONE", nm_setting_connection_get_zone(s_con), FALSE); + svSetValueString (ifcfg, "ZONE", nm_setting_connection_get_zone(s_con)); + + svSetValueString (ifcfg, "MASTER_UUID", NULL); + svSetValueString (ifcfg, "MASTER", NULL); + svSetValueString (ifcfg, "SLAVE", NULL); + svSetValueString (ifcfg, "BRIDGE_UUID", NULL); + svSetValueString (ifcfg, "BRIDGE", NULL); + svSetValueString (ifcfg, "TEAM_MASTER_UUID", NULL); + svSetValueString (ifcfg, "TEAM_MASTER", NULL); master = nm_setting_connection_get_master (s_con); if (master) { + /* The reader prefers the *_UUID variants, however we still try to resolve + * it into an interface name, so that legacy tooling is not confused. */ + if (!nm_utils_get_testing ()) { + /* This is conditional for easier testing. */ + master_iface = nm_manager_iface_for_uuid (nm_manager_get (), master); + } + if (!master_iface) { + master_iface = master; + master = NULL; + + } + if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BOND_SETTING_NAME)) { - v_master = master; - v_slave = "yes"; - } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BRIDGE_SETTING_NAME)) - v_bridge = master; - else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) { - v_team_master = master; - svSetValue (ifcfg, "TYPE", NULL, FALSE); + svSetValueString (ifcfg, "MASTER_UUID", master); + svSetValueString (ifcfg, "MASTER", master_iface); + svSetValueString (ifcfg, "SLAVE", "yes"); + } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BRIDGE_SETTING_NAME)) { + svSetValueString (ifcfg, "BRIDGE_UUID", master); + svSetValueString (ifcfg, "BRIDGE", master_iface); + } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) { + svSetValueString (ifcfg, "TEAM_MASTER_UUID", master); + svSetValueString (ifcfg, "TEAM_MASTER", master_iface); + svUnsetValue (ifcfg, "TYPE"); } } - svSetValue (ifcfg, "MASTER", v_master, FALSE); - svSetValue (ifcfg, "SLAVE", v_slave, FALSE); - svSetValue (ifcfg, "BRIDGE", v_bridge, FALSE); - svSetValue (ifcfg, "TEAM_MASTER", v_team_master, FALSE); - if (nm_streq0 (type, NM_SETTING_TEAM_SETTING_NAME)) - svSetValue (ifcfg, "DEVICETYPE", TYPE_TEAM, FALSE); - else if (master && nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) - svSetValue (ifcfg, "DEVICETYPE", TYPE_TEAM_PORT, FALSE); + svSetValueString (ifcfg, "DEVICETYPE", TYPE_TEAM); + else if (master_iface && nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) + svSetValueString (ifcfg, "DEVICETYPE", TYPE_TEAM_PORT); else - svSetValue (ifcfg, "DEVICETYPE", NULL, FALSE); + svUnsetValue (ifcfg, "DEVICETYPE"); /* secondary connection UUIDs */ - svSetValue (ifcfg, "SECONDARY_UUIDS", NULL, FALSE); + svUnsetValue (ifcfg, "SECONDARY_UUIDS"); n = nm_setting_connection_get_num_secondaries (s_con); if (n > 0) { str = g_string_sized_new (n * 37); @@ -1919,26 +1877,26 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) if ((uuid = nm_setting_connection_get_secondary (s_con, i)) != NULL) g_string_append (str, uuid); } - svSetValue (ifcfg, "SECONDARY_UUIDS", str->str, FALSE); + svSetValueString (ifcfg, "SECONDARY_UUIDS", str->str); g_string_free (str, TRUE); } - svSetValue (ifcfg, "GATEWAY_PING_TIMEOUT", NULL, FALSE); + svUnsetValue (ifcfg, "GATEWAY_PING_TIMEOUT"); if (nm_setting_connection_get_gateway_ping_timeout (s_con)) { tmp = g_strdup_printf ("%" G_GUINT32_FORMAT, nm_setting_connection_get_gateway_ping_timeout (s_con)); - svSetValue (ifcfg, "GATEWAY_PING_TIMEOUT", tmp, FALSE); + svSetValueString (ifcfg, "GATEWAY_PING_TIMEOUT", tmp); g_free (tmp); } switch (nm_setting_connection_get_metered (s_con)) { case NM_METERED_YES: - svSetValue (ifcfg, "CONNECTION_METERED", "yes", FALSE); + svSetValueString (ifcfg, "CONNECTION_METERED", "yes"); break; case NM_METERED_NO: - svSetValue (ifcfg, "CONNECTION_METERED", "no", FALSE); + svSetValueString (ifcfg, "CONNECTION_METERED", "no"); break; default: - svSetValue (ifcfg, "CONNECTION_METERED", NULL, FALSE); + svUnsetValue (ifcfg, "CONNECTION_METERED"); } } @@ -1998,6 +1956,45 @@ error: } static gboolean +write_proxy_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingProxy *s_proxy; + NMSettingProxyMethod method; + const char *pac_url, *pac_script; + + s_proxy = nm_connection_get_setting_proxy (connection); + if (!s_proxy) + return TRUE; + + svUnsetValue (ifcfg, "BROWSER_ONLY"); + svUnsetValue (ifcfg, "PAC_URL"); + svUnsetValue (ifcfg, "PAC_SCRIPT"); + + method = nm_setting_proxy_get_method (s_proxy); + switch (method) { + case NM_SETTING_PROXY_METHOD_AUTO: + svSetValueString (ifcfg, "PROXY_METHOD", "auto"); + + pac_url = nm_setting_proxy_get_pac_url (s_proxy); + if (pac_url) + svSetValueString (ifcfg, "PAC_URL", pac_url); + + pac_script = nm_setting_proxy_get_pac_script (s_proxy); + if (pac_script) + svSetValueString (ifcfg, "PAC_SCRIPT", pac_script); + + break; + case NM_SETTING_PROXY_METHOD_NONE: + svSetValueString (ifcfg, "PROXY_METHOD", "none"); + break; + } + + svSetValueBoolean (ifcfg, "BROWSER_ONLY", nm_setting_proxy_get_browser_only (s_proxy)); + + return TRUE; +} + +static gboolean write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) { NMSettingIPConfig *s_ip4; @@ -2018,17 +2015,17 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) * * Some IPv4 setting related options are not cleared, * for no strong reason. */ - svSetValue (ifcfg, "BOOTPROTO", NULL, FALSE); + svUnsetValue (ifcfg, "BOOTPROTO"); - svSetValue (ifcfg, "IPADDR", NULL, FALSE); - svSetValue (ifcfg, "PREFIX", NULL, FALSE); - svSetValue (ifcfg, "NETMASK", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY", NULL, FALSE); + svUnsetValue (ifcfg, "IPADDR"); + svUnsetValue (ifcfg, "PREFIX"); + svUnsetValue (ifcfg, "NETMASK"); + svUnsetValue (ifcfg, "GATEWAY"); - svSetValue (ifcfg, "IPADDR0", NULL, FALSE); - svSetValue (ifcfg, "PREFIX0", NULL, FALSE); - svSetValue (ifcfg, "NETMASK0", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY0", NULL, FALSE); + svUnsetValue (ifcfg, "IPADDR0"); + svUnsetValue (ifcfg, "PREFIX0"); + svUnsetValue (ifcfg, "NETMASK0"); + svUnsetValue (ifcfg, "GATEWAY0"); return TRUE; } @@ -2042,7 +2039,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) int result; /* IPv4 disabled, clear IPv4 related parameters */ - svSetValue (ifcfg, "BOOTPROTO", NULL, FALSE); + svUnsetValue (ifcfg, "BOOTPROTO"); for (j = -1; j < 256; j++) { if (j == -1) { addr_key = g_strdup ("IPADDR"); @@ -2056,10 +2053,10 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) gw_key = g_strdup_printf ("GATEWAY%d", j); } - svSetValue (ifcfg, addr_key, NULL, FALSE); - svSetValue (ifcfg, prefix_key, NULL, FALSE); - svSetValue (ifcfg, netmask_key, NULL, FALSE); - svSetValue (ifcfg, gw_key, NULL, FALSE); + svUnsetValue (ifcfg, addr_key); + svUnsetValue (ifcfg, prefix_key); + svUnsetValue (ifcfg, netmask_key); + svUnsetValue (ifcfg, gw_key); g_free (addr_key); g_free (prefix_key); @@ -2067,31 +2064,31 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_free (gw_key); } - route_path = utils_get_route_path (ifcfg->fileName); + route_path = utils_get_route_path (svFileGetName (ifcfg)); result = unlink (route_path); g_free (route_path); return TRUE; } if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) - svSetValue (ifcfg, "BOOTPROTO", "dhcp", FALSE); + svSetValueString (ifcfg, "BOOTPROTO", "dhcp"); else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) - svSetValue (ifcfg, "BOOTPROTO", "none", FALSE); + svSetValueString (ifcfg, "BOOTPROTO", "none"); else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) - svSetValue (ifcfg, "BOOTPROTO", "autoip", FALSE); + svSetValueString (ifcfg, "BOOTPROTO", "autoip"); else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) - svSetValue (ifcfg, "BOOTPROTO", "shared", FALSE); + svSetValueString (ifcfg, "BOOTPROTO", "shared"); /* Clear out un-numbered IP address fields */ - svSetValue (ifcfg, "IPADDR", NULL, FALSE); - svSetValue (ifcfg, "PREFIX", NULL, FALSE); - svSetValue (ifcfg, "NETMASK", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY", NULL, FALSE); + svUnsetValue (ifcfg, "IPADDR"); + svUnsetValue (ifcfg, "PREFIX"); + svUnsetValue (ifcfg, "NETMASK"); + svUnsetValue (ifcfg, "GATEWAY"); /* Clear out zero-indexed IP address fields */ - svSetValue (ifcfg, "IPADDR0", NULL, FALSE); - svSetValue (ifcfg, "PREFIX0", NULL, FALSE); - svSetValue (ifcfg, "NETMASK0", NULL, FALSE); - svSetValue (ifcfg, "GATEWAY0", NULL, FALSE); + svUnsetValue (ifcfg, "IPADDR0"); + svUnsetValue (ifcfg, "PREFIX0"); + svUnsetValue (ifcfg, "NETMASK0"); + svUnsetValue (ifcfg, "GATEWAY0"); /* Write out IPADDR<n>, PREFIX<n>, GATEWAY<n> for current IP addresses * without labels. Unset obsolete NETMASK<n>. @@ -2127,14 +2124,14 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) gw_key = g_strdup_printf ("GATEWAY%d", n); } - svSetValue (ifcfg, addr_key, nm_ip_address_get_address (addr), FALSE); + svSetValueString (ifcfg, addr_key, nm_ip_address_get_address (addr)); tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); - svSetValue (ifcfg, prefix_key, tmp, FALSE); + svSetValueString (ifcfg, prefix_key, tmp); g_free (tmp); - svSetValue (ifcfg, netmask_key, NULL, FALSE); - svSetValue (ifcfg, gw_key, NULL, FALSE); + svUnsetValue (ifcfg, netmask_key); + svUnsetValue (ifcfg, gw_key); g_free (addr_key); g_free (prefix_key); @@ -2150,10 +2147,10 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) netmask_key = g_strdup_printf ("NETMASK%d", n); gw_key = g_strdup_printf ("GATEWAY%d", n); - svSetValue (ifcfg, addr_key, NULL, FALSE); - svSetValue (ifcfg, prefix_key, NULL, FALSE); - svSetValue (ifcfg, netmask_key, NULL, FALSE); - svSetValue (ifcfg, gw_key, NULL, FALSE); + svUnsetValue (ifcfg, addr_key); + svUnsetValue (ifcfg, prefix_key); + svUnsetValue (ifcfg, netmask_key); + svUnsetValue (ifcfg, gw_key); g_free (addr_key); g_free (prefix_key); @@ -2161,7 +2158,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_free (gw_key); } - svSetValue (ifcfg, "GATEWAY", nm_setting_ip_config_get_gateway (s_ip4), FALSE); + svSetValueString (ifcfg, "GATEWAY", nm_setting_ip_config_get_gateway (s_ip4)); num = nm_setting_ip_config_get_num_dns (s_ip4); for (i = 0; i < 254; i++) { @@ -2170,10 +2167,10 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) addr_key = g_strdup_printf ("DNS%d", i + 1); if (i >= num) - svSetValue (ifcfg, addr_key, NULL, FALSE); + svUnsetValue (ifcfg, addr_key); else { dns = nm_setting_ip_config_get_dns (s_ip4, i); - svSetValue (ifcfg, addr_key, dns, FALSE); + svSetValueString (ifcfg, addr_key, dns); } g_free (addr_key); } @@ -2186,74 +2183,60 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_string_append_c (searches, ' '); g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip4, i)); } - svSetValue (ifcfg, "DOMAIN", searches->str, FALSE); + svSetValueString (ifcfg, "DOMAIN", searches->str); g_string_free (searches, TRUE); } else - svSetValue (ifcfg, "DOMAIN", NULL, FALSE); + svUnsetValue (ifcfg, "DOMAIN"); /* DEFROUTE; remember that it has the opposite meaning from never-default */ - svSetValue (ifcfg, "DEFROUTE", - nm_setting_ip_config_get_never_default (s_ip4) ? "no" : "yes", - FALSE); - - svSetValue (ifcfg, "PEERDNS", NULL, FALSE); - svSetValue (ifcfg, "PEERROUTES", NULL, FALSE); - svSetValue (ifcfg, "DHCP_CLIENT_ID", NULL, FALSE); - if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { - svSetValue (ifcfg, "PEERDNS", - nm_setting_ip_config_get_ignore_auto_dns (s_ip4) ? "no" : "yes", - FALSE); - - svSetValue (ifcfg, "PEERROUTES", - nm_setting_ip_config_get_ignore_auto_routes (s_ip4) ? "no" : "yes", - FALSE); - - value = nm_setting_ip_config_get_dhcp_hostname (s_ip4); - if (value) - svSetValue (ifcfg, "DHCP_HOSTNAME", value, FALSE); + svSetValueBoolean (ifcfg, "DEFROUTE", !nm_setting_ip_config_get_never_default (s_ip4)); - value = nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)); - if (value) - svSetValue (ifcfg, "DHCP_FQDN", value, FALSE); + /* Missing PEERDNS means TRUE, so write it only when is FALSE */ + svSetValueString (ifcfg, "PEERDNS", + nm_setting_ip_config_get_ignore_auto_dns (s_ip4) ? "no" : NULL); + /* Missing PEERROUTES means TRUE, so write it only when is FALSE */ + svSetValueString (ifcfg, "PEERROUTES", + nm_setting_ip_config_get_ignore_auto_routes (s_ip4) ? "no" : NULL); - /* Missing DHCP_SEND_HOSTNAME means TRUE, and we prefer not write it explicitly - * in that case, because it is NM-specific variable - */ - svSetValue (ifcfg, "DHCP_SEND_HOSTNAME", - nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) ? NULL : "no", - FALSE); + value = nm_setting_ip_config_get_dhcp_hostname (s_ip4); + svSetValueString (ifcfg, "DHCP_HOSTNAME", value); - value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)); - if (value) - svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE); + value = nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)); + svSetValueString (ifcfg, "DHCP_FQDN", value); - timeout = nm_setting_ip_config_get_dhcp_timeout (s_ip4); - tmp = timeout ? g_strdup_printf ("%d", timeout) : NULL; - svSetValue (ifcfg, "IPV4_DHCP_TIMEOUT", tmp, FALSE); - g_free (tmp); - } + /* Missing DHCP_SEND_HOSTNAME means TRUE, and we prefer not write it explicitly + * in that case, because it is NM-specific variable + */ + svSetValueString (ifcfg, "DHCP_SEND_HOSTNAME", + nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) ? NULL : "no"); + + value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)); + svSetValueString (ifcfg, "DHCP_CLIENT_ID", value); - svSetValue (ifcfg, "IPV4_FAILURE_FATAL", - nm_setting_ip_config_get_may_fail (s_ip4) ? "no" : "yes", - FALSE); + timeout = nm_setting_ip_config_get_dhcp_timeout (s_ip4); + tmp = timeout ? g_strdup_printf ("%d", timeout) : NULL; + svSetValueString (ifcfg, "IPV4_DHCP_TIMEOUT", tmp); + g_free (tmp); + + svSetValueBoolean (ifcfg, "IPV4_FAILURE_FATAL", !nm_setting_ip_config_get_may_fail (s_ip4)); route_metric = nm_setting_ip_config_get_route_metric (s_ip4); tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL; - svSetValue (ifcfg, "IPV4_ROUTE_METRIC", tmp, FALSE); + svSetValueString (ifcfg, "IPV4_ROUTE_METRIC", tmp); g_free (tmp); /* Static routes - route-<name> file */ - route_path = utils_get_route_path (ifcfg->fileName); + route_path = utils_get_route_path (svFileGetName (ifcfg)); if (!route_path) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not get route file path for '%s'", ifcfg->fileName); + "Could not get route file path for '%s'", svFileGetName (ifcfg)); return FALSE; } if (utils_has_route_file_new_syntax (route_path)) { shvarFile *routefile; - routefile = utils_get_route_ifcfg (ifcfg->fileName, TRUE); + routefile = utils_get_route_ifcfg (svFileGetName (ifcfg), TRUE); if (!routefile) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create route file '%s'", route_path); @@ -2275,29 +2258,29 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) metric_key = g_strdup_printf ("METRIC%d", i); if (i >= num) { - svSetValue (routefile, addr_key, NULL, FALSE); - svSetValue (routefile, netmask_key, NULL, FALSE); - svSetValue (routefile, gw_key, NULL, FALSE); - svSetValue (routefile, metric_key, NULL, FALSE); + svUnsetValue (routefile, addr_key); + svUnsetValue (routefile, netmask_key); + svUnsetValue (routefile, gw_key); + svUnsetValue (routefile, metric_key); } else { route = nm_setting_ip_config_get_route (s_ip4, i); - svSetValue (routefile, addr_key, nm_ip_route_get_dest (route), FALSE); + svSetValueString (routefile, addr_key, nm_ip_route_get_dest (route)); memset (buf, 0, sizeof (buf)); netmask = nm_utils_ip4_prefix_to_netmask (nm_ip_route_get_prefix (route)); inet_ntop (AF_INET, (const void *) &netmask, &buf[0], sizeof (buf)); - svSetValue (routefile, netmask_key, &buf[0], FALSE); + svSetValueString (routefile, netmask_key, &buf[0]); - svSetValue (routefile, gw_key, nm_ip_route_get_next_hop (route), FALSE); + svSetValueString (routefile, gw_key, nm_ip_route_get_next_hop (route)); memset (buf, 0, sizeof (buf)); metric = nm_ip_route_get_metric (route); if (metric == -1) - svSetValue (routefile, metric_key, NULL, FALSE); + svUnsetValue (routefile, metric_key); else { tmp = g_strdup_printf ("%u", (guint32) metric); - svSetValue (routefile, metric_key, tmp, FALSE); + svSetValueString (routefile, metric_key, tmp); g_free (tmp); } } @@ -2321,9 +2304,9 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) timeout = nm_setting_ip_config_get_dad_timeout (s_ip4); if (timeout < 0) - svSetValue (ifcfg, "ARPING_WAIT", NULL, FALSE); + svUnsetValue (ifcfg, "ARPING_WAIT"); else if (timeout == 0) - svSetValue (ifcfg, "ARPING_WAIT", "0", FALSE); + svSetValueString (ifcfg, "ARPING_WAIT", "0"); else { /* Round the value up to next integer */ svSetValueInt64 (ifcfg, "ARPING_WAIT", (timeout - 1) / 1000 + 1); @@ -2333,7 +2316,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) if (priority) svSetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", priority); else - svSetValue (ifcfg, "IPV4_DNS_PRIORITY", NULL, FALSE); + svUnsetValue (ifcfg, "IPV4_DNS_PRIORITY"); return TRUE; } @@ -2410,13 +2393,13 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) ifcfg = svCreateFile (path); g_free (path); - svSetValue (ifcfg, "DEVICE", label, FALSE); + svSetValueString (ifcfg, "DEVICE", label); addr = nm_setting_ip_config_get_address (s_ip4, i); - svSetValue (ifcfg, "IPADDR", nm_ip_address_get_address (addr), FALSE); + svSetValueString (ifcfg, "IPADDR", nm_ip_address_get_address (addr)); tmp = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr)); - svSetValue (ifcfg, "PREFIX", tmp, FALSE); + svSetValueString (ifcfg, "PREFIX", tmp); g_free (tmp); svWriteFile (ifcfg, 0644, NULL); @@ -2478,6 +2461,23 @@ error: return success; } +static void +write_ip6_setting_dhcp_hostname (NMSettingIPConfig *s_ip6, shvarFile *ifcfg) +{ + const char *hostname; + + hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6); + svSetValueString (ifcfg, "DHCPV6_HOSTNAME", hostname); + + /* Missing DHCPV6_SEND_HOSTNAME means TRUE, and we prefer not write it + * explicitly in that case, because it is NM-specific variable + */ + if (nm_setting_ip_config_get_dhcp_send_hostname (s_ip6)) + svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME"); + else + svSetValueString (ifcfg, "DHCPV6_SEND_HOSTNAME", "no"); +} + static gboolean write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) { @@ -2502,50 +2502,50 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) * * Some IPv6 setting related options are not cleared, * for no strong reason. */ - svSetValue (ifcfg, "IPV6INIT", NULL, FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", NULL, FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - svSetValue (ifcfg, "IPV6_DEFROUTE", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PEERDNS", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PEERROUTES", NULL, FALSE); - svSetValue (ifcfg, "IPV6_FAILURE_FATAL", NULL, FALSE); - svSetValue (ifcfg, "IPV6_ROUTE_METRIC", NULL, FALSE); - svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", NULL, FALSE); + svUnsetValue (ifcfg, "IPV6INIT"); + svUnsetValue (ifcfg, "IPV6_AUTOCONF"); + svUnsetValue (ifcfg, "DHCPV6C"); + svUnsetValue (ifcfg, "DHCPV6_HOSTNAME"); + svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME"); + svUnsetValue (ifcfg, "IPV6_DEFROUTE"); + svUnsetValue (ifcfg, "IPV6_PEERDNS"); + svUnsetValue (ifcfg, "IPV6_PEERROUTES"); + svUnsetValue (ifcfg, "IPV6_FAILURE_FATAL"); + svUnsetValue (ifcfg, "IPV6_ROUTE_METRIC"); + svUnsetValue (ifcfg, "IPV6_ADDR_GEN_MODE"); return TRUE; } value = nm_setting_ip_config_get_method (s_ip6); g_assert (value); if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { - svSetValue (ifcfg, "IPV6INIT", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); + svSetValueString (ifcfg, "IPV6INIT", "no"); + svUnsetValue (ifcfg, "DHCPV6C"); return TRUE; } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "yes", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "yes"); + svUnsetValue (ifcfg, "DHCPV6C"); } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) { - const char *hostname; - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", "yes", FALSE); - hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6); - if (hostname) - svSetValue (ifcfg, "DHCP_HOSTNAME", hostname, FALSE); + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "no"); + svSetValueString (ifcfg, "DHCPV6C", "yes"); } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "no"); + svUnsetValue (ifcfg, "DHCPV6C"); } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "IPV6_AUTOCONF", "no", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "no"); + svUnsetValue (ifcfg, "DHCPV6C"); } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { - svSetValue (ifcfg, "IPV6INIT", "yes", FALSE); - svSetValue (ifcfg, "DHCPV6C", NULL, FALSE); - /* TODO */ + svSetValueString (ifcfg, "IPV6INIT", "yes"); + svSetValueString (ifcfg, "IPV6_AUTOCONF", "shared"); + svUnsetValue (ifcfg, "DHCPV6C"); } + write_ip6_setting_dhcp_hostname (s_ip6, ifcfg); + /* Write out IP addresses */ num = nm_setting_ip_config_get_num_addresses (s_ip6); ip_str1 = g_string_new (NULL); @@ -2564,9 +2564,9 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) nm_ip_address_get_address (addr), nm_ip_address_get_prefix (addr)); } - svSetValue (ifcfg, "IPV6ADDR", ip_str1->str, FALSE); - svSetValue (ifcfg, "IPV6ADDR_SECONDARIES", ip_str2->str, FALSE); - svSetValue (ifcfg, "IPV6_DEFAULTGW", nm_setting_ip_config_get_gateway (s_ip6), FALSE); + svSetValueString (ifcfg, "IPV6ADDR", ip_str1->str); + svSetValueString (ifcfg, "IPV6ADDR_SECONDARIES", ip_str2->str); + svSetValueString (ifcfg, "IPV6_DEFAULTGW", nm_setting_ip_config_get_gateway (s_ip6)); g_string_free (ip_str1, TRUE); g_string_free (ip_str2, TRUE); @@ -2578,10 +2578,10 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) addr_key = g_strdup_printf ("DNS%d", i + num4 + 1); if (i >= num) - svSetValue (ifcfg, addr_key, NULL, FALSE); + svUnsetValue (ifcfg, addr_key); else { dns = nm_setting_ip_config_get_dns (s_ip6, i); - svSetValue (ifcfg, addr_key, dns, FALSE); + svSetValueString (ifcfg, addr_key, dns); } g_free (addr_key); } @@ -2590,59 +2590,53 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) num = nm_setting_ip_config_get_num_dns_searches (s_ip6); if (num > 0) { char *ip4_domains; - ip4_domains = svGetValue (ifcfg, "DOMAIN", FALSE); + ip4_domains = svGetValueString (ifcfg, "DOMAIN"); searches = g_string_new (ip4_domains); for (i = 0; i < num; i++) { if (searches->len > 0) g_string_append_c (searches, ' '); g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip6, i)); } - svSetValue (ifcfg, "DOMAIN", searches->str, FALSE); + svSetValueString (ifcfg, "DOMAIN", searches->str); g_string_free (searches, TRUE); g_free (ip4_domains); } + /* handle IPV6_DEFROUTE */ /* IPV6_DEFROUTE has the opposite meaning from 'never-default' */ if (nm_setting_ip_config_get_never_default(s_ip6)) - svSetValue (ifcfg, "IPV6_DEFROUTE", "no", FALSE); + svSetValueString (ifcfg, "IPV6_DEFROUTE", "no"); else - svSetValue (ifcfg, "IPV6_DEFROUTE", "yes", FALSE); + svSetValueString (ifcfg, "IPV6_DEFROUTE", "yes"); - svSetValue (ifcfg, "IPV6_PEERDNS", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PEERROUTES", NULL, FALSE); - if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { - svSetValue (ifcfg, "IPV6_PEERDNS", - nm_setting_ip_config_get_ignore_auto_dns (s_ip6) ? "no" : "yes", - FALSE); + svSetValueString (ifcfg, "IPV6_PEERDNS", + nm_setting_ip_config_get_ignore_auto_dns (s_ip6) ? "no" : NULL); - svSetValue (ifcfg, "IPV6_PEERROUTES", - nm_setting_ip_config_get_ignore_auto_routes (s_ip6) ? "no" : "yes", - FALSE); - } + svSetValueString (ifcfg, "IPV6_PEERROUTES", + nm_setting_ip_config_get_ignore_auto_routes (s_ip6) ? "no" : NULL); - svSetValue (ifcfg, "IPV6_FAILURE_FATAL", - nm_setting_ip_config_get_may_fail (s_ip6) ? "no" : "yes", - FALSE); + svSetValueString (ifcfg, "IPV6_FAILURE_FATAL", + nm_setting_ip_config_get_may_fail (s_ip6) ? "no" : "yes"); route_metric = nm_setting_ip_config_get_route_metric (s_ip6); tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL; - svSetValue (ifcfg, "IPV6_ROUTE_METRIC", tmp, FALSE); + svSetValueString (ifcfg, "IPV6_ROUTE_METRIC", tmp); g_free (tmp); /* IPv6 Privacy Extensions */ - svSetValue (ifcfg, "IPV6_PRIVACY", NULL, FALSE); - svSetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", NULL, FALSE); + svUnsetValue (ifcfg, "IPV6_PRIVACY"); + svUnsetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP"); switch (nm_setting_ip6_config_get_ip6_privacy (NM_SETTING_IP6_CONFIG (s_ip6))){ case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: - svSetValue (ifcfg, "IPV6_PRIVACY", "no", FALSE); + svSetValueString (ifcfg, "IPV6_PRIVACY", "no"); break; case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: - svSetValue (ifcfg, "IPV6_PRIVACY", "rfc3041", FALSE); - svSetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", "yes", FALSE); + svSetValueString (ifcfg, "IPV6_PRIVACY", "rfc3041"); + svSetValueString (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", "yes"); break; case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: - svSetValue (ifcfg, "IPV6_PRIVACY", "rfc3041", FALSE); + svSetValueString (ifcfg, "IPV6_PRIVACY", "rfc3041"); break; default: break; @@ -2653,27 +2647,27 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) 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); + svSetValueString (ifcfg, "IPV6_ADDR_GEN_MODE", tmp); g_free (tmp); } else { - svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", NULL, FALSE); + svUnsetValue (ifcfg, "IPV6_ADDR_GEN_MODE"); } /* IPv6 tokenized interface identifier */ value = nm_setting_ip6_config_get_token (NM_SETTING_IP6_CONFIG (s_ip6)); - svSetValue (ifcfg, "IPV6_TOKEN", value, FALSE); + svSetValueString (ifcfg, "IPV6_TOKEN", value); priority = nm_setting_ip_config_get_dns_priority (s_ip6); if (priority) svSetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", priority); else - svSetValue (ifcfg, "IPV6_DNS_PRIORITY", NULL, FALSE); + svUnsetValue (ifcfg, "IPV6_DNS_PRIORITY"); /* Static routes go to route6-<dev> file */ - route6_path = utils_get_route6_path (ifcfg->fileName); + route6_path = utils_get_route6_path (svFileGetName (ifcfg)); if (!route6_path) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not get route6 file path for '%s'", ifcfg->fileName); + "Could not get route6 file path for '%s'", svFileGetName (ifcfg)); goto error; } write_route6_file (route6_path, s_ip6, error); @@ -2708,7 +2702,7 @@ write_res_options (NMConnection *connection, shvarFile *ifcfg, GError **error) if (!s_ip4) { /* slave-type: clear res-options */ - svSetValue (ifcfg, "RES_OPTIONS", NULL, FALSE); + svUnsetValue (ifcfg, "RES_OPTIONS"); return TRUE; } @@ -2738,10 +2732,10 @@ write_res_options (NMConnection *connection, shvarFile *ifcfg, GError **error) g_string_append_c (value, ' '); g_string_append (value, array->pdata[i]); } - svSetValueFull (ifcfg, "RES_OPTIONS", value->str, FALSE); + svSetValue (ifcfg, "RES_OPTIONS", value->str); g_string_free (value, TRUE); } else - svSetValue (ifcfg, "RES_OPTIONS", NULL, FALSE); + svUnsetValue (ifcfg, "RES_OPTIONS"); return TRUE; } @@ -2768,7 +2762,6 @@ static gboolean write_connection (NMConnection *connection, const char *ifcfg_dir, const char *filename, - const char *keyfile, char **out_filename, GError **error) { @@ -2887,8 +2880,11 @@ write_connection (NMConnection *connection, if (!write_dcb_setting (connection, ifcfg, error)) goto out; - svSetValue (ifcfg, "DHCP_HOSTNAME", NULL, FALSE); - svSetValue (ifcfg, "DHCP_FQDN", NULL, FALSE); + if (!write_proxy_setting (connection, ifcfg, error)) + goto out; + + svUnsetValue (ifcfg, "DHCP_HOSTNAME"); + svUnsetValue (ifcfg, "DHCP_FQDN"); if (!write_ip4_setting (connection, ifcfg, error)) goto out; @@ -2949,14 +2945,13 @@ writer_new_connection (NMConnection *connection, char **out_filename, GError **error) { - return write_connection (connection, ifcfg_dir, NULL, NULL, out_filename, error); + return write_connection (connection, ifcfg_dir, NULL, out_filename, error); } gboolean writer_update_connection (NMConnection *connection, const char *ifcfg_dir, const char *filename, - const char *keyfile, GError **error) { if (utils_has_complex_routes (filename)) { @@ -2965,6 +2960,6 @@ writer_update_connection (NMConnection *connection, return FALSE; } - return write_connection (connection, ifcfg_dir, filename, keyfile, NULL, error); + return write_connection (connection, ifcfg_dir, filename, NULL, error); } diff --git a/src/settings/plugins/ifcfg-rh/writer.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h index 97a9f252..2662f79b 100644 --- a/src/settings/plugins/ifcfg-rh/writer.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h @@ -34,7 +34,6 @@ gboolean writer_new_connection (NMConnection *connection, gboolean writer_update_connection (NMConnection *connection, const char *ifcfg_dir, const char *filename, - const char *keyfile, GError **error); #endif /* _WRITER_H_ */ diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index a865c7df..65bcc0d9 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -37,292 +37,901 @@ #include <unistd.h> #include "nm-core-internal.h" +#include "nm-core-utils.h" + +/*****************************************************************************/ + +typedef struct { + /* There are three cases: + * + * 1) the line is not a valid variable assignment (that is, it doesn't + * start with a "FOO=" with possible whitespace prefix). + * In that case, @key and @key_with_prefix are %NULL, and the entire + * original line is in @line. Such entries are ignored for the most part. + * + * 2) if the line can be parsed with a "FOO=" assignment, then @line contains + * the part after '=', @key_with_prefix contains the key "FOO" with possible + * whitespace prefix, and @key points into @key_with_prefix skipping over the + * whitespace. + * + * 3) like 2, but if the value was deleted via svSetValue(), the entry is not removed, + * but only marked for deletion. That is done by clearing @line but preserving + * @key/@key_with_prefix. + * */ + char *line; + const char *key; + char *key_with_prefix; +} shvarLine; -/* Open the file <name>, returning a shvarFile on success and NULL on failure. - * Add a wrinkle to let the caller specify whether or not to create the file - * (actually, return a structure anyway) if it doesn't exist. +struct _shvarFile { + char *fileName; + int fd; + GList *lineList; + gboolean modified; +}; + +/*****************************************************************************/ + +/** + * svParseBoolean: + * @value: the input string + * @fallback: the fallback value + * + * Parses a string and returns the boolean value it contains or, + * in case no valid value is found, the fallback value. Valid values + * are: "yes", "true", "t", "y", "1" and "no", "false", "f", "n", "0". + * + * Returns: the parsed boolean value or @fallback. */ -static shvarFile * -svOpenFileInternal (const char *name, gboolean create, GError **error) +gint +svParseBoolean (const char *value, gint fallback) { - shvarFile *s = NULL; - gboolean closefd = FALSE; - int errsv = 0; + if (!value) + return fallback; - s = g_slice_new0 (shvarFile); + if ( !g_ascii_strcasecmp ("yes", value) + || !g_ascii_strcasecmp ("true", value) + || !g_ascii_strcasecmp ("t", value) + || !g_ascii_strcasecmp ("y", value) + || !g_ascii_strcasecmp ("1", value)) + return TRUE; + else if ( !g_ascii_strcasecmp ("no", value) + || !g_ascii_strcasecmp ("false", value) + || !g_ascii_strcasecmp ("f", value) + || !g_ascii_strcasecmp ("n", value) + || !g_ascii_strcasecmp ("0", value)) + return FALSE; - s->fd = -1; - if (create) - s->fd = open (name, O_RDWR | O_CLOEXEC); /* NOT O_CREAT */ + return fallback; +} - if (!create || s->fd == -1) { - /* try read-only */ - s->fd = open (name, O_RDONLY | O_CLOEXEC); /* NOT O_CREAT */ - if (s->fd == -1) - errsv = errno; - else - closefd = TRUE; - } - s->fileName = g_strdup (name); +/*****************************************************************************/ - if (s->fd != -1) { - struct stat buf; - char *arena, *p, *q; - ssize_t nread, total = 0; +static gboolean +_shell_is_name (const char *key, gssize len) +{ + gssize i; - if (fstat (s->fd, &buf) < 0) { - errsv = errno; - goto bail; + /* whether @key is a valid identifier (name). */ + if (!key || len == 0) + return FALSE; + if ( !g_ascii_isalpha (key[0]) + && key[0] != '_') + return FALSE; + for (i = 1; TRUE; i++) { + if (len < 0) { + if (!key[i]) + return TRUE; + } else { + if (i >= len) + return TRUE; } - arena = g_malloc (buf.st_size + 1); - arena[buf.st_size] = '\0'; + if ( !g_ascii_isalnum (key[i]) + && key[i] != '_') + return FALSE; + } +} - while (total < buf.st_size) { - nread = read (s->fd, arena + total, buf.st_size - total); - if (nread == -1 && errno == EINTR) - continue; - if (nread <= 0) { - errsv = errno; - g_free (arena); - goto bail; - } - total += nread; - } +/*****************************************************************************/ + +/* like g_strescape(), except that it also escapes '\''' *sigh*. + * + * While at it, add $''. */ +static char * +_escape_ansic (const char *source) +{ + const char *p; + gchar *dest; + gchar *q; + + nm_assert (source); - /* we'd use g_strsplit() here, but we want a list, not an array */ - for (p = arena; (q = strchr (p, '\n')) != NULL; p = q + 1) - s->lineList = g_list_append (s->lineList, g_strndup (p, q - p)); - g_free (arena); - - /* closefd is set if we opened the file read-only, so go ahead and - * close it, because we can't write to it anyway - */ - if (closefd) { - close (s->fd); - s->fd = -1; + p = (const char *) source; + /* Each source byte needs maximally four destination chars (\777) */ + q = dest = g_malloc (strlen (source) * 4 + 1 + 3); + + *q++ = '$'; + *q++ = '\''; + + while (*p) { + switch (*p) { + case '\b': + *q++ = '\\'; + *q++ = 'b'; + break; + case '\f': + *q++ = '\\'; + *q++ = 'f'; + break; + case '\n': + *q++ = '\\'; + *q++ = 'n'; + break; + case '\r': + *q++ = '\\'; + *q++ = 'r'; + break; + case '\t': + *q++ = '\\'; + *q++ = 't'; + break; + case '\v': + *q++ = '\\'; + *q++ = 'v'; + break; + case '\\': + case '"': + case '\'': + *q++ = '\\'; + *q++ = *p; + break; + default: + if ((*p < ' ') || (*p >= 0177)) { + *q++ = '\\'; + *q++ = '0' + (((*p) >> 6) & 07); + *q++ = '0' + (((*p) >> 3) & 07); + *q++ = '0' + ((*p) & 07); + } else + *q++ = *p; + break; } + p++; + } + *q++ = '\''; + *q++ = '\0'; + + nm_assert (q - dest <= strlen (source) * 4 + 1 + 3); + + return dest; +} + +/*****************************************************************************/ + +#define _char_req_escape(ch) NM_IN_SET (ch, '\"', '\\', '$', '`') +#define _char_req_escape_old(ch) NM_IN_SET (ch, '\"', '\\', '\'', '$', '`', '~') +#define _char_req_quotes(ch) NM_IN_SET (ch, ' ', '\'', '~', '\t', '|', '&', ';', '(', ')', '<', '>') + +const char * +svEscape (const char *s, char **to_free) +{ + char *new; + gsize mangle = 0; + gboolean requires_quotes = FALSE; + int newlen; + size_t i, j, slen; + slen = strlen (s); + + for (i = 0; i < slen; i++) { + if (_char_req_escape (s[i])) + mangle++; + else if (_char_req_quotes (s[i])) + requires_quotes = TRUE; + else if (s[i] < ' ') { + /* if the string contains newline we can only express it using ANSI C quotation + * (as we don't support line continuation). + * Additionally, ANSI control characters look odd with regular quotation, so handle + * them too. */ + return (*to_free = _escape_ansic (s)); + } + } + if (!mangle && !requires_quotes) { + *to_free = NULL; return s; } - if (create) - return s; + newlen = slen + mangle + 3; /* 3 is extra ""\0 */ + new = g_malloc (newlen); - bail: - if (s->fd != -1) - close (s->fd); - g_free (s->fileName); - g_slice_free (shvarFile, s); + j = 0; + new[j++] = '"'; + for (i = 0; i < slen; i++) { + if (_char_req_escape (s[i])) + new[j++] = '\\'; + new[j++] = s[i]; + } + new[j++] = '"'; + new[j++] = '\0'; - g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), - "Could not read file '%s': %s", - name, errsv ? strerror (errsv) : "Unknown error"); - return NULL; + nm_assert (j == slen + mangle + 3); + + *to_free = new; + return new; } -/* Open the file <name>, return shvarFile on success, NULL on failure */ -shvarFile * -svOpenFile (const char *name, GError **error) +static gboolean +_looks_like_old_svescaped (const char *value) { - return svOpenFileInternal (name, FALSE, error); + gsize k; + + if (value[0] != '"') + return FALSE; + + for (k = 1; ; k++) { + if (value[k] == '\0') + return FALSE; + if (!_char_req_escape_old (value[k])) + continue; + + if (value[k] == '"') + return (value[k + 1] == '\0'); + else if (value[k] == '\\') { + k++; + if (!_char_req_escape_old (value[k])) + return FALSE; + } else + return FALSE; + } } -/* Create a new file structure, returning actual data if the file exists, - * and a suitable starting point if it doesn't. - */ -shvarFile * -svCreateFile (const char *name) +static gboolean +_ch_octal_is (char ch) { - return svOpenFileInternal (name, TRUE, NULL); + return ch >= '0' && ch < '8'; } -/* remove escaped characters in place */ -void -svUnescape (char *s) +static guint8 +_ch_octal_get (char ch) { - size_t len, idx_rd = 0, idx_wr = 0; - char c; + nm_assert (_ch_octal_is (ch)); + return (ch - '0'); +} - len = strlen (s); - if (len < 2) { - if (s[0] == '\\') - s[0] = '\0'; - return; +static gboolean +_ch_hex_is (char ch) +{ + return g_ascii_isxdigit (ch); +} + +static guint8 +_ch_hex_get (char ch) +{ + nm_assert (_ch_hex_is (ch)); + return ch <= '9' ? ch - '0' : (ch & 0x4F) - 'A' + 10; +} + +static void +_gstr_init (GString **str, const char *value, gsize i) +{ + nm_assert (str); + nm_assert (value); + + if (!(*str)) { + /* if @str is not yet initialized, it allocates + * a new GString and copies @i characters from + * @value over. + * + * Unescaping usually does not extend the length of a string, + * so we might be tempted to allocate a fixed buffer of length + * (strlen(value)+CONST). + * However, due to $'\Ux' escapes, the maxium length is some + * (FACTOR*strlen(value) + CONST), which is non trivial to get + * right in all cases. Also, we would have to provision for the + * very unlikely extreme case. + * Instead, use a GString buffer which can grow as needed. But for an + * initial guess, strlen(value) is a good start */ + *str = g_string_new_len (NULL, strlen (value) + 3); + if (i) + g_string_append_len (*str, value, i); } +} + +const char * +svUnescape (const char *value, char **to_free) +{ + gsize i, j; + GString *str = NULL; + int looks_like_old_svescaped = -1; + + /* we handle bash syntax here (note that ifup has #!/bin/bash. + * Thus, see https://www.gnu.org/software/bash/manual/html_node/Quoting.html#Quoting */ + + /* @value shall start with the first character after "FOO=" */ + + nm_assert (value); + nm_assert (to_free); + + /* we don't expect any newlines. They must be filtered out before-hand. + * We also don't support line continuation. */ + nm_assert (!NM_STRCHAR_ANY (value, ch, ch == '\n')); + + i = 0; + while (TRUE) { + + if (value[i] == '\0') + goto out_value; + + if ( g_ascii_isspace (value[i]) + || value[i] == ';') { + gboolean has_semicolon = (value[i] == ';'); + + /* starting with space is only allowed, if the entire + * string consists of spaces (possibly terminated by a comment). + * This disallows for example + * LANG=C ls -1 + * LANG= ls -1 + * but allows + * LANG= #comment + * + * As a special case, we also allow one trailing semicolon, as long + * it is only followed by whitespace or a #-comment. + * FOO=; + * FOO=a; + * FOO=b ; #hallo + */ + j = i + 1; + while ( g_ascii_isspace (value[j]) + || ( !has_semicolon + && (has_semicolon = (value[j] == ';')))) + j++; + if (!NM_IN_SET (value[j], '\0', '#')) + goto out_error; + goto out_value; + } - if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) { - if (len == 2) { - s[0] = '\0'; - return; + if (value[i] == '\\') { + /* backslash escape */ + _gstr_init (&str, value, i); + i++; + if (G_UNLIKELY (value[i] == '\0')) { + /* we don't support line continuation */ + goto out_error; + } + g_string_append_c (str, value[i]); + i++; + goto loop1_next; } - if (len == 3) { - if (s[1] == '\\') { - s[0] = '\0'; - } else { - s[0] = s[1]; - s[1] = '\0'; + + if (value[i] == '\'') { + /* single quotes */ + _gstr_init (&str, value, i); + i++; + j = i; + while (TRUE) { + if (value[j] == '\0') { + /* unterminated single quote. We don't support line continuation */ + goto out_error; + } + if (value[j] == '\'') + break; + j++; } - return; + g_string_append_len (str, &value[i], j - i); + i = j + 1; + goto loop1_next; } - s[--len] = '\0'; - idx_rd = 1; - } else { - /* seek for the first escape... */ - char *p = strchr (s, '\\'); - - if (!p) - return; - if (p[1] == '\0') { - p[0] = '\0'; - return; + + if (value[i] == '"') { + /* double quotes */ + _gstr_init (&str, value, i); + i++; + while (TRUE) { + if (value[i] == '"') { + i++; + break; + } + if (value[i] == '\0') { + /* unterminated double quote. We don't support line continuation. */ + goto out_error; + } + if (NM_IN_SET (value[i], '`', '$')) { + /* we don't support shell expansion. */ + goto out_error; + } + if (value[i] == '\\') { + i++; + if (value[i] == '\0') { + /* we don't support line continuation */ + goto out_error; + } + if (NM_IN_SET (value[i], '$', '`', '"', '\\')) { + /* Drop the backslash. */ + } else if (NM_IN_SET (value[i], '\'', '~')) { + /* '\'' and '~' in double qoutes are not handled special by shell. + * However, old versions of svEscape() would wrongly use double-quoting + * with backslash escaping for these characters (expecting svUnescape() + * to remove the backslash). + * + * In order to preserve previous behavior, we continue to read such + * strings different then shell does. */ + + /* Actually, we can relax this. Old svEscape() escaped the entire value + * in a particular way with double quotes. + * If the value doesn't exactly look like something as created by svEscape(), + * don't do the compat hack and preserve the backslash. */ + if (looks_like_old_svescaped < 0) + looks_like_old_svescaped = _looks_like_old_svescaped (value); + if (!looks_like_old_svescaped) + g_string_append_c (str, '\\'); + } else + g_string_append_c (str, '\\'); + } + g_string_append_c (str, value[i]); + i++; + } + goto loop1_next; } - idx_wr = idx_rd = (p - s); - } - /* idx_rd points to the first escape. Walk the string and shift the - * characters from idx_rd to idx_wr. - */ - while ((c = s[idx_rd++])) { - if (c == '\\') { - if (s[idx_rd] == '\0') { - s[idx_wr] = '\0'; - return; + if ( value[i] == '$' + && value[i + 1] == '\'') { + /* ANSI-C Quoting */ + _gstr_init (&str, value, i); + i += 2; + while (TRUE) { + char ch; + + if (value[i] == '\'') { + i++; + break; + } + if (value[i] == '\0') { + /* unterminated double quote. We don't support line continuation. */ + goto out_error; + } + if (value[i] == '\\') { + + i++; + if (value[i] == '\0') { + /* we don't support line continuation */ + goto out_error; + } + switch (value[i]) { + case 'a': ch = '\a'; break; + case 'b': ch = '\b'; break; + case 'e': ch = '\e'; break; + case 'E': ch = '\E'; break; + case 'f': ch = '\f'; break; + case 'n': ch = '\n'; break; + case 'r': ch = '\r'; break; + case 't': ch = '\t'; break; + case 'v': ch = '\v'; break; + case '?': ch = '\?'; break; + case '"': ch = '"'; break; + case '\\': ch = '\\'; break; + case '\'': ch = '\''; break; + default: + if (_ch_octal_is (value[i])) { + guint v; + + v = _ch_octal_get (value[i]); + i++; + if (_ch_octal_is (value[i])) { + v = (v * 8) + _ch_octal_get (value[i]); + i++; + if (_ch_octal_is (value[i])) { + v = (v * 8) + _ch_octal_get (value[i]); + i++; + } + } + /* like bash, we cut too large numbers off. E.g. A=$'\772' becomes 0xfa */ + g_string_append_c (str, (guint8) v); + } else if (NM_IN_SET (value[i], 'x', 'u', 'U')) { + const char escape_type = value[i]; + int max_digits = escape_type == 'x' ? 2 : escape_type == 'u' ? 4 : 8; + guint64 v; + + i++; + if (!_ch_hex_is (value[i])) { + /* missing hex value after "\x" escape. This is treated like no escaping. */ + g_string_append_c (str, '\\'); + g_string_append_c (str, escape_type); + } else { + v = _ch_hex_get (value[i]); + i++; + + while (--max_digits > 0) { + if (!_ch_hex_is (value[i])) + break; + v = v * 16 + _ch_hex_get (value[i]); + i++; + } + if (escape_type == 'x') + g_string_append_c (str, v); + else { + /* we treat the unicode escapes as utf-8 encoded values. */ + g_string_append_unichar (str, v); + } + } + } else { + g_string_append_c (str, '\\'); + g_string_append_c (str, value[i]); + i++; + } + goto loop_ansic_next; + } + } else + ch = value[i]; + g_string_append_c (str, ch); + i++; +loop_ansic_next: ; } - s[idx_wr++] = s[idx_rd++]; - continue; + goto loop1_next; + } + + if (NM_IN_SET (value[i], '|', '&', '(', ')', '<', '>')) { + /* shell metacharacters are not supported without quoting. + * Note that ';' is already handled above. */ + goto out_error; + } + + /* an unquoted, regular character. Just consume it directly. */ + if (str) + g_string_append_c (str, value[i]); + i++; + +loop1_next: ; + } + + nm_assert_not_reached (); + +out_value: + if (i == 0) { + nm_assert (!str); + *to_free = NULL; + return ""; + } + + if (str) { + if (str->len == 0 || str->str[0] == '\0') { + g_string_free (str, TRUE); + *to_free = NULL; + return ""; + } else { + *to_free = g_string_free (str, FALSE); + return *to_free; } - s[idx_wr++] = c; } - s[idx_wr] = '\0'; + + if (value[i] != '\0') { + *to_free = g_strndup (value, i); + return *to_free; + } + + *to_free = NULL; + return value; + +out_error: + if (str) + g_string_free (str, TRUE); + *to_free = NULL; + return NULL; } -/* create a new string with all necessary characters escaped. - * caller must free returned string - */ -static const char escapees[] = "\"'\\$~`"; /* must be escaped */ -static const char spaces[] = " \t|&;()<>"; /* only require "" */ -static const char newlines[] = "\n\r"; /* will be removed */ +/*****************************************************************************/ + +static shvarFile * +svFile_new (const char *name) +{ + shvarFile *s; + + s = g_slice_new0 (shvarFile); + s->fd = -1; + s->fileName = g_strdup (name); + return s; +} const char * -svEscape (const char *s, char **to_free) +svFileGetName (const shvarFile *s) { - char *new; - int i, j, mangle = 0, space = 0, newline = 0; - int newlen, slen; + nm_assert (s); - slen = strlen (s); + return s->fileName; +} - for (i = 0; i < slen; i++) { - if (strchr (escapees, s[i])) - mangle++; - if (strchr (spaces, s[i])) - space++; - if (strchr (newlines, s[i])) - newline++; - } - if (!mangle && !space && !newline) { - *to_free = NULL; - return s; +void +svFileSetName (shvarFile *s, const char *fileName) +{ + g_free (s->fileName); + s->fileName = g_strdup (fileName); +} + +void +svFileSetModified (shvarFile *s) +{ + s->modified = TRUE; +} + +/*****************************************************************************/ + +static void +ASSERT_shvarLine (const shvarLine *line) +{ +#if NM_MORE_ASSERTS > 5 + const char *s, *s2; + + nm_assert (line); + if (!line->key) { + nm_assert (line->line); + nm_assert (!line->key_with_prefix); + s = nm_str_skip_leading_spaces (line->line); + s2 = strchr (s, '='); + nm_assert (!s2 || !_shell_is_name (s, s2 - s)); + } else { + nm_assert (line->key_with_prefix); + nm_assert (line->key == nm_str_skip_leading_spaces (line->key_with_prefix)); + nm_assert (_shell_is_name (line->key, -1)); } +#endif +} - newlen = slen + mangle - newline + 3; /* 3 is extra ""\0 */ - new = g_malloc (newlen); +static shvarLine * +line_new_parse (const char *value, gsize len) +{ + shvarLine *line; + gsize k, e; - j = 0; - new[j++] = '"'; - for (i = 0; i < slen; i++) { - if (strchr (newlines, s[i])) + nm_assert (value); + + line = g_slice_new0 (shvarLine); + + for (k = 0; k < len; k++) { + if (g_ascii_isspace (value[k])) continue; - if (strchr (escapees, s[i])) { - new[j++] = '\\'; + + if ( g_ascii_isalpha (value[k]) + || value[k] == '_') { + for (e = k + 1; e < len; e++) { + if (value[e] == '=') { + nm_assert (_shell_is_name (&value[k], e - k)); + line->line = g_strndup (&value[e + 1], len - e - 1); + line->key_with_prefix = g_strndup (value, e); + line->key = &line->key_with_prefix[k]; + ASSERT_shvarLine (line); + return line; + } + if ( !g_ascii_isalnum (value[e]) + && value[e] != '_') + break; + } } - new[j++] = s[i]; + break; } - new[j++] = '"'; - new[j++] = '\0'; - g_assert (j == slen + mangle - newline + 3); + line->line = g_strndup (value, len); + ASSERT_shvarLine (line); + return line; +} - *to_free = new; - return new; +static shvarLine * +line_new_build (const char *key, const char *value) +{ + char *value_escaped = NULL; + shvarLine *line; + + value = svEscape (value, &value_escaped); + + line = g_slice_new (shvarLine); + line->line = value_escaped ?: g_strdup (value); + line->key_with_prefix = g_strdup (key); + line->key = line->key_with_prefix; + ASSERT_shvarLine (line); + return line; } -/* Get the value associated with the key, and leave the current pointer - * pointing at the line containing the value. The char* returned MUST - * be freed by the caller. +static gboolean +line_set (shvarLine *line, const char *value) +{ + char *value_escaped = NULL; + gboolean changed = FALSE; + + ASSERT_shvarLine (line); + nm_assert (line->key); + + if (line->key != line->key_with_prefix) { + memmove (line->key_with_prefix, line->key, strlen (line->key) + 1); + line->key = line->key_with_prefix; + changed = TRUE; + ASSERT_shvarLine (line); + } + + value = svEscape (value, &value_escaped); + + if (line->line) { + if (nm_streq (value, line->line)) { + g_free (value_escaped); + return changed; + } + g_free (line->line); + } + + line->line = value_escaped ?: g_strdup (value); + ASSERT_shvarLine (line); + return TRUE; +} + +static void +line_free (shvarLine *line) +{ + ASSERT_shvarLine (line); + g_free (line->line); + g_free (line->key_with_prefix); + g_slice_free (shvarLine, line); +} + +/*****************************************************************************/ + +/* Open the file <name>, returning a shvarFile on success and NULL on failure. + * Add a wrinkle to let the caller specify whether or not to create the file + * (actually, return a structure anyway) if it doesn't exist. */ -char * -svGetValue (shvarFile *s, const char *key, gboolean verbatim) +static shvarFile * +svOpenFileInternal (const char *name, gboolean create, GError **error) { - char *value; + shvarFile *s; + gboolean closefd = FALSE; + int errsv = 0; + char *arena; + const char *p, *q; + GError *local = NULL; + nm_auto_close int fd = -1; + GList *lineList = NULL; + + if (create) + fd = open (name, O_RDWR | O_CLOEXEC); /* NOT O_CREAT */ + if (fd < 0) { + /* try read-only */ + fd = open (name, O_RDONLY | O_CLOEXEC); /* NOT O_CREAT */ + if (fd < 0) + errsv = errno; + else + closefd = TRUE; + } - value = svGetValueFull (s, key, verbatim); - if (value && !*value) { - g_free (value); + if (fd < 0) { + if (create) + return svFile_new (name); + + g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errsv), + "Could not read file '%s': %s", + name, strerror (errsv)); return NULL; } - return value; + + if (nm_utils_fd_get_contents (fd, + 10 * 1024 * 1024, + &arena, + NULL, + &local) < 0) { + g_set_error (error, G_FILE_ERROR, + local->domain == G_FILE_ERROR ? local->code : G_FILE_ERROR_FAILED, + "Could not read file '%s': %s", + name, local->message); + g_error_free (local); + return NULL; + } + + for (p = arena; (q = strchr (p, '\n')) != NULL; p = q + 1) + lineList = g_list_prepend (lineList, line_new_parse (p, q - p)); + if (p[0]) + lineList = g_list_prepend (lineList, line_new_parse (p, strlen (p))); + g_free (arena); + lineList = g_list_reverse (lineList); + + s = svFile_new (name); + s->lineList = lineList; + + /* closefd is set if we opened the file read-only, so go ahead and + * close it, because we can't write to it anyway */ + if (!closefd) { + s->fd = fd; + fd = -1; + } + + return s; } -/* svGetValueFull() is identical to svGetValue() except that - * svGetValue() will never return an empty value (but %NULL instead). - * svGetValueFull() will return empty values if that is the value for the @key. */ -char * -svGetValueFull (shvarFile *s, const char *key, gboolean verbatim) +/* Open the file <name>, return shvarFile on success, NULL on failure */ +shvarFile * +svOpenFile (const char *name, GError **error) { - char *value = NULL; - char *line; - guint len; + return svOpenFileInternal (name, FALSE, error); +} - g_return_val_if_fail (s != NULL, NULL); - g_return_val_if_fail (key != NULL, NULL); +/* Create a new file structure, returning actual data if the file exists, + * and a suitable starting point if it doesn't. + */ +shvarFile * +svCreateFile (const char *name) +{ + return svOpenFileInternal (name, TRUE, NULL); +} - len = strlen (key); +/*****************************************************************************/ - for (s->current = s->lineList; s->current; s->current = s->current->next) { - line = s->current->data; - if (!strncmp (key, line, len) && line[len] == '=') { - /* Strip trailing spaces before unescaping to preserve spaces quoted whitespace */ - value = g_strchomp (g_strdup (line + len + 1)); - if (!verbatim) - svUnescape (value); - break; - } +static const GList * +shlist_find (const GList *current, const char *key) +{ + nm_assert (_shell_is_name (key, -1)); + + if (current) { + do { + shvarLine *line = current->data; + + ASSERT_shvarLine (line); + if (line->key && nm_streq (line->key, key)) + return current; + current = current->next; + } while (current); + } + return NULL; +} + +/*****************************************************************************/ + +static const char * +_svGetValue (shvarFile *s, const char *key, char **to_free) +{ + const GList *current, *last; + const shvarLine *line; + + nm_assert (s); + nm_assert (_shell_is_name (key, -1)); + nm_assert (to_free); + + last = NULL; + current = s->lineList; + while ((current = shlist_find (current, key))) { + last = current; + current = current->next; + } + if (last) { + line = last->data; + if (line->line) + return svUnescape (line->line, to_free); } + *to_free = NULL; + return NULL; +} - return value; +const char * +svGetValue (shvarFile *s, const char *key, char **to_free) +{ + g_return_val_if_fail (s != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (to_free, NULL); + + return _svGetValue (s, key, to_free); } -/** - * svParseBoolean: - * @value: the input string - * @fallback: the fallback value - * - * Parses a string and returns the boolean value it contains or, - * in case no valid value is found, the fallback value. Valid values - * are: "yes", "true", "t", "y", "1" and "no", "false", "f", "n", "0". - * - * Returns: the parsed boolean value or @fallback. +/* Get the value associated with the key, and leave the current pointer + * pointing at the line containing the value. The char* returned MUST + * be freed by the caller. */ -gint -svParseBoolean (const char *value, gint fallback) +char * +svGetValueString (shvarFile *s, const char *key) { - if (!value) - return fallback; + char *to_free; + const char *value; - if ( !g_ascii_strcasecmp ("yes", value) - || !g_ascii_strcasecmp ("true", value) - || !g_ascii_strcasecmp ("t", value) - || !g_ascii_strcasecmp ("y", value) - || !g_ascii_strcasecmp ("1", value)) - return TRUE; - else if ( !g_ascii_strcasecmp ("no", value) - || !g_ascii_strcasecmp ("false", value) - || !g_ascii_strcasecmp ("f", value) - || !g_ascii_strcasecmp ("n", value) - || !g_ascii_strcasecmp ("0", value)) - return FALSE; - - return fallback; + value = _svGetValue (s, key, &to_free); + if (!value) { + nm_assert (!to_free); + return NULL; + } + if (!value[0]) { + nm_assert (!to_free); + return NULL; + } + return to_free ?: g_strdup (value); } /* svGetValueBoolean: @@ -337,10 +946,11 @@ svParseBoolean (const char *value, gint fallback) gint svGetValueBoolean (shvarFile *s, const char *key, gint fallback) { - gs_free char *tmp = NULL; + gs_free char *to_free = NULL; + const char *value; - tmp = svGetValue (s, key, FALSE); - return svParseBoolean (tmp, fallback); + value = _svGetValue (s, key, &to_free); + return svParseBoolean (value, fallback); } /* svGetValueInt64: @@ -356,97 +966,108 @@ svGetValueBoolean (shvarFile *s, const char *key, gint fallback) gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback) { - char *tmp; + char *to_free; + const char *value; gint64 result; int errsv; - tmp = svGetValueFull (s, key, FALSE); - if (!tmp) { - errno = 0; + value = _svGetValue (s, key, &to_free); + if (!value) { + nm_assert (!to_free); + /* indicate that the key does not exist (or has a syntax error + * and svUnescape() failed). */ + errno = ENOKEY; return fallback; } - result = _nm_utils_ascii_str_to_int64 (tmp, base, min, max, fallback); - errsv = errno; - - g_free (tmp); - - errno = errsv; + result = _nm_utils_ascii_str_to_int64 (value, base, min, max, fallback); + if (to_free) { + errsv = errno; + g_free (to_free); + errno = errsv; + } return result; } -/* Set the variable <key> equal to the value <value>. - * If <key> does not exist, and the <current> pointer is set, append - * the key=value pair after that line. Otherwise, append the pair - * to the bottom of the file. - */ -void -svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim) -{ - svSetValueFull (s, key, value && value[0] ? value : NULL, verbatim); -} +/*****************************************************************************/ -/* Same as svSetValue() but it preserves empty @value -- contrary to - * svSetValue() for which "" effectively means to remove the value. */ +/* Same as svSetValueString() but it preserves empty @value -- contrary to + * svSetValueString() for which "" effectively means to remove the value. */ void -svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim) +svSetValue (shvarFile *s, const char *key, const char *value) { - gs_free char *newval_free = NULL; - gs_free char *oldval = NULL; - const char *newval; - char *keyValue; + GList *current, *last; g_return_if_fail (s != NULL); g_return_if_fail (key != NULL); - /* value may be NULL */ - - if (!value || verbatim) - newval = value; - else - newval = svEscape (value, &newval_free); - oldval = svGetValueFull (s, key, FALSE); - - if (!newval) { - /* delete value */ - if (oldval) { - /* delete line */ - s->lineList = g_list_remove_link (s->lineList, s->current); - g_free (s->current->data); - g_list_free_1 (s->current); + + nm_assert (_shell_is_name (key, -1)); + + last = NULL; + current = s->lineList; + while ((current = (GList *) shlist_find (current, key))) { + if (last) { + /* if we find multiple entries for the same key, we can + * delete all but the last. */ + line_free (last->data); + s->lineList = g_list_delete_link (s->lineList, last); s->modified = TRUE; } - return; + last = current; + current = current->next; } - keyValue = g_strdup_printf ("%s=%s", key, newval); - if (!oldval) { - /* append line */ - s->lineList = g_list_append (s->lineList, keyValue); - s->modified = TRUE; - return; + if (!value) { + if (last) { + shvarLine *line = last->data; + + if (nm_clear_g_free (&line->line)) + s->modified = TRUE; + } + } else { + if (!last) { + s->lineList = g_list_append (s->lineList, line_new_build (key, value)); + s->modified = TRUE; + } else { + if (line_set (last->data, value)) + s->modified = TRUE; + } } +} - if (strcmp (oldval, newval) != 0) { - /* change line */ - if (s->current) { - g_free (s->current->data); - s->current->data = keyValue; - } else - s->lineList = g_list_append (s->lineList, keyValue); - s->modified = TRUE; - } else - g_free (keyValue); +/* Set the variable <key> equal to the value <value>. + * If <key> does not exist, and the <current> pointer is set, append + * the key=value pair after that line. Otherwise, append the pair + * to the bottom of the file. + */ +void +svSetValueString (shvarFile *s, const char *key, const char *value) +{ + svSetValue (s, key, value && value[0] ? value : NULL); } void svSetValueInt64 (shvarFile *s, const char *key, gint64 value) { - gs_free char *v = NULL; + char buf[NM_DECIMAL_STR_MAX (value)]; + + svSetValue (s, key, nm_sprintf_buf (buf, "%"G_GINT64_FORMAT, value)); +} - v = g_strdup_printf ("%"G_GINT64_FORMAT, value); - svSetValueFull (s, key, v, TRUE); +void +svSetValueBoolean (shvarFile *s, const char *key, gboolean value) +{ + svSetValue (s, key, value ? "yes" : "no"); } +void +svUnsetValue (shvarFile *s, const char *key) +{ + svSetValue (s, key, NULL); +} + +/*****************************************************************************/ + /* Write the current contents iff modified. Returns FALSE on error * and TRUE on success. Do not write if no values have been modified. * The mode argument is only used if creating the file, not if @@ -458,6 +1079,7 @@ svWriteFile (shvarFile *s, int mode, GError **error) { FILE *f; int tmpfd; + const GList *current; if (s->modified) { if (s->fd == -1) @@ -490,9 +1112,36 @@ svWriteFile (shvarFile *s, int mode, GError **error) } f = fdopen (tmpfd, "w"); fseek (f, 0, SEEK_SET); - for (s->current = s->lineList; s->current; s->current = s->current->next) { - char *line = s->current->data; - fprintf (f, "%s\n", line); + for (current = s->lineList; current; current = current->next) { + const shvarLine *line = current->data; + const char *str; + char *s_tmp; + gboolean valid_value; + + ASSERT_shvarLine (line); + + if (!line->key) { + str = nm_str_skip_leading_spaces (line->line); + if (NM_IN_SET (str[0], '\0', '#')) + fprintf (f, "%s\n", line->line); + else + fprintf (f, "#NM: %s\n", line->line); + continue; + } + + if (!line->line) + continue; + + /* we check that the assignment can be properly unescaped. */ + valid_value = !!svUnescape (line->line, &s_tmp); + g_free (s_tmp); + + if (valid_value) + fprintf (f, "%s=%s\n", line->key_with_prefix, line->line); + else { + fprintf (f, "%s=\n", line->key); + fprintf (f, "#NM: %s=%s\n", line->key_with_prefix, line->line); + } } fclose (f); } @@ -500,8 +1149,6 @@ svWriteFile (shvarFile *s, int mode, GError **error) return TRUE; } - -/* Close the file descriptor (if open) and free the shvarFile. */ void svCloseFile (shvarFile *s) { @@ -509,8 +1156,7 @@ svCloseFile (shvarFile *s) if (s->fd != -1) close (s->fd); - g_free (s->fileName); - g_list_free_full (s->lineList, g_free); /* implicitly frees s->current */ + g_list_free_full (s->lineList, (GDestroyNotify) line_free); g_slice_free (shvarFile, s); } diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index 97df8128..a6498fce 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -32,14 +32,11 @@ #define _SHVAR_H typedef struct _shvarFile shvarFile; -struct _shvarFile { - char *fileName; /* read-only */ - int fd; /* read-only */ - GList *lineList; /* read-only */ - GList *current; /* set implicitly or explicitly, points to element of lineList */ - gboolean modified; /* ignore */ -}; +const char *svFileGetName (const shvarFile *s); +void svFileSetName (shvarFile *s, const char *fileName); + +void svFileSetModified (shvarFile *s); /* Create the file <name>, return a shvarFile (never fails) */ shvarFile *svCreateFile (const char *name); @@ -51,8 +48,8 @@ shvarFile *svOpenFile (const char *name, GError **error); * pointing at the line containing the value. The char* returned MUST * be freed by the caller. */ -char *svGetValue (shvarFile *s, const char *key, gboolean verbatim); -char *svGetValueFull (shvarFile *s, const char *key, gboolean verbatim); +const char *svGetValue (shvarFile *s, const char *key, char **to_free); +char *svGetValueString (shvarFile *s, const char *key); gint svParseBoolean (const char *value, gint def); @@ -69,10 +66,12 @@ gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, g * the key=value pair after that line. Otherwise, prepend the pair * to the top of the file. */ -void svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim); -void svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim); +void svSetValueString (shvarFile *s, const char *key, const char *value); +void svSetValue (shvarFile *s, const char *key, const char *value); +void svSetValueBoolean (shvarFile *s, const char *key, gboolean value); void svSetValueInt64 (shvarFile *s, const char *key, gint64 value); +void svUnsetValue (shvarFile *s, const char *key); /* Write the current contents iff modified. Returns FALSE on error * and TRUE on success. Do not write if no values have been modified. @@ -85,10 +84,7 @@ gboolean svWriteFile (shvarFile *s, int mode, GError **error); /* Close the file descriptor (if open) and free the shvarFile. */ void svCloseFile (shvarFile *s); -/* Return @s unmodified or an escaped string */ const char *svEscape (const char *s, char **to_free); - -/* Unescape a string in-place */ -void svUnescape (char *s); +const char *svUnescape (const char *s, char **to_free); #endif /* _SHVAR_H */ diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am deleted file mode 100644 index fedbd93f..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -if ENABLE_TESTS - -SUBDIRS=network-scripts - -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/ \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/settings \ - -I$(srcdir)/../ \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ - -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ - -DSYSCONFDIR=\"nonexistent\" \ - -DSBINDIR=\"nonexistent\" - -AM_LDFLAGS = \ - $(GLIB_LIBS) \ - $(CODE_COVERAGE_LDFLAGS) - -noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils - -test_ifcfg_rh_SOURCES = \ - test-ifcfg-rh.c \ - ../reader.c \ - ../shvar.c \ - ../utils.c \ - ../writer.c - -test_ifcfg_rh_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -test_ifcfg_rh_utils_SOURCES = \ - test-ifcfg-rh-utils.c \ - ../utils.c \ - ../shvar.c - -test_ifcfg_rh_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -@VALGRIND_RULES@ -TESTS = test-ifcfg-rh-utils test-ifcfg-rh - -check-local: - LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifcfg-rh.so $(top_builddir)/src/NetworkManager --version >/dev/null - -endif - diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in deleted file mode 100644 index f2ce157b..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in +++ /dev/null @@ -1,1371 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-ifcfg-rh$(EXEEXT) \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh-utils$(EXEEXT) -@ENABLE_TESTS_TRUE@TESTS = test-ifcfg-rh-utils$(EXEEXT) \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh$(EXEEXT) -subdir = src/settings/plugins/ifcfg-rh/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am__test_ifcfg_rh_SOURCES_DIST = test-ifcfg-rh.c ../reader.c \ - ../shvar.c ../utils.c ../writer.c -@ENABLE_TESTS_TRUE@am_test_ifcfg_rh_OBJECTS = test-ifcfg-rh.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ reader.$(OBJEXT) shvar.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ utils.$(OBJEXT) writer.$(OBJEXT) -test_ifcfg_rh_OBJECTS = $(am_test_ifcfg_rh_OBJECTS) -@ENABLE_TESTS_TRUE@test_ifcfg_rh_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -am__test_ifcfg_rh_utils_SOURCES_DIST = test-ifcfg-rh-utils.c \ - ../utils.c ../shvar.c -@ENABLE_TESTS_TRUE@am_test_ifcfg_rh_utils_OBJECTS = \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh-utils.$(OBJEXT) \ -@ENABLE_TESTS_TRUE@ utils.$(OBJEXT) shvar.$(OBJEXT) -test_ifcfg_rh_utils_OBJECTS = $(am_test_ifcfg_rh_utils_OBJECTS) -@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(test_ifcfg_rh_SOURCES) $(test_ifcfg_rh_utils_SOURCES) -DIST_SOURCES = $(am__test_ifcfg_rh_SOURCES_DIST) \ - $(am__test_ifcfg_rh_utils_SOURCES_DIST) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - check recheck distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red='[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) -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -DIST_SUBDIRS = network-scripts -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -@ENABLE_TESTS_TRUE@SUBDIRS = network-scripts -@ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/platform \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ -@ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -@ENABLE_TESTS_TRUE@ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ -@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ -@ENABLE_TESTS_TRUE@ -DSYSCONFDIR=\"nonexistent\" \ -@ENABLE_TESTS_TRUE@ -DSBINDIR=\"nonexistent\" - -@ENABLE_TESTS_TRUE@AM_LDFLAGS = \ -@ENABLE_TESTS_TRUE@ $(GLIB_LIBS) \ -@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh.c \ -@ENABLE_TESTS_TRUE@ ../reader.c \ -@ENABLE_TESTS_TRUE@ ../shvar.c \ -@ENABLE_TESTS_TRUE@ ../utils.c \ -@ENABLE_TESTS_TRUE@ ../writer.c - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-ifcfg-rh-utils.c \ -@ENABLE_TESTS_TRUE@ ../utils.c \ -@ENABLE_TESTS_TRUE@ ../shvar.c - -@ENABLE_TESTS_TRUE@test_ifcfg_rh_utils_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la - -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -test-ifcfg-rh$(EXEEXT): $(test_ifcfg_rh_OBJECTS) $(test_ifcfg_rh_DEPENDENCIES) $(EXTRA_test_ifcfg_rh_DEPENDENCIES) - @rm -f test-ifcfg-rh$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ifcfg_rh_OBJECTS) $(test_ifcfg_rh_LDADD) $(LIBS) - -test-ifcfg-rh-utils$(EXEEXT): $(test_ifcfg_rh_utils_OBJECTS) $(test_ifcfg_rh_utils_DEPENDENCIES) $(EXTRA_test_ifcfg_rh_utils_DEPENDENCIES) - @rm -f test-ifcfg-rh-utils$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ifcfg_rh_utils_OBJECTS) $(test_ifcfg_rh_utils_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shvar.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifcfg-rh-utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifcfg-rh.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -reader.o: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.o -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c - -reader.obj: ../reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.obj -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` - -shvar.o: ../shvar.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shvar.o -MD -MP -MF $(DEPDIR)/shvar.Tpo -c -o shvar.o `test -f '../shvar.c' || echo '$(srcdir)/'`../shvar.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/shvar.Tpo $(DEPDIR)/shvar.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../shvar.c' object='shvar.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o shvar.o `test -f '../shvar.c' || echo '$(srcdir)/'`../shvar.c - -shvar.obj: ../shvar.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shvar.obj -MD -MP -MF $(DEPDIR)/shvar.Tpo -c -o shvar.obj `if test -f '../shvar.c'; then $(CYGPATH_W) '../shvar.c'; else $(CYGPATH_W) '$(srcdir)/../shvar.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/shvar.Tpo $(DEPDIR)/shvar.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../shvar.c' object='shvar.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o shvar.obj `if test -f '../shvar.c'; then $(CYGPATH_W) '../shvar.c'; else $(CYGPATH_W) '$(srcdir)/../shvar.c'; fi` - -utils.o: ../utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.o -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c - -utils.obj: ../utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.obj -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` - -writer.o: ../writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.o -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c - -writer.obj: ../writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.obj -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test-ifcfg-rh-utils.log: test-ifcfg-rh-utils$(EXEEXT) - @p='test-ifcfg-rh-utils$(EXEEXT)'; \ - b='test-ifcfg-rh-utils'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-ifcfg-rh.log: test-ifcfg-rh$(EXEEXT) - @p='test-ifcfg-rh$(EXEEXT)'; \ - b='test-ifcfg-rh'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -@ENABLE_TESTS_FALSE@check-local: -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local -check: check-recursive -all-am: Makefile $(PROGRAMS) -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) check-am install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-TESTS check-am check-local clean clean-generic \ - clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -@ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ - -@ENABLE_TESTS_TRUE@@VALGRIND_RULES@ - -@ENABLE_TESTS_TRUE@check-local: -@ENABLE_TESTS_TRUE@ LD_BIND_NOW=1 LD_PRELOAD=$(builddir)/../.libs/libnm-settings-plugin-ifcfg-rh.so $(top_builddir)/src/NetworkManager --version >/dev/null - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am deleted file mode 100644 index de9c1ed7..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ /dev/null @@ -1,170 +0,0 @@ -EXTRA_DIST = \ - ifcfg-test-minimal \ - ifcfg-test-misc-variables \ - ifcfg-test-variables-corner-cases-1 \ - ifcfg-test-nm-controlled \ - ifcfg-test-nm-controlled-unrecognized \ - ifcfg-test-unrecognized \ - ifcfg-test-wired-static \ - ifcfg-test-wired-static-bootproto \ - ifcfg-test-wired-dhcp \ - ifcfg-test-wired-dhcp-plus-ip \ - ifcfg-test-wired-shared-plus-ip \ - ifcfg-test-wired-dhcp-send-hostname \ - ifcfg-test-wired-dhcp6-only \ - ifcfg-test-wired-autoip \ - ifcfg-test-wired-global-gateway \ - network-test-wired-global-gateway \ - ifcfg-test-wired-global-gateway-ignore \ - network-test-wired-global-gateway-ignore \ - ifcfg-test-wired-obsolete-gateway-n \ - ifcfg-test-wired-never-default \ - network-test-wired-never-default \ - ifcfg-test-wired-defroute-no \ - ifcfg-test-wired-defroute-no-gatewaydev-yes \ - network-test-wired-defroute-no-gatewaydev-yes \ - ifcfg-test-wired-8021x-peap-mschapv2 \ - keys-test-wired-8021x-peap-mschapv2 \ - ifcfg-test-wired-8021x-tls-agent \ - ifcfg-test-wired-8021x-tls-always \ - ifcfg-test-wired-802-1X-subj-matches \ - ifcfg-test-wired-802-1x-ttls-eapgtc \ - ifcfg-test-onboot-no \ - ifcfg-test-noip \ - ifcfg-test-wifi-open \ - ifcfg-test-wifi-open-auto \ - ifcfg-test-wifi-open-ssid-quoted \ - ifcfg-test-wifi-open-ssid-long-quoted \ - ifcfg-test-wifi-open-ssid-hex \ - ifcfg-test-wifi-open-ssid-long-hex \ - ifcfg-test-wifi-open-ssid-bad-hex \ - ifcfg-test-wifi-wep \ - keys-test-wifi-wep \ - ifcfg-test-wifi-wep-adhoc \ - keys-test-wifi-wep-adhoc \ - ifcfg-test-wifi-wep-eap-ttls-chap \ - keys-test-wifi-wep-eap-ttls-chap \ - ifcfg-test-wifi-leap \ - keys-test-wifi-leap \ - ifcfg-test-wifi-leap-agent \ - ifcfg-test-wifi-leap-always-ask \ - ifcfg-test-wifi-wpa-psk \ - keys-test-wifi-wpa-psk \ - ifcfg-test-wifi-wpa-psk-2 \ - keys-test-wifi-wpa-psk-2 \ - ifcfg-test-wifi-wpa-psk-unquoted \ - keys-test-wifi-wpa-psk-unquoted \ - ifcfg-test-wifi-wpa-psk-unquoted2 \ - keys-test-wifi-wpa-psk-unquoted2 \ - ifcfg-test-wifi-wpa-psk-adhoc \ - keys-test-wifi-wpa-psk-adhoc \ - ifcfg-test-wifi-wpa-psk-hex \ - keys-test-wifi-wpa-psk-hex \ - ifcfg-test-wifi-wpa-eap-tls \ - keys-test-wifi-wpa-eap-tls \ - ifcfg-test-wifi-wpa-eap-ttls-tls \ - keys-test-wifi-wpa-eap-ttls-tls \ - ifcfg-test-wifi-hidden \ - ifcfg-test-wifi-band-a \ - ifcfg-test-wifi-band-a-channel-mismatch \ - ifcfg-test-wifi-band-bg-channel-mismatch \ - ifcfg-test-wifi-mac-random-always \ - ifcfg-test-wifi-mac-random-never \ - ifcfg-test-wifi-mac-random-default \ - ifcfg-test-wifi-mac-random-missing \ - test_ca_cert.pem \ - test1_key_and_cert.pem \ - ifcfg-test-ibft \ - ifcfg-test-static-routes-legacy \ - route-test-static-routes-legacy \ - ifcfg-test-sit-ignore \ - ifcfg-test-wired-static-routes \ - route-test-wired-static-routes \ - ifcfg-test-wired-static-routes-legacy \ - route-test-wired-static-routes-legacy \ - ifcfg-test-wired-ipv4-manual-1 \ - ifcfg-test-wired-ipv4-manual-2 \ - ifcfg-test-wired-ipv4-manual-3 \ - ifcfg-test-wired-ipv4-manual-4 \ - ifcfg-test-wired-ipv6-manual \ - route6-test-wired-ipv6-manual \ - ifcfg-test-wired-static-no-prefix-8 \ - ifcfg-test-wired-static-no-prefix-16 \ - ifcfg-test-wired-static-no-prefix-24 \ - ifcfg-test-wired-ipv6-only \ - ifcfg-test-wifi-wep-passphrase \ - keys-test-wifi-wep-passphrase \ - ifcfg-test-wifi-wep-40-ascii \ - keys-test-wifi-wep-40-ascii \ - ifcfg-test-wifi-wep-104-ascii \ - keys-test-wifi-wep-104-ascii \ - ifcfg-test-wired-qeth-static \ - ifcfg-test-wired-ctc-static \ - ifcfg-test-bridge-main \ - ifcfg-test-bridge-component \ - ifcfg-test-bridge-missing-stp \ - ifcfg-test-vlan-interface \ - ifcfg-test-vlan-only-vlanid \ - ifcfg-test-vlan-only-device \ - ifcfg-test-vlan-physdev \ - ifcfg-test-vlan-reorder-hdr-1 \ - ifcfg-test-vlan-reorder-hdr-2 \ - ifcfg-test-vlan-flags-1 \ - ifcfg-test-vlan-flags-2 \ - ifcfg-test-wifi-wep-no-keys \ - ifcfg-test-permissions \ - ifcfg-test-wifi-wep-agent-keys \ - ifcfg-test-wifi-dynamic-wep-leap \ - keys-test-wifi-dynamic-wep-leap \ - ifcfg-test-infiniband \ - ifcfg-test-bond-main \ - ifcfg-test-bond-slave \ - ifcfg-test-bond-slave-ib \ - ifcfg-test-bond-mode-numeric \ - ifcfg-test-dcb \ - ifcfg-test-dcb-default-app-priorities \ - ifcfg-test-dcb-bad-booleans \ - ifcfg-test-dcb-short-booleans \ - ifcfg-test-dcb-bad-uints \ - ifcfg-test-dcb-short-uints \ - ifcfg-test-dcb-bad-percent \ - ifcfg-test-dcb-short-percent \ - ifcfg-test-dcb-pgpct-not-100 \ - ifcfg-test-fcoe-fabric \ - ifcfg-test-fcoe-vn2vn \ - ifcfg-test-team-master-1 \ - ifcfg-test-team-master-2 \ - ifcfg-test-team-master-invalid \ - ifcfg-test-team-port-1 \ - ifcfg-test-team-port-2 \ - ifcfg-test-team-port-empty-config \ - ifcfg-test-vlan-trailing-spaces \ - ifcfg-test-dns-options \ - ifcfg-test-wired-wake-on-lan \ - ifcfg-test-wired-ipv6-only-1 - -# make target dependencies can't have colons in their names, which ends up -# meaning that we can't add the alias files to EXTRA_DIST -ALIAS_FILES = \ - ifcfg-aliasem0 \ - ifcfg-aliasem0:1 \ - ifcfg-aliasem0:2 \ - ifcfg-aliasem0:99 \ - ifcfg-aliasem1 \ - ifcfg-aliasem1:1 \ - ifcfg-aliasem2 \ - ifcfg-aliasem2:1 - -dist-hook: - @for f in $(ALIAS_FILES); do \ - cp $(abs_srcdir)/$$f $(distdir)/; \ - done - -check-local: - @for f in $(EXTRA_DIST) $(ALIAS_FILES); do \ - chmod 0600 $(abs_srcdir)/$$f; \ - done - -# Make the special temp dir for some written connections - mkdir -p $(abs_builddir)/tmp - diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in deleted file mode 100644 index 583f0809..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ /dev/null @@ -1,776 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ifcfg-rh/tests/network-scripts -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \ - $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_options.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/git-sha-record.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DL_LIBS = @DL_LIBS@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -JANSSON_CFLAGS = @JANSSON_CFLAGS@ -JANSSON_LIBS = @JANSSON_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ -LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ -LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ -NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ -NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SANITIZERS = @SANITIZERS@ -SANITIZER_ENV = @SANITIZER_ENV@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ -SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmlibdir = @nmlibdir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -EXTRA_DIST = \ - ifcfg-test-minimal \ - ifcfg-test-misc-variables \ - ifcfg-test-variables-corner-cases-1 \ - ifcfg-test-nm-controlled \ - ifcfg-test-nm-controlled-unrecognized \ - ifcfg-test-unrecognized \ - ifcfg-test-wired-static \ - ifcfg-test-wired-static-bootproto \ - ifcfg-test-wired-dhcp \ - ifcfg-test-wired-dhcp-plus-ip \ - ifcfg-test-wired-shared-plus-ip \ - ifcfg-test-wired-dhcp-send-hostname \ - ifcfg-test-wired-dhcp6-only \ - ifcfg-test-wired-autoip \ - ifcfg-test-wired-global-gateway \ - network-test-wired-global-gateway \ - ifcfg-test-wired-global-gateway-ignore \ - network-test-wired-global-gateway-ignore \ - ifcfg-test-wired-obsolete-gateway-n \ - ifcfg-test-wired-never-default \ - network-test-wired-never-default \ - ifcfg-test-wired-defroute-no \ - ifcfg-test-wired-defroute-no-gatewaydev-yes \ - network-test-wired-defroute-no-gatewaydev-yes \ - ifcfg-test-wired-8021x-peap-mschapv2 \ - keys-test-wired-8021x-peap-mschapv2 \ - ifcfg-test-wired-8021x-tls-agent \ - ifcfg-test-wired-8021x-tls-always \ - ifcfg-test-wired-802-1X-subj-matches \ - ifcfg-test-wired-802-1x-ttls-eapgtc \ - ifcfg-test-onboot-no \ - ifcfg-test-noip \ - ifcfg-test-wifi-open \ - ifcfg-test-wifi-open-auto \ - ifcfg-test-wifi-open-ssid-quoted \ - ifcfg-test-wifi-open-ssid-long-quoted \ - ifcfg-test-wifi-open-ssid-hex \ - ifcfg-test-wifi-open-ssid-long-hex \ - ifcfg-test-wifi-open-ssid-bad-hex \ - ifcfg-test-wifi-wep \ - keys-test-wifi-wep \ - ifcfg-test-wifi-wep-adhoc \ - keys-test-wifi-wep-adhoc \ - ifcfg-test-wifi-wep-eap-ttls-chap \ - keys-test-wifi-wep-eap-ttls-chap \ - ifcfg-test-wifi-leap \ - keys-test-wifi-leap \ - ifcfg-test-wifi-leap-agent \ - ifcfg-test-wifi-leap-always-ask \ - ifcfg-test-wifi-wpa-psk \ - keys-test-wifi-wpa-psk \ - ifcfg-test-wifi-wpa-psk-2 \ - keys-test-wifi-wpa-psk-2 \ - ifcfg-test-wifi-wpa-psk-unquoted \ - keys-test-wifi-wpa-psk-unquoted \ - ifcfg-test-wifi-wpa-psk-unquoted2 \ - keys-test-wifi-wpa-psk-unquoted2 \ - ifcfg-test-wifi-wpa-psk-adhoc \ - keys-test-wifi-wpa-psk-adhoc \ - ifcfg-test-wifi-wpa-psk-hex \ - keys-test-wifi-wpa-psk-hex \ - ifcfg-test-wifi-wpa-eap-tls \ - keys-test-wifi-wpa-eap-tls \ - ifcfg-test-wifi-wpa-eap-ttls-tls \ - keys-test-wifi-wpa-eap-ttls-tls \ - ifcfg-test-wifi-hidden \ - ifcfg-test-wifi-band-a \ - ifcfg-test-wifi-band-a-channel-mismatch \ - ifcfg-test-wifi-band-bg-channel-mismatch \ - ifcfg-test-wifi-mac-random-always \ - ifcfg-test-wifi-mac-random-never \ - ifcfg-test-wifi-mac-random-default \ - ifcfg-test-wifi-mac-random-missing \ - test_ca_cert.pem \ - test1_key_and_cert.pem \ - ifcfg-test-ibft \ - ifcfg-test-static-routes-legacy \ - route-test-static-routes-legacy \ - ifcfg-test-sit-ignore \ - ifcfg-test-wired-static-routes \ - route-test-wired-static-routes \ - ifcfg-test-wired-static-routes-legacy \ - route-test-wired-static-routes-legacy \ - ifcfg-test-wired-ipv4-manual-1 \ - ifcfg-test-wired-ipv4-manual-2 \ - ifcfg-test-wired-ipv4-manual-3 \ - ifcfg-test-wired-ipv4-manual-4 \ - ifcfg-test-wired-ipv6-manual \ - route6-test-wired-ipv6-manual \ - ifcfg-test-wired-static-no-prefix-8 \ - ifcfg-test-wired-static-no-prefix-16 \ - ifcfg-test-wired-static-no-prefix-24 \ - ifcfg-test-wired-ipv6-only \ - ifcfg-test-wifi-wep-passphrase \ - keys-test-wifi-wep-passphrase \ - ifcfg-test-wifi-wep-40-ascii \ - keys-test-wifi-wep-40-ascii \ - ifcfg-test-wifi-wep-104-ascii \ - keys-test-wifi-wep-104-ascii \ - ifcfg-test-wired-qeth-static \ - ifcfg-test-wired-ctc-static \ - ifcfg-test-bridge-main \ - ifcfg-test-bridge-component \ - ifcfg-test-bridge-missing-stp \ - ifcfg-test-vlan-interface \ - ifcfg-test-vlan-only-vlanid \ - ifcfg-test-vlan-only-device \ - ifcfg-test-vlan-physdev \ - ifcfg-test-vlan-reorder-hdr-1 \ - ifcfg-test-vlan-reorder-hdr-2 \ - ifcfg-test-vlan-flags-1 \ - ifcfg-test-vlan-flags-2 \ - ifcfg-test-wifi-wep-no-keys \ - ifcfg-test-permissions \ - ifcfg-test-wifi-wep-agent-keys \ - ifcfg-test-wifi-dynamic-wep-leap \ - keys-test-wifi-dynamic-wep-leap \ - ifcfg-test-infiniband \ - ifcfg-test-bond-main \ - ifcfg-test-bond-slave \ - ifcfg-test-bond-slave-ib \ - ifcfg-test-bond-mode-numeric \ - ifcfg-test-dcb \ - ifcfg-test-dcb-default-app-priorities \ - ifcfg-test-dcb-bad-booleans \ - ifcfg-test-dcb-short-booleans \ - ifcfg-test-dcb-bad-uints \ - ifcfg-test-dcb-short-uints \ - ifcfg-test-dcb-bad-percent \ - ifcfg-test-dcb-short-percent \ - ifcfg-test-dcb-pgpct-not-100 \ - ifcfg-test-fcoe-fabric \ - ifcfg-test-fcoe-vn2vn \ - ifcfg-test-team-master-1 \ - ifcfg-test-team-master-2 \ - ifcfg-test-team-master-invalid \ - ifcfg-test-team-port-1 \ - ifcfg-test-team-port-2 \ - ifcfg-test-team-port-empty-config \ - ifcfg-test-vlan-trailing-spaces \ - ifcfg-test-dns-options \ - ifcfg-test-wired-wake-on-lan \ - ifcfg-test-wired-ipv6-only-1 - - -# make target dependencies can't have colons in their names, which ends up -# meaning that we can't add the alias files to EXTRA_DIST -ALIAS_FILES = \ - ifcfg-aliasem0 \ - ifcfg-aliasem0:1 \ - ifcfg-aliasem0:2 \ - ifcfg-aliasem0:99 \ - ifcfg-aliasem1 \ - ifcfg-aliasem1:1 \ - ifcfg-aliasem2 \ - ifcfg-aliasem2:1 - -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: all all-am check check-am check-local clean clean-generic \ - clean-libtool cscopelist-am ctags-am dist-hook distclean \ - distclean-generic distclean-libtool distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ - uninstall-am - -.PRECIOUS: Makefile - - -dist-hook: - @for f in $(ALIAS_FILES); do \ - cp $(abs_srcdir)/$$f $(distdir)/; \ - done - -check-local: - @for f in $(EXTRA_DIST) $(ALIAS_FILES); do \ - chmod 0600 $(abs_srcdir)/$$f; \ - done - -# Make the special temp dir for some written connections - mkdir -p $(abs_builddir)/tmp - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables index c7892a21..1b10cddb 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables @@ -1,3 +1,4 @@ DEVICE=eth0 HWADDR_BLACKLIST="00:16:41:11:22:88 00:16:41:11:22:99 XX:aa:invalid 6A:5D:5A:FA:DD:F0" +AUTOCONNECT_RETRIES=100 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic new file mode 100644 index 00000000..e2cf6c21 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic @@ -0,0 +1,15 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=dhcp +ONBOOT=yes +USERCTL=yes +IPV6INIT=no +NM_CONTROLLED=yes +PEERDNS=no + +# proxy configuration +PROXY_METHOD=auto +PAC_URL=http://wpad.mycompany.com/wpad.dat +BROWSER_ONLY=yes diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk index 2119ba8e..a78051aa 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-wpa-psk @@ -16,4 +16,4 @@ CIPHER_GROUP="TKIP CCMP WEP40 WEP104" KEY_MGMT=WPA-PSK WPA_ALLOW_WPA=yes WPA_ALLOW_WPA2=yes - +LAST_ENTRY=no-newline \ No newline at end of file diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-auto-negotiate-on b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-auto-negotiate-on new file mode 100644 index 00000000..d0b50775 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-auto-negotiate-on @@ -0,0 +1,22 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +ONBOOT=yes +USERCTL=yes +MTU=1492 +NM_CONTROLLED=yes +DNS1=4.2.2.1 +DNS2=4.2.2.2 +IPADDR=192.168.1.5 +NETMASK=255.255.255.0 +GATEWAY=192.168.1.1 +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR=dead:beaf::1 +IPV6ADDR_SECONDARIES="dead:beaf::2/56" +DNS3=1:2:3:4::a +DNS4=1:2:3:4::b +RES_OPTIONS= +ETHTOOL_OPTS="wol apgs sopass 00:11:22:33:44:55 autoneg on speed 100" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback new file mode 100644 index 00000000..d38e762e --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback @@ -0,0 +1,12 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=dhcp +ONBOOT=yes +IPV6INIT=yes +IPV6_AUTOCONF=yes +USERCTL=yes +NM_CONTROLLED=yes +PEERDNS=no +DHCP_HOSTNAME="fully.qualified.domain" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-unknown-ethtool-opt b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-unknown-ethtool-opt new file mode 100644 index 00000000..861dd41f --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-unknown-ethtool-opt @@ -0,0 +1,22 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +ONBOOT=yes +USERCTL=yes +MTU=1492 +NM_CONTROLLED=yes +DNS1=4.2.2.1 +DNS2=4.2.2.2 +IPADDR=192.168.1.5 +NETMASK=255.255.255.0 +GATEWAY=192.168.1.1 +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR=dead:beaf::1 +IPV6ADDR_SECONDARIES="dead:beaf::2/56" +DNS3=1:2:3:4::a +DNS4=1:2:3:4::b +RES_OPTIONS= +ETHTOOL_OPTS="unknown1 wol apgs sopass 00:11:22:33:44:55 unkwnown2 opt2 unknown3" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1 new file mode 100644 index 00000000..c927389e --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1 @@ -0,0 +1,8 @@ +FOO='val + bar=3' +wrong line + F2=b + F3='b +XXX=adf' + XXX2=val2 +' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1.expected new file mode 100644 index 00000000..568b2efc --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-1.expected @@ -0,0 +1,12 @@ +FOO= +#NM: FOO='val +bar= +#NM: bar=3' +#NM: wrong line + F2=b +F3= +#NM: F3='b +XXX= +#NM: XXX=adf' + XXX2=val2 +#NM: ' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2 new file mode 100644 index 00000000..850149b2 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2 @@ -0,0 +1,3 @@ +FOO=' +BAR=a +' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2.expected new file mode 100644 index 00000000..6ec53c17 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-2.expected @@ -0,0 +1,4 @@ +FOO= +#NM: FOO=' +BAR=a +#NM: ' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3 new file mode 100644 index 00000000..3d198e00 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3 @@ -0,0 +1,3 @@ +FOO=' +BAR=" +' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3.expected new file mode 100644 index 00000000..d2b27eb3 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-3.expected @@ -0,0 +1,5 @@ +FOO= +#NM: FOO=' +BAR= +#NM: BAR=" +#NM: ' diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4 new file mode 100644 index 00000000..a7156e33 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4 @@ -0,0 +1,36 @@ +# test what happens with multiple defines of a name. +# +# Note that svGetValue() will return "l4x", which +# isn't correct in terms of shell-parsing. But we +# don't consider only line-by-line, thus this is +# expected. +# +# Also note that setting NAME will replace the last +# occurance, and delete all previous once. + +#L1 +NAME=l2 + +#L2 +NAME=l3 + +some_key1='' +some_key2=$'\U0x' +some_key3=$'x\U0' + +#L4 +NAME=' +NAME=l4x +' + +#Lx-1 +NAME2=not-visible +#Lx-2 +NAME2='invalid +#Lx-3 + +#Ly-1 +NAME3='invalid +#Ly-2 +NAME3=name3-value +#Ly-3 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4.expected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4.expected new file mode 100644 index 00000000..674df840 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-write-unknown-4.expected @@ -0,0 +1,31 @@ +# test what happens with multiple defines of a name. +# +# Note that svGetValue() will return "l4x", which +# isn't correct in terms of shell-parsing. But we +# don't consider only line-by-line, thus this is +# expected. +# +# Also note that setting NAME will replace the last +# occurance, and delete all previous once. + +#L1 + +#L2 + +some_key1='' +some_key2=$'\U0x' +some_key3=$'x\U0' + +#L4 +NAME=set-by-test1 +#NM: ' + +#Lx-1 +#Lx-2 +NAME2=set-by-test2 +#Lx-3 + +#Ly-1 +#Ly-2 +NAME3=set-by-test3 +#Ly-3 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 index 6a63e817..995721dd 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/keys-test-wifi-wpa-psk-2 @@ -1,2 +1,2 @@ -WPA_PSK=$'They\'re really saying I love you. >>`<< \' +WPA_PSK="They're really saying I love you. >>\`<< '" diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c deleted file mode 100644 index d2a348bb..00000000 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#include "nm-default.h" - -#include <stdio.h> -#include <stdarg.h> -#include <unistd.h> -#include <string.h> - -#include "common.h" -#include "utils.h" - -#include "nm-test-utils-core.h" - -static void -test_get_ifcfg_name (const char *desc, - const char *path, - gboolean only_ifcfg, - const char *expected) -{ - const char *result; - - result = utils_get_ifcfg_name (path, only_ifcfg); - g_assert_cmpstr (result, ==, expected); -} - -static void -test_get_ifcfg_path (const char *desc, - const char *path, - const char *expected) -{ - char *result; - - result = utils_get_ifcfg_path (path); - g_assert_cmpstr (result, ==, expected); - g_free (result); -} - -static void -test_get_keys_path (const char *desc, - const char *path, - const char *expected) -{ - char *result; - - result = utils_get_keys_path (path); - g_assert_cmpstr (result, ==, expected); - g_free (result); -} - -static void -test_get_route_path (const char *desc, - const char *path, - const char *expected) -{ - char *result; - - result = utils_get_route_path (path); - g_assert_cmpstr (result, ==, expected); - g_free (result); -} - -static void -test_ignored (const char *desc, const char *path, gboolean expected_ignored) -{ - gboolean result; - - result = utils_should_ignore_file (path, FALSE); - g_assert (result == expected_ignored); -} - -static void -test_name (void) -{ - test_get_ifcfg_name ("get-ifcfg-name-bad", "/foo/bar/adfasdfadf", FALSE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-good", "/foo/bar/ifcfg-FooBar", FALSE, "FooBar"); - test_get_ifcfg_name ("get-ifcfg-name-keys", "/foo/bar/keys-BlahLbah", FALSE, "BlahLbah"); - test_get_ifcfg_name ("get-ifcfg-name-route", "/foo/bar/route-Lalalala", FALSE, "Lalalala"); - test_get_ifcfg_name ("get-ifcfg-name-only-ifcfg-route", "/foo/bar/route-Lalalala", TRUE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-only-ifcfg-keys", "/foo/bar/keys-Lalalala", TRUE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-no-path-ifcfg", "ifcfg-Lalalala", FALSE, "Lalalala"); - test_get_ifcfg_name ("get-ifcfg-name-no-path-keys", "keys-Lalalala", FALSE, "Lalalala"); - test_get_ifcfg_name ("get-ifcfg-name-no-path-route", "route-Lalalala", FALSE, "Lalalala"); - - test_get_ifcfg_name ("get-ifcfg-name-bad2-ifcfg", "/foo/bar/asdfasifcfg-Foobar", FALSE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-bad2-keys", "/foo/bar/asdfaskeys-Foobar", FALSE, NULL); - test_get_ifcfg_name ("get-ifcfg-name-bad2-route", "/foo/bar/asdfasroute-Foobar", FALSE, NULL); -} - -static void -test_path (void) -{ - test_get_ifcfg_path ("ifcfg-path-bad", "/foo/bar/adfasdfasdf", NULL); - test_get_ifcfg_path ("ifcfg-path-from-keys-no-path", "keys-BlahBlah", "ifcfg-BlahBlah"); - test_get_ifcfg_path ("ifcfg-path-from-keys", "/foo/bar/keys-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); - test_get_ifcfg_path ("ifcfg-path-from-route", "/foo/bar/route-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); - - test_get_keys_path ("keys-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); - test_get_keys_path ("keys-path-from-ifcfg-no-path", "ifcfg-FooBar", "keys-FooBar"); - test_get_keys_path ("keys-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/keys-FooBar"); - test_get_keys_path ("keys-path-from-route", "/foo/bar/route-FooBar", "/foo/bar/keys-FooBar"); - - test_get_route_path ("route-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); - test_get_route_path ("route-path-from-ifcfg-no-path", "ifcfg-FooBar", "route-FooBar"); - test_get_route_path ("route-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/route-FooBar"); - test_get_route_path ("route-path-from-keys", "/foo/bar/keys-FooBar", "/foo/bar/route-FooBar"); -} - -static void -test_ignore (void) -{ - test_ignored ("ignored-ifcfg", "ifcfg-FooBar", FALSE); - test_ignored ("ignored-keys", "keys-FooBar", FALSE); - test_ignored ("ignored-route", "route-FooBar", FALSE); - test_ignored ("ignored-bak", "ifcfg-FooBar" BAK_TAG, TRUE); - test_ignored ("ignored-tilde", "ifcfg-FooBar" TILDE_TAG, TRUE); - test_ignored ("ignored-orig", "ifcfg-FooBar" ORIG_TAG, TRUE); - test_ignored ("ignored-rej", "ifcfg-FooBar" REJ_TAG, TRUE); - test_ignored ("ignored-rpmnew", "ifcfg-FooBar" RPMNEW_TAG, TRUE); - test_ignored ("ignored-augnew", "ifcfg-FooBar" AUGNEW_TAG, TRUE); - test_ignored ("ignored-augtmp", "ifcfg-FooBar" AUGTMP_TAG, TRUE); -} - -NMTST_DEFINE (); - -int main (int argc, char **argv) -{ - nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); - - /* The tests */ - g_test_add_func ("/settings/plugins/ifcfg-rh/name", test_name); - g_test_add_func ("/settings/plugins/ifcfg-rh/path", test_path); - g_test_add_func ("/settings/plugins/ifcfg-rh/ignore", test_ignore); - - return g_test_run (); -} - diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 9ed48beb..1a8439f6 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -50,15 +50,60 @@ #include "NetworkManagerUtils.h" -#include "common.h" -#include "reader.h" -#include "writer.h" -#include "utils.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.h" +#include "settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h" #include "nm-test-utils-core.h" +#define TEST_SCRATCH_DIR_TMP TEST_SCRATCH_DIR"/network-scripts/tmp" + /*****************************************************************************/ +#define _svOpenFile(testfile) \ + ({ \ + shvarFile *_f; \ + GError *_error = NULL; \ + const char *_testfile = (testfile); \ + \ + g_assert (_testfile); \ + _f = svOpenFile (_testfile, &_error); \ + nmtst_assert_success (_f, _error); \ + _f; \ + }) + +#define _svGetValue_check(f, key, expected_value) \ + G_STMT_START { \ + const char *_val; \ + gs_free char *_to_free = NULL; \ + gs_free char *_val_string = NULL; \ + shvarFile *const _f = (f); \ + const char *const _key = (key); \ + \ + _val_string = svGetValueString (_f, _key); \ + _val = svGetValue (_f, _key, &_to_free); \ + g_assert_cmpstr (_val, ==, (expected_value)); \ + g_assert ( (!_val_string && (!_val || !_val[0])) \ + || ( _val_string && nm_streq0 (_val, _val_string))); \ + } G_STMT_END + +#define _writer_update_connection(connection, ifcfg_dir, filename) \ + G_STMT_START { \ + NMConnection *_connection = (connection); \ + const char *_ifcfg_dir = (ifcfg_dir); \ + const char *_filename = (filename); \ + GError *_error = NULL; \ + gboolean _success; \ + \ + g_assert (NM_IS_CONNECTION (connection)); \ + g_assert (_ifcfg_dir && _ifcfg_dir[0]); \ + g_assert (_filename && _filename[0]); \ + \ + _success = writer_update_connection (_connection, _ifcfg_dir, _filename, &_error); \ + nmtst_assert_success (_success, _error); \ + } G_STMT_END + static NMConnection * _connection_from_file (const char *filename, const char *network_file, @@ -273,6 +318,7 @@ test_read_basic (void) g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-minimal"); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, 0); g_assert (nm_setting_connection_get_autoconnect (s_con)); + g_assert_cmpint (nm_setting_connection_get_autoconnect_retries (s_con), ==, -1); /* UUID can't be tested if the ifcfg does not contain the UUID key, because * the UUID is generated on the full path of the ifcfg file, which can change @@ -326,6 +372,7 @@ test_read_miscellaneous_variables (void) g_assert (s_con); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, expected_timestamp); g_assert (nm_setting_connection_get_autoconnect (s_con)); + g_assert_cmpint (nm_setting_connection_get_autoconnect_retries (s_con), ==, 100); /* ===== WIRED SETTING ===== */ s_wired = nm_connection_get_setting_wired (connection); @@ -363,8 +410,8 @@ test_read_variables_corner_cases (void) /* ===== CONNECTION SETTING ===== */ s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); - g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "\""); - g_assert_cmpstr (nm_setting_connection_get_zone (s_con), ==, "'"); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-variables-corner-cases-1"); + g_assert_cmpstr (nm_setting_connection_get_zone (s_con), ==, NULL); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, 0); g_assert (nm_setting_connection_get_autoconnect (s_con)); @@ -449,7 +496,7 @@ test_read_unrecognized (void) /* ===== CONNECTION SETTING ===== */ s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); - g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "U Can't Touch This"); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-unrecognized"); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, expected_timestamp); g_object_unref (connection); @@ -1493,9 +1540,10 @@ test_read_wired_8021x_tls_secret_flags (gconstpointer test_data) static void test_read_write_802_1X_subj_matches (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSetting8021x *s_8021x; - char *written = NULL; g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*missing IEEE_8021X_CA_CERT*peap*"); @@ -1521,14 +1569,12 @@ test_read_write_802_1X_subj_matches (void) _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*missing IEEE_8021X_CA_CERT*peap*"); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); g_test_assert_expected_messages (); - unlink (written); - g_free (written); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -1547,9 +1593,6 @@ test_read_write_802_1X_subj_matches (void) g_assert_cmpint (nm_setting_802_1x_get_num_phase2_altsubject_matches (s_8021x), ==, 2); g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 0), ==, "x.yourdomain.tld"); g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 1), ==, "y.yourdomain.tld"); - - g_object_unref (connection); - g_object_unref (reread); } static void @@ -1741,14 +1784,12 @@ test_read_dns_options (void) static void test_clear_master (void) { + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; - NMConnection *connection; char *unmanaged = NULL; - char *testfile = NULL, *keyfile; - GError *error = NULL; - gboolean success; shvarFile *f; - char *val; /* 1. load the bridge slave connection from disk */ connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-bridge-component", @@ -1776,47 +1817,33 @@ test_clear_master (void) g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NULL); /* 4. update the connection on disk */ + _writer_update_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + testfile); keyfile = utils_get_keys_path (testfile); - success = writer_update_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/", - testfile, - keyfile, - &error); - g_assert_no_error (error); - g_assert (success); - unlink (keyfile); - g_free (keyfile); + g_assert (!g_file_test (keyfile, G_FILE_TEST_EXISTS)); /* 5. check that BRIDGE variable has been removed */ - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - val = svGetValue (f, "BRIDGE", FALSE); - g_assert (!val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "BRIDGE", NULL); svCloseFile (f); - - unlink (testfile); - g_free (testfile); - g_object_unref (connection); } static void test_write_dns_options (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; - char *uuid; NMIPAddress *addr; NMIPAddress *addr6; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -1824,14 +1851,12 @@ test_write_dns_options (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test DNS options", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -1882,7 +1907,6 @@ test_write_dns_options (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); /* RES_OPTIONS is copied to both IPv4 and IPv6 settings */ nm_setting_ip_config_clear_dns_options (s_ip4, TRUE); @@ -1894,10 +1918,6 @@ test_write_dns_options (void) nm_setting_ip_config_add_dns_option (s_ip6, "timeout:3"); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -2023,6 +2043,30 @@ test_read_wifi_open_ssid_hex (void) } static void +test_read_wifi_open_ssid_hex_bad (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWireless *s_wireless; + GBytes *ssid; + const char *expected_ssid = "0x626cxx"; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-bad-hex", + NULL, TYPE_WIRELESS, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System 0x626cxx (test-wifi-open-ssid-bad-hex)"); + + s_wireless = nm_connection_get_setting_wireless (connection); + g_assert (s_wireless); + + ssid = nm_setting_wireless_get_ssid (s_wireless); + g_assert (ssid); + g_assert_cmpmem (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid), expected_ssid, strlen (expected_ssid)); +} + +static void test_read_wifi_open_ssid_bad (gconstpointer data) { _connection_from_file_fail ((const char *) data, NULL, TYPE_WIRELESS, NULL); @@ -2387,6 +2431,16 @@ test_read_wifi_leap_secret_flags (gconstpointer test_data) } static void +test_ifcfg_no_trailing_newline (void) +{ + shvarFile *sv; + + sv = _svOpenFile (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wifi-wpa-psk"); + _svGetValue_check (sv, "LAST_ENTRY", "no-newline"); + svCloseFile (sv); +} + +static void test_read_wifi_wpa_psk (void) { NMConnection *connection; @@ -2535,7 +2589,7 @@ test_read_wifi_wpa_psk_2 (void) s_wsec = nm_connection_get_setting_wireless_security (connection); g_assert (s_wsec); - g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "They're really saying I love you. >>`<< \\"); + g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "They're really saying I love you. >>`<< '"); g_object_unref (connection); } @@ -2574,12 +2628,10 @@ test_read_wifi_wpa_psk_unquoted (void) static void test_read_wifi_wpa_psk_unquoted2 (void) { - /* Ensure a quoted 64-character WPA passphrase will fail since passphrases - * must be between 8 and 63 ASCII characters inclusive per the WPA spec. - */ + gs_unref_object NMConnection *connection = NULL; - _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wifi-wpa-psk-unquoted2", - NULL, TYPE_WIRELESS, NULL); + connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wifi-wpa-psk-unquoted2", + NULL, TYPE_WIRELESS, NULL); } static void @@ -2933,6 +2985,81 @@ test_read_wired_wake_on_lan (void) } static void +test_read_wired_auto_negotiate_off (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-wake-on-lan", + NULL, TYPE_ETHERNET, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + g_assert (!nm_setting_wired_get_auto_negotiate (s_wired)); + g_assert_cmpint (nm_setting_wired_get_speed (s_wired), ==, 100); + g_assert_cmpstr (nm_setting_wired_get_duplex (s_wired), ==, "full"); +} + +static void +test_read_wired_auto_negotiate_on (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-auto-negotiate-on", + NULL, TYPE_ETHERNET, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + g_assert (nm_setting_wired_get_auto_negotiate (s_wired)); + g_assert_cmpint (nm_setting_wired_get_speed (s_wired), ==, 0); + g_assert_cmpstr (nm_setting_wired_get_duplex (s_wired), ==, NULL); +} + +static void +test_read_wired_unknown_ethtool_opt (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-unknown-ethtool-opt", + NULL, TYPE_ETHERNET, NULL); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + g_assert (!nm_setting_wired_get_auto_negotiate (s_wired)); + g_assert (!nm_setting_wired_get_speed (s_wired)); + g_assert (!nm_setting_wired_get_duplex (s_wired)); + + g_assert_cmpint (nm_setting_wired_get_wake_on_lan (s_wired), + ==, + NM_SETTING_WIRED_WAKE_ON_LAN_ARP | + NM_SETTING_WIRED_WAKE_ON_LAN_PHY | + NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC); + g_assert_cmpstr (nm_setting_wired_get_wake_on_lan_password (s_wired), + ==, + "00:11:22:33:44:55"); +} + +static void test_read_wifi_hidden (void) { NMConnection *connection; @@ -2956,11 +3083,11 @@ test_read_wifi_hidden (void) static void test_write_wifi_hidden (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; shvarFile *f; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; @@ -2971,13 +3098,11 @@ test_write_wifi_hidden (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write WiFi Hidden", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -2999,33 +3124,21 @@ test_write_wifi_hidden (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "SSID_HIDDEN", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "yes"); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "SSID_HIDDEN", "yes"); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_read_wifi_mac_random (gconstpointer user_data) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; + gs_free char *path = NULL; NMSettingWireless *s_wifi; - char *path; const char *name; gpointer value_p; NMSettingMacRandomization value; @@ -3035,23 +3148,21 @@ test_read_wifi_mac_random (gconstpointer user_data) path = g_strdup_printf (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-mac-random-%s", name); connection = _connection_from_file (path, NULL, TYPE_WIRELESS, NULL); - g_free (path); s_wifi = nm_connection_get_setting_wireless (connection); g_assert (s_wifi); g_assert_cmpint (nm_setting_wireless_get_mac_address_randomization (s_wifi), ==, value); - - g_object_unref (connection); } static void test_write_wifi_mac_random (gconstpointer user_data) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; + char *val; shvarFile *f; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; @@ -3070,14 +3181,12 @@ test_write_wifi_mac_random (gconstpointer user_data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); val = g_strdup_printf ("Test Write WiFi MAC %s", name); g_object_set (s_con, NM_SETTING_CONNECTION_ID, val, - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); g_free (val); /* Wifi setting */ @@ -3098,35 +3207,25 @@ test_write_wifi_mac_random (gconstpointer user_data) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "MAC_ADDRESS_RANDOMIZATION", FALSE); - g_assert_cmpstr (val, ==, write_expected); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "MAC_ADDRESS_RANDOMIZATION", write_expected); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_wake_on_lan (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingWiredWakeOnLan wol; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; + char *val; shvarFile *f; connection = nm_simple_connection_new (); @@ -3135,13 +3234,11 @@ test_write_wired_wake_on_lan (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Wake-on-LAN", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3162,12 +3259,8 @@ test_write_wired_wake_on_lan (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that the key was written. */ - val = svGetValue (f, "ETHTOOL_OPTS", FALSE); + f = _svOpenFile (testfile); + val = svGetValueString (f, "ETHTOOL_OPTS"); g_assert (val); g_assert (strstr (val, "wol")); g_assert (strstr (val, "sopass 00:00:00:11:22:33")); @@ -3175,13 +3268,78 @@ test_write_wired_wake_on_lan (void) svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); +} - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); +static void +test_write_wired_auto_negotiate_off (void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingWired *s_wired; + char *val; + shvarFile *f; + + connection = nmtst_create_minimal_connection ("Test Write Wired Auto-Negotiate", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); + s_wired = nm_connection_get_setting_wired (connection); + g_object_set (s_wired, + NM_SETTING_WIRED_AUTO_NEGOTIATE, FALSE, + NM_SETTING_WIRED_DUPLEX, "half", + NM_SETTING_WIRED_SPEED, 10, + NULL); + + _writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile); + + f = _svOpenFile (testfile); + val = svGetValueString (f, "ETHTOOL_OPTS"); + g_assert (val); + g_assert (strstr (val, "autoneg off")); + g_assert (strstr (val, "speed 10")); + g_assert (strstr (val, "duplex half")); + g_free (val); + svCloseFile (f); + + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); + + nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); +} + +static void +test_write_wired_auto_negotiate_on (void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingWired *s_wired; + char *val; + shvarFile *f; + + connection = nmtst_create_minimal_connection ("Test Write Wired Auto-Negotiate", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); + s_wired = nm_connection_get_setting_wired (connection); + g_object_set (s_wired, + NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, + NULL); + + _writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile); + + f = _svOpenFile (testfile); + val = svGetValueString (f, "ETHTOOL_OPTS"); + g_assert (val); + g_assert (strstr (val, "autoneg on")); + g_assert (!strstr (val, "speed")); + g_assert (!strstr (val, "duplex")); + g_free (val); + svCloseFile (f); + + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); + + nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); } static void @@ -3208,11 +3366,11 @@ test_read_wifi_band_a (void) static void test_write_wifi_band_a (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; shvarFile *f; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; @@ -3223,13 +3381,11 @@ test_write_wifi_band_a (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write WiFi Band A", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -3251,25 +3407,13 @@ test_write_wifi_band_a (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "BAND", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "a"); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "BAND", "a"); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -3510,19 +3654,18 @@ test_read_wifi_wep_agent_keys (void) static void test_write_wired_static (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *route6file = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4, *reread_s_ip4; NMSettingIPConfig *s_ip6, *reread_s_ip6; - char *uuid; NMIPAddress *addr; NMIPAddress *addr6; NMIPRoute *route6; GError *error = NULL; - char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -3530,14 +3673,13 @@ test_write_wired_static (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, 1, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3627,9 +3769,9 @@ test_write_wired_static (void) _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", &testfile); + route6file = utils_get_route6_path (testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); /* FIXME: currently DNS domains from IPv6 setting are stored in 'DOMAIN' key in ifcfg-file * However after re-reading they are dropped into IPv4 setting. @@ -3645,28 +3787,21 @@ test_write_wired_static (void) g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip4), ==, 204); g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip6), ==, 206); - nmtst_assert_connection_equals (connection, FALSE, reread, FALSE); - - route6file = utils_get_route6_path (testfile); - unlink (route6file); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); - g_free (testfile); - g_free (route6file); - g_object_unref (connection); - g_object_unref (reread); + nmtst_assert_connection_equals (connection, FALSE, reread, FALSE); } static void test_write_wired_dhcp (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -3674,14 +3809,12 @@ test_write_wired_dhcp (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired DHCP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3715,46 +3848,38 @@ test_write_wired_dhcp (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_dhcp_plus_ip (void) { - NMConnection *connection, *reread; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip", NULL, TYPE_ETHERNET, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); } static void test_read_write_wired_dhcp_send_hostname (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; const char * dhcp_hostname = "kamil-patka"; - char *written = NULL; connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-send-hostname", NULL, TYPE_ETHERNET, NULL); @@ -3766,7 +3891,7 @@ test_read_write_wired_dhcp_send_hostname (void) g_assert (s_ip6); g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == TRUE); g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, "svata-pulec"); - g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, "svata-pulec"); + g_assert (!nm_setting_ip_config_get_dhcp_hostname (s_ip6)); /* Set dhcp-send-hostname=false dhcp-hostname="kamil-patka" and write the connection. */ g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, FALSE, NULL); @@ -3775,11 +3900,9 @@ test_read_write_wired_dhcp_send_hostname (void) _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -3791,24 +3914,35 @@ test_read_write_wired_dhcp_send_hostname (void) g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == FALSE); g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, dhcp_hostname); g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, dhcp_hostname); +} - g_object_unref (connection); - g_object_unref (reread); +static void +test_read_wired_dhcpv6_hostname_fallback (void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig *s_ip6; + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcpv6-hostname-fallback", + NULL, TYPE_ETHERNET, NULL); + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + g_assert (s_ip6); + g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip6) == TRUE); + g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, "fully.qualified.domain"); } static void test_write_wired_static_ip6_only (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr6; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -3816,14 +3950,12 @@ test_write_wired_static_ip6_only (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static IP6 Only", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -3863,13 +3995,8 @@ test_write_wired_static_ip6_only (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } /* Test writing an IPv6 config with varying gateway address. @@ -3883,19 +4010,19 @@ test_write_wired_static_ip6_only (void) static void test_write_wired_static_ip6_only_gw (gconstpointer user_data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr6; GError *error = NULL; - char *testfile = NULL; char *id = NULL; - char *written_ifcfg_gateway; + gs_free char *written_ifcfg_gateway = NULL; const char *gateway6 = user_data; + shvarFile *ifcfg; connection = nm_simple_connection_new (); @@ -3903,15 +4030,13 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); id = g_strdup_printf ("Test Write Wired Static IP6 Only With Gateway %s", gateway6 ? gateway6 : "NULL"); g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); g_free (id); /* Wired setting */ @@ -3956,17 +4081,9 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - { - /* re-read the file to check that what key was written. */ - shvarFile *ifcfg = svOpenFile (testfile, &error); - - g_assert_no_error (error); - g_assert (ifcfg); - written_ifcfg_gateway = svGetValue (ifcfg, "IPV6_DEFAULTGW", FALSE); - svCloseFile (ifcfg); - } - - unlink (testfile); + ifcfg = _svOpenFile (testfile); + written_ifcfg_gateway = svGetValueString (ifcfg, "IPV6_DEFAULTGW"); + svCloseFile (ifcfg); /* access the gateway from the loaded connection. */ s_ip6 = nm_connection_get_setting_ip6_config (reread); @@ -3983,23 +4100,19 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip6), ==, gateway6); g_assert_cmpstr (written_ifcfg_gateway, ==, gateway6); } - - g_free (testfile); - g_free (written_ifcfg_gateway); - g_object_unref (connection); - g_object_unref (reread); } static void test_read_write_static_routes_legacy (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *routefile = NULL; + gs_free char *route6file = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *testfile = NULL; - char *routefile = NULL; - char *route6file = NULL; const char *tmp; connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-static-routes-legacy", @@ -4035,40 +4148,31 @@ test_read_write_static_routes_legacy (void) * source tree and for 'make distcheck'. */ _writer_new_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/tmp", + TEST_SCRATCH_DIR_TMP, &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); routefile = utils_get_route_path (testfile); - unlink (routefile); route6file = utils_get_route6_path (testfile); - unlink (route6file); + g_assert (!g_file_test (route6file, G_FILE_TEST_EXISTS)); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (routefile); - g_free (route6file); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_static_routes (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *routefile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr; NMIPRoute *route; GError *error = NULL; - char *testfile = NULL; - char *routefile = NULL; connection = nm_simple_connection_new (); @@ -4076,14 +4180,12 @@ test_write_wired_static_routes (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static Routes", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -4146,34 +4248,26 @@ test_write_wired_static_routes (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); routefile = utils_get_route_path (testfile); - unlink (routefile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (routefile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_dhcp_8021x_peap_mschapv2 (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *keyfile = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; NMSetting8021x *s_8021x; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; connection = nm_simple_connection_new (); @@ -4181,14 +4275,12 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired DHCP 802.1x PEAP MSCHAPv2", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -4238,34 +4330,26 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); - - keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); + keyfile = utils_get_keys_path (testfile); } static void test_write_wired_8021x_tls (gconstpointer test_data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; NMSetting8021x *s_8021x; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; const char *pw; char *tmp; @@ -4278,36 +4362,29 @@ test_write_wired_8021x_tls (gconstpointer test_data) flags = GPOINTER_TO_INT (flags_p); connection = nm_simple_connection_new (); - g_assert (connection != NULL); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired 802.1x TLS Blobs", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, @@ -4316,7 +4393,6 @@ test_write_wired_8021x_tls (gconstpointer test_data) /* 802.1x setting */ s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - g_assert (s_8021x); nm_connection_add_setting (connection, NM_SETTING (s_8021x)); g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL); @@ -4365,9 +4441,9 @@ test_write_wired_8021x_tls (gconstpointer test_data) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); + keyfile = utils_get_keys_path (testfile); - unlink (keyfile); + nmtst_file_unlink_if_exists (keyfile); /* Ensure the reread connection's certificates and private key are paths; no * matter what scheme was used in the original connection they will be read @@ -4411,21 +4487,16 @@ test_write_wired_8021x_tls (gconstpointer test_data) /* Clean up created certs and keys */ tmp = utils_cert_path (testfile, "ca-cert.der"); - unlink (tmp); + nmtst_file_unlink_if_exists (tmp); g_free (tmp); tmp = utils_cert_path (testfile, "client-cert.der"); - unlink (tmp); + nmtst_file_unlink_if_exists (tmp); g_free (tmp); tmp = utils_cert_path (testfile, "private-key.pem"); - unlink (tmp); + nmtst_file_unlink_if_exists (tmp); g_free (tmp); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } #define TEST_SCRATCH_ALIAS_BASE TEST_SCRATCH_DIR "/network-scripts/ifcfg-alias0" @@ -4433,45 +4504,43 @@ test_write_wired_8021x_tls (gconstpointer test_data) static void test_write_wired_aliases (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *uuid; int num_addresses = 4; const char *ip[] = { "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" }; const char *label[] = { NULL, "alias0:2", NULL, "alias0:3" }; NMIPAddress *addr; GError *error = NULL; - char *testfile = NULL; shvarFile *ifcfg; int i, j; + nmtst_file_unlink_if_exists (TEST_SCRATCH_ALIAS_BASE ":2"); + nmtst_file_unlink_if_exists (TEST_SCRATCH_ALIAS_BASE ":3"); + nmtst_file_unlink_if_exists (TEST_SCRATCH_ALIAS_BASE ":5"); + connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "alias0", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -4493,15 +4562,15 @@ test_write_wired_aliases (void) /* Create some pre-existing alias files, to make sure they get overwritten / deleted. */ ifcfg = svCreateFile (TEST_SCRATCH_ALIAS_BASE ":2"); - svSetValue (ifcfg, "DEVICE", "alias0:2", FALSE); - svSetValue (ifcfg, "IPADDR", "192.168.1.2", FALSE); + svSetValueString (ifcfg, "DEVICE", "alias0:2"); + svSetValueString (ifcfg, "IPADDR", "192.168.1.2"); svWriteFile (ifcfg, 0644, NULL); svCloseFile (ifcfg); g_assert (g_file_test (TEST_SCRATCH_ALIAS_BASE ":2", G_FILE_TEST_EXISTS)); ifcfg = svCreateFile (TEST_SCRATCH_ALIAS_BASE ":5"); - svSetValue (ifcfg, "DEVICE", "alias0:5", FALSE); - svSetValue (ifcfg, "IPADDR", "192.168.1.5", FALSE); + svSetValueString (ifcfg, "DEVICE", "alias0:5"); + svSetValueString (ifcfg, "IPADDR", "192.168.1.5"); svWriteFile (ifcfg, 0644, NULL); svCloseFile (ifcfg); g_assert (g_file_test (TEST_SCRATCH_ALIAS_BASE ":5", G_FILE_TEST_EXISTS)); @@ -4516,9 +4585,8 @@ test_write_wired_aliases (void) g_assert (!g_file_test (TEST_SCRATCH_ALIAS_BASE ":5", G_FILE_TEST_EXISTS)); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); - unlink (TEST_SCRATCH_ALIAS_BASE ":2"); - unlink (TEST_SCRATCH_ALIAS_BASE ":3"); + nmtst_file_unlink (TEST_SCRATCH_ALIAS_BASE ":2"); + nmtst_file_unlink (TEST_SCRATCH_ALIAS_BASE ":3"); /* nm_connection_compare() is not guaranteed to succeed, because the * aliases get read back in essentially random order. So just @@ -4555,20 +4623,17 @@ test_write_wired_aliases (void) /* Gateway */ g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1"); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_gateway (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *uuid, *testfile = NULL, *val; GError *error = NULL; shvarFile *f; NMIPAddress *addr; @@ -4579,13 +4644,11 @@ test_write_gateway (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Static Addresses Gateway", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -4617,77 +4680,37 @@ test_write_gateway (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that the keys was written as IPADDR, GATEWAY and IPADDR1, GATEWAY1 */ - val = svGetValue (f, "IPADDR", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "1.1.1.3"); - g_free (val); - - val = svGetValue (f, "IPADDR1", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "2.2.2.5"); - g_free (val); - - val = svGetValue (f, "IPADDR0", FALSE); - g_assert (val == NULL); - - val = svGetValue (f, "PREFIX", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "24"); - g_free (val); - - val = svGetValue (f, "PREFIX1", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "24"); - g_free (val); - - val = svGetValue (f, "PREFIX0", FALSE); - g_assert (val == NULL); - - val = svGetValue (f, "GATEWAY", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "1.1.1.254"); - g_free (val); - - val = svGetValue (f, "GATEWAY0", FALSE); - g_assert (val == NULL); - - val = svGetValue (f, "GATEWAY1", FALSE); - g_assert (val == NULL); - + f = _svOpenFile (testfile); + _svGetValue_check (f, "IPADDR", "1.1.1.3"); + _svGetValue_check (f, "IPADDR1", "2.2.2.5"); + _svGetValue_check (f, "IPADDR0", NULL); + _svGetValue_check (f, "PREFIX", "24"); + _svGetValue_check (f, "PREFIX1", "24"); + _svGetValue_check (f, "PREFIX0", NULL); + _svGetValue_check (f, "GATEWAY", "1.1.1.254"); + _svGetValue_check (f, "GATEWAY0", NULL); + _svGetValue_check (f, "GATEWAY1", NULL); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_open (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - GError *error = NULL; - char *testfile = NULL; GBytes *ssid; const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; shvarFile *ifcfg; - char *tmp; connection = nm_simple_connection_new (); @@ -4695,14 +4718,12 @@ test_write_wifi_open (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Open", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -4745,39 +4766,23 @@ test_write_wifi_open (void) reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - /* Now make sure that the ESSID item isn't double-quoted (rh #606518) */ - ifcfg = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (ifcfg != NULL); - - tmp = svGetValue (ifcfg, "ESSID", TRUE); - g_assert (tmp); - - g_assert (strncmp (tmp, "\"\"", 2) != 0); - - g_free (tmp); + ifcfg = _svOpenFile (testfile); + _svGetValue_check (ifcfg, "ESSID", "Test SSID"); svCloseFile (ifcfg); - unlink (testfile); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_open_hex_ssid (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; GBytes *ssid; const unsigned char ssid_data[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd }; @@ -4787,14 +4792,12 @@ test_write_wifi_open_hex_ssid (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Open Hex SSID", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -4831,28 +4834,22 @@ test_write_wifi_open_hex_ssid (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -4863,14 +4860,12 @@ test_write_wifi_wep (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -4921,36 +4916,28 @@ test_write_wifi_wep (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_adhoc (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -4962,14 +4949,12 @@ test_write_wifi_wep_adhoc (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP AdHoc", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5024,35 +5009,27 @@ test_write_wifi_wep_adhoc (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_passphrase (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -5063,14 +5040,12 @@ test_write_wifi_wep_passphrase (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP Passphrase", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5119,35 +5094,27 @@ test_write_wifi_wep_passphrase (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_40_ascii (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah40"; struct stat statbuf; @@ -5158,14 +5125,12 @@ test_write_wifi_wep_40_ascii (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP 40 ASCII", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5216,35 +5181,27 @@ test_write_wifi_wep_40_ascii (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_104_ascii (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah104"; struct stat statbuf; @@ -5255,14 +5212,12 @@ test_write_wifi_wep_104_ascii (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP 104 ASCII", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5313,36 +5268,27 @@ test_write_wifi_wep_104_ascii (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_leap (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct stat statbuf; @@ -5353,14 +5299,12 @@ test_write_wifi_leap (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi LEAP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5408,35 +5352,27 @@ test_write_wifi_leap (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); g_assert_cmpint (stat (keyfile, &statbuf), ==, 0); g_assert (S_ISREG (statbuf.st_mode)); g_assert_cmpint ((statbuf.st_mode & 0077), ==, 0); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_leap_secret_flags (gconstpointer data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; NMSettingSecretFlags flags = GPOINTER_TO_UINT (data); @@ -5446,20 +5382,16 @@ test_write_wifi_leap_secret_flags (gconstpointer data) /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi LEAP Secret Flags", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -5471,7 +5403,6 @@ test_write_wifi_leap_secret_flags (gconstpointer data) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -5484,13 +5415,11 @@ test_write_wifi_leap_secret_flags (gconstpointer data) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -5505,7 +5434,6 @@ test_write_wifi_leap_secret_flags (gconstpointer data) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); /* No key should be written out since the secret is not system owned */ keyfile = utils_get_keys_path (testfile); @@ -5516,26 +5444,20 @@ test_write_wifi_leap_secret_flags (gconstpointer data) */ g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, NULL, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_psk (gconstpointer test_data) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; struct { @@ -5553,14 +5475,12 @@ test_write_wifi_wpa_psk (gconstpointer test_data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, args.name, - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5621,33 +5541,25 @@ test_write_wifi_wpa_psk (gconstpointer test_data) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_psk_adhoc (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; NMIPAddress *addr; @@ -5658,14 +5570,12 @@ test_write_wifi_wpa_psk_adhoc (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA PSK", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5727,35 +5637,27 @@ test_write_wifi_wpa_psk_adhoc (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_eap_tls (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -5765,14 +5667,12 @@ test_write_wifi_wpa_eap_tls (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TLS", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5848,35 +5748,27 @@ test_write_wifi_wpa_eap_tls (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_eap_ttls_tls (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -5886,14 +5778,12 @@ test_write_wifi_wpa_eap_ttls_tls (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TTLS (TLS)", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -5985,35 +5875,27 @@ test_write_wifi_wpa_eap_ttls_tls (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wpa_eap_ttls_mschapv2 (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -6023,14 +5905,12 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TTLS (MSCHAPv2)", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); @@ -6099,34 +5979,24 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); - - keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); + keyfile = utils_get_keys_path (testfile); } static void test_write_wifi_wpa_then_open (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_free char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - gboolean success; - GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; @@ -6135,25 +6005,20 @@ test_write_wifi_wpa_then_open (void) */ connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "random wifi connection", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -6167,7 +6032,6 @@ test_write_wifi_wpa_then_open (void) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6185,16 +6049,12 @@ test_write_wifi_wpa_then_open (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); - g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); - g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, @@ -6218,51 +6078,30 @@ test_write_wifi_wpa_then_open (void) nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); /* Write it back out */ + _writer_update_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + testfile); keyfile = utils_get_keys_path (testfile); - success = writer_update_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/", - testfile, - keyfile, - &error); - g_assert_no_error (error); - g_assert (success); - - unlink (keyfile); - g_free (keyfile); - keyfile = NULL; + g_assert (!g_file_test (keyfile, G_FILE_TEST_EXISTS)); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); - - /* No keyfile since it's an open connection this time */ - keyfile = utils_get_keys_path (testfile); - g_assert (g_file_test (keyfile, G_FILE_TEST_EXISTS) == FALSE); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - unlink (testfile); - g_free (testfile); - g_free (keyfile); - g_object_unref (reread); - - g_object_unref (connection); } static void test_write_wifi_wpa_then_wep_with_perms (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; gboolean success; - GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; char **perms; const char *ssid_data = "SomeSSID"; @@ -6276,25 +6115,21 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); perms = g_strsplit ("user:superman:", ",", -1); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "random wifi connection 2", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_PERMISSIONS, perms, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); g_strfreev (perms); g_assert_cmpint (nm_setting_connection_get_num_permissions (s_con), ==, 1); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -6308,7 +6143,6 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6326,14 +6160,12 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6357,7 +6189,6 @@ test_write_wifi_wpa_then_wep_with_perms (void) /* Now change the connection to WEP and recheck */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6366,17 +6197,9 @@ test_write_wifi_wpa_then_wep_with_perms (void) nm_setting_wireless_security_set_wep_key (s_wsec, 0, "abraka dabra"); /* Write it back out */ - keyfile = utils_get_keys_path (testfile); - success = writer_update_connection (connection, - TEST_SCRATCH_DIR "/network-scripts/", - testfile, - keyfile, - &error); - g_assert_no_error (error); - g_assert (success); - - g_free (keyfile); - keyfile = NULL; + _writer_update_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); @@ -6387,55 +6210,38 @@ test_write_wifi_wpa_then_wep_with_perms (void) g_assert (success); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); - unlink (testfile); - g_free (keyfile); - - g_free (testfile); - g_object_unref (reread); - - g_object_unref (connection); } static void test_write_wifi_dynamic_wep_leap (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + nmtst_auto_unlinkfile char *keyfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSetting8021x *s_8021x; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - GError *error = NULL; - char *testfile = NULL; - char *keyfile = NULL; GBytes *ssid; const char *ssid_data = "blahblah"; shvarFile *ifcfg; - char *tmp; connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Dynamic WEP LEAP", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (ssid_data, strlen (ssid_data)); @@ -6449,14 +6255,12 @@ test_write_wifi_dynamic_wep_leap (void) /* Wireless security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL); /* Wireless security setting */ s_8021x = (NMSetting8021x *) nm_setting_802_1x_new (); - g_assert (s_8021x); nm_connection_add_setting (connection, NM_SETTING (s_8021x)); nm_setting_802_1x_add_eap_method (s_8021x, "leap"); @@ -6468,13 +6272,11 @@ test_write_wifi_dynamic_wep_leap (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6491,7 +6293,6 @@ test_write_wifi_dynamic_wep_leap (void) reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); keyfile = utils_get_keys_path (testfile); - unlink (keyfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -6499,38 +6300,23 @@ test_write_wifi_dynamic_wep_leap (void) * did not get written. Check first that the auth alg is not set to "LEAP" * and next that the only IEEE 802.1x EAP method is "LEAP". */ - ifcfg = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (ifcfg); - tmp = svGetValue (ifcfg, "SECURITYMODE", FALSE); - g_assert_cmpstr (tmp, ==, NULL); - g_free (tmp); - - tmp = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE); - g_assert_cmpstr (tmp, ==, "LEAP"); - g_free (tmp); - + ifcfg = _svOpenFile (testfile); + _svGetValue_check (ifcfg, "SECURITYMODE", NULL); + _svGetValue_check (ifcfg, "IEEE_8021X_EAP_METHODS", "LEAP"); svCloseFile (ifcfg); - unlink (testfile); - - g_free (testfile); - g_free (keyfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_qeth_dhcp (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; char **subchans; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -6538,14 +6324,12 @@ test_write_wired_qeth_dhcp (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired qeth Static", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -6587,50 +6371,37 @@ test_write_wired_qeth_dhcp (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wired_ctc_dhcp (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; char **subchans; - GError *error = NULL; - char *testfile = NULL; shvarFile *ifcfg; - char *tmp; connection = nm_simple_connection_new (); - g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired ctc Static", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); subchans = g_strsplit ("0.0.600,0.0.601", ",", -1); @@ -6643,13 +6414,11 @@ test_write_wired_ctc_dhcp (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6664,43 +6433,30 @@ test_write_wired_ctc_dhcp (void) &testfile); /* Ensure the CTCPROT item gets written out as it's own option */ - ifcfg = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (ifcfg); + ifcfg = _svOpenFile (testfile); - tmp = svGetValue (ifcfg, "CTCPROT", TRUE); - g_assert (tmp); - g_assert_cmpstr (tmp, ==, "0"); - g_free (tmp); + _svGetValue_check (ifcfg, "CTCPROT", "0"); /* And that it's not in the generic OPTIONS string */ - tmp = svGetValue (ifcfg, "OPTIONS", TRUE); - g_assert (tmp == NULL); - g_free (tmp); + _svGetValue_check (ifcfg, "OPTIONS", NULL); svCloseFile (ifcfg); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_permissions (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -6708,14 +6464,12 @@ test_write_permissions (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Permissions", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); nm_setting_connection_add_permission (s_con, "user", "blahblah", NULL); nm_setting_connection_add_permission (s_con, "user", "foobar", NULL); @@ -6749,55 +6503,44 @@ test_write_permissions (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_write_wifi_wep_agent_keys (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; const char *str_ssid = "foobarbaz"; GBytes *ssid; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection != NULL); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP Agent Owned", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free (uuid); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -6807,7 +6550,6 @@ test_write_wifi_wep_agent_keys (void) /* Wifi setting */ s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); - g_assert (s_wifi); nm_connection_add_setting (connection, NM_SETTING (s_wifi)); ssid = g_bytes_new (str_ssid, strlen (str_ssid)); @@ -6819,7 +6561,6 @@ test_write_wifi_wep_agent_keys (void) /* Wifi security setting */ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); - g_assert (s_wsec); nm_connection_add_setting (connection, NM_SETTING (s_wsec)); g_object_set (s_wsec, @@ -6836,7 +6577,6 @@ test_write_wifi_wep_agent_keys (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_WIRELESS, NULL); - unlink (testfile); /* Remove the WEP key from the original, because it should not have been * written out to disk as it was agent-owned. The new connection should @@ -6849,10 +6589,6 @@ test_write_wifi_wep_agent_keys (void) NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -6864,7 +6600,6 @@ test_write_wired_pppoe (void) NMSettingIPConfig *s_ip4; NMSettingPppoe *s_pppoe; NMSettingPpp *s_ppp; - char *uuid; GError *error = NULL; connection = nm_simple_connection_new (); @@ -6873,14 +6608,12 @@ test_write_wired_pppoe (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired PPPoE", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -6925,7 +6658,6 @@ test_write_vpn (void) NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; NMSettingVpn *s_vpn; - char *uuid; GError *error = NULL; connection = nm_simple_connection_new (); @@ -6934,14 +6666,12 @@ test_write_vpn (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write VPN", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_VPN_SETTING_NAME, NULL); - g_free (uuid); /* VPN setting */ s_vpn = (NMSettingVpn *) nm_setting_vpn_new (); @@ -6983,7 +6713,6 @@ test_write_mobile_broadband (gconstpointer data) NMSettingCdma *s_cdma; NMSettingPpp *s_ppp; NMSettingSerial *s_serial; - char *uuid; GError *error = NULL; gboolean gsm = GPOINTER_TO_UINT (data); @@ -6993,14 +6722,12 @@ test_write_mobile_broadband (gconstpointer data) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, gsm ? "Test Write GSM" : "Test Write CDMA", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, gsm ? NM_SETTING_GSM_SETTING_NAME : NM_SETTING_CDMA_SETTING_NAME, NULL); - g_free (uuid); if (gsm) { /* GSM setting */ @@ -7085,39 +6812,34 @@ test_read_bridge_main (void) static void test_write_bridge_main (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingBridge *s_bridge; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid; NMIPAddress *addr; static const char *mac = "31:33:33:37:be:cd"; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Main", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_INTERFACE_NAME, "br0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, NULL); - g_free (uuid); /* bridge setting */ s_bridge = (NMSettingBridge *) nm_setting_bridge_new (); - g_assert (s_bridge); nm_connection_add_setting (connection, NM_SETTING (s_bridge)); g_object_set (s_bridge, @@ -7126,7 +6848,6 @@ test_write_bridge_main (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -7142,13 +6863,14 @@ test_write_bridge_main (void) /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); + nmtst_assert_connection_verifies_without_normalization (connection); _writer_new_connection (connection, @@ -7156,13 +6878,8 @@ test_write_bridge_main (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_BRIDGE, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7192,38 +6909,33 @@ test_read_bridge_component (void) static void test_write_bridge_component (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSetting *s_port; static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Component", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "br0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); g_object_set (s_wired, @@ -7246,13 +6958,8 @@ test_write_bridge_component (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7485,78 +7192,64 @@ test_read_vlan_flags_2 (void) static void test_write_vlan (void) { - NMConnection *connection; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; connection = _connection_from_file (TEST_IFCFG_VLAN_INTERFACE, NULL, TYPE_VLAN, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); - - unlink (written); - g_free (written); - - g_object_unref (connection); + &testfile); } static void test_write_vlan_flags (void) { - NMConnection *connection, *reread; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-2", NULL, TYPE_VLAN, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); - - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); + &testfile); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); } static void test_write_vlan_only_vlanid (void) { - NMConnection *connection, *reread; - char *written = NULL; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; connection = _connection_from_file (TEST_IFCFG_VLAN_ONLY_VLANID, NULL, TYPE_VLAN, NULL); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", - &written); + &testfile); - reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); - unlink (written); - g_free (written); + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); } static void test_write_vlan_reorder_hdr (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingVlan *s_vlan; NMSettingWired *s_wired; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7564,14 +7257,12 @@ test_write_vlan_reorder_hdr (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write VLAN reorder_hdr", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_VLAN_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -7592,51 +7283,40 @@ test_write_vlan_reorder_hdr (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); - g_free (testfile); } static void test_write_ethernet_missing_ipv6 (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); g_assert (connection); /* Connection setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); - g_assert (s_con); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Ethernet Without IPv6 Setting", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); - g_assert (s_wired); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, @@ -7658,13 +7338,8 @@ test_write_ethernet_missing_ipv6 (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7701,17 +7376,16 @@ test_read_bond_main (void) static void test_write_bond_main (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingBond *s_bond; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; NMSettingWired *s_wired; - char *uuid; NMIPAddress *addr; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7719,15 +7393,13 @@ test_write_bond_main (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Main", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_INTERFACE_NAME, "bond0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_BOND_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -7760,6 +7432,8 @@ test_write_bond_main (void) NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); + nmtst_assert_connection_verifies_without_normalization (connection); _writer_new_connection (connection, @@ -7767,13 +7441,8 @@ test_write_bond_main (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_BOND, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7799,14 +7468,13 @@ test_read_bond_slave (void) static void test_write_bond_slave (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; static const char *mac = "31:33:33:37:be:cd"; guint32 mtu = 1492; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7814,16 +7482,14 @@ test_write_bond_slave (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Slave", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "bond0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME, NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -7841,13 +7507,8 @@ test_write_bond_slave (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -7885,18 +7546,17 @@ test_read_infiniband (void) static void test_write_infiniband (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingInfiniband *s_infiniband; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; guint32 mtu = 65520; - char *uuid; NMIPAddress *addr; GError *error = NULL; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7904,14 +7564,12 @@ test_write_infiniband (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write InfiniBand", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_INFINIBAND_SETTING_NAME, NULL); - g_free (uuid); /* InfiniBand setting */ s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new (); @@ -7953,19 +7611,14 @@ test_write_infiniband (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_INFINIBAND, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void test_read_bond_slave_ib (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingConnection *s_con; connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-bond-slave-ib", @@ -7975,22 +7628,18 @@ test_read_bond_slave_ib (void) g_assert (s_con); g_assert_cmpstr (nm_setting_connection_get_master (s_con), ==, "bond0"); - g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NM_SETTING_BOND_SETTING_NAME); - - g_object_unref (connection); } static void test_write_bond_slave_ib (void) { - NMConnection *connection; - NMConnection *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingInfiniband *s_infiniband; static const char *mac = "80:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22"; - char *uuid; - char *testfile = NULL; connection = nm_simple_connection_new (); @@ -7998,16 +7647,14 @@ test_write_bond_slave_ib (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Slave InfiniBand", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "bond0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME, NULL); - g_free (uuid); /* InfiniBand setting */ s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new (); @@ -8026,13 +7673,8 @@ test_write_bond_slave_ib (void) &testfile); reread = _connection_from_file (testfile, NULL, NULL, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -8122,14 +7764,15 @@ test_read_dcb_basic (void) static void test_write_dcb_basic (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingDcb *s_dcb; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; guint i; - char *uuid, *testfile; const guint group_ids[8] = { 4, 0xF, 6, 0xF, 1, 7, 3, 0xF }; const guint group_bandwidths[8] = { 10, 20, 15, 10, 2, 3, 35, 5 }; const guint bandwidths[8] = { 10, 20, 30, 40, 50, 10, 0, 25 }; @@ -8141,14 +7784,12 @@ test_write_dcb_basic (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, "dcb-test", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME, "eth0", NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -8194,19 +7835,14 @@ test_write_dcb_basic (void) &testfile); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); - g_free (testfile); } static void test_read_dcb_default_app_priorities (void) { - NMConnection *connection; + gs_unref_object NMConnection *connection = NULL; NMSettingDcb *s_dcb; connection = _connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-default-app-priorities", @@ -8223,8 +7859,6 @@ test_read_dcb_default_app_priorities (void) g_assert_cmpint (nm_setting_dcb_get_app_fip_flags (s_dcb), ==, NM_SETTING_DCB_FLAG_ENABLE); g_assert_cmpint (nm_setting_dcb_get_app_fip_priority (s_dcb), ==, -1); - - g_object_unref (connection); } static void @@ -8335,49 +7969,45 @@ test_read_dcb_pgpct_not_100 (void) static void test_read_fcoe_mode (gconstpointer user_data) { + gs_unref_object NMConnection *connection = NULL; + gs_free char *file = NULL; const char *expected_mode = user_data; - NMConnection *connection; NMSettingDcb *s_dcb; - char *file; file = g_strdup_printf (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-fcoe-%s", expected_mode); connection = _connection_from_file (file, NULL, TYPE_ETHERNET, NULL); - g_free (file); s_dcb = nm_connection_get_setting_dcb (connection); g_assert (s_dcb); g_assert_cmpint (nm_setting_dcb_get_app_fcoe_flags (s_dcb), ==, NM_SETTING_DCB_FLAG_ENABLE); g_assert_cmpstr (nm_setting_dcb_get_app_fcoe_mode (s_dcb), ==, expected_mode); - - g_object_unref (connection); } static void test_write_fcoe_mode (gconstpointer user_data) { + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; const char *expected_mode = user_data; - NMConnection *connection, *reread; - GError *error = NULL; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingDcb *s_dcb; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid, *testfile; + shvarFile *ifcfg; connection = nm_simple_connection_new (); s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, "fcoe-test", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME, "eth0", NULL); - g_free (uuid); /* Wired setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); @@ -8407,26 +8037,13 @@ test_write_fcoe_mode (gconstpointer user_data) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - { - shvarFile *ifcfg = svOpenFile (testfile, &error); - char *written_mode; - - g_assert_no_error (error); - g_assert (ifcfg); - written_mode = svGetValue (ifcfg, "DCB_APP_FCOE_MODE", FALSE); - svCloseFile (ifcfg); - g_assert_cmpstr (written_mode, ==, expected_mode); - g_free (written_mode); - } + ifcfg = _svOpenFile (testfile); + _svGetValue_check (ifcfg, "DCB_APP_FCOE_MODE", expected_mode); + svCloseFile (ifcfg); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_object_unref (connection); - g_object_unref (reread); - g_free (testfile); } static void @@ -8481,16 +8098,15 @@ test_read_team_master_invalid (gconstpointer user_data) static void test_write_team_master (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingTeam *s_team; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; const char *expected_config = "{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"; - const char *escaped_expected_config = "\"{ \\\"device\\\": \\\"team0\\\", \\\"link_watch\\\": { \\\"name\\\": \\\"ethtool\\\" } }\""; shvarFile *f; connection = nm_simple_connection_new (); @@ -8499,14 +8115,12 @@ test_write_team_master (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Master", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_INTERFACE_NAME, "team0", NM_SETTING_CONNECTION_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); - g_free (uuid); /* Team setting */ s_team = (NMSettingTeam *) nm_setting_team_new (); @@ -8522,7 +8136,6 @@ test_write_team_master (void) /* IP4 setting */ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); - g_assert (s_ip4); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -8531,43 +8144,28 @@ test_write_team_master (void) /* IP6 setting */ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); - g_assert (s_ip6); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); + nm_connection_add_setting (connection, nm_setting_proxy_new ()); + nmtst_assert_connection_verifies_without_normalization (connection); _writer_new_connection (connection, TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "DEVICETYPE", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "Team"); - g_free (val); - val = svGetValue (f, "TEAM_CONFIG", TRUE); - g_assert (val); - g_assert_cmpstr (val, ==, escaped_expected_config); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "DEVICETYPE", "Team"); + _svGetValue_check (f, "TEAM_CONFIG", expected_config); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); - nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -8596,14 +8194,13 @@ test_read_team_port (gconstpointer user_data) static void test_write_team_port (void) { - NMConnection *connection, *reread; + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; NMSettingConnection *s_con; NMSettingTeamPort *s_team_port; NMSettingWired *s_wired; - char *uuid, *testfile = NULL, *val; - GError *error = NULL; const char *expected_config = "{ \"p4p1\": { \"prio\": -10, \"sticky\": true } }"; - const char *escaped_expected_config = "\"{ \\\"p4p1\\\": { \\\"prio\\\": -10, \\\"sticky\\\": true } }\""; shvarFile *f; connection = nm_simple_connection_new (); @@ -8612,15 +8209,13 @@ test_write_team_port (void) s_con = (NMSettingConnection *) nm_setting_connection_new (); nm_connection_add_setting (connection, NM_SETTING (s_con)); - uuid = nm_utils_uuid_generate (); g_object_set (s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Port", - NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, "team0", NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); - g_free (uuid); /* Team setting */ s_team_port = (NMSettingTeamPort *) nm_setting_team_port_new (); @@ -8637,36 +8232,17 @@ test_write_team_port (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - f = svOpenFile (testfile, &error); - g_assert_no_error (error); - g_assert (f); - - /* re-read the file to check that what key was written. */ - val = svGetValue (f, "TYPE", FALSE); - g_assert (!val); - val = svGetValue (f, "DEVICETYPE", FALSE); - g_assert (val); - g_assert_cmpstr (val, ==, "TeamPort"); - g_free (val); - val = svGetValue (f, "TEAM_PORT_CONFIG", TRUE); - g_assert (val); - g_assert_cmpstr (val, ==, escaped_expected_config); - g_free (val); - val = svGetValue (f, "TEAM_MASTER", TRUE); - g_assert (val); - g_assert_cmpstr (val, ==, "team0"); - g_free (val); + f = _svOpenFile (testfile); + _svGetValue_check (f, "TYPE", NULL); + _svGetValue_check (f, "DEVICETYPE", "TeamPort"); + _svGetValue_check (f, "TEAM_PORT_CONFIG", expected_config); + _svGetValue_check (f, "TEAM_MASTER", "team0"); svCloseFile (f); reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); - unlink (testfile); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); - - g_free (testfile); - g_object_unref (connection); - g_object_unref (reread); } static void @@ -8692,108 +8268,456 @@ test_read_team_port_empty_config (void) g_object_unref (connection); } -/* Old algorithm for "remove escaped characters in place". - * - * This function is obsolete because it has O(n^2) runtime - * complexity and got replaced. Keep it here for testing, - * that both functions behave identical. - **/ -static void -svUnescape_On2 (char *s) -{ - int len, i; - - len = strlen(s); - if (len >= 2 && (s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) { - i = len - 2; - if (i == 0) - s[0] = '\0'; - else { - memmove(s, s+1, i); - s[i+1] = '\0'; - len = i; - } +static void +test_read_proxy_basic (void) +{ + NMConnection *connection; + NMSettingProxy *s_proxy; + + /* Test basic proxy configuration */ + + connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-read-proxy-basic", + NULL, TYPE_ETHERNET, NULL); + + /* ===== Proxy setting ===== */ + s_proxy = nm_connection_get_setting_proxy (connection); + g_assert (s_proxy); + + /* Proxy method */ + g_assert_cmpint (nm_setting_proxy_get_method (s_proxy), ==, NM_SETTING_PROXY_METHOD_AUTO); + g_assert (nm_setting_proxy_get_browser_only (s_proxy)); + g_assert_cmpstr (nm_setting_proxy_get_pac_url (s_proxy), ==, "http://wpad.mycompany.com/wpad.dat"); + + g_object_unref (connection); +} + +static void +test_write_proxy_basic (void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingProxy *s_proxy; + const char *expected_url = "https://wpad.neverland.org/wpad.dat"; + shvarFile *f; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Write Proxy Basic", + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, + NULL); + + /* Proxy setting */ + s_proxy = (NMSettingProxy *) nm_setting_proxy_new (); + nm_connection_add_setting (connection, NM_SETTING (s_proxy)); + g_object_set (s_proxy, NM_SETTING_PROXY_METHOD, NM_SETTING_PROXY_METHOD_AUTO, NULL); + g_object_set (s_proxy, NM_SETTING_PROXY_PAC_URL, expected_url, NULL); + + /* Wired setting */ + s_wired = (NMSettingWired *) nm_setting_wired_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + nmtst_assert_connection_verifies (connection); + + _writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile); + + f = _svOpenFile (testfile); + _svGetValue_check (f, "TYPE", "Ethernet"); + _svGetValue_check (f, "PROXY_METHOD", "auto"); + _svGetValue_check (f, "PAC_URL", expected_url); + svCloseFile (f); + + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, + NULL); + + nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); +} + +/*****************************************************************************/ + +static const char * +_svUnescape (const char *str, char **to_free) +{ + const char *s; + gs_free char *str_free = NULL; + + g_assert (str); + g_assert (to_free); + + if (str[0] == '\0') { + /* avoid static string "" */ + str = (str_free = g_strdup (str)); } - for (i = 0; i < len; i++) { - if (s[i] == '\\') { - memmove(s+i, s+i+1, len-(i+1)); - len--; - } - s[len] = '\0'; + + s = svUnescape (str, to_free); + if (*to_free) { + g_assert (s == *to_free); + g_assert (s[0]); + } else { + g_assert ( s == NULL + || (!s[0] && (s < str || s > strchr (str, '\0'))) + || ( s[0] && s >= str && s <= strchr (str, '\0') )); } + return s; } +typedef struct { + const char *val; + const char *exp; + bool can_concat:1; + bool needs_ascii_separator:1; +} UnescapeTestData; + static void -test_svUnescape_assert (const char *str) +do_svUnescape_assert (const char *str, const char *expected) { - char *s1 = g_strdup (str); - char *s2 = g_strdup (str); + gs_free char *to_free = NULL; + const char *s; + + s = _svUnescape (str, &to_free); + g_assert_cmpstr (s, ==, expected); - svUnescape (s1); - svUnescape_On2 (s2); + /* check we can make a round-trip */ + if (expected) { + gs_free char *s1_free = NULL; + gs_free char *s2_free = NULL; + const char *s1, *s2; - g_assert_cmpstr (s1, ==, s2); + s1 = svEscape (expected, &s1_free); + g_assert (s1); - g_free (s1); - g_free (s2); + s2 = _svUnescape (s1, &s2_free); + g_assert (s2); + + g_assert_cmpstr (s2, ==, expected); + } +} + +static void +do_svUnescape_combine_ansi_append (GString *str_val, GString *str_exp, const UnescapeTestData *data, gboolean honor_needs_ascii_separator) +{ + g_string_append (str_val, data->val); + g_string_append (str_exp, data->exp); + if (honor_needs_ascii_separator && data->needs_ascii_separator) { + /* the string has an open escape sequence. We must ensure that when + * combining it with another sequence, that they don't merge into + * something diffent. for example "\xa" + "a" must not result in + * "\xaa". Instead, we add a space in between to get "\xa a". */ + g_string_append (str_val, " "); + g_string_append (str_exp, " "); + } +} + +static void +do_svUnescape_combine_ansi (GString *str_val, GString *str_exp, const UnescapeTestData *data_ansi, gsize data_len, gssize idx) +{ + gsize i, j; + + g_string_set_size (str_val, 0); + g_string_set_size (str_exp, 0); + g_string_append (str_val, "$'"); + if (idx < 0) { + for (i = -idx; i > 0; i--) { + j = nmtst_get_rand_int () % data_len; + if (!data_ansi[j].can_concat) { + i++; + continue; + } + do_svUnescape_combine_ansi_append (str_val, str_exp, &data_ansi[j], i > 1); + } + } else { + g_assert_cmpint (idx, <, data_len); + do_svUnescape_combine_ansi_append (str_val, str_exp, &data_ansi[idx], FALSE); + } + g_string_append (str_val, "'"); } static void test_svUnescape (void) { - int len, repeat, i, k; - GRand *r = g_rand_new (); - guint32 seed = g_random_int (); - - g_rand_set_seed (r, seed); - - test_svUnescape_assert (""); - test_svUnescape_assert ("'"); - test_svUnescape_assert ("\""); - test_svUnescape_assert ("\\"); - test_svUnescape_assert ("x"); - test_svUnescape_assert (" "); - test_svUnescape_assert ("' '"); - test_svUnescape_assert ("'x'"); - test_svUnescape_assert ("\'some string\'"); - test_svUnescape_assert ("Bob outside LAN"); - test_svUnescape_assert ("{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"); - - for (len = 1; len < 25; len++) { - char *s = g_new0 (char, len+1); - - for (repeat = 0; repeat < MAX (4*len, 20); repeat++) { - - /* fill the entire string with random. */ - for (i = 0; i < len; i++) - s[i] = g_rand_int (r); - - /* randomly place escape characters into the string */ - k = g_rand_int (r) % (len); - while (k-- > 0) - s[g_rand_int (r) % len] = '\\'; - - if (len > 1) { - /* quote the string. */ - k = g_rand_int (r) % (10); - if (k < 4) { - char quote = k < 2 ? '"' : '\''; - - s[0] = quote; - s[len-1] = quote; - } +#define V0(v_value, v_expected) { .val = ""v_value"", .exp = v_expected, .can_concat = FALSE, } +#define V1(v_value, v_expected) { .val = ""v_value"", .exp = v_expected, .can_concat = !!v_expected, } +#define V2(v_value, v_expected) { .val = ""v_value"", .exp = v_expected, .can_concat = TRUE, .needs_ascii_separator = TRUE, } + const UnescapeTestData data_full[] = { + V1 ("", ""), + V0 ("'", NULL), + V1 ("'x'", "x"), + V1 ("' '", " "), + V1 ("'x'", "x"), + V0 ("\"", NULL), + V0 ("\\", NULL), + V0 (" ", ""), + V0 (" ", ""), + V0 ("a; #", "a"), + V0 (" ; #", ""), + V0 ("; ", ""), + V0 ("; ;", NULL), + V0 (" ; a #", NULL), + V0 (" ; a;; #", NULL), + V0 ("a; ; #", NULL), + V0 ("\t # ", ""), + V0 ("\t #a", ""), + V0 ("\t #a\r", ""), + V0 ("\r", ""), + V1 ("\\\"", "\""), + V1 ("\\`", "`"), + V1 ("\\$", "$"), + V1 ("\\\\", "\\"), + V1 ("\\a", "a"), + V1 ("\\b", "b"), + V1 ("\\'", "'"), + V1 ("\\~", "~"), + V1 ("\\\t", "\t"), + V1 ("\"\\\"\"", "\""), + V1 ("\"\\`\"", "`"), + V1 ("\"\\$\"", "$"), + V1 ("\"\\\\\"", "\\"), + V1 ("\"\\a\"", "\\a"), + V1 ("\"\\b\"", "\\b"), + V1 ("\"\\\t\"", "\\\t"), + V0 ("ab\r", "ab"), + V0 ("a'b'\r ", "ab"), + V0 ("a'b' \r", "ab"), + V0 ("a#b", "a#b"), + V0 ("#b", "#b"), + V1 ("\'some string\'", "some string"), + V0 ("Bob outside LAN", NULL), + V1 ("x", "x"), + V1 ("'{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }'", + "{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"), + V1 ("x\"\"b", "xb"), + V1 ("x\"c\"b", "xcb"), + V1 ("\"c\"b", "cb"), + V1 ("\"c\"\\'b", "c'b"), + V1 ("$''", ""), + V1 ("$'\\n'", "\n"), + V0 ("$'\\'", NULL), + V1 ("$'\\x'", "\\x"), + V1 ("$'\\xa'", "\xa"), + V0 ("$'\\x0'", ""), + V1 ("$'\\x12'", "\x12"), + V1 ("$'\\x12A'", "\x12""A"), + V1 ("$'\\x12t'", "\x12t"), + V1 ("\"aa\\\"\"", "aa\""), + V1 ("\"aa\\\"b\"c", "aa\"bc"), + V1 ("\"aa\\\"\"b", "aa\"b"), + + /* the following is not shell behavior, but kept for backward compatibility + * with old svEscape(). */ + V0 ("\"\\'\"", "'"), + V0 ("\"\\~\"", "~"), + V0 ("\"b\\~b\"", "b~b"), + V0 ("\"\\~\\~\"", "~~"), + V0 ("\"\\~\\'\"", "~'"), + + /* the following is shell-behavior, because it doesn't look like written + * by old svEscape(). */ + V1 ("\"\\~~\"", "\\~~"), + V1 ("\"\\a\\'\"", "\\a\\'"), + V1 ("x\"\\~\"", "x\\~"), + V1 ("\"\\'\"''", "\\'"), + V0 ("\"b\\~b\" ", "b\\~b"), + V1 ("\"b\\~b\"x", "b\\~bx"), + }; + const UnescapeTestData data_ansi[] = { + /* strings inside $''. They cannot be compared directly, but must + * be wrapped by do_svUnescape_combine_ansi(). */ + V1 ("", ""), + V1 ("a", "a"), + V1 ("b", "b"), + V1 ("x", "x"), + V1 (" ", " "), + V1 ("\\a", "\a"), + V1 ("\\b", "\b"), + V1 ("\\e", "\e"), + V1 ("\\E", "\E"), + V1 ("\\f", "\f"), + V1 ("\\n", "\n"), + V1 ("\\r", "\r"), + V1 ("\\t", "\t"), + V1 ("\\v", "\v"), + V1 ("\\\\", "\\"), + V1 ("\\'", "'"), + V1 ("\\\"", "\""), + V1 ("\\?", "\?"), + V1 ("\\?", "?"), + V2 ("\\8", "\\8"), + V2 ("\\1", "\1"), + V1 ("\\1A", "\1A"), + V1 ("\\18", "\18"), + V2 ("\\01", "\1"), + V1 ("\\001", "\1"), + V0 ("\\008", ""), + V1 ("\\018", "\0018"), + V0 ("\\08", ""), + V1 ("\\18", "\0018"), + V1 ("\\x", "\\x"), + V2 ("\\xa", "\xa"), + V1 ("\\x12", "\x12"), + V1 ("\\x12A", "\x12""A"), + V1 ("\\x12a", "\x12""a"), + V1 ("\\x12t", "\x12t"), + V1 ("\\x1a", "\x1a"), + V1 ("\\x1A", "\x1A"), + V1 ("\\ut", "\\ut"), + V2 ("\\ua", "\xa"), + V1 ("\\uat", "\xat"), + V2 ("\\uab", "\xc2\xab"), + V1 ("\\uabt", "\xc2\xabt"), + V2 ("\\uabc", "\xe0\xaa\xbc"), + V1 ("\\uabct", "\xe0\xaa\xbct"), + V2 ("\\uabcd", "\xea\xaf\x8d"), + V1 ("\\uabcdt", "\xea\xaf\x8dt"), + V2 ("\\uabcde", "\xea\xaf\x8d""e"), + V1 ("\\uabcdet", "\xea\xaf\x8d""et"), + V1 ("\\Ut", "\\Ut"), + V2 ("\\Ua", "\xa"), + V1 ("\\Uat", "\xat"), + V2 ("\\Uab", "\xc2\xab"), + V1 ("\\Uabt", "\xc2\xabt"), + V2 ("\\Uabc", "\xe0\xaa\xbc"), + V1 ("\\Uabct", "\xe0\xaa\xbct"), + V2 ("\\Uabcd", "\xea\xaf\x8d"), + V1 ("\\Uabcdt", "\xea\xaf\x8dt"), + V2 ("\\Uabcde", "\xf2\xab\xb3\x9e"), + V1 ("\\Uabcdet", "\xf2\xab\xb3\x9et"), + V2 ("\\Uabcde0", "\xf8\xaa\xbc\xb7\xa0"), + V1 ("\\Uabcde0t", "\xf8\xaa\xbc\xb7\xa0t"), + V2 ("\\Uabcde01", "\xfc\x8a\xaf\x8d\xb8\x81"), + V1 ("\\Uabcde01t", "\xfc\x8a\xaf\x8d\xb8\x81t"), + V2 ("\\U0abcde01", "\xfc\x8a\xaf\x8d\xb8\x81"), + V1 ("\\U0abcde01t", "\xfc\x8a\xaf\x8d\xb8\x81t"), + V1 ("\\U00abcde01", "\xf8\xaa\xbc\xb7\xa0""1"), + V1 ("\\U00abcde01t", "\xf8\xaa\xbc\xb7\xa0""1t"), + + /* control-x sequence is not supported */ + V1 ("\\c", "\\c"), + V1 ("\\c1", "\\c1"), + }; +#undef V0 +#undef V1 +#undef V2 + gsize i; + nm_auto_free_gstring GString *str_val = g_string_new (NULL); + nm_auto_free_gstring GString *str_val2 = g_string_new (NULL); + nm_auto_free_gstring GString *str_exp = g_string_new (NULL); + nm_auto_free_gstring GString *str_exp2 = g_string_new (NULL); + + do_svUnescape_assert ( "' '' '", " "); + + for (i = 0; i < G_N_ELEMENTS (data_full); i++) + do_svUnescape_assert (data_full[i].val, data_full[i].exp); + + for (i = 0; i < G_N_ELEMENTS (data_ansi); i++) { + do_svUnescape_combine_ansi (str_val, str_exp, data_ansi, G_N_ELEMENTS (data_ansi), i); + do_svUnescape_assert (str_val->str, str_exp->str); + } + + /* different values can be just concatenated... */ + for (i = 0; i < 200; i++) { + gsize num_concat = (nmtst_get_rand_int () % 5) + 2; + + g_string_set_size (str_val, 0); + g_string_set_size (str_exp, 0); + + while (num_concat > 0) { + gsize idx; + + if ((nmtst_get_rand_int () % 3 == 0)) { + do_svUnescape_combine_ansi (str_val2, str_exp2, data_ansi, G_N_ELEMENTS (data_ansi), -((int) ((nmtst_get_rand_int () % 5) + 1))); + continue; } - /*g_message (">>%s<<", s);*/ - test_svUnescape_assert (s); + idx = nmtst_get_rand_int () % G_N_ELEMENTS (data_full); + if (!data_full[idx].can_concat) + continue; + g_string_append (str_val, data_full[idx].val); + g_string_append (str_exp, data_full[idx].exp); + num_concat--; + } + + switch (nmtst_get_rand_int () % 3) { + case 0: + g_string_append (str_val, " "); + break; + case 1: + g_string_append (str_val, " "); + break; + } + switch (nmtst_get_rand_int () % 3) { + case 0: + g_string_append (str_val, " #"); + break; + case 1: + g_string_append (str_val, " #foo"); + break; } + do_svUnescape_assert (str_val->str, str_exp->str); + } +} + +/*****************************************************************************/ + +static void +test_write_unknown (gconstpointer test_data) +{ + nmtst_auto_unlinkfile char *filename_tmp_1 = g_strdup (TEST_SCRATCH_DIR_TMP"/tmp-1"); + const char *testfile = test_data; + gs_free char *testfile_expected = g_strconcat (testfile, ".expected", NULL); + shvarFile *sv; + gs_free_error GError *error = NULL; + gboolean success; + gs_free char *file_contents_out = NULL; + gs_free char *file_contents_exp = NULL; + + sv = _svOpenFile (testfile); + + svFileSetName (sv, filename_tmp_1); + svFileSetModified (sv); + + if (g_str_has_suffix (testfile, "ifcfg-test-write-unknown-4")) { + _svGetValue_check (sv, "NAME", "l4x"); + _svGetValue_check (sv, "NAME2", NULL); + _svGetValue_check (sv, "NAME3", "name3-value"); - g_free (s); + svSetValue (sv, "NAME", "set-by-test1"); + svSetValue (sv, "NAME2", NULL); + svSetValue (sv, "NAME2", "set-by-test2"); + svSetValue (sv, "NAME3", "set-by-test3"); + + _svGetValue_check (sv, "some_key", NULL); + _svGetValue_check (sv, "some_key1", ""); + _svGetValue_check (sv, "some_key2", ""); + _svGetValue_check (sv, "some_key3", "x"); + + _svGetValue_check (sv, "NAME", "set-by-test1"); + _svGetValue_check (sv, "NAME2", "set-by-test2"); + _svGetValue_check (sv, "NAME3", "set-by-test3"); } - g_rand_free (r); + success = svWriteFile (sv, 0644, &error); + nmtst_assert_success (success, error); + + file_contents_out = nmtst_file_get_contents (filename_tmp_1); + file_contents_exp = nmtst_file_get_contents (testfile_expected); + + g_assert_cmpstr (file_contents_out, ==, file_contents_exp); + + svCloseFile (sv); } +/*****************************************************************************/ + static void test_read_vlan_trailing_spaces (void) { @@ -8842,10 +8766,123 @@ test_sit_read_ignore (void) /*****************************************************************************/ +static void +do_test_utils_name (const char *desc, + const char *path, + gboolean only_ifcfg, + const char *expected) +{ + const char *result; + + result = utils_get_ifcfg_name (path, only_ifcfg); + g_assert_cmpstr (result, ==, expected); +} + +static void +test_utils_name (void) +{ + do_test_utils_name ("get-ifcfg-name-bad", "/foo/bar/adfasdfadf", FALSE, NULL); + do_test_utils_name ("get-ifcfg-name-good", "/foo/bar/ifcfg-FooBar", FALSE, "FooBar"); + do_test_utils_name ("get-ifcfg-name-keys", "/foo/bar/keys-BlahLbah", FALSE, "BlahLbah"); + do_test_utils_name ("get-ifcfg-name-route", "/foo/bar/route-Lalalala", FALSE, "Lalalala"); + do_test_utils_name ("get-ifcfg-name-only-ifcfg-route", "/foo/bar/route-Lalalala", TRUE, NULL); + do_test_utils_name ("get-ifcfg-name-only-ifcfg-keys", "/foo/bar/keys-Lalalala", TRUE, NULL); + do_test_utils_name ("get-ifcfg-name-no-path-ifcfg", "ifcfg-Lalalala", FALSE, "Lalalala"); + do_test_utils_name ("get-ifcfg-name-no-path-keys", "keys-Lalalala", FALSE, "Lalalala"); + do_test_utils_name ("get-ifcfg-name-no-path-route", "route-Lalalala", FALSE, "Lalalala"); + + do_test_utils_name ("get-ifcfg-name-bad2-ifcfg", "/foo/bar/asdfasifcfg-Foobar", FALSE, NULL); + do_test_utils_name ("get-ifcfg-name-bad2-keys", "/foo/bar/asdfaskeys-Foobar", FALSE, NULL); + do_test_utils_name ("get-ifcfg-name-bad2-route", "/foo/bar/asdfasroute-Foobar", FALSE, NULL); +} + +/*****************************************************************************/ + +static void +do_test_utils_path_ifcfg (const char *desc, + const char *path, + const char *expected) +{ + char *result; + + result = utils_get_ifcfg_path (path); + g_assert_cmpstr (result, ==, expected); + g_free (result); +} + +static void +do_test_utils_path_keys (const char *desc, + const char *path, + const char *expected) +{ + char *result; + + result = utils_get_keys_path (path); + g_assert_cmpstr (result, ==, expected); + g_free (result); +} + +static void +do_test_utils_path_route (const char *desc, + const char *path, + const char *expected) +{ + char *result; + + result = utils_get_route_path (path); + g_assert_cmpstr (result, ==, expected); + g_free (result); +} + +static void +test_utils_path (void) +{ + do_test_utils_path_ifcfg ("ifcfg-path-bad", "/foo/bar/adfasdfasdf", NULL); + do_test_utils_path_ifcfg ("ifcfg-path-from-keys-no-path", "keys-BlahBlah", "ifcfg-BlahBlah"); + do_test_utils_path_ifcfg ("ifcfg-path-from-keys", "/foo/bar/keys-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); + do_test_utils_path_ifcfg ("ifcfg-path-from-route", "/foo/bar/route-BlahBlah", "/foo/bar/ifcfg-BlahBlah"); + + do_test_utils_path_keys ("keys-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); + do_test_utils_path_keys ("keys-path-from-ifcfg-no-path", "ifcfg-FooBar", "keys-FooBar"); + do_test_utils_path_keys ("keys-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/keys-FooBar"); + do_test_utils_path_keys ("keys-path-from-route", "/foo/bar/route-FooBar", "/foo/bar/keys-FooBar"); + + do_test_utils_path_route ("route-path-bad", "/foo/bar/asdfasdfasdfasdf", NULL); + do_test_utils_path_route ("route-path-from-ifcfg-no-path", "ifcfg-FooBar", "route-FooBar"); + do_test_utils_path_route ("route-path-from-ifcfg", "/foo/bar/ifcfg-FooBar", "/foo/bar/route-FooBar"); + do_test_utils_path_route ("route-path-from-keys", "/foo/bar/keys-FooBar", "/foo/bar/route-FooBar"); +} + +/*****************************************************************************/ + +static void +do_test_utils_ignored (const char *desc, const char *path, gboolean expected_ignored) +{ + gboolean result; + + result = utils_should_ignore_file (path, FALSE); + g_assert (result == expected_ignored); +} + +static void +test_utils_ignore (void) +{ + do_test_utils_ignored ("ignored-ifcfg", "ifcfg-FooBar", FALSE); + do_test_utils_ignored ("ignored-keys", "keys-FooBar", FALSE); + do_test_utils_ignored ("ignored-route", "route-FooBar", FALSE); + do_test_utils_ignored ("ignored-bak", "ifcfg-FooBar" BAK_TAG, TRUE); + do_test_utils_ignored ("ignored-tilde", "ifcfg-FooBar" TILDE_TAG, TRUE); + do_test_utils_ignored ("ignored-orig", "ifcfg-FooBar" ORIG_TAG, TRUE); + do_test_utils_ignored ("ignored-rej", "ifcfg-FooBar" REJ_TAG, TRUE); + do_test_utils_ignored ("ignored-rpmnew", "ifcfg-FooBar" RPMNEW_TAG, TRUE); + do_test_utils_ignored ("ignored-augnew", "ifcfg-FooBar" AUGNEW_TAG, TRUE); + do_test_utils_ignored ("ignored-augtmp", "ifcfg-FooBar" AUGTMP_TAG, TRUE); +} + +/*****************************************************************************/ #define TPATH "/settings/plugins/ifcfg-rh/" -#define TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-bad-hex" #define TEST_IFCFG_WIFI_OPEN_SSID_LONG_QUOTED TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-quoted" #define TEST_IFCFG_WIFI_OPEN_SSID_LONG_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-hex" @@ -8857,7 +8894,16 @@ int main (int argc, char **argv) { nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); + if (g_mkdir_with_parents (TEST_SCRATCH_DIR_TMP, 0755) != 0) + g_error ("failure to create test directory \"%s\": %s", TEST_SCRATCH_DIR_TMP, g_strerror (errno)); + g_test_add_func (TPATH "svUnescape", test_svUnescape); + + g_test_add_data_func (TPATH "write-unknown/1", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-1", test_write_unknown); + g_test_add_data_func (TPATH "write-unknown/2", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-2", test_write_unknown); + g_test_add_data_func (TPATH "write-unknown/3", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-3", test_write_unknown); + g_test_add_data_func (TPATH "write-unknown/4", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-write-unknown-4", test_write_unknown); + g_test_add_func (TPATH "vlan-trailing-spaces", test_read_vlan_trailing_spaces); g_test_add_func (TPATH "unmanaged", test_read_unmanaged); @@ -8883,6 +8929,7 @@ int main (int argc, char **argv) g_test_add_func (TPATH "read-dhcp-plus-ip", test_read_wired_dhcp_plus_ip); g_test_add_func (TPATH "read-shared-plus-ip", test_read_wired_shared_plus_ip); g_test_add_func (TPATH "read-dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname); + g_test_add_func (TPATH "read-dhcpv6-hostname-fallback", test_read_wired_dhcpv6_hostname_fallback); g_test_add_func (TPATH "read-global-gateway", test_read_wired_global_gateway); g_test_add_func (TPATH "read-global-gateway-ignore", test_read_wired_global_gateway_ignore); g_test_add_func (TPATH "read-obsolete-gateway-n", test_read_wired_obsolete_gateway_n); @@ -8919,7 +8966,7 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wifi/read/open", test_read_wifi_open); g_test_add_func (TPATH "wifi/read/open/auto", test_read_wifi_open_auto); g_test_add_func (TPATH "wifi/read/open/hex-ssid", test_read_wifi_open_ssid_hex); - g_test_add_data_func (TPATH "wifi/read/open-ssid/bad-hex", TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX, test_read_wifi_open_ssid_bad); + g_test_add_func (TPATH "wifi/read/open-ssid/bad-hex", test_read_wifi_open_ssid_hex_bad); g_test_add_data_func (TPATH "wifi/read/open-ssid/long-hex", TEST_IFCFG_WIFI_OPEN_SSID_LONG_HEX, test_read_wifi_open_ssid_bad); g_test_add_data_func (TPATH "wifi/read/open-ssid/long-quoted", TEST_IFCFG_WIFI_OPEN_SSID_LONG_QUOTED, test_read_wifi_open_ssid_bad); g_test_add_func (TPATH "wifi/read/open/quoted-ssid", test_read_wifi_open_ssid_quoted); @@ -8970,6 +9017,9 @@ int main (int argc, char **argv) g_test_add_func (TPATH "vlan/read/reorder-hdr-1", test_read_vlan_reorder_hdr_1); g_test_add_func (TPATH "vlan/read/reorder-hdr-2", test_read_vlan_reorder_hdr_2); g_test_add_func (TPATH "wired/read/read-wake-on-lan", test_read_wired_wake_on_lan); + g_test_add_func (TPATH "wired/read/read-auto-negotiate-off", test_read_wired_auto_negotiate_off); + g_test_add_func (TPATH "wired/read/read-auto-negotiate-on", test_read_wired_auto_negotiate_on); + g_test_add_func (TPATH "wired/read/unkwnown-ethtool-opt", test_read_wired_unknown_ethtool_opt); g_test_add_func (TPATH "wired/write/static", test_write_wired_static); g_test_add_func (TPATH "wired/write/static-ip6-only", test_write_wired_static_ip6_only); @@ -8989,6 +9039,8 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wired/write-aliases", test_write_wired_aliases); g_test_add_func (TPATH "ipv4/write-static-addresses-GATEWAY", test_write_gateway); g_test_add_func (TPATH "wired/write-wake-on-lan", test_write_wired_wake_on_lan); + g_test_add_func (TPATH "wired/write-auto-negotiate-off", test_write_wired_auto_negotiate_off); + g_test_add_func (TPATH "wired/write-auto-negotiate-on", test_write_wired_auto_negotiate_on); g_test_add_func (TPATH "wifi/write/open", test_write_wifi_open); g_test_add_func (TPATH "wifi/write/open/hex-ssid", test_write_wifi_open_hex_ssid); g_test_add_func (TPATH "wifi/write/wep", test_write_wifi_wep); @@ -9082,6 +9134,9 @@ int main (int argc, char **argv) g_test_add_func (TPATH "team/write-port", test_write_team_port); g_test_add_func (TPATH "team/read-port-empty-config", test_read_team_port_empty_config); + g_test_add_func (TPATH "proxy/read-proxy-basic", test_read_proxy_basic); + g_test_add_func (TPATH "proxy/write-proxy-basic", test_write_proxy_basic); + g_test_add_func (TPATH "sit/read/ignore", test_sit_read_ignore); /* Stuff we expect to fail for now */ @@ -9090,6 +9145,11 @@ int main (int argc, char **argv) g_test_add_data_func (TPATH "wwan/write-gsm", GUINT_TO_POINTER (TRUE), test_write_mobile_broadband); g_test_add_data_func (TPATH "wwan/write-cdma", GUINT_TO_POINTER (FALSE), test_write_mobile_broadband); + g_test_add_func (TPATH "no-trailing-newline", test_ifcfg_no_trailing_newline); + + g_test_add_func (TPATH "utils/name", test_utils_name); + g_test_add_func (TPATH "utils/path", test_utils_path); + g_test_add_func (TPATH "utils/ignore", test_utils_ignore); + return g_test_run (); } - |