Either `setfiles` should not abort when it's not not able to set a new context, or it should provide an option which would on suppress aborting on labeling errors.
$ mkdir -p r/1/1 r/1/2
$ sudo chown root: r/1/2
$ mkdir -p r/2/1 r/2/2
$ setfiles -v -r r /etc/selinux/targeted/contexts/files/file_contexts r
Relabeled r from unconfined_u:object_r:user_tmp_t:s0 to unconfined_u:object_r:root_t:s0
Relabeled r/1 from unconfined_u:object_r:user_tmp_t:s0 to unconfined_u:object_r:default_t:s0
Relabeled r/1/1 from unconfined_u:object_r:user_tmp_t:s0 to unconfined_u:object_r:default_t:s0
setfiles: Could not set context for r/1/2: Operation not permitted
See https://bugzilla.redhat.com/show_bug.cgi?id=1794518 for more details
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 (policycoreutils 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.