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

« back to all changes in this revision

Viewing changes to nslcd/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:
3
3
   This file is part of the nss-pam-ldapd library.
4
4
 
5
5
   Copyright (C) 2006 West Consulting
6
 
   Copyright (C) 2006, 2007, 2008, 2009, 2010 Arthur de Jong
 
6
   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Arthur de Jong
7
7
 
8
8
   This library is free software; you can redistribute it and/or
9
9
   modify it under the terms of the GNU Lesser General Public
54
54
int mysnprintf(char *buffer,size_t buflen,const char *format, ...)
55
55
  LIKE_PRINTF(3,4);
56
56
 
 
57
/* return the fully qualified domain name of the current host
 
58
   the returned value does not need to be freed but is re-used for every
 
59
   call */
 
60
MUST_USE const char *getfqdn(void);
 
61
 
57
62
/* This tries to get the user password attribute from the entry.
58
63
   It will try to return an encrypted password as it is used in /etc/passwd,
59
64
   /etc/group or /etc/shadow depending upon what is in the directory.
60
65
   This function will return NULL if no passwd is found and will return the
61
66
   literal value in the directory if conversion is not possible. */
62
 
const char *get_userpassword(MYLDAP_ENTRY *entry,const char *attr);
 
67
const char *get_userpassword(MYLDAP_ENTRY *entry,const char *attr,
 
68
                             char *buffer,size_t buflen);
63
69
 
64
70
/* write out an address, parsing the addr value */
65
71
int write_address(TFILE *fp,const char *addr);
78
84
  if (read_address(fp,addr,&(len),&(af))) \
79
85
    return -1;
80
86
 
 
87
/* convert the provided string representation of a sid
 
88
   (e.g. S-1-5-21-1936905831-823966427-12391542-23578)
 
89
   to a format that can be used to search the objectSid property with */
 
90
MUST_USE char *sid2search(const char *sid);
 
91
 
 
92
/* return the last security identifier of the binary sid */
 
93
MUST_USE long int binsid2id(const char *binsid);
 
94
 
81
95
/* checks to see if the specified string is a valid user or group name */
82
96
MUST_USE int isvalidname(const char *name);
83
97
 
84
98
/* Perform an LDAP lookup to translate the DN into a uid.
85
99
   This function either returns NULL or a strdup()ed string. */
86
 
MUST_USE char *lookup_dn2uid(MYLDAP_SESSION *session,const char *dn,int *rcp);
 
100
MUST_USE char *lookup_dn2uid(MYLDAP_SESSION *session,const char *dn,int *rcp,char *buf,size_t buflen);
87
101
 
88
102
/* transforms the DN info a uid doing an LDAP lookup if needed */
89
103
MUST_USE char *dn2uid(MYLDAP_SESSION *session,const char *dn,char *buf,size_t buflen);
90
104
 
91
105
/* use the user id to lookup an LDAP entry */
92
 
MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid);
 
106
MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid,int *rcp);
93
107
 
94
108
/* transforms the uid into a DN by doing an LDAP lookup */
95
109
MUST_USE char *uid2dn(MYLDAP_SESSION *session,const char *uid,char *buf,size_t buflen);
96
110
 
 
111
/* try to update the shadowLastChange attribute of the entry if possible */
 
112
int update_lastchange(MYLDAP_SESSION *session,const char *userdn);
 
113
 
 
114
/* use the user id to lookup an LDAP entry with the shadow attributes
 
115
   requested*/
 
116
MYLDAP_ENTRY *shadow_uid2entry(MYLDAP_SESSION *session,const char *username,int *rcp);
 
117
 
 
118
/* return shadown information */
 
119
void get_shadow_properties(MYLDAP_ENTRY *entry,long *lastchangedate,
 
120
                           long *mindays,long *maxdays,long *warndays,
 
121
                           long *inactdays,long *expiredate,unsigned long *flag);
 
122
 
 
123
 
 
124
/* check whether the nsswitch.conf file has LDAP as a naming source for db */
 
125
int nsswitch_db_uses_ldap(const char *filename,const char *db);
 
126
 
 
127
/* fallback definition of HOST_NAME_MAX */
 
