]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common: admin socket fallback to json-pretty format 1210/head
authorLoic Dachary <loic@dachary.org>
Mon, 10 Feb 2014 22:42:38 +0000 (23:42 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 11 Feb 2014 08:36:39 +0000 (09:36 +0100)
commit30a604d2d6a5de7bcbfa0136e9a766cb34f96c0a
tree01d8110e4a1b10abb8f9a1f1eb197c16e3e132ce
parentccd9b5eb9bcfe2360e874b306d4decd8815ecf46
common: admin socket fallback to json-pretty format

If the format argument to a command sent to the admin socket is not
among the supported formats ( json, json-pretty, xml, xml-pretty ) the
new_formatter function will return null and the AdminSocketHook::call
function must fall back to a sensible default.

The CephContextHook::call and HelpHook::call failed to do that and a
malformed format argument would cause the mon to crash. A check is added
to each of them and fallback to json-pretty if the format is not
recognized.

To further protect AdminSocketHook::call implementations from similar
problems the format argument is checked immediately after accepting the
command in AdminSocket::do_accept and replaced with json-pretty if it is
not known.

A test case is added for both CephContextHook::call and HelpHook::call
to demonstrate the problem exists and is fixed by the patch.

Three other instances of unsafe calls to new_formatter were found and
a fallback to json-pretty was added. All other calls have been audited
and appear to be safe.

http://tracker.ceph.com/issues/7378 fixes #7378

Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 165e76d4d03ffcc490fd3c2ba60fb37372990d0a)
src/Makefile.am
src/client/Client.cc
src/common/admin_socket.cc
src/common/ceph_context.cc
src/osd/OSD.cc
src/osdc/Objecter.cc
src/test/admin_socket.cc
src/test/common/test_context.cc [new file with mode: 0644]