1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "rgw_common.h"
9 #include "include/assert.h"
10 #include "rgw_crypt_sanitize.h"
12 #define dout_context g_ceph_context
13 #define dout_subsys ceph_subsys_rgw
15 void RGWEnv::init(CephContext
*cct
)
20 void RGWEnv::set(const boost::string_ref
& name
, const boost::string_ref
& val
)
22 env_map
[std::string
{name
}] = std::string
{val
};
25 void RGWEnv::init(CephContext
*cct
, char **envp
)
31 for (int i
=0; (p
= envp
[i
]); ++i
) {
33 int pos
= s
.find('=');
34 if (pos
<= 0) // should never be 0
36 string name
= s
.substr(0, pos
);
37 string val
= s
.substr(pos
+ 1);
44 const char *RGWEnv::get(const char *name
, const char *def_val
)
46 map
<string
, string
, ltstr_nocase
>::iterator iter
= env_map
.find(name
);
47 if (iter
== env_map
.end())
50 return iter
->second
.c_str();
53 int RGWEnv::get_int(const char *name
, int def_val
)
55 map
<string
, string
, ltstr_nocase
>::iterator iter
= env_map
.find(name
);
56 if (iter
== env_map
.end())
59 const char *s
= iter
->second
.c_str();
63 bool RGWEnv::get_bool(const char *name
, bool def_val
)
65 map
<string
, string
, ltstr_nocase
>::iterator iter
= env_map
.find(name
);
66 if (iter
== env_map
.end())
69 const char *s
= iter
->second
.c_str();
70 return rgw_str_to_bool(s
, def_val
);
73 size_t RGWEnv::get_size(const char *name
, size_t def_val
)
75 map
<string
, string
, ltstr_nocase
>::iterator iter
= env_map
.find(name
);
76 if (iter
== env_map
.end())
79 const char *s
= iter
->second
.c_str();
83 bool RGWEnv::exists(const char *name
)
85 map
<string
, string
, ltstr_nocase
>::iterator iter
= env_map
.find(name
);
86 return (iter
!= env_map
.end());
89 bool RGWEnv::exists_prefix(const char *prefix
)
91 if (env_map
.empty() || prefix
== NULL
)
94 map
<string
, string
, ltstr_nocase
>::iterator iter
= env_map
.lower_bound(prefix
);
95 if (iter
== env_map
.end())
98 return (strncmp(iter
->first
.c_str(), prefix
, strlen(prefix
)) == 0);
101 void RGWEnv::remove(const char *name
)
103 map
<string
, string
, ltstr_nocase
>::iterator iter
= env_map
.find(name
);
104 if (iter
!= env_map
.end())
108 void RGWConf::init(CephContext
*cct
, RGWEnv
*env
)
110 enable_ops_log
= cct
->_conf
->rgw_enable_ops_log
;
111 enable_usage_log
= cct
->_conf
->rgw_enable_usage_log
;
113 defer_to_bucket_acls
= 0; // default
114 if (cct
->_conf
->rgw_defer_to_bucket_acls
== "recurse") {
115 defer_to_bucket_acls
= RGW_DEFER_TO_BUCKET_ACLS_RECURSE
;
116 } else if (cct
->_conf
->rgw_defer_to_bucket_acls
== "full_control") {
117 defer_to_bucket_acls
= RGW_DEFER_TO_BUCKET_ACLS_FULL_CONTROL
;