128
#ifndef HOST_NAME_MAX
 
129
#ifdef _POSIX_HOST_NAME_MAX
 
130
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
 
131
#else
 
132
#define HOST_NAME_MAX 255
 
133
#endif /* _POSIX_HOST_NAME_MAX */
 
134
#endif /* not HOST_NAME_MAX */
 
135
 
 
136
/* provide strtouid() function alias */
 
137
#if SIZEOF_UID_T == SIZEOF_UNSIGNED_LONG_INT
 
138
#define strtouid (uid_t)strtoul
 
139
#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
 
140
#define strtouid (uid_t)strtoull
 
141
#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_INT
 
142
#define WANT_STRTOUI 1
 
143
#define strtouid (uid_t)strtoui
 
144
#else
 
145
#error unable to find implementation for strtouid()
 
146
#endif
 
147
 
 
148
/* provide strtouid() function alias */
 
149
#if SIZEOF_GID_T == SIZEOF_UNSIGNED_LONG_INT
 
150
#define strtogid (gid_t)strtoul
 
151
#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
 
152
#define strtogid (gid_t)strtoull
 
153
#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_INT
 
154
#ifndef WANT_STRTOUI
 
155
#define WANT_STRTOUI 1
 
156
#endif
 
157
#define strtogid (uid_t)strtoui
 
158
#else
 
159
#error unable to find implementation for strtogid()
 
160
#endif
 
161
 
 
162
#ifdef WANT_STRTOUI
 
163
/* provide a strtoui() if it is needed */
 
164
unsigned int strtoui(const char *nptr,char **endptr,int base);
 
165
#endif /* WANT_STRTOUI */
 
166
 
97
167
/* these are the functions for initialising the database specific
98
168
   modules */
99
169
void alias_init(void);
140
210
int nslcd_service_all(TFILE *fp,MYLDAP_SESSION *session);
141
211
int nslcd_shadow_byname(TFILE *fp,MYLDAP_SESSION *session);
142
212
int nslcd_shadow_all(TFILE *fp,MYLDAP_SESSION *session);
143
 
int nslcd_pam_authc(TFILE *fp,MYLDAP_SESSION *session);
 
213
int nslcd_pam_authc(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
144
214
int nslcd_pam_authz(TFILE *fp,MYLDAP_SESSION *session);
145
215
int nslcd_pam_sess_o(TFILE *fp,MYLDAP_SESSION *session);
146
216
int nslcd_pam_sess_c(TFILE *fp,MYLDAP_SESSION *session);
147
 
int nslcd_pam_pwmod(TFILE *fp,MYLDAP_SESSION *session);
 
217
int nslcd_pam_pwmod(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
148
218
 
149
219
/* macros for generating service handling code */
150
 
#define NSLCD_HANDLE(db,fn,readfn,logcall,action,mkfilter,writefn) \
 
220
#define NSLCD_HANDLE(db,fn,readfn,action,mkfilter,writefn) \
151
221
  int nslcd_##db##_##fn(TFILE *fp,MYLDAP_SESSION *session) \
152
 
  NSLCD_HANDLE_BODY(db,fn,readfn,logcall,action,mkfilter,writefn)
153
 
#define NSLCD_HANDLE_UID(db,fn,readfn,logcall,action,mkfilter,writefn) \
 
222
  NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn)
 
223
#define NSLCD_HANDLE_UID(db,fn,readfn,action,mkfilter,writefn) \
154
224
  int nslcd_##db##_##fn(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid) \
155
 
  NSLCD_HANDLE_BODY(db,fn,readfn,logcall,action,mkfilter,writefn)
156
 
#define NSLCD_HANDLE_BODY(db,fn,readfn,logcall,action,mkfilter,writefn) \
 
225
  NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn)
 
226
#define NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn) \
157
227
  { \
158
228
    /* define common variables */ \
159
229
    int32_t tmpint32; \
163
233
    int rc,i; \
164
234
    /* read request parameters */ \
165
235
    readfn; \
166
 
    /* log call */ \
167
 
    logcall; \
168
236
    /* write the response header */ \
169
237
    WRITE_INT32(fp,NSLCD_VERSION); \
170
238
    WRITE_INT32(fp,action); \