Bug #13872
openError accessing default template when trying to disable build mode with a normal user
Description
$ curl -s -k -u jenkins:pass -H Content-Type:application/json -H Accept:version=2,application/json -X PUT -d '{"build":false}' https://foreman.example.lab/api/hosts/fna060.be.example.lab { "error": {"id":435,"errors":{"base":["Failed to generate PXELinux template: undefined method `encoding' for nil:NilClass"]},"full_messages":["Failed to generate PXELinux template: undefined method `encoding' for nil:NilClass"]} }Additional infos:
- jenkins is a non admin user
- '{"build":true}' works to put the host in build mode
- At the end the host is still in build mode
- It is broken in the webui as well
Files
Updated by Julien Pivotto about 8 years ago
- File production.log production.log added
- Description updated (diff)
Updated by Julien Pivotto about 8 years ago
- Subject changed from Error when trying to disable build mode via the API to Error when trying to disable build mode with a normal user
- Description updated (diff)
- Category deleted (
API)
Updated by Dominic Cleal about 8 years ago
Do you have a template named (precisely) "PXELinux default local boot"? If using orgs/locs, it may need to be accessible to the jenkins user too.
Updated by Julien Pivotto about 8 years ago
Yes.
And it is not accessible by that user because not associated with any location/org.
Updated by Dominic Cleal about 8 years ago
- Subject changed from Error when trying to disable build mode with a normal user to Error accessing default template when trying to disable build mode with a normal user
- Category set to Organizations and Locations
Updated by Julien Pivotto about 8 years ago
- Subject changed from Error accessing default template when trying to disable build mode with a normal user to Error when trying to disable build mode with a normal user
- Category deleted (
Organizations and Locations)
Fixed, thanks Dominic.
Not sure if this is a bug or not, but I would have expected that a user would have been able to disable build on a host "out of the box".
Updated by Julien Pivotto about 8 years ago
- Subject changed from Error when trying to disable build mode with a normal user to Error accessing default template when trying to disable build mode with a normal user
- Category set to Organizations and Locations
Updated by Dominic Cleal about 8 years ago
No problem. It's definitely a bug, the user shouldn't need direct permissions to view those templates as they're hard-coded. It can probably be fixed just by using ProvisioningTemplate.unscoped
over at https://github.com/theforeman/foreman/blob/1.10.2/app/models/concerns/orchestration/tftp.rb#L48-L50 which will avoid orgs/locs entirely.
The code should probably be more defensive if they're missing so as not to get the 'encoding' related error, e.g. https://github.com/theforeman/foreman/blob/1.10.2/app/models/provisioning_template.rb#L116