1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Whole lot of changes to support CE.

This commit is contained in:
Werner Koch 2010-04-14 11:24:02 +00:00
parent aed838b750
commit 31d7bdfe77
28 changed files with 413 additions and 151 deletions

View File

@ -1,3 +1,9 @@
2010-04-07 Werner Koch <wk@g10code.com>
* autogen.sh: Take a .gnupg-autogen.rc file in account.
* gl/mkdtemp.c (getpid) [W32CE]: New macro.
2010-03-24 Werner Koch <wk@g10code.com> 2010-03-24 Werner Koch <wk@g10code.com>
* configure.ac (AH_BOTTOM): Use /gnupg as the default homedir on * configure.ac (AH_BOTTOM): Use /gnupg as the default homedir on

View File

@ -1,3 +1,40 @@
2010-04-14 Werner Koch <wk@g10code.com>
* trustlist.c (read_one_trustfile): Use estream.
2010-04-13 Werner Koch <wk@g10code.com>
* findkey.c (read_key_file): Use estream.
(agent_write_private_key): Ditto.
2010-04-07 Werner Koch <wk@g10code.com>
* gpg-agent.c (handle_connections) [W32]: Assume that PTh support
the handle event. Use a dummy event for W32CE.
(get_agent_scd_notify_event) [W32CE]: Do not build.
* call-pinentry.c: Remove setenv.h. Include sysutils.h.
(atfork_cb): s/setenv/gnupg_setenv/.
* gpg-agent.c: Do not include setenv.h.
(main): s/unsetenv/gnupg_unsetenv/.
* protect.c (calibrate_get_time) [W32CE]: Use GetThreadTimes.
2010-04-06 Werner Koch <wk@g10code.com>
* call-scd.c [!HAVE_SIGNAL_H]: Do not include signal.h.
* findkey.c (agent_write_private_key): s/remove/gnupg_remove/.
* command-ssh.c (search_control_file): Replace rewind by fseek and
clearerr.
* genkey.c (check_passphrase_pattern): Ditto.
* gpg-agent.c [!HAVE_SIGNAL_H]: Do not include signal.h.
(remove_socket): s/remove/gnupg_remove/.
(create_private_keys_directory): Use gnupg_mkdir.
2010-03-11 Werner Koch <wk@g10code.com> 2010-03-11 Werner Koch <wk@g10code.com>
* gpg-agent.c: Include "asshelp.h". * gpg-agent.c: Include "asshelp.h".

View File

@ -36,7 +36,7 @@
#include "agent.h" #include "agent.h"
#include <assuan.h> #include <assuan.h>
#include "setenv.h" #include "sysutils.h"
#include "i18n.h" #include "i18n.h"
#ifdef _POSIX_OPEN_MAX #ifdef _POSIX_OPEN_MAX
@ -190,7 +190,7 @@ atfork_cb (void *opaque, int where)
{ {
value = session_env_getenv (ctrl->session_env, name); value = session_env_getenv (ctrl->session_env, name);
if (value) if (value)
setenv (name, value, 1); gnupg_setenv (name, value, 1);
} }
} }
} }

View File

@ -25,7 +25,9 @@
#include <ctype.h> #include <ctype.h>
#include <assert.h> #include <assert.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#ifndef HAVE_W32_SYSTEM #ifndef HAVE_W32_SYSTEM
@ -385,7 +387,9 @@ start_scd (ctrl_t ctrl)
xfree (databuf); xfree (databuf);
} }
/* Tell the scdaemon we want him to send us an event signal. */ /* Tell the scdaemon we want him to send us an event signal. We
don't support this for W32CE. */
#ifndef HAVE_W32CE_SYSTEM
{ {
char buf[100]; char buf[100];
@ -397,6 +401,7 @@ start_scd (ctrl_t ctrl)
#endif #endif
assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL);
} }
#endif /*HAVE_W32CE_SYSTEM*/
primary_scd_ctx = ctx; primary_scd_ctx = ctx;
primary_scd_ctx_reusable = 0; primary_scd_ctx_reusable = 0;

View File

