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 %{!?build_type:%global build_type RELEASE}
6 %global coverage_only 0
7 %if %{build_type} == COVERAGE_ONLY
8 %global build_type COVERAGE
9 %global coverage_only 1
13 Summary: Central Key Manager and utilities
16 Group: Security/Secure Storage
17 License: Apache-2.0 and BSD-3-Clause
18 Source0: %{name}-%{version}.tar.gz
19 Source1001: key-manager-pam-plugin.manifest
20 Source1002: libkey-manager-client.manifest
21 Source1003: libkey-manager-client-devel.manifest
22 Source1004: libkey-manager-common.manifest
25 BuildRequires: pkgconfig(dlog)
26 BuildRequires: pkgconfig(openssl1.1)
27 BuildRequires: libattr-devel
28 BuildRequires: pkgconfig(libsmack)
29 BuildRequires: pkgconfig(libsystemd)
30 BuildRequires: pkgconfig(libxml-2.0)
31 BuildRequires: pkgconfig(capi-system-info)
32 BuildRequires: pkgconfig(security-manager)
33 BuildRequires: pkgconfig(cynara-client-async)
34 BuildRequires: pkgconfig(cynara-creds-socket)
35 BuildRequires: pkgconfig(libtzplatform-config)
36 BuildRequires: pkgconfig(glib-2.0)
37 BuildRequires: pkgconfig(pkgmgr)
38 BuildRequires: pkgconfig(vconf)
39 BuildRequires: pkgconfig(sqlcipher)
40 %if 0%{?watchdog_enabled}
41 BuildRequires: pkgconfig(argos_watchdog)
43 BuildRequires: boost-devel
44 BuildRequires: ca-certificates-devel
45 %if %{tz_backend_enabled} == ON
46 BuildRequires: key-manager-ta-devel
47 BuildRequires: key-manager-ta-serialization-devel
48 BuildRequires: pkgconfig(tef-libteec)
50 Requires: libkey-manager-common = %{version}-%{release}
51 %if "%{build_type}" == "COVERAGE"
57 %global user_name key-manager
58 %global group_name security_fw
59 %global supplementary_group_names key-manager
60 %global service_name key-manager
61 %global smack_domain_name System
62 %global old_rw_data_dir /opt/data/ckm
63 %global rw_data_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm}%{!?TZ_SYS_DATA:%old_rw_data_dir}
64 %global ro_data_dir %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE/ckm}%{!?TZ_SYS_RO_SHARE:%_datadir/ckm}
65 %global unit_tests_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-unit-tests}%{!?TZ_SYS_DATA:%/opt/data/ckm-unit-tests}
66 %global misc_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-misc}%{!?TZ_SYS_DATA:%/opt/data/ckm-misc}
67 %global coverage_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-coverage}%{!?TZ_SYS_DATA:%/opt/data/ckm-coverage}
68 %global bin_dir %{?TZ_SYS_BIN:%TZ_SYS_BIN}%{!?TZ_SYS_BIN:%_bindir}
69 %global ro_etc_dir %{?TZ_SYS_RO_ETC:%TZ_SYS_RO_ETC}%{!?TZ_SYS_RO_ETC:/etc}
70 %global run_dir %{?TZ_SYS_RUN:%TZ_SYS_RUN}%{!?TZ_SYS_RUN:/var/run}
71 %global initial_values_dir_ro %{ro_data_dir}/initial_values
72 %global initial_values_dir_rw %{rw_data_dir}/initial_values
73 %global ca_certs_dir %{?TZ_SYS_CA_CERTS:%TZ_SYS_CA_CERTS}%{!?TZ_SYS_CA_CERTS:%ro_etc_dir/ssl/certs}
74 %global dump_legacy_db_libname key-manager-dump-legacy-database
77 Central Key Manager daemon could be used as secure storage
78 for certificate and private/public keys. It gives API for
79 application to sign and verify (DSA/RSA/ECDSA) signatures.
81 %package -n libkey-manager-common
82 Summary: Central Key Manager (common libraries)
83 Group: Security/Libraries
85 Requires(post): /sbin/ldconfig
86 Requires(postun): /sbin/ldconfig
88 %description -n libkey-manager-common
89 Central Key Manager package (common library)
91 %package -n libkey-manager-client
92 Summary: Central Key Manager (client)
93 Group: Security/Libraries
95 Requires: key-manager = %{version}-%{release}
96 Requires: libkey-manager-common = %{version}-%{release}
97 Requires(post): /sbin/ldconfig
98 Requires(postun): /sbin/ldconfig
100 %description -n libkey-manager-client
101 Central Key Manager package (client)
103 %package -n libkey-manager-client-devel
104 Summary: Central Key Manager (client-devel)
105 Group: Security/Development
107 BuildRequires: pkgconfig(capi-base-common)
108 Requires: pkgconfig(capi-base-common)
109 Requires: libkey-manager-client = %{version}-%{release}
111 %description -n libkey-manager-client-devel
112 Central Key Manager package (client-devel)
114 %package -n key-manager-unit-tests
115 Summary: Unit tests for key-manager
116 Group: Security/Testing
117 License: Apache-2.0 and BSL-1.0
118 BuildRequires: pkgconfig(libxml-2.0)
121 %description -n key-manager-unit-tests
122 Unit tests for key-manager.
124 %package -n key-manager-misc
125 Summary: Miscellaneous tools and tests for key-manager
126 Group: Security/Testing
127 License: Apache-2.0 and BSL-1.0
129 Requires: key-manager = %{version}-%{release}
131 %description -n key-manager-misc
132 Miscellaneous tools and tests for key-manager.
134 %package -n key-manager-pam-plugin
135 Summary: CKM login/password module to PAM
136 Group: Security/Libraries
138 BuildRequires: pam-devel
139 Requires: key-manager = %{version}-%{release}
140 Requires(post): /sbin/ldconfig
141 Requires(postun): /sbin/ldconfig
143 %description -n key-manager-pam-plugin
144 CKM login/password module to PAM. Used to monitor user login/logout
145 and password change events from PAM
147 %package -n key-manager-initial-values
148 Summary: CKM initial values tool
149 Group: Security/Libraries
152 BuildRequires: pkgconfig(openssl1.1)
153 BuildRequires: pkgconfig(libxml-2.0)
154 Requires(post): /sbin/ldconfig
155 Requires(postun): /sbin/ldconfig
157 %description -n key-manager-initial-values
158 Includes ckm_initial_values tool for initial values XML generation
160 %if "%{build_type}" == "COVERAGE"
162 %package -n key-manager-coverage
163 Summary: Central Key Manager code coverage data
164 Group: Security/Testing
166 Requires: key-manager-unit-tests = %{version}-%{release}
167 Requires: key-manager-debugsource = %{version}-%{release}
171 %description -n key-manager-coverage
172 Central Key Manager code coverage data
180 %if 0%{?sec_build_binary_debug_enable}
181 export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
182 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
185 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions"
187 %cmake . -DVERSION=%{version} \
188 -DCMAKE_BUILD_TYPE=%{build_type} \
189 -DCMAKE_VERBOSE_MAKEFILE=ON \
190 -DSYSTEMD_UNIT_DIR=%{_unitdir} \
191 -DSYSTEMD_ENV_FILE=%{ro_etc_dir}"/sysconfig/central-key-manager" \
192 -DRUN_DIR:PATH=%{run_dir} \
193 -DSERVICE_NAME=%{service_name} \
194 -DUSER_NAME=%{user_name} \
195 -DGROUP_NAME=%{group_name} \
196 -DSUPPLEMENTARY_GROUP_NAMES="%{supplementary_group_names}" \
197 -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
198 -DOLD_RW_DATA_DIR=%{old_rw_data_dir} \
199 -DRW_DATA_DIR=%{rw_data_dir} \
200 -DRO_DATA_DIR=%{ro_data_dir} \
201 -DRW_ETC_DIR=%{rw_etc_dir} \
202 -DRO_ETC_DIR=%{ro_etc_dir} \
203 -DBIN_DIR=%{bin_dir} \
204 -DINITIAL_VALUES_DIR_RW=%{initial_values_dir_rw} \
205 -DINITIAL_VALUES_DIR_RO=%{initial_values_dir_ro} \
206 -DCA_CERTS_DIR=%{ca_certs_dir} \
207 %if 0%{?watchdog_enabled}
208 -DWATCHDOG_ENABLED=%{watchdog_enabled} \
209 -DWATCHDOG_TIMEOUT_SEC=%{watchdog_timeout_sec} \
210 -DWATCHDOG_NOTIFY_SEC=%{watchdog_notify_sec} \
212 %if %{tz_backend_enabled} == ON
213 -DTZ_BACKEND_ENABLED=ON \
215 -DTZ_BACKEND_ENABLED=OFF \
217 -DUNIT_TESTS_DIR=%{unit_tests_dir} \
218 -DMISC_DIR=%{misc_dir} \
219 -DCOVERAGE_DIR=%{coverage_dir} \
223 -DDUMP_LEGACY_DB_LIBNAME=%{dump_legacy_db_libname}
225 make %{?jobs:-j%jobs}
230 %if ! %{coverage_only}
232 %install_service multi-user.target.wants central-key-manager.service
233 %install_service sockets.target.wants central-key-manager-api-control.socket
234 %install_service sockets.target.wants central-key-manager-api-storage.socket
235 %install_service sockets.target.wants central-key-manager-api-ocsp.socket
236 %install_service sockets.target.wants central-key-manager-api-encryption.socket
237 cp -a %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{buildroot}%{_datadir}/
242 # tzplatform-get sync breaked because of on-development situation. comment out just for temporary
243 # fail if runtime dir variable is different than compilation time variable
244 #if [ `tzplatform-get TZ_SYS_DATA | cut -d'=' -f2` != %{TZ_SYS_DATA} ]
246 # echo "Runtime value of TZ_SYS_DATA is different than the compilation time value. Aborting"
249 #if [ `tzplatform-get TZ_SYS_RO_SHARE | cut -d'=' -f2` != %{TZ_SYS_RO_SHARE} ]
251 # echo "Runtime value of TZ_SYS_RO_SHARE is different than the compilation time value. Aborting"
255 ## backup plan for manage key-manager user/group is deprecated b/c pwdutils package
256 ## would be excluded from binary
257 # User/group (key-manager/key-manager) should be already added in passwd package.
258 # This is our backup plan if passwd package will not be configured correctly.
259 #id -g %{group_name} > /dev/null 2>&1
260 #if [ $? -eq 1 ]; then
261 # groupadd %{group_name} -r > /dev/null 2>&1
264 #id -u %{user_name} > /dev/null 2>&1
265 #if [ $? -eq 1 ]; then
266 # useradd -d /var/lib/empty -s /sbin/nologin -r -g %{group_name} %{user_name} > /dev/null 2>&1
270 # move data from old path to new one
271 # we have to assume that in case of TZ_SYS_DATA change some upgrade script will move all the data
272 if [ -d "%{old_rw_data_dir}" ] && [ "%{rw_data_dir}" != "%{old_rw_data_dir}" ]
274 echo "Migrating old rw data to new rw data dir"
275 cp -a %{old_rw_data_dir}/. %{rw_data_dir}/ && rm -rf %{old_rw_data_dir}
278 systemctl daemon-reload
281 systemctl start central-key-manager.service
287 # In ckm version <= 0.1.18 all files were owned by root.
288 find %{rw_data_dir} -exec chsmack -a %{smack_domain_name} {} \;
289 chown %{user_name}:%{group_name} -R %{rw_data_dir}
290 systemctl restart central-key-manager.service
297 systemctl stop central-key-manager.service
303 systemctl daemon-reload
306 %post -n libkey-manager-common -p /sbin/ldconfig
307 %post -n libkey-manager-client -p /sbin/ldconfig
308 %postun -n libkey-manager-common -p /sbin/ldconfig
309 %postun -n libkey-manager-client -p /sbin/ldconfig
311 %if ! %{coverage_only}
313 %files -n key-manager
314 %manifest key-manager.manifest
316 %license LICENSE.BSD-3-Clause
317 %{bin_dir}/key-manager
318 %{_libdir}/lib%{dump_legacy_db_libname}.so
319 %{_unitdir}/multi-user.target.wants/central-key-manager.service
320 %{_unitdir}/central-key-manager.service
321 %{_unitdir}/sockets.target.wants/central-key-manager-api-control.socket
322 %{_unitdir}/central-key-manager-api-control.socket
323 %{_unitdir}/sockets.target.wants/central-key-manager-api-storage.socket
324 %{_unitdir}/central-key-manager-api-storage.socket
325 %{_unitdir}/sockets.target.wants/central-key-manager-api-ocsp.socket
326 %{_unitdir}/central-key-manager-api-ocsp.socket
327 %{_unitdir}/sockets.target.wants/central-key-manager-api-encryption.socket
328 %{_unitdir}/central-key-manager-api-encryption.socket
331 %dir %attr(770, %{user_name}, %{group_name}) %{rw_data_dir}
332 %dir %attr(550, %{user_name}, %{group_name}) %{initial_values_dir_ro}
333 %dir %attr(770, %{user_name}, %{group_name}) %{initial_values_dir_rw}
334 %attr(755,root,root) /usr/share/upgrade/scripts/295.key-manager_upgrade.sh
336 %{ro_etc_dir}/gumd/userdel.d/10_key-manager.post
339 %files -n key-manager-pam-plugin
340 %manifest %{_datadir}/key-manager-pam-plugin.manifest
342 %{_libdir}/security/pam_key_manager_plugin.so*
344 %files -n libkey-manager-common
345 %manifest %{_datadir}/libkey-manager-common.manifest
347 %{_libdir}/libkey-manager-common.so.*
349 %files -n libkey-manager-client
350 %manifest %{_datadir}/libkey-manager-client.manifest
352 %{_libdir}/libkey-manager-client.so.*
353 %{_libdir}/libkey-manager-control-client.so.*
355 %files -n libkey-manager-client-devel
356 %manifest %{_datadir}/libkey-manager-client-devel.manifest
358 %{_libdir}/libkey-manager-client.so
359 %{_libdir}/libkey-manager-control-client.so
360 %{_libdir}/libkey-manager-common.so
361 %{_includedir}/ckm/ckm/ckm-manager.h
362 %{_includedir}/ckm/ckm/ckm-manager-async.h
363 %{_includedir}/ckm/ckm/ckm-certificate.h
364 %{_includedir}/ckm/ckm/ckm-control.h
365 %{_includedir}/ckm/ckm/ckm-error.h
366 %{_includedir}/ckm/ckm/ckm-key.h
367 %{_includedir}/ckm/ckm/ckm-password.h
368 %{_includedir}/ckm/ckm/ckm-pkcs12.h
369 %{_includedir}/ckm/ckm/ckm-raw-buffer.h
370 %{_includedir}/ckm/ckm/ckm-type.h
371 %{_includedir}/ckm/ckm/ckm-zero-memory.h
372 %{_includedir}/ckm/ckmc/ckmc-manager.h
373 %{_includedir}/ckm/ckmc/ckmc-control.h
374 %{_includedir}/ckm/ckmc/ckmc-error.h
375 %{_includedir}/ckm/ckmc/ckmc-type.h
376 %{_libdir}/pkgconfig/*.pc
378 %files -n key-manager-initial-values
380 %{bin_dir}/ckm_initial_values
382 %files -n key-manager-misc
383 %manifest key-manager-misc.manifest
385 %license LICENSE.BSL-1.0
386 %{bin_dir}/ckm-scheme-test
387 %{bin_dir}/ckm_so_loader
388 %{bin_dir}/ckm_db_tool
389 %{bin_dir}/ckm_db_merge
390 %{bin_dir}/ckm_generate_db
391 %{bin_dir}/ckm_db_perf
396 %files -n key-manager-unit-tests
397 %manifest key-manager-unit-tests.manifest
399 %license LICENSE.BSL-1.0
400 %{bin_dir}/ckm-unit-tests
403 %if "%{build_type}" == "COVERAGE"
405 %files -n key-manager-coverage
407 %{bin_dir}/key-manager-coverage.sh