~ubuntu-branches/ubuntu/wily/nss-pam-ldapd/wily-proposed

« back to all changes in this revision

Viewing changes to nss/ethers.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
   ethers.c - NSS lookup functions for ethers 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_etherent(
 
33
/* read an ethernet entry from the stream */
 
34
static nss_status_t read_etherent(
33
35
        TFILE *fp,struct etherent *result,
34
36
        char *buffer,size_t buflen,int *errnop)
35
37
{
40
42
  return NSS_STATUS_SUCCESS;
41
43
}
42
44
 
 
45
#ifdef NSS_FLAVOUR_GLIBC
 
46
 
43
47
/* map a hostname to the corresponding ethernet address */
44
 
enum nss_status _nss_ldap_gethostton_r(
 
48
nss_status_t _nss_ldap_gethostton_r(
45
49
        const char *name,struct etherent *result,
46
50
        char *buffer,size_t buflen,int *errnop)
47
51
{
51
55
}
52
56
 
53
57
/* map an ethernet address to the corresponding hostname */
54
 
enum nss_status _nss_ldap_getntohost_r(
 
58
nss_status_t _nss_ldap_getntohost_r(
55
59
        const struct ether_addr *addr,struct etherent *result,
56
60
        char *buffer,size_t buflen,int *errnop)
57
61
{
63
67
/* thread-local file pointer to an ongoing request */
64
68
static __thread TFILE *etherentfp;
65
69
 
66
 
enum nss_status _nss_ldap_setetherent(int UNUSED(stayopen))
 
70
/* open a connection to read all ether entries */
 
71
nss_status_t _nss_ldap_setetherent(int UNUSED(stayopen))
67
72
{
68
73
  NSS_SETENT(etherentfp);
69
74
}
70
75
 
71
 
enum nss_status _nss_ldap_getetherent_r(
 
76
/* read a single ethernet entry from the stream */
 
77
nss_status_t _nss_ldap_getetherent_r(
72
78
        struct etherent *result,
73
79
        char *buffer,size_t buflen,int *errnop)
74
80
{
76
82
             read_etherent(etherentfp,result,buffer,buflen,errnop));
77
83
}
78
84
 
79
 
enum nss_status _nss_ldap_endetherent(void)
 
85
/* close the stream opened with setetherent() above */
 
86
nss_status_t _nss_ldap_endetherent(void)
80
87
{
81
88
  NSS_ENDENT(etherentfp);
82
89
}
 
90
 
 
91
#endif /* NSS_FLAVOUR_GLIBC */
 
92
 
 
93
#ifdef NSS_FLAVOUR_SOLARIS
 
94
 
 
95
#ifndef NSS_BUFLEN_ETHERS
 
96
#define NSS_BUFLEN_ETHERS 1024
 
97
#endif /* NSS_BUFLEN_ETHERS */
 
98
 
 
99
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
 
100
 
 
101
static nss_status_t read_etherstring(TFILE *fp,nss_XbyY_args_t *args)
 
102
{
 
103
  struct etherent result;
 
104
  nss_status_t retv;
 
105
  char *buffer;
 
106
  int res;
 
107
  /* read the etherent into a temporary buffer */
 
108
  buffer=(char *)malloc(args->buf.buflen);
 
109
  if (buffer==NULL)
 
110
    return NSS_STATUS_UNAVAIL;
 
111
  retv=read_etherent(fp,&result,buffer,args->buf.buflen,&errno);
 
112
  if (retv!=NSS_STATUS_SUCCESS)
 
113
  {
 
114
    free(buffer);
 
115
    return retv;
 
116
  }
 
117
  /* make a string representation */
 
118
  res=snprintf(args->buf.buffer,args->buf.buflen,
 
119
               "%s %s",ether_ntoa(&result.e_addr),result.e_name);
 
120
  free(buffer);
 
121
  if ((res<0)||(res>=args->buf.buflen))
 
122
    return NSS_STATUS_TRYAGAIN;
 
123
  NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.buffer;
 
124
  NSS_ARGS(args)->returnlen=strlen(NSS_ARGS(args)->buf.buffer);
 
125
  return NSS_STATUS_SUCCESS;
 
126
}
 
127
 
 
128
#define READ_RESULT(fp) \
 
129
  NSS_ARGS(args)->buf.result? \
 
130
    read_etherent(fp,(struct etherent *)NSS_ARGS(args)->buf.result,NSS_ARGS(args)->buf.buffer,NSS_ARGS(args)->buf.buflen,&errno): \
 
131
    read_etherstring(fp,args); \
 
132
  if ((NSS_ARGS(args)->buf.result)&&(retv==NSS_STATUS_SUCCESS)) \
 
133
    NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.result;
 
134
 
 
135
#else /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
136
 
 
137
#define READ_RESULT(fp) \
 
138
  read_etherent(fp,(struct etherent *)NSS_ARGS(args)->buf.result,NSS_ARGS(args)->buf.buffer,NSS_ARGS(args)->buf.buflen,&errno); \
 
139
  if (retv==NSS_STATUS_SUCCESS) \
 
140
    NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.result;
 
141
 
 
142
#endif /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
143
 
 
144
/* map a hostname to the corresponding ethernet address */
 
145
static nss_status_t ethers_gethostton(nss_backend_t UNUSED(*be),void *args)
 
146
{
 
147
  NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME,
 
148
             NSS_ARGS(args)->key.name,
 
149
             READ_RESULT(fp));
 
150
}
 
151
 
 
152
/* map an ethernet address to the corresponding hostname */
 
153
static nss_status_t ethers_getntohost(nss_backend_t UNUSED(*be),void *args)
 
154
{
 
155
  struct ether_addr *addr=(struct ether_addr *)(NSS_ARGS(args)->key.ether);
 
156
  NSS_BYTYPE(NSLCD_ACTION_ETHER_BYETHER,
 
157
             *addr,uint8_t[6],
 
158
             READ_RESULT(fp));
 
159
}
 
160
 
 
161
static nss_status_t ethers_destructor(nss_backend_t *be,void UNUSED(*args))
 
162
{
 
163
  free(be);
 
164
  return NSS_STATUS_SUCCESS;
 
165
}
 
166
 
 
167
static nss_backend_op_t ethers_ops[]={
 
168
  ethers_destructor,
 
169
  ethers_gethostton,
 
170
  ethers_getntohost
 
171
};
 
172
 
 
173
nss_backend_t *_nss_ldap_ethers_constr(const char UNUSED(*db_name),
 
174
                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
 
175
{
 
176
  nss_backend_t *be;
 
177
  if (!(be=(nss_backend_t *)malloc(sizeof(*be))))
 
178
    return NULL;
 
179
  be->ops=ethers_ops;
 
180
  be->n_ops=sizeof(ethers_ops)/sizeof(nss_backend_op_t);
 
181
  return be;
 
182
}
 
183
 
 
184
#endif /* NSS_FLAVOUR_SOLARIS */