mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-06 16:21:50 +00:00
libnm: use "libnm-systemd-shared.a" in "libnm-core.la" (and "libnm.so")
It's not yet used, but it will be. We will need nm_sd_utils_unbase64mem() to strictly validate WireGuard settings, which contain keys in base64 encoding. Note that we also need a stub implementation for logging. This will do nothing for all logging from "libnm-systemd-shared.a". This makes sense because "libnm.so" as a library should not log directly. Also, "libnm.so" will only use a small portion of "libnm-systemd-shared.a" which doesn't log anything. Thus this code is unused and dropped by the linker with "--gc-sections".
This commit is contained in:
parent
0298d54078
commit
c4512f839f
23
Makefile.am
23
Makefile.am
|
@ -940,6 +940,8 @@ nodist_libnm_core_tests_test_general_SOURCES = \
|
|||
|
||||
libnm_core_tests_ldadd = \
|
||||
libnm-core/libnm-core.la \
|
||||
shared/systemd/libnm-systemd-shared.la \
|
||||
shared/systemd/libnm-systemd-logging-stub.la \
|
||||
shared/nm-utils/libnm-utils-base.la \
|
||||
$(libnm_crypto_lib) \
|
||||
$(GLIB_LIBS)
|
||||
|
@ -1191,6 +1193,8 @@ EXTRA_libnm_libnm_la_DEPENDENCIES = \
|
|||
|
||||
libnm_libnm_la_LIBADD = \
|
||||
libnm/libnm-utils.la \
|
||||
shared/systemd/libnm-systemd-shared.la \
|
||||
shared/systemd/libnm-systemd-logging-stub.la \
|
||||
shared/nm-utils/libnm-utils-udev.la \
|
||||
$(DL_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
|
@ -1357,6 +1361,8 @@ libnm_tests_cppflags = \
|
|||
|
||||
libnm_tests_ldadd = \
|
||||
libnm/libnm.la \
|
||||
shared/systemd/libnm-systemd-shared.la \
|
||||
shared/systemd/libnm-systemd-logging-stub.la \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
libnm_tests_ldflags = \
|
||||
|
@ -1517,6 +1523,22 @@ libsystemd_libadd = \
|
|||
$(CODE_COVERAGE_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
noinst_LTLIBRARIES += shared/systemd/libnm-systemd-logging-stub.la
|
||||
|
||||
shared_systemd_libnm_systemd_logging_stub_la_CPPFLAGS = \
|
||||
$(libsystemd_cppflags) \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD_SHARED \
|
||||
-DG_LOG_DOMAIN=\""libnm"\" \
|
||||
$(NULL)
|
||||
|
||||
shared_systemd_libnm_systemd_logging_stub_la_SOURCES = \
|
||||
shared/systemd/nm-logging-stub.c \
|
||||
$(NULL)
|
||||
|
||||
shared_systemd_libnm_systemd_logging_stub_la_LIBADD = \
|
||||
$(libsystemd_libadd) \
|
||||
$(NULL)
|
||||
|
||||
noinst_LTLIBRARIES += shared/systemd/libnm-systemd-shared.la
|
||||
|
||||
shared_systemd_libnm_systemd_shared_la_CPPFLAGS = \
|
||||
|
@ -2105,6 +2127,7 @@ src_initrd_nm_initrd_generator_LDADD = \
|
|||
libnm-core/libnm-core.la \
|
||||
src/initrd/libnmi-core.la \
|
||||
src/libNetworkManagerBase.la \
|
||||
shared/systemd/libnm-systemd-shared.la \
|
||||
shared/nm-utils/libnm-utils-base.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
|
|
@ -200,6 +200,7 @@ nm_core_dep = declare_dependency(
|
|||
dependencies: [
|
||||
shared_dep,
|
||||
shared_c_siphash_dep,
|
||||
libnm_systemd_shared_dep,
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -33,7 +33,10 @@ foreach test_unit: test_units
|
|||
exe = executable(
|
||||
'libnm-core-' + test_unit,
|
||||
[test_unit + '.c'] + enum,
|
||||
dependencies: nm_core_dep,
|
||||
dependencies: [
|
||||
nm_core_dep,
|
||||
libnm_systemd_shared_no_logging_dep,
|
||||
],
|
||||
c_args: [
|
||||
'-DNETWORKMANAGER_COMPILATION_TEST',
|
||||
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
|
||||
|
|
|
@ -147,6 +147,7 @@ deps = [
|
|||
libudev_dep,
|
||||
shared_dep,
|
||||
uuid_dep,
|
||||
libnm_systemd_shared_no_logging_dep,
|
||||
]
|
||||
|
||||
linker_script = join_paths(meson.current_source_dir(), 'libnm.ver')
|
||||
|
|
|
@ -20,6 +20,7 @@ foreach test_unit: test_units
|
|||
dependencies: [
|
||||
libnm_dep,
|
||||
nm_core_dep,
|
||||
libnm_systemd_shared_no_logging_dep,
|
||||
],
|
||||
c_args: cflags,
|
||||
link_with: test_unit[1],
|
||||
|
|
|
@ -207,3 +207,28 @@ libnm_systemd_shared_dep = declare_dependency(
|
|||
libnm_systemd_shared,
|
||||
],
|
||||
)
|
||||
|
||||
libnm_systemd_logging_stub = static_library(
|
||||
'nm-systemd-logging-stub',
|
||||
sources: files(
|
||||
'systemd/nm-logging-stub.c',
|
||||
),
|
||||
include_directories: include_directories(
|
||||
'systemd/sd-adapt-shared',
|
||||
'systemd/src/basic',
|
||||
),
|
||||
dependencies: shared_dep,
|
||||
c_args: [
|
||||
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD_SHARED',
|
||||
'-DG_LOG_DOMAIN="libnm"',
|
||||
],
|
||||
)
|
||||
|
||||
libnm_systemd_shared_no_logging_dep = declare_dependency(
|
||||
dependencies: [
|
||||
libnm_systemd_shared_dep,
|
||||
],
|
||||
link_with: [
|
||||
libnm_systemd_logging_stub,
|
||||
],
|
||||
)
|
||||
|
|
45
shared/systemd/nm-logging-stub.c
Normal file
45
shared/systemd/nm-logging-stub.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-utils/nm-logging-fwd.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
_nm_log_enabled (NMLogLevel level,
|
||||
NMLogDomain domain)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
_nm_log_impl (const char *file,
|
||||
guint line,
|
||||
const char *func,
|
||||
NMLogLevel level,
|
||||
NMLogDomain domain,
|
||||
int error,
|
||||
const char *ifname,
|
||||
const char *con_uuid,
|
||||
const char *fmt,
|
||||
...)
|
||||
{
|
||||
}
|
|
@ -38,7 +38,6 @@ libnm_systemd_core = static_library(
|
|||
)
|
||||
],
|
||||
dependencies: [
|
||||
libnm_systemd_shared_dep,
|
||||
nm_core_dep,
|
||||
],
|
||||
c_args: [
|
||||
|
|
Loading…
Reference in a new issue