@ -721,7 +721,8 @@ search_control_file (FILE *fp, const char *hexgrip,
assert (strlen (hexgrip) == 40 ); assert (strlen (hexgrip) == 40 );
rewind (fp); fseek (fp, 0, SEEK_SET);
clearerr (fp);
*r_disabled = 0; *r_disabled = 0;
next_line: next_line:
do do

View File

@ -57,9 +57,8 @@ agent_write_private_key (const unsigned char *grip,
const void *buffer, size_t length, int force) const void *buffer, size_t length, int force)
{ {
char *fname; char *fname;
FILE *fp; estream_t fp;
char hexgrip[40+4+1]; char hexgrip[40+4+1];
int fd;
bin2hex (grip, 20, hexgrip); bin2hex (grip, 20, hexgrip);
strcpy (hexgrip+40, ".key"); strcpy (hexgrip+40, ".key");
@ -73,53 +72,30 @@ agent_write_private_key (const unsigned char *grip,
return gpg_error (GPG_ERR_GENERAL); return gpg_error (GPG_ERR_GENERAL);
} }
/* In FORCE mode we would like to create FNAME but only if it does /* FIXME: On POSIX systems we used include S_IRGRP as well. */
not already exist. We cannot make this guarantee just using fp = es_fopen (fname, force? "wb" : "wbx");
POSIX (GNU provides the "x" opentype for fopen, however, this is
not portable). Thus, we use the more flexible open function and
then use fdopen to obtain a stream. */
fd = open (fname, force? (O_CREAT | O_TRUNC | O_WRONLY | O_BINARY)
: (O_CREAT | O_EXCL | O_WRONLY | O_BINARY),
S_IRUSR | S_IWUSR
#ifndef HAVE_W32_SYSTEM
| S_IRGRP
#endif
);
if (fd < 0)
fp = NULL;
else
{
fp = fdopen (fd, "wb");
if (!fp) if (!fp)
{ {
int save_e = errno; gpg_error_t tmperr = gpg_error_from_syserror ();
close (fd); log_error ("can't create `%s': %s\n", fname, gpg_strerror (tmperr));
errno = save_e;
}
}
if (!fp)
{
gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
log_error ("can't create `%s': %s\n", fname, strerror (errno));
xfree (fname); xfree (fname);
return tmperr; return tmperr;
} }
if (fwrite (buffer, length, 1, fp) != 1) if (es_fwrite (buffer, length, 1, fp) != 1)
{ {
gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); gpg_error_t tmperr = gpg_error_from_syserror ();
log_error ("error writing `%s': %s\n", fname, strerror (errno)); log_error ("error writing `%s': %s\n", fname, gpg_strerror (tmperr));
fclose (fp); es_fclose (fp);
remove (fname); gnupg_remove (fname);
xfree (fname); xfree (fname);
return tmperr; return tmperr;
} }
if ( fclose (fp) ) if (es_fclose (fp))
{ {
gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); gpg_error_t tmperr = gpg_error_from_syserror ();
log_error ("error closing `%s': %s\n", fname, strerror (errno)); log_error ("error closing `%s': %s\n", fname, gpg_strerror (tmperr));
remove (fname); gnupg_remove (fname);
xfree (fname); xfree (fname);
return tmperr; return tmperr;
} }
@ -425,7 +401,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
{ {
int rc; int rc;
char *fname; char *fname;
FILE *fp; estream_t fp;
struct stat st; struct stat st;
unsigned char *buf; unsigned char *buf;
size_t buflen, erroff; size_t buflen, erroff;
@ -438,7 +414,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
strcpy (hexgrip+40, ".key"); strcpy (hexgrip+40, ".key");
fname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL); fname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL);
fp = fopen (fname, "rb"); fp = es_fopen (fname, "rb");
if (!fp) if (!fp)
{ {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
@ -448,23 +424,36 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
return rc; return rc;
} }
if (fstat (fileno(fp), &st)) if (fstat (es_fileno (fp), &st))
{ {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
log_error ("can't stat `%s': %s\n", fname, strerror (errno)); log_error ("can't stat `%s': %s\n", fname, strerror (errno));
xfree (fname); xfree (fname);
fclose (fp); es_fclose (fp);
return rc; return rc;
} }
buflen = st.st_size; buflen = st.st_size;
buf = xtrymalloc (buflen+1); buf = xtrymalloc (buflen+1);
if (!buf || fread (buf, buflen, 1, fp) != 1) if (!buf)
{ {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
log_error ("error reading `%s': %s\n", fname, strerror (errno)); log_error ("error allocating %zu bytes for `%s': %s\n",
buflen, fname, strerror (errno));
xfree (fname); xfree (fname);
fclose (fp); es_fclose (fp);
xfree (buf);
return rc;
}
if (es_fread (buf, buflen, 1, fp) != 1)
{
rc = gpg_error_from_syserror ();
log_error ("error reading %zu bytes from `%s': %s\n",
buflen, fname, strerror (errno));
xfree (fname);
es_fclose (fp);
xfree (buf); xfree (buf);
return rc; return rc;
} }
@ -472,7 +461,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
/* Convert the file into a gcrypt S-expression object. */ /* Convert the file into a gcrypt S-expression object. */
rc = gcry_sexp_sscan (&s_skey, &erroff, (char*)buf, buflen); rc = gcry_sexp_sscan (&s_skey, &erroff, (char*)buf, buflen);
xfree (fname); xfree (fname);
fclose (fp); es_fclose (fp);
xfree (buf); xfree (buf);
if (rc) if (rc)
{ {

View File

@ -117,7 +117,8 @@ check_passphrase_pattern (ctrl_t ctrl, const char *pw)
fclose (infp); fclose (infp);
return 1; /* Error - assume password should not be used. */ return 1; /* Error - assume password should not be used. */
} }
rewind (infp); fseek (infp, 0, SEEK_SET);
clearerr (infp);
i = 0; i = 0;
argv[i++] = "--null"; argv[i++] = "--null";
@ -134,7 +135,8 @@ check_passphrase_pattern (ctrl_t ctrl, const char *pw)
result = 0; /* Success; i.e. no match. */ result = 0; /* Success; i.e. no match. */
/* Overwrite our temporary file. */ /* Overwrite our temporary file. */
rewind (infp); fseek (infp, 0, SEEK_SET);
clearerr (infp);
for (i=((strlen (pw)+99)/100)*100; i > 0; i--) for (i=((strlen (pw)+99)/100)*100; i > 0; i--)
putc ('\xff', infp); putc ('\xff', infp);
fflush (infp); fflush (infp);

View File

