Skip to content

Commit 1fddf9a

Browse files
committed
MGM: Allow handling the new token 't' flag via the eos acl command. Fixes EOS-6528
1 parent 1ab3608 commit 1fddf9a

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

console/commands/helpers/AclHelper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ AclHelper::CheckId(const std::string& id)
7878
bool
7979
AclHelper::CheckFlags(const std::string& flags)
8080
{
81-
static const std::string allowed_chars = "!+-rwoxmduqcaAX";
81+
static const std::string allowed_chars = "!+-rwoxmduqcatAX";
8282
return flags.find_first_not_of(allowed_chars) == std::string::npos;
8383
}
8484

mgm/proc/user/AclCmd.cc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Rule AclCmd::GetRuleFromString(const std::string& single_acl)
282282
auto acl_delimiter = single_acl.rfind(':');
283283
ret.first = std::string(single_acl.begin(),
284284
single_acl.begin() + acl_delimiter);
285-
unsigned short rule_int = 0;
285+
unsigned long rule_int = 0;
286286

287287
for (auto i = acl_delimiter + 1, size = single_acl.length(); i < size; ++i) {
288288
switch (single_acl.at(i)) {
@@ -330,6 +330,10 @@ Rule AclCmd::GetRuleFromString(const std::string& single_acl)
330330
rule_int = rule_int | AclCmd::SysAttr;
331331
break;
332332

333+
case 't':
334+
rule_int = rule_int | AclCmd::Token;
335+
break;
336+
333337
case '+' :
334338
// There are only two + flags in current acl permissions +d and +u
335339
i++;
@@ -419,7 +423,7 @@ AclCmd::GenerateRuleMap(const std::string& acl_string, RuleMap& rmap)
419423
bool AclCmd::GetRuleBitmask(const std::string& input, bool set)
420424
{
421425
bool lambda_happen = false;
422-
unsigned short int ret = 0, add_ret = 0, rm_ret = 0;
426+
unsigned long ret = 0, add_ret = 0, rm_ret = 0;
423427
auto add_lambda = [&](AclCmd::ACLPos pos) {
424428
add_ret = add_ret | pos;
425429
ret = ret | pos;
@@ -522,6 +526,11 @@ bool AclCmd::GetRuleBitmask(const std::string& input, bool set)
522526
continue;
523527
}
524528

529+
if (*flag == 't') {
530+
curr_lambda(AclCmd::Token);
531+
continue;
532+
}
533+
525534
if (*flag == 'c') {
526535
curr_lambda(AclCmd::C);
527536
continue;
@@ -695,7 +704,7 @@ AclCmd::CheckCorrectId(const std::string& id) const
695704
//------------------------------------------------------------------------------
696705
void AclCmd::ApplyRule(RuleMap& rules, size_t pos)
697706
{
698-
unsigned short temp_rule = 0;
707+
unsigned long temp_rule = 0;
699708

700709
if (!mSet) {
701710
auto it = std::find_if(rules.begin(),
@@ -757,7 +766,7 @@ AclCmd::GenerateAclString(const RuleMap& rmap)
757766
// Convert ACL bitmask to string representation
758767
//------------------------------------------------------------------------------
759768
std::string
760-
AclCmd::AclBitmaskToString(const unsigned short int in)
769+
AclCmd::AclBitmaskToString(const unsigned long int in)
761770
{
762771
std::string ret = "";
763772

@@ -785,6 +794,10 @@ AclCmd::AclBitmaskToString(const unsigned short int in)
785794
ret.append("X");
786795
}
787796

797+
if (in & AclCmd::Token) {
798+
ret.append("t");
799+
}
800+
788801
if (in & AclCmd::M) {
789802
ret.append("m");
790803
}

mgm/proc/user/AclCmd.hh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
EOSMGMNAMESPACE_BEGIN
3030

31-
typedef std::pair<std::string, unsigned short> Rule;
32-
//typedef std::unordered_map<std::string, unsigned short> RuleMap;
31+
typedef std::pair<std::string, unsigned long> Rule;
32+
//typedef std::unordered_map<std::string, unsigned long> RuleMap;
3333
// We use a list as we need to be able to insert at any position
3434
typedef std::list<Rule> RuleMap;
3535

@@ -195,15 +195,15 @@ public:
195195
//----------------------------------------------------------------------------
196196
//! Return mAddRule result after GetRuleBitmask call.
197197
//----------------------------------------------------------------------------
198-
unsigned short GetAddRule()
198+
unsigned long GetAddRule()
199199
{
200200
return mAddRule;
201201
}
202202

203203
//----------------------------------------------------------------------------
204204
//! Return mRmRule result after GetRuleBitmask call.
205205
//----------------------------------------------------------------------------
206-
unsigned short GetRmRule()
206+
unsigned long GetRmRule()
207207
{
208208
return mRmRule;
209209
}
@@ -227,13 +227,14 @@ private:
227227
nW = 1 << 13, // 8192 - !w
228228
nX = 1 << 14, //16384 - !x
229229
A = 1 << 15, //32768 - a
230-
SysAcl = 1 << 16, //65536 - A
231-
SysAttr = 1 << 17 //131072 - X
230+
SysAcl = 1 << 16, //65536 - A
231+
SysAttr = 1 << 17, //131072 - X
232+
Token = 1 << 18 //262144 - t
232233
};
233234

234235
std::string mId; ///< Rule identifier extracted from command line
235236
///< ACL rule bitmasks for adding and removing
236-
unsigned short mAddRule, mRmRule;
237+
unsigned long mAddRule, mRmRule;
237238
bool mSet; ///< Rule is set operations i.e contains =
238239

239240
//----------------------------------------------------------------------------
@@ -289,7 +290,7 @@ private:
289290
//!
290291
//! @return std::string representation of ACL
291292
//----------------------------------------------------------------------------
292-
static std::string AclBitmaskToString(const unsigned short in);
293+
static std::string AclBitmaskToString(const unsigned long in);
293294

294295
std::string mErr; ///< Command error output string
295296

0 commit comments

Comments
 (0)