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