Bug 1136282

Summary: `foreman-rake bootdisk:generate:generic` fails with: Permission denied - bootdisk_<fqdn>.iso
Product: Red Hat Satellite Reporter: Jan Hutař <jhutar>
Component: ProvisioningAssignee: Dominic Cleal <dcleal>
Status: CLOSED ERRATA QA Contact: Tazim Kolhar <tkolhar>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.3CC: bbuckingham, cwelton, lzap, mmccune, sghai, sthirugn, tkolhar
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/7370
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-12 05:15:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Hutař 2014-09-02 09:33:24 UTC
Description of problem:
`foreman-rake bootdisk:generate:generic` fails with: "Permission denied - bootdisk_<fqdn>.iso"


Version-Release number of selected component (if applicable):
Satellite-6.0.4-RHEL-6-20140829.0


How reproducible:
always


Steps to Reproduce:
1. Take an empty Satellite 6
2. foreman-rake bootdisk:generate:generic --trace


Actual results:
# foreman-rake bootdisk:generate:generic --trace
** Invoke bootdisk:generate:generic (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute bootdisk:generate:generic
Size of boot image is 4 sectors -> No emulation
Total translation table size: 2048
Total rockridge attributes bytes: 0
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
339 extents written (0 MB)
rake aborted!
Permission denied - bootdisk_<fqdn>.iso
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1371:in `initialize'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1371:in `open'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1371:in `block in copy_file'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1370:in `open'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1370:in `copy_file'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:477:in `copy_file'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:396:in `block in cp'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1515:in `block in fu_each_src_dest'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1531:in `fu_each_src_dest0'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:1513:in `fu_each_src_dest'
/opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:395:in `cp'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_bootdisk-2.0.6/lib/tasks/bootdisk.rake:21:in `block (4 levels) in <top (required)>'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_bootdisk-2.0.6/app/services/bootdisk/iso_generator.rb:42:in `block in generate'
/opt/rh/ruby193/root/usr/share/ruby/tmpdir.rb:83:in `mktmpdir'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_bootdisk-2.0.6/app/services/bootdisk/iso_generator.rb:12:in `generate'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_bootdisk-2.0.6/lib/tasks/bootdisk.rake:19:in `block (3 levels) in <top (required)>'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `call'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `block in execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in `block in invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in `invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in `invoke'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in `invoke_task'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block (2 levels) in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in `top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in `block in run'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in `run'
/opt/rh/ruby193/root/usr/bin/rake:32:in `<main>'
Tasks: TOP => bootdisk:generate:generic


Expected results:
Usable ISO should be generated

Comment 2 Jan Hutař 2014-09-02 09:35:21 UTC
Sorry, expected result (due to fact we are on Sat6 without any repos synced) should be some reasonable error message. ISO can not be generated because we do not have the content.

Comment 3 Lukas Zapletal 2014-09-02 13:21:38 UTC
I can confirm, this is because foreman-rake runs as "foreman" effective user. Unfortunately changing to /tmp does not help, it looks like it wants to create some kind of temporary file somewhere. We should respect the $PWD when copying the file.

Workaround:

[root@dell-pe2950-01 ~]# foreman-rake bootdisk:generate:generic OUTPUT=/tmp/my.iso
Size of boot image is 4 sectors -> No emulation
Total translation table size: 2048
Total rockridge attributes bytes: 0
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
339 extents written (0 MB)
Wrote /tmp/my.iso

Comment 4 Mike McCune 2014-09-02 19:19:33 UTC
WORKAROUND:

User should specify an output directory on where to write the ISO file where the foreman user has permission to write to. A good example of this is /tmp

Comment 5 Dominic Cleal 2014-09-08 07:40:56 UTC
Created redmine issue http://projects.theforeman.org/issues/7370 from this bug

Comment 6 Bryan Kearney 2014-10-03 12:05:49 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7370 has been closed
-------------
Dominic Cleal
Applied in changeset commit:foreman_bootdisk|c010a67fada33276da4dd9164d6580f16d476904.

Comment 9 Tazim Kolhar 2015-03-09 12:12:47 UTC
VERIFIED:

# foreman-rake bootdisk:generate:generic --trace
** Invoke bootdisk:generate:generic (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute bootdisk:generate:generic
Size of boot image is 4 sectors -> No emulation
Total translation table size: 2048
Total rockridge attributes bytes: 0
Total directory bytes: 290
Path table size(bytes): 10
Max brk space used 0
339 extents written (0 MB)
Wrote /tmp/bootdisk_2365076133.dom.com.iso

Comment 10 Bryan Kearney 2015-08-11 13:37:37 UTC
This bug is slated to be released with Satellite 6.1.

Comment 11 errata-xmlrpc 2015-08-12 05:15:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2015:1592