1project( 2 'phosphor-user-manager', 3 'cpp', 4 version: '0.1', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'warning_level=3', 8 'werror=true', 9 'cpp_std=c++23', 10 'buildtype=debugoptimized', 11 ], 12) 13 14if get_option('root_user_mgmt').allowed() 15 add_project_arguments('-DENABLE_ROOT_USER_MGMT', language: 'cpp') 16endif 17 18conf_data = configuration_data() 19 20conf_data.set_quoted( 21 'USER_MANAGER_BUSNAME', 22 'xyz.openbmc_project.User.Manager', 23 description: 'The DBus busname to own.', 24) 25 26conf_data.set( 27 'CLASS_VERSION', 28 1, 29 description: 'Class version to register with Cereal.', 30) 31 32conf_data.set_quoted( 33 'LDAP_CONFIG_FILE', 34 '/etc/nslcd.conf', 35 description: 'Path of LDAP configuration file.', 36) 37 38conf_data.set_quoted( 39 'TLS_CACERT_PATH', 40 '/etc/ssl/certs/authority', 41 description: 'Path of LDAP server CA certificate.', 42) 43 44conf_data.set_quoted( 45 'TLS_CERT_FILE', 46 '/etc/nslcd/certs/cert.pem', 47 description: 'Path of LDAP client certificate.', 48) 49 50conf_data.set_quoted( 51 'LDAP_CONFIG_ROOT', 52 '/xyz/openbmc_project/user/ldap', 53 description: 'LDAP configuration root.', 54) 55 56conf_data.set_quoted( 57 'LDAP_CONFIG_DBUS_OBJ_PATH', 58 '/xyz/openbmc_project/user/ldap/config', 59 description: 'D-Bus path of LDAP config object.', 60) 61 62conf_data.set_quoted( 63 'LDAP_CONFIG_BUSNAME', 64 'xyz.openbmc_project.Ldap.Config', 65 description: 'D-Bus busname of LDAP config service.', 66) 67 68conf_data.set_quoted( 69 'LDAP_CONF_PERSIST_PATH', 70 '/var/lib/phosphor-ldap-conf', 71 description: 'path of directory having persisted LDAP configuration enabled property.', 72) 73 74conf_data.set( 75 'MAX_PASSWORD_LENGTH', 76 get_option('MAX_PASSWORD_LENGTH'), 77 description: 'Maximum password length', 78) 79 80conf_header = configure_file(output: 'config.h', configuration: conf_data) 81 82cpp = meson.get_compiler('cpp') 83 84ldap_dep = cpp.find_library('ldap', required: get_option('ldap')) 85nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 86pam_dep = dependency('pam') 87phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 88phosphor_logging_dep = dependency('phosphor-logging') 89sdbusplus_dep = dependency('sdbusplus') 90systemd_dep = dependency('systemd') 91 92# Get Cereal dependency. 93cereal_dep = dependency('cereal', required: false) 94has_cereal = cpp.has_header_symbol( 95 'cereal/cereal.hpp', 96 'cereal::specialize', 97 dependencies: cereal_dep, 98 required: false, 99) 100if not has_cereal 101 cereal_opts = import('cmake').subproject_options() 102 cereal_opts.add_cmake_defines( 103 {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}, 104 ) 105 cereal_proj = import('cmake').subproject( 106 'cereal', 107 options: cereal_opts, 108 required: false, 109 ) 110 assert(cereal_proj.found(), 'cereal is required') 111 cereal_dep = cereal_proj.dependency('cereal') 112endif 113user_manager_src = ['mainapp.cpp', 'user_mgr.cpp', 'users.cpp'] 114 115 116user_manager_deps = [ 117 nlohmann_json_dep, 118 pam_dep, 119 phosphor_dbus_interfaces_dep, 120 phosphor_logging_dep, 121 sdbusplus_dep, 122] 123 124user_manager_lib = static_library( 125 'phosphor-user-manager', 126 ['user_mgr.cpp', 'users.cpp'], 127 dependencies: user_manager_deps, 128) 129 130user_manager_dep = declare_dependency( 131 link_with: user_manager_lib, 132 dependencies: user_manager_deps, 133) 134 135executable( 136 'phosphor-user-manager', 137 'mainapp.cpp', 138 dependencies: user_manager_dep, 139 link_args: ['-lcrypt'], 140 install: true, 141) 142 143 144systemd_system_unit_dir = systemd_dep.get_variable('systemd_system_unit_dir') 145 146install_data( 147 'phosphor-nslcd-cert-config.conf', 148 install_dir: get_option('datadir') / 'dbus-1' / 'system.d', 149) 150 151install_data( 152 'nslcd', 153 install_dir: get_option('datadir') / 'phosphor-certificate-manager', 154) 155 156install_data('mfa_pam', install_dir: '/etc/pam.d/') 157 158# Figure out how to use install_symlink to install symlink to a file of another 159# recipe 160#install_symlink( 161# 'phosphor-certificate-manager@nslcd.service', 162# install_dir: systemd_system_unit_dir / 'multi-user.target.wants', 163# pointing_to: systemd_system_unit_dir / 'phosphor-certificate-manager@.service', 164# ) 165meson.add_install_script( 166 'sh', 167 '-c', 168 'mkdir -p $(dirname $DESTDIR/@0@/@1@)'.format( 169 systemd_system_unit_dir, 170 'multi-user.target.wants/phosphor-certificate-manager@nslcd.service', 171 ), 172) 173meson.add_install_script( 174 'sh', 175 '-c', 176 'ln -s @0@ $DESTDIR/@1@/@2@'.format( 177 '../phosphor-certificate-manager@.service', 178 systemd_system_unit_dir, 179 'multi-user.target.wants/phosphor-certificate-manager@nslcd.service', 180 ), 181) 182 183if get_option('ldap').allowed() and ldap_dep.found() 184 subdir('phosphor-ldap-config') 185endif 186 187if get_option('tests').allowed() 188 subdir('test') 189endif 190