Merge pull request #445 from vmlintu-nosto/mountpoint_permissions

Allow setting permissions on mountpoints
This commit is contained in:
Anders Ingemann 2018-02-08 00:06:14 +01:00 committed by GitHub
commit 6b99432ac7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 0 deletions

View file

@ -191,6 +191,7 @@ definitions:
minItems: 1
type: array
size: {$ref: '#/definitions/bytes'}
mode: {type: string}
required: [size, filesystem]
additionalProperties: false
partition_table:

View file

@ -76,6 +76,7 @@ mounting_group = [filesystem.CreateMountDir,
filesystem.MountRoot,
filesystem.MountAdditional,
filesystem.MountSpecials,
filesystem.ChmodMountDirs,
filesystem.CopyMountTable,
filesystem.RemoveMountTable,
filesystem.UnmountRoot,

View file

@ -127,6 +127,32 @@ class MountAdditional(Task):
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):
description = 'Mounting special block devices'
phase = phases.os_installation

View file

@ -297,6 +297,7 @@ boot, root and swap.
- ``size``: The size of the partition. Valid values: Any
datasize specification up to TB (e.g. 5KiB, 1MB, 6TB).
``required``
- ``mode``: Set the mode bits of the mount point, e.g. '1777' for /tmp
- ``filesystem``: The filesystem of the partition. When choosing
``xfs``, the ``xfsprogs`` package will need to be installed.
Valid values: ``ext2``, ``ext3``, ``ext4``, ``xfs``

View file

@ -34,6 +34,7 @@ volume:
- journal_ioprio=3
filesystem: ext4
size: 1GiB
mode: '1777'
var:
filesystem: ext4
size: 1GiB