Package: gnarwl / 3.6.dfsg-11

fln/0008-Add-deref-option-for-LDAP-alias-dereferencing.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From 8c2c1166edeb027214b74827354842b97c96f958 Mon Sep 17 00:00:00 2001
From: Andrew McCarthy <me@andrewmccarthy.ie>
Date: Wed, 28 Sep 2016 21:05:53 +0100
Subject: [PATCH] Add deref option for LDAP alias dereferencing

---
 README.md      | 1 +
 doc/gnarwl.man | 3 +++
 src/config.c   | 9 +++++++++
 src/config.h   | 1 +
 src/dbaccess.c | 1 +
 5 files changed, 15 insertions(+)

diff --git a/README.md b/README.md
index a106a6b..e897a77 100644
--- a/README.md
+++ b/README.md
@@ -56,3 +56,4 @@ Improvements
 *   New config option *ca_cert* allow specifying CA certificate when ldaps or 
     StartTLS is used.
 *   New config option *starttls*.
+*   New config option *deref* allows control of LDAP alias dereferencing.
diff --git a/doc/gnarwl.man b/doc/gnarwl.man
index ebcd74e..3c45934 100644
--- a/doc/gnarwl.man
+++ b/doc/gnarwl.man
@@ -194,6 +194,9 @@ Specifies what to send to the syslog. A higher loglevel
 automatically includes all lower loglevels (see section syslog for more 
 information).
 
+.IP "deref <never|search|find|always>"
+Controls what LDAP alias dereferencing will be performed. Default is "find".
+
 .SH SYSLOG
 Since 
 .B gnarwl
diff --git a/src/config.c b/src/config.c
index bdc18bd..70f0b40 100644
--- a/src/config.c
+++ b/src/config.c
@@ -192,6 +192,14 @@ void putEntry(char* key, char* val) {
     return;
   }
   
+  if (!strcasecmp(key,"deref")) {
+    if (!strcasecmp(val,"never")) cfg.deref=LDAP_DEREF_NEVER;
+    if (!strcasecmp(val,"search")) cfg.deref=LDAP_DEREF_SEARCHING;
+    if (!strcasecmp(val,"find")) cfg.deref=LDAP_DEREF_FINDING;
+    if (!strcasecmp(val,"always")) cfg.deref=LDAP_DEREF_ALWAYS;
+    return;
+  }
+
   syslog(LOG_MAIL|LOG_WARNING,"WARN/CFG Unknown config directive: %s",key);
 }
 
@@ -226,6 +234,7 @@ void setDefaults(void) {
   cpyStr(&cfg.recv_header[0],"to");
   cpyStr(&cfg.recv_header[1],"cc");
   if (cfg.macro_attr==NULL || cfg.macro_name==NULL) oom();
+  cfg.deref=LDAP_DEREF_FINDING;
 }
 
 void readConf(char *cfile) {
diff --git a/src/config.h b/src/config.h
index 82ccb76..8311537 100644
--- a/src/config.h
+++ b/src/config.h
@@ -32,6 +32,7 @@ struct conf {
   int maxmail;		// max number of recepients allowed
   int maxheader;	// max number of header lines allowed in mail
   int umask;		// file creation mask for db files
+  int deref;		// When to follow LDAP aliases
 };
 
 /**
diff --git a/src/dbaccess.c b/src/dbaccess.c
index 4bda734..018c9e7 100644
--- a/src/dbaccess.c
+++ b/src/dbaccess.c
@@ -196,6 +196,7 @@ void dbConnect() {
   }
 
   ldap_set_option(ldcon, LDAP_OPT_PROTOCOL_VERSION, &cfg.protver);
+  ldap_set_option(ldcon, LDAP_OPT_DEREF, &cfg.deref);
 
   if (cfg.starttls) {
     rc = ldap_start_tls_s(ldcon, NULL, NULL);
-- 
2.9.3