Пример #1
0
    def __init__(self, sambacreds, username, domain, is_machine):
        self.cache_path = '/var/cache/gpupdate/creds/krb5cc_{}'.format(
            os.getpid())
        self.__kinit_successful = machine_kinit(self.cache_path)
        self.storage = registry_factory('registry')
        self.storage.set_info('domain', domain)
        machine_name = get_machine_name()
        machine_sid = get_sid(domain, machine_name, is_machine)
        self.storage.set_info('machine_name', machine_name)
        self.storage.set_info('machine_sid', machine_sid)

        # User SID to work with HKCU hive
        self.username = username
        self._is_machine_username = is_machine
        if is_machine:
            self.sid = machine_sid
        else:
            self.sid = get_sid(self.storage.get_info('domain'), self.username)

        self.cache = cache_factory('regpol_cache')
        self.gpo_names = cache_factory('gpo_names')

        # Samba objects - LoadParm() and CredentialsOptions()
        self.sambacreds = sambacreds

        self.cache_dir = self.sambacreds.get_cache_dir()
        logdata = dict({'cachedir': self.cache_dir})
        log('D7', logdata)
Пример #2
0
    def __init__(self):
        self.storage = registry_factory('registry')
        self.storage.set_info('domain', domain)
        self.storage.set_info('machine_name', get_machine_name())
        self.storage.set_info('machine_sid', get_sid(domain, self.storage.get_info('machine_name')))

        # User SID to work with HKCU hive
        self.username = username
        self.sid = get_sid(self.storage.get_info('domain'), self.username)
Пример #3
0
def merge_polfile(preg, sid=None, reg_name='registry', reg_path=None):
    pregfile = load_preg(preg)
    logging.info(slogm('Loaded PReg {}'.format(preg)))
    storage = registry_factory(reg_name, reg_path)
    for entry in pregfile.entries:
        if not sid:
            storage.add_hklm_entry(entry)
        else:
            storage.add_hkcu_entry(entry, sid)
Пример #4
0
def merge_polfile(preg, sid=None):
    pregfile = load_preg(preg)
    logging.info(slogm('Loaded PReg {}'.format(preg)))
    key_map = dict()
    storage = registry_factory('registry')
    for entry in pregfile.entries:
        if not sid:
            storage.add_hklm_entry(entry)
        else:
            storage.add_hkcu_entry(entry, sid)
Пример #5
0
    def __init__(self):
        domain = None
        machine_name = get_machine_name()
        machine_sid = get_sid(domain, machine_name, True)
        self.storage = registry_factory('registry')
        self.storage.set_info('domain', domain)
        self.storage.set_info('machine_name', machine_name)
        self.storage.set_info('machine_sid', machine_sid)

        # User SID to work with HKCU hive
        self.username = machine_name
        self.sid = machine_sid
Пример #6
0
def merge_polfile(preg,
                  sid=None,
                  reg_name='registry',
                  reg_path=None,
                  policy_name='Unknown'):
    pregfile = load_preg(preg)
    logdata = dict({'pregfile': preg})
    log('D32', logdata)
    storage = registry_factory(reg_name, reg_path)
    for entry in pregfile.entries:
        if not sid:
            storage.add_hklm_entry(entry, policy_name)
        else:
            storage.add_hkcu_entry(entry, sid, policy_name)
Пример #7
0
    def __init__(self, sambacreds, username, domain):
        self.storage = registry_factory('registry')
        self.storage.set_info('domain', domain)
        self.storage.set_info('machine_name', get_machine_name())
        self.storage.set_info(
            'machine_sid',
            get_sid(domain, self.storage.get_info('machine_name')))

        # User SID to work with HKCU hive
        self.username = username
        self._is_machine_username = is_machine_name(self.username)
        self.sid = get_sid(self.storage.get_info('domain'), self.username)

        self.cache = cache_factory('regpol_cache')
        self.gpo_names = cache_factory('gpo_names')

        # Samba objects - LoadParm() and CredentialsOptions()
        self.sambacreds = sambacreds

        self.cache_dir = self.sambacreds.get_cache_dir()
        logging.debug(slogm('Cache directory is: {}'.format(self.cache_dir)))
