diff options
| author | Michael Biebl <biebl@debian.org> | 2019-12-18 18:29:24 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-12-18 18:29:24 +0100 |
| commit | 28028b26b3371756811e95d894f709f4b1207c00 (patch) | |
| tree | 6fe7316fd743b51042db47601a8ef8814b3134ac /dispatcher | |
| parent | e22609983008e1a669196ad64ba3a59ae8c76e0d (diff) | |
New upstream version 1.22.0 upstream/1.22.0
Diffstat (limited to 'dispatcher')
| -rw-r--r-- | dispatcher/meson.build | 33 | ||||
| -rw-r--r-- | dispatcher/nm-dispatcher-utils.c | 18 | ||||
| -rw-r--r-- | dispatcher/nm-dispatcher-utils.h | 18 | ||||
| -rw-r--r-- | dispatcher/nm-dispatcher.c | 45 | ||||
| -rw-r--r-- | dispatcher/tests/meson.build | 25 | ||||
| -rw-r--r-- | dispatcher/tests/test-dispatcher-envp.c | 16 |
6 files changed, 42 insertions, 113 deletions
diff --git a/dispatcher/meson.build b/dispatcher/meson.build index da9ac7f2..7feb9597 100644 --- a/dispatcher/meson.build +++ b/dispatcher/meson.build @@ -2,20 +2,11 @@ dispatcher_inc = include_directories('.') name = 'nm-dispatcher' -service_conf = configuration_data() -service_conf.set('sbindir', nm_sbindir) -service_conf.set('sysconfdir', nm_sysconfdir) -service_conf.set('localstatedir', nm_localstatedir) -service_conf.set('libexecdir', nm_libexecdir) - -service = 'org.freedesktop.nm_dispatcher.service' - configure_file( - input: service + '.in', - output: service, - install: true, - install_dir: dbus_sys_dir, - configuration: service_conf, + input: 'org.freedesktop.nm_dispatcher.service.in', + output: '@BASENAME@', + install_dir: dbus_system_bus_services_dir, + configuration: data_conf, ) install_data( @@ -23,27 +14,23 @@ install_data( install_dir: dbus_conf_dir, ) -sources = files('nm-dispatcher-utils.c') - deps = [ libnm_dep, - libnm_core_dep, + libnm_nm_default_dep, ] -cflags = [ +c_flags = [ '-DG_LOG_DOMAIN="@0@"'.format(name), '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT', ] libnm_dispatcher_core = static_library( name + '-core', - sources: sources, + sources: 'nm-dispatcher-utils.c', dependencies: deps, - c_args: cflags, + c_args: c_flags, ) -sources = files('nm-dispatcher.c') - nmdbus_dispatcher_sources = gnome.gdbus_codegen( 'nmdbus-dispatcher', name + '.xml', @@ -53,9 +40,9 @@ nmdbus_dispatcher_sources = gnome.gdbus_codegen( executable( name, - sources, + name + '.c', dependencies: deps, - c_args: cflags, + c_args: c_flags, link_with: libnm_dispatcher_core, link_args: ldflags_linker_script_binary, link_depends: linker_script_binary, diff --git a/dispatcher/nm-dispatcher-utils.c b/dispatcher/nm-dispatcher-utils.c index d9e7b32b..13a7f789 100644 --- a/dispatcher/nm-dispatcher-utils.c +++ b/dispatcher/nm-dispatcher-utils.c @@ -1,19 +1,5 @@ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Copyright (C) 2008 - 2011 Red Hat, Inc. */ diff --git a/dispatcher/nm-dispatcher-utils.h b/dispatcher/nm-dispatcher-utils.h index dca9b84f..ba355f31 100644 --- a/dispatcher/nm-dispatcher-utils.h +++ b/dispatcher/nm-dispatcher-utils.h @@ -1,19 +1,5 @@ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Copyright (C) 2008 - 2011 Red Hat, Inc. */ diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c index 311ad8d4..c38ea00f 100644 --- a/dispatcher/nm-dispatcher.c +++ b/dispatcher/nm-dispatcher.c @@ -1,19 +1,5 @@ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Copyright (C) 2008 - 2012 Red Hat, Inc. */ @@ -619,24 +605,22 @@ find_scripts (Request *request) g_hash_table_iter_init (&iter, scripts); while (g_hash_table_iter_next (&iter, (gpointer *) &filename, (gpointer *) &path)) { + gs_free char *link_target = NULL; + const char *err_msg = NULL; struct stat st; - char *link_target; int err; - const char *err_msg = NULL; link_target = g_file_read_link (path, NULL); - if (g_strcmp0 (link_target, "/dev/null") == 0) { - g_free (link_target); + if (nm_streq0 (link_target, "/dev/null")) continue; - } - g_free (link_target); err = stat (path, &st); if (err) _LOG_R_W (request, "find-scripts: Failed to stat '%s': %d", path, err); - else if (!S_ISREG (st.st_mode)) - ; /* silently skip. */ - else if (!check_permissions (&st, &err_msg)) + else if ( !S_ISREG (st.st_mode) + || st.st_size == 0) { + /* silently skip. */ + } else if (!check_permissions (&st, &err_msg)) _LOG_R_W (request, "find-scripts: Cannot execute '%s': %s", path, err_msg); else { /* success */ @@ -652,14 +636,15 @@ static gboolean script_must_wait (const char *path) { gs_free char *link = NULL; - gs_free char *dir = NULL; - gs_free char *real = NULL; - char *tmp; - link = g_file_read_link (path, NULL); if (link) { + gs_free char *dir = NULL; + nm_auto_free char *real = NULL; + if (!g_path_is_absolute (link)) { + char *tmp; + dir = g_path_get_dirname (path); tmp = g_build_path ("/", dir, link, NULL); g_free (link); @@ -669,7 +654,7 @@ script_must_wait (const char *path) dir = g_path_get_dirname (link); real = realpath (dir, NULL); - if (real && !g_str_has_suffix (real, "/no-wait.d")) + if (NM_STR_HAS_SUFFIX (real, "/no-wait.d")) return FALSE; } diff --git a/dispatcher/tests/meson.build b/dispatcher/tests/meson.build index 9d6a16de..83c915e5 100644 --- a/dispatcher/tests/meson.build +++ b/dispatcher/tests/meson.build @@ -1,22 +1,21 @@ test_unit = 'test-dispatcher-envp' -incs = [ - dispatcher_inc, - libnm_inc, +deps = [ + libnm_nm_default_dep, + libnm_utils_base_dep, +] + +c_flags = [ + '-DNETWORKMANAGER_COMPILATION_TEST', + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT', ] exe = executable( test_unit, - [ test_unit + '.c' ] + [ nmdbus_dispatcher_sources ], - include_directories: incs, - dependencies: [ - libnm_core_dep, - libnm_dep, - ], - c_args: [ - '-DNETWORKMANAGER_COMPILATION_TEST', - '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT', - ], + [test_unit + '.c', nmdbus_dispatcher_sources], + include_directories: dispatcher_inc, + dependencies: deps, + c_args: c_flags, link_with: libnm_dispatcher_core, ) diff --git a/dispatcher/tests/test-dispatcher-envp.c b/dispatcher/tests/test-dispatcher-envp.c index 47ed04ee..240b8951 100644 --- a/dispatcher/tests/test-dispatcher-envp.c +++ b/dispatcher/tests/test-dispatcher-envp.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) 2011 Red Hat, Inc. - * */ #include "nm-default.h" |