Example #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)
Example #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)
Example #3
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
Example #4
0
    def retrieve_and_store(self):
        '''
        Retrieve settings and strore it in a database
        '''
        # Get policies for machine at first.
        machine_gpts = self._get_gpts(get_machine_name(),
                                      self.storage.get_info('machine_sid'))
        self.storage.wipe_hklm()
        self.storage.wipe_user(self.storage.get_info('machine_sid'))
        for gptobj in machine_gpts:
            gptobj.merge()

        # Load user GPT values in case user's name specified
        # This is a buggy implementation and should be tested more
        if not self._is_machine_username:
            user_gpts = self._get_gpts(self.username, self.sid)
            self.storage.wipe_user(self.sid)
            for gptobj in user_gpts:
                gptobj.merge()
Example #5
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)))
Example #6
0
    def retrieve_and_store(self):
        '''
        Retrieve settings and strore it in a database
        '''
        # Get policies for machine at first.
        machine_gpts = list()
        try:
            machine_gpts = self._get_gpts(get_machine_name(),
                                          self.storage.get_info('machine_sid'))
        except Exception as exc:
            log('F2')
            raise exc
        self.storage.wipe_hklm()
        self.storage.wipe_user(self.storage.get_info('machine_sid'))
        for gptobj in machine_gpts:
            try:
                gptobj.merge()
            except Exception as exc:
                logdata = dict()
                logdata['msg'] = str(exc)
                log('E26', logdata)

        # Load user GPT values in case user's name specified
        # This is a buggy implementation and should be tested more
        if not self._is_machine_username:
            user_gpts = list()
            try:
                user_gpts = self._get_gpts(self.username, self.sid)
            except Exception as exc:
                log('F3')
                raise exc
            self.storage.wipe_user(self.sid)
            for gptobj in user_gpts:
                try:
                    gptobj.merge()
                except Exception as exc:
                    logdata = dict()
                    logdata['msg'] = str(exc)
                    log('E27', logdata)