mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Merge pull request #445 from vmlintu-nosto/mountpoint_permissions
Allow setting permissions on mountpoints
This commit is contained in:
commit
6b99432ac7
5 changed files with 30 additions and 0 deletions
|
@ -191,6 +191,7 @@ definitions:
|
||||||
minItems: 1
|
minItems: 1
|
||||||
type: array
|
type: array
|
||||||
size: {$ref: '#/definitions/bytes'}
|
size: {$ref: '#/definitions/bytes'}
|
||||||
|
mode: {type: string}
|
||||||
required: [size, filesystem]
|
required: [size, filesystem]
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
partition_table:
|
partition_table:
|
||||||
|
|
|
@ -76,6 +76,7 @@ mounting_group = [filesystem.CreateMountDir,
|
||||||
filesystem.MountRoot,
|
filesystem.MountRoot,
|
||||||
filesystem.MountAdditional,
|
filesystem.MountAdditional,
|
||||||
filesystem.MountSpecials,
|
filesystem.MountSpecials,
|
||||||
|
filesystem.ChmodMountDirs,
|
||||||
filesystem.CopyMountTable,
|
filesystem.CopyMountTable,
|
||||||
filesystem.RemoveMountTable,
|
filesystem.RemoveMountTable,
|
||||||
filesystem.UnmountRoot,
|
filesystem.UnmountRoot,
|
||||||
|
|
|
@ -127,6 +127,32 @@ class MountAdditional(Task):
|
||||||
p_map.root.add_mount(getattr(p_map, partition.name), partition.name, ['--options'] + partition.mountopts)
|
p_map.root.add_mount(getattr(p_map, partition.name), partition.name, ['--options'] + partition.mountopts)
|
||||||
|
|
||||||
|
|
||||||
|
class ChmodMountDirs(Task):
|
||||||
|
description = 'Chmod mount dirs'
|
||||||
|
phase = phases.volume_mounting
|
||||||
|
predecessors = [MountAdditional]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run(cls, info):
|
||||||
|
import os
|
||||||
|
from bootstrapvz.base.fs.partitions.unformatted import UnformattedPartition
|
||||||
|
from bootstrapvz.base.fs.partitions.single import SinglePartition
|
||||||
|
|
||||||
|
def has_mode(partition):
|
||||||
|
return (not isinstance(partition, (UnformattedPartition, SinglePartition)) and
|
||||||
|
'mode' in info.manifest.volume['partitions'][partition.name] and
|
||||||
|
info.manifest.volume['partitions'][partition.name]['mode'] is not None)
|
||||||
|
|
||||||
|
p_map = info.volume.partition_map
|
||||||
|
partitions = p_map.partitions
|
||||||
|
for partition in list(
|
||||||
|
filter(has_mode, partitions)):
|
||||||
|
partition = getattr(p_map, partition.name)
|
||||||
|
mode_str = info.manifest.volume['partitions'][partition.name]['mode']
|
||||||
|
mode = int(mode_str, 8)
|
||||||
|
os.chmod(os.path.join(info.root, partition.name), mode)
|
||||||
|
|
||||||
|
|
||||||
class MountSpecials(Task):
|
class MountSpecials(Task):
|
||||||
description = 'Mounting special block devices'
|
description = 'Mounting special block devices'
|
||||||
phase = phases.os_installation
|
phase = phases.os_installation
|
||||||
|
|
|
@ -297,6 +297,7 @@ boot, root and swap.
|
||||||
- ``size``: The size of the partition. Valid values: Any
|
- ``size``: The size of the partition. Valid values: Any
|
||||||
datasize specification up to TB (e.g. 5KiB, 1MB, 6TB).
|
datasize specification up to TB (e.g. 5KiB, 1MB, 6TB).
|
||||||
``required``
|
``required``
|
||||||
|
- ``mode``: Set the mode bits of the mount point, e.g. '1777' for /tmp
|
||||||
- ``filesystem``: The filesystem of the partition. When choosing
|
- ``filesystem``: The filesystem of the partition. When choosing
|
||||||
``xfs``, the ``xfsprogs`` package will need to be installed.
|
``xfs``, the ``xfsprogs`` package will need to be installed.
|
||||||
Valid values: ``ext2``, ``ext3``, ``ext4``, ``xfs``
|
Valid values: ``ext2``, ``ext3``, ``ext4``, ``xfs``
|
||||||
|
|
|
@ -34,6 +34,7 @@ volume:
|
||||||
- journal_ioprio=3
|
- journal_ioprio=3
|
||||||
filesystem: ext4
|
filesystem: ext4
|
||||||
size: 1GiB
|
size: 1GiB
|
||||||
|
mode: '1777'
|
||||||
var:
|
var:
|
||||||
filesystem: ext4
|
filesystem: ext4
|
||||||
size: 1GiB
|
size: 1GiB
|
||||||
|
|
Loading…
Add table
Reference in a new issue