@@ -71,8 +71,12 @@ void watch_list_add(int fd, const char *path)
if (len > 0 &&
strcmp(&globbuf.gl_pathv[i][len], "/..") == 0)
continue;
- selinux_restorecon(globbuf.gl_pathv[i],
- r_opts.restorecon_flags);
+
+ if (selinux_restorecon(globbuf.gl_pathv[i], r_opts.restorecon_flags) < 0) {
+ if (errno != ENOENT)
+ syslog(LOG_ERR, "Unable to relabel %s: %s\n",
+ globbuf.gl_pathv[i], strerror(errno));
+ }
}
globfree(&globbuf);
}
@@ -138,8 +142,12 @@ int watch_list_find(int wd, const char *file)
0)
exitApp("Error allocating memory.");
- selinux_restorecon(path,
- r_opts.restorecon_flags);
+ if (selinux_restorecon(path, r_opts.restorecon_flags) < 0) {
+ if (errno != ENOENT)
+ syslog(LOG_ERR, "Unable to relabel %s: %s\n",
+ path, strerror(errno));
+ }
+
free(path);
return 0;
}
watch.c: In function ‘watch_list_add’: watch.c:74:25: error: ignoring return value of ‘selinux_restorecon’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 74 | selinux_restorecon(globbuf.gl_pathv[i], | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 75 | r_opts.restorecon_flags); | ~~~~~~~~~~~~~~~~~~~~~~~~ watch.c: In function ‘watch_list_find’: watch.c:141:33: error: ignoring return value of ‘selinux_restorecon’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 141 | selinux_restorecon(path, | ^~~~~~~~~~~~~~~~~~~~~~~~ 142 | r_opts.restorecon_flags); | ~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche <cgzones@googlemail.com> --- restorecond/watch.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)