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

« back to all changes in this revision

Viewing changes to tests/test_myldap.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
   test_myldap.c - simple test for the myldap module
3
3
   This file is part of the nss-pam-ldapd library.
4
4
 
5
 
   Copyright (C) 2007, 2008, 2009 Arthur de Jong
 
5
   Copyright (C) 2007, 2008, 2009, 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
29
29
#include <assert.h>
30
30
#include <signal.h>
31
31
 
 
32
#include "common.h"
 
33
 
32
34
#include "nslcd/log.h"
33
35
#include "nslcd/cfg.h"
34
36
#include "nslcd/myldap.h"
35
37
 
36
 
#ifndef __ASSERT_FUNCTION
37
 
#define __ASSERT_FUNCTION ""
38
 
#endif /* not __ASSERT_FUNCTION */
39
 
 
40
 
#define assertstreq(str1,str2) \
41
 
  (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2) ")==0", \
42
 
                    __FILE__, __LINE__, __ASSERT_FUNCTION))
43
 
 
44
 
/* for Solaris: */
45
 
#define __assert_fail(assertion,file,line,function) __assert(assertion,file,line)
46
 
 
47
 
/* method for determening string equalness */
48
 
static void assertstreq_impl(const char *str1,const char *str2,
49
 
                             const char *assertion,const char *file,
50
 
                             int line,const char *function)
51
 
{
52
 
  if (strcmp(str1,str2)!=0)
53
 
    __assert_fail(assertion,file,line,function);
54
 
}
55
 
 
56
38
struct worker_args {
57
39
  int id;
58
40
};
59
41
 
60
 
static const char *foo="";
61
 
 
62
 
/* this is a simple way to get this into an executable,
63
 
   we should probably read a valid config instead */
64
 
const char **base_get_var(int UNUSED(map)) {return NULL;}
65
 
int *scope_get_var(int UNUSED(map)) {return NULL;}
66
 
const char **filter_get_var(int UNUSED(map)) {return &foo;}
67
 
const char **attmap_get_var(int UNUSED(map),const char UNUSED(*name)) {return &foo;}
68
 
const char *attmap_get_value(MYLDAP_ENTRY UNUSED(*entry),const char UNUSED(*attr),char UNUSED(*buffer),size_t UNUSED(buflen)) {return "";}
69
 
void *attmap_add_attributes(void UNUSED(*set),const char UNUSED(*attr)) {return NULL;}
70
 
const char *attmap_set_mapping(const char UNUSED(**var),const char UNUSED(*value)) {return NULL;}
71
 
 
72
42
/* the maxium number of results to print (all results are retrieved) */
73
43
#define MAXRESULTS 10
74
44
 
104
74
      printf("test_myldap: test_search(): ...\n");
105
75
  }
106
76
  printf("test_myldap: test_search(): %d entries returned: %s\n",i,ldap_err2string(rc));
 
77
  assert(rc==LDAP_SUCCESS);
107
78
  /* perform another search */
108
79
  printf("test_myldap: test_search(): doing search...\n");
109
80
  search=myldap_search(session,nslcd_cfg->ldc_bases[0],
121
92
      printf("test_myldap: test_search(): ...\n");
122
93
  }
123
94
  printf("test_myldap: test_search(): %d entries returned: %s\n",i,ldap_err2string(rc));
 
95
  assert(rc==LDAP_SUCCESS);
124
96
  /* clean up */
125
97
  myldap_session_close(session);
126
98
}
130
102
  MYLDAP_SESSION *session;
131
103
  MYLDAP_SEARCH *search1,*search2;
132
104
  MYLDAP_ENTRY *entry;
133
 
  const char *attrs1[] = { "cn", "userPassword", "memberUid", "gidNumber", "uniqueMember", NULL };
 
105
  const char *attrs1[] = { "cn", "userPassword", "memberUid", "gidNumber", "member", NULL };
134
106
  const char *attrs2[] = { "uid", NULL };
135
107
  int rc;
136
108
  /* initialize session */
141
113
  printf("test_myldap: test_get(): doing search...\n");
142
114
  search1=myldap_search(session,nslcd_cfg->ldc_bases[0],
143
115
                        LDAP_SCOPE_SUBTREE,
144
 
                        "(&(|(objectClass=posixGroup)(objectClass=groupOfUniqueNames))(cn=testgroup2))",
 
116
                        "(&(|(objectClass=posixGroup)(objectClass=groupOfNames))(cn=testgroup2))",
145
117
                        attrs1,NULL);
146
118
  assert(search1!=NULL);
147
119
  /* get one entry */
152
124
  (void)myldap_get_values(entry,"gidNumber");
153
125
  (void)myldap_get_values(entry,"userPassword");
154
126
  (void)myldap_get_values(entry,"memberUid");
155
 
  (void)myldap_get_values(entry,"uniqueMember");
 
127
  (void)myldap_get_values(entry,"member");
156
128
  /* perform another search */
157
129
  printf("test_myldap: test_get(): doing get...\n");
158
130
  search2=myldap_search(session,"cn=Test User2,ou=people,dc=test,dc=tld",