~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-security

« back to all changes in this revision

Viewing changes to common/init.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* init.c - Various initializations
 
2
 *      Copyright (C) 2007 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GnuPG.
 
5
 *
 
6
 * GnuPG is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * GnuPG is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <config.h>
 
21
 
 
22
#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth.  */
 
23
#undef HAVE_PTH
 
24
#undef USE_GNU_PTH
 
25
#endif
 
26
 
 
27
#ifdef HAVE_W32_SYSTEM
 
28
#include <windows.h>
 
29
#endif
 
30
#ifdef HAVE_PTH      
 
31
#include <pth.h>
 
32
#endif
 
33
 
 
34
#include "estream.h"
 
35
#include "util.h"
 
36
 
 
37
 
 
38
/* This function is to be used early at program startup to make sure
 
39
   that some subsystems are initialized.  This is in particular
 
40
   important for W32 to initialize the sockets so that our socket
 
41
   emulation code used directly as well as in libassuan may be used.
 
42
   It should best be called before any I/O is done so that setup
 
43
   required for logging is ready.  CAUTION: This might be called while
 
44
   running suid(root). */
 
45
void
 
46
init_common_subsystems (void)
 
47
{
 
48
  /* Try to auto set the character set.  */
 
49
  set_native_charset (NULL); 
 
50
 
 
51
#ifdef HAVE_W32_SYSTEM
 
52
  /* For W32 we need to initialize the socket layer.  This is because
 
53
     we use recv and send in libassuan as well as at some other
 
54
     places.  If we are building with PTH we let pth_init do it.  We
 
55
     can't do much on error so we ignore them.  An error would anyway
 
56
     later pop up if one of the socket functions is used. */
 
57
# ifdef HAVE_PTH
 
58
  pth_init ();
 
59
# else
 
60
 {
 
61
   WSADATA wsadat;
 
62
 
 
63
   WSAStartup (0x202, &wsadat);
 
64
 }
 
65
# endif /*!HAVE_PTH*/
 
66
#endif
 
67
 
 
68
  /* Initialize the Estream library. */
 
69
  es_init ();
 
70
}
 
71