aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog24
-rw-r--r--g10/armor.c9
-rw-r--r--g10/filter.h1
-rw-r--r--g10/g10.c14
-rw-r--r--g10/keygen.c11
-rw-r--r--g10/main.h2
-rw-r--r--g10/openfile.c29
-rw-r--r--g10/pkclist.c5
-rw-r--r--g10/ringedit.c29
-rw-r--r--g10/tdbio.c18
-rw-r--r--g10/trustdb.c2
11 files changed, 89 insertions, 55 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 55633c155..09bc6f766 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,27 @@
+Sat Dec 4 12:30:28 CET 1999 Werner Koch <[email protected]>
+
+ * pkclist.c (build_pk_list): Validate the trust using the namehash
+ if this one has been set by the key lookup.
+
+ * g10.c: Add --delete-secret-key to the help page.
+
+ * openfile.c (copy_options_file): Made static.
+ (try_make_homedir): New.
+ * ringedit.c (add_keyblock_resource): Use the try_make_hoemdir logic.
+ * tdbio.c (tdbio_set_dbname): Likewise.
+
+ * keygen.c (generate_user_id): Use m_alloc_clear() here. We should
+ better use an allocation function specific to the user_id packet.
+
+ * keygen.c (keygen_add_std_prefs): Changed symmetric preferences
+ to include Blowfish again. This is due to it's better speed compared
+ to CAST5.
+
+ * g10.c (strusage): Print the home directory.
+
+ * armor.c (armor_filter): Take action on the cancel control msg.
+ * filter.h (armor_filter_context_t): Add cancel flag.
+
Mon Nov 29 21:52:11 CET 1999 Werner Koch <[email protected]>
* g10.c: New option --fast-list-mode ..
diff --git a/g10/armor.c b/g10/armor.c
index be0cc1472..3fa52e617 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -874,7 +874,7 @@ armor_filter( void *opaque, int control,
#endif
*ret_len = n;
}
- else if( control == IOBUFCTRL_FLUSH ) {
+ else if( control == IOBUFCTRL_FLUSH && !afx->cancel ) {
if( !afx->status ) { /* write the header line */
if( afx->what >= DIM(head_strings) )
log_bug("afx->what=%d", afx->what);
@@ -951,8 +951,13 @@ armor_filter( void *opaque, int control,
if( !is_initialized )
initialize();
}
+ else if( control == IOBUFCTRL_CANCEL ) {
+ afx->cancel = 1;
+ }
else if( control == IOBUFCTRL_FREE ) {
- if( afx->status ) { /* pad, write cecksum, and bottom line */
+ if( afx->cancel )
+ ;
+ else if( afx->status ) { /* pad, write cecksum, and bottom line */
crc = afx->crc;
idx = afx->idx;
idx2 = afx->idx2;
diff --git a/g10/filter.h b/g10/filter.h
index 49d92103b..5e16040e7 100644
--- a/g10/filter.h
+++ b/g10/filter.h
@@ -59,6 +59,7 @@ typedef struct {
u32 crc;
int status; /* an internal state flag */
+ int cancel;
int any_data; /* any valid armored data seen */
int pending_lf; /* used together with faked */
} armor_filter_context_t;
diff --git a/g10/g10.c b/g10/g10.c
index ab84e0ddc..fd3b33356 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -205,6 +205,8 @@ static ARGPARSE_OPTS opts[] = {
{ aListSecretKeys, "list-secret-keys", 256, N_("list secret keys")},
{ aKeygen, "gen-key", 256, N_("generate a new key pair")},
{ aDeleteKey, "delete-key",256, N_("remove key from the public keyring")},
+ { aDeleteSecretKey, "delete-secret-key",256,
+ N_("remove key from the secret keyring")},
{ aSignKey, "sign-key" ,256, N_("sign a key")},
{ aLSignKey, "lsign-key" ,256, N_("sign a key locally")},
{ aEditKey, "edit-key" ,256, N_("sign or edit a key")},
@@ -304,7 +306,6 @@ static ARGPARSE_OPTS opts[] = {
{ aListTrustPath, "list-trust-path",0, "@"},
{ oKOption, NULL, 0, "@"},
{ oPasswdFD, "passphrase-fd",1, "@" },
- { aDeleteSecretKey, "delete-secret-key",0, "@" },
{ oQuickRandom, "quick-random", 0, "@"},
{ oNoVerbose, "no-verbose", 0, "@"},
{ oTrustDBName, "trustdb-name", 2, "@" },
@@ -391,26 +392,29 @@ strusage( int level )
"default operation depends on the input data\n");
break;
- case 31: p = _("\nSupported algorithms:\n"); break;
- case 32:
+ case 31: p = "\nHome: "; break;
+ case 32: p = opt.homedir; break;
+ case 33: p = _("\nSupported algorithms:\n"); break;
+ case 34:
if( !ciphers )
ciphers = build_list("Cipher: ", cipher_algo_to_string,
check_cipher_algo );
p = ciphers;
break;
- case 33:
+ case 35:
if( !pubkeys )
pubkeys = build_list("Pubkey: ", pubkey_algo_to_string,
check_pubkey_algo );
p = pubkeys;
break;
- case 34:
+ case 36:
if( !digests )
digests = build_list("Hash: ", digest_algo_to_string,
check_digest_algo );
p = digests;
break;
+
default: p = default_strusage(level);
}
return p;
diff --git a/g10/keygen.c b/g10/keygen.c
index 415b5b25f..11d79d0fd 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -43,7 +43,7 @@ write_uid( KBNODE root, const char *s )
size_t n = strlen(s);
pkt->pkttype = PKT_USER_ID;
- pkt->pkt.user_id = m_alloc( sizeof *pkt->pkt.user_id + n - 1 );
+ pkt->pkt.user_id = m_alloc_clear( sizeof *pkt->pkt.user_id + n - 1 );
pkt->pkt.user_id->len = n;
strcpy(pkt->pkt.user_id->name, s);
add_kbnode( root, new_kbnode( pkt ) );
@@ -84,8 +84,9 @@ keygen_add_std_prefs( PKT_signature *sig, void *opaque )
keygen_add_key_expire( sig, opaque );
buf[0] = CIPHER_ALGO_TWOFISH;
- buf[1] = CIPHER_ALGO_CAST5;
- build_sig_subpkt( sig, SIGSUBPKT_PREF_SYM, buf, 2 );
+ buf[1] = CIPHER_ALGO_BLOWFISH;
+ buf[2] = CIPHER_ALGO_CAST5;
+ build_sig_subpkt( sig, SIGSUBPKT_PREF_SYM, buf, 3 );
buf[0] = DIGEST_ALGO_RMD160;
buf[1] = DIGEST_ALGO_SHA1;
@@ -558,7 +559,7 @@ ask_expire_interval(void)
tty_printf(_("Key expires at %s\n"),
asctimestamp((ulong)(curtime + interval) ) );
if( (time_t)((ulong)(curtime+interval)) < 0 )
- tty_printf(_("Your system can't display dates beyond 2036.\n"
+ tty_printf(_("Your system can't display dates beyond 2038.\n"
"However, it will be correctly handled up to 2106.\n"));
}
@@ -827,7 +828,7 @@ generate_user_id()
if( !p )
return NULL;
n = strlen(p);
- uid = m_alloc( sizeof *uid + n - 1 );
+ uid = m_alloc_clear( sizeof *uid + n - 1 );
uid->len = n;
strcpy(uid->name, p);
return uid;
diff --git a/g10/main.h b/g10/main.h
index 554a60581..4be23aecd 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -103,7 +103,7 @@ char *make_outfile_name( const char *iname );
char *ask_outfile_name( const char *name, size_t namelen );
int open_outfile( const char *iname, int mode, IOBUF *a );
IOBUF open_sigfile( const char *iname );
-void copy_options_file( const char *destdir );
+void try_make_homedir( const char *fname );
/*-- seskey.c --*/
void make_session_key( DEK *dek );
diff --git a/g10/openfile.c b/g10/openfile.c
index 8c78670d7..4591f4212 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -24,6 +24,9 @@
#include <string.h>
#include <assert.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include "util.h"
#include "memory.h"
@@ -45,6 +48,10 @@
#define CMP_FILENAME(a,b) strcmp( (a), (b) )
#endif
+#ifdef MKDIR_TAKES_ONE_ARG
+# undef mkdir
+# define mkdir(a,b) mkdir(a)
+#endif
/* FIXME: Implement opt.interactive. */
@@ -251,7 +258,7 @@ open_sigfile( const char *iname )
/****************
* Copy the option file skeleton to the given directory.
*/
-void
+static void
copy_options_file( const char *destdir )
{
const char *datadir = GNUPG_DATADIR;
@@ -294,3 +301,23 @@ copy_options_file( const char *destdir )
m_free(fname);
}
+
+void
+try_make_homedir( const char *fname )
+{
+ if( opt.dry_run )
+ return;
+ if( strlen(fname) >= 7
+ && !strcmp(fname+strlen(fname)-7, "/.gnupg" ) ) {
+ if( mkdir( fname, S_IRUSR|S_IWUSR|S_IXUSR ) )
+ log_fatal( _("%s: can't create directory: %s\n"),
+ fname, strerror(errno) );
+ else if( !opt.quiet )
+ log_info( _("%s: directory created\n"), fname );
+ copy_options_file( fname );
+ log_info(_("you have to start GnuPG again, "
+ "so it can read the new options file\n") );
+ g10_exit(1);
+ }
+}
+
diff --git a/g10/pkclist.c b/g10/pkclist.c
index 0cf2942a3..04f76b653 100644
--- a/g10/pkclist.c
+++ b/g10/pkclist.c
@@ -775,7 +775,8 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use )
else {
int trustlevel;
- rc = check_trust( pk, &trustlevel, NULL, NULL, NULL );
+ rc = check_trust( pk, &trustlevel, pk->namehash,
+ NULL, NULL );
if( rc ) {
log_error("error checking pk of `%s': %s\n",
answer, g10_errstr(rc) );
@@ -849,7 +850,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use )
else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) {
int trustlevel;
- rc = check_trust( pk, &trustlevel, NULL, NULL, NULL );
+ rc = check_trust( pk, &trustlevel, pk->namehash, NULL, NULL );
if( rc ) {
free_public_key( pk ); pk = NULL;
log_error(_("%s: error checking key: %s\n"),
diff --git a/g10/ringedit.c b/g10/ringedit.c
index 7db1b0b6b..bd7a882bd 100644
--- a/g10/ringedit.c
+++ b/g10/ringedit.c
@@ -63,10 +63,6 @@
#include "i18n.h"
-#ifdef MKDIR_TAKES_ONE_ARG
-# undef mkdir
-# define mkdir(a,b) mkdir(a)
-#endif
struct resource_table_struct {
@@ -291,24 +287,13 @@ add_keyblock_resource( const char *url, int force, int secret )
*last_slash_in_filename = 0;
if( access(filename, F_OK) ) {
- if( strlen(filename) >= 7
- && !strcmp(filename+strlen(filename)-7, "/.gnupg") ) {
- if( mkdir(filename, S_IRUSR|S_IWUSR|S_IXUSR) )
- {
- log_error( _("%s: can't create directory: %s\n"),
- filename, strerror(errno));
- rc = G10ERR_OPEN_FILE;
- goto leave;
- }
- else if( !opt.quiet )
- log_info( _("%s: directory created\n"), filename );
- copy_options_file( filename );
- }
- else
- {
- rc = G10ERR_OPEN_FILE;
- goto leave;
- }
+ /* on the first time we try to create the default homedir and
+ * in this case the process will be terminated, so that on the
+ * next invocation it can read the options file in on startup
+ */
+ try_make_homedir( filename );
+ rc = G10ERR_OPEN_FILE;
+ goto leave;
}
*last_slash_in_filename = '/';
diff --git a/g10/tdbio.c b/g10/tdbio.c
index 70fc530fd..6ae39ed20 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -40,11 +40,6 @@
#include "tdbio.h"
-#ifdef MKDIR_TAKES_ONE_ARG
-# undef mkdir
-# define mkdir(a,b) mkdir(a)
-#endif
-
/****************
* Yes, this is a very simple implementation. We should really
* use a page aligned buffer and read complete pages.
@@ -439,17 +434,8 @@ tdbio_set_dbname( const char *new_dbname, int create )
assert(p);
*p = 0;
if( access( fname, F_OK ) ) {
- if( strlen(fname) >= 7
- && !strcmp(fname+strlen(fname)-7, "/.gnupg" ) ) {
- if( mkdir( fname, S_IRUSR|S_IWUSR|S_IXUSR ) )
- log_fatal( _("%s: can't create directory: %s\n"),
- fname, strerror(errno) );
- else if( !opt.quiet )
- log_info( _("%s: directory created\n"), fname );
- copy_options_file( fname );
- }
- else
- log_fatal( _("%s: directory does not exist!\n"), fname );
+ try_make_homedir( fname );
+ log_fatal( _("%s: directory does not exist!\n"), fname );
}
*p = '/';
diff --git a/g10/trustdb.c b/g10/trustdb.c
index e239306b4..69e3936b0 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -2664,7 +2664,7 @@ enum_cert_paths_print( void **context, FILE *fp,
/*
* Return an allocated buffer with the preference values for
* the key with LID and the userid which is identified by the
- * HAMEHASH or the firstone if namehash is NULL. ret_n receives
+ * HAMEHASH or the first one if namehash is NULL. ret_n receives
* the length of the allocated buffer. Structure of the buffer is
* a repeated sequences of 2 bytes; where the first byte describes the
* type of the preference and the second one the value. The constants