Skip to content

Commit cbb0a81

Browse files
committed
Update
1 parent 1aa7b0d commit cbb0a81

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,14 @@ void CheckCanModifyOtherResource(CScriptArgReader& argStream, CResource* pThisRe
746746
"Access denied");
747747
}
748748

749+
std::pair<bool, SString> CheckCanModifyOtherResource(CResource* thisResource, CResource* otherResource)
750+
{
751+
if (GetResourceModifyScope(thisResource, otherResource) != eResourceModifyScope::NONE)
752+
return {true, ""};
753+
754+
return {false, SString("ModifyOtherObjects in ACL denied resource %s to access %s", thisResource->GetName().c_str(), otherResource->GetName().c_str())};
755+
}
756+
749757
//
750758
// Set error if pThisResource does not have permission to modify every resource in resourceList
751759
//

Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,10 @@ enum class eResourceModifyScope
402402
};
403403

404404
eResourceModifyScope GetResourceModifyScope(CResource* pThisResource, CResource* pOtherResource);
405-
void CheckCanModifyOtherResource(CScriptArgReader& argStream, CResource* pThisResource, CResource* pOtherResource);
406-
void CheckCanModifyOtherResources(CScriptArgReader& argStream, CResource* pThisResource, std::initializer_list<CResource*> resourceList);
405+
void CheckCanModifyOtherResource(CScriptArgReader& argStream, CResource* pThisResource, CResource* pOtherResource);
406+
std::pair<bool, SString> CheckCanModifyOtherResource(CResource* thisResource, CResource* otherResource);
407+
408+
void CheckCanModifyOtherResources(CScriptArgReader& argStream, CResource* pThisResource, std::initializer_list<CResource*> resourceList);
407409
void CheckCanAccessOtherResourceFile(CScriptArgReader& argStream, CResource* pThisResource, CResource* pOtherResource, const SString& strAbsPath,
408410
bool* pbReadOnly = nullptr);
409411

Server/mods/deathmatch/logic/luadefs/CLuaDatabaseDefs.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ std::variant<CDatabaseConnectionElement*, bool> CLuaDatabaseDefs::DbConnect(lua_
248248
if (!IsValidFilePath(host.c_str()))
249249
{
250250
SString err("host path %s not valid", host.c_str());
251-
throw LuaFunctionError(err.c_str());
251+
throw LuaFunctionError(err.c_str(), false);
252252
}
253253

254254
host = PathJoin(g_pGame->GetConfig()->GetGlobalDatabasesPath(), host);
@@ -259,15 +259,16 @@ std::variant<CDatabaseConnectionElement*, bool> CLuaDatabaseDefs::DbConnect(lua_
259259

260260
// Parse path
261261
CResource* pathResource = resource;
262-
if (CResourceManager::ParseResourcePathInput(host, pathResource, &absPath))
262+
if (!CResourceManager::ParseResourcePathInput(host, pathResource, &absPath))
263263
{
264-
host = absPath;
265-
auto [status, err] = CheckCanModifyOtherResource(resource, pathResource);
266-
if (!status)
267-
throw LuaFunctionError(err.c_str());
264+
SString err("host path %s not found", host.c_str());
265+
throw LuaFunctionError(err.c_str(), false);
268266
}
269-
SString err("host path %s not found", host.c_str());
270-
throw LuaFunctionError(err.c_str());
267+
268+
host = absPath;
269+
auto [status, err] = CheckCanModifyOtherResource(resource, pathResource);
270+
if (!status)
271+
throw LuaFunctionError(err.c_str(), false);
271272
}
272273
}
273274

@@ -338,7 +339,7 @@ std::variant<CDatabaseConnectionElement*, bool> CLuaDatabaseDefs::DbConnect(lua_
338339
type, host, *username, *password, *options
339340
);
340341
if (connection == INVALID_DB_HANDLE)
341-
throw LuaFunctionError(g_pGame->GetDatabaseManager()->GetLastErrorMessage().c_str());
342+
throw LuaFunctionError(g_pGame->GetDatabaseManager()->GetLastErrorMessage().c_str(), false);
342343

343344
return CreateConnection(resource, connection);
344345
}

Shared/sdk/SharedUtil.Misc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,12 @@ namespace SharedUtil
745745

746746
std::string Get(const char*& inCmd) const noexcept;
747747
bool Get(const char*& inCmd, std::string& out, const char* defaultValue = "") const noexcept;
748-
bool Get(const char*& inCmd, std::vector<std::string>& outList) const noexcept;
748+
bool Get(const char*& inCmd, std::vector<std::string>& outList) const;
749749
bool Get(const char*& inCmd, int& value, int defaultValue = 0) const noexcept;
750750

751751
std::string Get(const std::string& inCmd) const noexcept;
752752
bool Get(const std::string& inCmd, std::string& out, const char* defaultValue = "") const noexcept;
753-
bool Get(const std::string& inCmd, std::vector<std::string>& outList) const noexcept;
753+
bool Get(const std::string& inCmd, std::vector<std::string>& outList) const;
754754
bool Get(const std::string& inCmd, int& value, int defaultValue = 0) const noexcept;
755755

756756
bool Get(const SString& strInCmd, SString& strOut, const char* szDefault = "") const; // First result as string
@@ -873,7 +873,7 @@ namespace SharedUtil
873873
{
874874
std::string temp;
875875
GetOption<T>(text, key, temp);
876-
numbers = temp;
876+
numbers = std::move(temp);
877877
}
878878
std::vector<SString> numberList;
879879
numbers.Split(separator, numberList);

Shared/sdk/SharedUtil.Misc.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ namespace SharedUtil
17511751
return Get(std::string(inCmd), out, defaultValue);
17521752
}
17531753

1754-
bool CArgMap::Get(const char*& inCmd, std::vector<std::string>& outList) const noexcept
1754+
bool CArgMap::Get(const char*& inCmd, std::vector<std::string>& outList) const
17551755
{
17561756
return Get(std::string(inCmd), outList);
17571757
}
@@ -1781,7 +1781,7 @@ namespace SharedUtil
17811781
return false;
17821782
}
17831783

1784-
bool CArgMap::Get(const std::string& inCmd, std::vector<std::string>& outList) const noexcept
1784+
bool CArgMap::Get(const std::string& inCmd, std::vector<std::string>& outList) const
17851785
{
17861786
std::vector<SString> newItems;
17871787
MultiFind(m_Map, Escape(inCmd), &newItems);

0 commit comments

Comments
 (0)