コード例 #1
0
    def __new__(cls, **kwargs):
        log.debug("FreeNAS_GroupCache.__new__: enter")

        obj = None
        if ldap_enabled() or activedirectory_enabled() or \
            nt4_enabled() or nis_enabled() \
            or domaincontroller_enabled() or nis_enabled():
            obj = FreeNAS_Directory_LocalGroupCache(**kwargs)

        else:
            obj = FreeNAS_BaseCache(**kwargs)

        log.debug("FreeNAS_GroupCache.__new__: leave")
        return obj
コード例 #2
0
def main():
    nsswitch_conf = {
        'group': ['files'],
        'hosts': ['files', 'mdns', 'dns'],
        'networks': ['files'],
        'passwd': ['files'],
        'shells': ['files'],
        'services': ['files'],
        'protocols': ['files'],
        'rpc': ['files'],
        'sudoers': ['files']
    }

    verb = "start"
    if len(sys.argv) > 1:
        verb = sys.argv[1].lower()

    if verb == 'start':
        if activedirectory_enabled() and \
            activedirectory_has_unix_extensions() and  \
            activedirectory_has_keytab():
            nsswitch_conf['passwd'].append('sss')
            nsswitch_conf['group'].append('sss')
        elif activedirectory_enabled() or \
            domaincontroller_enabled() or nt4_enabled():
            nsswitch_conf['passwd'].append('winbind')
            nsswitch_conf['group'].append('winbind')

        #if nt4_enabled():
        #    nsswitch_conf['hosts'].append('wins')

        if ldap_enabled() and ldap_anonymous_bind():
            nsswitch_conf['passwd'].append('ldap')
            nsswitch_conf['group'].append('ldap')
        elif ldap_enabled():
            nsswitch_conf['passwd'].append('sss')
            nsswitch_conf['group'].append('sss')
            if ldap_sudo_configured():
                nsswitch_conf['sudoers'].append('sss')

        if nis_enabled():
            nsswitch_conf['passwd'].append('nis')
            nsswitch_conf['group'].append('nis')
            nsswitch_conf['hosts'].append('nis')

    try:
        fd = os.open(NSSWITCH_CONF_PATH, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0644)
        for key in nsswitch_conf:
            line = "%s: %s\n" % (
                key.strip(),
                string.join(map(lambda x: x.strip(), nsswitch_conf[key]), ' ')
            )
            os.write(fd, line)
        os.close(fd)

    except Exception as e:
        print >> sys.stderr, "can't create %s: %s" % (NSSWITCH_CONF_PATH, e)
        sys.exit(1)
コード例 #3
0
def main():
    nsswitch_conf = {
        'group': ['files'],
        'hosts': ['files', 'mdns', 'dns'],
        'networks': ['files'],
        'passwd': ['files'],
        'shells': ['files'],
        'services': ['files'],
        'protocols': ['files'],
        'rpc': ['files'],
        'sudoers': ['files']
    }

    verb = "start"
    if len(sys.argv) > 1:
        verb = sys.argv[1].lower()

    if verb == 'start':
        if activedirectory_enabled() and \
            activedirectory_has_unix_extensions() and  \
            activedirectory_has_principal():
            nsswitch_conf['passwd'].append('sss')
            nsswitch_conf['group'].append('sss')
        elif activedirectory_enabled() or \
            domaincontroller_enabled() or nt4_enabled():
            nsswitch_conf['passwd'].append('winbind')
            nsswitch_conf['group'].append('winbind')

        #if nt4_enabled():
        #    nsswitch_conf['hosts'].append('wins')

        if ldap_enabled() and ldap_anonymous_bind():
            nsswitch_conf['passwd'].append('ldap')
            nsswitch_conf['group'].append('ldap')
        elif ldap_enabled():
            nsswitch_conf['passwd'].append('sss')
            nsswitch_conf['group'].append('sss')
            if ldap_sudo_configured():
                nsswitch_conf['sudoers'].append('sss')

        if nis_enabled():
            nsswitch_conf['passwd'].append('nis')
            nsswitch_conf['group'].append('nis')
            nsswitch_conf['hosts'].append('nis')

    try:
        fd = os.open(NSSWITCH_CONF_PATH, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
                     0644)
        for key in nsswitch_conf:
            line = "%s: %s\n" % (
                key.strip(),
                string.join(map(lambda x: x.strip(), nsswitch_conf[key]), ' '))
            os.write(fd, line)
        os.close(fd)

    except Exception as e:
        print >> sys.stderr, "can't create %s: %s" % (NSSWITCH_CONF_PATH, e)
        sys.exit(1)
