Project

General

Profile

Actions

Bug #13872

open

Error accessing default template when trying to disable build mode with a normal user

Added by Julien Pivotto about 8 years ago. Updated about 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Organizations and Locations
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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

production.log production.log 15.8 KB Julien Pivotto, 02/24/2016 06:15 AM
Actions #1

Updated by Julien Pivotto about 8 years ago

Actions #2

Updated by Julien Pivotto about 8 years ago

  • Description updated (diff)
Actions #3

Updated by Julien Pivotto about 8 years ago

  • Category set to API
Actions #4

Updated by Julien Pivotto about 8 years ago

  • Description updated (diff)
Actions #5

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)
Actions #6

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.

Actions #7

Updated by Julien Pivotto about 8 years ago

Yes.

And it is not accessible by that user because not associated with any location/org.

Actions #8

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
Actions #9

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".

Actions #10

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
Actions #11

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

Actions

Also available in: Atom PDF