Helper/Nix: constructRunCommandLogPath: take RunCommandLog as input
This way we ensure that it actually exists in the database, rather than blindly trusting user-generated input.
This commit is contained in:
@ -537,7 +537,8 @@ sub runcommandlog :Local :Args(1) {
|
||||
|
||||
die if defined $tail && $tail !~ /^[0-9]+$/;
|
||||
|
||||
my $logFile = constructRunCommandLogPath($uuid);
|
||||
my $runlog = $c->model('DB')->resultset('RunCommandLogs')->find({ uuid => $uuid });
|
||||
my $logFile = constructRunCommandLogPath($runlog);
|
||||
if (-f $logFile) {
|
||||
serveLogFile($c, $logFile, $tail);
|
||||
return;
|
||||
|
@ -591,12 +591,13 @@ sub isLocalStore {
|
||||
|
||||
|
||||
sub constructRunCommandLogPath {
|
||||
my ($filename) = @_;
|
||||
my ($runlog) = @_;
|
||||
|
||||
my $uuid = $runlog->uuid;
|
||||
my $hydra_path = Hydra::Model::DB::getHydraPath;
|
||||
my $bucket = substr($filename, 0, 2);
|
||||
my $bucket = substr($uuid, 0, 2);
|
||||
|
||||
return "$hydra_path/runcommand-logs/$bucket/$filename";
|
||||
return "$hydra_path/runcommand-logs/$bucket/$uuid";
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -163,7 +163,7 @@ sub buildFinished {
|
||||
|
||||
$runlog->started();
|
||||
|
||||
my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($runlog->uuid);
|
||||
my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($runlog);
|
||||
my $dir = dirname($logPath);
|
||||
my $oldUmask = umask();
|
||||
|
||||
|
Reference in New Issue
Block a user