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-daemon)
30 BuildRequires: pkgconfig(libsystemd-journal)
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 Requires: libkey-manager-common = %{version}-%{release}
52 %if "%{build_type}" == "COVERAGE"
58 %global user_name key-manager
59 %global group_name security_fw
60 %global supplementary_group_names key-manager
61 %global service_name key-manager
62 %global smack_domain_name System
63 %global old_rw_data_dir /opt/data/ckm
64 %global rw_data_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm}%{!?TZ_SYS_DATA:%old_rw_data_dir}
65 %global ro_data_dir %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE/ckm}%{!?TZ_SYS_RO_SHARE:%_datadir/ckm}
66 %global unit_tests_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-unit-tests}%{!?TZ_SYS_DATA:%/opt/data/ckm-unit-tests}
67 %global misc_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-misc}%{!?TZ_SYS_DATA:%/opt/data/ckm-misc}
68 %global coverage_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-coverage}%{!?TZ_SYS_DATA:%/opt/data/ckm-coverage}
69 %global bin_dir %{?TZ_SYS_BIN:%TZ_SYS_BIN}%{!?TZ_SYS_BIN:%_bindir}
70 %global ro_etc_dir %{?TZ_SYS_RO_ETC:%TZ_SYS_RO_ETC}%{!?TZ_SYS_RO_ETC:/etc}
71 %global run_dir %{?TZ_SYS_RUN:%TZ_SYS_RUN}%{!?TZ_SYS_RUN:/var/run}
72 %global initial_values_dir_ro %{ro_data_dir}/initial_values
73 %global initial_values_dir_rw %{rw_data_dir}/initial_values
74 %global ca_certs_dir %{?TZ_SYS_CA_CERTS:%TZ_SYS_CA_CERTS}%{!?TZ_SYS_CA_CERTS:%ro_etc_dir/ssl/certs}
75 %global dump_legacy_db_libname key-manager-dump-legacy-database
78 Central Key Manager daemon could be used as secure storage
79 for certificate and private/public keys. It gives API for
80 application to sign and verify (DSA/RSA/ECDSA) signatures.
82 %package -n libkey-manager-common
83 Summary: Central Key Manager (common libraries)
84 Group: Security/Libraries
86 Requires(post): /sbin/ldconfig
87 Requires(postun): /sbin/ldconfig
89 %description -n libkey-manager-common
90 Central Key Manager package (common library)
92 %package -n libkey-manager-client
93 Summary: Central Key Manager (client)
94 Group: Security/Libraries
96 Requires: key-manager = %{version}-%{release}
97 Requires: libkey-manager-common = %{version}-%{release}
98 Requires(post): /sbin/ldconfig
99 Requires(postun): /sbin/ldconfig
101 %description -n libkey-manager-client
102 Central Key Manager package (client)
104 %package -n libkey-manager-client-devel
105 Summary: Central Key Manager (client-devel)
106 Group: Security/Development
108 BuildRequires: pkgconfig(capi-base-common)
109 Requires: pkgconfig(capi-base-common)
110 Requires: libkey-manager-client = %{version}-%{release}
112 %description -n libkey-manager-client-devel
113 Central Key Manager package (client-devel)
115 %package -n key-manager-unit-tests
116 Summary: Unit tests for key-manager
117 Group: Security/Testing
118 License: Apache-2.0 and BSL-1.0
119 BuildRequires: pkgconfig(libxml-2.0)
122 %description -n key-manager-unit-tests
123 Unit tests for key-manager.
125 %package -n key-manager-misc
126 Summary: Miscellaneous tools and tests for key-manager
127 Group: Security/Testing
128 License: Apache-2.0 and BSL-1.0
130 Requires: key-manager = %{version}-%{release}
132 %description -n key-manager-misc
133 Miscellaneous tools and tests for key-manager.
135 %package -n key-manager-pam-plugin
136 Summary: CKM login/password module to PAM
137 Group: Security/Libraries
139 BuildRequires: pam-devel
140 Requires: key-manager = %{version}-%{release}
141 Requires(post): /sbin/ldconfig
142 Requires(postun): /sbin/ldconfig
144 %description -n key-manager-pam-plugin
145 CKM login/password module to PAM. Used to monitor user login/logout
146 and password change events from PAM
148 %package -n key-manager-initial-values
149 Summary: CKM initial values tool
150 Group: Security/Libraries
153 BuildRequires: pkgconfig(openssl1.1)
154 BuildRequires: pkgconfig(libxml-2.0)
155 Requires(post): /sbin/ldconfig
156 Requires(postun): /sbin/ldconfig
158 %description -n key-manager-initial-values
159 Includes ckm_initial_values tool for initial values XML generation
161 %if "%{build_type}" == "COVERAGE"
163 %package -n key-manager-coverage
164 Summary: Central Key Manager code coverage data
165 Group: Security/Testing
167 Requires: key-manager-unit-tests = %{version}-%{release}
168 Requires: key-manager-debugsource = %{version}-%{release}
172 %description -n key-manager-coverage
173 Central Key Manager code coverage data
181 %if 0%{?sec_build_binary_debug_enable}
182 export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
183 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
186 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions"
188 %cmake . -DVERSION=%{version} \
189 -DCMAKE_BUILD_TYPE=%{build_type} \
190 -DCMAKE_VERBOSE_MAKEFILE=ON \
191 -DSYSTEMD_UNIT_DIR=%{_unitdir} \
192 -DSYSTEMD_ENV_FILE=%{ro_etc_dir}"/sysconfig/central-key-manager" \
193 -DRUN_DIR:PATH=%{run_dir} \
194 -DSERVICE_NAME=%{service_name} \
195 -DUSER_NAME=%{user_name} \
196 -DGROUP_NAME=%{group_name} \
197 -DSUPPLEMENTARY_GROUP_NAMES="%{supplementary_group_names}" \
198 -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
199 -DOLD_RW_DATA_DIR=%{old_rw_data_dir} \
200 -DRW_DATA_DIR=%{rw_data_dir} \
201 -DRO_DATA_DIR=%{ro_data_dir} \
202 -DRW_ETC_DIR=%{rw_etc_dir} \
203 -DRO_ETC_DIR=%{ro_etc_dir} \
204 -DBIN_DIR=%{bin_dir} \
205 -DINITIAL_VALUES_DIR_RW=%{initial_values_dir_rw} \
206 -DINITIAL_VALUES_DIR_RO=%{initial_values_dir_ro} \
207 -DCA_CERTS_DIR=%{ca_certs_dir} \
208 %if 0%{?watchdog_enabled}
209 -DWATCHDOG_ENABLED=%{watchdog_enabled} \
210 -DWATCHDOG_TIMEOUT_SEC=%{watchdog_timeout_sec} \
211 -DWATCHDOG_NOTIFY_SEC=%{watchdog_notify_sec} \
213 %if %{tz_backend_enabled} == ON
214 -DTZ_BACKEND_ENABLED=ON \
216 -DTZ_BACKEND_ENABLED=OFF \
218 -DUNIT_TESTS_DIR=%{unit_tests_dir} \
219 -DMISC_DIR=%{misc_dir} \
220 -DCOVERAGE_DIR=%{coverage_dir} \
224 -DDUMP_LEGACY_DB_LIBNAME=%{dump_legacy_db_libname}
226 make %{?jobs:-j%jobs}
231 %if ! %{coverage_only}
233 %install_service multi-user.target.wants central-key-manager.service
234 %install_service sockets.target.wants central-key-manager-api-control.socket
235 %install_service sockets.target.wants central-key-manager-api-storage.socket
236 %install_service sockets.target.wants central-key-manager-api-ocsp.socket
237 %install_service sockets.target.wants central-key-manager-api-encryption.socket
238 cp -a %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{buildroot}%{_datadir}/
243 # tzplatform-get sync breaked because of on-development situation. comment out just for temporary
244 # fail if runtime dir variable is different than compilation time variable
245 #if [ `tzplatform-get TZ_SYS_DATA | cut -d'=' -f2` != %{TZ_SYS_DATA} ]
247 # echo "Runtime value of TZ_SYS_DATA is different than the compilation time value. Aborting"
250 #if [ `tzplatform-get TZ_SYS_RO_SHARE | cut -d'=' -f2` != %{TZ_SYS_RO_SHARE} ]
252 # echo "Runtime value of TZ_SYS_RO_SHARE is different than the compilation time value. Aborting"
256 ## backup plan for manage key-manager user/group is deprecated b/c pwdutils package
257 ## would be excluded from binary
258 # User/group (key-manager/key-manager) should be already added in passwd package.
259 # This is our backup plan if passwd package will not be configured correctly.
260 #id -g %{group_name} > /dev/null 2>&1
261 #if [ $? -eq 1 ]; then
262 # groupadd %{group_name} -r > /dev/null 2>&1
265 #id -u %{user_name} > /dev/null 2>&1
266 #if [ $? -eq 1 ]; then
267 # useradd -d /var/lib/empty -s /sbin/nologin -r -g %{group_name} %{user_name} > /dev/null 2>&1
271 # move data from old path to new one
272 # we have to assume that in case of TZ_SYS_DATA change some upgrade script will move all the data
273 if [ -d "%{old_rw_data_dir}" ] && [ "%{rw_data_dir}" != "%{old_rw_data_dir}" ]
275 echo "Migrating old rw data to new rw data dir"
276 cp -a %{old_rw_data_dir}/. %{rw_data_dir}/ && rm -rf %{old_rw_data_dir}
279 systemctl daemon-reload
282 systemctl start central-key-manager.service
288 # In ckm version <= 0.1.18 all files were owned by root.
289 find %{rw_data_dir} -exec chsmack -a %{smack_domain_name} {} \;
290 chown %{user_name}:%{group_name} -R %{rw_data_dir}
291 systemctl restart central-key-manager.service
298 systemctl stop central-key-manager.service
304 systemctl daemon-reload
307 %post -n libkey-manager-common -p /sbin/ldconfig
308 %post -n libkey-manager-client -p /sbin/ldconfig
309 %postun -n libkey-manager-common -p /sbin/ldconfig
310 %postun -n libkey-manager-client -p /sbin/ldconfig
312 %if ! %{coverage_only}
314 %files -n key-manager
315 %manifest key-manager.manifest
317 %license LICENSE.BSD-3-Clause
318 %{bin_dir}/key-manager
319 %{_libdir}/lib%{dump_legacy_db_libname}.so
320 %{_unitdir}/multi-user.target.wants/central-key-manager.service
321 %{_unitdir}/central-key-manager.service
322 %{_unitdir}/sockets.target.wants/central-key-manager-api-control.socket
323 %{_unitdir}/central-key-manager-api-control.socket
324 %{_unitdir}/sockets.target.wants/central-key-manager-api-storage.socket
325 %{_unitdir}/central-key-manager-api-storage.socket
326 %{_unitdir}/sockets.target.wants/central-key-manager-api-ocsp.socket
327 %{_unitdir}/central-key-manager-api-ocsp.socket
328 %{_unitdir}/sockets.target.wants/central-key-manager-api-encryption.socket
329 %{_unitdir}/central-key-manager-api-encryption.socket
332 %dir %attr(770, %{user_name}, %{group_name}) %{rw_data_dir}
333 %dir %attr(550, %{user_name}, %{group_name}) %{initial_values_dir_ro}
334 %dir %attr(770, %{user_name}, %{group_name}) %{initial_values_dir_rw}
335 %attr(755,root,root) /usr/share/upgrade/scripts/295.key-manager_upgrade.sh
337 %{ro_etc_dir}/gumd/userdel.d/10_key-manager.post
340 %files -n key-manager-pam-plugin
341 %manifest %{_datadir}/key-manager-pam-plugin.manifest
343 %{_libdir}/security/pam_key_manager_plugin.so*
345 %files -n libkey-manager-common
346 %manifest %{_datadir}/libkey-manager-common.manifest
348 %{_libdir}/libkey-manager-common.so.*
350 %files -n libkey-manager-client
351 %manifest %{_datadir}/libkey-manager-client.manifest
353 %{_libdir}/libkey-manager-client.so.*
354 %{_libdir}/libkey-manager-control-client.so.*
356 %files -n libkey-manager-client-devel
357 %manifest %{_datadir}/libkey-manager-client-devel.manifest
359 %{_libdir}/libkey-manager-client.so
360 %{_libdir}/libkey-manager-control-client.so
361 %{_libdir}/libkey-manager-common.so
362 %{_includedir}/ckm/ckm/ckm-manager.h
363 %{_includedir}/ckm/ckm/ckm-manager-async.h
364 %{_includedir}/ckm/ckm/ckm-certificate.h
365 %{_includedir}/ckm/ckm/ckm-control.h
366 %{_includedir}/ckm/ckm/ckm-error.h
367 %{_includedir}/ckm/ckm/ckm-key.h
368 %{_includedir}/ckm/ckm/ckm-password.h
369 %{_includedir}/ckm/ckm/ckm-pkcs12.h
370 %{_includedir}/ckm/ckm/ckm-raw-buffer.h
371 %{_includedir}/ckm/ckm/ckm-type.h
372 %{_includedir}/ckm/ckm/ckm-zero-memory.h
373 %{_includedir}/ckm/ckmc/ckmc-manager.h
374 %{_includedir}/ckm/ckmc/ckmc-control.h
375 %{_includedir}/ckm/ckmc/ckmc-error.h
376 %{_includedir}/ckm/ckmc/ckmc-type.h
377 %{_libdir}/pkgconfig/*.pc
379 %files -n key-manager-initial-values
381 %{bin_dir}/ckm_initial_values
383 %files -n key-manager-misc
384 %manifest key-manager-misc.manifest
386 %license LICENSE.BSL-1.0
387 %{bin_dir}/ckm-scheme-test
388 %{bin_dir}/ckm_so_loader
389 %{bin_dir}/ckm_db_tool
390 %{bin_dir}/ckm_db_merge
391 %{bin_dir}/ckm_generate_db
392 %{bin_dir}/ckm_db_perf
397 %files -n key-manager-unit-tests
398 %manifest key-manager-unit-tests.manifest
400 %license LICENSE.BSL-1.0
401 %{bin_dir}/ckm-unit-tests
404 %if "%{build_type}" == "COVERAGE"
406 %files -n key-manager-coverage
408 %{bin_dir}/key-manager-coverage.sh