Commit Graph

485 Commits

Author SHA1 Message Date
Luo Kexue
63515bec9d auth: add err log info for load function
Signed-off-by: Luo Kexue <luo.kexue@zte.com.cn>
2017-08-25 19:12:34 +08:00
Luo Kexue
e8cf00e8e5 auth: Remove unused function in AuthSessionHandler
Signed-off-by: Luo Kexue <luo.kexue@zte.com.cn>
2017-07-31 08:16:08 +08:00
Kefu Chai
efc0b61ba7 auth/RotatingKeyRing: use std::move() to set secrets
the param will be thrown away anyway. see
CephxClientHandler::handle_response().

Signed-off-by: Kefu Chai <kchai@redhat.com>
2017-06-23 15:36:14 +08:00
Yuri Weinstein
a49d9c5637 Merge pull request #15042 from badone/wip-redundant-headers-3
common: Remove redundant includes

Reviewed-by: Kefu Chai <kchai@redhat.com>
2017-05-16 13:16:43 -07:00
Brad Hubbard
bfec53faa5 common: Remove redundant includes
Fixes: http://tracker.ceph.com/issues/19883 (Partially)

Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
2017-05-13 08:57:45 +10:00
Kefu Chai
b7a194eb65 byteorder: use gcc intrinsics for byteswap
* use gcc intrinsics for byteswap
* use template to wrap them.
* add the modeline for emacs/vim
* update the caller of the mswab/swab accordingly

Signed-off-by: Kefu Chai <kchai@redhat.com>
2017-05-10 23:12:30 +08:00
Sage Weil
ef6de18a62 Merge pull request #13692 from Liuchang0812/wip-add-override-in-auth-headers
common/auth: add override in headers

Reviewed-by: Sage Weil <sage@redhat.com>
2017-02-28 09:54:55 -06:00
liuchang0812
4975d6d3d1 common/auth: add override in headers
Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
2017-02-28 17:22:51 +08:00
Kefu Chai
87e0759bf2 auth/cephx: print challenges in hex
this matches the CephxServiceHandler::handle_request(), hence would be
easier for debugging.

Signed-off-by: Kefu Chai <kchai@redhat.com>
2017-02-27 00:23:07 +08:00
Kefu Chai
c623b3eb1a Merge pull request #13443 from Liuchang0812/cleanup-common
common: add override in common and misc

Reviewed-by: Kefu Chai <kchai@redhat.com>
2017-02-16 19:49:53 +08:00
liuchang0812
da109b3139 common: add override for common submodule and misc
Fixes: http://tracker.ceph.com/issues/18922

Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
2017-02-16 13:32:22 +08:00
Kefu Chai
5871a6f403 auth: AuthClientHandler::init() pass parameter by const ref
Signed-off-by: Kefu Chai <kchai@redhat.com>
2017-02-14 12:58:22 +08:00
Dave Chen
364a6f2e39 auth: Enhancement for the supported auth methods
- If no auth protocol defined, `cephx` is used by default, it's debatable if
  ceph should abort here or use `cephx` by default, but if `cephx` is used
  in this case it's better to give some warning message.
- ceph has CEPH_AUTH_UNKNOWN auth protocol defined, change to use this
  protocol if the auth method is unknown.

Signed-off-by: Dave Chen <wei.d.chen@intel.com>
2017-01-16 15:11:02 +08:00
Adam C. Emerson
750ad8340c common: Unskew clock
In preparation to deglobalizing CephContext, remove the CephContext*
parameter to ceph_clock_now() and ceph::real_clock::now() that carries
a configurable offset.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
2016-12-22 13:55:37 -05:00
Li Wang
cdc0930a95 auth/Crypto.h: remove unneeded forward declaration
Signed-off-by: Li Wang <li.wang@kylin-cloud.com>
2016-12-01 09:01:15 +00:00
Li Wang
aebe74641b auth/AuthClientHandler.h: remove unneeded forward declaration
Signed-off-by: Li Wang <li.wang@kylin-cloud.com>
2016-12-01 09:01:03 +00:00
Sage Weil
61fca96c29 assert(0) -> ceph_abort()
Signed-off-by: Sage Weil <sage@redhat.com>
2016-11-21 23:37:31 -05:00
runsisi
45fc387e16 auth: fix NULL pointer access when trying to delete CryptoAESKeyHandler instance
the caller needs to check the nullity of the parameter before calling
PK11_FreeSymKey or PK11_FreeSlot, otherwise if CryptoAESKeyHandler::init
failed, we will hit a segfault as follows:
  #0  0x00007f76844f5a95 in PK11_FreeSymKey () from /lib64/libnss3.so
  #1  0x00007f76586b6e49 in CryptoAESKeyHandler::~CryptoAESKeyHandler() () from /lib64/librados.so.2
  #2  0x00007f76586b5eea in CryptoAES::get_key_handler(ceph::buffer::ptr const&, std::string&) () from /lib64/librados.so.2
  #3  0x00007f76586b4b9c in CryptoKey::_set_secret(int, ceph::buffer::ptr const&) () from /lib64/librados.so.2
  #4  0x00007f76586b4e95 in CryptoKey::decode(ceph::buffer::list::iterator&) () from /lib64/librados.so.2
  #5  0x00007f76586b7ee6 in KeyRing::set_modifier(char const*, char const*, EntityName&, std::map<std::string, ceph::buffer::list, std::less<std::string>, std::allocator<std::pair<std::string const, ceph::buffer::list> > >&) () from /lib64/librados.so.2
  #6  0x00007f76586b8882 in KeyRing::decode_plaintext(ceph::buffer::list::iterator&) () from /lib64/librados.so.2
  #7  0x00007f76586b9803 in KeyRing::decode(ceph::buffer::list::iterator&) () from /lib64/librados.so.2
  #8  0x00007f76586b9a1f in KeyRing::load(CephContext*, std::string const&) () from /lib64/librados.so.2
  #9  0x00007f76586ba04b in KeyRing::from_ceph_context(CephContext*) () from /lib64/librados.so.2
  #10 0x00007f765852d0cd in MonClient::init() () from /lib64/librados.so.2
  #11 0x00007f76583c15f5 in librados::RadosClient::connect() () from /lib64/librados.so.2
  #12 0x00007f765838cb1c in rados_connect () from /lib64/librados.so.2
  ...

