]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - meson.build
udev: fix codesonar warnings
[thirdparty/systemd.git] / meson.build
index e9eb7f9569eb3d502aeeb7fe116f01d0418fe051..dbbddb68e23283596da04b94f0d3b596d539d96c 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
 project('systemd', 'c',
-        version : '245',
+        version : '246',
         license : 'LGPLv2+',
         default_options: [
                 'c_std=gnu99',
@@ -13,8 +13,8 @@ project('systemd', 'c',
         meson_version : '>= 0.46',
        )
 
-libsystemd_version = '0.28.0'
-libudev_version = '1.6.17'
+libsystemd_version = '0.29.0'
+libudev_version = '1.6.18'
 
 # We need the same data in two different formats, ugh!
 # Also, for hysterical reasons, we use different variable
@@ -85,11 +85,17 @@ if rootprefixdir == ''
 endif
 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
 
+have_standalone_binaries = get_option('standalone-binaries')
+
 sysvinit_path = get_option('sysvinit-path')
 sysvrcnd_path = get_option('sysvrcnd-path')
 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
            description : 'SysV init scripts and rcN.d links are supported')
 
+if get_option('hibernate') and not get_option('initrd')
+        error('hibernate depends on initrd')
+endif
+
 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN',  get_option('bump-proc-sys-fs-nr-open'))
 conf.set('HIGH_RLIMIT_NOFILE',          512*1024)
@@ -304,6 +310,7 @@ meson_build_sh = find_program('tools/meson-build.sh')
 
 want_tests = get_option('tests')
 slow_tests = want_tests != 'false' and get_option('slow-tests')
+fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
 install_tests = get_option('install-tests')
 
 if add_languages('cpp', required : fuzzer_build)
@@ -669,13 +676,17 @@ conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
 
 time_epoch = get_option('time-epoch')
 if time_epoch == -1
-        source_date_epoch = run_command('sh', ['-c', 'echo "$SOURCE_DATE_EPOCH"']).stdout().strip()
-        if source_date_epoch != ''
-                time_epoch = source_date_epoch.to_int()
-        else
+        time_epoch = run_command('sh', ['-c', 'echo "$SOURCE_DATE_EPOCH"']).stdout().strip()
+        if time_epoch == '' and git.found() and run_command('test', '-e', '.git').returncode() == 0
+                # If we're in a git repository, use the creation time of the latest git tag.
+                latest_tag = run_command('git', 'describe', '--abbrev=0', '--tags').stdout().strip()
+                time_epoch = run_command('git', 'log', '-1', '--format=%at', latest_tag).stdout()
+        endif
+        if time_epoch == ''
                 NEWS = files('NEWS')
-                time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout().to_int()
+                time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
         endif
+        time_epoch = time_epoch.to_int()
 endif
 conf.set('TIME_EPOCH', time_epoch)
 
@@ -924,6 +935,7 @@ conf.set10('HAVE_SELINUX', have)
 want_apparmor = get_option('apparmor')
 if want_apparmor != 'false' and not skip_deps
         libapparmor = dependency('libapparmor',
+                                 version : '>= 2.13',
                                  required : want_apparmor == 'true')
         have = libapparmor.found()
 else
@@ -1027,6 +1039,8 @@ if want_libcryptsetup != 'false' and not skip_deps
 
         conf.set10('HAVE_CRYPT_SET_METADATA_SIZE',
                    have and cc.has_function('crypt_set_metadata_size', dependencies : libcryptsetup))
+        conf.set10('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY',
+                   have and cc.has_function('crypt_activate_by_signed_key', dependencies : libcryptsetup))
 else
         have = false
         libcryptsetup = []
@@ -1143,6 +1157,17 @@ else
 endif
 conf.set10('HAVE_P11KIT', have)
 
+want_libfido2 = get_option('libfido2')
+if want_libfido2 != 'false' and not skip_deps
+        libfido2 = dependency('libfido2',
+                              required : want_libfido2 == 'true')
+        have = libfido2.found()
+else
+        have = false
+        libfido2 = []
+endif
+conf.set10('HAVE_LIBFIDO2', have)
+
 want_elfutils = get_option('elfutils')
 if want_elfutils != 'false' and not skip_deps
         libdw = dependency('libdw',
@@ -1180,36 +1205,38 @@ want_xz = get_option('xz')
 if want_xz != 'false' and not skip_deps
         libxz = dependency('liblzma',
                            required : want_xz == 'true')
-        have = libxz.found()
+        have_xz = libxz.found()
 else
-        have = false
+        have_xz = false
         libxz = []
 endif
-conf.set10('HAVE_XZ', have)
+conf.set10('HAVE_XZ', have_xz)
 
 want_lz4 = get_option('lz4')
 if want_lz4 != 'false' and not skip_deps
         liblz4 = dependency('liblz4',
                             version : '>= 1.3.0',
                             required : want_lz4 == 'true')
-        have = liblz4.found()
+        have_lz4 = liblz4.found()
 else
-        have = false
+        have_lz4 = false
         liblz4 = []
 endif
-conf.set10('HAVE_LZ4', have)
+conf.set10('HAVE_LZ4', have_lz4)
 
 want_zstd = get_option('zstd')
 if want_zstd != 'false' and not skip_deps
         libzstd = dependency('libzstd',
                              required : want_zstd == 'true',
                              version : '>= 1.4.0')
-        have = libzstd.found()
+        have_zstd = libzstd.found()
 else
-        have = false
+        have_zstd = false
         libzstd = []
 endif
-conf.set10('HAVE_ZSTD', have)
+conf.set10('HAVE_ZSTD', have_zstd)
+
+conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
 
 want_xkbcommon = get_option('xkbcommon')
 if want_xkbcommon != 'false' and not skip_deps
@@ -1412,6 +1439,7 @@ foreach term : ['utmp',
                 'tmpfiles',
                 'hwdb',
                 'rfkill',
+                'xdg-autostart',
                 'ldconfig',
                 'efi',
                 'tpm',
@@ -1419,6 +1447,7 @@ foreach term : ['utmp',
                 'smack',
                 'gshadow',
                 'idn',
+                'initrd',
                 'nss-myhostname',
                 'nss-systemd']
         have = get_option(term)
@@ -1514,6 +1543,7 @@ includes = include_directories('src/basic',
                                'src/libudev',
                                'src/core',
                                'src/shutdown',
+                               'src/xdg-autostart-generator',
                                'src/libsystemd/sd-bus',
                                'src/libsystemd/sd-device',
                                'src/libsystemd/sd-event',
@@ -1626,6 +1656,7 @@ subdir('src/nspawn')
 subdir('src/resolve')
 subdir('src/timedate')
 subdir('src/timesync')
+subdir('src/tmpfiles')
 subdir('src/vconsole')
 subdir('src/boot/efi')
 
@@ -1648,7 +1679,7 @@ test_dlopen = executable(
         build_by_default : want_tests != 'false')
 
 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
-                 ['systemd',    'ENABLE_NSS_SYSTEMD', 'src/nss-systemd/userdb-glue.c src/nss-systemd/userdb-glue.h'],
+                 ['systemd',    'ENABLE_NSS_SYSTEMD', 'src/nss-systemd/userdb-glue.c src/nss-systemd/userdb-glue.h src/nss-systemd/nss-systemd.h'],
                  ['mymachines', 'ENABLE_NSS_MYMACHINES'],
                  ['resolve',    'ENABLE_NSS_RESOLVE']]
 
@@ -2130,7 +2161,8 @@ if conf.get('ENABLE_HOMED') == 1
                                 libcrypt,
                                 libopenssl,
                                 libfdisk,
-                                libp11kit],
+                                libp11kit,
+                                libfido2],
                 install_rpath : rootlibexecdir,
                 install : true,
                 install_dir : rootlibexecdir)
