In commit 36f1ccbb574374 ("policycoreutils: setfiles: print error if
no default label found"), a warning message was added to setfiles/restorecon
if the user explicitly does a restorecon /path/to/foo and
/path/to/foo does not have any matching label in file_contexts; in the
case of a restorecon -R or setfiles, the warning isn't supposed to be
logged.  The check on the recursive flag got dropped when this logic was
taken into selinux_restorecon(3) in libselinux.  Restore this check so
that we do not generate noisy log messages on restorecon -R or setfiles.

Reported-by: Alan Jenkins <>
Signed-off-by: Stephen Smalley <>
 libselinux/src/selinux_restorecon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libselinux/src/selinux_restorecon.c 
index e38d1d0..f5fa8f5 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -613,7 +613,7 @@ static int restorecon_sb(const char *pathname, const struct 
stat *sb,
        if (rc < 0) {
-               if (errno == ENOENT && flags->verbose)
+               if (errno == ENOENT && flags->verbose && !flags->recurse)
                                    "Warning no default label for %s\n",

Selinux mailing list
To unsubscribe, send email to
To get help, send an email containing "help" to

Reply via email to