Release 0.1.54.9
[platform/core/security/key-manager.git] / packaging / key-manager.spec
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
11 %endif
12
13 Name:       key-manager
14 Summary:    Central Key Manager and utilities
15 Version:    0.1.54.9
16 Release:    1
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
24 BuildRequires: cmake
25 BuildRequires: zip
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)
43 %endif
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)
50 %endif
51 %if %{se_backend_enabled} == ON
52 BuildRequires: pkgconfig(key-manager-se-backend)
53 %endif
54 Requires: libkey-manager-common = %{version}-%{release}
55 %if "%{build_type}" == "COVERAGE"
56 BuildRequires: lcov
57 %endif
58
59 %{?systemd_requires}
60
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
79
80 %description
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.
84
85 %package -n libkey-manager-common
86 Summary:    Central Key Manager (common libraries)
87 Group:      Security/Libraries
88 License:    Apache-2.0
89 Requires(post): /sbin/ldconfig
90 Requires(postun): /sbin/ldconfig
91
92 %description -n libkey-manager-common
93 Central Key Manager package (common library)
94
95 %package -n libkey-manager-client
96 Summary:    Central Key Manager (client)
97 Group:      Security/Libraries
98 License:    Apache-2.0
99 Requires:   key-manager = %{version}-%{release}
100 Requires:   libkey-manager-common = %{version}-%{release}
101 Requires(post): /sbin/ldconfig
102 Requires(postun): /sbin/ldconfig
103
104 %description -n libkey-manager-client
105 Central Key Manager package (client)
106
107 %package -n libkey-manager-client-devel
108 Summary:    Central Key Manager (client-devel)
109 Group:      Security/Development
110 License:    Apache-2.0
111 BuildRequires: pkgconfig(capi-base-common)
112 Requires:   pkgconfig(capi-base-common)
113 Requires:   libkey-manager-client = %{version}-%{release}
114
115 %description -n libkey-manager-client-devel
116 Central Key Manager package (client-devel)
117
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)
123 Requires:   boost-test
124
125 %description -n key-manager-unit-tests
126 Unit tests for key-manager.
127
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
132 Requires:   boost-test
133 Requires:   key-manager = %{version}-%{release}
134
135 %description -n key-manager-misc
136 Miscellaneous tools and tests for key-manager.
137
138 %package -n key-manager-pam-plugin
139 Summary:    CKM login/password module to PAM
140 Group:      Security/Libraries
141 License:    Apache-2.0
142 BuildRequires: pam-devel
143 Requires:   key-manager = %{version}-%{release}
144 Requires(post): /sbin/ldconfig
145 Requires(postun): /sbin/ldconfig
146
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
150
151 %package -n key-manager-initial-values
152 Summary:    CKM initial values tool
153 Group:      Security/Libraries
154 License:    Apache-2.0
155 BuildRequires: cmake
156 BuildRequires: pkgconfig(openssl1.1)
157 BuildRequires: pkgconfig(libxml-2.0)
158 Requires(post): /sbin/ldconfig
159 Requires(postun): /sbin/ldconfig
160
161 %description -n key-manager-initial-values
162 Includes ckm_initial_values tool for initial values XML generation
163
164 %if "%{build_type}" == "COVERAGE"
165
166 %package -n key-manager-coverage
167 Summary:    Central Key Manager code coverage data
168 Group:      Security/Testing
169 License:    Apache-2.0
170 Requires:   key-manager-unit-tests = %{version}-%{release}
171 Requires:   key-manager-debugsource = %{version}-%{release}
172 Requires:   lcov
173 Requires:   gcc
174
175 %description -n key-manager-coverage
176 Central Key Manager code coverage data
177
178 %endif
179
180 %prep
181 %setup -q
182
183 %build
184 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions"
185
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} \
210 %endif
211 %if %{tz_backend_enabled} == ON
212         -DTZ_BACKEND_ENABLED=ON \
213 %else
214         -DTZ_BACKEND_ENABLED=OFF \
215 %endif
216 %if %{se_backend_enabled} == ON
217         -DSE_BACKEND_ENABLED=ON \
218 %else
219         -DSE_BACKEND_ENABLED=OFF \
220 %endif
221         -DUNIT_TESTS_DIR=%{unit_tests_dir} \
222         -DMISC_DIR=%{misc_dir} \
223         -DCOVERAGE_DIR=%{coverage_dir} \
224 %if %{coverage_only}
225         -DCOVERAGE_ONLY=ON \
226 %endif
227         -DDUMP_LEGACY_DB_LIBNAME=%{dump_legacy_db_libname}
228
229 make %{?jobs:-j%jobs}
230
231 %install
232 %make_install
233
234 %if ! %{coverage_only}
235
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}/
242
243 %endif
244
245 %pre
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} ]
249 #then
250 #    echo "Runtime value of TZ_SYS_DATA is different than the compilation time value. Aborting"
251 #    exit 1
252 #fi
253 #if [ `tzplatform-get TZ_SYS_RO_SHARE | cut -d'=' -f2` != %{TZ_SYS_RO_SHARE} ]
254 #then
255 #    echo "Runtime value of TZ_SYS_RO_SHARE is different than the compilation time value. Aborting"
256 #    exit 1
257 #fi
258
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
266 #fi
267 #
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
271 #fi
272
273 %post
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}" ]
277 then
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}
280 fi
281
282 systemctl daemon-reload
283 if [ $1 = 1 ]; then
284     # installation
285     systemctl start central-key-manager.service
286 fi
287
288 if [ $1 = 2 ]; then
289     # update
290
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
295 fi
296
297
298 %preun
299 if [ $1 = 0 ]; then
300     # unistall
301     systemctl stop central-key-manager.service
302 fi
303
304 %postun
305 if [ $1 = 0 ]; then
306     # unistall
307     systemctl daemon-reload
308 fi
309
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
314
315 %if ! %{coverage_only}
316
317 %files -n key-manager
318 %manifest key-manager.manifest
319 %license LICENSE
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
333 %dir %{ro_data_dir}
334 %{ro_data_dir}/*
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
339
340 %{ro_etc_dir}/gumd/userdel.d/10_key-manager.post
341 %{bin_dir}/ckm_tool
342
343 %files -n key-manager-pam-plugin
344 %manifest %{_datadir}/key-manager-pam-plugin.manifest
345 %license LICENSE
346 %{_libdir}/security/pam_key_manager_plugin.so*
347
348 %files -n libkey-manager-common
349 %manifest %{_datadir}/libkey-manager-common.manifest
350 %license LICENSE
351 %{_libdir}/libkey-manager-common.so.*
352
353 %files -n libkey-manager-client
354 %manifest %{_datadir}/libkey-manager-client.manifest
355 %license LICENSE
356 %{_libdir}/libkey-manager-client.so.*
357 %{_libdir}/libkey-manager-control-client.so.*
358
359 %files -n libkey-manager-client-devel
360 %manifest %{_datadir}/libkey-manager-client-devel.manifest
361 %license LICENSE
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
381
382 %files -n key-manager-initial-values
383 %license LICENSE
384 %{bin_dir}/ckm_initial_values
385
386 %files -n key-manager-misc
387 %manifest key-manager-misc.manifest
388 %license LICENSE
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
397 %misc_dir
398
399 %endif
400
401 %files -n key-manager-unit-tests
402 %manifest key-manager-unit-tests.manifest
403 %license LICENSE
404 %license LICENSE.BSL-1.0
405 %{bin_dir}/ckm-unit-tests
406 %unit_tests_dir
407
408 %if "%{build_type}" == "COVERAGE"
409
410 %files -n key-manager-coverage
411 %license LICENSE
412 %{bin_dir}/key-manager-coverage.sh
413 %coverage_dir
414
415 %endif