コード例 #4
0
ファイル: cachetool.py プロジェクト: tejp/freenas
def cache_keys(**kwargs):
    if nis_enabled():
        _cache_keys_NIS(**kwargs)

    elif ldap_enabled():
        _cache_keys_default(**kwargs)

    else:
        _cache_keys_default(**kwargs)
コード例 #5
0
def _get_dflags():
    dflags = 0

    if activedirectory_enabled():
        dflags |= U_AD_ENABLED
    elif nis_enabled():
        dflags |= U_NIS_ENABLED
    elif ldap_enabled():
        dflags |= U_LDAP_ENABLED

    return dflags
コード例 #6
0
ファイル: freenascache.py プロジェクト: vaibhav-rbs/freenas
    def __new__(cls, **kwargs):
        log.debug("FreeNAS_UserCache.__new__: enter")

        obj = None
        if (ldap_enabled() or activedirectory_enabled() or nis_enabled()):
            obj = FreeNAS_Directory_LocalUserCache(**kwargs)

        else:
            obj = FreeNAS_BaseCache(**kwargs)

        log.debug("FreeNAS_UserCache.__new__: leave")
        return obj
コード例 #7
0
ファイル: cachetool.py プロジェクト: binzyw/freenas
def cache_count(**kwargs):
    if activedirectory_enabled():
        _cache_count_ActiveDirectory(**kwargs)

    elif nis_enabled():
        _cache_count_NIS(**kwargs)

    elif ldap_enabled():
        _cache_count_default(**kwargs)

    else:
        _cache_count_default(**kwargs)
コード例 #8
0
ファイル: cachetool.py プロジェクト: binzyw/freenas
def cache_rawdump(**kwargs):
    if activedirectory_enabled():
        _cache_rawdump_ActiveDirectory(**kwargs)

    elif nis_enabled():
        _cache_rawdump_NIS(**kwargs)

    elif ldap_enabled():
        _cache_rawdump_default(**kwargs)

    else:
        _cache_rawdump_default(**kwargs)
コード例 #9
0
ファイル: cachetool.py プロジェクト: tejp/freenas
def cache_rawdump(**kwargs):
    if activedirectory_enabled():
        _cache_rawdump_ActiveDirectory(**kwargs)

    elif nis_enabled():
        _cache_rawdump_NIS(**kwargs)

    elif ldap_enabled():
        _cache_rawdump_default(**kwargs)

    else:
        _cache_rawdump_default(**kwargs)
コード例 #10
0
ファイル: cachetool.py プロジェクト: tejp/freenas
def cache_count(**kwargs):
    if activedirectory_enabled():
        _cache_count_ActiveDirectory(**kwargs)

    elif nis_enabled():
        _cache_count_NIS(**kwargs)

    elif ldap_enabled():
        _cache_count_default(**kwargs)

    else:
        _cache_count_default(**kwargs)
コード例 #11
0
ファイル: freenasusers.py プロジェクト: CsMAr51/freenas
def _get_dflags():
    dflags = 0

    if activedirectory_enabled():
        dflags |= U_AD_ENABLED
    elif nt4_enabled():
        dflags |= U_NT4_ENABLED
    elif nis_enabled():
        dflags |= U_NIS_ENABLED
    elif ldap_enabled():
        dflags |= U_LDAP_ENABLED

    return dflags
