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

« back to all changes in this revision

Viewing changes to nss/common.h

  • 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:
2
2
   common.h - common functions for NSS lookups
3
3
 
4
4
   Copyright (C) 2006 West Consulting
5
 
   Copyright (C) 2006, 2007, 2008, 2009, 2010 Arthur de Jong
 
5
   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Arthur de Jong
6
6
 
7
7
   This library is free software; you can redistribute it and/or
8
8
   modify it under the terms of the GNU Lesser General Public
24
24
#define NSS__COMMON_H 1
25
25
 
26
26
#include <stdio.h>
 
27
#include <stdlib.h>
27
28
 
28
29
#include "nslcd.h"
29
30
#include "common/nslcd-prot.h"
66
67
  fp=NULL; \
67
68
  return NSS_STATUS_NOTFOUND;
68
69
 
 
70
/* These are some general macros that are used to build parts of the
 
71
   genral macros below. */
 
72
 
 
73
/* check to see if we should answer NSS requests */
 
74
#define NSS_AVAILCHECK \
 
75
  if (!_nss_ldap_enablelookups) \
 
76
    return NSS_STATUS_UNAVAIL;
 
77
 
 
78
#ifdef NSS_FLAVOUR_GLIBC
 
79
 
 
80
/* extra definitions we need (nothing for Glibc) */
 
81
#define NSS_EXTRA_DEFS ;
 
82
 
 
83
/* check validity of passed buffer (Glibc flavour) */
 
84
#define NSS_BUFCHECK \
 
85
  if ((buffer==NULL)||(buflen==0)) \
 
86
  { \
 
87
      *errnop=EINVAL; \
 
88
      return NSS_STATUS_UNAVAIL; \
 
89
  }
 
90
 
 
91
#endif /* NSS_FLAVOUR_GLIBC */
 
92
 
 
93
#ifdef NSS_FLAVOUR_SOLARIS
 
94
 
 
95
/* extra definitions we need (Solaris NSS functions don't pass errno) */
 
96
#define NSS_EXTRA_DEFS \
 
97
  int *errnop=&(errno);
 
98
 
 
99
/* check validity of passed buffer (Solaris flavour) */
 
100
#define NSS_BUFCHECK \
 
101
  if ((NSS_ARGS(args)->buf.buffer==NULL)||(NSS_ARGS(args)->buf.buflen<=0)) \
 
102
  { \
 
103
      NSS_ARGS(args)->erange=1; \
 
104
      return NSS_STATUS_TRYAGAIN; \
 
105
  }
 
106
 
 
107
/* this is the backend structure for Solaris */
 
108
struct nss_ldap_backend
 
109
{
 
110
  nss_backend_op_t *ops; /* function-pointer table */
 
111
  int n_ops; /* number of function pointers */
 
112
  TFILE *fp; /* the file pointer for {set,get,end}ent() functions */
 
113
};
 
114
 
 
115
/* constructor for LDAP backends */
 
116
nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops,size_t sizeofops);
 
117
 
 
118
/* destructor for LDAP backends */
 
119
nss_status_t nss_ldap_destructor(nss_backend_t *be,void UNUSED(*args));
 
120
 
 
121
#endif /* NSS_FLAVOUR_SOLARIS */
 
122
 
69
123
/* The following macros to automatically generate get..byname(),
70
124
   get..bynumber(), setent(), getent() and endent() function
71
125
   bodies. These functions have very common code so this can
82
136
#define NSS_BYGEN(action,writefn,readfn) \
83
137
  TFILE *fp; \
84
138
  int32_t tmpint32; \
85
 
  enum nss_status retv; \
86
 
  if (!_nss_ldap_enablelookups) \
87
 
    return NSS_STATUS_UNAVAIL; \
88
 
  /* check that we have a valid buffer */ \
89
 
  if ((buffer==NULL)||(buflen<=0)) \
90
 
  { \
91
 
      *errnop=EINVAL; \
92
 
      return NSS_STATUS_UNAVAIL; \
93
 
  } \
 
139
  nss_status_t retv; \
 
140
  NSS_EXTRA_DEFS; \
 
141
  NSS_AVAILCHECK; \
 
142
  NSS_BUFCHECK; \
94
143
  /* open socket and write request */ \
95
144
  NSLCD_REQUEST(fp,action,writefn); \
96
145
  /* read response */ \
119
168
/* This macro generates a simple setent() function body. This closes any
120
169
   open streams so that NSS_GETENT() can open a new file. */
121
170
#define NSS_SETENT(fp) \
122
 
  if (!_nss_ldap_enablelookups) \
123
 
    return NSS_STATUS_UNAVAIL; \
 
171
  NSS_AVAILCHECK; \
124
172
  if (fp!=NULL) \
125
173
  { \
126
174
    (void)tio_close(fp); \
133
181
   a response header. A single entry is read with the readfn() function. */
134
182
#define NSS_GETENT(fp,action,readfn) \
135
183
  int32_t tmpint32; \
136
 
  enum nss_status retv; \
137
 
  if (!_nss_ldap_enablelookups) \
138
 
    return NSS_STATUS_UNAVAIL; \
139
 
  /* check that we have a valid buffer */ \
140
 
  if ((buffer==NULL)||(buflen<=0)) \
141
 
  { \
142
 
      /* close stream */ \
143
 
      if (fp!=NULL) \
144
 
      { \
145
 
        (void)tio_close(fp); \
146
 
        fp=NULL; \
147
 
      } \
148
 
      /* indicate error */ \
149
 
      *errnop=EINVAL; \
150
 
      return NSS_STATUS_UNAVAIL; \
151
 
  } \
 
184
  nss_status_t retv; \
 
185
  NSS_EXTRA_DEFS; \
 
186
  NSS_AVAILCHECK; \
 
187
  NSS_BUFCHECK; \
152
188
  /* check that we have a valid file descriptor */ \
153
189
  if (fp==NULL) \
154
190
  { \
180
216
/* This macro generates a endent() function body. This just closes
181
217
   the stream. */
182
218
#define NSS_ENDENT(fp) \
183
 
  if (!_nss_ldap_enablelookups) \
184
 
    return NSS_STATUS_UNAVAIL; \
 
219
  NSS_AVAILCHECK; \
185
220
  if (fp!=NULL) \
186
221
  { \
187
222
    (void)tio_close(fp); \