add the se-backend for db encryption
[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
7 Name:       key-manager
8 Summary:    Central Key Manager and utilities
9 Version:    0.1.38.2
10 Release:    1
11 Group:      Security/Secure Storage
12 License:    Apache-2.0 and BSD-3-Clause
13 Source0:    %{name}-%{version}.tar.gz
14 Source1001: key-manager-pam-plugin.manifest
15 Source1002: libkey-manager-client.manifest
16 Source1003: libkey-manager-client-devel.manifest
17 Source1004: libkey-manager-common.manifest
18 BuildRequires: cmake
19 BuildRequires: zip
20 BuildRequires: pkgconfig(dlog)
21 BuildRequires: pkgconfig(openssl1.1)
22 BuildRequires: libattr-devel
23 BuildRequires: pkgconfig(libsmack)
24 BuildRequires: pkgconfig(libsystemd-daemon)
25 BuildRequires: pkgconfig(libsystemd-journal)
26 BuildRequires: pkgconfig(libxml-2.0)
27 BuildRequires: pkgconfig(capi-system-info)
28 BuildRequires: pkgconfig(security-manager)
29 BuildRequires: pkgconfig(cynara-client-async)
30 BuildRequires: pkgconfig(cynara-creds-socket)
31 BuildRequires: pkgconfig(libtzplatform-config)
32 BuildRequires: pkgconfig(glib-2.0)
33 BuildRequires: pkgconfig(pkgmgr)
34 BuildRequires: pkgconfig(vconf)
35 BuildRequires: pkgconfig(sqlcipher)
36 %if 0%{?watchdog_enabled}
37 BuildRequires: pkgconfig(argos_watchdog)
38 %endif
39 BuildRequires: boost-devel
40 BuildRequires: ca-certificates-devel
41 %if %{tz_backend_enabled} == ON
42 BuildRequires: key-manager-ta-devel
43 BuildRequires: key-manager-ta-serialization-devel
44 BuildRequires: pkgconfig(tef-libteec)
45 %endif
46 %if %{se_backend_enabled} == ON
47 BuildRequires: pkgconfig(key-manager-se-backend)
48 %endif
49 Requires: libkey-manager-common = %{version}-%{release}
50
51 %{?systemd_requires}
52
53 %global user_name key-manager
54 %global group_name security_fw
55 %global supplementary_group_names key-manager
56 %global service_name key-manager
57 %global smack_domain_name System
58 %global old_rw_data_dir /opt/data/ckm
59 %global rw_data_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm}%{!?TZ_SYS_DATA:%old_rw_data_dir}
60 %global ro_data_dir %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE/ckm}%{!?TZ_SYS_RO_SHARE:%_datadir/ckm}
61 %global test_dir %{?TZ_SYS_DATA:%TZ_SYS_DATA/ckm-tests-internal}%{!?TZ_SYS_DATA:%/opt/data/ckm-tests-internal}
62 %global bin_dir %{?TZ_SYS_BIN:%TZ_SYS_BIN}%{!?TZ_SYS_BIN:%_bindir}
63 # image creation error occured if /usr/sbin used for ldconfig
64 #%global sbin_dir %{?TZ_SYS_SBIN:%TZ_SYS_SBIN}%{!?TZ_SYS_SBIN:%_sbindir}
65 %global sbin_dir /sbin
66 %global ro_etc_dir %{?TZ_SYS_RO_ETC:%TZ_SYS_RO_ETC}%{!?TZ_SYS_RO_ETC:/etc}
67 %global run_dir %{?TZ_SYS_RUN:%TZ_SYS_RUN}%{!?TZ_SYS_RUN:/var/run}
68 %global initial_values_dir_ro %{ro_data_dir}/initial_values
69 %global initial_values_dir_rw %{rw_data_dir}/initial_values
70 %global ca_certs_dir %{?TZ_SYS_CA_CERTS:%TZ_SYS_CA_CERTS}%{!?TZ_SYS_CA_CERTS:%ro_etc_dir/ssl/certs}
71 %global dump_legacy_db_libname key-manager-dump-legacy-database
72
73 %description
74 Central Key Manager daemon could be used as secure storage
75 for certificate and private/public keys. It gives API for
76 application to sign and verify (DSA/RSA/ECDSA) signatures.
77
78 %package -n libkey-manager-common
79 Summary:    Central Key Manager (common libraries)
80 Group:      Security/Libraries
81 License:    Apache-2.0
82 Requires(post): %{sbin_dir}/ldconfig
83 Requires(postun): %{sbin_dir}/ldconfig
84
85 %description -n libkey-manager-common
86 Central Key Manager package (common library)
87
88 %package -n libkey-manager-client
89 Summary:    Central Key Manager (client)
90 Group:      Security/Libraries
91 License:    Apache-2.0
92 Requires:   key-manager = %{version}-%{release}
93 Requires:   libkey-manager-common = %{version}-%{release}
94 Requires(post): %{sbin_dir}/ldconfig
95 Requires(postun): %{sbin_dir}/ldconfig
96
97 %description -n libkey-manager-client
98 Central Key Manager package (client)
99
100 %package -n libkey-manager-client-devel
101 Summary:    Central Key Manager (client-devel)
102 Group:      Security/Development
103 License:    Apache-2.0
104 BuildRequires: pkgconfig(capi-base-common)
105 Requires:   pkgconfig(capi-base-common)
106 Requires:   libkey-manager-client = %{version}-%{release}
107
108 %description -n libkey-manager-client-devel
109 Central Key Manager package (client-devel)
110
111 %package -n key-manager-tests
112 Summary:    Internal test for key-manager
113 Group:      Security/Testing
114 License:    Apache-2.0 and BSL-1.0
115 BuildRequires: pkgconfig(libxml-2.0)
116 Requires:   boost-test
117 Requires:   key-manager = %{version}-%{release}
118
119 %description -n key-manager-tests
120 Internal test for key-manager implementation.
121
122 %package -n key-manager-pam-plugin
123 Summary:    CKM login/password module to PAM
124 Group:      Security/Libraries
125 License:    Apache-2.0
126 BuildRequires: pam-devel
127 Requires:   key-manager = %{version}-%{release}
128 Requires(post): %{sbin_dir}/ldconfig
129 Requires(postun): %{sbin_dir}/ldconfig
130
131 %description -n key-manager-pam-plugin
132 CKM login/password module to PAM. Used to monitor user login/logout
133 and password change events from PAM
134
135 %package -n key-manager-initial-values
136 Summary:    CKM initial values tool
137 Group:      Security/Libraries
138 License:    Apache-2.0
139 BuildRequires: cmake
140 BuildRequires: pkgconfig(openssl1.1)
141 BuildRequires: pkgconfig(libxml-2.0)
142 Requires(post): %{sbin_dir}/ldconfig
143 Requires(postun): %{sbin_dir}/ldconfig
144
145 %description -n key-manager-initial-values
146 Includes ckm_initial_values tool for initial values XML generation
147
148 %prep
149 %setup -q
150
151 %build
152 %if 0%{?sec_build_binary_debug_enable}
153     export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
154     export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
155 %endif
156
157 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions"
158
159 %cmake . -DVERSION=%{version} \
160         -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
161         -DCMAKE_VERBOSE_MAKEFILE=ON \
162         -DSYSTEMD_UNIT_DIR=%{_unitdir} \
163         -DSYSTEMD_ENV_FILE=%{ro_etc_dir}"/sysconfig/central-key-manager" \
164         -DRUN_DIR:PATH=%{run_dir} \
165         -DSERVICE_NAME=%{service_name} \
166         -DUSER_NAME=%{user_name} \
167         -DGROUP_NAME=%{group_name} \
168         -DSUPPLEMENTARY_GROUP_NAMES="%{supplementary_group_names}" \
169         -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
170         -DOLD_RW_DATA_DIR=%{old_rw_data_dir} \
171         -DRW_DATA_DIR=%{rw_data_dir} \
172         -DRO_DATA_DIR=%{ro_data_dir} \
173         -DRW_ETC_DIR=%{rw_etc_dir} \
174         -DRO_ETC_DIR=%{ro_etc_dir} \
175         -DBIN_DIR=%{bin_dir} \
176         -DINITIAL_VALUES_DIR_RW=%{initial_values_dir_rw} \
177         -DINITIAL_VALUES_DIR_RO=%{initial_values_dir_ro} \
178         -DCA_CERTS_DIR=%{ca_certs_dir} \
179 %if 0%{?watchdog_enabled}
180         -DWATCHDOG_ENABLED=%{watchdog_enabled} \
181         -DWATCHDOG_TIMEOUT_SEC=%{watchdog_timeout_sec} \
182         -DWATCHDOG_NOTIFY_SEC=%{watchdog_notify_sec} \
183 %endif
184 %if %{tz_backend_enabled} == ON
185         -DTZ_BACKEND_ENABLED=ON \
186 %else
187         -DTZ_BACKEND_ENABLED=OFF \
188 %endif
189 %if %{se_backend_enabled} == ON
190         -DSE_BACKEND_ENABLED=ON \
191 %else
192         -DSE_BACKEND_ENABLED=OFF \
193 %endif
194         -DTEST_DIR=%{test_dir} \
195         -DDUMP_LEGACY_DB_LIBNAME=%{dump_legacy_db_libname}
196
197 make %{?jobs:-j%jobs}
198
199 %install
200 %make_install
201 %install_service multi-user.target.wants central-key-manager.service
202 %install_service sockets.target.wants central-key-manager-api-control.socket
203 %install_service sockets.target.wants central-key-manager-api-storage.socket
204 %install_service sockets.target.wants central-key-manager-api-ocsp.socket
205 %install_service sockets.target.wants central-key-manager-api-encryption.socket
206 cp -a %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{buildroot}%{_datadir}/
207
208 %pre
209 # tzplatform-get sync breaked because of on-development situation. comment out just for temporary
210 # fail if runtime dir variable is different than compilation time variable
211 #if [ `tzplatform-get TZ_SYS_DATA | cut -d'=' -f2` != %{TZ_SYS_DATA} ]
212 #then
213 #    echo "Runtime value of TZ_SYS_DATA is different than the compilation time value. Aborting"
214 #    exit 1
215 #fi
216 #if [ `tzplatform-get TZ_SYS_RO_SHARE | cut -d'=' -f2` != %{TZ_SYS_RO_SHARE} ]
217 #then
218 #    echo "Runtime value of TZ_SYS_RO_SHARE is different than the compilation time value. Aborting"
219 #    exit 1
220 #fi
221
222 ## backup plan for manage key-manager user/group is deprecated b/c pwdutils package
223 ## would be excluded from binary
224 # User/group (key-manager/key-manager) should be already added in passwd package.
225 # This is our backup plan if passwd package will not be configured correctly.
226 #id -g %{group_name} > /dev/null 2>&1
227 #if [ $? -eq 1 ]; then
228 #    groupadd %{group_name} -r > /dev/null 2>&1
229 #fi
230 #
231 #id -u %{user_name} > /dev/null 2>&1
232 #if [ $? -eq 1 ]; then
233 #    useradd -d /var/lib/empty -s %{sbin_dir}/nologin -r -g %{group_name} %{user_name} > /dev/null 2>&1
234 #fi
235
236 %post
237 # move data from old path to new one
238 # we have to assume that in case of TZ_SYS_DATA change some upgrade script will move all the data
239 if [ -d "%{old_rw_data_dir}" ] && [ "%{rw_data_dir}" != "%{old_rw_data_dir}" ]
240 then
241     echo "Migrating old rw data to new rw data dir"
242     cp -a %{old_rw_data_dir}/. %{rw_data_dir}/ && rm -rf %{old_rw_data_dir}
243 fi
244
245 systemctl daemon-reload
246 if [ $1 = 1 ]; then
247     # installation
248     systemctl start central-key-manager.service
249 fi
250
251 if [ $1 = 2 ]; then
252     # update
253
254     # In ckm version <= 0.1.18 all files were owned by root.
255     find %{rw_data_dir} -exec chsmack -a %{smack_domain_name} {} \;
256     chown %{user_name}:%{group_name} -R %{rw_data_dir}
257     systemctl restart central-key-manager.service
258 fi
259
260
261 %preun
262 if [ $1 = 0 ]; then
263     # unistall
264     systemctl stop central-key-manager.service
265 fi
266
267 %postun
268 if [ $1 = 0 ]; then
269     # unistall
270     systemctl daemon-reload
271 fi
272
273 %post -n libkey-manager-common -p %{sbin_dir}/ldconfig
274 %post -n libkey-manager-client -p %{sbin_dir}/ldconfig
275 %postun -n libkey-manager-common -p %{sbin_dir}/ldconfig
276 %postun -n libkey-manager-client -p %{sbin_dir}/ldconfig
277
278 %files -n key-manager
279 %manifest key-manager.manifest
280 %license LICENSE
281 %license LICENSE.BSD-3-Clause
282 %{bin_dir}/key-manager
283 %{_libdir}/lib%{dump_legacy_db_libname}.so
284 %{_unitdir}/multi-user.target.wants/central-key-manager.service
285 %{_unitdir}/central-key-manager.service
286 %{_unitdir}/sockets.target.wants/central-key-manager-api-control.socket
287 %{_unitdir}/central-key-manager-api-control.socket
288 %{_unitdir}/sockets.target.wants/central-key-manager-api-storage.socket
289 %{_unitdir}/central-key-manager-api-storage.socket
290 %{_unitdir}/sockets.target.wants/central-key-manager-api-ocsp.socket
291 %{_unitdir}/central-key-manager-api-ocsp.socket
292 %{_unitdir}/sockets.target.wants/central-key-manager-api-encryption.socket
293 %{_unitdir}/central-key-manager-api-encryption.socket
294 %dir %{ro_data_dir}
295 %{ro_data_dir}/*
296 %dir %attr(770, %{user_name}, %{group_name}) %{rw_data_dir}
297 %dir %attr(550, %{user_name}, %{group_name}) %{initial_values_dir_ro}
298 %dir %attr(770, %{user_name}, %{group_name}) %{initial_values_dir_rw}
299 %attr(755,root,root) /usr/share/upgrade/scripts/295.key-manager_upgrade.sh
300
301 %{ro_etc_dir}/gumd/userdel.d/10_key-manager.post
302 %{bin_dir}/ckm_tool
303
304 %files -n key-manager-pam-plugin
305 %manifest %{_datadir}/key-manager-pam-plugin.manifest
306 %license LICENSE
307 %{_libdir}/security/pam_key_manager_plugin.so*
308
309 %files -n libkey-manager-common
310 %manifest %{_datadir}/libkey-manager-common.manifest
311 %license LICENSE
312 %{_libdir}/libkey-manager-common.so.*
313
314 %files -n libkey-manager-client
315 %manifest %{_datadir}/libkey-manager-client.manifest
316 %license LICENSE
317 %{_libdir}/libkey-manager-client.so.*
318 %{_libdir}/libkey-manager-control-client.so.*
319
320 %files -n libkey-manager-client-devel
321 %manifest %{_datadir}/libkey-manager-client-devel.manifest
322 %license LICENSE
323 %{_libdir}/libkey-manager-client.so
324 %{_libdir}/libkey-manager-control-client.so
325 %{_libdir}/libkey-manager-common.so
326 %{_includedir}/ckm/ckm/ckm-manager.h
327 %{_includedir}/ckm/ckm/ckm-manager-async.h
328 %{_includedir}/ckm/ckm/ckm-certificate.h
329 %{_includedir}/ckm/ckm/ckm-control.h
330 %{_includedir}/ckm/ckm/ckm-error.h
331 %{_includedir}/ckm/ckm/ckm-key.h
332 %{_includedir}/ckm/ckm/ckm-password.h
333 %{_includedir}/ckm/ckm/ckm-pkcs12.h
334 %{_includedir}/ckm/ckm/ckm-raw-buffer.h
335 %{_includedir}/ckm/ckm/ckm-type.h
336 %{_includedir}/ckm/ckm/ckm-zero-memory.h
337 %{_includedir}/ckm/ckmc/ckmc-manager.h
338 %{_includedir}/ckm/ckmc/ckmc-control.h
339 %{_includedir}/ckm/ckmc/ckmc-error.h
340 %{_includedir}/ckm/ckmc/ckmc-type.h
341 %{_libdir}/pkgconfig/*.pc
342
343 %files -n key-manager-tests
344 %manifest key-manager-tests.manifest
345 %license LICENSE
346 %license LICENSE.BSL-1.0
347 %{bin_dir}/ckm-tests-internal
348 %{bin_dir}/ckm_so_loader
349 %{bin_dir}/ckm_db_tool
350 %{bin_dir}/ckm_db_merge
351 %{bin_dir}/ckm_generate_db
352 %test_dir
353
354 %files -n key-manager-initial-values
355 %license LICENSE
356 %{bin_dir}/ckm_initial_values