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

« back to all changes in this revision

Viewing changes to tests/test_netgroup.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:
1
 
/*
2
 
   test_netgroup.c - simple tests of developed nss code
3
 
 
4
 
   Copyright (C) 2006 West Consulting
5
 
   Copyright (C) 2006 Arthur de Jong
6
 
 
7
 
   This library is free software; you can redistribute it and/or
8
 
   modify it under the terms of the GNU Lesser General Public
9
 
   License as published by the Free Software Foundation; either
10
 
   version 2.1 of the License, or (at your option) any later version.
11
 
 
12
 
   This library is distributed in the hope that it will be useful,
13
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
   Lesser General Public License for more details.
16
 
 
17
 
   You should have received a copy of the GNU Lesser General Public
18
 
   License along with this library; if not, write to the Free Software
19
 
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20
 
   02110-1301 USA
21
 
*/
22
 
 
23
 
#include "config.h"
24
 
 
25
 
#include <string.h>
26
 
#include <stdio.h>
27
 
#include <errno.h>
28
 
#include <sys/types.h>
29
 
#include <sys/socket.h>
30
 
#include <arpa/inet.h>
31
 
 
32
 
#include "nss/prototypes.h"
33
 
 
34
 
static char *nssstatus(enum nss_status retv)
35
 
{
36
 
  switch(retv)
37
 
  {
38
 
    case NSS_STATUS_TRYAGAIN: return "NSS_STATUS_TRYAGAIN";
39
 
    case NSS_STATUS_UNAVAIL:  return "NSS_STATUS_UNAVAIL";
40
 
    case NSS_STATUS_NOTFOUND: return "NSS_STATUS_NOTFOUND";
41
 
    case NSS_STATUS_SUCCESS:  return "NSS_STATUS_SUCCESS";
42
 
    case NSS_STATUS_RETURN:   return "NSS_STATUS_RETURN";
43
 
    default:                  return "NSS_STATUS_**ILLEGAL**";
44
 
  }
45
 
}
46
 
 
47
 
static void printnetgroup(struct __netgrent *netgroup)
48
 
{
49
 
  printf("struct __netgrent {\n");
50
 
  if (netgroup->type==triple_val)
51
 
  {
52
 
    printf("  type=triple_val,\n");
53
 
    if (netgroup->val.triple.host==NULL)
54
 
      printf("  val.triple.host=NULL,\n");
55
 
    else
56
 
      printf("  val.triple.host=\"%s\",\n",netgroup->val.triple.host);
57
 
    if (netgroup->val.triple.user==NULL)
58
 
      printf("  val.triple.user=NULL,\n");
59
 
    else
60
 
      printf("  val.triple.user=\"%s\",\n",netgroup->val.triple.user);
61
 
    if (netgroup->val.triple.domain==NULL)
62
 
      printf("  val.triple.domain=NULL,\n");
63
 
    else
64
 
      printf("  val.triple.domain=\"%s\",\n",netgroup->val.triple.domain);
65
 
  }
66
 
  else
67
 
  {
68
 
    printf("  type=triple_val,\n"
69
 
           "  val.group=\"%s\",\n",
70
 
           netgroup->val.group);
71
 
  }
72
 
  printf("  ...\n"
73
 
         "}\n");
74
 
}
75
 
 
76
 
/* the main program... */
77
 
int main(int argc,char *argv[])
78
 
{
79
 
  struct __netgrent netgroupresult;
80
 
  char buffer[1024];
81
 
  enum nss_status res;
82
 
  int errnocp;
83
 
 
84
 
  /* test {set,get,end}netgrent() */
85
 
  printf("\nTEST {set,get,end}netgrent()\n");
86
 
  res=_nss_ldap_setnetgrent("westcomp",&netgroupresult);
87
 
  printf("status=%s\n",nssstatus(res));
88
 
  while ((_nss_ldap_getnetgrent_r(&netgroupresult,buffer,1024,&errnocp))==NSS_STATUS_SUCCESS)
89
 
  {
90
 
    printf("status=%s\n",nssstatus(res));
91
 
    printnetgroup(&netgroupresult);
92
 
  }
93
 
  printf("status=%s\n",nssstatus(res));
94
 
  printf("errno=%d:%s\n",(int)errnocp,strerror(errnocp));
95
 
  res=_nss_ldap_endnetgrent(&netgroupresult);
96
 
  printf("status=%s\n",nssstatus(res));
97
 
 
98
 
  return 0;
99
 
}