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

« back to all changes in this revision

Viewing changes to nss/protocols.c

  • 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
   protocols.c - NSS lookup functions for protocol database
3
3
 
4
4
   Copyright (C) 2006 West Consulting
5
 
   Copyright (C) 2006, 2007, 2008 Arthur de Jong
 
5
   Copyright (C) 2006, 2007, 2008, 2010 Arthur de Jong
 
6
   Copyright (C) 2010 Symas Corporation
6
7
 
7
8
   This library is free software; you can redistribute it and/or
8
9
   modify it under the terms of the GNU Lesser General Public
29
30
#include "common.h"
30
31
#include "compat/attrs.h"
31
32
 
32
 
static enum nss_status read_protoent(
 
33
/* read a single protocol entry from the stream */
 
34
static nss_status_t read_protoent(
33
35
        TFILE *fp,struct protoent *result,
34
36
        char *buffer,size_t buflen,int *errnop)
35
37
{
41
43
  return NSS_STATUS_SUCCESS;
42
44
}
43
45
 
44
 
enum nss_status _nss_ldap_getprotobyname_r(const char *name,struct protoent *result,char *buffer,size_t buflen,int *errnop)
 
46
#ifdef NSS_FLAVOUR_GLIBC
 
47
 
 
48
/* get a protocol entry by name */
 
49
nss_status_t _nss_ldap_getprotobyname_r(
 
50
        const char *name,struct protoent *result,
 
51
        char *buffer,size_t buflen,int *errnop)
45
52
{
46
53
  NSS_BYNAME(NSLCD_ACTION_PROTOCOL_BYNAME,
47
54
             name,
48
55
             read_protoent(fp,result,buffer,buflen,errnop));
49
56
}
50
57
 
51
 
enum nss_status _nss_ldap_getprotobynumber_r(int number,struct protoent *result,char *buffer,size_t buflen,int *errnop)
 
58
/* get a protocol entry by number */
 
59
nss_status_t _nss_ldap_getprotobynumber_r(
 
60
        int number,struct protoent *result,
 
61
        char *buffer,size_t buflen,int *errnop)
52
62
{
53
63
  NSS_BYINT32(NSLCD_ACTION_PROTOCOL_BYNUMBER,
54
64
              number,
58
68
/* thread-local file pointer to an ongoing request */
59
69
static __thread TFILE *protoentfp;
60
70
 
61
 
enum nss_status _nss_ldap_setprotoent(int UNUSED(stayopen))
 
71
/* start a request to read all protocol entries */
 
72
nss_status_t _nss_ldap_setprotoent(int UNUSED(stayopen))
62
73
{
63
74
  NSS_SETENT(protoentfp);
64
75
}
65
76
 
66
 
enum nss_status _nss_ldap_getprotoent_r(struct protoent *result,char *buffer,size_t buflen,int *errnop)
 
77
/* get a single protocol entry */
 
78
nss_status_t _nss_ldap_getprotoent_r(
 
79
        struct protoent *result,
 
80
        char *buffer,size_t buflen,int *errnop)
67
81
{
68
82
  NSS_GETENT(protoentfp,NSLCD_ACTION_PROTOCOL_ALL,
69
83
             read_protoent(protoentfp,result,buffer,buflen,errnop));
70
84
}
71
85
 
72
 
enum nss_status _nss_ldap_endprotoent(void)
 
86
/* close the stream opened by setprotoent() above */
 
87
nss_status_t _nss_ldap_endprotoent(void)
73
88
{
74
89
  NSS_ENDENT(protoentfp);
75
90
}
 
91
 
 
92
#endif /* NSS_FLAVOUR_GLIBC */
 
93
 
 
94
#ifdef NSS_FLAVOUR_SOLARIS
 
95
 
 
96
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
 
97
 
 
98
static nss_status_t read_protostring(TFILE *fp,nss_XbyY_args_t *args)
 
99
{
 
100
  struct protoent result;
 
101
  nss_status_t retv;
 
102
  char *buffer;
 
103
  size_t buflen;
 
104
  int i;
 
105
  /* read the protoent */
 
106
  retv=read_protoent(fp,&result,NSS_ARGS(args)->buf.buffer,args->buf.buflen,&errno);
 
107
  if (retv!=NSS_STATUS_SUCCESS)
 
108
    return retv;
 
109
  /* allocate a temporary buffer */
 
110
  buflen=args->buf.buflen;
 
111
  buffer=(char *)malloc(buflen);
 
112
  /* build the formatted string */
 
113
  /* FIXME: implement proper buffer size checking */
 
114
  sprintf(buffer,"%s\t\t%d",result.p_name,result.p_proto);
 
115
  if (result.p_aliases)
 
116
    for (i=0; result.p_aliases[i]; i++)
 
117
    {
 
118
      strcat(buffer," ");
 
119
      strcat(buffer,result.p_aliases[i]);
 
120
    }
 
121
  /* copy the result back to the result buffer and free the temporary one */
 
122
  strcpy(NSS_ARGS(args)->buf.buffer,buffer);
 
123
  free(buffer);
 
124
  NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.buffer;
 
125
  NSS_ARGS(args)->returnlen=strlen(NSS_ARGS(args)->buf.buffer);
 
126
  return NSS_STATUS_SUCCESS;
 
127
}
 
128
 
 
129
#define READ_RESULT(fp) \
 
130
  NSS_ARGS(args)->buf.result? \
 
131
    read_protoent(fp,(struct protoent *)NSS_ARGS(args)->buf.result,NSS_ARGS(args)->buf.buffer,NSS_ARGS(args)->buf.buflen,&errno): \
 
132
    read_protostring(fp,args); \
 
133
  if ((NSS_ARGS(args)->buf.result)&&(retv==NSS_STATUS_SUCCESS)) \
 
134
    NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.result;
 
135
 
 
136
#else /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
137
 
 
138
#define READ_RESULT(fp) \
 
139
  read_protoent(fp,(struct protoent *)NSS_ARGS(args)->buf.result,NSS_ARGS(args)->buf.buffer,NSS_ARGS(args)->buf.buflen,&errno); \
 
140
  if (retv==NSS_STATUS_SUCCESS) \
 
141
    NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.result;
 
142
 
 
143
#endif /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
144
 
 
145
static nss_status_t protocols_getprotobyname(nss_backend_t UNUSED(*be),void *args)
 
146
{
 
147
  NSS_BYNAME(NSLCD_ACTION_PROTOCOL_BYNAME,
 
148
             NSS_ARGS(args)->key.name,
 
149
             READ_RESULT(fp));
 
150
}
 
151
 
 
152
static nss_status_t protocols_getprotobynumber(nss_backend_t UNUSED(*be),void *args)
 
153
{
 
154
  NSS_BYINT32(NSLCD_ACTION_PROTOCOL_BYNUMBER,
 
155
              NSS_ARGS(args)->key.number,
 
156
              READ_RESULT(fp));
 
157
}
 
158
 
 
159
static nss_status_t protocols_setprotoent(nss_backend_t *be,void UNUSED(*args))
 
160
{
 
161
  NSS_SETENT(LDAP_BE(be)->fp);
 
162
}
 
163
 
 
164
static nss_status_t protocols_getprotoent(nss_backend_t *be,void *args)
 
165
{
 
166
  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_PROTOCOL_ALL,
 
167
             READ_RESULT(LDAP_BE(be)->fp));
 
168
}
 
169
 
 
170
static nss_status_t protocols_endprotoent(nss_backend_t *be,void UNUSED(*args))
 
171
{
 
172
  NSS_ENDENT(LDAP_BE(be)->fp);
 
173
}
 
174
 
 
175
static nss_backend_op_t protocols_ops[]={
 
176
  nss_ldap_destructor,
 
177
  protocols_endprotoent,
 
178
  protocols_setprotoent,
 
179
  protocols_getprotoent,
 
180
  protocols_getprotobyname,
 
181
  protocols_getprotobynumber
 
182
};
 
183
 
 
184
nss_backend_t *_nss_ldap_protocols_constr(const char UNUSED(*db_name),
 
185
                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
 
186
{
 
187
  return nss_ldap_constructor(protocols_ops,sizeof(protocols_ops));
 
188
}
 
189
 
 
190
#endif /* NSS_FLAVOUR_SOLARIS */