From 4e138c1fc6acbd89555189cf7d2e362fccd571be Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 12 Apr 2010 14:37:47 -0700 Subject: [PATCH] osd: Add is_X functions to OSDCaps (where X is mon, osd, mds). --- src/osd/OSD.cc | 1 + src/osd/OSDCaps.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index de64ba8862d..7044d38228b 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1708,6 +1708,7 @@ bool OSD::ms_verify_authorizer(Connection *con, int peer_type, s->caps.set_allow_all(caps_info.allow_all); s->caps.set_auid(auid); + s->caps.set_peer_type(peer_type); if (caps_info.caps.length() > 0) { bufferlist::iterator iter = caps_info.caps.begin(); diff --git a/src/osd/OSDCaps.h b/src/osd/OSDCaps.h index e4d73bcdab5..f01015e3f42 100644 --- a/src/osd/OSDCaps.h +++ b/src/osd/OSDCaps.h @@ -16,6 +16,10 @@ * "allow rwx auid foo[,bar,baz]" (which allows full access to listed auids) * "allow rwx pool foo[,bar,baz]" (which allows full access to listed pools) * "allow *" (which allows full access to EVERYTHING) + * + * The OSD assumes that anyone with * caps is an admin and has full + * message permissions. This means that only the monitor and the OSDs + * should get * */ #ifndef __CEPH_OSDCAPS_H @@ -57,6 +61,7 @@ struct OSDCaps { map auid_map; rwx_t default_action; bool allow_all; + int peer_type; __u64 auid; bool get_next_token(string s, size_t& pos, string& token); @@ -66,7 +71,11 @@ struct OSDCaps { auid(CEPH_AUTH_UID_DEFAULT) {} bool parse(bufferlist::iterator& iter); int get_pool_cap(int pool_id, __u64 uid = CEPH_AUTH_UID_DEFAULT); + bool is_mon() { return CEPH_ENTITY_TYPE_MON == peer_type; } + bool is_osd() { return CEPH_ENTITY_TYPE_OSD == peer_type; } + bool is_mds() { return CEPH_ENTITY_TYPE_MDS == peer_type; } void set_allow_all(bool allow) { allow_all = allow; } + void set_peer_type (int pt) { peer_type = pt; } void set_auid(__u64 uid) { auid = uid; } }; -- 2.47.3