Signed-off-by: runsisi <runsisi@zte.com.cn>
2016-10-24 09:24:51 +08:00
Sage Weil
6d7f748653 buffer: rename iterator copy() to copy_deep()
Current callers expect a deep copy; be explicit about it.

Signed-off-by: Sage Weil <sage@redhat.com>
2016-10-16 10:32:49 -04:00
Sage Weil
16fda71354 auth/cephx: do not re-request *only* the MGR key
If we request a bunch of service keys, we may not get
back a MGR key because of an in-progress upgrade.  If we
have everything we need except for just the MGR key, do
not bother re-requesting it.  Instead just continue and
we'll re-request it later when the secrets rotate.

Signed-off-by: Sage Weil <sage@redhat.com>
2016-10-15 22:51:27 -04:00
Sage Weil
392fa14c06 auth/cephx: tolerate missing rotating keys
During an upgrade, we may have a client requesting an
MGR service key but not have one in the database yet,
either because we *just* upgraded and haven't generated
one yet, or because the leader mon hasn't been upgraded
yet.

Fix this by silently tolerating a missing key as long as
one or more other service keys were present and we have
something to give to the client.

Signed-off-by: Sage Weil <sage@redhat.com>
2016-10-14 14:41:44 -04:00
John Spray
bbc66310ef auth: add mgr service type
Signed-off-by: John Spray <john.spray@redhat.com>
2016-09-29 17:26:54 +01:00
Sage Weil
fba798dcad remove autotools
Signed-off-by: Sage Weil <sage@redhat.com>
2016-09-07 11:50:14 -04:00
Yuri Weinstein
a602346880 Merge pull request #9679 from xiexingguo/xxg-wip-fix-cephx
auth/cephx: misc fixes

Reviewed-by: Sage Weil <sage@redhat.com>
2016-08-01 14:27:27 -07:00
Brad Hubbard
009e777fbd cephx: Fix multiple segfaults due to attempts to encrypt or decrypt
an empty secret and a null CryptoKeyHandler

Fixes: http://tracker.ceph.com/issues/16266
Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
2016-07-05 15:26:23 +10:00
xie xingguo
b8af5f75a4 auth/cephx: kill dead code
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
2016-06-12 16:25:51 +08:00
xie xingguo
3655b00127 auth/cephx: return error if we are unable to decode rotate-key
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
2016-06-07 14:50:14 +08:00
xie xingguo
5ed15148e5 auth/cephx: fix race condition for build_session_auth_info()
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
2016-06-07 10:19:01 +08:00
xie xingguo
9eab1d99da auth/cephx: process formatter dump more tenderly
E.g., if there is no secrets, we don't open a session and
leave it haning after returning.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
2016-06-07 10:19:01 +08:00
xie xingguo
d55f43f1b3 auth: return error if we are unable to parse keyring file
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
2016-06-07 10:19:01 +08:00
xie xingguo
003289d4b9 auth/cephx: fix race conditon for some public methods of KeyServer
These methods are called only by AuthMonitor and are accessed
without protection of internal lock, which is not safe.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
2016-06-07 10:19:01 +08:00
shawn
077af137de AUTH: optimize header file dependency.
same work as PR: https://github.com/ceph/ceph/pull/9193, https://github.com/ceph/ceph/pull/9161

Signed-off-by: Xiaowei Chen <chen.xiaowei@h3c.com>
2016-05-20 04:43:33 -04:00
Kefu Chai
827320cb6d osd,auth: silence "-Wmisleading-indentation" warnings
Signed-off-by: Kefu Chai <kchai@redhat.com>
2016-05-17 13:17:06 +08:00
Danny Al-Gaaf
bbf0582342 make ctors with one argument explicit
Use explicit keyword for constructors with one argument to
prevent implicit usage as conversion functions.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2016-01-29 23:48:58 +01:00
Danny Al-Gaaf
b43497c611 auth/Crypto.cc: close theoretical memory leak
Fix for:

