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-30868 Report dropzone name and scope when scope access denied #18371

Merged
merged 1 commit into from
Mar 7, 2024
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
16 changes: 12 additions & 4 deletions dali/dfu/dfurun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,19 @@ class CDFUengine: public CInterface, implements IDFUengine
return result;
}

void ensureFilePermissions(const char * fileName, SecAccessFlags perm, bool write)
void ensureFilePermissions(const char * planeName, const char * fileName, SecAccessFlags perm, bool write)
{
if ((write && !HASWRITEPERMISSION(perm)) || (!write && !HASREADPERMISSION(perm)))
{
if (!isEmptyString(planeName))
{
CDfsLogicalFileName dlfn;
dlfn.setPlaneExternal(planeName, fileName);
if (write)
throw makeStringExceptionV(DFSERR_CreateAccessDenied, "Create permission denied for file scope: %s on DropZone: %s", dlfn.get(), planeName);
else
throw makeStringExceptionV(DFSERR_LookupAccessDenied, "Lookup permission denied for file scope: %s on DropZone: %s", dlfn.get(), planeName);
}
if (write)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personal: since the above block can never fall through, this is really an else if (coding as such would clarify at a glance).

throw makeStringExceptionV(DFSERR_CreateAccessDenied, "Create permission denied for physical file(s): %s", fileName);
else
Expand Down Expand Up @@ -614,7 +623,7 @@ class CDFUengine: public CInterface, implements IDFUengine

SecAccessFlags perm = queryDistributedFileDirectory().getFDescPermissions(fd,user,auditflags);
StringBuffer name;
ensureFilePermissions(getFDescName(fd,name),perm,write);
ensureFilePermissions(nullptr,getFDescName(fd,name),perm,write);
}

void checkForeignFilePermissions(IConstDFUfileSpec *fSpec,IFileDescriptor *fd,IUserDescriptor *user)
Expand Down Expand Up @@ -688,6 +697,7 @@ class CDFUengine: public CInterface, implements IDFUengine
{
if (getGlobalConfigSP()->getPropBool("expert/@failOverToLegacyPhysicalPerms",!isContainerized()))
perm = queryDistributedFileDirectory().getFDescPermissions(fd,user,auditflags);
ensureFilePermissions(planeName,relativePath,perm,write);
}
}
else
Expand All @@ -702,8 +712,6 @@ class CDFUengine: public CInterface, implements IDFUengine
throw makeStringException(-1,"Unexpected empty plane name."); // should never be the case in containerized setups
#endif
}
StringBuffer name;
ensureFilePermissions(getFDescName(fd,name),perm,write);
}

void monitorCycle(bool &cancelling)
Expand Down
Loading