~peter-pearse/ubuntu/natty/libgcrypt11/prop001

« back to all changes in this revision

Viewing changes to cipher/rndlinux.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2007-04-09 11:22:41 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409112241-hzwl3tex8cmr2dkz
Tags: 1.2.4-2
* Upload to unstable.
* Drop -lgpg-error from libgcrypt-config --libs output. (Closes: #405238)
* Switch to debhelper v5 mode.
* New upstream version closes filehandles in gcry_rndlinux_gather_random().
  (Closes: #403613)

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
                                  int requester,
43
43
                                  size_t length, int level );
44
44
 
 
45
static int
 
46
set_cloexec_flag (int fd)
 
47
{
 
48
  int oldflags;
 
49
 
 
50
  oldflags= fcntl (fd, F_GETFD, 0);
 
51
  if (oldflags < 0)
 
52
    return oldflags;
 
53
  oldflags |= FD_CLOEXEC;
 
54
  return fcntl (fd, F_SETFD, oldflags);
 
55
}
 
56
 
 
57
 
45
58
/*
46
59
 * Used to open the /dev/random devices (Linux, xBSD, Solaris (if it exists)).
47
60
 */
54
67
  if( fd == -1 )
55
68
    log_fatal ("can't open %s: %s\n", name, strerror(errno) );
56
69
 
 
70
  if (set_cloexec_flag (fd))
 
71
    log_error ("error setting FD_CLOEXEC on fd %d: %s\n",
 
72
               fd, strerror (errno));
 
73
 
57
74
  /* We used to do the follwing check, however it turned out that this
58
75
     is not portable since more OSes provide a random device which is
59
76
     sometimes implemented as anoteher device type.