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
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)
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)
def cache_keys(**kwargs): if nis_enabled(): _cache_keys_NIS(**kwargs) elif ldap_enabled(): _cache_keys_default(**kwargs) else: _cache_keys_default(**kwargs)
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
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
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)
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)
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
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
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
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
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)
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)
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
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
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
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)