Skip to content

Commit

Permalink
tkt-78015: Switch from SSSD to NSLCD (#2687)
Browse files Browse the repository at this point in the history
* Switch from SSSD to NSLCD
- Begin using NSLCD for authenticated LDAP. More work is needed to bring in / validate kerberos support post-sssd.
  • Loading branch information
anodos325 committed Mar 8, 2019
1 parent 95cb046 commit df3ee38
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 1,197 deletions.
22 changes: 22 additions & 0 deletions gui/directoryservice/migrations/0007_migrate_to_nslcd.py
@@ -0,0 +1,22 @@
import django.core.validators
from django.db import migrations, models
import freenasUI.freeadmin.models.fields

def remove_sssd_aux_params(apps, schema_editor):
LDAP = apps.get_model('directoryservice.LDAP')
for o in LDAP.objects.all():
if not o.ldap_anonbind:
o.ldap_auxiliary_parameters = ""
o.save()

class Migration(migrations.Migration):

dependencies = [
('directoryservice', '0006_certificate_model'),
]

operations = [
migrations.RunPython(
remove_sssd_aux_params
),
]
2 changes: 1 addition & 1 deletion gui/directoryservice/models.py
Expand Up @@ -1279,7 +1279,7 @@ class LDAP(DirectoryServiceBase):
ldap_auxiliary_parameters = models.TextField(
verbose_name=_("Auxiliary Parameters"),
blank=True,
help_text=_("These parameters are added to sssd.conf")
help_text=_("These parameters are added to nslcd.conf")
)
ldap_schema = models.CharField(
verbose_name=("Schema"),
Expand Down
42 changes: 0 additions & 42 deletions src/freenas/etc/directoryservice/ActiveDirectory/ctl
Expand Up @@ -23,31 +23,6 @@ adctl_cmd()
return 0
}

sssd_running()
{
${service} sssd onestatus >/dev/null 2>&1
return $?
}

sssd_start()
{
adctl_cmd ${service} sssd onestart
return $?
}

sssd_stop()
{
adctl_cmd ${service} sssd onestop
return $?
}

sssd_restart()
{
adctl_cmd ${service} sssd onestop
adctl_cmd ${service} sssd onestart
return $?
}

cifs_enabled()
{
srv_enabled cifs && return 0
Expand Down Expand Up @@ -123,17 +98,6 @@ adctl_start()
return 1
fi

if AD_has_unix_extensions && AD_has_keytab
then
adctl_cmd ${service} ix-sssd start
if sssd_running
then
sssd_restart
else
sssd_start
fi
fi

cifs_start

if ! adctl_cmd ${service} ix-activedirectory quietstart
Expand Down Expand Up @@ -180,12 +144,6 @@ adctl_stop()
cifs_stop
fi

if sssd_running
then
sssd_stop
adctl_cmd ${service} ix-sssd start
fi

if [ "${prev_cifs_started}" = "0" -a "${cifs_started}" = "0" ]
then
adctl_cmd ${service} samba_server forcestop
Expand Down
62 changes: 11 additions & 51 deletions src/freenas/etc/directoryservice/LDAP/ctl
Expand Up @@ -22,31 +22,6 @@ ldapctl_cmd()
return 0
}

sssd_running()
{
${service} sssd onestatus >/dev/null 2>&1
return $?
}

sssd_start()
{
ldapctl_cmd ${service} sssd onestart
return $?
}

sssd_stop()
{
ldapctl_cmd ${service} sssd onestop
return $?
}

sssd_restart()
{
ldapctl_cmd ${service} sssd onestop
ldapctl_cmd ${service} sssd onestart
return $?
}

nslcd_running()
{
${service} nslcd onestatus >/dev/null 2>&1
Expand Down Expand Up @@ -87,7 +62,7 @@ cifs_restart()

cifs_reset()
{
ldapctl_cmd ${python} ${notifier} call etc.generate smb
ldapctl_cmd ${python} ${notifier} call etc.generate smb > /dev/null

if cifs_enabled;
then
Expand Down Expand Up @@ -150,26 +125,14 @@ ldapctl_start()
fi
fi

anonbind="$(LDAP_get ldap_anonbind)"
if [ "${anonbind}" = "0" ]
then
ldapctl_cmd ${service} ix-sssd start
if sssd_running
then
sssd_restart
else
sssd_start
fi

elif [ "${anonbind}" = "1" ]

ldapctl_cmd ${python} ${notifier} call etc.generate nss > /dev/null
ldapctl_cmd ${service} ix-pam quietstart
if nslcd_running
then
ldapctl_cmd ${service} ix-pam quietstart
if nslcd_running
then
nslcd_restart
else
nslcd_start
fi
nslcd_restart
else
nslcd_start
fi

if ! ldapctl_cmd ${service} ix-ldap status
Expand All @@ -181,6 +144,8 @@ ldapctl_start()

if cifs_enabled && LDAP_has_samba_schema
then
ldapctl_cmd ${python} ${notifier} call etc.generate smb > /dev/null
ldapctl_cmd ${python} ${notifier} call smb.store_ldap_admin_password > /dev/null
cifs_restart
fi

Expand All @@ -200,19 +165,14 @@ ldapctl_stop()
ldap_set 1
fi

if sssd_running
then
sssd_stop
ldapctl_cmd ${service} ix-sssd start
fi
if nslcd_running
then
nslcd_stop
ldapctl_cmd ${service} ix-nslcd start
fi

ldapctl_cmd ${service} ix-ldap forcestop
ldapctl_cmd ${service} ix-nsswitch quietstop
ldapctl_cmd ${python} ${notifier} call etc.generate nss > /dev/null
ldapctl_cmd ${service} ix-pam quietstop
ldapctl_cmd "${service} ix-cache quietstop &"

Expand Down
50 changes: 0 additions & 50 deletions src/freenas/etc/ix.rc.d/ix-smbpasswd

This file was deleted.

22 changes: 0 additions & 22 deletions src/freenas/etc/ix.rc.d/ix-sssd

This file was deleted.

2 changes: 1 addition & 1 deletion src/freenas/etc/ix.rc.d/ix_pf_late
Expand Up @@ -4,7 +4,7 @@
#

# PROVIDE: ix_pf_late
# REQUIRE: ix-smbpasswd
# REQUIRE: samba_server
# KEYWORD: nojail shutdown

. /etc/rc.subr
Expand Down
33 changes: 2 additions & 31 deletions src/freenas/etc/rc.conf.local
Expand Up @@ -444,42 +444,13 @@ _snmp_config()
_ldap_config()
{
# Should we ditch sssd now that we have nslcd in? TBD
sssd_enable="NO"
# Should we ditch sssd now that we have nslcd in? Yes
nslcd_enable="NO"
if dirsrv_enabled ldap ; then
local anonymous_bind=$(${FREENAS_SQLITE_CMD} ${FREENAS_CONFIG} "
SELECT
ldap_anonbind
FROM
directoryservice_ldap
ORDER BY
-id
LIMIT 1
")
if [ "${anonymous_bind}" = "1" ]; then
nslcd_enable="YES"
fi
sssd_enable="YES"
nslcd_enable="YES"
fi
# This needs to go away, winbind is perfectly fine for this use case nowdays
if dirsrv_enabled activedirectory; then
local ad_unix=$(${FREENAS_SQLITE_CMD} ${FREENAS_CONFIG} "
SELECT
ad_unix_extensions
FROM
directoryservice_activedirectory
ORDER BY
-id
LIMIT 1
")
if [ "${ad_unix}" = "1" ]; then
sssd_enable="YES"
fi
fi
echo "sssd_enable=\"${sssd_enable}\""
echo "nslcd_enable=\"${nslcd_enable}\""
}
Expand Down
1 change: 0 additions & 1 deletion src/freenas/etc/rc.freenas
Expand Up @@ -60,7 +60,6 @@
#
# LDAP settings
#
: ${SSSD_CONF:="/usr/local/etc/sssd/sssd.conf"}
: ${LDAP_CONF:="/usr/local/etc/openldap/ldap.conf"}
: ${CERT_FILE:="/usr/local/etc/certs/cacert.crt"}
: ${LDAP_TIMEOUT:="0"}
Expand Down
Expand Up @@ -195,13 +195,6 @@ __EOF__
klist
section_footer

#
# Dump Active Directory SSSD configuration
#
section_header "${SSSD_CONF}"
sc "${SSSD_CONF}" | grep -iv ldap_default_authtok
section_footer

#
# Dump generated AD config file
#
Expand Down
Expand Up @@ -165,13 +165,6 @@ __EOF__
klist
section_footer

#
# Dump Domain Controller SSSD configuration
#
section_header "${SSSD_CONF}"
sc "${SSSD_CONF}" | grep -iv ldap_default_authtok
section_footer

#
# Dump generated DC config file
#
Expand Down
6 changes: 3 additions & 3 deletions src/freenas/usr/local/libexec/freenas-debug/ldap/ldap.sh
Expand Up @@ -142,10 +142,10 @@ __EOF__
section_footer

#
# Dump SSSD configuration
# Dump NSLCD configuration
#
section_header "${SSSD_CONF}"
sc "${SSSD_CONF}" | grep -iv ldap_default_authtok
section_header "${NSLCD_CONF}"
sc "${NSLCD_CONF}" | grep -iv ldap_default_authtok
section_footer

#
Expand Down

0 comments on commit df3ee38

Please sign in to comment.