Bug 2137965

Summary: restorecon `-i` flag has no effect when the parent dir is also missing
Product: Red Hat Enterprise Linux 8 Reporter: lingwangneuraleng
Component: libselinuxAssignee: Vit Mojzis <vmojzis>
Status: CLOSED ERRATA QA Contact: Amith <apeetham>
Severity: low Docs Contact:
Priority: low    
Version: 8.6CC: ahumbe, chhuang, dwalsh, lvrabec, mmalik, plautrba, vmojzis
Target Milestone: rcKeywords: AutoVerified, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libselinux-2.9-8.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2152116 (view as bug list) Environment:
Last Closed: 2023-05-16 09:10:48 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:
Bug Depends On:    
Bug Blocks: 2152116    

Description lingwangneuraleng 2022-10-26 18:22:25 UTC
Description of problem:
The `-i` can ignore missing files if the parent dirs exist. However, if the parent dir does not exist it still report `No such file or direectory`


Version-Release number of selected component (if applicable):

rpm -qf /sbin/restorecon
policycoreutils-2.9-19.el8.x86_64


How reproducible:

```
$ restorecon -i -v -R /var/log/missingfile; echo $?
0
$ restorecon -i -v -R /var/log/missingdir/missingfile; echo $?
255
restorecon: SELinux: Could not get canonical path for /var/log/missingdir/missingfile restorecon: No such file or directory.
```

Actual results:
exit with 255

Expected results:
should just be fine exit with 0

Additional info:

Comment 13 errata-xmlrpc 2023-05-16 09:10:48 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 (libselinux bug fix and enhancement update), 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/RHBA-2023:3023