[RFC PATCH 8/9] restorecond: check selinux_restorecon(3) for failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    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@xxxxxxxxxxxxxx>
---
 restorecond/watch.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/restorecond/watch.c b/restorecond/watch.c
index 98ff797b..64bc29c6 100644
--- a/restorecond/watch.c
+++ b/restorecond/watch.c
@@ -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;
 			}
-- 
2.40.1




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux