Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-30090 Find Dropzone plane using host and path when spraying #17676

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions esp/services/ws_fs/ws_fsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1945,15 +1945,8 @@ void CFileSprayEx::readAndCheckSpraySourceReq(IEspContext& context, MemoryBuffer
if (!sourceIPReq.isEmpty() && !isHostInPlane(dropZone, sourceIPReq, true))
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "SourceIP '%s' is not defined within the dropzone %s.", sourceIPReq.str(), dropZone->queryProp("@name"));
}
else
{
if (sourceIPReq.isEmpty())
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Source network IP not specified.");
dropZone.setown(findDropZonePlane(nullptr, sourceIPReq, true, isContainerized()));
if (dropZone)
sourcePlaneReq.append(dropZone->queryProp("@name"));
// else - only possible if bare-metal and isDropZoneRestrictionEnabled()==false
}
else if (sourceIPReq.isEmpty())
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Source network IP not specified.");

SocketEndpoint sourceHostEp(sourceIPReq);

Expand All @@ -1978,7 +1971,16 @@ void CFileSprayEx::readAndCheckSpraySourceReq(IEspContext& context, MemoryBuffer
SocketEndpoint hostInPathEp(hostInPath);
if (!sourceIPReq.isEmpty() && !sourceHostEp.ipequals(hostInPathEp))
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "The host '%s' defined in the SourcePath '%s' does not match with the host '%s' defined in SourceIP.", hostInPath.str(), file, sourceIPReq.str());
if (dropZone)
if (!dropZone)
{
if (i == 0)
{
dropZone.setown(getAndValidateDropZone(localPath, hostInPath));
if (dropZone)
sourcePlaneReq.append(dropZone->queryProp("@name"));
}
}
else
{
// don't re-check if sourceIPReq specified and therefore already checked valid previously.
if (sourceIPReq.isEmpty())
Expand All @@ -1989,7 +1991,6 @@ void CFileSprayEx::readAndCheckSpraySourceReq(IEspContext& context, MemoryBuffer
if (!isPathInPlane(dropZone, localPath))
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Path '%s' in '%s' is not valid for dropzone '%s'", localPath.str(), file, dropZone->queryProp("@name"));
}
// else implies bare-metal+restrictions off - sourceIPReq cannot be empty, if no dropzone.

path = localPath.str();
}
Expand All @@ -1998,11 +1999,29 @@ void CFileSprayEx::readAndCheckSpraySourceReq(IEspContext& context, MemoryBuffer
path = file;
if (isAbsolutePath(path))
{
if (dropZone && !isPathInPlane(dropZone, path))
if (!dropZone)
{
if (i == 0)
{
dropZone.setown(getAndValidateDropZone(path, sourceIPReq));
if (dropZone)
sourcePlaneReq.append(dropZone->queryProp("@name"));
}
}
else if (!isPathInPlane(dropZone, path))
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Path '%s' is not valid for dropzone '%s'", path, sourcePlaneReq.str());
}
else
{
if (!dropZone && (i == 0))
{
//The sourceIPReq should must have been supplied here. This has been verified if
//the sourcePlaneReq is empty. When the sourcePlaneReq is not empty, the dropZone
//should not be null. Otherwise, an exception should already be thrown.
dropZone.setown(getAndValidateDropZone(nullptr, sourceIPReq));
if (dropZone)
sourcePlaneReq.append(dropZone->queryProp("@name"));
}
if (dropZone) // force paths to absolute, for LDAP checking below
{
absPath.set(dropZone->queryProp("@prefix"));
Expand Down
Loading