chiark / gitweb /
dev-setup: allow a path prefix for use in chroots
[elogind.git] / src / shared / label.c
index e13eba65501ef7f0264a96a9643b217c6aca816c..7aa362106e39871077a6d1e6c47d27e41bd2bf17 100644 (file)
@@ -99,7 +99,7 @@ int label_init(const char *prefix) {
         return r;
 }
 
-int label_fix(const char *path, bool ignore_enoent) {
+int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
         int r = 0;
 
 #ifdef HAVE_SELINUX
@@ -132,6 +132,9 @@ int label_fix(const char *path, bool ignore_enoent) {
                 if (ignore_enoent && errno == ENOENT)
                         return 0;
 
+                if (ignore_erofs && errno == EROFS)
+                        return 0;
+
                 log_full(security_getenforce() == 1 ? LOG_ERR : LOG_DEBUG,
                          "Unable to fix label of %s: %m", path);
                 r = security_getenforce() == 1 ? -errno : 0;
@@ -263,15 +266,14 @@ void label_free(const char *label) {
 #endif
 }
 
-int label_mkdir(const char *path, mode_t mode) {
+int label_mkdir(const char *path, mode_t mode, bool apply) {
 
         /* Creates a directory and labels it according to the SELinux policy */
-
 #ifdef HAVE_SELINUX
         int r;
         security_context_t fcon = NULL;
 
-        if (!use_selinux() || !label_hnd)
+        if (!apply || !use_selinux() || !label_hnd)
                 goto skipped;
 
         if (path_is_absolute(path))