コード例 #12
0
ファイル: freenasusers.py プロジェクト: binzyw/freenas
def _get_dflags():
    dflags = 0

    if activedirectory_enabled():
        dflags |= U_AD_ENABLED
    elif nis_enabled():
        dflags |= U_NIS_ENABLED
    elif ldap_enabled():
        dflags |= U_LDAP_ENABLED
    elif domaincontroller_enabled():
        dflags |= U_DC_ENABLED

    return dflags
コード例 #13
0
def _get_dflags():
    dflags = 0

    if activedirectory_enabled():
        dflags |= U_AD_ENABLED
    elif nt4_enabled():
        dflags |= U_NT4_ENABLED
    elif nis_enabled():
        dflags |= U_NIS_ENABLED
    elif ldap_enabled():
        dflags |= U_LDAP_ENABLED
    elif domaincontroller_enabled():
        dflags |= U_DC_ENABLED

    return dflags
コード例 #14
0
ファイル: freenascache.py プロジェクト: vaibhav-rbs/freenas
    def __new__(cls, **kwargs):
        log.debug("FreeNAS_Directory_LocalGroupCache.__new__: enter")

        obj = None
        if ldap_enabled():
            obj = FreeNAS_LDAP_LocalGroupCache(**kwargs)

        elif activedirectory_enabled():
            obj = FreeNAS_ActiveDirectory_LocalGroupCache(**kwargs)

        elif nis_enabled():
            obj = FreeNAS_NIS_LocalGroupCache(**kwargs)

        log.debug("FreeNAS_Directory_LocalGroupCache.__new__: leave")
        return obj
コード例 #15
0
ファイル: cachetool.py プロジェクト: HySoaKa/freenas
def cache_check(**kwargs):
    if activedirectory_enabled():
        _cache_check_ActiveDirectory(**kwargs) 

    elif nis_enabled():
        _cache_check_NIS(**kwargs) 

    elif nt4_enabled():
        _cache_check_NT4(**kwargs) 

    elif ldap_enabled():
        _cache_check_default(**kwargs)
     
    else:
        _cache_check_default(**kwargs)
コード例 #16
0
ファイル: cachetool.py プロジェクト: william-gr/freenas
def cache_check(**kwargs):
    if activedirectory_enabled():
        _cache_check_ActiveDirectory(**kwargs)

    elif nis_enabled():
        _cache_check_NIS(**kwargs)

    elif nt4_enabled():
        _cache_check_NT4(**kwargs)

    elif ldap_enabled():
        _cache_check_default(**kwargs)

    else:
        _cache_check_default(**kwargs)
コード例 #17
0
def main():
    nsswitch_conf = {
        'group': ['files'],
        'hosts': ['files', 'dns'],
        'networks': ['files'],
        'passwd': ['files'],
        'shells': ['files'],
        'services': ['files'],
        'protocols': ['files'],
        'rpc': ['files']
    }

    if activedirectory_enabled() and activedirectory_has_unix_extensions():
        nsswitch_conf['passwd'].append('sss')
        nsswitch_conf['group'].append('sss')
    elif activedirectory_enabled() or \
        domaincontroller_enabled() or nt4_enabled():
        nsswitch_conf['passwd'].append('winbind')
        nsswitch_conf['group'].append('winbind')

    if nt4_enabled():
        nsswitch_conf['hosts'].append('wins')

    if ldap_enabled():
        nsswitch_conf['passwd'].append('sss')
        nsswitch_conf['group'].append('sss')

    if nis_enabled():
        nsswitch_conf['passwd'].append('nis')
        nsswitch_conf['group'].append('nis')
        nsswitch_conf['hosts'].append('nis')

    try:
        fd = os.open(NSSWITCH_CONF_PATH, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0644)
        for key in nsswitch_conf:
            line = "%s: %s\n" % (
                key.strip(),
                string.join(map(lambda x: x.strip(), nsswitch_conf[key]), ' ')
            )
            os.write(fd, line)
        os.close(fd)

    except Exception as e:
        print >> sys.stderr, "can't create %s: %s" % (NSSWITCH_CONF_PATH, e)
        sys.exit(1)
