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

« back to all changes in this revision

Viewing changes to nss/rpc.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
   rpc.c - NSS lookup functions for rpc 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_rpcent(
 
33
/* read a sinlge rpc entry from the stream */
 
34
static nss_status_t read_rpcent(
33
35
        TFILE *fp,struct rpcent *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_getrpcbyname_r(const char *name,struct rpcent *result,char *buffer,size_t buflen,int *errnop)
 
46
#ifdef NSS_FLAVOUR_GLIBC
 
47
 
 
48
/* get a rpc entry by name */
 
49
nss_status_t _nss_ldap_getrpcbyname_r(
 
50
        const char *name,struct rpcent *result,
 
51
        char *buffer,size_t buflen,int *errnop)
45
52
{
46
53
  NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
47
54
             name,
48
55
             read_rpcent(fp,result,buffer,buflen,errnop));
49
56
}
50
57
 
51
 
enum nss_status _nss_ldap_getrpcbynumber_r(int number,struct rpcent *result,char *buffer,size_t buflen,int *errnop)
 
58
/* get a rpc entry by number */
 
59
nss_status_t _nss_ldap_getrpcbynumber_r(
 
60
        int number,struct rpcent *result,
 
61
        char *buffer,size_t buflen,int *errnop)
52
62
{
53
63
  NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
54
64
              number,
56
66
}
57
67
 
58
68
/* thread-local file pointer to an ongoing request */
59
 
static __thread TFILE *protoentfp;
60
 
 
61
 
enum nss_status _nss_ldap_setrpcent(int UNUSED(stayopen))
62
 
{
63
 
  NSS_SETENT(protoentfp);
64
 
}
65
 
 
66
 
enum nss_status _nss_ldap_getrpcent_r(struct rpcent *result,char *buffer,size_t buflen,int *errnop)
67
 
{
68
 
  NSS_GETENT(protoentfp,NSLCD_ACTION_RPC_ALL,
69
 
             read_rpcent(protoentfp,result,buffer,buflen,errnop));
70
 
}
71
 
 
72
 
enum nss_status _nss_ldap_endrpcent(void)
73
 
{
74
 
  NSS_ENDENT(protoentfp);
75
 
}
 
69
static __thread TFILE *rpcentfp;
 
70
 
 
71
/* request a stream to list all rpc entries */
 
72
nss_status_t _nss_ldap_setrpcent(int UNUSED(stayopen))
 
73
{
 
74
  NSS_SETENT(rpcentfp);
 
75
}
 
76
 
 
77
/* get an rpc entry from the list */
 
78
nss_status_t _nss_ldap_getrpcent_r(
 
79
        struct rpcent *result,
 
80
        char *buffer,size_t buflen,int *errnop)
 
81
{
 
82
  NSS_GETENT(rpcentfp,NSLCD_ACTION_RPC_ALL,
 
83
             read_rpcent(rpcentfp,result,buffer,buflen,errnop));
 
84
}
 
85
 
 
86
/* close the stream opened by setrpcent() above */
 
87
nss_status_t _nss_ldap_endrpcent(void)
 
88
{
 
89
  NSS_ENDENT(rpcentfp);
 
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_rpcstring(TFILE *fp,nss_XbyY_args_t *args)
 
99
{
 
100
  struct rpcent result;
 
101
  nss_status_t retv;
 
102
  char *buffer;
 
103
  size_t buflen;
 
104
  int i;
 
105
  /* read the rpcent */
 
106
  retv=read_rpcent(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 %d",result.r_name,result.r_number);
 
115
  if (result.r_aliases)
 
116
    for (i=0; result.r_aliases[i]; i++)
 
117
    {
 
118
      strcat(buffer," ");
 
119
      strcat(buffer,result.r_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_rpcent(fp,(struct rpcent *)NSS_ARGS(args)->buf.result,NSS_ARGS(args)->buf.buffer,NSS_ARGS(args)->buf.buflen,&errno): \
 
132
    read_rpcstring(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_rpcent(fp,(struct rpcent *)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 rpc_getrpcbyname(nss_backend_t UNUSED(*be),void *args)
 
146
{
 
147
  NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
 
148
             NSS_ARGS(args)->key.name,
 
149
             READ_RESULT(fp));
 
150
}
 
151
 
 
152
static nss_status_t rpc_getrpcbynumber(nss_backend_t UNUSED(*be),void *args)
 
153
{
 
154
  NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
 
155
              NSS_ARGS(args)->key.number,
 
156
              READ_RESULT(fp));
 
157
}
 
158
 
 
159
static nss_status_t rpc_setrpcent(nss_backend_t *be,void UNUSED(*args))
 
160
{
 
161
  NSS_SETENT(LDAP_BE(be)->fp);
 
162
}
 
163
 
 
164
static nss_status_t rpc_getrpcent(nss_backend_t *be,void *args)
 
165
{
 
166
  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_RPC_ALL,
 
167
             READ_RESULT(LDAP_BE(be)->fp));
 
168
}
 
169
 
 
170
static nss_status_t rpc_endrpcent(nss_backend_t *be,void UNUSED(*args))
 
171
{
 
172
  NSS_ENDENT(LDAP_BE(be)->fp);
 
173
}
 
174
 
 
175
static nss_backend_op_t rpc_ops[]={
 
176
  nss_ldap_destructor,
 
177
  rpc_endrpcent,
 
178
  rpc_setrpcent,
 
179
  rpc_getrpcent,
 
180
  rpc_getrpcbyname,
 
181
  rpc_getrpcbynumber
 
182
};
 
183
 
 
184
nss_backend_t *_nss_ldap_rpc_constr(const char UNUSED(*db_name),
 
185
                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
 
186
{
 
187
  return nss_ldap_constructor(rpc_ops,sizeof(rpc_ops));
 
188
}
 
189
 
 
190
#endif /* NSS_FLAVOUR_SOLARIS */