1 %global watchdog_enabled 1
2 %global watchdog_timeout_sec 60
3 %global watchdog_notify_sec 20
4 %global tz_backend_enabled %{?tz_backend:%tz_backend}%{!?tz_backend:OFF}
5 %global se_backend_enabled %{?se_backend:%se_backend}%{!?se_backend:OFF}
6 %{!?build_type:%global build_type RELEASE}
7 %global coverage_only 0
8 %if %{build_type} == COVERAGE_ONLY
9 %global build_type COVERAGE
10 %global coverage_only 1
14 Summary: Central Key Manager and utilities
17 Group: Security/Secure Storage
18 License: Apache-2.0 and BSD-3-Clause
19 Source0: %{name}-%{version}.tar.gz
20 Source1001: key-manager-pam-plugin.manifest
21 Source1002: libkey-manager-client.manifest
22 Source1003: libkey-manager-client-devel.manifest
23 Source1004: libkey-manager-common.manifest
26 BuildRequires: pkgconfig(dlog)
27 BuildRequires: pkgconfig(openssl1.1)
28 BuildRequires: libattr-devel
29 BuildRequires: pkgconfig(libsmack)
30 BuildRequires: pkgconfig(libsystemd)
31 BuildRequires: pkgconfig(libxml-2.0)
32 BuildRequires: pkgconfig(capi-system-info)
33 BuildRequires: pkgconfig(security-manager)
34 BuildRequires: pkgconfig(cynara-client-async)
35 BuildRequires: pkgconfig(cynara-creds-socket)
36 BuildRequires: pkgconfig(libtzplatform-config)
37 BuildRequires: pkgconfig(glib-2.0)
38 BuildRequires: pkgconfig(pkgmgr)
39 BuildRequires: pkgconfig(vconf)
40 BuildRequires: pkgconfig(sqlcipher)
41 %if 0%{?watchdog_enabled}
42 BuildRequires: pkgconfig(argos_watchdog)
44 BuildRequires: boost-devel
45 BuildRequires: ca-certificates-devel
46 %if %{tz_backend_enabled} == ON
47 BuildRequires: key-manager-ta-devel
48 BuildRequires: key-manager-ta-serialization-devel
49 BuildRequires: pkgconfig(tef-libteec)
51 %if %{se_backend_enabled} == ON
52 BuildRequires: pkgconfig(key-manager-se-backend)
54 Requires: libkey-manager-common = %{version}-%{release}
55 %if "%{build_type}" == "COVERAGE"
61 %global user_name key-manager
62 %global group_name security_fw
63 %global supplementary_group_names key-manager
64 %global service_name key-manager
65 %global smack_domain_name System
66 %global old_rw_data_dir /opt/data/ckm
67 %global rw_data_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm}%{!?TZ_SYS_DATA:%old_rw_data_dir}
68 %global ro_data_dir %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE/ckm}%{!?TZ_SYS_RO_SHARE:%_datadir/ckm}
69 %global unit_tests_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-unit-tests}%{!?TZ_SYS_DATA:%/opt/data/ckm-unit-tests}
70 %global misc_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-misc}%{!?TZ_SYS_DATA:%/opt/data/ckm-misc}
71 %global coverage_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-coverage}%{!?TZ_SYS_DATA:%/opt/data/ckm-coverage}
72 %global bin_dir %{?TZ_SYS_BIN:%TZ_SYS_BIN}%{!?TZ_SYS_BIN:%_bindir}
73 %global ro_etc_dir %{?TZ_SYS_RO_ETC:%TZ_SYS_RO_ETC}%{!?TZ_SYS_RO_ETC:/etc}
74 %global run_dir %{?TZ_SYS_RUN:%TZ_SYS_RUN}%{!?TZ_SYS_RUN:/var/run}
75 %global initial_values_dir_ro %{ro_data_dir}/initial_values
76 %global initial_values_dir_rw %{rw_data_dir}/initial_values
77 %global ca_certs_dir %{?TZ_SYS_CA_CERTS:%TZ_SYS_CA_CERTS}%{!?TZ_SYS_CA_CERTS:%ro_etc_dir/ssl/certs}
78 %global dump_legacy_db_libname key-manager-dump-legacy-database
81 Central Key Manager daemon could be used as secure storage
82 for certificate and private/public keys. It gives API for
83 application to sign and verify (DSA/RSA/ECDSA) signatures.
85 %package -n libkey-manager-common
86 Summary: Central Key Manager (common libraries)
87 Group: Security/Libraries
89 Requires(post): /sbin/ldconfig
90 Requires(postun): /sbin/ldconfig
92 %description -n libkey-manager-common
93 Central Key Manager package (common library)
95 %package -n libkey-manager-client
96 Summary: Central Key Manager (client)
97 Group: Security/Libraries
99 Requires: key-manager = %{version}-%{release}
100 Requires: libkey-manager-common = %{version}-%{release}
101 Requires(post): /sbin/ldconfig
102 Requires(postun): /sbin/ldconfig
104 %description -n libkey-manager-client
105 Central Key Manager package (client)
107 %package -n libkey-manager-client-devel
108 Summary: Central Key Manager (client-devel)
109 Group: Security/Development
111 BuildRequires: pkgconfig(capi-base-common)
112 Requires: pkgconfig(capi-base-common)
113 Requires: libkey-manager-client = %{version}-%{release}
115 %description -n libkey-manager-client-devel
116 Central Key Manager package (client-devel)
118 %package -n key-manager-unit-tests
119 Summary: Unit tests for key-manager
120 Group: Security/Testing
121 License: Apache-2.0 and BSL-1.0
122 BuildRequires: pkgconfig(libxml-2.0)
125 %description -n key-manager-unit-tests
126 Unit tests for key-manager.
128 %package -n key-manager-misc
129 Summary: Miscellaneous tools and tests for key-manager
130 Group: Security/Testing
131 License: Apache-2.0 and BSL-1.0
133 Requires: key-manager = %{version}-%{release}
135 %description -n key-manager-misc
136 Miscellaneous tools and tests for key-manager.
138 %package -n key-manager-pam-plugin
139 Summary: CKM login/password module to PAM
140 Group: Security/Libraries
142 BuildRequires: pam-devel
143 Requires: key-manager = %{version}-%{release}
144 Requires(post): /sbin/ldconfig
145 Requires(postun): /sbin/ldconfig
147 %description -n key-manager-pam-plugin
148 CKM login/password module to PAM. Used to monitor user login/logout
149 and password change events from PAM
151 %package -n key-manager-initial-values
152 Summary: CKM initial values tool
153 Group: Security/Libraries
156 BuildRequires: pkgconfig(openssl1.1)
157 BuildRequires: pkgconfig(libxml-2.0)
158 Requires(post): /sbin/ldconfig
159 Requires(postun): /sbin/ldconfig
161 %description -n key-manager-initial-values
162 Includes ckm_initial_values tool for initial values XML generation
164 %if "%{build_type}" == "COVERAGE"
166 %package -n key-manager-coverage
167 Summary: Central Key Manager code coverage data
168 Group: Security/Testing
170 Requires: key-manager-unit-tests = %{version}-%{release}
171 Requires: key-manager-debugsource = %{version}-%{release}
175 %description -n key-manager-coverage
176 Central Key Manager code coverage data
184 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions"
186 %cmake . -DVERSION=%{version} \
187 -DCMAKE_BUILD_TYPE=%{build_type} \
188 -DCMAKE_VERBOSE_MAKEFILE=ON \
189 -DSYSTEMD_UNIT_DIR=%{_unitdir} \
190 -DSYSTEMD_ENV_FILE=%{ro_etc_dir}"/sysconfig/central-key-manager" \
191 -DRUN_DIR:PATH=%{run_dir} \
192 -DSERVICE_NAME=%{service_name} \
193 -DUSER_NAME=%{user_name} \
194 -DGROUP_NAME=%{group_name} \
195 -DSUPPLEMENTARY_GROUP_NAMES="%{supplementary_group_names}" \
196 -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
197 -DOLD_RW_DATA_DIR=%{old_rw_data_dir} \
198 -DRW_DATA_DIR=%{rw_data_dir} \
199 -DRO_DATA_DIR=%{ro_data_dir} \
200 -DRW_ETC_DIR=%{rw_etc_dir} \
201 -DRO_ETC_DIR=%{ro_etc_dir} \
202 -DBIN_DIR=%{bin_dir} \
203 -DINITIAL_VALUES_DIR_RW=%{initial_values_dir_rw} \
204 -DINITIAL_VALUES_DIR_RO=%{initial_values_dir_ro} \
205 -DCA_CERTS_DIR=%{ca_certs_dir} \
206 %if 0%{?watchdog_enabled}
207 -DWATCHDOG_ENABLED=%{watchdog_enabled} \
208 -DWATCHDOG_TIMEOUT_SEC=%{watchdog_timeout_sec} \
209 -DWATCHDOG_NOTIFY_SEC=%{watchdog_notify_sec} \
211 %if %{tz_backend_enabled} == ON
212 -DTZ_BACKEND_ENABLED=ON \
214 -DTZ_BACKEND_ENABLED=OFF \
216 %if %{se_backend_enabled} == ON
217 -DSE_BACKEND_ENABLED=ON \
219 -DSE_BACKEND_ENABLED=OFF \
221 -DUNIT_TESTS_DIR=%{unit_tests_dir} \
222 -DMISC_DIR=%{misc_dir} \
223 -DCOVERAGE_DIR=%{coverage_dir} \
227 -DDUMP_LEGACY_DB_LIBNAME=%{dump_legacy_db_libname}
229 make %{?jobs:-j%jobs}
234 %if ! %{coverage_only}
236 %install_service multi-user.target.wants central-key-manager.service
237 %install_service sockets.target.wants central-key-manager-api-control.socket
238 %install_service sockets.target.wants central-key-manager-api-storage.socket
239 %install_service sockets.target.wants central-key-manager-api-ocsp.socket
240 %install_service sockets.target.wants central-key-manager-api-encryption.socket
241 cp -a %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{buildroot}%{_datadir}/
246 # tzplatform-get sync breaked because of on-development situation. comment out just for temporary
247 # fail if runtime dir variable is different than compilation time variable
248 #if [ `tzplatform-get TZ_SYS_DATA | cut -d'=' -f2` != %{TZ_SYS_DATA} ]
250 # echo "Runtime value of TZ_SYS_DATA is different than the compilation time value. Aborting"
253 #if [ `tzplatform-get TZ_SYS_RO_SHARE | cut -d'=' -f2` != %{TZ_SYS_RO_SHARE} ]
255 # echo "Runtime value of TZ_SYS_RO_SHARE is different than the compilation time value. Aborting"
259 ## backup plan for manage key-manager user/group is deprecated b/c pwdutils package
260 ## would be excluded from binary
261 # User/group (key-manager/key-manager) should be already added in passwd package.
262 # This is our backup plan if passwd package will not be configured correctly.
263 #id -g %{group_name} > /dev/null 2>&1
264 #if [ $? -eq 1 ]; then
265 # groupadd %{group_name} -r > /dev/null 2>&1
268 #id -u %{user_name} > /dev/null 2>&1
269 #if [ $? -eq 1 ]; then
270 # useradd -d /var/lib/empty -s /sbin/nologin -r -g %{group_name} %{user_name} > /dev/null 2>&1
274 # move data from old path to new one
275 # we have to assume that in case of TZ_SYS_DATA change some upgrade script will move all the data
276 if [ -d "%{old_rw_data_dir}" ] && [ "%{rw_data_dir}" != "%{old_rw_data_dir}" ]
278 echo "Migrating old rw data to new rw data dir"
279 cp -a %{old_rw_data_dir}/. %{rw_data_dir}/ && rm -rf %{old_rw_data_dir}
282 systemctl daemon-reload
285 systemctl start central-key-manager.service
291 # In ckm version <= 0.1.18 all files were owned by root.
292 find %{rw_data_dir} -exec chsmack -a %{smack_domain_name} {} \;
293 chown %{user_name}:%{group_name} -R %{rw_data_dir}
294 systemctl restart central-key-manager.service
301 systemctl stop central-key-manager.service
307 systemctl daemon-reload
310 %post -n libkey-manager-common -p /sbin/ldconfig
311 %post -n libkey-manager-client -p /sbin/ldconfig
312 %postun -n libkey-manager-common -p /sbin/ldconfig
313 %postun -n libkey-manager-client -p /sbin/ldconfig
315 %if ! %{coverage_only}
317 %files -n key-manager
318 %manifest key-manager.manifest
320 %license LICENSE.BSD-3-Clause
321 %{bin_dir}/key-manager
322 %{_libdir}/lib%{dump_legacy_db_libname}.so
323 %{_unitdir}/multi-user.target.wants/central-key-manager.service
324 %{_unitdir}/central-key-manager.service
325 %{_unitdir}/sockets.target.wants/central-key-manager-api-control.socket
326 %{_unitdir}/central-key-manager-api-control.socket
327 %{_unitdir}/sockets.target.wants/central-key-manager-api-storage.socket
328 %{_unitdir}/central-key-manager-api-storage.socket
329 %{_unitdir}/sockets.target.wants/central-key-manager-api-ocsp.socket
330 %{_unitdir}/central-key-manager-api-ocsp.socket
331 %{_unitdir}/sockets.target.wants/central-key-manager-api-encryption.socket
332 %{_unitdir}/central-key-manager-api-encryption.socket
335 %dir %attr(770, %{user_name}, %{group_name}) %{rw_data_dir}
336 %dir %attr(550, %{user_name}, %{group_name}) %{initial_values_dir_ro}
337 %dir %attr(770, %{user_name}, %{group_name}) %{initial_values_dir_rw}
338 %attr(755,root,root) /usr/share/upgrade/scripts/295.key-manager_upgrade.sh
340 %{ro_etc_dir}/gumd/userdel.d/10_key-manager.post
343 %files -n key-manager-pam-plugin
344 %manifest %{_datadir}/key-manager-pam-plugin.manifest
346 %{_libdir}/security/pam_key_manager_plugin.so*
348 %files -n libkey-manager-common
349 %manifest %{_datadir}/libkey-manager-common.manifest
351 %{_libdir}/libkey-manager-common.so.*
353 %files -n libkey-manager-client
354 %manifest %{_datadir}/libkey-manager-client.manifest
356 %{_libdir}/libkey-manager-client.so.*
357 %{_libdir}/libkey-manager-control-client.so.*
359 %files -n libkey-manager-client-devel
360 %manifest %{_datadir}/libkey-manager-client-devel.manifest
362 %{_libdir}/libkey-manager-client.so
363 %{_libdir}/libkey-manager-control-client.so
364 %{_libdir}/libkey-manager-common.so
365 %{_includedir}/ckm/ckm/ckm-manager.h
366 %{_includedir}/ckm/ckm/ckm-manager-async.h
367 %{_includedir}/ckm/ckm/ckm-certificate.h
368 %{_includedir}/ckm/ckm/ckm-control.h
369 %{_includedir}/ckm/ckm/ckm-error.h
370 %{_includedir}/ckm/ckm/ckm-key.h
371 %{_includedir}/ckm/ckm/ckm-password.h
372 %{_includedir}/ckm/ckm/ckm-pkcs12.h
373 %{_includedir}/ckm/ckm/ckm-raw-buffer.h
374 %{_includedir}/ckm/ckm/ckm-type.h
375 %{_includedir}/ckm/ckm/ckm-zero-memory.h
376 %{_includedir}/ckm/ckmc/ckmc-manager.h
377 %{_includedir}/ckm/ckmc/ckmc-control.h
378 %{_includedir}/ckm/ckmc/ckmc-error.h
379 %{_includedir}/ckm/ckmc/ckmc-type.h
380 %{_libdir}/pkgconfig/*.pc
382 %files -n key-manager-initial-values
384 %{bin_dir}/ckm_initial_values
386 %files -n key-manager-misc
387 %manifest key-manager-misc.manifest
389 %license LICENSE.BSL-1.0
390 %{bin_dir}/ckm-scheme-test
391 %{bin_dir}/ckm_so_loader
392 %{bin_dir}/ckm_db_tool
393 %{bin_dir}/ckm_db_merge
394 %{bin_dir}/ckm_generate_db
395 %{bin_dir}/ckm_db_perf
396 %{bin_dir}/ckm_enc_perf
401 %files -n key-manager-unit-tests
402 %manifest key-manager-unit-tests.manifest
404 %license LICENSE.BSL-1.0
405 %{bin_dir}/ckm-unit-tests
408 %if "%{build_type}" == "COVERAGE"
410 %files -n key-manager-coverage
412 %{bin_dir}/key-manager-coverage.sh