Bug #24159
closedNon admin user failed to render included template
Description
Error Trace:
2018-07-05 16:18:43 2662b0da [app] [D] included template 'restorecon' not found
| /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-1.3.7.2/app/models/input_template_renderer.rb:64:in `render_template'
| /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode/scope.rb:37:in `method_missing'
| Unnamed:52:in `bind'
| /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode.rb:51:in `eval'
| /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.2/lib/safemode.rb:51:in `eval'
| /usr/share/foreman/lib/foreman/renderer.rb:56:in `render_safe'
Step to Reproduce:
1. Create a local user with Role "Remote Execution User" only. User name during my tests is rexuser.
2. Hosts > Job Templates > New Job Template
2.1. Name: restorecon
Default: ON
Template code is a single line with exactly this content:
restorecon -RvF <%= input("directory") %>
2.2. Job tab in the New Job Template form:
Job category: Commands
Click Add Input.
Template Input, Name: directory
Required: ON
Input type: User input
2.3. Add to all locations and orgs
2.4. Click Submit
3. Hosts > Job Templates > New Job Template
3.1. Name: renders restorecon
Default: ON
Template code is a single line with exactly this content:
<%= render_template('restorecon', :directory => '/etc/lvm') %>
3.2. Job tab in the New Job Template form:
Job category: Commands
3.3. Add to all locations and orgs
3.4. Click Submit
Now we have a new job template that calls the restorecon command on a given directory.
We also have a new job template that calls this ^^ job template passing it the /etc/lvm directory as argument.
4. Logout from admin, login as rexuser.
5. click Monitor > Jobs > Run Job
6.1. Job Category: Commands
Job template: renders restorecon
Add the same host to search query...
6.2. Click Submit.
6.3. FAILS with Warning! included template 'restorecon' not found. <=== but works fine under the admin user.
Updated by The Foreman Bot over 5 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman_remote_execution/pull/364 added
Updated by Adam Ruzicka over 5 years ago
- Status changed from Ready For Testing to Closed