mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
storage: unify permission formatting
Volume and pool formatting functions took different approaches to unspecified uids/gids. When unknown, it is always parsed as -1, but one of the functions formatted it as unsigned int (wrong) and one as int (better). Due to that, our two of our XML files from tests cannot be parsed on 32-bit machines. RNG schema needs to be modified as well, but because both storagepool.rng and storagevol.rng need same schema for permission element, save some space by moving it to storagecommon.rng. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
e3435caf6a
commit
d2632d60aa
@ -93,4 +93,33 @@
|
||||
<notAllowed/>
|
||||
</define>
|
||||
|
||||
<define name='permissions'>
|
||||
<optional>
|
||||
<element name='permissions'>
|
||||
<interleave>
|
||||
<element name='mode'>
|
||||
<ref name='octalMode'/>
|
||||
</element>
|
||||
<element name='owner'>
|
||||
<choice>
|
||||
<ref name='unsignedInt'/>
|
||||
<value>-1</value>
|
||||
</choice>
|
||||
</element>
|
||||
<element name='group'>
|
||||
<choice>
|
||||
<ref name='unsignedInt'/>
|
||||
<value>-1</value>
|
||||
</choice>
|
||||
</element>
|
||||
<optional>
|
||||
<element name='label'>
|
||||
<text/>
|
||||
</element>
|
||||
</optional>
|
||||
</interleave>
|
||||
</element>
|
||||
</optional>
|
||||
</define>
|
||||
|
||||
</grammar>
|
||||
|
@ -3,6 +3,7 @@
|
||||
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
|
||||
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
||||
<include href='basictypes.rng'/>
|
||||
<include href='storagecommon.rng'/>
|
||||
<start>
|
||||
<ref name='pool'/>
|
||||
</start>
|
||||
@ -224,35 +225,6 @@
|
||||
</interleave>
|
||||
</define>
|
||||
|
||||
<define name='permissions'>
|
||||
<optional>
|
||||
<element name='permissions'>
|
||||
<interleave>
|
||||
<element name='mode'>
|
||||
<ref name='octalMode'/>
|
||||
</element>
|
||||
<element name='owner'>
|
||||
<choice>
|
||||
<ref name='unsignedInt'/>
|
||||
<value>-1</value>
|
||||
</choice>
|
||||
</element>
|
||||
<element name='group'>
|
||||
<choice>
|
||||
<ref name='unsignedInt'/>
|
||||
<value>-1</value>
|
||||
</choice>
|
||||
</element>
|
||||
<optional>
|
||||
<element name='label'>
|
||||
<text/>
|
||||
</element>
|
||||
</optional>
|
||||
</interleave>
|
||||
</element>
|
||||
</optional>
|
||||
</define>
|
||||
|
||||
<define name='target'>
|
||||
<element name='target'>
|
||||
<interleave>
|
||||
|
@ -59,29 +59,6 @@
|
||||
</interleave>
|
||||
</define>
|
||||
|
||||
<define name='permissions'>
|
||||
<optional>
|
||||
<element name='permissions'>
|
||||
<interleave>
|
||||
<element name='mode'>
|
||||
<ref name='octalMode'/>
|
||||
</element>
|
||||
<element name='owner'>
|
||||
<ref name='unsignedInt'/>
|
||||
</element>
|
||||
<element name='group'>
|
||||
<ref name='unsignedInt'/>
|
||||
</element>
|
||||
<optional>
|
||||
<element name='label'>
|
||||
<text/>
|
||||
</element>
|
||||
</optional>
|
||||
</interleave>
|
||||
</element>
|
||||
</optional>
|
||||
</define>
|
||||
|
||||
<define name='timestamps'>
|
||||
<optional>
|
||||
<element name='timestamps'>
|
||||
|
@ -1203,7 +1203,6 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
|
||||
(int) def->target.perms.uid);
|
||||
virBufferAsprintf(&buf, "<group>%d</group>\n",
|
||||
(int) def->target.perms.gid);
|
||||
|
||||
virBufferEscapeString(&buf, "<label>%s</label>\n",
|
||||
def->target.perms.label);
|
||||
|
||||
@ -1527,10 +1526,10 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
||||
|
||||
virBufferAsprintf(buf, "<mode>0%o</mode>\n",
|
||||
def->perms->mode);
|
||||
virBufferAsprintf(buf, "<owner>%u</owner>\n",
|
||||
(unsigned int) def->perms->uid);
|
||||
virBufferAsprintf(buf, "<group>%u</group>\n",
|
||||
(unsigned int) def->perms->gid);
|
||||
virBufferAsprintf(buf, "<owner>%d</owner>\n",
|
||||
(int) def->perms->uid);
|
||||
virBufferAsprintf(buf, "<group>%d</group>\n",
|
||||
(int) def->perms->gid);
|
||||
|
||||
|
||||
virBufferEscapeString(buf, "<label>%s</label>\n",
|
||||
|
17
tests/storagevolxml2xmlin/vol-gluster-dir-neg-uid.xml
Normal file
17
tests/storagevolxml2xmlin/vol-gluster-dir-neg-uid.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<volume type='netdir'>
|
||||
<name>dir</name>
|
||||
<key>vol/dir</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>0</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
<path>gluster://example.com/vol/dir</path>
|
||||
<format type='dir'/>
|
||||
<permissions>
|
||||
<mode>0600</mode>
|
||||
<owner>4294967295</owner>
|
||||
<group>4294967295</group>
|
||||
</permissions>
|
||||
</target>
|
||||
</volume>
|
17
tests/storagevolxml2xmlout/vol-gluster-dir-neg-uid.xml
Normal file
17
tests/storagevolxml2xmlout/vol-gluster-dir-neg-uid.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<volume type='netdir'>
|
||||
<name>dir</name>
|
||||
<key>vol/dir</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>0</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
<path>gluster://example.com/vol/dir</path>
|
||||
<format type='dir'/>
|
||||
<permissions>
|
||||
<mode>0600</mode>
|
||||
<owner>-1</owner>
|
||||
<group>-1</group>
|
||||
</permissions>
|
||||
</target>
|
||||
</volume>
|
@ -10,8 +10,8 @@
|
||||
<format type='dir'/>
|
||||
<permissions>
|
||||
<mode>0600</mode>
|
||||
<owner>4294967295</owner>
|
||||
<group>4294967295</group>
|
||||
<owner>-1</owner>
|
||||
<group>-1</group>
|
||||
</permissions>
|
||||
</target>
|
||||
</volume>
|
||||
|
@ -9,8 +9,8 @@
|
||||
<format type='unknown'/>
|
||||
<permissions>
|
||||
<mode>0600</mode>
|
||||
<owner>4294967295</owner>
|
||||
<group>4294967295</group>
|
||||
<owner>-1</owner>
|
||||
<group>-1</group>
|
||||
</permissions>
|
||||
</target>
|
||||
</volume>
|
||||
|
@ -122,6 +122,7 @@ mymain(void)
|
||||
DO_TEST("pool-logical", "vol-logical-backing");
|
||||
DO_TEST("pool-sheepdog", "vol-sheepdog");
|
||||
DO_TEST("pool-gluster", "vol-gluster-dir");
|
||||
DO_TEST("pool-gluster", "vol-gluster-dir-neg-uid");
|
||||
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user