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

« back to all changes in this revision

Viewing changes to common/nslcd-prot.c

  • Committer: Package Import Robot
  • Author(s): Arthur de Jong
  • Date: 2014-06-08 14:00:00 UTC
  • mfrom: (16.1.8) (14.1.12 experimental)
  • Revision ID: package-import@ubuntu.com-20140608140000-rt6fspljmk9252zd
Tags: 0.9.4-1
* upload to unstable
* new upstream release:
  - also handle password policy information on BIND failure (this makes it
    possible to distinguish between a wrong password and an expired
    password)
  - fix mapping the member attribute to an empty string
  - any buffers that may have held passwords are cleared before the memory
    is released
  - increase buffer size for passwords to support extremely long passwords
    (thanks ushi)
  - increase buffer size for DN to support very long names or names with
    non-ASCII characters
  - log an error in almost all places where a defined buffer is not large
    enough to hold the provided data instead of just (sometimes silently)
    failing
  - logging improvements (start-up problems, login failures)
* add signature checking option to watch file
* add a debian/upstream/metadata file

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
/* read timeout is 60 seconds because looking up stuff may take some time
43
43
   write timeout is 10 secods because nslcd could be loaded with requests */
44
 
#define READ_TIMEOUT 60*1000
45
 
#define WRITE_TIMEOUT 10*1000
 
44
#define READ_TIMEOUT 60 * 1000
 
45
#define WRITE_TIMEOUT 10 * 1000
46
46
 
47
47
/* buffer sizes for I/O */
48
48
#define READBUFFER_MINSIZE 1024
49
 
#define READBUFFER_MAXSIZE 2*1024*1024
 
49
#define READBUFFER_MAXSIZE 2 * 1024 * 1024
50
50
#define WRITEBUFFER_MINSIZE 32
51
51
#define WRITEBUFFER_MAXSIZE 32
52
52
 
65
65
  TFILE *fp;
66
66
  int flags;
67
67
  /* create a socket */
68
 
  if ( (sock=socket(PF_UNIX,SOCK_STREAM,0))<0 )
 
68
  if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
69
69
    return NULL;
70
70
  /* create socket address structure */
71
 
  memset(&addr,0,sizeof(struct sockaddr_un));
72
 
  addr.sun_family=AF_UNIX;
73
 
  strncpy(addr.sun_path,NSLCD_SOCKET,sizeof(addr.sun_path));
74
 
  addr.sun_path[sizeof(addr.sun_path)-1]='\0';
 
71
  memset(&addr, 0, sizeof(struct sockaddr_un));
 
72
  addr.sun_family = AF_UNIX;
 
73
  strncpy(addr.sun_path, NSLCD_SOCKET, sizeof(addr.sun_path));
 
74
  addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
75
75
  /* close the file descriptor on exec (ignore errors) */
76
 
  flags=fcntl(sock,F_GETFL);
77
 
  if (flags>=0)
78
 
    (void)fcntl(sock,F_SETFD,flags|FD_CLOEXEC);
 
76
  flags = fcntl(sock, F_GETFL);
 
77
  if (flags >= 0)
 
78
    (void)fcntl(sock, F_SETFD, flags | FD_CLOEXEC);
79
79
  /* connect to the socket */
80
 
  if (connect(sock,(struct sockaddr *)&addr,SUN_LEN(&addr))<0)
 
80
  if (connect(sock, (struct sockaddr *)&addr, SUN_LEN(&addr)) < 0)
81
81
  {
82
82
    (void)close(sock);
83
83
    return NULL;
84
84
  }
85
85
  /* create a stream object */
86
 
  if ((fp=tio_fdopen(sock,READ_TIMEOUT,WRITE_TIMEOUT,
87
 
                     READBUFFER_MINSIZE,READBUFFER_MAXSIZE,
88
 
                     WRITEBUFFER_MINSIZE,WRITEBUFFER_MAXSIZE))==NULL)
 
86
  if ((fp = tio_fdopen(sock, READ_TIMEOUT, WRITE_TIMEOUT,
 
87
                       READBUFFER_MINSIZE, READBUFFER_MAXSIZE,
 
88
                       WRITEBUFFER_MINSIZE, WRITEBUFFER_MAXSIZE)) == NULL)
89
89
  {
90
90
    (void)close(sock);
91
91
    return NULL;