Exemplo n.º 1
0
    def configure_smb(self, enable):
        workgroup = self.workgroup
        cfg = smbconf.SambaConfig('registry')
        params = {
            'server role': 'member server',
            'local master': 'no',
            'domain master': 'no',
            'preferred master': 'no',
            'domain logons': 'no',
            'workgroup': workgroup,
            'realm': self.parameters['realm'],
            'security': 'ads',
            'winbind cache time': str(self.context.cache_ttl),
            'winbind offline logon': 'yes',
            'winbind enum users': 'no',
            'winbind enum groups': 'no',
            'winbind nested groups': 'yes',
            'winbind use default domain': 'no',
            'winbind refresh tickets': 'no',
            'client use spnego': 'yes',
            'allow trusted domains': 'no',
            'client ldap sasl wrapping':
            self.parameters['sasl_wrapping'].lower(),
            'template shell': '/bin/sh',
            'template homedir': '/home/%U'
        }

        if enable:
            for k, v in params.items():
                logger.debug('Setting samba parameter "{0}" to "{1}"'.format(
                    k, v))
                cfg[k] = v
        else:
            for k in params:
                del cfg[k]

            params = {
                'server role':
                'auto',
                'workgroup':
                self.context.configstore.get('service.smb.workgroup'),
                'local master':
                yesno(self.context.configstore.get('service.smb.local_master'))
            }

            for k, v in params.items():
                logger.debug('Setting samba parameter "{0}" to "{1}"'.format(
                    k, v))
                cfg[k] = v

        self.context.client.call_sync('service.restart', 'smb')
Exemplo n.º 2
0
    def configure_smb(self, enable):
        workgroup = self.parameters['realm'].split('.')[0]
        cfg = smbconf.SambaConfig('registry')
        params = {
            'server role': 'member server',
            'local master': 'no',
            'domain master': 'no',
            'preferred master': 'no',
            'domain logons': 'no',
            'workgroup': workgroup,
            'realm': self.parameters['realm'],
            'security': 'ads',
            'winbind cache time': str(self.context.cache_ttl),
            'winbind offline logon': 'yes',
            'winbind enum users': 'no',
            'winbind enum groups': 'no',
            'winbind nested groups': 'yes',
            'winbind use default domain': 'no',
            'winbind refresh tickets': 'no',
            'idmap config *: backend': 'tdb',
            'idmap config *: range': '0-65536',
            'idmap config {0}: backend'.format(workgroup): 'rid',
            'idmap config {0}: range'.format(workgroup):
                '{0}-{1}'.format(self.uid_min, self.uid_max),
            'client use spnego': 'yes',
            'allow trusted domains': 'no',
            'client ldap sasl wrapping': self.parameters['sasl_wrapping'].lower(),
            'template shell': '/bin/sh',
            'template homedir': '/home/%U'
        }

        if enable:
            for k, v in params.items():
                logger.debug('Setting samba parameter "{0}" to "{1}"'.format(k, v))
                cfg[k] = v
        else:
            for k in params:
                del cfg[k]

            params = {
                'server role': 'auto',
                'workgroup': self.context.configstore.get('service.smb.workgroup'),
                'local master': yesno(self.context.configstore.get('service.smb.local_master'))
            }

            for k, v in params.items():
                logger.debug('Setting samba parameter "{0}" to "{1}"'.format(k, v))
                cfg[k] = v

        subprocess.call(['/usr/sbin/service', 'samba_server', 'restart'])
Exemplo n.º 3
0
    def configure_smb(self, enable):
        workgroup = self.parameters['realm'].split('.')[0]
        cfg = smbconf.SambaConfig('registry')
        params = {
            'server role':
            'member server',
            'local master':
            'no',
            'domain master':
            'no',
            'preferred master':
            'no',
            'domain logons':
            'no',
            'workgroup':
            workgroup,
            'realm':
            self.parameters['realm'],
            'security':
            'ads',
            'winbind cache time':
            str(self.context.cache_ttl),
            'winbind offline logon':
            'yes',
            'winbind enum users':
            'no',
            'winbind enum groups':
            'no',
            'winbind nested groups':
            'yes',
            'winbind use default domain':
            'no',
            'winbind refresh tickets':
            'no',
            'idmap config *: backend':
            'tdb',
            'idmap config *: range':
            '0-65536',
            'idmap config {0}: backend'.format(workgroup):
            'rid',
            'idmap config {0}: range'.format(workgroup):
            '{0}-{1}'.format(self.uid_min, self.uid_max),
            'client use spnego':
            'yes',
            'allow trusted domains':
            'no',
            'client ldap sasl wrapping':
            'plain',
            'template shell':
            '/bin/sh',
            'template homedir':
            '/home/%U'
        }

        if enable:
            for k, v in params.items():
                logger.debug('Setting samba parameter "{0}" to "{1}"'.format(
                    k, v))
                cfg[k] = v
        else:
            for k in params:
                del cfg[k]

            params = {
                'server role':
                'auto',
                'workgroup':
                self.context.configstore.get('service.smb.workgroup'),
                'local master':
                yesno(self.context.configstore.get('service.smb.local_master'))
            }

            for k, v in params.items():
                logger.debug('Setting samba parameter "{0}" to "{1}"'.format(
                    k, v))
                cfg[k] = v

        #self.context.client.call_sync('service.reload', 'smb', 'reload')
        subprocess.call(['/usr/sbin/service', 'samba_server', 'restart'])