{
static const unsigned int MAX_CAPS = (sizeof(intptr_t) * 8) - 1;
static const intptr_t CAP_302_BIT = (intptr_t)1 << MAX_CAPS;
+ static const unsigned int MAX_VALUE_LENGTH = 100;
typedef intptr_t Ext;
typedef LocalIntExt ExtItem;
{
return true;
}
+
+ /** Query the value of this capability for a user
+ * @param user User who will get the value of the capability
+ * @return Value to show to the user. If NULL, the capability has no value (default).
+ */
+ virtual const std::string* GetValue(LocalUser* user) const
+ {
+ return NULL;
+ }
};
}
return true;
}
- void HandleList(std::string& out, LocalUser* user, bool show_all, bool minus_prefix = false) const
+ void HandleList(std::string& out, LocalUser* user, bool show_all, bool show_values, bool minus_prefix = false) const
{
Ext show_caps = (show_all ? ~0 : capext.get(user));
if (minus_prefix)
out.push_back('-');
- out.append(cap->GetName()).push_back(' ');
+ out.append(cap->GetName());
+
+ if (show_values)
+ {
+ const std::string* capvalue = cap->GetValue(user);
+ if ((capvalue) && (!capvalue->empty()) && (capvalue->find(' ') == std::string::npos))
+ {
+ out.push_back('=');
+ out.append(*capvalue, 0, MAX_VALUE_LENGTH);
+ }
+ }
+ out.push_back(' ');
}
}
void HandleClear(LocalUser* user, std::string& result)
{
- HandleList(result, user, false, true);
+ HandleList(result, user, false, false, true);
capext.unset(user);
}
};
manager.Set302Protocol(user);
std::string result = subcommand + " :";
- manager.HandleList(result, user, is_ls);
+ // Show values only if supports v3.2 and doing LS
+ manager.HandleList(result, user, is_ls, ((is_ls) && (manager.GetProtocol(user) != Cap::CAP_LEGACY)));
DisplayResult(user, result);
}
else if ((subcommand == "CLEAR") && (manager.GetProtocol(user) == Cap::CAP_LEGACY))