* gpg-agent.c (main): Use default_homedir().

* protect-tool.c (main): Ditto.

* signal.c (got_fatal_signal, got_usr_signal)
(got_fatal_signal) [DOSISH]: Don't build.
* simple-gettext.c: Include sysutils.h

* homedir.c: New.
* Makefile.am (libcommon_a_SOURCES): Add it.
(EXTRA_DIST): Removed mkerror and mkerrtok.

* gpgv.c, g10.c (main): Use default_hoemdir ().

* scdaemon.c (main): Use default_homedir().

* gpgsm.c (main): Use default_homedir().
This commit is contained in:
Werner Koch 2004-12-21 10:03:00 +00:00
parent 581f5ddb17
commit 878cf20766
18 changed files with 102 additions and 66 deletions

2
TODO
View File

@ -101,4 +101,6 @@ might want to have an agent context for each service request
Fix is to change everything to libestream
** Signals are not support
This means we can't reread a configuration
** No card status notifications.

View File

@ -1,3 +1,9 @@
2004-12-21 Werner Koch <wk@g10code.com>
* gpg-agent.c (main): Use default_homedir().
* protect-tool.c (main): Ditto.
2004-12-20 Werner Koch <wk@g10code.com>
* gpg-agent.c (main) [W32]: Now that Mutexes work we can remove

View File

@ -478,15 +478,8 @@ main (int argc, char **argv )
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
csh_style = 1;
opt.homedir = default_homedir ();
opt.homedir = getenv("GNUPGHOME");
#ifdef HAVE_W32_SYSTEM
if (!opt.homedir || !*opt.homedir)
opt.homedir = read_w32_registry_string (NULL,
"Software\\GNU\\GnuPG", "HomeDir");
#endif /*HAVE_W32_SYSTEM*/
if (!opt.homedir || !*opt.homedir)
opt.homedir = GNUPG_DEFAULT_HOMEDIR;
/* Check whether we have a config file on the commandline */
orig_argc = argc;

View File

@ -84,7 +84,7 @@ struct rsa_secret_key_s
};
static char *opt_homedir;
static const char *opt_homedir;
static int opt_armor;
static int opt_store;
static int opt_force;
@ -1067,14 +1067,7 @@ main (int argc, char **argv )
gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
opt_homedir = getenv ("GNUPGHOME");
#ifdef HAVE_W32_SYSTEM
if (!opt_homedir || !*opt_homedir)
opt_homedir = read_w32_registry_string (NULL,
"Software\\GNU\\GnuPG", "HomeDir");
#endif /*HAVE_W32_SYSTEM*/
if (!opt_homedir || !*opt_homedir)
opt_homedir = GNUPG_DEFAULT_HOMEDIR;
opt_homedir = default_homedir ();
pargs.argc = &argc;

View File

@ -1,3 +1,13 @@
2004-12-21 Werner Koch <wk@g10code.com>
* signal.c (got_fatal_signal, got_usr_signal)
(got_fatal_signal) [DOSISH]: Don't build.
* simple-gettext.c: Include sysutils.h
* homedir.c: New.
* Makefile.am (libcommon_a_SOURCES): Add it.
(EXTRA_DIST): Removed mkerror and mkerrtok.
2004-12-20 Werner Koch <wk@g10code.com>
* sysutils.h [W32]: Define sleep.

View File

@ -19,8 +19,6 @@
## Process this file with automake to produce Makefile.in
EXTRA_DIST = mkerrors mkerrtok
noinst_LIBRARIES = libcommon.a libsimple-pwquery.a
AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS)
@ -31,6 +29,7 @@ libcommon_a_SOURCES = \
sexp-parse.h \
maperror.c \
sysutils.c sysutils.h \
homedir.c \
gettime.c \
yesno.c \
b64enc.c \

44
common/homedir.c Normal file
View File

@ -0,0 +1,44 @@
/* homedir.c - Setup the home directory.
* Copyright (C) 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <config.h>
#include <stdlib.h>
#include <errno.h>
#include "util.h"
#include "sysutils.h"
/* Set up the default home directory. The usual --homedir option
should be parsed later. */
const char *
default_homedir (void)
{
const char *dir;
dir = getenv("GNUPGHOME");
#ifdef HAVE_W32_SYSTEM
if (!dir || !*dir)
dir = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "HomeDir");
#endif /*HAVE_W32_SYSTEM*/
if (!dir || !*dir)
dir = GNUPG_DEFAULT_HOMEDIR;
return dir;
}

View File

@ -30,15 +30,17 @@
#include "util.h"
#ifndef HAVE_DOSISH_SYSTEM
static volatile int caught_fatal_sig;
static volatile int caught_sigusr1;
#endif
static void (*cleanup_fnc)(void);
#ifndef HAVE_DOSISH_SYSTEM
static void
init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
{
#ifndef HAVE_DOSISH_SYSTEM
# ifdef HAVE_SIGACTION
struct sigaction oact, nact;
@ -64,9 +66,10 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
signal (sig, SIG_IGN);
}
# endif
#endif /*!HAVE_DOSISH_SYSTEM*/
}
#endif /*!HAVE_DOSISH_SYSTEM*/
#ifndef HAVE_DOSISH_SYSTEM
static const char *
get_signal_name( int signum )
{
@ -76,7 +79,9 @@ get_signal_name( int signum )
return "some signal";
#endif
}
#endif /*!HAVE_DOSISH_SYSTEM*/
#ifndef HAVE_DOSISH_SYSTEM
static RETSIGTYPE
got_fatal_signal (int sig)
{
@ -106,14 +111,15 @@ got_fatal_signal (int sig)
#endif /* __riscos__ */
raise( sig );
}
#endif /*!HAVE_DOSISH_SYSTEM*/
#ifndef HAVE_DOSISH_SYSTEM
static RETSIGTYPE
got_usr_signal (int sig)
{
caught_sigusr1 = 1;
}
#endif /*!HAVE_DOSISH_SYSTEM*/
void
gnupg_init_signals (int mode, void (*fast_cleanup)(void))

