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