Project

General

Profile

Bug #24159

Non admin user failed to render included template

Added by Ranjan Kumar 12 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Team Backlog:
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.

Associated revisions

Revision 211b941a (diff)
Added by Ranjan Kumar 11 months ago

Fixes #24159 - Non admin user failed to render included template

Revision 61dd73a1 (diff)
Added by Adam Ruzicka 11 months ago

Refs #24159 - Tests for nested template rendering

History

#1 Updated by The Foreman Bot 12 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman_remote_execution/pull/364 added

#2 Updated by Ranjan Kumar 11 months ago

  • Bugzilla link set to 1602810

#3 Updated by Adam Ruzicka 11 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF