Release 0.1.65
[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.65
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(openssl3)
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 BuildRequires: pkgconfig(capi-system-resource)
59
60 %{?systemd_requires}
61
62 %global user_name key-manager
63 %global group_name security_fw
64 %global supplementary_group_names key-manager
65 %global service_name key-manager
66 %global smack_domain_name System
67 %global old_rw_data_dir /opt/data/ckm
68 %global rw_data_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm}%{!?TZ_SYS_DATA:%old_rw_data_dir}
69 %global ro_data_dir %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE/ckm}%{!?TZ_SYS_RO_SHARE:%_datadir/ckm}
70 %global unit_tests_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-unit-tests}%{!?TZ_SYS_DATA:%/opt/data/ckm-unit-tests}
71 %global misc_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-misc}%{!?TZ_SYS_DATA:%/opt/data/ckm-misc}
72 %global coverage_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-coverage}%{!?TZ_SYS_DATA:%/opt/data/ckm-coverage}
73 %global bin_dir %{?TZ_SYS_BIN:%TZ_SYS_BIN}%{!?TZ_SYS_BIN:%_bindir}
74 %global ro_etc_dir %{?TZ_SYS_RO_ETC:%TZ_SYS_RO_ETC}%{!?TZ_SYS_RO_ETC:/etc}
75 %global run_dir %{?TZ_SYS_RUN:%TZ_SYS_RUN}%{!?TZ_SYS_RUN:/var/run}
76 %global initial_values_dir_ro %{ro_data_dir}/initial_values
77 %global initial_values_dir_rw %{rw_data_dir}/initial_values
78 %global ca_certs_dir %{?TZ_SYS_CA_CERTS:%TZ_SYS_CA_CERTS}%{!?TZ_SYS_CA_CERTS:%ro_etc_dir/ssl/certs}
79 %global dump_legacy_db_libname key-manager-dump-legacy-database
80
81 %description
82 Central Key Manager daemon could be used as secure storage
83 for certificate and private/public keys. It gives API for
84 application to sign and verify (DSA/RSA/ECDSA) signatures.
85
86 %package -n libkey-manager-common
87 Summary:    Central Key Manager (common libraries)
88 Group:      Security/Libraries
89 License:    Apache-2.0
90 Requires(post): /sbin/ldconfig
91 Requires(postun): /sbin/ldconfig
92
93 %description -n libkey-manager-common
94 Central Key Manager package (common library)
95
96 %package -n libkey-manager-client
97 Summary:    Central Key Manager (client)
98 Group:      Security/Libraries
99 License:    Apache-2.0
100 Requires:   key-manager = %{version}-%{release}
101 Requires:   libkey-manager-common = %{version}-%{release}
102 Requires(post): /sbin/ldconfig
103 Requires(postun): /sbin/ldconfig
104
105 %description -n libkey-manager-client
106 Central Key Manager package (client)
107
108 %package -n libkey-manager-client-devel
109 Summary:    Central Key Manager (client-devel)
110 Group:      Security/Development
111 License:    Apache-2.0
112 BuildRequires: pkgconfig(capi-base-common)
113 Requires:   pkgconfig(capi-base-common)
114 Requires:   libkey-manager-client = %{version}-%{release}
115
116 %description -n libkey-manager-client-devel
117 Central Key Manager package (client-devel)
118
119 %package -n key-manager-unit-tests
120 Summary:    Unit tests for key-manager
121 Group:      Security/Testing
122 License:    Apache-2.0 and BSL-1.0
123 BuildRequires: pkgconfig(libxml-2.0)
124 Requires:   boost-test
125
126 %description -n key-manager-unit-tests
127 Unit tests for key-manager.
128
129 %package -n key-manager-misc
130 Summary:    Miscellaneous tools and tests for key-manager
131 Group:      Security/Testing
132 License:    Apache-2.0 and BSL-1.0
133 Requires:   boost-test
134 Requires:   key-manager = %{version}-%{release}
135
136 %description -n key-manager-misc
137 Miscellaneous tools and tests for key-manager.
138
139 %package -n key-manager-pam-plugin
140 Summary:    CKM login/password module to PAM
141 Group:      Security/Libraries
142 License:    Apache-2.0
143 BuildRequires: pam-devel
144 Requires:   key-manager = %{version}-%{release}
145 Requires(post): /sbin/ldconfig
146 Requires(postun): /sbin/ldconfig
147
148 %description -n key-manager-pam-plugin
149 CKM login/password module to PAM. Used to monitor user login/logout
150 and password change events from PAM
151
152 %package -n key-manager-initial-values
153 Summary:    CKM initial values tool
154 Group:      Security/Libraries
155 License:    Apache-2.0
156 BuildRequires: cmake
157 BuildRequires: pkgconfig(openssl3)
158 BuildRequires: pkgconfig(libxml-2.0)
159 Requires(post): /sbin/ldconfig
160 Requires(postun): /sbin/ldconfig
161
162 %description -n key-manager-initial-values
163 Includes ckm_initial_values tool for initial values XML generation
164
165 %if "%{build_type}" == "COVERAGE"
166
167 %package -n key-manager-coverage
168 Summary:    Central Key Manager code coverage data
169 Group:      Security/Testing
170 License:    Apache-2.0
171 Requires:   key-manager-unit-tests = %{version}-%{release}
172 Requires:   key-manager-debugsource = %{version}-%{release}
173 Requires:   lcov
174 Requires:   gcc
175
176 %description -n key-manager-coverage
177 Central Key Manager code coverage data
178
179 %endif
180
181 %prep
182 %setup -q
183
184 %build
185 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions"
186
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} \
211 %endif
212 %if %{tz_backend_enabled} == ON
213         -DTZ_BACKEND_ENABLED=ON \
214 %else
215         -DTZ_BACKEND_ENABLED=OFF \
216 %endif
217 %if %{se_backend_enabled} == ON
218         -DSE_BACKEND_ENABLED=ON \
219 %else
220         -DSE_BACKEND_ENABLED=OFF \
221 %endif
222         -DUNIT_TESTS_DIR=%{unit_tests_dir} \
223         -DMISC_DIR=%{misc_dir} \
224         -DCOVERAGE_DIR=%{coverage_dir} \
225 %if %{coverage_only}
226         -DCOVERAGE_ONLY=ON \
227 %endif
228         -DDUMP_LEGACY_DB_LIBNAME=%{dump_legacy_db_libname}
229
230 make %{?jobs:-j%jobs}
231
232 %install
233 %make_install
234
235 %if ! %{coverage_only}
236
237 %install_service multi-user.target.wants central-key-manager.service
238 %install_service sockets.target.wants central-key-manager-api-control.socket
239 %install_service sockets.target.wants central-key-manager-api-storage.socket
240 %install_service sockets.target.wants central-key-manager-api-ocsp.socket
241 %install_service sockets.target.wants central-key-manager-api-encryption.socket
242 cp -a %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{buildroot}%{_datadir}/
243
244 %endif
245
246 %pre
247 # tzplatform-get sync breaked because of on-development situation. comment out just for temporary
248 # fail if runtime dir variable is different than compilation time variable
249 #if [ `tzplatform-get TZ_SYS_DATA | cut -d'=' -f2` != %{TZ_SYS_DATA} ]
250 #then
251 #    echo "Runtime value of TZ_SYS_DATA is different than the compilation time value. Aborting"
252 #    exit 1
253 #fi
254 #if [ `tzplatform-get TZ_SYS_RO_SHARE | cut -d'=' -f2` != %{TZ_SYS_RO_SHARE} ]
255 #then
256 #    echo "Runtime value of TZ_SYS_RO_SHARE is different than the compilation time value. Aborting"
257 #    exit 1
258 #fi
259
260 ## backup plan for manage key-manager user/group is deprecated b/c pwdutils package
261 ## would be excluded from binary
262 # User/group (key-manager/key-manager) should be already added in passwd package.
263 # This is our backup plan if passwd package will not be configured correctly.
264 #id -g %{group_name} > /dev/null 2>&1
265 #if [ $? -eq 1 ]; then
266 #    groupadd %{group_name} -r > /dev/null 2>&1
267 #fi
268 #
269 #id -u %{user_name} > /dev/null 2>&1
270 #if [ $? -eq 1 ]; then
271 #    useradd -d /var/lib/empty -s /sbin/nologin -r -g %{group_name} %{user_name} > /dev/null 2>&1
272 #fi
273
274 %post
275 # move data from old path to new one
276 # we have to assume that in case of TZ_SYS_DATA change some upgrade script will move all the data
277 if [ -d "%{old_rw_data_dir}" ] && [ "%{rw_data_dir}" != "%{old_rw_data_dir}" ]
278 then
279     echo "Migrating old rw data to new rw data dir"
280     cp -a %{old_rw_data_dir}/. %{rw_data_dir}/ && rm -rf %{old_rw_data_dir}
281 fi
282
283 systemctl daemon-reload
284 if [ $1 = 1 ]; then
285     # installation
286     systemctl start central-key-manager.service
287 fi
288
289 if [ $1 = 2 ]; then
290     # update
291
292     # In ckm version <= 0.1.18 all files were owned by root.
293     find %{rw_data_dir} -exec chsmack -a %{smack_domain_name} {} \;
294     chown %{user_name}:%{group_name} -R %{rw_data_dir}
295     systemctl restart central-key-manager.service
296 fi
297
298
299 %preun
300 if [ $1 = 0 ]; then
301     # unistall
302     systemctl stop central-key-manager.service
303 fi
304
305 %postun
306 if [ $1 = 0 ]; then
307     # unistall
308     systemctl daemon-reload
309 fi
310
311 %post -n libkey-manager-common -p /sbin/ldconfig
312 %post -n libkey-manager-client -p /sbin/ldconfig
313 %postun -n libkey-manager-common -p /sbin/ldconfig
314 %postun -n libkey-manager-client -p /sbin/ldconfig
315
316 %if ! %{coverage_only}
317
318 %files -n key-manager
319 %manifest key-manager.manifest
320 %license LICENSE
321 %license LICENSE.BSD-3-Clause
322 %{bin_dir}/key-manager
323 %{_libdir}/lib%{dump_legacy_db_libname}.so
324 %{_unitdir}/multi-user.target.wants/central-key-manager.service
325 %{_unitdir}/central-key-manager.service
326 %{_unitdir}/sockets.target.wants/central-key-manager-api-control.socket
327 %{_unitdir}/central-key-manager-api-control.socket
328 %{_unitdir}/sockets.target.wants/central-key-manager-api-storage.socket
329 %{_unitdir}/central-key-manager-api-storage.socket
330 %{_unitdir}/sockets.target.wants/central-key-manager-api-ocsp.socket
331 %{_unitdir}/central-key-manager-api-ocsp.socket
332 %{_unitdir}/sockets.target.wants/central-key-manager-api-encryption.socket
333 %{_unitdir}/central-key-manager-api-encryption.socket
334 %dir %{ro_data_dir}
335 %{ro_data_dir}/*
336 %dir %attr(770, %{user_name}, %{group_name}) %{rw_data_dir}
337 %dir %attr(550, %{user_name}, %{group_name}) %{initial_values_dir_ro}
338 %dir %attr(770, %{user_name}, %{group_name}) %{initial_values_dir_rw}
339 %attr(755,root,root) /usr/share/upgrade/scripts/295.key-manager_upgrade.sh
340
341 %{ro_etc_dir}/gumd/userdel.d/10_key-manager.post
342 %{bin_dir}/ckm_tool
343
344 %files -n key-manager-pam-plugin
345 %manifest %{_datadir}/key-manager-pam-plugin.manifest
346 %license LICENSE
347 %{_libdir}/security/pam_key_manager_plugin.so*
348
349 %files -n libkey-manager-common
350 %manifest %{_datadir}/libkey-manager-common.manifest
351 %license LICENSE
352 %{_libdir}/libkey-manager-common.so.*
353
354 %files -n libkey-manager-client
355 %manifest %{_datadir}/libkey-manager-client.manifest
356 %license LICENSE
357 %{_libdir}/libkey-manager-client.so.*
358 %{_libdir}/libkey-manager-control-client.so.*
359
360 %files -n libkey-manager-client-devel
361 %manifest %{_datadir}/libkey-manager-client-devel.manifest
362 %license LICENSE
363 %{_libdir}/libkey-manager-client.so
364 %{_libdir}/libkey-manager-control-client.so
365 %{_libdir}/libkey-manager-common.so
366 %{_includedir}/ckm/ckm/ckm-manager.h
367 %{_includedir}/ckm/ckm/ckm-manager-async.h
368 %{_includedir}/ckm/ckm/ckm-certificate.h
369 %{_includedir}/ckm/ckm/ckm-control.h
370 %{_includedir}/ckm/ckm/ckm-error.h
371 %{_includedir}/ckm/ckm/ckm-key.h
372 %{_includedir}/ckm/ckm/ckm-password.h
373 %{_includedir}/ckm/ckm/ckm-pkcs12.h
374 %{_includedir}/ckm/ckm/ckm-raw-buffer.h
375 %{_includedir}/ckm/ckm/ckm-type.h
376 %{_includedir}/ckm/ckm/ckm-zero-memory.h
377 %{_includedir}/ckm/ckmc/ckmc-manager.h
378 %{_includedir}/ckm/ckmc/ckmc-control.h
379 %{_includedir}/ckm/ckmc/ckmc-error.h
380 %{_includedir}/ckm/ckmc/ckmc-type.h
381 %{_libdir}/pkgconfig/*.pc
382
383 %files -n key-manager-initial-values
384 %license LICENSE
385 %{bin_dir}/ckm_initial_values
386
387 %files -n key-manager-misc
388 %manifest key-manager-misc.manifest
389 %license LICENSE
390 %license LICENSE.BSL-1.0
391 %{bin_dir}/ckm-scheme-test
392 %{bin_dir}/ckm_so_loader
393 %{bin_dir}/ckm_db_tool
394 %{bin_dir}/ckm_db_merge
395 %{bin_dir}/ckm_generate_db
396 %{bin_dir}/ckm_db_perf
397 %{bin_dir}/ckm_enc_perf
398 %misc_dir
399
400 %endif
401
402 %files -n key-manager-unit-tests
403 %manifest key-manager-unit-tests.manifest
404 %license LICENSE
405 %license LICENSE.BSL-1.0
406 %{bin_dir}/ckm-unit-tests
407 %unit_tests_dir
408
409 %if "%{build_type}" == "COVERAGE"
410
411 %files -n key-manager-coverage
412 %license LICENSE
413 %{bin_dir}/key-manager-coverage.sh
414 %coverage_dir
415
416 %endif