@ -1,6 +1,6 @@
/* gpg-agent.c - The GnuPG Agent /* gpg-agent.c - The GnuPG Agent
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009,
* 2006, 2007, 2009 Free Software Foundation, Inc. * 2010 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -35,7 +35,9 @@
# include <sys/un.h> # include <sys/un.h>
#endif /*!HAVE_W32_SYSTEM*/ #endif /*!HAVE_W32_SYSTEM*/
#include <unistd.h> #include <unistd.h>
#include <signal.h> #ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#include <pth.h> #include <pth.h>
#define JNLIB_NEED_LOG_LOGV #define JNLIB_NEED_LOG_LOGV
@ -46,7 +48,6 @@
#include "i18n.h" #include "i18n.h"
#include "mkdtemp.h" /* Gnulib replacement. */ #include "mkdtemp.h" /* Gnulib replacement. */
#include "sysutils.h" #include "sysutils.h"
#include "setenv.h"
#include "gc-opt-flags.h" #include "gc-opt-flags.h"
#include "exechelp.h" #include "exechelp.h"
#include "asshelp.h" #include "asshelp.h"
@ -425,7 +426,7 @@ remove_socket (char *name)
{ {
char *p; char *p;
remove (name); gnupg_remove (name);
p = strrchr (name, '/'); p = strrchr (name, '/');
if (p) if (p)
{ {
@ -994,7 +995,7 @@ main (int argc, char **argv )
exec the program given as arguments). */ exec the program given as arguments). */
#ifndef HAVE_W32_SYSTEM #ifndef HAVE_W32_SYSTEM
if (!opt.keep_display && !argc) if (!opt.keep_display && !argc)
unsetenv ("DISPLAY"); gnupg_unsetenv ("DISPLAY");
#endif #endif
@ -1374,7 +1375,7 @@ get_agent_ssh_socket_name (void)
/* Under W32, this function returns the handle of the scdaemon /* Under W32, this function returns the handle of the scdaemon
notification event. Calling it the first time creates that notification event. Calling it the first time creates that
event. */ event. */
#ifdef HAVE_W32_SYSTEM #if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM)
void * void *
get_agent_scd_notify_event (void) get_agent_scd_notify_event (void)
{ {
@ -1412,7 +1413,7 @@ get_agent_scd_notify_event (void)
log_debug ("returning notify handle %p\n", the_event); log_debug ("returning notify handle %p\n", the_event);
return the_event; return the_event;
} }
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM && !HAVE_W32CE_SYSTEM*/
@ -1510,7 +1511,7 @@ create_server_socket (char *name, int is_ssh, assuan_sock_nonce_t *nonce)
assuan_sock_close (fd); assuan_sock_close (fd);
agent_exit (2); agent_exit (2);
} }
remove (name); gnupg_remove (name);
rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len);
} }
if (rc != -1 if (rc != -1
@ -1556,15 +1557,9 @@ create_private_keys_directory (const char *home)
fname = make_filename (home, GNUPG_PRIVATE_KEYS_DIR, NULL); fname = make_filename (home, GNUPG_PRIVATE_KEYS_DIR, NULL);
if (stat (fname, &statbuf) && errno == ENOENT) if (stat (fname, &statbuf) && errno == ENOENT)
{ {
#ifdef HAVE_W32_SYSTEM /*FIXME: Setup proper permissions. */ if (gnupg_mkdir (fname, "-rwx"))
if (!CreateDirectory (fname, NULL))
log_error (_("can't create directory `%s': %s\n"),
fname, w32_strerror (-1) );
#else
if (mkdir (fname, S_IRUSR|S_IWUSR|S_IXUSR ))
log_error (_("can't create directory `%s': %s\n"), log_error (_("can't create directory `%s': %s\n"),
fname, strerror (errno) ); fname, strerror (errno) );
#endif
else if (!opt.quiet) else if (!opt.quiet)
log_info (_("directory `%s' created\n"), fname); log_info (_("directory `%s' created\n"), fname);
} }
@ -1601,15 +1596,9 @@ create_directories (void)
#endif #endif
) )
{ {
#ifdef HAVE_W32_SYSTEM if (gnupg_mkdir (home, "-rwx"))
if (!CreateDirectory (home, NULL))
log_error (_("can't create directory `%s': %s\n"),
home, w32_strerror (-1) );
#else
if (mkdir (home, S_IRUSR|S_IWUSR|S_IXUSR ))
log_error (_("can't create directory `%s': %s\n"), log_error (_("can't create directory `%s': %s\n"),
home, strerror (errno) ); home, strerror (errno) );
#endif
else else
{ {
if (!opt.quiet) if (!opt.quiet)
@ -1863,14 +1852,14 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
pth_sigmask (SIG_UNBLOCK, &sigs, NULL); pth_sigmask (SIG_UNBLOCK, &sigs, NULL);
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
#else #else
# ifdef PTH_EVENT_HANDLE # ifdef HAVE_W32CE_SYSTEM
sigs = 0;
ev = pth_event (PTH_EVENT_HANDLE, get_agent_scd_notify_event ());
signo = 0;
# else
/* Use a dummy event. */ /* Use a dummy event. */
sigs = 0; sigs = 0;
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
# else
sigs = 0;
ev = pth_event (PTH_EVENT_HANDLE, get_agent_scd_notify_event ());
signo = 0;
# endif # endif
#endif #endif
time_ev = NULL; time_ev = NULL;

View File

@ -1249,14 +1249,14 @@ store_private_key (const unsigned char *grip,
{ {
log_error ("error writing `%s': %s\n", fname, strerror (errno)); log_error ("error writing `%s': %s\n", fname, strerror (errno));
es_fclose (fp); es_fclose (fp);
remove (fname); gnupg_remove (fname);
xfree (fname); xfree (fname);
return -1; return -1;
} }
if (es_fclose (fp)) if (es_fclose (fp))
{ {
log_error ("error closing `%s': %s\n", fname, strerror (errno)); log_error ("error closing `%s': %s\n", fname, strerror (errno));
remove (fname); gnupg_remove (fname);
xfree (fname); xfree (fname);
return -1; return -1;
} }

View File

@ -78,7 +78,11 @@ static void
calibrate_get_time (struct calibrate_time_s *data) calibrate_get_time (struct calibrate_time_s *data)
{ {
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
# ifdef HAVE_W32CE_SYSTEM
GetThreadTimes (GetCurrentThread (),
# else
GetProcessTimes (GetCurrentProcess (), GetProcessTimes (GetCurrentProcess (),
# endif
&data->creation_time, &data->exit_time, &data->creation_time, &data->exit_time,
&data->kernel_time, &data->user_time); &data->kernel_time, &data->user_time);
#else #else

View File

@ -116,7 +116,7 @@ read_one_trustfile (const char *fname, int allow_include,
int *addr_of_tableidx) int *addr_of_tableidx)
{ {
gpg_error_t err = 0; gpg_error_t err = 0;
FILE *fp; estream_t fp;
int n, c; int n, c;
char *p, line[256]; char *p, line[256];
trustitem_t *table, *ti; trustitem_t *table, *ti;
@ -128,7 +128,7 @@ read_one_trustfile (const char *fname, int allow_include,
tablesize = *addr_of_tablesize; tablesize = *addr_of_tablesize;
tableidx = *addr_of_tableidx; tableidx = *addr_of_tableidx;
fp = fopen (fname, "r"); fp = es_fopen (fname, "r");
if (!fp) if (!fp)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
@ -136,14 +136,14 @@ read_one_trustfile (const char *fname, int allow_include,
goto leave; goto leave;
} }
while (fgets (line, DIM(line)-1, fp)) while (es_fgets (line, DIM(line)-1, fp))
{ {
lnr++; lnr++;
if (!*line || line[strlen(line)-1] != '\n') if (!*line || line[strlen(line)-1] != '\n')
{ {
/* Eat until end of line. */ /* Eat until end of line. */
while ( (c=getc (fp)) != EOF && c != '\n') while ( (c=es_getc (fp)) != EOF && c != '\n')
; ;
err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG
: GPG_ERR_INCOMPLETE_LINE); : GPG_ERR_INCOMPLETE_LINE);
@ -288,7 +288,7 @@ read_one_trustfile (const char *fname, int allow_include,
} }
tableidx++; tableidx++;
} }
if ( !err && !feof (fp) ) if ( !err && !es_feof (fp) )
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
log_error (_("error reading `%s', line %d: %s\n"), log_error (_("error reading `%s', line %d: %s\n"),
@ -296,8 +296,7 @@ read_one_trustfile (const char *fname, int allow_include,
} }
leave: leave:
if (fp) es_fclose (fp);
fclose (fp);
*addr_of_table = table; *addr_of_table = table;
*addr_of_tablesize = tablesize; *addr_of_tablesize = tablesize;
*addr_of_tableidx = tableidx; *addr_of_tableidx = tableidx;

View File

@ -18,7 +18,7 @@ cvtver () {
} }
check_version () { check_version () {
if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then
return 0 return 0
fi fi
echo "**Error**: "\`$1\'" not installed or too old." >&2 echo "**Error**: "\`$1\'" not installed or too old." >&2
@ -45,6 +45,24 @@ if test x"$1" = x"--force"; then
shift shift
fi fi
# Begin list of optional variables sourced from ~/.gnupg-autogen.rc
w32_toolprefixes=
w32_extraoptions=
w32ce_toolprefixes=
w32ce_extraoptions=
amd64_toolprefixes=
# End list of optional variables sourced from ~/.gnupg-autogen.rc
# What follows are variables which are sourced but default to
# environment variables or lacking them hardcoded values.
#w32root=
#w32ce_root=
#amd64root=
if [ -f "$HOME/.gnupg-autogen.rc" ]; then
echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc"
. "$HOME/.gnupg-autogen.rc"
fi
# Convenience option to use certain configure options for some hosts. # Convenience option to use certain configure options for some hosts.
myhost="" myhost=""
myhostsub="" myhostsub=""
@ -59,6 +77,10 @@ case "$1" in
--build-amd64) --build-amd64)
myhost="amd64" myhost="amd64"
;; ;;
--build*)
echo "**Error**: invalid build option $1" >&2
exit 1
;;
*) *)
;; ;;
esac esac
@ -76,16 +98,17 @@ if [ "$myhost" = "w32" ]; then
fi fi
build=`$tsdir/scripts/config.guess` build=`$tsdir/scripts/config.guess`
extraoptions=""
case $myhostsub in case $myhostsub in
ce) ce)
[ -z "$w32root" ] && w32root="$HOME/w32ce_root" [ -z "$w32ce_root" ] && w32root="$HOME/w32ce_root"
toolprefixes="arm-mingw32ce" toolprefixes="$w32ce_toolprefixes arm-mingw32ce"
extraoptions="--disable-scdaemon" extraoptions="--disable-scdaemon $w32ce_extraoptions"
;; ;;
*) *)
[ -z "$w32root" ] && w32root="$HOME/w32root" [ -z "$w32root" ] && w32root="$HOME/w32root"
toolprefixes="i586-mingw32msvc i386-mingw32msvc mingw32" toolprefixes="$w32_toolprefixes i586-mingw32msvc"
toolprefixes="$toolprefixes i386-mingw32msvc mingw32"
extraoptions="$w32_extraoptions"
;; ;;
esac esac
echo "Using $w32root as standard install directory" >&2 echo "Using $w32root as standard install directory" >&2
@ -147,9 +170,11 @@ if [ "$myhost" = "amd64" ]; then
[ -z "$amd64root" ] && amd64root="$HOME/amd64root" [ -z "$amd64root" ] && amd64root="$HOME/amd64root"
echo "Using $amd64root as standard install directory" >&2 echo "Using $amd64root as standard install directory" >&2
toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu"
# Locate the cross compiler # Locate the cross compiler
crossbindir= crossbindir=
for host in x86_64-linux-gnu amd64-linux-gnu; do for host in $toolprefixes ; do
if ${host}-gcc --version >/dev/null 2>&1 ; then if ${host}-gcc --version >/dev/null 2>&1 ; then
crossbindir=/usr/${host}/bin crossbindir=/usr/${host}/bin
conf_CC="CC=${host}-gcc" conf_CC="CC=${host}-gcc"
@ -224,7 +249,7 @@ if test "$DIE" = "yes"; then
cat <<EOF cat <<EOF
Note that you may use alternative versions of the tools by setting Note that you may use alternative versions of the tools by setting
the corresponding environment variables; see README.CVS for details. the corresponding environment variables; see README.SVN for details.
EOF EOF
exit 1 exit 1

View File

@ -1,3 +1,26 @@
2010-04-14 Werner Koch <wk@g10code.com>
* asshelp.c (setup_libassuan_logging): Read ASSUAN_DEBUG envvar.
(my_libassuan_log_handler): Use it.
* sysutils.c (_gnupg_getenv): Implement ASSUAN_DEBUG.
2010-04-08 Werner Koch <wk@g10code.com>
* w32help.h (_setmode, setmode) [W32CE]: Provide prototype and
macro.
2010-04-07 Werner Koch <wk@g10code.com>
* mischelp.c (timegm): Replace unsetenv/putenv by gnupg_unsetenv.
* sysutils.c: Include setenv.h.
(gnupg_setenv, gnupg_unsetenv): New.
2010-04-06 Werner Koch <wk@g10code.com>
* sysutils.c (gnupg_mkdir): New.
2010-03-29 Werner Koch <wk@g10code.com> 2010-03-29 Werner Koch <wk@g10code.com>
* init.c (sleep_on_exit): Change to 400ms. * init.c (sleep_on_exit): Change to 400ms.

View File

@ -36,6 +36,14 @@
#include "asshelp.h" #include "asshelp.h"
/* A bitfield that specifies the assuan categories to log. This is
identical to the default log handler of libassuan. We need to do
it ourselves because we use a custom log handler and want to use
the same assuan variables to select the categories to log. */
static int log_cats;
#define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1))))
static int static int
my_libassuan_log_handler (assuan_context_t ctx, void *hook, my_libassuan_log_handler (assuan_context_t ctx, void *hook,
unsigned int cat, const char *msg) unsigned int cat, const char *msg)
@ -44,8 +52,9 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
(void)ctx; (void)ctx;
if (cat != ASSUAN_LOG_CONTROL) if (! TEST_LOG_CAT (cat))
return 0; /* We only want the control channel messages. */ return 0;
dbgval = hook? *(unsigned int*)hook : 0; dbgval = hook? *(unsigned int*)hook : 0;
if (!(dbgval & 1024)) if (!(dbgval & 1024))
return 0; /* Assuan debugging is not enabled. */ return 0; /* Assuan debugging is not enabled. */
@ -62,6 +71,13 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
void void
setup_libassuan_logging (unsigned int *debug_var_address) setup_libassuan_logging (unsigned int *debug_var_address)
{ {
char *flagstr;
flagstr = getenv ("ASSUAN_DEBUG");
if (flagstr)
log_cats = atoi (flagstr);
else /* Default to log the control channel. */
log_cats = (1 << (ASSUAN_LOG_CONTROL - 1));
assuan_set_log_cb (my_libassuan_log_handler, debug_var_address); assuan_set_log_cb (my_libassuan_log_handler, debug_var_address);
} }

View File

@ -118,6 +118,9 @@ void *memrchr (const void *block, int c, size_t size);
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
# define _set_errno(a) gpg_err_set_errno ((a)) # define _set_errno(a) gpg_err_set_errno ((a))
/* Setmode is missing in cegcc but available since CE 5.0. */
int _setmode (int handle, int mode);
# define setmode(a,b) _setmode ((a),(b))
#else #else
# define _set_errno(a) do { errno = (a); } while (0) # define _set_errno(a) do { errno = (a); } while (0)
#endif #endif

View File

@ -183,11 +183,7 @@ timegm (struct tm *tm)
putenv (old_zone); putenv (old_zone);
} }
else else
#ifdef HAVE_UNSETENV gnupg_unsetenv("TZ");
unsetenv("TZ");
#else
putenv("TZ");
#endif
tzset(); tzset();
return answer; return answer;

View File

@ -51,6 +51,8 @@
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#include "setenv.h" /* Gnulib replacement. */
#include "util.h" #include "util.h"
#include "i18n.h" #include "i18n.h"
@ -529,6 +531,97 @@ gnupg_remove (const char *fname)
} }
/* A wrapper around mkdir which takes a string for the mode argument.
This makes it easier to handle the mode argument which is not
defined on all systems. The format of the modestring is
"-rwxrwxrwx"
'-' is a don't care or not set. 'r', 'w', 'x' are read allowed,
write allowed, execution allowed with the first group for the user,
the second for the group and the third for all others. If the
string is shorter than above the missing mode characters are meant
to be not set. */
int
gnupg_mkdir (const char *name, const char *modestr)
{
#ifdef HAVE_W32CE_SYSTEM
wchar_t *wname;
(void)modestr;
wname = utf8_to_wchar (name);
if (!wname)
return -1;
if (!CreateDirectoryW (wname, NULL))
{
xfree (wname);
return -1; /* ERRNO is automagically provided by gpg-error.h. */
}
xfree (wname);
return 0;
#elif MKDIR_TAKES_ONE_ARG
(void)modestr;
/* Note: In the case of W32 we better use CreateDirectory and try to
set appropriate permissions. However using mkdir is easier
because this sets ERRNO. */
return mkdir (name);
#else
mode_t mode = 0;
if (modestr && *modestr)
{
modestr++;
if (*modestr && *modestr++ == 'r')
mode |= S_IRUSR;
if (*modestr && *modestr++ == 'w')
mode |= S_IWUSR;
if (*modestr && *modestr++ == 'x')
mode |= S_IXUSR;
if (*modestr && *modestr++ == 'r')
mode |= S_IRGRP;
if (*modestr && *modestr++ == 'w')
mode |= S_IWGRP;
if (*modestr && *modestr++ == 'x')
mode |= S_IXGRP;
if (*modestr && *modestr++ == 'r')
mode |= S_IROTH;
if (*modestr && *modestr++ == 'w')
mode |= S_IWOTH;
if (*modestr && *modestr++ == 'x')
mode |= S_IXOTH;
}
return mkdir (home, mode)
#endif
}
int
gnupg_setenv (const char *name, const char *value, int overwrite)
{
#ifdef HAVE_W32CE_SYSTEM
(void)name;
(void)value;
(void)overwrite;
return 0;
#else
setenv (name, value, overwrite);
#endif
}
int
gnupg_unsetenv (const char *name)
{
#ifdef HAVE_W32CE_SYSTEM
(void)name;
return 0;
#else
# ifdef HAVE_UNSETENV
unsetenv (name);
# else
putenv (name);
# endif
#endif
}
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
@ -538,8 +631,22 @@ gnupg_remove (const char *fname)
char * char *
_gnupg_getenv (const char *name) _gnupg_getenv (const char *name)
{ {
(void)name; static int initialized;
static char *assuan_debug;
if (!initialized)
{
assuan_debug = read_w32_registry_string (NULL,
"\\Software\\GNU\\libassuan",
"debug");
initialized = 1;
}
if (!strcmp (name, "ASSUAN_DEBUG"))
return assuan_debug;
else
return NULL; return NULL;
} }
#endif /*HAVE_W32CE_SYSTEM*/ #endif /*HAVE_W32CE_SYSTEM*/

View File

@ -49,6 +49,9 @@ FILE *gnupg_tmpfile (void);
void gnupg_reopen_std (const char *pgmname); void gnupg_reopen_std (const char *pgmname);
void gnupg_allow_set_foregound_window (pid_t pid); void gnupg_allow_set_foregound_window (pid_t pid);
int gnupg_remove (const char *fname); int gnupg_remove (const char *fname);
int gnupg_mkdir (const char *name, const char *modestr);
int gnupg_setenv (const char *name, const char *value, int overwrite);
int gnupg_unsetenv (const char *name);
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM

View File

@ -298,6 +298,8 @@ ttyname (int fd)
#define getpid() GetCurrentProcessId () #define getpid() GetCurrentProcessId ()
char *_gnupg_getenv (const char *name); /* See sysutils.c */ char *_gnupg_getenv (const char *name); /* See sysutils.c */
#define getenv(a) _gnupg_getenv ((a)) #define getenv(a) _gnupg_getenv ((a))
char *_gnupg_setenv (const char *name); /* See sysutils.c */
#define setenv(a,b,c) _gnupg_setenv ((a),(b),(c))
#endif #endif

View File

@ -28,5 +28,12 @@ int write_w32_registry_string (const char *root, const char *dir,
const char *name, const char *value); const char *name, const char *value);
/* Other stuff. */
#ifdef HAVE_W32CE_SYSTEM
/* Setmode is missing in cegcc but available since CE 5.0. */
int _setmode (int handle, int mode);
# define setmode(a,b) _setmode ((a),(b))
#endif /*HAVE_W32CE_SYSTEM*/
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/
#endif /*LIBJNLIB_MISCHELP_H*/ #endif /*LIBJNLIB_MISCHELP_H*/

View File

@ -1,3 +1,8 @@
2010-04-06 Werner Koch <wk@g10code.com>
* openfile.c (mkdir): Remove.
(try_make_homedir): Use gnupg_mkdir.
2010-04-01 Werner Koch <wk@g10code.com> 2010-04-01 Werner Koch <wk@g10code.com>
Use gpg_err_set_errno to set ERRNO. Use gpg_err_set_errno to set ERRNO.

View File

@ -56,10 +56,6 @@
#define CMP_FILENAME(a,b) strcmp( (a), (b) ) #define CMP_FILENAME(a,b) strcmp( (a), (b) )
#endif #endif
#ifdef MKDIR_TAKES_ONE_ARG
#undef mkdir
#define mkdir(a,b) mkdir(a)
#endif
/* FIXME: Implement opt.interactive. */ /* FIXME: Implement opt.interactive. */
@ -444,12 +440,11 @@ try_make_homedir (const char *fname)
#endif #endif
) )
{ {
if ( mkdir (fname, S_IRUSR|S_IWUSR|S_IXUSR) ) if (gnupg_mkdir (fname, "-rwx"))
log_fatal ( _("can't create directory `%s': %s\n"), log_fatal ( _("can't create directory `%s': %s\n"),
fname, strerror(errno) ); fname, strerror(errno) );
else if (!opt.quiet ) else if (!opt.quiet )
log_info ( _("directory `%s' created\n"), fname ); log_info ( _("directory `%s' created\n"), fname );
copy_options_file( fname ); copy_options_file( fname );
} }
} }

View File

@ -80,6 +80,11 @@
# include <io.h> # include <io.h>
#endif #endif
#ifdef HAVE_W32CE_SYSTEM
#include <windows.h>
#define getpid() GetCurrentProcessId ()
#endif
#if !_LIBC #if !_LIBC
# define __getpid getpid # define __getpid getpid
# define __gettimeofday gettimeofday # define __gettimeofday gettimeofday

View File

@ -1,3 +1,22 @@
2010-04-14 Werner Koch <wk@g10code.com>
* gpgsm.c (main) [W32CE]: Disable dirmngr for now.
2010-04-13 Werner Koch <wk@g10code.com>
* sign.c (gpgsm_sign): Do not check qualified status in
no-chain-validation mode.
2010-04-08 Werner Koch <wk@g10code.com>
* gpgsm.c (open_es_fread): Add arg mode.
(main) <aKeygen>: Call with mode "r" instead of "rb".
2010-04-07 Werner Koch <wk@g10code.com>
* misc.c: Remove setenv.h. Include sysutils.h.
(setup_pinentry_env): s/setenv/gnupg_setenv/
2010-03-24 Werner Koch <wk@g10code.com> 2010-03-24 Werner Koch <wk@g10code.com>
* Makefile.am (gpgsm_LDADD): Add extra_sys_libs. * Makefile.am (gpgsm_LDADD): Add extra_sys_libs.

View File

@ -434,7 +434,7 @@ static void set_cmd (enum cmd_and_opt_values *ret_cmd,
static void emergency_cleanup (void); static void emergency_cleanup (void);
static int check_special_filename (const char *fname, int for_write); static int check_special_filename (const char *fname, int for_write);
static int open_read (const char *filename); static int open_read (const char *filename);
static estream_t open_es_fread (const char *filename); static estream_t open_es_fread (const char *filename, const char *mode);
static FILE *open_fwrite (const char *filename); static FILE *open_fwrite (const char *filename);
static estream_t open_es_fwrite (const char *filename); static estream_t open_es_fwrite (const char *filename);
static void run_protect_tool (int argc, char **argv); static void run_protect_tool (int argc, char **argv);
@ -942,6 +942,11 @@ main ( int argc, char **argv)
opt.homedir = default_homedir (); opt.homedir = default_homedir ();
#ifdef HAVE_W32CE_SYSTEM
opt.disable_dirmngr = 1;
opt.no_crl_check = 1;
#endif
/* 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_argc = argc;
orig_argv = argv; orig_argv = argv;
@ -1834,9 +1839,9 @@ main ( int argc, char **argv)
if (opt.batch) if (opt.batch)
{ {
if (!argc) /* Create from stdin. */ if (!argc) /* Create from stdin. */
fpin = open_es_fread ("-"); fpin = open_es_fread ("-", "r");
else if (argc == 1) /* From file. */ else if (argc == 1) /* From file. */
fpin = open_es_fread (*argv); fpin = open_es_fread (*argv, "r");
else else
wrong_args ("--gen-key --batch [parmfile]"); wrong_args ("--gen-key --batch [parmfile]");
} }
@ -2057,7 +2062,7 @@ open_read (const char *filename)
/* Same as open_read but return an estream_t. */ /* Same as open_read but return an estream_t. */
static estream_t static estream_t
open_es_fread (const char *filename) open_es_fread (const char *filename, const char *mode)
{ {
int fd; int fd;
estream_t fp; estream_t fp;
@ -2068,7 +2073,7 @@ open_es_fread (const char *filename)
fd = check_special_filename (filename, 0); fd = check_special_filename (filename, 0);
if (fd != -1) if (fd != -1)
{ {
fp = es_fdopen_nc (fd, "rb"); fp = es_fdopen_nc (fd, mode);
if (!fp) if (!fp)
{ {
log_error ("es_fdopen(%d) failed: %s\n", fd, strerror (errno)); log_error ("es_fdopen(%d) failed: %s\n", fd, strerror (errno));
@ -2076,7 +2081,7 @@ open_es_fread (const char *filename)
} }
return fp; return fp;
} }
fp = es_fopen (filename, "rb"); fp = es_fopen (filename, mode);
if (!fp) if (!fp)
{ {
log_error (_("can't open `%s': %s\n"), filename, strerror (errno)); log_error (_("can't open `%s': %s\n"), filename, strerror (errno));

View File

@ -30,7 +30,7 @@
#include "gpgsm.h" #include "gpgsm.h"
#include "i18n.h" #include "i18n.h"
#include "setenv.h" #include "sysutils.h"
/* Setup the environment so that the pinentry is able to get all /* Setup the environment so that the pinentry is able to get all
required information. This is used prior to an exec of the required information. This is used prior to an exec of the
@ -49,7 +49,7 @@ setup_pinentry_env (void)
but print a warning. */ but print a warning. */
value = session_env_getenv (opt.session_env, "GPG_TTY"); value = session_env_getenv (opt.session_env, "GPG_TTY");
if (value) if (value)
setenv ("GPG_TTY", value, 1); gnupg_setenv ("GPG_TTY", value, 1);
else if (!(lc=getenv ("GPG_TTY")) || !*lc) else if (!(lc=getenv ("GPG_TTY")) || !*lc)
{ {
log_error (_("GPG_TTY has not been set - " log_error (_("GPG_TTY has not been set - "
@ -57,21 +57,21 @@ setup_pinentry_env (void)
lc = ttyname (0); lc = ttyname (0);
if (!lc) if (!lc)
lc = "/dev/tty"; lc = "/dev/tty";
setenv ("GPG_TTY", lc, 1); gnupg_setenv ("GPG_TTY", lc, 1);
} }
if (opt.lc_ctype) if (opt.lc_ctype)
setenv ("LC_CTYPE", opt.lc_ctype, 1); gnupg_setenv ("LC_CTYPE", opt.lc_ctype, 1);
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) #if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
else if ( (lc = setlocale (LC_CTYPE, "")) ) else if ( (lc = setlocale (LC_CTYPE, "")) )
setenv ("LC_CTYPE", lc, 1); gnupg_setenv ("LC_CTYPE", lc, 1);
#endif #endif
if (opt.lc_messages) if (opt.lc_messages)
setenv ("LC_MESSAGES", opt.lc_messages, 1); gnupg_setenv ("LC_MESSAGES", opt.lc_messages, 1);
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) #if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
else if ( (lc = setlocale (LC_MESSAGES, "")) ) else if ( (lc = setlocale (LC_MESSAGES, "")) )
setenv ("LC_MESSAGES", lc, 1); gnupg_setenv ("LC_MESSAGES", lc, 1);
#endif #endif
iterator = 0; iterator = 0;
@ -81,7 +81,7 @@ setup_pinentry_env (void)
continue; /* Already set. */ continue; /* Already set. */
value = session_env_getenv (opt.session_env, name); value = session_env_getenv (opt.session_env, name);
if (value) if (value)
setenv (name, value, 1); gnupg_setenv (name, value, 1);
} }
#endif /*!HAVE_W32_SYSTEM*/ #endif /*!HAVE_W32_SYSTEM*/

View File

@ -503,6 +503,8 @@ gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
/* Check whether one of the certificates is qualified. Note that we /* Check whether one of the certificates is qualified. Note that we
already validated the certificate and thus the user data stored already validated the certificate and thus the user data stored
flag must be available. */ flag must be available. */
if (!opt.no_chain_validation)
{
for (cl=signerlist; cl; cl = cl->next) for (cl=signerlist; cl; cl = cl->next)
{ {
size_t buflen; size_t buflen;
@ -527,6 +529,7 @@ gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
goto leave; goto leave;
} }
} }
}
/* Prepare hashing (actually we are figuring out what we have set /* Prepare hashing (actually we are figuring out what we have set
above). */ above). */

View File

@ -210,12 +210,17 @@ gnu_getcwd (void)
for (;;) for (;;)
{ {
buffer = xmalloc (size+1); buffer = xmalloc (size+1);
#ifdef HAVE_W32CE_SYSTEM
strcpy (buffer, "/");
return buffer;
#else
if (getcwd (buffer, size) == buffer) if (getcwd (buffer, size) == buffer)
return buffer; return buffer;
xfree (buffer); xfree (buffer);
if (errno != ERANGE) if (errno != ERANGE)
return NULL; return NULL;
size *= 2; size *= 2;
#endif
} }
} }
@ -989,7 +994,8 @@ do_open (char *line)
if (fd >= 0 && fd < DIM (open_fd_table)) if (fd >= 0 && fd < DIM (open_fd_table))
{ {
open_fd_table[fd].inuse = 1; open_fd_table[fd].inuse = 1;
#ifdef HAVE_W32_SYSTEM #warning fixme: implement our pipe emulation.
#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM)
{ {
HANDLE prochandle, handle, newhandle; HANDLE prochandle, handle, newhandle;
@ -1197,7 +1203,11 @@ main (int argc, char **argv)
if (log_get_errorcount (0)) if (log_get_errorcount (0))
exit (2); exit (2);
#ifdef HAVE_W32CE_SYSTEM
use_tty = 0;
#else
use_tty = (isatty ( fileno (stdin)) && isatty (fileno (stdout))); use_tty = (isatty ( fileno (stdin)) && isatty (fileno (stdout)));
#endif
if (opt.exec) if (opt.exec)
{ {
@ -1890,7 +1900,11 @@ handle_inquire (assuan_context_t ctx, char *line)
{ {
if (d->is_prog) if (d->is_prog)
{ {
#ifdef HAVE_W32CE_SYSTEM
fp = NULL;
#else
fp = popen (d->file, "r"); fp = popen (d->file, "r");
#endif
if (!fp) if (!fp)
log_error ("error executing `%s': %s\n", log_error ("error executing `%s': %s\n",
d->file, strerror (errno)); d->file, strerror (errno));
@ -1931,8 +1945,10 @@ handle_inquire (assuan_context_t ctx, char *line)
; ;
else if (d->is_prog) else if (d->is_prog)
{ {
#ifndef HAVE_W32CE_SYSTEM
if (pclose (fp)) if (pclose (fp))
log_error ("error running `%s': %s\n", d->file, strerror (errno)); log_error ("error running `%s': %s\n", d->file, strerror (errno));
#endif
} }
else else
fclose (fp); fclose (fp);