Exemple #1
0
def database_engine(settings_dict):
    """Allow to use aliases for database engines, as well as the default dotted name"""
    engine = _default_database_engines.get(
        settings_dict["DATABASE_ENGINE"].lower(), settings_dict["DATABASE_ENGINE"]
    )
    if engine == "django.db.backends.postgresql":
        try:
            get_distribution("psycopg2-binary")
        except DistributionNotFound:
            try:
                get_distribution("psycopg2")
            except DistributionNotFound:
                settings_check_results.append(
                    missing_package("psycopg2-binary", " to use PostgreSQL database")
                )
    elif engine == "django.db.backends.oracle":
        try:
            get_distribution("cx_Oracle")
        except DistributionNotFound:
            settings_check_results.append(
                missing_package("cx_Oracle", " to use Oracle database")
            )
    elif engine == "django.db.backends.mysql":
        try:
            get_distribution("mysqlclient")
        except DistributionNotFound:
            try:
                get_distribution("pymysql")
            except DistributionNotFound:
                settings_check_results.append(
                    missing_package(
                        "mysqlclient or pymysql", " to use MySQL or MariaDB database"
                    )
                )
    return engine
Exemple #2
0
 def get_requirements(package_name, parent=None):
     try:
         yield str(package_name)
         d = get_distribution(package_name)
         for r in d.requires():
             for required_package in get_requirements(r,
                                                      parent=package_name):
                 yield str(required_package)
     except DistributionNotFound:
         settings_check_results.append(
             missing_package(str(package_name), " by %s" % parent))
     except VersionConflict:
         settings_check_results.append(
             missing_package(str(package_name), " by %s" % parent))
Exemple #3
0
 def process_radius(self, settings_dict):
     if not settings_dict["RADIUS_SERVER"]:
         return []
     try:
         get_distribution("django-radius")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-radius", " to use RADIUS authentication")
         )
         return []
     return ["radiusauth.backends.RADIUSBackend"]
Exemple #4
0
 def process_django_ldap(self, settings_dict):
     if not settings_dict["AUTH_LDAP_SERVER_URI"]:
         return []
     try:
         get_distribution("django-auth-ldap")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-auth-ldap", " to use LDAP authentication")
         )
         return []
     return ["django_auth_ldap.backend.LDAPBackend"]
Exemple #5
0
 def process_pam(self, settings_dict):
     if not settings_dict["USE_PAM_AUTHENTICATION"]:
         return []
     try:
         get_distribution("django_pam")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-pam", " to use PAM authentication")
         )
         return []
     # check if the current user is in the shadow group
     username = pwd.getpwuid(os.getuid()).pw_name
     if not any(
         x.gr_name == "shadow" and username in x.gr_mem for x in grp.getgrall()
     ):
         settings_check_results.append(
             Error(
                 'The user "%s" must belong to the "shadow" group to use PAM '
                 "authentication." % username,
                 obj="configuration",
             )
         )
         return []
     return ["django_pam.auth.backends.PAMBackend"]