# Path: pyanaconda/iutil.py
# def augmentEnv():
# def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None):
#     def chroot():
# def execWithRedirect(command, argv, stdin=None, stdout=None,
#                      root='/', env_prune=None):
# def execWithCapture(command, argv, stdin=None, root='/'):
# def execReadlines(command, argv, stdin=None, root='/', env_prune=None):
#     def queue_lines(out, queue):
#     def chroot():
# def execConsole():
# def getDirSize(directory):
#     def getSubdirSize(directory):
# def mkdirChain(directory):
# def get_active_console(dev="console"):
# def isConsoleOnVirtualTerminal(dev="console"):
# def strip_markup(text):
# def reIPL(ipldev):
# def resetRpmDb():
# def parseNfsUrl(nfsurl):
# def add_po_path(module, directory):
# def setup_translations(module):
# def fork_orphan():
# def _run_systemctl(command, service):
# def start_service(service):
# def stop_service(service):
# def restart_service(service):
# def service_running(service):
# def dracut_eject(device):
# def vtActivate(num):
#     def __init__(self, url=None, protocol="http://", host=None, port="3128",
#                  username=None, password=None):
#     def parse_url(self):
#     def parse_components(self):
#     def dict(self):
#     def __str__(self):
# def getdeepattr(obj, name):
# def setdeepattr(obj, name, value):
# def strip_accents(s):
# def cmp_obj_attrs(obj1, obj2, attr_list):
# def dir_tree_map(root, func, files=True, dirs=True):
# def chown_dir_tree(root, uid, gid, from_uid_only=None, from_gid_only=None):
#     def conditional_chown(path, uid, gid, from_uid=None, from_gid=None):
# def is_unsupported_hw():
# def _toASCII(s):
# def upperASCII(s):
# def lowerASCII(s):
# def upcase_first_letter(text):
# class ProxyStringError(Exception):
# class ProxyString(object):
# 
# Path: pyanaconda/iutil.py
# def strip_accents(s):
#     """This function takes arbitrary unicode string
#     and returns it with all the diacritics removed.
# 
#     :param s: arbitrary string
#     :type s: unicode
# 
#     :return: s with diacritics removed
#     :rtype: unicode
# 
#     """
#     return ''.join((c for c in unicodedata.normalize('NFD', s)
#                       if unicodedata.category(c) != 'Mn'))
# 
# Path: pyanaconda/constants.py
# PASSWORD_MIN_LEN = 6


import libuser
import string
import crypt
import random
import tempfile
import os
import os.path
import pwquality
import logging
from pyanaconda import iutil
from pyanaconda.iutil import strip_accents
from pyanaconda.i18n import _
from pyanaconda.constants import PASSWORD_MIN_LEN

            if kwargs.get("gecos", False):
                userEnt.set(libuser.GECOS, kwargs["gecos"])

            # need to create home directory for the user or does it already exist?
            # userEnt.get returns lists (usually with a single item)
            mk_homedir = not os.path.exists(userEnt.get(libuser.HOMEDIRECTORY)[0])

            try:
                self.admin.addUser(userEnt, mkmailspool=kwargs.get("mkmailspool", True),
                                   mkhomedir=mk_homedir)
            except RuntimeError as e:
                log.critical("Error when creating new user: %s", e)
                os._exit(1)

            try:
                self.admin.addGroup(groupEnt)
            except RuntimeError as e:
                log.critical("Error when creating new group: %s", e)
                os._exit(1)

            if not mk_homedir:
                try:
                    stats = os.stat(userEnt.get(libuser.HOMEDIRECTORY)[0])
                    orig_uid = stats.st_uid
                    orig_gid = stats.st_gid

                    log.info("Home directory for the user %s already existed, "
                             "fixing the owner.", user_name)
                    # home directory already existed, change owner of it properly

