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}
7 Summary: Central Key Manager and utilities
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
19 BuildRequires: pkgconfig(dlog)
20 BuildRequires: pkgconfig(openssl)
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)
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)
44 Requires: libkey-manager-common = %{version}-%{release}
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}
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.
72 %package -n libkey-manager-common
73 Summary: Central Key Manager (common libraries)
74 Group: Security/Libraries
76 Requires(post): %{sbin_dir}/ldconfig
77 Requires(postun): %{sbin_dir}/ldconfig
79 %description -n libkey-manager-common
80 Central Key Manager package (common library)
82 %package -n libkey-manager-client
83 Summary: Central Key Manager (client)
84 Group: Security/Libraries
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
91 %description -n libkey-manager-client
92 Central Key Manager package (client)
94 %package -n libkey-manager-client-devel
95 Summary: Central Key Manager (client-devel)
96 Group: Security/Development
98 BuildRequires: pkgconfig(capi-base-common)
99 Requires: pkgconfig(capi-base-common)
100 Requires: libkey-manager-client = %{version}-%{release}
102 %description -n libkey-manager-client-devel
103 Central Key Manager package (client-devel)
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)
111 Requires: key-manager = %{version}-%{release}
113 %description -n key-manager-tests
114 Internal test for key-manager implementation.
116 %package -n key-manager-pam-plugin
117 Summary: CKM login/password module to PAM
118 Group: Security/Libraries
120 BuildRequires: pam-devel
121 Requires: key-manager = %{version}-%{release}
122 Requires(post): %{sbin_dir}/ldconfig
123 Requires(postun): %{sbin_dir}/ldconfig
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
129 %package -n key-manager-initial-values
130 Summary: CKM initial values tool
131 Group: Security/Libraries
134 BuildRequires: pkgconfig(openssl)
135 BuildRequires: pkgconfig(libxml-2.0)
136 Requires(post): %{sbin_dir}/ldconfig
137 Requires(postun): %{sbin_dir}/ldconfig
139 %description -n key-manager-initial-values
140 Includes ckm_initial_values tool for initial values XML generation
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"
152 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions "
154 %cmake . -DVERSION=%{version} \
155 -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
156 -DCMAKE_VERBOSE_MAKEFILE=ON \
157 -DSYSTEMD_UNIT_DIR=%{_unitdir} \
158 -DSYSTEMD_ENV_FILE=%{ro_etc_dir}"/sysconfig/central-key-manager" \
159 -DRUN_DIR:PATH=%{run_dir} \
160 -DSERVICE_NAME=%{service_name} \
161 -DUSER_NAME=%{user_name} \
162 -DGROUP_NAME=%{group_name} \
163 -DSUPPLEMENTARY_GROUP_NAMES="%{supplementary_group_names}" \
164 -DSMACK_DOMAIN_NAME=%{smack_domain_name} \
165 -DOLD_RW_DATA_DIR=%{old_rw_data_dir} \
166 -DRW_DATA_DIR=%{rw_data_dir} \
167 -DRO_DATA_DIR=%{ro_data_dir} \
168 -DRW_ETC_DIR=%{rw_etc_dir} \
169 -DRO_ETC_DIR=%{ro_etc_dir} \
170 -DBIN_DIR=%{bin_dir} \
171 -DINITIAL_VALUES_DIR_RW=%{initial_values_dir_rw} \
172 -DINITIAL_VALUES_DIR_RO=%{initial_values_dir_ro} \
173 -DCA_CERTS_DIR=%{ca_certs_dir} \
174 %if 0%{?watchdog_enabled}
175 -DWATCHDOG_ENABLED=%{watchdog_enabled} \
176 -DWATCHDOG_TIMEOUT_SEC=%{watchdog_timeout_sec} \
177 -DWATCHDOG_NOTIFY_SEC=%{watchdog_notify_sec} \
179 %if %{tz_backend_enabled} == ON
180 -DTZ_BACKEND_ENABLED=ON \
182 -DTZ_BACKEND_ENABLED=OFF \
184 -DTEST_DIR=%{test_dir}
186 make %{?jobs:-j%jobs}
190 %install_service multi-user.target.wants central-key-manager.service
191 %install_service sockets.target.wants central-key-manager-api-control.socket
192 %install_service sockets.target.wants central-key-manager-api-storage.socket
193 %install_service sockets.target.wants central-key-manager-api-ocsp.socket
194 %install_service sockets.target.wants central-key-manager-api-encryption.socket
195 cp -a %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{buildroot}%{_datadir}/
198 # tzplatform-get sync breaked because of on-development situation. comment out just for temporary
199 # fail if runtime dir variable is different than compilation time variable
200 #if [ `tzplatform-get TZ_SYS_DATA | cut -d'=' -f2` != %{TZ_SYS_DATA} ]
202 # echo "Runtime value of TZ_SYS_DATA is different than the compilation time value. Aborting"
205 #if [ `tzplatform-get TZ_SYS_RO_SHARE | cut -d'=' -f2` != %{TZ_SYS_RO_SHARE} ]
207 # echo "Runtime value of TZ_SYS_RO_SHARE is different than the compilation time value. Aborting"
211 ## backup plan for manage key-manager user/group is deprecated b/c pwdutils package
212 ## would be excluded from binary
213 # User/group (key-manager/key-manager) should be already added in passwd package.
214 # This is our backup plan if passwd package will not be configured correctly.
215 #id -g %{group_name} > /dev/null 2>&1
216 #if [ $? -eq 1 ]; then
217 # groupadd %{group_name} -r > /dev/null 2>&1
220 #id -u %{user_name} > /dev/null 2>&1
221 #if [ $? -eq 1 ]; then
222 # useradd -d /var/lib/empty -s %{sbin_dir}/nologin -r -g %{group_name} %{user_name} > /dev/null 2>&1
226 # move data from old path to new one
227 # we have to assume that in case of TZ_SYS_DATA change some upgrade script will move all the data
228 if [ -d "%{old_rw_data_dir}" ] && [ "%{rw_data_dir}" != "%{old_rw_data_dir}" ]
230 echo "Migrating old rw data to new rw data dir"
231 cp -a %{old_rw_data_dir}/. %{rw_data_dir}/ && rm -rf %{old_rw_data_dir}
234 systemctl daemon-reload
237 systemctl start central-key-manager.service
243 # In ckm version <= 0.1.18 all files were owned by root.
244 find %{rw_data_dir} -exec chsmack -a %{smack_domain_name} {} \;
245 chown %{user_name}:%{group_name} -R %{rw_data_dir}
246 systemctl restart central-key-manager.service
253 systemctl stop central-key-manager.service
259 systemctl daemon-reload
262 %post -n libkey-manager-common -p %{sbin_dir}/ldconfig
263 %post -n libkey-manager-client -p %{sbin_dir}/ldconfig
264 %postun -n libkey-manager-common -p %{sbin_dir}/ldconfig
265 %postun -n libkey-manager-client -p %{sbin_dir}/ldconfig
267 %files -n key-manager
268 %manifest key-manager.manifest
270 %license LICENSE.BSD-3-Clause
271 %{bin_dir}/key-manager
272 %{_unitdir}/multi-user.target.wants/central-key-manager.service
273 %{_unitdir}/central-key-manager.service
274 %{_unitdir}/central-key-manager.target
275 %{_unitdir}/sockets.target.wants/central-key-manager-api-control.socket
276 %{_unitdir}/central-key-manager-api-control.socket
277 %{_unitdir}/sockets.target.wants/central-key-manager-api-storage.socket
278 %{_unitdir}/central-key-manager-api-storage.socket
279 %{_unitdir}/sockets.target.wants/central-key-manager-api-ocsp.socket
280 %{_unitdir}/central-key-manager-api-ocsp.socket
281 %{_unitdir}/sockets.target.wants/central-key-manager-api-encryption.socket
282 %{_unitdir}/central-key-manager-api-encryption.socket
285 %dir %attr(770, %{user_name}, %{group_name}) %{rw_data_dir}
286 %dir %attr(550, %{user_name}, %{group_name}) %{initial_values_dir_ro}
287 %dir %attr(770, %{user_name}, %{group_name}) %{initial_values_dir_rw}
289 %{ro_etc_dir}/gumd/userdel.d/10_key-manager.post
292 %files -n key-manager-pam-plugin
293 %manifest %{_datadir}/key-manager-pam-plugin.manifest
295 %{_libdir}/security/pam_key_manager_plugin.so*
297 %files -n libkey-manager-common
298 %manifest %{_datadir}/libkey-manager-common.manifest
300 %{_libdir}/libkey-manager-common.so.*
302 %files -n libkey-manager-client
303 %manifest %{_datadir}/libkey-manager-client.manifest
305 %{_libdir}/libkey-manager-client.so.*
306 %{_libdir}/libkey-manager-control-client.so.*
308 %files -n libkey-manager-client-devel
309 %manifest %{_datadir}/libkey-manager-client-devel.manifest
311 %{_libdir}/libkey-manager-client.so
312 %{_libdir}/libkey-manager-control-client.so
313 %{_libdir}/libkey-manager-common.so
314 %{_includedir}/ckm/ckm/ckm-manager.h
315 %{_includedir}/ckm/ckm/ckm-manager-async.h
316 %{_includedir}/ckm/ckm/ckm-certificate.h
317 %{_includedir}/ckm/ckm/ckm-control.h
318 %{_includedir}/ckm/ckm/ckm-error.h
319 %{_includedir}/ckm/ckm/ckm-key.h
320 %{_includedir}/ckm/ckm/ckm-password.h
321 %{_includedir}/ckm/ckm/ckm-pkcs12.h
322 %{_includedir}/ckm/ckm/ckm-raw-buffer.h
323 %{_includedir}/ckm/ckm/ckm-type.h
324 %{_includedir}/ckm/ckmc/ckmc-manager.h
325 %{_includedir}/ckm/ckmc/ckmc-control.h
326 %{_includedir}/ckm/ckmc/ckmc-error.h
327 %{_includedir}/ckm/ckmc/ckmc-type.h
328 %{_libdir}/pkgconfig/*.pc
330 %files -n key-manager-tests
331 %manifest key-manager-tests.manifest
333 %license LICENSE.BSL-1.0
334 %{bin_dir}/ckm-tests-internal
335 %{bin_dir}/ckm_so_loader
336 %{bin_dir}/ckm_db_tool
337 %{bin_dir}/ckm_db_merge
338 %{bin_dir}/ckm_generate_db
341 %files -n key-manager-initial-values
343 %{bin_dir}/ckm_initial_values