Project

General

Profile

Actions

Bug #24159

closed

Non admin user failed to render included template

Added by Ranjan Kumar over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

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.

Actions #1

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

Updated by Ranjan Kumar over 5 years ago

  • Bugzilla link set to 1602810
Actions #3

Updated by Adam Ruzicka over 5 years ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF