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