# Path: pyanaconda/iutil.py
# def augmentEnv():
# def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None):
#     def chroot():
# def execWithRedirect(command, argv, stdin=None, stdout=None,
#                      root='/', env_prune=None):
# def execWithCapture(command, argv, stdin=None, root='/'):
# def execReadlines(command, argv, stdin=None, root='/', env_prune=None):
#     def queue_lines(out, queue):
#     def chroot():
# def execConsole():
# def getDirSize(directory):
#     def getSubdirSize(directory):
# def mkdirChain(directory):
# def get_active_console(dev="console"):
# def isConsoleOnVirtualTerminal(dev="console"):
# def strip_markup(text):
# def reIPL(ipldev):
# def resetRpmDb():
# def parseNfsUrl(nfsurl):
# def add_po_path(module, directory):
# def setup_translations(module):
# def fork_orphan():
# def _run_systemctl(command, service):
# def start_service(service):
# def stop_service(service):
# def restart_service(service):
# def service_running(service):
# def dracut_eject(device):
# def vtActivate(num):
#     def __init__(self, url=None, protocol="http://", host=None, port="3128",
#                  username=None, password=None):
#     def parse_url(self):
#     def parse_components(self):
#     def dict(self):
#     def __str__(self):
# def getdeepattr(obj, name):
# def setdeepattr(obj, name, value):
# def strip_accents(s):
# def cmp_obj_attrs(obj1, obj2, attr_list):
# def dir_tree_map(root, func, files=True, dirs=True):
# def chown_dir_tree(root, uid, gid, from_uid_only=None, from_gid_only=None):
#     def conditional_chown(path, uid, gid, from_uid=None, from_gid=None):
# def is_unsupported_hw():
# def _toASCII(s):
# def upperASCII(s):
# def lowerASCII(s):
# def upcase_first_letter(text):
# class ProxyStringError(Exception):
# class ProxyString(object):
# 
# Path: pyanaconda/iutil.py
# def strip_accents(s):
#     """This function takes arbitrary unicode string
#     and returns it with all the diacritics removed.
# 
#     :param s: arbitrary string
#     :type s: unicode
# 
#     :return: s with diacritics removed
#     :rtype: unicode
# 
#     """
#     return ''.join((c for c in unicodedata.normalize('NFD', s)
#                       if unicodedata.category(c) != 'Mn'))
# 
# Path: pyanaconda/constants.py
# PASSWORD_MIN_LEN = 6


# Path: pyanaconda/users.py
import libuser
import string
import crypt
import random
import tempfile
import os
import os.path
import pwquality
import logging
from pyanaconda import iutil
from pyanaconda.iutil import strip_accents
from pyanaconda.i18n import _
from pyanaconda.constants import PASSWORD_MIN_LEN


            if kwargs.get("gecos", False):
                userEnt.set(libuser.GECOS, kwargs["gecos"])

            # need to create home directory for the user or does it already exist?
            # userEnt.get returns lists (usually with a single item)
            mk_homedir = not os.path.exists(userEnt.get(libuser.HOMEDIRECTORY)[0])

            try:
                self.admin.addUser(userEnt, mkmailspool=kwargs.get("mkmailspool", True),
                                   mkhomedir=mk_homedir)
            except RuntimeError as e:
                log.critical("Error when creating new user: %s", e)
                os._exit(1)

            try:
                self.admin.addGroup(groupEnt)
            except RuntimeError as e:
                log.critical("Error when creating new group: %s", e)
                os._exit(1)

            if not mk_homedir:
                try:
                    stats = os.stat(userEnt.get(libuser.HOMEDIRECTORY)[0])
                    orig_uid = stats.st_uid
                    orig_gid = stats.st_gid

                    log.info("Home directory for the user %s already existed, "
                             "fixing the owner.", user_name)
                    # home directory already existed, change owner of it properly

                    iutil.chown_dir_tree(userEnt.get(libuser.HOMEDIRECTORY)[0],