Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,24 @@ public CreateEntityDownloadURLAnswer handleCreateEntityURLCommand(CreateEntityDo
// Create the directory structure so that its visible under apache server root
String extractDir = BASE_EXTRACT_PATH;
extractDir = extractDir + cmd.getFilepathInExtractURL() + File.separator;
// Ensure the base extract directory exists and is owned by www-data so that
// the www-data user can create the per-entity subdirectory inside it.
Script baseDirCommand = new Script("/bin/bash", logger);
baseDirCommand.add("-c");
baseDirCommand.add("mkdir -p " + BASE_EXTRACT_PATH + " && chown www-data:www-data " + BASE_EXTRACT_PATH);
String result = baseDirCommand.execute();
if (result != null) {
String errorString = "Error in creating base extract directory =" + result;
logger.error(errorString);
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
}
Script command = new Script("/bin/su", logger);
command.add("-s");
command.add("/bin/bash");
command.add("-c");
command.add("mkdir -p " + extractDir);
command.add("www-data");
String result = command.execute();
result = command.execute();
if (result != null) {
String errorString = "Error in creating directory =" + result;
logger.error(errorString);
Expand Down