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

« back to all changes in this revision

Viewing changes to .pc/01-use-poll-instead-of-select.patch/common/nslcd-prot.c

  • Committer: Package Import Robot
  • Author(s): Arthur de Jong
  • Date: 2013-05-05 20:00:00 UTC
  • mfrom: (16.1.6) (14.1.6 experimental)
  • Revision ID: package-import@ubuntu.com-20130505200000-nhg39y204kr141mz
Tags: 0.8.13-1
* New upstream release
  - include an extra sanity check to ensure not too many file
    descriptors are open
  - fix handling of gid configuration option if it listed before the uid
    option
  - return NSS_STATUS_TRYAGAIN on zero-length (but not-NULL) buffer (thanks
    Jakub Hrozek)
  - provide an _nss_ldap_version symbol in the NSS module to help debug
    problems with a newer nslcd
  - retry updating the lastChange attribute with the normal nslcd LDAP
    connection if the update with the user's connection failed
  - avoid processing passwd_byuid requests for uids below nss_min_uid
  - fix a few minor or very unlikely to occur memory leaks
  - miscellaneous minor changes, fixes and compatibility improvements
* drop 01-fix-set-usec-instead-of-sec.patch which is part of 0.8.13
* remove compatibility code that converted nss-ldapd.conf to nslcd.conf
  for upgrading from pre-0.7 versions of nss-ldapd (thanks Dominik George)
* remove code for fixing permissions when upgrading from a pre-0.6.7.1
  version
* updated Turkish debconf translation by Atila KOÇ (closes: #701067)
* drop Richard A Nelson from uploaders
* add build dependency on autotools-dev to ensure config.sub and
  config.guess are automatically updated during build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
   nslcd-prot.c - common functions for NSLCD lookups
3
 
 
4
 
   Copyright (C) 2006 West Consulting
5
 
   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012 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
 
#ifdef HAVE_STDINT_H
26
 
#include <stdint.h>
27
 
#endif /* HAVE_STDINT_H */
28
 
#include <unistd.h>
29
 
#include <stdio.h>
30
 
#include <sys/socket.h>
31
 
#include <sys/un.h>
32
 
#include <sys/types.h>
33
 
#include <sys/stat.h>
34
 
#include <errno.h>
35
 
#include <string.h>
36
 
 
37
 
#include "nslcd.h"
38
 
#include "nslcd-prot.h"
39
 
#include "compat/socket.h"
40
 
 
41
 
/* buffer sizes for I/O */
42
 
#define READBUFFER_MINSIZE 1024
43
 
#define READBUFFER_MAXSIZE 2*1024*1024
44
 
#define WRITEBUFFER_MINSIZE 32
45
 
#define WRITEBUFFER_MAXSIZE 32
46
 
 
47
 
/* Note that the READBUFFER_MAXSIZE should be large enough to hold any single
48
 
   result entity as defined in nslcd.h because the get*ent() functions expect
49
 
   to be able to tio_reset() the stream to re-read the current entity.
50
 
   Since group entities can grow arbitrarily large, this setting limits the
51
 
   number of users that can be put in a group. */
52
 
 
53
 
/* returns a socket to the server or NULL on error (see errno),
54
 
   socket should be closed with fclose() */
55
 
TFILE *nslcd_client_open()
56
 
{
57
 
  int sock;
58
 
  struct sockaddr_un addr;
59
 
  struct timeval readtimeout,writetimeout;
60
 
  TFILE *fp;
61
 
  /* create a socket */
62
 
  if ( (sock=socket(PF_UNIX,SOCK_STREAM,0))<0 )
63
 
    return NULL;
64
 
  /* create socket address structure */
65
 
  memset(&addr,0,sizeof(struct sockaddr_un));
66
 
  addr.sun_family=AF_UNIX;
67
 
  strncpy(addr.sun_path,NSLCD_SOCKET,sizeof(addr.sun_path));
68
 
  addr.sun_path[sizeof(addr.sun_path)-1]='\0';
69
 
  /* connect to the socket */
70
 
  if (connect(sock,(struct sockaddr *)&addr,SUN_LEN(&addr))<0)
71
 
  {
72
 
    (void)close(sock);
73
 
    return NULL;
74
 
  }
75
 
  /* set the timeouts */
76
 
  readtimeout.tv_sec=60; /* looking up stuff may take some time */
77
 
  readtimeout.tv_usec=0;
78
 
  writetimeout.tv_sec=10; /* nslcd could be loaded with requests */
79
 
  writetimeout.tv_usec=0;
80
 
  /* create a stream object */
81
 
  if ((fp=tio_fdopen(sock,&readtimeout,&writetimeout,
82
 
                     READBUFFER_MINSIZE,READBUFFER_MAXSIZE,
83
 
                     WRITEBUFFER_MINSIZE,WRITEBUFFER_MAXSIZE))==NULL)
84
 
  {
85
 
    (void)close(sock);
86
 
    return NULL;
87
 
  }
88
 
  /* return the stream */
89
 
  return fp;
90
 
}