Bug 748498

Summary: restorecon -o <file> does not seem to work
Product: [Fedora] Fedora Reporter: Yaniv Kaul <ykaul>
Component: policycoreutilsAssignee: Daniel Walsh <dwalsh>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: dwalsh, jkt, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-08 17:51:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Yaniv Kaul 2011-10-24 15:44:17 UTC
Description of problem:
In the hope that I'm not doing something wrong, I was trying to use the '-o' option of restorecon so it'll write to file what may be wrong with my selinux context. However, this fails:
[ykaul@ykaul ~]$ restorecon * -o /tmp/test.txt
Error opening /tmp/test.txt: Permission denied
usage:  restorecon [-iFnprRv0] [ -L labelprefix ] [-e excludedir ] [-o filename ] [-f filename | pathname... ]
[ykaul@ykaul ~]$ touch /tmp/test.txt
[ykaul@ykaul ~]$ restorecon * -o /tmp/test.txt
Error opening /tmp/test.txt: Permission denied
usage:  restorecon [-iFnprRv0] [ -L labelprefix ] [-e excludedir ] [-o filename ] [-f filename | pathname... ]
[ykaul@ykaul ~]$ sudo restorecon * -o /tmp/test.txt
Error opening /tmp/test.txt: Permission denied
usage:  restorecon [-iFnprRv0] [ -L labelprefix ] [-e excludedir ] [-o filename ] [-f filename | pathname... ]
[ykaul@ykaul ~]$ rpm -qf `which restorecon`
policycoreutils-2.1.4-3.fc16.x86_64

strace (of a different run than above) shows:

open("./test.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 EACCES (Permission denied)
write(2, "Error opening ./test.txt: Permis"..., 44Error opening ./test.txt: Permission denied
) = 44


Version-Release number of selected component (if applicable):
policycoreutils-2.1.4-3.fc16.x86_64

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Daniel Walsh 2011-10-24 15:57:21 UTC
Well depending on where you told it to write, it is being denied.

I would not use the -o command and just redirect stdout.

restorecon -R * > /tmp/test

Comment 2 Yaniv Kaul 2011-10-24 16:20:19 UTC
(In reply to comment #1)
> Well depending on where you told it to write, it is being denied.

I couldn't get it to write to anywhere, while as the user (or root) I was able to write to those files in those locations.

> 
> I would not use the -o command and just redirect stdout.

So lets deprecate it. And remove it from the man page.

> 
> restorecon -R * > /tmp/test

Comment 3 Fedora End Of Life 2013-01-16 13:26:09 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Daniel Walsh 2013-02-08 17:51:56 UTC
Deprecated in policycoreutils-2.1.14-2.fc19