X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fauth.cpp;h=fce521e13bec26d4d330a2d75233d0e65c5343e2;hb=569fca53089b7b7e87b02edd44e2ad47166f7af6;hp=5d61243c693e357e279da5d6ee6f06d7160a0960;hpb=ccae5a49ad55a7c70d3977af33f5ce413abe94df;p=minetest.git diff --git a/src/auth.cpp b/src/auth.cpp index 5d61243c6..fce521e13 100644 --- a/src/auth.cpp +++ b/src/auth.cpp @@ -23,15 +23,37 @@ with this program; if not, write to the Free Software Foundation, Inc., //#include "main.h" // for g_settings #include #include "strfnd.h" -#include "debug.h" +#include "log.h" + +std::set privsToSet(u64 privs) +{ + std::set s; + if(privs & PRIV_INTERACT) + s.insert("interact"); + if(privs & PRIV_TELEPORT) + s.insert("teleport"); + if(privs & PRIV_SETTIME) + s.insert("settime"); + if(privs & PRIV_PRIVS) + s.insert("privs"); + if(privs & PRIV_SHOUT) + s.insert("shout"); + if(privs & PRIV_BAN) + s.insert("ban"); + if(privs & PRIV_GIVE) + s.insert("give"); + if(privs & PRIV_PASSWORD) + s.insert("password"); + return s; +} // Convert a privileges value into a human-readable string, // with each component separated by a comma. std::string privsToString(u64 privs) { std::ostringstream os(std::ios_base::binary); - if(privs & PRIV_BUILD) - os<<"build,"; + if(privs & PRIV_INTERACT) + os<<"interact,"; if(privs & PRIV_TELEPORT) os<<"teleport,"; if(privs & PRIV_SETTIME) @@ -40,6 +62,12 @@ std::string privsToString(u64 privs) os<<"privs,"; if(privs & PRIV_SHOUT) os<<"shout,"; + if(privs & PRIV_BAN) + os<<"ban,"; + if(privs & PRIV_GIVE) + os<<"give,"; + if(privs & PRIV_PASSWORD) + os<<"password,"; if(os.tellp()) { // Drop the trailing comma. (Why on earth can't @@ -61,7 +89,9 @@ u64 stringToPrivs(std::string str) { std::string s = trim(f.next(",")); if(s == "build") - privs |= PRIV_BUILD; + privs |= PRIV_INTERACT; + else if(s == "interact") + privs |= PRIV_INTERACT; else if(s == "teleport") privs |= PRIV_TELEPORT; else if(s == "settime") @@ -70,6 +100,12 @@ u64 stringToPrivs(std::string str) privs |= PRIV_PRIVS; else if(s == "shout") privs |= PRIV_SHOUT; + else if(s == "ban") + privs |= PRIV_BAN; + else if(s == "give") + privs |= PRIV_GIVE; + else if(s == "password") + privs |= PRIV_PASSWORD; else return PRIV_INVALID; } @@ -87,7 +123,7 @@ AuthManager::AuthManager(const std::string &authfilepath): } catch(SerializationError &e) { - dstream<<"WARNING: AuthManager: creating " + infostream<<"WARNING: AuthManager: creating " <