@@ -2157,6 +2189,7 @@ if conf.get('ENABLE_HOMED') == 1
                                 libcrypt,
                                 libopenssl,
                                 libp11kit,
+                                libfido2,
                                 libpwquality],
                 install_rpath : rootlibexecdir,
                 install : true,
@@ -2183,12 +2216,17 @@ if conf.get('ENABLE_HOMED') == 1
         endif
 endif
 
-foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
+foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
+                (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
         meson.add_install_script(meson_make_symlink,
                                  join_paths(rootbindir, 'systemctl'),
                                  join_paths(rootsbindir, alias))
 endforeach
 
+meson.add_install_script(meson_make_symlink,
+                         join_paths(rootbindir, 'udevadm'),
+                         join_paths(rootlibexecdir, 'systemd-udevd'))
+
 if conf.get('ENABLE_BACKLIGHT') == 1
         executable(
                 'systemd-backlight',
@@ -2222,8 +2260,10 @@ executable(
 
 if conf.get('HAVE_LIBCRYPTSETUP') == 1
         systemd_cryptsetup_sources = files('''
-                src/cryptsetup/cryptsetup.c
                 src/cryptsetup/cryptsetup-pkcs11.h
+                src/cryptsetup/cryptsetup-util.c
+                src/cryptsetup/cryptsetup-util.h
+                src/cryptsetup/cryptsetup.c
 '''.split())
 
         if conf.get('HAVE_P11KIT') == 1
@@ -2292,6 +2332,27 @@ if conf.get('HAVE_SYSV_COMPAT') == 1
                 install_dir : systemgeneratordir)
 endif
 
+if conf.get('ENABLE_XDG_AUTOSTART') == 1
+        executable(
+                'systemd-xdg-autostart-generator',
+                'src/xdg-autostart-generator/xdg-autostart-generator.c',
+                'src/xdg-autostart-generator/xdg-autostart-service.c',
+                include_directories : includes,
+                link_with : [libshared],
+                install_rpath : rootlibexecdir,
+                install : true,
+                install_dir : usergeneratordir)
+
+        executable(
+                'systemd-xdg-autostart-condition',
+                'src/xdg-autostart-generator/xdg-autostart-condition.c',
+                include_directories : includes,
+                link_with : [libshared],
+                install_rpath : rootlibexecdir,
+                install : true,
+                install_dir : rootlibexecdir)
+endif
+
 if conf.get('ENABLE_HOSTNAMED') == 1
         executable(
                 'systemd-hostnamed',
@@ -2766,7 +2827,7 @@ executable(
         include_directories : includes,
         link_with : [libshared],
         install_rpath : rootlibexecdir,
-        install : true,
+        install : conf.get('ENABLE_INITRD') == 1,
         install_dir : rootlibexecdir)
 
 executable(
@@ -2843,7 +2904,7 @@ executable(
         include_directories : includes,
         link_with : [libshared],
         install_rpath : rootlibexecdir,
-        install : true,
+        install : (conf.get('HAVE_SYSV_COMPAT') == 1),
         install_dir : rootlibexecdir)
 
 public_programs += executable(
@@ -2894,14 +2955,26 @@ if conf.get('ENABLE_SYSUSERS') == 1
                 install_rpath : rootlibexecdir,
                 install : true,
                 install_dir : rootbindir)
+
+        if have_standalone_binaries
+                public_programs += executable(
+                        'systemd-sysusers.standalone',
+                        'src/sysusers/sysusers.c',
+                        include_directories : includes,
+                        link_with : [libshared_static,
+                                     libbasic,
+                                     libbasic_gcrypt,
+                                     libsystemd_static,
+                                     libjournal_client],
+                        install : true,
+                        install_dir : rootbindir)
+        endif
 endif
 
 if conf.get('ENABLE_TMPFILES') == 1
         exe = executable(
                 'systemd-tmpfiles',
-                'src/tmpfiles/tmpfiles.c',
-                'src/tmpfiles/offline-passwd.c',
-                'src/tmpfiles/offline-passwd.h',
+                systemd_tmpfiles_sources,
                 include_directories : includes,
                 link_with : [libshared],
                 dependencies : [libacl],
@@ -2916,6 +2989,21 @@ if conf.get('ENABLE_TMPFILES') == 1
                      # https://github.com/mesonbuild/meson/issues/2681
                      args : exe.full_path())
         endif
+
+        if have_standalone_binaries
+                public_programs += executable(
+                        'systemd-tmpfiles.standalone',
+                        systemd_tmpfiles_sources,
+                        include_directories : includes,
+                        link_with : [libshared_static,
+                                     libbasic,
+                                     libbasic_gcrypt,
+                                     libsystemd_static,
+                                     libjournal_client],
+                        dependencies : [libacl],
+                        install : true,
+                        install_dir : rootbindir)
+        endif
 endif
 
 if conf.get('ENABLE_HWDB') == 1
@@ -2951,24 +3039,6 @@ public_programs += executable(
         install : true,
         install_dir : rootlibexecdir)
 
-public_programs += executable(
-        'systemd-udevd',
-        systemd_udevd_sources,
-        include_directories : includes,
-        c_args : '-DLOG_REALM=LOG_REALM_UDEV',
-        link_with : [libudev_core,
-                     libsystemd_network,
-                     libudev_static],
-        dependencies : [versiondep,
-                        threads,
-                        libkmod,
-                        libidn,
-                        libacl,
-                        libblkid],
-        install_rpath : udev_rpath,
-        install : true,
-        install_dir : rootlibexecdir)
-
 public_programs += executable(
         'udevadm',
         udevadm_sources,
@@ -3014,7 +3084,7 @@ executable(
         link_with : [libshared],
         dependencies : [libaudit],
         install_rpath : rootlibexecdir,
-        install : true,
+        install : (conf.get('ENABLE_UTMP') == 1),
         install_dir : rootlibexecdir)
 
 if conf.get('HAVE_KMOD') == 1
@@ -3343,7 +3413,7 @@ foreach tuple : sanitizers
                         if name != prev
                                 if want_tests == 'false'
                                         message('Not compiling @0@ because tests is set to false'.format(name))
-                                elif slow_tests
+                                elif slow_tests or fuzz_tests
                                         exe = custom_target(
                                                 name,
                                                 output : name,
@@ -3353,14 +3423,16 @@ foreach tuple : sanitizers
                                                            '@OUTPUT@'],
                                                 build_by_default : true)
                                 else
-                                        message('Not compiling @0@ because slow-tests is set to false'.format(name))
+                                        message('Not compiling @0@ because slow-tests/fuzz-tests is set to false'.format(name))
                                 endif
                         endif
                         prev = name
 
-                        if want_tests != 'false' and slow_tests
+                        if want_tests != 'false' and (slow_tests or fuzz_tests)
                                 test('@0@:@1@:@2@'.format(b, c, sanitizer),
                                      env,
+                                     env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
+                                     timeout : 60,
                                      args : [exe.full_path(),
                                              join_paths(project_source_root, p)])
                         endif
@@ -3520,6 +3592,7 @@ foreach tuple : [
         ['pwquality'],
         ['libfdisk'],
         ['p11kit'],
+        ['libfido2'],
         ['AUDIT'],
         ['IMA'],
         ['AppArmor'],
@@ -3539,6 +3612,7 @@ foreach tuple : [
         ['openssl'],
         ['libcurl'],
         ['idn'],
+        ['initrd'],
         ['libidn2'],
         ['libidn'],
         ['libiptc'],
@@ -3554,6 +3628,7 @@ foreach tuple : [
         ['randomseed'],
         ['backlight'],
         ['rfkill'],
+        ['xdg-autostart'],
         ['logind'],
         ['machined'],
         ['portabled'],