Skip to content

Commit

Permalink
job_endpoint: Validate volume permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
endocrimes committed Aug 9, 2019
1 parent 2e7545e commit ce8951b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nomad/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis
if !aclObj.AllowNsOp(args.RequestNamespace(), acl.NamespaceCapabilitySubmitJob) {
return structs.ErrPermissionDenied
}
// Validate Volume Permsissions
for _, tg := range args.Job.TaskGroups {
for _, vol := range tg.Volumes {
if vol.Volume.Type != structs.VolumeTypeHost {
return structs.ErrPermissionDenied
}

cfg, err := structs.ParseHostVolumeConfig(vol.Config)
if err != nil {
return structs.ErrPermissionDenied
}

if !aclObj.AllowHostVolumeOperation(cfg.Source, acl.HostVolumeCapabilityMount) {
return structs.ErrPermissionDenied
}
}
}

// Check if override is set and we do not have permissions
if args.PolicyOverride {
if !aclObj.AllowNsOp(args.RequestNamespace(), acl.NamespaceCapabilitySentinelOverride) {
Expand Down

0 comments on commit ce8951b

Please sign in to comment.