From: Frank Brehm Date: Mon, 20 Mar 2017 12:23:14 +0000 (+0100) Subject: Checking existence of home dir X-Git-Tag: 0.1.2~246 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=e5d1a3b58e100028750b6d6fb5beff8c3bb8b2b9;p=pixelpark%2Fadmin-tools.git Checking existence of home dir --- diff --git a/pp_lib/mk_home_app.py b/pp_lib/mk_home_app.py index f47ffdf..dab2979 100644 --- a/pp_lib/mk_home_app.py +++ b/pp_lib/mk_home_app.py @@ -17,6 +17,7 @@ import re import traceback import textwrap import copy +import shutil # Third party modules import six @@ -38,7 +39,7 @@ from .merge import merge_structure from .ldap_app import PpLdapAppError, PpLdapApplication -__version__ = '0.3.2' +__version__ = '0.3.3' LOG = logging.getLogger(__name__) @@ -233,6 +234,21 @@ class PpMkHomeApp(PpLdapApplication): home = entry['homeDirectory'][0] LOG.debug("Checking home directory {!r} ...".format(home)) + chroot_dir = os.path.join( + self.chroot_homedir, os.path.relpath(home, os.sep)) + if self.verbose > 1: + LOG.debug("Checking existence of {!r} ...".format(chroot_dir)) + + if os.path.exists(chroot_dir): + if os.path.isdir(chroot_dir): + if self.verbose > 2: + LOG.debug("Directory {!r} is already existing.".format(chroot_dir)) + else: + LOG.error("Directory {!r} exists, but is NOT a directory.".format(chroot_dir)) + continue + + LOG.info("Creating home directory {!r} ....".format(chroot_dir)) + if i >= 5: break