from .ldap_app import PpLdapAppError, PpLdapApplication
-__version__ = '0.3.3'
+__version__ = '0.3.4'
LOG = logging.getLogger(__name__)
default_initial_uid = 999999999
default_chroot_homedir = os.sep + os.path.join('mnt', 'nfs')
+ default_home_root = os.sep + 'home'
# -------------------------------------------------------------------------
def __init__(self, appname=None, version=__version__):
self.initial_uid = self.default_initial_uid
self.chroot_homedir = self.default_chroot_homedir
+ self.home_root_abs = default_chroot_homedir
+ self.home_root_rel = os.path.relpath(self.home_root_abs, os.sep)
self.simulate = False
self.user_entries = []
+ self.home_root_real = os.path.join(self.chroot_homedir, self.home_root)
description = textwrap.dedent('''\
Home Directory and UIDNumber generation - this script will search for
raise PpMkHomeError(msg)
self.chroot_homedir = v
+ if 'home_root' in section:
+ v = section['home_root']
+ if not os.path.isabs(v):
+ msg = (
+ "The root path of the home directories must be an "
+ "absolute pathname (found [{s}]/home_root "
+ "=> {v!r} in configuration.").format(s=section_name, v=v)
+ raise PpMkHomeError(msg)
+ self.home_root_abs = v
+
+ self.home_root_rel = os.path.relpath(self.home_root_abs, os.sep)
+ self.home_root_real = os.path.join(self.chroot_homedir, self.home_root)
+
# -------------------------------------------------------------------------
def pre_run(self):
"""
def check_home_dirs(self):
LOG.info("Checking home directories ...")
+ upper_dir = os.pardir + os.sep
i = 0
for entry in self.user_entries:
home = entry['homeDirectory'][0]
LOG.debug("Checking home directory {!r} ...".format(home))
+ if not os.path.isabs(home):
+ LOG.warn("Home directory {h!r} of user {u!r} is not absolute.".format(
+ h=home, u=dn))
+ continue
+ home_relative = os.path.relpath(home, self.home_root_abs)
+ if home_relative.startswith(upper_dir):
+ if self.verbose:
+ LOG.warn("Home directory {h!r} outside {r!r} is not considered.".format(
+ h=home, r=self.home_root_abs))
+ continue
chroot_dir = os.path.join(
self.chroot_homedir, os.path.relpath(home, os.sep))