[PATCH v2] storage: support all file permissions

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

 



sticky, setuid and setgid are no longer ignored.

---
v2: reading these permissions from XML works too
---
 src/conf/storage_conf.c       |    9 ++++++---
 src/storage/storage_backend.c |    3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 7944555..0335f99 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -665,7 +665,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
     } else {
         int tmp;
 
-        if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || (tmp & ~0777)) {
+        if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 ||
+            (tmp & ~(S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO))) {
             VIR_FREE(mode);
             virReportError(VIR_ERR_XML_ERROR,
                            "%s", _("malformed octal mode"));
@@ -1035,7 +1036,8 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def) {
 
         virBufferAddLit(&buf,"    <permissions>\n");
         virBufferAsprintf(&buf,"      <mode>0%o</mode>\n",
-                          def->target.perms.mode);
+                          def->target.perms.mode &
+                          (S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO));
         virBufferAsprintf(&buf,"      <owner>%u</owner>\n",
                           (unsigned int) def->target.perms.uid);
         virBufferAsprintf(&buf,"      <group>%u</group>\n",
@@ -1275,7 +1277,8 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
 
     virBufferAddLit(buf,"    <permissions>\n");
     virBufferAsprintf(buf,"      <mode>0%o</mode>\n",
-                      def->perms.mode);
+                      def->perms.mode &
+                      (S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO));
     virBufferAsprintf(buf,"      <owner>%u</owner>\n",
                       (unsigned int) def->perms.uid);
     virBufferAsprintf(buf,"      <group>%u</group>\n",
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index e677cda..e9ec7a5 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1210,7 +1210,8 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
         }
     }
 
-    target->perms.mode = sb.st_mode & S_IRWXUGO;
+    target->perms.mode = sb.st_mode &
+                         (S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO);
     target->perms.uid = sb.st_uid;
     target->perms.gid = sb.st_gid;
 
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]