summaryrefslogtreecommitdiff
path: root/src/nslcd_systemd
diff options
context:
space:
mode:
Diffstat (limited to 'src/nslcd_systemd')
-rw-r--r--src/nslcd_systemd/disable_nss_module.go43
-rw-r--r--src/nslcd_systemd/nslcd_systemd.go2
2 files changed, 45 insertions, 0 deletions
diff --git a/src/nslcd_systemd/disable_nss_module.go b/src/nslcd_systemd/disable_nss_module.go
new file mode 100644
index 0000000..90d4edb
--- /dev/null
+++ b/src/nslcd_systemd/disable_nss_module.go
@@ -0,0 +1,43 @@
+package nslcd_systemd
+
+import (
+ "dl"
+ "sd_daemon/logger"
+ "unsafe"
+)
+
+//static char *strary(char **ary, unsigned int n) { return ary[n]; }
+import "C"
+
+const (
+ nss_module_soname = "libnss_ldap.so.2"
+ nss_module_sym_version = "_nss_ldap_version"
+ nss_module_sym_enablelookups = "_nss_ldap_enablelookups"
+)
+
+func disable_nss_module() {
+ handle, err := dl.Open(nss_module_soname, dl.RTLD_LAZY|dl.RTLD_NODELETE)
+ if err == nil {
+ defer handle.Close()
+ } else {
+ logger.Warning("NSS module %s not loaded: %v", nss_module_soname, err)
+ return
+ }
+
+ c_version_info, err := handle.Sym(nss_module_sym_version)
+ if err == nil {
+ g_version_info := (**C.char)(unsafe.Pointer(c_version_info))
+ logger.Debug("NSS module %s version %s %s", nss_module_soname,
+ C.GoString(C.strary(g_version_info, 0)),
+ C.GoString(C.strary(g_version_info, 1)))
+ } else {
+ logger.Warning("NSS module %s version missing: %v", nss_module_soname, err)
+ }
+ c_enable_flag, err := handle.Sym(nss_module_sym_enablelookups)
+ if err != nil {
+ logger.Warning("Unable to disable NSS ldap module for nslcd process: %v", err)
+ return
+ }
+ g_enable_flag := (*C.int)(unsafe.Pointer(c_enable_flag))
+ *g_enable_flag = 0
+}
diff --git a/src/nslcd_systemd/nslcd_systemd.go b/src/nslcd_systemd/nslcd_systemd.go
index c4511ef..8d7d4fb 100644
--- a/src/nslcd_systemd/nslcd_systemd.go
+++ b/src/nslcd_systemd/nslcd_systemd.go
@@ -70,6 +70,8 @@ func Main(backend Backend) uint8 {
}
}()
+ disable_nss_module()
+
socket, err = get_socket()
if err != nil {
logger.Err("%s", err.Error())