diff options
Diffstat (limited to 'src/settings/plugins/ifupdown')
10 files changed, 80 insertions, 193 deletions
diff --git a/src/settings/plugins/ifupdown/meson.build b/src/settings/plugins/ifupdown/meson.build index 365ae1a9..0cabe771 100644 --- a/src/settings/plugins/ifupdown/meson.build +++ b/src/settings/plugins/ifupdown/meson.build @@ -3,25 +3,18 @@ sources = files( 'nms-ifupdown-parser.c', ) -deps = [ - libudev_dep, - nm_dep, -] - libnms_ifupdown_core = static_library( 'nms-ifupdown-core', sources: sources, - dependencies: deps, -) - -sources = files( - 'nms-ifupdown-plugin.c', + dependencies: daemon_nm_default_dep, + c_args: daemon_c_flags, ) libnm_settings_plugin_ifupdown = shared_module( 'nm-settings-plugin-ifupdown', - sources: sources, - dependencies: deps, + sources: 'nms-ifupdown-plugin.c', + dependencies: daemon_nm_default_dep, + c_args: daemon_c_flags, link_with: libnms_ifupdown_core, link_args: ldflags_linker_script_settings, link_depends: linker_script_settings, @@ -31,18 +24,6 @@ libnm_settings_plugin_ifupdown = shared_module( core_plugins += libnm_settings_plugin_ifupdown -# FIXME: check_so_symbols replacement -''' -run_target( - 'check-local-symbols-settings-ifupdown', - command: [check_so_symbols, libnm_settings_plugin_ifupdown.full_path()], - depends: libnm_settings_plugin_ifupdown, -) - -check-local-symbols-settings-ifupdown: src/settings/plugins/ifupdown/libnm-settings-plugin-ifupdown.la - $(call check_so_symbols,$(builddir)/src/settings/plugins/ifupdown/.libs/libnm-settings-plugin-ifupdown.so) -''' - if enable_tests subdir('tests') endif diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c index 75f29878..a146ae60 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c +++ b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c @@ -1,22 +1,7 @@ -/* NetworkManager -- Network link manager - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Tom Parker <palfrey@tevp.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2004 Tom Parker + * Copyright (C) 2004 Tom Parker */ #include "nm-default.h" diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h index 308228a4..af02c7f6 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h +++ b/src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.h @@ -1,22 +1,7 @@ -/* NetworkManager -- Network link manager - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Tom Parker <palfrey@tevp.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2004 Tom Parker + * Copyright (C) 2004 Tom Parker */ #ifndef _INTERFACE_PARSER_H diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-parser.c b/src/settings/plugins/ifupdown/nms-ifupdown-parser.c index 41b20850..1db9ef15 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-parser.c +++ b/src/settings/plugins/ifupdown/nms-ifupdown-parser.c @@ -1,22 +1,7 @@ -/* NetworkManager system settings service (ifupdown) - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Alexander Sack <asac@ubuntu.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Canonical Ltd. + * Copyright (C) 2008 Canonical Ltd. */ #include "nm-default.h" diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-parser.h b/src/settings/plugins/ifupdown/nms-ifupdown-parser.h index 7569648f..b8761fc3 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-parser.h +++ b/src/settings/plugins/ifupdown/nms-ifupdown-parser.h @@ -1,22 +1,7 @@ -/* NetworkManager system settings service (ifupdown) - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Alexander Sack <asac@ubuntu.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Canonical Ltd. + * Copyright (C) 2008 Canonical Ltd. */ #ifndef __NMS_IFUPDOWN_PARSER_H__ diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c index e663ab8a..d19db0fd 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c +++ b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c @@ -1,23 +1,8 @@ -/* NetworkManager system settings service (ifupdown) - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Alexander Sack <asac@ubuntu.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2007,2008 Canonical Ltd. - * (C) Copyright 2009 - 2011 Red Hat, Inc. + * Copyright (C) 2007, 2008 Canonical Ltd. + * Copyright (C) 2009 - 2011 Red Hat, Inc. */ #include "nm-default.h" diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.h b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.h index 10ea2be4..91e3e43a 100644 --- a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.h +++ b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.h @@ -1,22 +1,7 @@ -/* NetworkManager system settings service (ifupdown) - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Alexander Sack <asac@ubuntu.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Canonical Ltd. + * Copyright (C) 2008 Canonical Ltd. */ #ifndef __NMS_IFUPDOWN_PLUGIN_H__ diff --git a/src/settings/plugins/ifupdown/tests/meson.build b/src/settings/plugins/ifupdown/tests/meson.build index 9b844c75..1ca094b5 100644 --- a/src/settings/plugins/ifupdown/tests/meson.build +++ b/src/settings/plugins/ifupdown/tests/meson.build @@ -3,7 +3,8 @@ test_unit = 'test-ifupdown' exe = executable( test_unit, test_unit + '.c', - dependencies: test_nm_dep, + dependencies: libnetwork_manager_test_dep, + c_args: test_c_flags, link_with: libnms_ifupdown_core, ) diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 4adcf085..6a7b5ecc 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * * Copyright (C) 2010 Red Hat, Inc. - * */ #include "nm-default.h" @@ -149,6 +135,9 @@ expected_free (Expected *e) g_free (e); } +NM_AUTO_DEFINE_FCN_VOID0 (Expected *, _nm_auto_free_expected, expected_free) +#define nm_auto_free_expected nm_auto(_nm_auto_free_expected) + static void compare_expected_to_ifparser (if_parser *parser, Expected *e) { @@ -226,7 +215,7 @@ init_ifparser_with_file (const char *file) static void test1_ignore_line_before_first_block (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test1"); @@ -238,14 +227,12 @@ test1_ignore_line_before_first_block (void) expected_block_add_key (b, expected_key_new ("inet", "dhcp")); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test2_wrapped_line (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test2"); @@ -254,14 +241,12 @@ test2_wrapped_line (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test3_wrapped_multiline_multiarg (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test3"); @@ -274,14 +259,12 @@ test3_wrapped_multiline_multiarg (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test4_allow_auto_is_auto (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test4"); @@ -290,14 +273,12 @@ test4_allow_auto_is_auto (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test5_allow_auto_multiarg (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test5"); @@ -308,14 +289,12 @@ test5_allow_auto_multiarg (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test6_mixed_whitespace (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test6"); @@ -325,8 +304,6 @@ test6_mixed_whitespace (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void @@ -348,7 +325,7 @@ test8_long_line_wrapped (void) static void test9_wrapped_lines_in_block (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test9"); @@ -362,14 +339,12 @@ test9_wrapped_lines_in_block (void) expected_block_add_key (b, expected_key_new ("gateway", "10.250.2.50")); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test11_complex_wrap (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test11"); @@ -380,14 +355,12 @@ test11_complex_wrap (void) expected_block_add_key (b, expected_key_new ("pre-up", "/sbin/ifconfig eth0 up")); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test12_complex_wrap_split_word (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test12"); @@ -398,14 +371,12 @@ test12_complex_wrap_split_word (void) expected_block_add_key (b, expected_key_new ("up", "ifup ppp0=dsl")); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test13_more_mixed_whitespace (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test13"); @@ -415,14 +386,12 @@ test13_more_mixed_whitespace (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test14_mixed_whitespace_block_start (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test14"); @@ -438,14 +407,12 @@ test14_mixed_whitespace_block_start (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test15_trailing_space (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test15"); @@ -455,23 +422,20 @@ test15_trailing_space (void) expected_add_block (e, b); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test16_missing_newline (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test16"); e = expected_new (); expected_add_block (e, expected_block_new ("mapping", "eth0")); compare_expected_to_ifparser (parser, e); - - expected_free (e); } + static void test17_read_static_ipv4 (void) { @@ -578,7 +542,7 @@ test19_read_static_ipv4_plen (void) static void test20_source_stanza (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test20-source-stanza"); @@ -597,14 +561,12 @@ test20_source_stanza (void) expected_block_add_key (b, expected_key_new ("inet", "dhcp")); compare_expected_to_ifparser (parser, e); - - expected_free (e); } static void test21_source_dir_stanza (void) { - Expected *e; + nm_auto_free_expected Expected *e = NULL; ExpectedBlock *b; nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test21-source-dir-stanza"); @@ -617,10 +579,34 @@ test21_source_dir_stanza (void) expected_block_add_key (b, expected_key_new ("inet", "dhcp")); compare_expected_to_ifparser (parser, e); +} + +static void +test22_duplicate_stanzas (void) +{ + nm_auto_free_expected Expected *e = NULL; + ExpectedBlock *b; + nm_auto_ifparser if_parser *parser = init_ifparser_with_file ("test22-duplicate-stanzas"); + + e = expected_new (); - expected_free (e); + b = expected_block_new ("iface", "br10"); + expected_add_block (e, b); + expected_block_add_key (b, expected_key_new ("inet", "manual")); + expected_block_add_key (b, expected_key_new ("bridge-ports", "enp6s0.15")); + expected_block_add_key (b, expected_key_new ("bridge-stp", "off")); + expected_block_add_key (b, expected_key_new ("bridge-maxwait", "0")); + expected_block_add_key (b, expected_key_new ("bridge-fd", "0")); + b = expected_block_new ("iface", "br10"); + expected_add_block (e, b); + expected_block_add_key (b, expected_key_new ("inet", "auto")); + expected_block_add_key (b, expected_key_new ("bridge-ports", "enp6s0.15")); + + compare_expected_to_ifparser (parser, e); } +/*****************************************************************************/ + NMTST_DEFINE (); int @@ -650,6 +636,7 @@ main (int argc, char **argv) g_test_add_func ("/ifupdate/read_static_ipv4_plen", test19_read_static_ipv4_plen); g_test_add_func ("/ifupdate/source_stanza", test20_source_stanza); g_test_add_func ("/ifupdate/source_dir_stanza", test21_source_dir_stanza); + g_test_add_func ("/ifupdate/test22-duplicate-stanzas", test22_duplicate_stanzas); return g_test_run (); } diff --git a/src/settings/plugins/ifupdown/tests/test22-duplicate-stanzas b/src/settings/plugins/ifupdown/tests/test22-duplicate-stanzas new file mode 100644 index 00000000..c13c2e7e --- /dev/null +++ b/src/settings/plugins/ifupdown/tests/test22-duplicate-stanzas @@ -0,0 +1,8 @@ +iface br10 inet manual + bridge_ports enp6s0.15 + bridge_stp off + bridge_maxwait 0 + bridge_fd 0 + +iface br10 inet auto + bridge_ports enp6s0.15 |