View File

@ -40,7 +40,7 @@
#include <sys/stat.h>
#include "util.h"
#include "sysutils.h"
/* The magic number of the GNU message catalog format. */
#define MAGIC 0x950412de

View File

@ -121,6 +121,10 @@ gpg_error_t b64enc_write (struct b64state *state,
gpg_error_t b64enc_finish (struct b64state *state);
/*-- homedir. c --*/
const char *default_homedir (void);
/*-- miscellaneous.c --*/
/* Same as asprintf but return an allocated buffer suitable to be

View File

@ -1,3 +1,7 @@
2004-12-21 Werner Koch <wk@g10code.com>
* gpgv.c, g10.c (main): Use default_hoemdir ().
2004-12-18 Werner Koch <wk@g10code.com>
* gpg.h (map_assuan_err): Define in terms of

View File

@ -1264,16 +1264,9 @@ main( int argc, char **argv )
opt.mangle_dos_filenames = 1;
opt.use_agent = 1;
#if defined (_WIN32)
set_homedir ( read_w32_registry_string( NULL,
"Software\\GNU\\GnuPG", "HomeDir" ));
#else
set_homedir ( getenv("GNUPGHOME") );
#endif
if( !*opt.homedir )
set_homedir ( GNUPG_DEFAULT_HOMEDIR );
set_homedir ( default_homedir () );
/* check whether we have a config file on the commandline */
/* Check whether we have a config file on the commandline */
orig_argc = argc;
orig_argv = argv;
pargs.argc = &argc;

View File

@ -150,15 +150,8 @@ main( int argc, char **argv )
opt.trust_model = TM_ALWAYS;
opt.batch = 1;
#if defined (_WIN32)
opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG",
"HomeDir" );
#else
opt.homedir = getenv("GNUPGHOME");
#endif
if( !opt.homedir || !*opt.homedir ) {
opt.homedir = GNUPG_DEFAULT_HOMEDIR;
}
opt.homedir = default_homedir ();
tty_no_terminal(1);
tty_batchmode(1);
disable_dotlock();

View File

@ -1,3 +1,7 @@
2004-12-21 Werner Koch <wk@g10code.com>
* scdaemon.c (main): Use default_homedir().
2004-12-18 Werner Koch <wk@g10code.com>
* scdaemon.c (main) [W32]: Remove special Pth initialize..

View File

@ -1261,9 +1261,7 @@ scd_update_reader_status_file (void)
log_info ("client pid is %d, sending signal %d\n", pid, signo);
#ifdef HAVE_W32_SYSTEM
#warning Need to implement a notification service
#else
#ifndef HAVE_W32_SYSTEM
if (pid != (pid_t)(-1) && pid && signo > 0)
kill (pid, signo);
#endif

View File

@ -351,17 +351,12 @@ main (int argc, char **argv )
Note that this will also do the pth_init. */
#ifndef HAVE_OPENSC
#ifdef USE_GNU_PTH
#ifdef HAVE_W32_SYSTEM
/* For W32 we need pth. */
pth_init ();
#else
err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
if (err)
{
log_fatal ("can't register GNU Pth with Libgcrypt: %s\n",
gpg_strerror (err));
}
#endif
#endif /*USE_GNU_PTH*/
#endif /*!HAVE_OPENSC*/
@ -392,14 +387,9 @@ main (int argc, char **argv )
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
csh_style = 1;
/* FIXME: Using this homedir option does only make sense when not
running as a system service. We might want to check for this by
looking at the uid or ebtter use an explict option for this */
opt.homedir = getenv("GNUPGHOME");
if (!opt.homedir || !*opt.homedir)
opt.homedir = GNUPG_DEFAULT_HOMEDIR;
opt.homedir = default_homedir ();
/* check whether we have a config file on the commandline */
/* Check whether we have a config file on the commandline */
orig_argc = argc;
orig_argv = argv;
pargs.argc = &argc;

View File

@ -1,3 +1,7 @@
2004-12-21 Werner Koch <wk@g10code.com>
* gpgsm.c (main): Use default_homedir().
2004-12-20 Werner Koch <wk@g10code.com>
* call-agent.c (start_agent): Before starting a pipe server start

View File

@ -756,16 +756,9 @@ main ( int argc, char **argv)
opt.def_cipher_algoid = "1.2.840.113549.3.7"; /*des-EDE3-CBC*/
#ifdef HAVE_W32_SYSTEM
opt.homedir = read_w32_registry_string ( NULL,
"Software\\GNU\\GnuPG", "HomeDir" );
#else
opt.homedir = getenv ("GNUPGHOME");
#endif
if (!opt.homedir || !*opt.homedir )
opt.homedir = GNUPG_DEFAULT_HOMEDIR;
opt.homedir = default_homedir ();
/* first check whether we have a config file on the commandline */
/* First check whether we have a config file on the commandline */
orig_argc = argc;
orig_argv = argv;
pargs.argc = &argc;