1 |
commit: 4c6618086e16e704df31113b279e7ea4395bd41a |
2 |
Author: Patrick McLean <chutzpah <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 30 23:52:50 2016 +0000 |
4 |
Commit: Patrick McLean <chutzpah <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 30 23:52:50 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4c661808 |
7 |
|
8 |
sys-cluster/ceph: Revision bump to 9.2.1-r2 and 10.2.2-r1 for CVE-2016-5009 (bug #587568) |
9 |
|
10 |
Package-Manager: portage-2.3.0 |
11 |
|
12 |
sys-cluster/ceph/ceph-10.2.2-r1.ebuild | 263 ++++++++++++++++++++++++ |
13 |
sys-cluster/ceph/ceph-9.2.1-r2.ebuild | 193 +++++++++++++++++ |
14 |
sys-cluster/ceph/files/ceph-CVE-2016-5009.patch | 87 ++++++++ |
15 |
3 files changed, 543 insertions(+) |
16 |
|
17 |
diff --git a/sys-cluster/ceph/ceph-10.2.2-r1.ebuild b/sys-cluster/ceph/ceph-10.2.2-r1.ebuild |
18 |
new file mode 100644 |
19 |
index 0000000..276f496 |
20 |
--- /dev/null |
21 |
+++ b/sys-cluster/ceph/ceph-10.2.2-r1.ebuild |
22 |
@@ -0,0 +1,263 @@ |
23 |
+# Copyright 1999-2016 Gentoo Foundation |
24 |
+# Distributed under the terms of the GNU General Public License v2 |
25 |
+# $Id$ |
26 |
+ |
27 |
+EAPI=6 |
28 |
+PYTHON_COMPAT=( python{2_7,3_{4,5}} ) |
29 |
+ |
30 |
+inherit check-reqs autotools eutils python-r1 udev user \ |
31 |
+ readme.gentoo-r1 systemd versionator flag-o-matic |
32 |
+ |
33 |
+if [[ ${PV} == *9999* ]]; then |
34 |
+ inherit git-r3 |
35 |
+ EGIT_REPO_URI=" |
36 |
+ git://github.com/ceph/ceph.git |
37 |
+ https://github.com/ceph/ceph.git" |
38 |
+ SRC_URI="" |
39 |
+else |
40 |
+ SRC_URI="http://ceph.com/download/${P}.tar.gz" |
41 |
+ KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86" |
42 |
+fi |
43 |
+ |
44 |
+DESCRIPTION="Ceph distributed filesystem" |
45 |
+HOMEPAGE="http://ceph.com/" |
46 |
+ |
47 |
+LICENSE="LGPL-2.1" |
48 |
+SLOT="0" |
49 |
+ |
50 |
+IUSE="babeltrace cephfs cryptopp debug fuse gtk jemalloc ldap +libaio" |
51 |
+IUSE+=" libatomic lttng +nss +radosgw static-libs tcmalloc test xfs zfs" |
52 |
+ |
53 |
+# unbundling code commented out pending bugs 584056 and 584058 |
54 |
+#>=dev-libs/jerasure-2.0.0-r1 |
55 |
+#>=dev-libs/gf-complete-2.0.0 |
56 |
+COMMON_DEPEND=" |
57 |
+ app-arch/snappy |
58 |
+ app-arch/lz4:= |
59 |
+ app-arch/bzip2 |
60 |
+ dev-libs/boost:=[threads] |
61 |
+ dev-libs/libaio |
62 |
+ dev-libs/leveldb[snappy] |
63 |
+ nss? ( dev-libs/nss ) |
64 |
+ libatomic? ( dev-libs/libatomic_ops ) |
65 |
+ cryptopp? ( dev-libs/crypto++ ) |
66 |
+ sys-apps/keyutils |
67 |
+ sys-apps/util-linux |
68 |
+ dev-libs/libxml2 |
69 |
+ radosgw? ( dev-libs/fcgi ) |
70 |
+ ldap? ( net-nds/openldap ) |
71 |
+ babeltrace? ( dev-util/babeltrace ) |
72 |
+ fuse? ( sys-fs/fuse ) |
73 |
+ xfs? ( sys-fs/xfsprogs ) |
74 |
+ zfs? ( sys-fs/zfs ) |
75 |
+ gtk? ( |
76 |
+ x11-libs/gtk+:2 |
77 |
+ dev-cpp/gtkmm:2.4 |
78 |
+ gnome-base/librsvg |
79 |
+ ) |
80 |
+ radosgw? ( |
81 |
+ dev-libs/fcgi |
82 |
+ dev-libs/expat |
83 |
+ net-misc/curl |
84 |
+ ) |
85 |
+ jemalloc? ( dev-libs/jemalloc ) |
86 |
+ !jemalloc? ( dev-util/google-perftools ) |
87 |
+ lttng? ( dev-util/lttng-ust ) |
88 |
+ ${PYTHON_DEPS} |
89 |
+ " |
90 |
+DEPEND="${COMMON_DEPEND} |
91 |
+ dev-python/cython[${PYTHON_USEDEP}] |
92 |
+ app-arch/cpio |
93 |
+ sys-apps/lsb-release |
94 |
+ virtual/pkgconfig |
95 |
+ dev-python/sphinx |
96 |
+ test? ( |
97 |
+ sys-fs/btrfs-progs |
98 |
+ sys-apps/grep[pcre] |
99 |
+ dev-python/tox[${PYTHON_USEDEP}] |
100 |
+ dev-python/virtualenv[${PYTHON_USEDEP}] |
101 |
+ )" |
102 |
+RDEPEND="${COMMON_DEPEND} |
103 |
+ sys-apps/hdparm |
104 |
+ sys-block/parted |
105 |
+ sys-fs/cryptsetup |
106 |
+ sys-apps/gptfdisk |
107 |
+ dev-python/flask[${PYTHON_USEDEP}] |
108 |
+ dev-python/requests[${PYTHON_USEDEP}] |
109 |
+ " |
110 |
+REQUIRED_USE=" |
111 |
+ $(python_gen_useflags 'python2*') |
112 |
+ ${PYTHON_REQUIRED_USE} |
113 |
+ ^^ ( nss cryptopp ) |
114 |
+ ?? ( jemalloc tcmalloc ) |
115 |
+ " |
116 |
+ |
117 |
+# work around bug in ceph compilation (rgw/ceph_dencoder-rgw_dencoder.o... undefined reference to `vtable for RGWZoneGroup') |
118 |
+REQUIRED_USE+=" radosgw" |
119 |
+ |
120 |
+RESTRICT="test? ( userpriv )" |
121 |
+ |
122 |
+# distribution tarball does not include everything needed for tests |
123 |
+RESTRICT+=" test" |
124 |
+ |
125 |
+STRIP_MASK="/usr/lib*/rados-classes/*" |
126 |
+ |
127 |
+UNBUNDLE_LIBS=( |
128 |
+ src/erasure-code/jerasure/jerasure |
129 |
+ src/erasure-code/jerasure/gf-complete |
130 |
+) |
131 |
+ |
132 |
+PATCHES=( |
133 |
+ "${FILESDIR}/ceph-10.2.0-dont-use-virtualenvs.patch" |
134 |
+ #"${FILESDIR}/ceph-10.2.1-unbundle-jerasure.patch" |
135 |
+ "${FILESDIR}/${PN}-10.2.1-libzfs.patch" |
136 |
+ "${FILESDIR}/${PN}-10.2.1-armv7l-doesnt-support-momit-leaf-frame-pointer.patch" |
137 |
+ "${FILESDIR}/${PN}-CVE-2016-5009.patch" |
138 |
+) |
139 |
+ |
140 |
+check-reqs_export_vars() { |
141 |
+ if use debug; then |
142 |
+ CHECKREQS_DISK_BUILD="23G" |
143 |
+ CHECKREQS_DISK_USR="7G" |
144 |
+ elif use amd64; then |
145 |
+ CHECKREQS_DISK_BUILD="12G" |
146 |
+ CHECKREQS_DISK_USR="450M" |
147 |
+ else |
148 |
+ CHECKREQS_DISK_BUILD="1400M" |
149 |
+ CHECKREQS_DISK_USR="450M" |
150 |
+ fi |
151 |
+ |
152 |
+ export CHECKREQS_DISK_BUILD CHECKREQS_DISK_USR |
153 |
+} |
154 |
+ |
155 |
+user_setup() { |
156 |
+ enewgroup ceph |
157 |
+ enewuser ceph -1 -1 /var/lib/ceph ceph |
158 |
+} |
159 |
+ |
160 |
+emake_python_bindings() { |
161 |
+ local action="${1}" params binding |
162 |
+ shift |
163 |
+ params=("${@}") |
164 |
+ |
165 |
+ __emake_python_bindings_do_impl() { |
166 |
+ emake "${params[@]}" PYTHON="${EPYTHON}" "${binding}-pybind-${action}" |
167 |
+ |
168 |
+ # these don't work and aren't needed on python3 |
169 |
+ if [[ ${EBUILD_PHASE} == install ]] && python_is_python3; then |
170 |
+ rm -f "${ED}/$(python_get_sitedir)"/ceph_{argparse,volume_client}.py |
171 |
+ fi |
172 |
+ } |
173 |
+ |
174 |
+ pushd "${S}/src" |
175 |
+ for binding in rados rbd $(use cephfs && echo cephfs); do |
176 |
+ python_foreach_impl __emake_python_bindings_do_impl |
177 |
+ done |
178 |
+ popd |
179 |
+ |
180 |
+ unset __emake_python_bindings_do_impl |
181 |
+} |
182 |
+ |
183 |
+pkg_pretend() { |
184 |
+ check-reqs_export_vars |
185 |
+ check-reqs_pkg_pretend |
186 |
+} |
187 |
+ |
188 |
+pkg_setup() { |
189 |
+ python_setup |
190 |
+ check-reqs_export_vars |
191 |
+ check-reqs_pkg_setup |
192 |
+ user_setup |
193 |
+} |
194 |
+ |
195 |
+src_prepare() { |
196 |
+ default |
197 |
+ |
198 |
+ # remove tests that need root access |
199 |
+ rm src/test/cli/ceph-authtool/cap*.t |
200 |
+ |
201 |
+ #rm -rf "${UNBUNDLE_LIBS[@]}" |
202 |
+ |
203 |
+ append-flags -fPIC |
204 |
+ eautoreconf |
205 |
+} |
206 |
+ |
207 |
+src_configure() { |
208 |
+ local myeconfargs=( |
209 |
+ --without-hadoop |
210 |
+ --includedir=/usr/include |
211 |
+ $(use_with cephfs) |
212 |
+ $(use_with debug) |
213 |
+ $(use_with fuse) |
214 |
+ $(use_with libaio) |
215 |
+ $(use_with libatomic libatomic-ops) |
216 |
+ $(use_with nss) |
217 |
+ $(use_with cryptopp) |
218 |
+ $(use_with radosgw) |
219 |
+ $(use_with gtk gtk2) |
220 |
+ $(use_enable static-libs static) |
221 |
+ $(use_with jemalloc) |
222 |
+ $(use_with xfs libxfs) |
223 |
+ $(use_with zfs libzfs) |
224 |
+ $(use_with lttng ) |
225 |
+ $(use_with babeltrace) |
226 |
+ $(use_with ldap openldap) |
227 |
+ $(use jemalloc || usex tcmalloc " --with-tcmalloc" " --with-tcmalloc-minimal") |
228 |
+ --with-mon |
229 |
+ --with-eventfd |
230 |
+ --with-cython |
231 |
+ --without-kinetic |
232 |
+ --without-librocksdb |
233 |
+ --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" |
234 |
+ ) |
235 |
+ |
236 |
+ # we can only use python2.7 for building at the moment |
237 |
+ python_export python2.7 PYTHON EPYTHON |
238 |
+ econf "${myeconfargs[@]}" |
239 |
+} |
240 |
+ |
241 |
+src_compile() { |
242 |
+ emake |
243 |
+ emake_python_bindings all |
244 |
+ |
245 |
+ use test && emake check-local |
246 |
+} |
247 |
+ |
248 |
+src_test() { |
249 |
+ make check || die "make check failed" |
250 |
+} |
251 |
+ |
252 |
+src_install() { |
253 |
+ default |
254 |
+ emake_python_bindings install-exec "DESTDIR=\"${D}\"" |
255 |
+ |
256 |
+ prune_libtool_files --all |
257 |
+ |
258 |
+ exeinto /usr/$(get_libdir)/ceph |
259 |
+ newexe src/init-ceph ceph_init.sh |
260 |
+ |
261 |
+ insinto /etc/logrotate.d/ |
262 |
+ newins "${FILESDIR}"/ceph.logrotate ${PN} |
263 |
+ |
264 |
+ keepdir /var/lib/${PN}{,/tmp} /var/log/${PN}/stat |
265 |
+ |
266 |
+ fowners ceph:ceph /var/lib/ceph |
267 |
+ |
268 |
+ newinitd "${FILESDIR}/rbdmap.initd" rbdmap |
269 |
+ newinitd "${FILESDIR}/${PN}.initd-r2" ${PN} |
270 |
+ newconfd "${FILESDIR}/${PN}.confd-r1" ${PN} |
271 |
+ |
272 |
+ systemd_install_serviced "${FILESDIR}/ceph-mds_at.service.conf" "ceph-mds@.service" |
273 |
+ systemd_install_serviced "${FILESDIR}/ceph-osd_at.service.conf" "ceph-osd@.service" |
274 |
+ systemd_install_serviced "${FILESDIR}/ceph-mon_at.service.conf" "ceph-mon@.service" |
275 |
+ |
276 |
+ python_fix_shebang "${ED}"/usr/{,s}bin/ |
277 |
+ |
278 |
+ udev_dorules udev/*.rules |
279 |
+ |
280 |
+ readme.gentoo_create_doc |
281 |
+} |
282 |
+ |
283 |
+pkg_postinst() { |
284 |
+ readme.gentoo_print_elog |
285 |
+} |
286 |
|
287 |
diff --git a/sys-cluster/ceph/ceph-9.2.1-r2.ebuild b/sys-cluster/ceph/ceph-9.2.1-r2.ebuild |
288 |
new file mode 100644 |
289 |
index 0000000..494094e |
290 |
--- /dev/null |
291 |
+++ b/sys-cluster/ceph/ceph-9.2.1-r2.ebuild |
292 |
@@ -0,0 +1,193 @@ |
293 |
+# Copyright 1999-2016 Gentoo Foundation |
294 |
+# Distributed under the terms of the GNU General Public License v2 |
295 |
+# $Id$ |
296 |
+ |
297 |
+EAPI=5 |
298 |
+PYTHON_COMPAT=( python2_7 ) |
299 |
+ |
300 |
+if [[ $PV = *9999* ]]; then |
301 |
+ scm_eclass=git-r3 |
302 |
+ EGIT_REPO_URI=" |
303 |
+ git://github.com/ceph/ceph.git |
304 |
+ https://github.com/ceph/ceph.git" |
305 |
+ SRC_URI="" |
306 |
+else |
307 |
+ SRC_URI="http://ceph.com/download/${P}.tar.gz" |
308 |
+fi |
309 |
+KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86" |
310 |
+ |
311 |
+inherit check-reqs autotools eutils multilib python-single-r1 udev user readme.gentoo systemd versionator ${scm_eclass} |
312 |
+ |
313 |
+DESCRIPTION="Ceph distributed filesystem" |
314 |
+HOMEPAGE="http://ceph.com/" |
315 |
+ |
316 |
+LICENSE="LGPL-2.1" |
317 |
+SLOT="0" |
318 |
+IUSE="babeltrace cryptopp debug fuse gtk libatomic +libaio lttng +nss radosgw static-libs jemalloc tcmalloc xfs zfs" |
319 |
+ |
320 |
+COMMON_DEPEND=" |
321 |
+ app-arch/snappy |
322 |
+ dev-libs/boost:=[threads] |
323 |
+ dev-libs/fcgi |
324 |
+ dev-libs/libaio |
325 |
+ dev-libs/libedit |
326 |
+ dev-libs/leveldb[snappy] |
327 |
+ nss? ( dev-libs/nss ) |
328 |
+ cryptopp? ( dev-libs/crypto++ ) |
329 |
+ sys-apps/keyutils |
330 |
+ sys-apps/util-linux |
331 |
+ dev-libs/libxml2 |
332 |
+ babeltrace? ( dev-util/babeltrace ) |
333 |
+ fuse? ( sys-fs/fuse ) |
334 |
+ libatomic? ( dev-libs/libatomic_ops ) |
335 |
+ xfs? ( sys-fs/xfsprogs ) |
336 |
+ zfs? ( sys-fs/zfs ) |
337 |
+ gtk? ( |
338 |
+ x11-libs/gtk+:2 |
339 |
+ dev-cpp/gtkmm:2.4 |
340 |
+ gnome-base/librsvg |
341 |
+ ) |
342 |
+ radosgw? ( |
343 |
+ dev-libs/fcgi |
344 |
+ dev-libs/expat |
345 |
+ net-misc/curl |
346 |
+ ) |
347 |
+ jemalloc? ( dev-libs/jemalloc ) |
348 |
+ !jemalloc? ( dev-util/google-perftools ) |
349 |
+ lttng? ( dev-util/lttng-ust ) |
350 |
+ ${PYTHON_DEPS} |
351 |
+ " |
352 |
+DEPEND="${COMMON_DEPEND} |
353 |
+ virtual/pkgconfig" |
354 |
+RDEPEND="${COMMON_DEPEND} |
355 |
+ sys-apps/hdparm |
356 |
+ dev-python/flask[${PYTHON_USEDEP}] |
357 |
+ dev-python/requests[${PYTHON_USEDEP}] |
358 |
+ " |
359 |
+REQUIRED_USE=" |
360 |
+ ${PYTHON_REQUIRED_USE} |
361 |
+ ^^ ( nss cryptopp ) |
362 |
+ ?? ( jemalloc tcmalloc ) |
363 |
+ " |
364 |
+ |
365 |
+STRIP_MASK="/usr/lib*/rados-classes/*" |
366 |
+ |
367 |
+PATCHES=( |
368 |
+ "${FILESDIR}"/${PN}-0.79-libzfs.patch |
369 |
+ "${FILESDIR}"/${P}-libxfs.patch |
370 |
+) |
371 |
+ |
372 |
+check-reqs_export_vars() { |
373 |
+ # check-reqs does not support use flags, and there is a lot of variability |
374 |
+ # in Ceph. |
375 |
+ # 16G /var/tmp/portage/sys-cluster/ceph-9999-r1/work/ceph-9999 |
376 |
+ # 6.7G /var/tmp/portage/sys-cluster/ceph-9999-r1/image/usr |
377 |
+ # 23G /var/tmp/portage/sys-cluster/ceph-9999-r1 |
378 |
+ # Size requirements tested for Hammer & Jewel releases |
379 |
+ if use debug; then |
380 |
+ export CHECKREQS_DISK_BUILD="23G" |
381 |
+ export CHECKREQS_DISK_USR="7G" |
382 |
+ else |
383 |
+ export CHECKREQS_DISK_BUILD="9G" |
384 |
+ export CHECKREQS_DISK_USR="450M" |
385 |
+ fi |
386 |
+ |
387 |
+ export CHECKREQS_MEMORY="7G" |
388 |
+} |
389 |
+ |
390 |
+user_setup() { |
391 |
+ enewgroup ceph |
392 |
+ enewuser ceph -1 -1 /var/lib/ceph ceph |
393 |
+} |
394 |
+ |
395 |
+pkg_setup() { |
396 |
+ python_setup |
397 |
+ check-reqs_export_vars |
398 |
+ check-reqs_pkg_setup |
399 |
+ user_setup |
400 |
+} |
401 |
+ |
402 |
+src_prepare() { |
403 |
+ [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}" |
404 |
+ |
405 |
+ epatch_user |
406 |
+ eautoreconf |
407 |
+} |
408 |
+ |
409 |
+pkg_pretend() { |
410 |
+ check-reqs_export_vars |
411 |
+ check-reqs_pkg_pretend |
412 |
+} |
413 |
+ |
414 |
+src_configure() { |
415 |
+ local myeconfargs=( |
416 |
+ --without-hadoop |
417 |
+ --docdir="${EPREFIX}/usr/share/doc/${PF}" |
418 |
+ --includedir=/usr/include |
419 |
+ $(use_with debug) |
420 |
+ $(use_with fuse) |
421 |
+ $(use_with libaio) |
422 |
+ $(use_with libatomic libatomic-ops) |
423 |
+ $(use_with nss) |
424 |
+ $(use_with cryptopp) |
425 |
+ $(use_with radosgw) |
426 |
+ $(use_with gtk gtk2) |
427 |
+ $(use_enable static-libs static) |
428 |
+ $(use_with jemalloc) |
429 |
+ $(use_with xfs libxfs) |
430 |
+ $(use_with zfs libzfs) |
431 |
+ $(use_with lttng ) |
432 |
+ $(use_with babeltrace) |
433 |
+ --without-kinetic |
434 |
+ --without-librocksdb |
435 |
+ --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" |
436 |
+ ) |
437 |
+ |
438 |
+ use jemalloc || \ |
439 |
+ myeconfargs+=( $(usex tcmalloc " --with-tcmalloc" " --with-tcmalloc-minimal") ) |
440 |
+ |
441 |
+ PYTHON="${EPYTHON}" \ |
442 |
+ econf "${myeconfargs[@]}" |
443 |
+} |
444 |
+ |
445 |
+src_install() { |
446 |
+ default |
447 |
+ |
448 |
+ prune_libtool_files --all |
449 |
+ |
450 |
+ exeinto /usr/$(get_libdir)/ceph |
451 |
+ newexe src/init-ceph ceph_init.sh |
452 |
+ |
453 |
+ insinto /etc/logrotate.d/ |
454 |
+ newins "${FILESDIR}"/ceph.logrotate ${PN} |
455 |
+ |
456 |
+ chmod 644 "${ED}"/usr/share/doc/${PF}/sample.* |
457 |
+ |
458 |
+ keepdir /var/lib/${PN} |
459 |
+ keepdir /var/lib/${PN}/tmp |
460 |
+ keepdir /var/log/${PN}/stat |
461 |
+ |
462 |
+ fowners ceph:ceph /var/lib/ceph |
463 |
+ |
464 |
+ newinitd "${FILESDIR}/rbdmap.initd" rbdmap |
465 |
+ newinitd "${FILESDIR}/${PN}.initd-r2" ${PN} |
466 |
+ newconfd "${FILESDIR}/${PN}.confd-r1" ${PN} |
467 |
+ |
468 |
+ systemd_install_serviced "${FILESDIR}/ceph-mds_at.service.conf" "ceph-mds@.service" |
469 |
+ systemd_install_serviced "${FILESDIR}/ceph-osd_at.service.conf" "ceph-osd@.service" |
470 |
+ systemd_install_serviced "${FILESDIR}/ceph-mon_at.service.conf" "ceph-mon@.service" |
471 |
+ |
472 |
+ python_fix_shebang \ |
473 |
+ "${ED}"/usr/sbin/{ceph-disk,ceph-create-keys} \ |
474 |
+ "${ED}"/usr/bin/{ceph,ceph-rest-api,ceph-detect-init,ceph-brag} |
475 |
+ |
476 |
+ #install udev rules |
477 |
+ udev_dorules udev/50-rbd.rules |
478 |
+ udev_dorules udev/95-ceph-osd.rules |
479 |
+ |
480 |
+ readme.gentoo_create_doc |
481 |
+} |
482 |
+ |
483 |
+pkg_postinst() { |
484 |
+ readme.gentoo_print_elog |
485 |
+} |
486 |
|
487 |
diff --git a/sys-cluster/ceph/files/ceph-CVE-2016-5009.patch b/sys-cluster/ceph/files/ceph-CVE-2016-5009.patch |
488 |
new file mode 100644 |
489 |
index 0000000..1528dad |
490 |
--- /dev/null |
491 |
+++ b/sys-cluster/ceph/files/ceph-CVE-2016-5009.patch |
492 |
@@ -0,0 +1,87 @@ |
493 |
+diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc |
494 |
+index 10c8bfc..98843d7 100644 |
495 |
+--- a/src/mon/Monitor.cc |
496 |
++++ b/src/mon/Monitor.cc |
497 |
+@@ -2631,7 +2631,19 @@ void Monitor::handle_command(MonOpRequestRef op) |
498 |
+ return; |
499 |
+ } |
500 |
+ |
501 |
+- cmd_getval(g_ceph_context, cmdmap, "prefix", prefix); |
502 |
++ // check return value. If no prefix parameter provided, |
503 |
++ // return value will be false, then return error info. |
504 |
++ if(!cmd_getval(g_ceph_context, cmdmap, "prefix", prefix)) { |
505 |
++ reply_command(op, -EINVAL, "command prefix not found", 0); |
506 |
++ return; |
507 |
++ } |
508 |
++ |
509 |
++ // check prefix is empty |
510 |
++ if (prefix.empty()) { |
511 |
++ reply_command(op, -EINVAL, "command prefix must not be empty", 0); |
512 |
++ return; |
513 |
++ } |
514 |
++ |
515 |
+ if (prefix == "get_command_descriptions") { |
516 |
+ bufferlist rdata; |
517 |
+ Formatter *f = Formatter::create("json"); |
518 |
+@@ -2652,6 +2664,15 @@ void Monitor::handle_command(MonOpRequestRef op) |
519 |
+ boost::scoped_ptr<Formatter> f(Formatter::create(format)); |
520 |
+ |
521 |
+ get_str_vec(prefix, fullcmd); |
522 |
++ |
523 |
++ // make sure fullcmd is not empty. |
524 |
++ // invalid prefix will cause empty vector fullcmd. |
525 |
++ // such as, prefix=";,,;" |
526 |
++ if (fullcmd.empty()) { |
527 |
++ reply_command(op, -EINVAL, "command requires a prefix to be valid", 0); |
528 |
++ return; |
529 |
++ } |
530 |
++ |
531 |
+ module = fullcmd[0]; |
532 |
+ |
533 |
+ // validate command is in leader map |
534 |
+diff --git a/src/test/librados/cmd.cc b/src/test/librados/cmd.cc |
535 |
+index 9261fb5..878a8af 100644 |
536 |
+--- a/src/test/librados/cmd.cc |
537 |
++++ b/src/test/librados/cmd.cc |
538 |
+@@ -48,6 +48,41 @@ TEST(LibRadosCmd, MonDescribe) { |
539 |
+ rados_buffer_free(buf); |
540 |
+ rados_buffer_free(st); |
541 |
+ |
542 |
++ cmd[0] = (char *)""; |
543 |
++ ASSERT_EQ(-EINVAL, rados_mon_command(cluster, (const char **)cmd, 1, "{}", 2, &buf, &buflen, &st, &stlen)); |
544 |
++ rados_buffer_free(buf); |
545 |
++ rados_buffer_free(st); |
546 |
++ |
547 |
++ cmd[0] = (char *)"{}"; |
548 |
++ ASSERT_EQ(-EINVAL, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); |
549 |
++ rados_buffer_free(buf); |
550 |
++ rados_buffer_free(st); |
551 |
++ |
552 |
++ cmd[0] = (char *)"{\"abc\":\"something\"}"; |
553 |
++ ASSERT_EQ(-EINVAL, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); |
554 |
++ rados_buffer_free(buf); |
555 |
++ rados_buffer_free(st); |
556 |
++ |
557 |
++ cmd[0] = (char *)"{\"prefix\":\"\"}"; |
558 |
++ ASSERT_EQ(-EINVAL, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); |
559 |
++ rados_buffer_free(buf); |
560 |
++ rados_buffer_free(st); |
561 |
++ |
562 |
++ cmd[0] = (char *)"{\"prefix\":\" \"}"; |
563 |
++ ASSERT_EQ(-EINVAL, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); |
564 |
++ rados_buffer_free(buf); |
565 |
++ rados_buffer_free(st); |
566 |
++ |
567 |
++ cmd[0] = (char *)"{\"prefix\":\";;;,,,;;,,\"}"; |
568 |
++ ASSERT_EQ(-EINVAL, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); |
569 |
++ rados_buffer_free(buf); |
570 |
++ rados_buffer_free(st); |
571 |
++ |
572 |
++ cmd[0] = (char *)"{\"prefix\":\"extra command\"}"; |
573 |
++ ASSERT_EQ(-EINVAL, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); |
574 |
++ rados_buffer_free(buf); |
575 |
++ rados_buffer_free(st); |
576 |
++ |
577 |
+ cmd[0] = (char *)"{\"prefix\":\"mon_status\"}"; |
578 |
+ ASSERT_EQ(0, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); |
579 |
+ ASSERT_LT(0u, buflen); |