~ubuntu-branches/ubuntu/precise/nss-pam-ldapd/precise-security

« back to all changes in this revision

Viewing changes to debian/nslcd.config

  • Committer: Package Import Robot
  • Author(s): Arthur de Jong
  • Date: 2011-09-04 21:00:00 UTC
  • mfrom: (14.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20110904210000-pe3u91iga88vtr16
Tags: 0.8.4
* Upload to unstable
* switch to using the member attribute by default instead of
  uniqueMember (backwards incompatible change)
* only return "x" as a password hash when the object has the shadowAccount
  objectClass and nsswitch.conf is configured to do shadow lookups using
  LDAP (this avoids some problems with pam_unix)
* fix problem with partial attribute name matches in DN (thanks Timothy
  White)
* fix a problem with objectSid mappings with recent versions of OpenLDAP
  (patch by Wesley Mason)
* set the socket timeout in a connection callback to avoid timeout
  issues during the SSL handshake (patch by Stefan Völkel)
* check for unknown variables in pam_authz_search
* only check password expiration when authenticating, only check account
  expiration when doing authorisation
* make buffer sizes consistent and grow all buffers holding string
  representations of numbers to be able to hold 64-bit numbers
* update AX_PTHREAD from autoconf-archive
* support querying DNS SRV records from a different domain than the current
  one (based on a patch by James M. Leddy)
* fix a problem with uninitialised memory while parsing the tls_ciphers
  option (closes: #638872) (but doesn't work yet due to #640384)
* implement bounds checking of numeric values read from LDAP (patch by
  Jakub Hrozek)
* correctly support large uid and gid values from LDAP (patch by Jakub
  Hrozek)
* improvements to the configure script (patch by Jakub Hrozek)
* switch to dh for debian/rules and bump debhelper compatibility to 8
* build Debian packages with multiarch support
* ship shlibs (but still no symbol files) for libnss-ldapd since that was
  the easiest way to support multiarch
* fix output in init script when restarting nslcd (closes: #637132)
* correctly handle leading and trailing spaces in preseeded debconf uri
  option (patch by Andreas B. Mundt) (closes: #637863)
* support spaces around database names in /etc/nsswitch.conf while
  configuring package (closes: #640185)
* updated Russian debconf translation by Yuri Kozlov (closes: #637751)
* updated French debconf translation by Christian Perrier (closes: #637756)
* added Slovak debconf translation by Slavko (closes: #637759)
* updated Danish debconf translation by Joe Hansen (closes :#637763)
* updated Brazilian Portuguese debconf translation by Denis Doria
* updated Portuguese debconf translation by Américo Monteiro
* updated Japanese debconf translation by Kenshi Muto (closes: #638195)
* updated Czech debconf translation by Miroslav Kure (closes: #639026)
* updated German debconf translation by Chris Leick (closes: #639107)
* updated Spanish debconf translation by Francisco Javier Cuadrado
  (closes: #639236)
* updated Dutch debconf translation by Arthur de Jong with help from Paul
  Gevers and Jeroen Schot

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# default.
21
21
#
22
22
 
23
 
# check the system (non-LDAP configuration files) for some
24
 
# reasonable defaults
25
 
parsesys()
26
 
{
27
 
  # guess domain based on system information
28
 
  db_get nslcd/ldap-base
29
 
  if [ -z "$RET" ]
30
 
  then
31
 
    domain=`hostname --domain` || true
32
 
    [ -z "$domain" ] && domain=`hostname --nis | grep '\.'` || true
33
 
    [ -z "$domain" ] && domain=`hostname --fqdn | sed -n 's/^[^.]*\.//p'` || true
34
 
    [ -z "$domain" ] && domain=`sed -n 's/^ *\(domain\|search\) *\([^ ]*\) *$/\2/p' /etc/resolv.conf | head -n 1` || true
35
 
    db_get nslcd/ldap-base
36
 
    searchbase="$RET"
37
 
    # if the ldap-base value doesn't seem to be preseeded, try to use the
38
 
    # domain name to build the default base
39
 
    if [ -n "$domain" ]
 
23
# read a configuration value from the specified file
 
24
# (it takes care in not overwriting a previously written value)
 
25
read_config()
 
26
{
 
27
  debconf_param="$1"
 
28
  cfg_param="$2"
 
29
  # overwrite debconf value if different from config file
 
30
  db_get "$debconf_param"
 
31
  debconf_value="$RET"
 
32
  cfgfile_value=`sed -n 's/^'"$cfg_param"'[[:space:]]*\([^[:space:]].*[^[:space:]]\)[[:space:]]*$/\1/ip' "$cfgfile" | tail -n 1`
 
33
  [ -n "$cfgfile_value" ] && [ "$debconf_value" != "$cfgfile_value" ] && db_set "$debconf_param" "$cfgfile_value"
 
34
  # we're done
 
35
  return 0
 
36
}
 
37
 
 
38
# figure out the system's domain name
 
39
get_domain()
 
40
{
 
41
  domain=`hostname --domain` || true
 
42
  [ -z "$domain" ] && domain=`hostname --nis | grep '\.'` || true
 
43
  [ -z "$domain" ] && domain=`hostname --fqdn | sed -n 's/^[^.]*\.//p'` || true
 
44
  [ -z "$domain" ] && domain=`sed -n 's/^ *\(domain\|search\) *\([^ ]*\) *$/\2/p' /etc/resolv.conf | head -n 1` || true
 
45
  echo "$domain"
 
46
}
 
47
 
 
48
# find a LDAP server URI by trying DNS and normal hostname lookups
 
49
guess_ldap_uri()
 
50
{
 
51
  # see if ldap server exists on localhost and is listening on ldapi://
 
52
  if [ -e /var/run/slapd/ldapi ]
 
53
  then
 
54
    echo "ldapi:///"
 
55
    return
 
56
  fi
 
57
  # try to lookup _ldap._tcp SRV records
 
58
  if [ -n "$domain" ]
 
59
  then
 
60
    server=`host -N 2 -t SRV _ldap._tcp.$domain 2> /dev/null | grep -v NXDOMAIN | awk '{print $NF}' | head -1 | sed 's/\.$//'` || true
 
61
    if [ -n "$server" ]
40
62
    then
41
 
      searchbase=`echo "$domain" | sed 's/^/dc=/;s/\./,dc=/'` || true
42
 
      db_set nslcd/ldap-base "$searchbase"
 
63
      echo "ldap://$server/"
 
64
      return
43
65
    fi
44
66
  fi
45
 
  # guess ldap server
46
 
  db_get nslcd/ldap-uris
47
 
  if [ -z "$RET" ]
 
67
  # fall back to name lookups
 
68
  if [ -z "$ldap_uri" ]
48
69
  then
 
70
    # try unqualified hostname lookup
49
71
    server=`getent hosts ldap` || true
50
72
    [ -z "$server" ] && server=`getent hosts dirhost` || true
 
73
    # try qualified hostname
51
74
    if [ -n "$domain" ] && [ -z "$server" ]
52
75
    then
53
76
      server=`getent hosts ldap."$domain"` || true
54
77
      [ -z "$server" ] && server=`getent hosts dirhost."$domain"` || true
55
78
    fi
 
79
    # turn into URI with IP address
56
80
    if [ -n "$server" ]
57
81
    then
58
 
      # extract ip address from host entry and quote ipv6 address
 
82
      # extract IP address from host entry and quote IPv6 address
59
83
      ip=`echo $server | sed 's/[[:space:]].*//;s/^\(.*:.*\)$/[\1]/'`
60
 
      db_set nslcd/ldap-uris "ldap://$ip/"
61
 
    fi
 
84
      echo "ldap://$ip/"
 
85
    fi
 
86
  fi
 
87
}
 
88
 
 
89
# guess the LDAP search base by performing LDAP searches on the
 
90
# found server
 
91
query_search_base()
 
92
{
 
93
  ldap_uri="$1"
 
94
  # first try the default naming context
 
95
  context=`ldapsearch -LLL -H "$ldap_uri" -x -b '' -s base defaultNamingContext 2>/dev/null | sed -n 's/^defaultNamingContext: //pi'` || true
 
96
  if [ -n "$context" ]
 
97
  then
 
98
    echo "$context"
 
99
    return
 
100
  fi
 
101
  # go over naming contexts, pick the first one with posixAccount or
 
102
  # posixGroup objects in it
 
103
  for context in `ldapsearch -LLL -H "$ldap_uri" -x -b ''  -s base namingContexts 2>/dev/null | sed -n 's/^namingContexts: //pi'`
 
104
  do
 
105
    # search the context
 
106
    found=`ldapsearch -LLL -H "$ldap_uri" -x -b "$context" -s sub -z 1 '(|(objectClass=posixAccount)(objectclass=posixGroup))' dn 2>/dev/null` || true
 
107
    if [ -n "$found" ]
 
108
    then
 
109
      echo $context
 
110
      return
 
111
    fi
 
112
  done
 
113
}
 
114
 
 
115
# check the system (non-LDAP configuration files) for some
 
116
# reasonable defaults
 
117
parsesys()
 
118
{
 
119
  # guess domain based on system information
 
120
  domain=`get_domain`
 
121
  # guess ldap server URI
 
122
  db_get nslcd/ldap-uris
 
123
  if [ -z "$RET" ]
 
124
  then
 
125
    ldap_uri=`guess_ldap_uri "$domain"`
 
126
    [ -n "$ldap_uri" ] && db_set nslcd/ldap-uris "$ldap_uri"
 
127
  else
 
128
    # only get first URI from any stored (preseeded) value
 
129
    ldap_uri=`echo "$RET" | sed -n 's/[[:space:]].*//'`
 
130
  fi
 
131
  # guess search base
 
132
  db_get nslcd/ldap-base
 
133
  if [ -z "$RET" ]
 
134
  then
 
135
    # try to find the search base from the found URI
 
136
    [ -n "$ldap_uri" ] && search_base=`query_search_base "$ldap_uri"`
 
137
    # try to use the domain name to build the default base
 
138
    if [ -z "$search_base" ] && [ -n "$domain" ]
 
139
    then
 
140
      search_base=`echo "$domain" | sed 's/^/dc=/;s/\./,dc=/g'`
 
141
    fi
 
142
    [ -n "$search_base" ] && db_set nslcd/ldap-base "$search_base"
62
143
  fi
63
144
  # we're done
64
145
  return 0
91
172
    fi
92
173
    [ -n "$uris" ] && db_set nslcd/ldap-uris "$uris"
93
174
  fi
94
 
  # find base config
95
 
  db_get nslcd/ldap-base
96
 
  if [ -z "$RET" ]
97
 
  then
98
 
    searchbase=`sed -n 's/^base[[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/ip' "$cfgfile" | tail -n 1`
99
 
    [ -n "$searchbase" ] && db_set nslcd/ldap-base "$searchbase"
100
 
  fi
101
 
  # find binddn
102
 
  db_get nslcd/ldap-binddn
103
 
  if [ -z "$RET" ]
104
 
  then
105
 
    binddn=`sed -n 's/^binddn[[:space:]]*//ip' "$cfgfile" | tail -n 1`
106
 
    db_set nslcd/ldap-binddn "$binddn"
107
 
  fi
108
 
  # find bindpw
109
 
  db_get nslcd/ldap-bindpw
110
 
  if [ -z "$RET" ]
111
 
  then
112
 
    bindpw=`sed -n 's/^bindpw[[:space:]]*//ip' "$cfgfile" | tail -n 1`
113
 
    db_set nslcd/ldap-bindpw "$bindpw"
114
 
  fi
 
175
  # read simple options
 
176
  read_config nslcd/ldap-base base
 
177
  read_config nslcd/ldap-binddn binddn
 
178
  read_config nslcd/ldap-bindpw bindpw
 
179
  read_config nslcd/ldap-sasl-mech sasl_mech
 
180
  read_config nslcd/ldap-sasl-realm sasl_realm
 
181
  read_config nslcd/ldap-sasl-authcid sasl_authcid
 
182
  read_config nslcd/ldap-sasl-authzid sasl_authzid
 
183
  read_config nslcd/ldap-sasl-secprops sasl_secprops
 
184
  read_config nslcd/ldap-sasl-krb5-ccname krb5_ccname
115
185
  # check ssl option
116
186
  db_get nslcd/ldap-starttls
117
187
  if [ -z "$RET" ]
141
211
# and fall back to guessing the config from some other system files
142
212
if [ -f "$CONFFILE" ]
143
213
then
144
 
  # clear settings to pick up valus from configfile
145
 
  db_set nslcd/ldap-uris ""
146
 
  db_set nslcd/ldap-base ""
147
 
  db_set nslcd/ldap-binddn ""
148
 
  db_set nslcd/ldap-bindpw ""
149
 
  db_set nslcd/ldap-starttls ""
150
214
  # parse current configuration
151
215
  parsecfg "$CONFFILE"
152
216
else
160
224
  db_get nslcd/ldap-uris
161
225
  [ -z "$RET" ] && db_set nslcd/ldap-uris "ldap://127.0.0.1/"
162
226
  db_get nslcd/ldap-base
163
 
  [ -z "$RET" ] && db_set nslcd/ldap-base "dc=example,dc=net/"
 
227
  [ -z "$RET" ] && db_set nslcd/ldap-base "dc=example,dc=net"
164
228
fi
165
229
 
166
230
# fallback for starttls option
167
231
db_get nslcd/ldap-starttls
168
232
[ -z "$RET" ] && db_set nslcd/ldap-starttls "false"
169
233
 
 
234
# deduce auth-type from available information
 
235
db_get nslcd/ldap-auth-type
 
236
if [ -z "$RET" ]
 
237
then
 
238
  db_get nslcd/ldap-sasl-mech
 
239
  sasl_mech="$RET"
 
240
  db_get nslcd/ldap-binddn
 
241
  binddn="$RET"
 
242
  if [ -n "$sasl_mech" ]
 
243
  then
 
244
    db_set nslcd/ldap-auth-type "SASL"
 
245
  elif [ -n "$binddn" ]
 
246
  then
 
247
    db_set nslcd/ldap-auth-type "simple"
 
248
  else
 
249
    db_set nslcd/ldap-auth-type "none"
 
250
  fi
 
251
fi
 
252
 
170
253
#
171
254
# This is the second part of the script. In this part the configurable
172
255
# settings will be presented to the user for approval. The postinst
182
265
    db_input high nslcd/ldap-uris || true
183
266
    db_input high nslcd/ldap-base || true
184
267
    # ask the questions, go to the next question or exit
185
 
    state="binddn"
 
268
    state="authtype"
186
269
    db_go || exit 1
187
270
    # TODO: add error checking on options
188
271
    ;;
189
 
  binddn)
190
 
    # ask for login information
191
 
    db_input medium nslcd/ldap-binddn || true
 
272
  authtype)
 
273
    # ask for authentication type
 
274
    db_input medium nslcd/ldap-auth-type || true
192
275
    # ask the question, go to the next question or back
193
 
    state="bindpw"
 
276
    state="authentication"
194
277
    db_go || state="server"
195
278
    ;;
196
 
  bindpw)
197
 
    # only ask question if we have a binddn
198
 
    db_get nslcd/ldap-binddn
199
 
    if [ -n "$RET" ]
200
 
    then
201
 
      # ask for login information
202
 
      db_input medium nslcd/ldap-bindpw || true
203
 
    else
204
 
      # clear password
 
279
  authentication)
 
280
    # check which questions to ask, depending on the authentication type
 
281
    db_get nslcd/ldap-auth-type
 
282
    case "$RET" in
 
283
    none)
 
284
      # anonymous bind, nothing to ask (clear password)
205
285
      db_set nslcd/ldap-bindpw ""
 
286
      state="starttls"
 
287
      ;;
 
288
    simple)
 
289
      # ask for binddn and bindpw
 
290
      db_input medium nslcd/ldap-binddn || true
 
291
      db_input medium nslcd/ldap-bindpw || true
 
292
      state="starttls"
 
293
      ;;
 
294
    SASL)
 
295
      # ask about SASL mechanism (other SASL questions depend on this)
 
296
      db_input medium nslcd/ldap-sasl-mech || true
 
297
      state="sasloptions"
 
298
      ;;
 
299
    *)
 
300
      exit 1
 
301
      ;;
 
302
    esac
 
303
    db_go || state="authtype"
 
304
    ;;
 
305
  sasloptions)
 
306
    # get SASL mech
 
307
    db_get nslcd/ldap-sasl-mech
 
308
    sasl_mech="$RET"
 
309
    # ask SASL questions
 
310
    db_input medium nslcd/ldap-sasl-realm || true
 
311
    if [ "$sasl_mech" != "GSSAPI" ]
 
312
    then
 
313
      db_input medium nslcd/ldap-sasl-authcid || true
 
314
      db_input medium nslcd/ldap-bindpw || true
 
315
    fi
 
316
    db_input medium nslcd/ldap-sasl-authzid || true
 
317
    db_input medium nslcd/ldap-sasl-secprops || true
 
318
    if [ "$sasl_mech" = "GSSAPI" ]
 
319
    then
 
320
      # have a default for ldap-sasl-krb5-ccname
 
321
      db_get nslcd/ldap-sasl-krb5-ccname
 
322
      [ -z "$RET" ] && db_set nslcd/ldap-sasl-krb5-ccname "/var/run/nslcd/nslcd.tkt"
 
323
      db_input low nslcd/ldap-sasl-krb5-ccname || true
206
324
    fi
207
325
    # ask the question, go to the next question or back
208
326
    state="starttls"
209
 
    db_go || state="binddn"
 
327
    db_go || state="authentication"
210
328
    ;;
211
329
  starttls)
212
330
    # check if ldaps:// URL's are used
221
339
      db_input medium nslcd/ldap-starttls || true
222
340
    fi
223
341
    # ask the question, go to the next question or back
 
342
    # (we go back to authtype because the previous questions were optional)
224
343
    state="reqcert"
225
 
    db_go || state="bindpw"
 
344
    db_go || state="authtype"
226
345
    ;;
227
346
  reqcert)
228
347
    # check if ldaps:// URL's are used
235
354
    then
236
355
      # ask whether to do certificate validation
237
356
      db_input high nslcd/ldap-reqcert || true
 
357
    else
 
358
      db_set nslcd/ldap-reqcert ""
238
359
    fi
239
360
    # ask the question, go to the next question or back
 
361
    # (we go back to authtype because the previous questions were optional)
240
362
    state="done"
241
 
    db_go || state="starttls"
 
363
    db_go || state="authtype"
242
364
    ;;
243
365
  esac
244
366
done