Skip to content

Fix docs path and build #668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
author = __license_info["author"]
copyright = __license_info["full"]

__version_file = os.path.join(__dirname, '../ioc/VERSION')
__version_file = os.path.join(__dirname, '../libioc/VERSION')
with open(__version_file, "r") as f:
release = f.read().split("\n")[0]
version = release.split()[0]
Expand All @@ -49,7 +49,7 @@ def setup(app):
'--no-toc',
'-o', 'docs',
'--full',
'ioc',
'libioc',
'tests'
])

Expand Down
6 changes: 3 additions & 3 deletions libioc/Config/Jail/BaseConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import re

import libioc.Config.Data
import libioc.Config.Jail.Defaults
import libioc.Config.Jail.Globals
import libioc.Config.Jail.Properties
import libioc.errors
import libioc.helpers
Expand Down Expand Up @@ -694,7 +694,7 @@ def __sanitize_value(self, key: str, value: typing.Any) -> typing.Any:
return value

def __get_default_type(self, key: str) -> typing.Optional[type]:
return type(libioc.Config.Jail.Defaults.DEFAULTS[key])
return type(libioc.Config.Jail.Globals.DEFAULTS[key])

def set( # noqa: T484
self,
Expand Down Expand Up @@ -818,7 +818,7 @@ def _is_known_property(self, key: str) -> bool:
"""Return True when the key is a known config property."""
if self._is_known_jail_param(key):
return True
if key in libioc.Config.Jail.Defaults.DEFAULTS.keys():
if key in libioc.Config.Jail.Globals.DEFAULTS.keys():
return True # key is default
if f"_set_{key}" in dict.__dir__(self):
return True # key is setter
Expand Down
90 changes: 8 additions & 82 deletions libioc/Config/Jail/Defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,89 +22,15 @@
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Global jail configuration defaults."""
"""A dataset default configuration."""
import typing

import libioc.helpers_object
import libioc.Config.Data
import libioc.Config.Jail.Globals
import libioc.Config.Jail.BaseConfig

DEFAULTS = libioc.Config.Data.Data({
"id": None,
"release": None,
"boot": False,
"priority": 0,
"legacy": False,
"priority": 0,
"depends": [],
"basejail": False,
"basejail_type": "nullfs",
"clonejail": False,
"defaultrouter": None,
"defaultrouter6": None,
"mac_prefix": "02ff60",
"vnet": False,
"interfaces": [],
"vnet_interfaces": [],
"ip4": "new",
"ip4_saddrsel": 1,
"ip4_addr": None,
"ip6": "new",
"ip6_saddrsel": 1,
"ip6_addr": None,
"resolver": "/etc/resolv.conf",
"host_hostuuid": None,
"host_hostname": None,
"host_domainname": None,
"hostid": None,
"hostid_strict_check": False,
"devfs_ruleset": 4,
"enforce_statfs": 2,
"children_max": 0,
"allow_set_hostname": 1,
"allow_sysvipc": 0,
"allow_raw_sockets": 0,
"allow_chflags": 0,
"allow_mount": 0,
"allow_mount_devfs": 0,
"allow_mount_nullfs": 0,
"allow_mount_procfs": 0,
"allow_mount_fdescfs": 0,
"allow_mount_zfs": 0,
"allow_mount_tmpfs": 0,
"allow_quotas": 0,
"allow_socket_af": 0,
"allow_vmm": False,
"rlimits": None,
"sysvmsg": "new",
"sysvsem": "new",
"sysvshm": "new",
"exec_clean": 1,
"exec_fib": 1,
"exec_prestart": None,
"exec_created": None,
"exec_start": "/bin/sh /etc/rc",
"exec_poststart": None,
"exec_prestop": None,
"exec_stop": "/bin/sh /etc/rc.shutdown",
"exec_poststop": None,
"exec_jail_user": "root",
"exec_timeout": "600",
"stop_timeout": "30",
"mount_procfs": "0",
"mount_devfs": "1",
"mount_fdescfs": "0",
"securelevel": 2,
"tags": [],
"template": False,
"jail_zfs": False,
"jail_zfs_dataset": None,
"provision": {
"method": None,
"source": None,
"rev": "master"
}
})
_DEFAULTS = libioc.Config.Jail.Globals.DEFAULTS


class JailConfigDefaults(libioc.Config.Jail.BaseConfig.BaseConfig):
Expand Down Expand Up @@ -144,7 +70,7 @@ def _getitem_special_property(
try:
return super()._getitem_special_property(key, data)
except KeyError:
return super()._getitem_special_property(key, DEFAULTS)
return super()._getitem_special_property(key, _DEFAULTS)

def __getitem__(self, key: str) -> typing.Any:
"""Return a user provided value or the hardcoded default."""
Expand All @@ -157,12 +83,12 @@ def __getitem__(self, key: str) -> typing.Any:

def __contains__(self, key: typing.Any) -> bool:
"""Return true if the storage or hardcoded defaults contain the key."""
return ((key in self.user_data) or (key in DEFAULTS)) is True
return ((key in self.user_data) or (key in _DEFAULTS)) is True

def getitem_default(self, key: str) -> typing.Any:
"""Return the interpreted hardcoded default value."""
try:
return DEFAULTS.__getitem__(key)
return _DEFAULTS.__getitem__(key)
except KeyError:
if self.special_properties.is_special_property(key):
return None
Expand All @@ -173,7 +99,7 @@ def __delitem__(self, key: str) -> None:

def __iter__(self) -> typing.Iterator[str]:
"""Iterate over all default properties."""
return iter(self.user_properties.union(DEFAULTS.keys()))
return iter(self.user_properties.union(_DEFAULTS.keys()))

def __len__(self) -> int:
"""Return the number of default config properties."""
Expand All @@ -183,7 +109,7 @@ def keys(self) -> typing.KeysView[str]:
"""List all default property keys."""
return typing.cast(
typing.KeysView[str],
list(self.user_properties.union(DEFAULTS.keys()))
list(self.user_properties.union(_DEFAULTS.keys()))
)

@property
Expand Down
103 changes: 103 additions & 0 deletions libioc/Config/Jail/Globals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Copyright (c) 2017-2019, Stefan Grönke
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted providing that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Global jail configuration defaults."""
import libioc.Config.Data


DEFAULTS = libioc.Config.Data.Data({
"id": None,
"release": None,
"boot": False,
"priority": 0,
"legacy": False,
"priority": 0,
"depends": [],
"basejail": False,
"basejail_type": "nullfs",
"clonejail": False,
"defaultrouter": None,
"defaultrouter6": None,
"mac_prefix": "02ff60",
"vnet": False,
"interfaces": [],
"vnet_interfaces": [],
"ip4": "new",
"ip4_saddrsel": 1,
"ip4_addr": None,
"ip6": "new",
"ip6_saddrsel": 1,
"ip6_addr": None,
"resolver": "/etc/resolv.conf",
"host_hostuuid": None,
"host_hostname": None,
"host_domainname": None,
"hostid": None,
"hostid_strict_check": False,
"devfs_ruleset": 4,
"enforce_statfs": 2,
"children_max": 0,
"allow_set_hostname": 1,
"allow_sysvipc": 0,
"allow_raw_sockets": 0,
"allow_chflags": 0,
"allow_mount": 0,
"allow_mount_devfs": 0,
"allow_mount_nullfs": 0,
"allow_mount_procfs": 0,
"allow_mount_fdescfs": 0,
"allow_mount_zfs": 0,
"allow_mount_tmpfs": 0,
"allow_quotas": 0,
"allow_socket_af": 0,
"allow_vmm": False,
"rlimits": None,
"sysvmsg": "new",
"sysvsem": "new",
"sysvshm": "new",
"exec_clean": 1,
"exec_fib": 1,
"exec_prestart": None,
"exec_created": None,
"exec_start": "/bin/sh /etc/rc",
"exec_poststart": None,
"exec_prestop": None,
"exec_stop": "/bin/sh /etc/rc.shutdown",
"exec_poststop": None,
"exec_jail_user": "root",
"exec_timeout": "600",
"stop_timeout": "30",
"mount_procfs": "0",
"mount_devfs": "1",
"mount_fdescfs": "0",
"securelevel": 2,
"tags": [],
"template": False,
"jail_zfs": False,
"jail_zfs_dataset": None,
"provision": {
"method": None,
"source": None,
"rev": "master"
}
})