CID 1296382 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable ckh going out of scope leaks the storage
 it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2016-01-29 21:51:17 +01:00
Sage Weil
b3ad2b93ea Merge pull request #6698 from mathslinux/auth-crash-fix
auth: fix crash when bad keyring is passed

Reviewed-by: Sage Weil <sage@redhat.com>
2015-12-11 15:42:53 -05:00
Dunrong Huang
a7f520caab auth: fix a crash issue due to CryptoHandler::create() failed
In this case(e.g. user passes wrong key), attempts to call the CryptoKey.ckh will lead to a segfault.

This patch fixes crash issue like following:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffed10e700 (LWP 25051)]
0x00007ffff59896c6 in CryptoKey::encrypt (this=0x7fffed10d4f0, cct=0x555555829c30, in=..., out=..., error=0x7fffed10d440) at auth/cephx/../Crypto.h:110
110	    return ckh->encrypt(in, out, error);
(gdb) bt
    at auth/cephx/../Crypto.h:110
    at auth/cephx/CephxProtocol.h:464

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
2015-11-28 23:48:23 +08:00
Dunrong Huang
e9e05333ac auth: fix double PK11_DestroyContext() if PK11_DigestFinal() failed
Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
2015-11-28 23:48:23 +08:00
Sage Weil
d633b64566 Merge pull request #5734 from cxwshawn/mon-fix
auth: make keyring without mon entity type return -EACCES

Reviewed-by: Loic Dachary <ldachary@redhat.com>
2015-11-26 17:24:59 -05:00
Sage Weil
88fe166cfa Merge pull request #6473 from H3C/wip-osd-bugfix1
auth: fail if rotating key is missing (do not spam log)

Reviewed-by: Kefu Chai <kchai@redhat.com>
2015-11-25 17:46:01 -05:00
Rohan Mars
f83f10a5ca solaris big endian fixes
Signed-off-by: Rohan Mars <code@rohanmars.com>
2015-11-12 17:30:49 -08:00
Xiaowei Chen
1ace4d03b2 auth: keyring without mon entity type should return -EACCES
test:
                         see test.sh:test_mon_caps
                         before modify:
                         when we first exec ../qa/workunits/cephtool/test.sh -t mon_caps --asok-does-not-need-root , it stuck.
                         after modify:
                         exec again, return Permission denied.

Signed-off-by: Xiaowei Chen <chen.xiaowei@h3c.com>
2015-11-10 02:54:35 -05:00
qiankunzheng
102f0b1932 auth/cephx: large amounts of log are produced by osd
if the auth of osd is deleted when the osd is running, the osd will produce large amounts of log.

Fixes:#13610
Signed-off-by: Qiankun Zheng <zheng.qiankun@h3c.com>
2015-11-05 07:31:12 -05:00
Nathan Cutler
7250db62cb CephxServiceHandler.cc: fix get_auth conditional
The KeyServer class has a public method get_auth() that returns a boolean
value. This value is being checked here - fix the conditional so it triggers
when get_auth() returns false.

http://tracker.ceph.com/issues/9756 References: #9756

Signed-off-by: Nathan Cutler <ncutler@suse.com>
2015-10-09 06:28:34 +02:00
Casey Bodley
5b15ea2b2d c++11: replace auto_ptr with unique_ptr
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2015-08-03 11:16:13 -04:00
John Spray
64e5041008 auth: check return value of keyring->get_secret
get_secret can fail to populate the passed CryptoKey, for
example if the entity name is not found in the keyring.  In
this case, attempts to use the CryptoKey will lead to
segfaults.

Fixes: #12417
Signed-off-by: John Spray <john.spray@redhat.com>
2015-07-21 16:13:10 +01:00
Danny Al-Gaaf
67e2caa6fe crypto: fix cmake error '#elif with no expression'
It needs to be '#elif defined()' to work with cmake.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2015-05-07 13:23:37 +02:00
Sage Weil
40203f711d auth: return error code from encrypt/decrypt; make error string optional
This is simpler for a lot of callers.

Signed-off-by: Sage Weil <sage@redhat.com>
2015-04-21 17:00:27 -07:00
Sage Weil
7762f1886c auth: optimize crypto++ key context
The cbc appears to be stateful, but the key is not.

Signed-off-by: Sage Weil <sage@redhat.com>
2015-04-21 17:00:27 -07:00
Sage Weil
973cd1c00a auth/Crypto: optimize libnss key
Allocate the key and slot once per key instead of once per encrypt/
decrypt operation.  This improves things by a factor of almost 4x
for my microbenchmark.

Signed-off-by: Sage Weil <sage@redhat.com>
2015-04-21 17:00:27 -07:00