Пример #8
0
    def __init__(self, username, is_machine):
        self.storage = registry_factory('registry')
        self.username = determine_username(username)
        self.is_machine = is_machine
        self.process_uname = get_process_user()
        self.sid = get_sid(self.storage.get_info('domain'), self.username,
                           is_machine)

        self.machine_appliers = dict({
            'control':
            control_applier(self.storage),
            'polkit':
            polkit_applier(self.storage),
            'systemd':
            systemd_applier(self.storage),
            'firefox':
            firefox_applier(self.storage, self.sid, self.username),
            'chromium':
            chromium_applier(self.storage, self.sid, self.username),
            'shortcuts':
            shortcut_applier(self.storage),
            'gsettings':
            gsettings_applier(self.storage),
            'cups':
            cups_applier(self.storage),
            'package':
            package_applier(self.storage)
        })

        # User appliers are expected to work with user-writable
        # files and settings, mostly in $HOME.
        self.user_appliers = dict({
            'shortcuts':
            shortcut_applier_user(self.storage, self.sid, self.username),
            'gsettings':
            gsettings_applier_user(self.storage, self.sid, self.username),
            'cifs':
            cifs_applier_user(self.storage, self.sid, self.username)
        })
Пример #9
0
    def __init__(self, gpt_path, sid):
        self.path = gpt_path
        self.sid = sid
        self.storage = registry_factory('registry')
        self.name = ''

        self.guid = self.path.rpartition('/')[2]
        if 'default' == self.guid:
            self.guid = 'Local Policy'

        self._machine_path = find_dir(self.path, 'Machine')
        self._user_path = find_dir(self.path, 'User')

        self.settings_list = [
              'shortcuts'
            , 'drives'
            , 'environmentvariables'
            , 'printers'
            , 'folders'
            , 'files'
            , 'inifiles'
            , 'services'
            , 'scheduledtasks'
        ]
        self.settings = dict()
        self.settings['machine'] = dict()
        self.settings['user'] = dict()
        self.settings['machine']['regpol'] = find_file(self._machine_path, 'registry.pol')
        self.settings['user']['regpol'] = find_file(self._user_path, 'registry.pol')
        for setting in self.settings_list:
            machine_preffile = find_preffile(self._machine_path, setting)
            user_preffile = find_preffile(self._user_path, setting)
            mlogdata = dict({'setting': setting, 'prefpath': machine_preffile})
            log('D24', mlogdata)
            self.settings['machine'][setting] = machine_preffile
            ulogdata = dict({'setting': setting, 'prefpath': user_preffile})
            log('D23', ulogdata)
            self.settings['user'][setting] = user_preffile
Пример #10
0
    def __init__(self, username, is_machine):
        self.storage = registry_factory('registry')
        self.username = determine_username(username)
        self.is_machine = is_machine
        self.process_uname = get_process_user()
        self.sid = get_sid(self.storage.get_info('domain'), self.username, is_machine)

        self.machine_appliers = dict()
        self.machine_appliers['control'] = control_applier(self.storage)
        self.machine_appliers['polkit'] = polkit_applier(self.storage)
        self.machine_appliers['systemd'] = systemd_applier(self.storage)
        self.machine_appliers['firefox'] = firefox_applier(self.storage, self.sid, self.username)
        self.machine_appliers['chromium'] = chromium_applier(self.storage, self.sid, self.username)
        self.machine_appliers['shortcuts'] = shortcut_applier(self.storage)
        self.machine_appliers['gsettings'] = gsettings_applier(self.storage)
        self.machine_appliers['cups'] = cups_applier(self.storage)
        self.machine_appliers['firewall'] = firewall_applier(self.storage)
        self.machine_appliers['folders'] = folder_applier(self.storage, self.sid)
        self.machine_appliers['package'] = package_applier(self.storage)
        self.machine_appliers['ntp'] = ntp_applier(self.storage)
        self.machine_appliers['envvar'] = envvar_applier(self.storage, self.sid)

        # User appliers are expected to work with user-writable
        # files and settings, mostly in $HOME.
        self.user_appliers = dict()
        self.user_appliers['shortcuts'] = shortcut_applier_user(self.storage, self.sid, self.username)
        self.user_appliers['folders'] = folder_applier_user(self.storage, self.sid, self.username)
        self.user_appliers['gsettings'] = gsettings_applier_user(self.storage, self.sid, self.username)
        try:
            self.user_appliers['cifs'] = cifs_applier_user(self.storage, self.sid, self.username)
        except Exception as exc:
            logdata = dict()
            logdata['applier_name'] = 'cifs'
            logdata['msg'] = str(exc)
            log('E25', logdata)
        self.user_appliers['package'] = package_applier_user(self.storage, self.sid, self.username)
        self.user_appliers['polkit'] = polkit_applier_user(self.storage, self.sid, self.username)
        self.user_appliers['envvar'] = envvar_applier_user(self.storage, self.sid, self.username)
Пример #11
0
 def __init__(self, gpt_path, sid):
     self.path = gpt_path
     self.sid = sid
     self.storage = registry_factory('registry')
     self._scan_gpt()