コード例 #18
0
ファイル: freenascache.py プロジェクト: binzyw/freenas
    def __new__(cls, **kwargs):
        log.debug("FreeNAS_Directory_LocalUserCache.__new__: enter")

        obj = None
        if ldap_enabled():
            obj = FreeNAS_LDAP_LocalUserCache(**kwargs)

        elif activedirectory_enabled():
            obj = FreeNAS_ActiveDirectory_LocalUserCache(**kwargs)

        elif nis_enabled():
            obj = FreeNAS_NIS_LocalUserCache(**kwargs)

        elif domaincontroller_enabled():
            obj = FreeNAS_DomainController_LocalUserCache(**kwargs)

        log.debug("FreeNAS_Directory_LocalUserCache.__new__: leave")
        return obj
コード例 #19
0
    def __new__(cls, **kwargs):
        log.debug("FreeNAS_Directory_UserCache.__new__: enter")

        obj = None
        if ldap_enabled():
            obj = FreeNAS_LDAP_UserCache(**kwargs)

        elif activedirectory_enabled():
            obj = FreeNAS_ActiveDirectory_UserCache(**kwargs)

        elif nis_enabled():
            obj = FreeNAS_NIS_UserCache(**kwargs)

        elif domaincontroller_enabled():
            obj = FreeNAS_DomainController_UserCache(**kwargs)

        log.debug("FreeNAS_Directory_UserCache.__new__: leave")
        return obj
コード例 #20
0
ファイル: freenascache.py プロジェクト: CsMAr51/freenas
    def __new__(cls, **kwargs):
        log.debug("FreeNAS_Directory_LocalGroupCache.__new__: enter")

        obj = None
        if ldap_enabled():
            obj = FreeNAS_LDAP_LocalGroupCache(**kwargs)

        elif activedirectory_enabled():
            obj = FreeNAS_ActiveDirectory_LocalGroupCache(**kwargs)

        elif nt4_enabled():
            obj = FreeNAS_NT4_LocalGroupCache(**kwargs)

        elif nis_enabled():
            obj = FreeNAS_NIS_LocalGroupCache(**kwargs)

        log.debug("FreeNAS_Directory_LocalGroupCache.__new__: leave")
        return obj
コード例 #21
0
def main():
    nsswitch_conf = {
        'group': ['files'],
        'hosts': ['files', 'dns'],
        'networks': ['files'],
        'passwd': ['files'],
        'shells': ['files'],
        'services': ['files'],
        'protocols': ['files'],
        'rpc': ['files']
    }

    if activedirectory_enabled() and activedirectory_has_unix_extensions():
        nsswitch_conf['passwd'].append('sss')
        nsswitch_conf['group'].append('sss')
    elif activedirectory_enabled() or \
        domaincontroller_enabled() or nt4_enabled():
        nsswitch_conf['passwd'].append('winbind')
        nsswitch_conf['group'].append('winbind')

    if ldap_enabled():
        nsswitch_conf['passwd'].append('sss')
        nsswitch_conf['group'].append('sss')

    if nis_enabled():
        nsswitch_conf['passwd'].append('nis')
        nsswitch_conf['group'].append('nis')
        nsswitch_conf['hosts'].append('nis')

    try:
        fd = os.open(NSSWITCH_CONF_PATH, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0644)
        for key in nsswitch_conf:
            line = "%s: %s\n" % (
                key.strip(),
                string.join(map(lambda x: x.strip(), nsswitch_conf[key]), ' ')
            )
            os.write(fd, line)
        os.close(fd)

    except Exception as e:
        print >> sys.stderr, "can't create %s: %s" % (NSSWITCH_CONF_PATH, e)
        sys.exit(1)