mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
some random changes
This commit is contained in:
parent
e309a875cb
commit
5ccb92591e
3
AUTHORS
3
AUTHORS
@ -28,3 +28,6 @@ fr.po
|
||||
TRANSLATIONS Walter Koch ??????????
|
||||
de.po
|
||||
|
||||
TRANSLATIONS Gregory Steuck ??????????
|
||||
ru.po
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
Sun Oct 25 19:49:37 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* Makefile.am (g10defs.h): New macro GNUPG_DATADIR.
|
||||
|
||||
Wed Oct 21 17:24:24 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* configure.in: Removed gettext kludge
|
||||
|
17
Makefile.am
17
Makefile.am
@ -13,9 +13,11 @@ g10defs.h : config.h
|
||||
echo "#ifdef __MINGW32__"; \
|
||||
echo "#define G10_LOCALEDIR \"c:/lib/gnupg/locale\""; \
|
||||
echo "#define GNUPG_LIBDIR \"c:/lib/gnupg\""; \
|
||||
echo "#define GNUPG_DATADIR \"c:/lib/gnupg\""; \
|
||||
echo "#else";\
|
||||
echo "#define G10_LOCALEDIR \"$(prefix)/$(DATADIRNAME)/locale\""; \
|
||||
echo "#define GNUPG_LIBDIR \"$(libdir)/gnupg\""; \
|
||||
echo "#define GNUPG_DATADIR \"$(datadir)/gnupg\""; \
|
||||
echo "#endif";\
|
||||
) >g10defs.h
|
||||
|
||||
@ -36,13 +38,24 @@ dist-hook:
|
||||
|
||||
# maintainer only
|
||||
cvs-get:
|
||||
rsync -avuzb --exclude '*~' koch@ftp.guug.de:work/gnupg .
|
||||
rsync -Cavuzb --exclude scratch --exclude .deps \
|
||||
koch@ftp.guug.de:work/gnupg .
|
||||
|
||||
cvs-put:
|
||||
rsync -Cavuzb . koch@ftp.guug.de:work/gnupg
|
||||
rsync -Cavuzb --exclude .deps --exclude scratch \
|
||||
. koch@ftp.guug.de:work/gnupg
|
||||
|
||||
cvs-sync: cvs-get cvs-put
|
||||
|
||||
|
||||
tobold-get:
|
||||
rsync -Cavuzb --exclude scratch --exclude .deps \
|
||||
tobold:gnupg/ .
|
||||
|
||||
tobold-put:
|
||||
rsync -Cavuzb --excude scratch --exclude .deps \
|
||||
. tobold:gnupg/
|
||||
|
||||
|
||||
.PHONY: cvs-get cvs-put cvs-sync
|
||||
|
||||
|
4
NEWS
4
NEWS
@ -12,6 +12,10 @@
|
||||
keys. Use "--keyring gnupg-gdbm:<name-of-gdbm-file>". This is
|
||||
not (yet) supported for secret keys.
|
||||
|
||||
* A Russian language file in the distribution (alternatives are in
|
||||
the contrib directory of the FTP servers)
|
||||
|
||||
|
||||
|
||||
Noteworthy changes in version 0.4.2
|
||||
-----------------------------------
|
||||
|
2
TODO
2
TODO
@ -1,6 +1,8 @@
|
||||
|
||||
* Fix ;) revocation and expire stuff.
|
||||
|
||||
* check preferences (cipher and compress)
|
||||
|
||||
* OpenBSD: dynamic loading with dlopen works on OpenBSD, but:
|
||||
OpenBSD binaries are a.out, so every symbol begins with "_"
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
Sun Oct 25 18:19:35 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* mds.test: Check whether TIGER is available.
|
||||
* sigs.tesr: Ditto.
|
||||
|
||||
Wed Sep 23 12:25:07 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* run-gpg.patterns: New (because Solaris fgrep does not like -f -).
|
||||
|
@ -60,6 +60,10 @@ chdir () {
|
||||
#}
|
||||
|
||||
|
||||
have_hash_algo () {
|
||||
../g10/gpgm --homedir . --version | grep "Hash:.*$1" >/dev/null
|
||||
}
|
||||
|
||||
set -e
|
||||
pgmname=`basename $0`
|
||||
#trap cleanup SIGHUP SIGINT SIGQUIT
|
||||
|
@ -1,7 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
. $srcdir/defs.inc || exit 3
|
||||
|
||||
|
||||
test_one () {
|
||||
if [ "`grep $1 y | sed -e 's/.*=[ ]\(.*\)/\1/' -e 's/ //g'`" != "$2" ]; then
|
||||
failed="$failed $1"
|
||||
@ -11,11 +13,15 @@ test_one () {
|
||||
failed=""
|
||||
|
||||
#info Checking message digests
|
||||
echo -n "" | $srcdir/run-gpgm --print-mds >y
|
||||
echo -n "" | $srcdir/run-gpgm -v --print-mds >y
|
||||
test_one "MD5" "D41D8CD98F00B204E9800998ECF8427E"
|
||||
test_one "SHA1" "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
|
||||
test_one "RMD160" "9C1185A5C5E9FC54612808977EE8F548B2258D31"
|
||||
test_one "TIGER" "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A"
|
||||
if have_hash_algo "TIGER"; then
|
||||
test_one "TIGER" "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A"
|
||||
else
|
||||
echo "Hash algorithm TIGER/192 is not installed"
|
||||
fi
|
||||
|
||||
[ "$failed" != "" ] && error "$failed failed for empty string"
|
||||
|
||||
@ -23,7 +29,9 @@ echo -n "abcdefghijklmnopqrstuvwxyz" | $srcdir/run-gpgm --print-mds >y
|
||||
test_one "MD5" "C3FCD3D76192E4007DFB496CCA67E13B"
|
||||
test_one "SHA1" "32D10C7B8CF96570CA04CE37F2A19D84240D3A89"
|
||||
test_one "RMD160" "F71C27109C692C1B56BBDCEB5B9D2865B3708DBC"
|
||||
test_one "TIGER" "307DE5EE72A414172A0355CCBF120404E9EE7BF32F60110B"
|
||||
if have_hash_algo "TIGER"; then
|
||||
test_one "TIGER" "307DE5EE72A414172A0355CCBF120404E9EE7BF32F60110B"
|
||||
fi
|
||||
|
||||
|
||||
[ "$failed" != "" ] && error "$failed failed for a..z"
|
||||
|
@ -9,7 +9,12 @@ for i in $plain_files $data_files; do
|
||||
cmp $i y || error "$i: mismatch"
|
||||
done
|
||||
|
||||
for da in ripemd160 sha1 md5 tiger; do
|
||||
hash_algo_list="ripemd160 sha1 md5"
|
||||
if have_hash_algo "TIGER"; then
|
||||
hash_algo_list="$hash_algo_list tiger"
|
||||
fi
|
||||
|
||||
for da in $hash_algo_list ; do
|
||||
for i in $plain_files; do
|
||||
echo "$usrpass1" | $srcdir/run-gpg --passphrase-fd 0 --digest-algo $da \
|
||||
-s -o x --yes $i
|
||||
|
@ -13,7 +13,7 @@ AM_CONFIG_HEADER(config.h)
|
||||
|
||||
VERSION=`cat $srcdir/VERSION`
|
||||
PACKAGE=gnupg
|
||||
ALL_LINGUAS="en de it fr"
|
||||
ALL_LINGUAS="en de it fr ru"
|
||||
AC_SUBST(VERSION)
|
||||
AC_SUBST(PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
|
||||
|
15
doc/gpg.1pod
15
doc/gpg.1pod
@ -190,8 +190,10 @@ B<--export-secret-keys> [I<names>
|
||||
Same as B<--export>, but does export the secret keys.
|
||||
This is normally not very useful.
|
||||
|
||||
B<--import>
|
||||
import/merge keys
|
||||
B<--import>, B<--fast-import>
|
||||
Import/merge keys. The fast version does not build
|
||||
the trustdb; this can be deon at anytime with the
|
||||
command B<--update-trustdb>.
|
||||
|
||||
B<--export-ownertrust>
|
||||
List the assigned ownertrust values in ascii format
|
||||
@ -238,6 +240,8 @@ B<-v>, B<--verbose>
|
||||
Give more information during processing. If used
|
||||
twice, the input data is listed in detail.
|
||||
|
||||
B<-q>, B<--quiet>
|
||||
Be somewhat more quiet in some cases.
|
||||
|
||||
B<-z> I<n>
|
||||
Set compress level to I<n>. A value of 0 for I<n>
|
||||
@ -260,10 +264,10 @@ B<--no-batch>
|
||||
is used in the options file.
|
||||
|
||||
B<--yes>
|
||||
Assume yes on most questions.
|
||||
Assume "yes" on most questions.
|
||||
|
||||
B<--no>
|
||||
Assume no on most questions.
|
||||
Assume "no" on most questions.
|
||||
|
||||
B<--keyring> I<file>
|
||||
Add I<file> to the list of keyrings.
|
||||
@ -271,6 +275,9 @@ B<--keyring> I<file>
|
||||
are replaced by the HOME directory. If the filename
|
||||
does not contain a slash, it is assumed to be in the
|
||||
home-directory (F<~/.gnupg> if B<--homedir>) is not used.
|
||||
The filename may be prefixed with a scheme:
|
||||
"gnupg-ring:" is the default one.
|
||||
"gnupg-gdbm:" may be used for a GDBM ring.
|
||||
|
||||
B<--secret-keyring> I<file>
|
||||
Same as B<--keyring> but for secret keyrings.
|
||||
|
@ -1,3 +1,52 @@
|
||||
Sun Oct 25 19:32:05 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* openfile.c (copy_options_File): New.
|
||||
* ringedit.c (add_keyblock_resource): Creates options file
|
||||
* tdbio.c (tdbio_set_dbname): Ditto.
|
||||
|
||||
Sat Oct 24 14:10:53 1998 brian moore <bem@cmc.net>
|
||||
|
||||
* mainproc.c (proc_pubkey_enc): Don't release the DEK
|
||||
(do_proc_packets): Ditto.
|
||||
|
||||
Fri Oct 23 06:49:38 1998 me,,, (wk@tobold)
|
||||
|
||||
* keyedit.c (keyedit_menu): Comments are now allowed
|
||||
|
||||
* trustdb.c: Rewrote large parts.
|
||||
|
||||
|
||||
Thu Oct 22 15:56:45 1998 Michael Roth (mroth@nessie.de)
|
||||
|
||||
* encode.c: (encode_simple): Only the plain filename without
|
||||
a given directory is stored in generated packets.
|
||||
(encode_crypt): Ditto.
|
||||
|
||||
* sign.c: (sign_file) Ditto.
|
||||
|
||||
|
||||
Thu Oct 22 10:53:41 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* trustdb.c (update_trust_record): Add new optional arg.
|
||||
|
||||
* import.c (import_keys): Add statistics output
|
||||
* trustdb.c (update_trustdb): Ditto.
|
||||
(insert_trustdb): Ditto.
|
||||
|
||||
* tdbio.c (tdbio_begin_transaction): New.
|
||||
(tdbio_end_transaction): New.
|
||||
(tdbio_cancel_transaction): New.
|
||||
|
||||
* g10.c (main): New option --quit.
|
||||
|
||||
* trustdb.c (check_hint_sig): No tests for user-id w/o sig.
|
||||
This caused an assert while checking the sigs.
|
||||
|
||||
* trustdb.c (upd_sig_record): Splitted into several functions.
|
||||
|
||||
* import.c (import_keys): New arg "fast".
|
||||
* g10.c (main): New command --fast-import.
|
||||
|
||||
Wed Oct 21 18:19:36 1998 Michael Roth <mroth@nessie.de>
|
||||
|
||||
* ringedit.c (add_keyblock_resource): Directory is now created.
|
||||
|
@ -1,7 +1,7 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl
|
||||
EXTRA_DIST = OPTIONS pubring.asc
|
||||
EXTRA_DIST = OPTIONS pubring.asc options.skel
|
||||
OMIT_DEPENDENCIES = zlib.h zconf.h
|
||||
LDFLAGS = @LDFLAGS@ @DYNLINK_LDFLAGS@
|
||||
needed_libs = ../cipher/libcipher.a ../mpi/libmpi.a ../util/libutil.a
|
||||
@ -87,3 +87,9 @@ g10maint.o: $(srcdir)/g10.c
|
||||
$(PROGRAMS): $(needed_libs)
|
||||
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) $(pkgdatadir)
|
||||
$(INSTALL_DATA) $(srcdir)/options.skel $(pkgdatadir)/options.skel
|
||||
|
||||
|
||||
|
||||
|
@ -140,10 +140,11 @@ encode_simple( const char *filename, int mode )
|
||||
|
||||
/* setup the inner packet */
|
||||
if( filename || opt.set_filename ) {
|
||||
const char *s = opt.set_filename ? opt.set_filename : filename;
|
||||
char *s = make_basename( opt.set_filename ? opt.set_filename : filename );
|
||||
pt = m_alloc( sizeof *pt + strlen(s) - 1 );
|
||||
pt->namelen = strlen(s);
|
||||
memcpy(pt->name, s, pt->namelen );
|
||||
m_free(s);
|
||||
}
|
||||
else { /* no filename */
|
||||
pt = m_alloc( sizeof *pt - 1 );
|
||||
@ -253,10 +254,11 @@ encode_crypt( const char *filename, STRLIST remusr )
|
||||
|
||||
/* setup the inner packet */
|
||||
if( filename || opt.set_filename ) {
|
||||
const char *s = opt.set_filename ? opt.set_filename : filename;
|
||||
char *s = make_basename( opt.set_filename ? opt.set_filename : filename );
|
||||
pt = m_alloc( sizeof *pt + strlen(s) - 1 );
|
||||
pt->namelen = strlen(s);
|
||||
memcpy(pt->name, s, pt->namelen );
|
||||
m_free(s);
|
||||
}
|
||||
else { /* no filename */
|
||||
pt = m_alloc( sizeof *pt - 1 );
|
||||
|
11
g10/g10.c
11
g10/g10.c
@ -57,6 +57,7 @@ enum cmd_and_opt_values { aNull = 0,
|
||||
oKOption = 'k',
|
||||
oDryRun = 'n',
|
||||
oOutput = 'o',
|
||||
oQuiet = 'q',
|
||||
oRemote = 'r',
|
||||
aSign = 's',
|
||||
oTextmode = 't',
|
||||
@ -76,6 +77,7 @@ enum cmd_and_opt_values { aNull = 0,
|
||||
aKMode,
|
||||
aKModeC,
|
||||
aImport,
|
||||
aFastImport,
|
||||
aVerify,
|
||||
aListKeys,
|
||||
aListSigs,
|
||||
@ -174,6 +176,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ aExport, "export" , 256, N_("export keys") },
|
||||
{ aExportSecret, "export-secret-keys" , 256, "@" },
|
||||
{ aImport, "import", 256 , N_("import/merge keys")},
|
||||
{ aFastImport, "fast-import", 256 , "@"},
|
||||
{ aListPackets, "list-packets",256,N_("list only the sequence of packets")},
|
||||
#ifdef IS_G10MAINT
|
||||
{ aExportOwnerTrust,
|
||||
@ -206,6 +209,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
#endif
|
||||
{ oOutput, "output", 2, N_("use as output file")},
|
||||
{ oVerbose, "verbose", 0, N_("verbose") },
|
||||
{ oQuiet, "quiet", 0, N_("be somewhat more quiet") },
|
||||
{ oForceV3Sigs, "force-v3-sigs", 0, N_("force v3 signatures") },
|
||||
/* { oDryRun, "dry-run", 0, N_("do not make any changes") }, */
|
||||
{ oBatch, "batch", 0, N_("batch mode: never ask")},
|
||||
@ -614,6 +618,7 @@ main( int argc, char **argv )
|
||||
case aCheckKeys: set_cmd( &cmd, aCheckKeys); break;
|
||||
case aListPackets: set_cmd( &cmd, aListPackets); break;
|
||||
case aImport: set_cmd( &cmd, aImport); break;
|
||||
case aFastImport: set_cmd( &cmd, aFastImport); break;
|
||||
case aExport: set_cmd( &cmd, aExport); break;
|
||||
case aListKeys: set_cmd( &cmd, aListKeys); break;
|
||||
case aListSigs: set_cmd( &cmd, aListSigs); break;
|
||||
@ -657,6 +662,7 @@ main( int argc, char **argv )
|
||||
|
||||
case oArmor: opt.armor = 1; opt.no_armor=0; break;
|
||||
case oOutput: opt.outfile = pargs.r.ret_str; break;
|
||||
case oQuiet: opt.quiet = 1; break;
|
||||
case oVerbose: g10_opt_verbose++;
|
||||
opt.verbose++; opt.list_sigs=1; break;
|
||||
case oKOption: set_cmd( &cmd, aKMode ); break;
|
||||
@ -1022,14 +1028,15 @@ main( int argc, char **argv )
|
||||
break;
|
||||
#endif
|
||||
|
||||
case aFastImport:
|
||||
case aImport:
|
||||
if( !argc ) {
|
||||
rc = import_keys( NULL );
|
||||
rc = import_keys( NULL, (cmd == aFastImport) );
|
||||
if( rc )
|
||||
log_error("import failed: %s\n", g10_errstr(rc) );
|
||||
}
|
||||
for( ; argc; argc--, argv++ ) {
|
||||
rc = import_keys( *argv );
|
||||
rc = import_keys( *argv, (cmd == aFastImport) );
|
||||
if( rc )
|
||||
log_error("import from '%s' failed: %s\n",
|
||||
*argv, g10_errstr(rc) );
|
||||
|
135
g10/import.c
135
g10/import.c
@ -36,9 +36,24 @@
|
||||
#include "i18n.h"
|
||||
|
||||
|
||||
static struct {
|
||||
ulong no_user_id;
|
||||
ulong imported;
|
||||
ulong imported_rsa;
|
||||
ulong n_uids;
|
||||
ulong n_sigs;
|
||||
ulong n_subk;
|
||||
ulong unchanged;
|
||||
ulong n_revoc;
|
||||
ulong secret_read;
|
||||
ulong secret_imported;
|
||||
ulong secret_dups;
|
||||
} stats;
|
||||
|
||||
|
||||
static int read_block( IOBUF a, compress_filter_context_t *cfx,
|
||||
PACKET **pending_pkt, KBNODE *ret_root );
|
||||
static int import_one( const char *fname, KBNODE keyblock );
|
||||
static int import_one( const char *fname, KBNODE keyblock, int fast );
|
||||
static int import_secret_one( const char *fname, KBNODE keyblock );
|
||||
static int import_revoke_cert( const char *fname, KBNODE node );
|
||||
static int chk_self_sigs( const char *fname, KBNODE keyblock,
|
||||
@ -59,7 +74,7 @@ static int merge_sigs( KBNODE dst, KBNODE src, int *n_sigs,
|
||||
* least one userid. Only user ids which are self signed will be imported.
|
||||
* Other signatures are not checked.
|
||||
*
|
||||
* Actually this functtion does a merge. It works like this:
|
||||
* Actually this function does a merge. It works like this:
|
||||
*
|
||||
* - get the keyblock
|
||||
* - check self-signatures and remove all userids and their signatures
|
||||
@ -85,7 +100,7 @@ static int merge_sigs( KBNODE dst, KBNODE src, int *n_sigs,
|
||||
*
|
||||
*/
|
||||
int
|
||||
import_keys( const char *fname )
|
||||
import_keys( const char *fname, int fast )
|
||||
{
|
||||
armor_filter_context_t afx;
|
||||
compress_filter_context_t cfx;
|
||||
@ -93,11 +108,15 @@ import_keys( const char *fname )
|
||||
IOBUF inp = NULL;
|
||||
KBNODE keyblock;
|
||||
int rc = 0;
|
||||
ulong count=0;
|
||||
|
||||
memset( &afx, 0, sizeof afx);
|
||||
memset( &cfx, 0, sizeof cfx);
|
||||
afx.only_keyblocks = 1;
|
||||
|
||||
/* fixme: don't use static variables */
|
||||
memset( &stats, 0, sizeof( stats ) );
|
||||
|
||||
/* open file */
|
||||
inp = iobuf_open(fname);
|
||||
if( !fname )
|
||||
@ -112,7 +131,7 @@ import_keys( const char *fname )
|
||||
|
||||
while( !(rc = read_block( inp, &cfx, &pending_pkt, &keyblock) )) {
|
||||
if( keyblock->pkt->pkttype == PKT_PUBLIC_KEY )
|
||||
rc = import_one( fname, keyblock );
|
||||
rc = import_one( fname, keyblock, fast );
|
||||
else if( keyblock->pkt->pkttype == PKT_SECRET_KEY )
|
||||
rc = import_secret_one( fname, keyblock );
|
||||
else if( keyblock->pkt->pkttype == PKT_SIGNATURE
|
||||
@ -125,12 +144,41 @@ import_keys( const char *fname )
|
||||
release_kbnode(keyblock);
|
||||
if( rc )
|
||||
break;
|
||||
if( !(++count % 100) )
|
||||
log_info(_("%lu keys so far processed\n"), count );
|
||||
}
|
||||
if( rc == -1 )
|
||||
rc = 0;
|
||||
else if( rc && rc != G10ERR_INV_KEYRING )
|
||||
log_error_f( fname, _("read error: %s\n"), g10_errstr(rc));
|
||||
|
||||
log_info(_("Total number processed: %lu\n"), count );
|
||||
if( stats.no_user_id )
|
||||
log_info(_(" w/o user IDs: %lu\n"), stats.no_user_id );
|
||||
if( stats.imported || stats.imported_rsa ) {
|
||||
log_info(_(" imported: %lu"), stats.imported );
|
||||
if( stats.imported_rsa )
|
||||
fprintf(stderr, " (RSA: %lu)", stats.imported_rsa );
|
||||
putc('\n', stderr);
|
||||
}
|
||||
if( stats.unchanged )
|
||||
log_info(_(" unchanged: %lu\n"), stats.unchanged );
|
||||
if( stats.n_uids )
|
||||
log_info(_(" new user IDs: %lu\n"), stats.n_uids );
|
||||
if( stats.n_subk )
|
||||
log_info(_(" new subkeys: %lu\n"), stats.n_subk );
|
||||
if( stats.n_sigs )
|
||||
log_info(_(" new signatures: %lu\n"), stats.n_sigs );
|
||||
if( stats.n_revoc )
|
||||
log_info(_(" new key revocations: %lu\n"), stats.n_revoc );
|
||||
if( stats.secret_read )
|
||||
log_info(_(" secret keys read: %lu\n"), stats.secret_read );
|
||||
if( stats.secret_imported )
|
||||
log_info(_(" secret keys imported: %lu\n"), stats.secret_imported );
|
||||
if( stats.secret_dups )
|
||||
log_info(_(" secret keys unchanged: %lu\n"), stats.secret_dups );
|
||||
|
||||
|
||||
iobuf_close(inp);
|
||||
return rc;
|
||||
}
|
||||
@ -238,7 +286,7 @@ read_block( IOBUF a, compress_filter_context_t *cfx,
|
||||
* which called g10.
|
||||
*/
|
||||
static int
|
||||
import_one( const char *fname, KBNODE keyblock )
|
||||
import_one( const char *fname, KBNODE keyblock, int fast )
|
||||
{
|
||||
PKT_public_key *pk;
|
||||
PKT_public_key *pk_orig;
|
||||
@ -280,9 +328,12 @@ import_one( const char *fname, KBNODE keyblock )
|
||||
return rc== -1? 0:rc;
|
||||
|
||||
if( !delete_inv_parts( fname, keyblock, keyid ) ) {
|
||||
log_info_f( fname, _("key %08lX: no valid user ids\n"),
|
||||
(ulong)keyid[1]);
|
||||
log_info(_("this may be caused by a missing self-signature\n"));
|
||||
if( !opt.quiet ) {
|
||||
log_info_f( fname, _("key %08lX: no valid user ids\n"),
|
||||
(ulong)keyid[1]);
|
||||
log_info(_("this may be caused by a missing self-signature\n"));
|
||||
}
|
||||
stats.no_user_id++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -311,7 +362,12 @@ import_one( const char *fname, KBNODE keyblock )
|
||||
_("can't write to keyring: %s\n"), g10_errstr(rc) );
|
||||
unlock_keyblock( &kbpos );
|
||||
/* we are ready */
|
||||
log_info_f( fname, _("key %08lX: public key imported\n"), (ulong)keyid[1]);
|
||||
if( !opt.quiet )
|
||||
log_info_f( fname, _("key %08lX: public key imported\n"),
|
||||
(ulong)keyid[1]);
|
||||
stats.imported++;
|
||||
if( is_RSA( pk->pubkey_algo ) )
|
||||
stats.imported_rsa++;
|
||||
new_key = 1;
|
||||
}
|
||||
else { /* merge */
|
||||
@ -366,29 +422,39 @@ import_one( const char *fname, KBNODE keyblock )
|
||||
_("can't write keyblock: %s\n"), g10_errstr(rc) );
|
||||
unlock_keyblock( &kbpos );
|
||||
/* we are ready */
|
||||
if( n_uids == 1 )
|
||||
log_info_f(fname, _("key %08lX: 1 new user-id\n"),
|
||||
(ulong)keyid[1]);
|
||||
else if( n_uids )
|
||||
log_info_f(fname, _("key %08lX: %d new user-ids\n"),
|
||||
(ulong)keyid[1], n_uids );
|
||||
if( n_sigs == 1 )
|
||||
log_info_f(fname, _("key %08lX: 1 new signature\n"),
|
||||
(ulong)keyid[1]);
|
||||
else if( n_sigs )
|
||||
log_info_f(fname, _("key %08lX: %d new signatures\n"),
|
||||
(ulong)keyid[1], n_sigs );
|
||||
if( n_subk == 1 )
|
||||
log_info_f(fname, _("key %08lX: 1 new subkey\n"),
|
||||
(ulong)keyid[1]);
|
||||
else if( n_subk )
|
||||
log_info_f(fname, _("key %08lX: %d new subkeys\n"),
|
||||
(ulong)keyid[1], n_subk );
|
||||
if( !opt.quiet ) {
|
||||
if( n_uids == 1 )
|
||||
log_info_f(fname, _("key %08lX: 1 new user-id\n"),
|
||||
(ulong)keyid[1]);
|
||||
else if( n_uids )
|
||||
log_info_f(fname, _("key %08lX: %d new user-ids\n"),
|
||||
(ulong)keyid[1], n_uids );
|
||||
if( n_sigs == 1 )
|
||||
log_info_f(fname, _("key %08lX: 1 new signature\n"),
|
||||
(ulong)keyid[1]);
|
||||
else if( n_sigs )
|
||||
log_info_f(fname, _("key %08lX: %d new signatures\n"),
|
||||
(ulong)keyid[1], n_sigs );
|
||||
if( n_subk == 1 )
|
||||
log_info_f(fname, _("key %08lX: 1 new subkey\n"),
|
||||
(ulong)keyid[1]);
|
||||
else if( n_subk )
|
||||
log_info_f(fname, _("key %08lX: %d new subkeys\n"),
|
||||
(ulong)keyid[1], n_subk );
|
||||
}
|
||||
|
||||
stats.n_uids +=n_uids;
|
||||
stats.n_sigs +=n_sigs;
|
||||
stats.n_subk +=n_subk;
|
||||
}
|
||||
else {
|
||||
if( !opt.quiet )
|
||||
log_info_f(fname, _("key %08lX: not changed\n"),
|
||||
(ulong)keyid[1] );
|
||||
stats.unchanged++;
|
||||
}
|
||||
else
|
||||
log_info_f(fname, _("key %08lX: not changed\n"), (ulong)keyid[1] );
|
||||
}
|
||||
if( !rc ) {
|
||||
if( !rc && !fast ) {
|
||||
rc = query_trust_record( new_key? pk : pk_orig );
|
||||
if( rc && rc != -1 )
|
||||
log_error("trustdb error: %s\n", g10_errstr(rc) );
|
||||
@ -399,7 +465,7 @@ import_one( const char *fname, KBNODE keyblock )
|
||||
(ulong)keyid[1], g10_errstr(rc) );
|
||||
}
|
||||
else if( mod_key )
|
||||
rc = update_trust_record( keyblock_orig );
|
||||
rc = update_trust_record( keyblock_orig, NULL );
|
||||
else
|
||||
rc = clear_trust_checked_flag( new_key? pk : pk_orig );
|
||||
}
|
||||
@ -442,6 +508,7 @@ import_secret_one( const char *fname, KBNODE keyblock )
|
||||
uidnode->pkt->pkt.user_id->len, 0 );
|
||||
putc('\n', stderr);
|
||||
}
|
||||
stats.secret_read++;
|
||||
if( !uidnode ) {
|
||||
log_error_f(fname, _("key %08lX: no user id\n"), (ulong)keyid[1]);
|
||||
return 0;
|
||||
@ -468,10 +535,12 @@ import_secret_one( const char *fname, KBNODE keyblock )
|
||||
unlock_keyblock( &kbpos );
|
||||
/* we are ready */
|
||||
log_info_f(fname, _("key %08lX: secret key imported\n"), (ulong)keyid[1]);
|
||||
stats.secret_imported++;
|
||||
}
|
||||
else if( !rc ) { /* we can't merge secret keys */
|
||||
log_error_f(fname, _("key %08lX: already in secret keyring\n"),
|
||||
(ulong)keyid[1]);
|
||||
stats.secret_dups++;
|
||||
}
|
||||
else
|
||||
log_error_f(fname, _("key %08lX: secret key not found: %s\n"),
|
||||
@ -569,8 +638,10 @@ import_revoke_cert( const char *fname, KBNODE node )
|
||||
_("can't write keyblock: %s\n"), g10_errstr(rc) );
|
||||
unlock_keyblock( &kbpos );
|
||||
/* we are ready */
|
||||
log_info_f(fname, _("key %08lX: revocation certificate imported\n"),
|
||||
if( !opt.quiet )
|
||||
log_info_f(fname, _("key %08lX: revocation certificate imported\n"),
|
||||
(ulong)keyid[1]);
|
||||
stats.n_revoc++;
|
||||
|
||||
leave:
|
||||
release_kbnode( keyblock );
|
||||
|
@ -571,10 +571,12 @@ keyedit_menu( const char *username, STRLIST locusr )
|
||||
tty_printf("\n");
|
||||
redisplay = 0;
|
||||
}
|
||||
m_free(answer);
|
||||
answer = cpr_get(N_("keyedit.cmd"), _("Command> "));
|
||||
cpr_kill_prompt();
|
||||
trim_spaces(answer);
|
||||
do {
|
||||
m_free(answer);
|
||||
answer = cpr_get(N_("keyedit.cmd"), _("Command> "));
|
||||
cpr_kill_prompt();
|
||||
trim_spaces(answer);
|
||||
} while( *answer == '#' );
|
||||
|
||||
arg_number = 0;
|
||||
if( !*answer )
|
||||
@ -645,7 +647,7 @@ keyedit_menu( const char *username, STRLIST locusr )
|
||||
}
|
||||
else
|
||||
tty_printf(_("Key not changed so no update needed.\n"));
|
||||
rc = update_trust_record( keyblock );
|
||||
rc = update_trust_record( keyblock, NULL );
|
||||
if( rc )
|
||||
log_error(_("update of trust db failed: %s\n"),
|
||||
g10_errstr(rc) );
|
||||
@ -703,7 +705,7 @@ keyedit_menu( const char *username, STRLIST locusr )
|
||||
sec_modified = modified = 1;
|
||||
/* must update the trustdb already here, so that preferences
|
||||
* get listed correctly */
|
||||
rc = update_trust_record( keyblock );
|
||||
rc = update_trust_record( keyblock, NULL );
|
||||
if( rc ) {
|
||||
log_error(_("update of trust db failed: %s\n"),
|
||||
g10_errstr(rc) );
|
||||
|
@ -88,6 +88,7 @@ int generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock );
|
||||
int overwrite_filep( const char *fname );
|
||||
int open_outfile( const char *iname, int mode, IOBUF *a );
|
||||
IOBUF open_sigfile( const char *iname );
|
||||
void copy_options_file( const char *destdir );
|
||||
|
||||
/*-- seskey.c --*/
|
||||
void make_session_key( DEK *dek );
|
||||
@ -100,7 +101,7 @@ KBNODE make_comment_node( const char *s );
|
||||
KBNODE make_mpi_comment_node( const char *s, MPI a );
|
||||
|
||||
/*-- import.c --*/
|
||||
int import_keys( const char *filename );
|
||||
int import_keys( const char *filename, int fast );
|
||||
/*-- export.c --*/
|
||||
int export_pubkeys( STRLIST users );
|
||||
int export_seckeys( STRLIST users );
|
||||
|
@ -180,11 +180,12 @@ proc_pubkey_enc( CTX c, PACKET *pkt )
|
||||
if( is_ELGAMAL(enc->pubkey_algo)
|
||||
|| enc->pubkey_algo == PUBKEY_ALGO_DSA
|
||||
|| is_RSA(enc->pubkey_algo) ) {
|
||||
m_free(c->dek ); /* paranoid: delete a pending DEK */
|
||||
c->dek = m_alloc_secure( sizeof *c->dek );
|
||||
if( (result = get_session_key( enc, c->dek )) ) {
|
||||
/* error: delete the DEK */
|
||||
m_free(c->dek); c->dek = NULL;
|
||||
if ( !c->dek ) {
|
||||
c->dek = m_alloc_secure( sizeof *c->dek );
|
||||
if( (result = get_session_key( enc, c->dek )) ) {
|
||||
/* error: delete the DEK */
|
||||
m_free(c->dek); c->dek = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -716,13 +717,6 @@ do_proc_packets( CTX c, IOBUF a )
|
||||
c->iobuf = a;
|
||||
init_packet(pkt);
|
||||
while( (rc=parse_packet(a, pkt)) != -1 ) {
|
||||
/* cleanup if we have an illegal data structure */
|
||||
if( c->dek && pkt->pkttype != PKT_ENCRYPTED ) {
|
||||
/* FIXME: do we need to ave it in case we have no secret
|
||||
* key for one of the next reciepents- we should check it
|
||||
* here. */
|
||||
m_free(c->dek); c->dek = NULL; /* burn it */
|
||||
}
|
||||
|
||||
if( rc ) {
|
||||
free_packet(pkt);
|
||||
|
@ -78,11 +78,11 @@ open_outfile( const char *iname, int mode, IOBUF *a )
|
||||
*a = NULL;
|
||||
if( (!iname || (*iname=='-' && !iname[1])) && !opt.outfile ) {
|
||||
if( !(*a = iobuf_create(NULL)) ) {
|
||||
log_error("can't open [stdout]: %s\n", strerror(errno) );
|
||||
log_error(_("%s: can't open: %s\n"), "[stdout]", strerror(errno) );
|
||||
rc = G10ERR_CREATE_FILE;
|
||||
}
|
||||
else if( opt.verbose )
|
||||
log_info("writing to stdout\n");
|
||||
log_info(_("writing to stdout\n"));
|
||||
}
|
||||
else {
|
||||
char *buf=NULL;
|
||||
@ -98,11 +98,11 @@ open_outfile( const char *iname, int mode, IOBUF *a )
|
||||
}
|
||||
if( overwrite_filep( name ) ) {
|
||||
if( !(*a = iobuf_create( name )) ) {
|
||||
log_error("can't create %s: %s\n", name, strerror(errno) );
|
||||
log_error(_("%s: can't create: %s\n"), name, strerror(errno) );
|
||||
rc = G10ERR_CREATE_FILE;
|
||||
}
|
||||
else if( opt.verbose )
|
||||
log_info("writing to '%s'\n", name );
|
||||
log_info(_("writing to '%s'\n"), name );
|
||||
}
|
||||
else
|
||||
rc = G10ERR_FILE_EXISTS;
|
||||
@ -131,10 +131,54 @@ open_sigfile( const char *iname )
|
||||
buf[len-4] = 0 ;
|
||||
a = iobuf_open( buf );
|
||||
if( opt.verbose )
|
||||
log_info("assuming signed data in '%s'\n", buf );
|
||||
log_info(_("assuming signed data in '%s'\n"), buf );
|
||||
m_free(buf);
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Copy the option file skeleton to the given directory.
|
||||
*/
|
||||
void
|
||||
copy_options_file( const char *destdir )
|
||||
{
|
||||
const char *datadir = GNUPG_DATADIR;
|
||||
char *fname;
|
||||
FILE *src, *dst;
|
||||
int linefeeds=0;
|
||||
int c;
|
||||
|
||||
fname = m_alloc( strlen(datadir) + strlen(destdir) + 15 );
|
||||
strcpy(stpcpy(fname, datadir), "/options.skel" );
|
||||
src = fopen( fname, "r" );
|
||||
if( !src ) {
|
||||
log_error(_("%s: can't open: %s\n"), fname, strerror(errno) );
|
||||
m_free(fname);
|
||||
return;
|
||||
}
|
||||
strcpy(stpcpy(fname, destdir), "/options" );
|
||||
dst = fopen( fname, "w" );
|
||||
if( !dst ) {
|
||||
log_error(_("%s: can't create: %s\n"), fname, strerror(errno) );
|
||||
fclose( src );
|
||||
m_free(fname);
|
||||
return;
|
||||
}
|
||||
|
||||
while( (c=getc(src)) != EOF ) {
|
||||
if( linefeeds < 3 ) {
|
||||
if( c == '\n' )
|
||||
linefeeds++;
|
||||
}
|
||||
else
|
||||
putc( c, dst );
|
||||
}
|
||||
fclose( dst );
|
||||
fclose( src );
|
||||
log_info(_("%s: new options file created\n"), fname );
|
||||
m_free(fname);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
struct {
|
||||
int verbose;
|
||||
int quiet;
|
||||
unsigned debug;
|
||||
int armor;
|
||||
int compress;
|
||||
|
37
g10/options.skel
Normal file
37
g10/options.skel
Normal file
@ -0,0 +1,37 @@
|
||||
These first three lines are not copied to the options file in
|
||||
the users home directory.
|
||||
$Id$
|
||||
# Options for GnuPG
|
||||
#
|
||||
# Unless you you specify which option file to use (with the
|
||||
# commandline option "--options filename"), GnuPG uses the
|
||||
# file ~/.gnupg/options by default.
|
||||
#
|
||||
# An option file can contain all long options which are
|
||||
# available in GnuPG. If the first non white space character of
|
||||
# a line is a '#', this line is ignored. Empty lines are also
|
||||
# ignored.
|
||||
#
|
||||
# See the man page for a list of options.
|
||||
|
||||
# Uncomment the next line to get rid of the copyright notice
|
||||
#no-greeting
|
||||
|
||||
# If you have more than 1 secret key in your keyring, you may want
|
||||
# to uncomment the following option and set your preffered keyid
|
||||
|
||||
# default-key 621CC013
|
||||
|
||||
# The next option is enabled because this one is needed for interoperation
|
||||
# with PGP 5 users. To enable full OpenPGP compliance you have to remove
|
||||
# this option.
|
||||
|
||||
force-v3-sigs
|
||||
|
||||
# Default is to use the newer compress algo 2, but PGP 5 does not
|
||||
# like this, so we use the old one
|
||||
# Hmm: Do we really need this ... preferences should decide which compress
|
||||
# algo to use.
|
||||
|
||||
compress-algo 1
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "keydb.h"
|
||||
#include "host2net.h"
|
||||
#include "options.h"
|
||||
#include "main.h"
|
||||
#include "i18n.h"
|
||||
|
||||
|
||||
@ -153,7 +154,7 @@ add_keyblock_resource( const char *url, int force, int secret )
|
||||
{
|
||||
static int any_secret, any_public;
|
||||
const char *resname = url;
|
||||
IOBUF iobuf;
|
||||
IOBUF iobuf = NULL;
|
||||
int i;
|
||||
char *filename = NULL;
|
||||
int rc = 0;
|
||||
@ -217,6 +218,8 @@ add_keyblock_resource( const char *url, int force, int secret )
|
||||
else
|
||||
rt = rt_RING;
|
||||
}
|
||||
else /* maybe empty: assume ring */
|
||||
rt = rt_RING;
|
||||
fclose( fp );
|
||||
}
|
||||
else /* no file yet: create ring */
|
||||
@ -258,6 +261,7 @@ add_keyblock_resource( const char *url, int force, int secret )
|
||||
}
|
||||
else
|
||||
log_info( _("%s: directory created\n"), filename );
|
||||
copy_options_file( filename );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -513,6 +517,7 @@ locate_keyblock_by_fpr( KBPOS *kbpos, const byte *fpr, int fprlen, int secret )
|
||||
rc = do_gdbm_locate( rentry->dbf, kbpos, fpr, fprlen );
|
||||
break;
|
||||
default:
|
||||
rc = G10ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -521,7 +526,7 @@ locate_keyblock_by_fpr( KBPOS *kbpos, const byte *fpr, int fprlen, int secret )
|
||||
kbpos->fp = NULL;
|
||||
return 0;
|
||||
}
|
||||
else if( rc != -1 ) {
|
||||
else if( rc != -1 && rc != G10ERR_UNSUPPORTED ) {
|
||||
log_error("error searching resource %d: %s\n",
|
||||
i, g10_errstr(rc));
|
||||
last_rc = rc;
|
||||
@ -551,6 +556,7 @@ locate_keyblock_by_keyid( KBPOS *kbpos, u32 *keyid, int shortkid, int secret )
|
||||
rc = do_gdbm_locate_by_keyid( rentry->dbf, kbpos, keyid );
|
||||
break;
|
||||
default:
|
||||
rc = G10ERR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -559,7 +565,7 @@ locate_keyblock_by_keyid( KBPOS *kbpos, u32 *keyid, int shortkid, int secret )
|
||||
kbpos->fp = NULL;
|
||||
return 0;
|
||||
}
|
||||
else if( rc != -1 ) {
|
||||
else if( rc != -1 && rc != G10ERR_UNSUPPORTED ) {
|
||||
log_error("error searching resource %d: %s\n",
|
||||
i, g10_errstr(rc));
|
||||
last_rc = rc;
|
||||
@ -719,7 +725,10 @@ enum_keyblocks( int mode, KBPOS *kbpos, KBNODE *ret_root )
|
||||
break;
|
||||
case rt_GDBM:
|
||||
break;
|
||||
default: BUG();
|
||||
default:
|
||||
log_error("OOPS in close enum_keyblocks - ignored\n");
|
||||
return rc;
|
||||
break;
|
||||
}
|
||||
/* release pending packet */
|
||||
free_packet( kbpos->pkt );
|
||||
@ -778,7 +787,8 @@ delete_keyblock( KBPOS *kbpos )
|
||||
break;
|
||||
#ifdef HAVE_LIBGDBM
|
||||
case rt_GDBM:
|
||||
/* FIXME!!!! */
|
||||
log_debug("deleting gdbm keyblock is not yet implemented\n");
|
||||
rc = 0;
|
||||
break;
|
||||
#endif
|
||||
default: BUG();
|
||||
|
@ -253,7 +253,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
||||
int skcount=0;
|
||||
/* loop over the secret certificates and build headers
|
||||
* The specs now say that the data should be bracket by
|
||||
* the onepass-sig and signature-packet; so we muts build it
|
||||
* the onepass-sig and signature-packet; so we must build it
|
||||
* here in reverse order */
|
||||
for( sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next )
|
||||
skcount++;
|
||||
@ -320,10 +320,11 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
||||
}
|
||||
else {
|
||||
if( fname || opt.set_filename ) {
|
||||
const char *s = opt.set_filename ? opt.set_filename : fname;
|
||||
char *s = make_basename( opt.set_filename ? opt.set_filename : fname );
|
||||
pt = m_alloc( sizeof *pt + strlen(s) - 1 );
|
||||
pt->namelen = strlen(s);
|
||||
memcpy(pt->name, s, pt->namelen );
|
||||
m_free(s);
|
||||
}
|
||||
else { /* no filename */
|
||||
pt = m_alloc( sizeof *pt - 1 );
|
||||
|
108
g10/tdbio.c
108
g10/tdbio.c
@ -56,9 +56,11 @@ struct cache_ctrl_struct {
|
||||
char data[TRUST_RECORD_LEN];
|
||||
};
|
||||
|
||||
#define MAX_CACHE_ENTRIES 200
|
||||
#define MAX_CACHE_ENTRIES_SOFT 200 /* may be increased due while in a */
|
||||
#define MAX_CACHE_ENTRIES_HARD 1000 /* transaction to this one */
|
||||
static CACHE_CTRL cache_list;
|
||||
static int cache_entries;
|
||||
static int cache_is_dirty;
|
||||
|
||||
/* a type used to pass infomation to cmp_krec_fpr */
|
||||
struct cmp_krec_fpr_struct {
|
||||
@ -76,6 +78,7 @@ struct cmp_sdir_struct {
|
||||
|
||||
static char *db_name;
|
||||
static int db_fd = -1;
|
||||
static int in_transaction;
|
||||
|
||||
|
||||
static void open_db(void);
|
||||
@ -143,8 +146,10 @@ put_record_into_cache( ulong recno, const char *data )
|
||||
else if( r->recno == recno ) {
|
||||
if( !r->flags.dirty ) {
|
||||
/* Hmmm: should we use a a copy and compare? */
|
||||
if( memcmp(r->data, data, TRUST_RECORD_LEN ) )
|
||||
if( memcmp(r->data, data, TRUST_RECORD_LEN ) ) {
|
||||
r->flags.dirty = 1;
|
||||
cache_is_dirty = 1;
|
||||
}
|
||||
}
|
||||
memcpy( r->data, data, TRUST_RECORD_LEN );
|
||||
return 0;
|
||||
@ -163,11 +168,12 @@ put_record_into_cache( ulong recno, const char *data )
|
||||
r->recno = recno;
|
||||
memcpy( r->data, data, TRUST_RECORD_LEN );
|
||||
r->flags.dirty = 1;
|
||||
cache_is_dirty = 1;
|
||||
cache_entries++;
|
||||
return 0;
|
||||
}
|
||||
/* see whether we reached the limit */
|
||||
if( cache_entries < MAX_CACHE_ENTRIES ) { /* no */
|
||||
if( cache_entries < MAX_CACHE_ENTRIES_SOFT ) { /* no */
|
||||
r = m_alloc( sizeof *r );
|
||||
r->flags.used = 1;
|
||||
r->recno = recno;
|
||||
@ -175,6 +181,7 @@ put_record_into_cache( ulong recno, const char *data )
|
||||
r->flags.dirty = 1;
|
||||
r->next = cache_list;
|
||||
cache_list = r;
|
||||
cache_is_dirty = 1;
|
||||
cache_entries++;
|
||||
return 0;
|
||||
}
|
||||
@ -199,10 +206,31 @@ put_record_into_cache( ulong recno, const char *data )
|
||||
r->recno = recno;
|
||||
memcpy( r->data, data, TRUST_RECORD_LEN );
|
||||
r->flags.dirty = 1;
|
||||
cache_is_dirty = 1;
|
||||
cache_entries++;
|
||||
return 0;
|
||||
}
|
||||
/* no clean entries: have to flush some dirty entries */
|
||||
if( in_transaction ) {
|
||||
/* but we can't do this while in a transaction
|
||||
* we increase the cache size instead */
|
||||
if( cache_entries < MAX_CACHE_ENTRIES_HARD ) { /* no */
|
||||
if( !(cache_entries % 100) )
|
||||
log_info("increasing tdbio cache size\n");
|
||||
r = m_alloc( sizeof *r );
|
||||
r->flags.used = 1;
|
||||
r->recno = recno;
|
||||
memcpy( r->data, data, TRUST_RECORD_LEN );
|
||||
r->flags.dirty = 1;
|
||||
r->next = cache_list;
|
||||
cache_list = r;
|
||||
cache_is_dirty = 1;
|
||||
cache_entries++;
|
||||
return 0;
|
||||
}
|
||||
log_info("hard cache size limit reached\n");
|
||||
return G10ERR_RESOURCE_LIMIT;
|
||||
}
|
||||
if( dirty_count ) {
|
||||
int n = dirty_count / 5; /* discard some dirty entries */
|
||||
if( !n )
|
||||
@ -226,6 +254,7 @@ put_record_into_cache( ulong recno, const char *data )
|
||||
r->recno = recno;
|
||||
memcpy( r->data, data, TRUST_RECORD_LEN );
|
||||
r->flags.dirty = 1;
|
||||
cache_is_dirty = 1;
|
||||
cache_entries++;
|
||||
return 0;
|
||||
}
|
||||
@ -233,16 +262,27 @@ put_record_into_cache( ulong recno, const char *data )
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
tdbio_is_dirty()
|
||||
{
|
||||
return cache_is_dirty;
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Sync the cache to disk
|
||||
* Flush the cache. This cannot be used while in a transaction.
|
||||
*/
|
||||
|
||||
int
|
||||
tdbio_sync()
|
||||
{
|
||||
CACHE_CTRL r;
|
||||
|
||||
if( in_transaction )
|
||||
log_bug("tdbio: syncing while in transaction\n");
|
||||
|
||||
if( !cache_is_dirty )
|
||||
return 0;
|
||||
|
||||
for( r = cache_list; r; r = r->next ) {
|
||||
if( r->flags.used && r->flags.dirty ) {
|
||||
int rc = write_cache_item( r );
|
||||
@ -250,6 +290,63 @@ tdbio_sync()
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
cache_is_dirty = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************
|
||||
* Simple transactions system:
|
||||
* Everything between begin_transaction and end/cancel_transaction
|
||||
* is not immediatly written but at the time of end_transaction.
|
||||
*
|
||||
*/
|
||||
int
|
||||
tdbio_begin_transaction()
|
||||
{
|
||||
int rc;
|
||||
|
||||
if( in_transaction )
|
||||
log_bug("tdbio: nested transactions\n");
|
||||
/* flush everything out */
|
||||
rc = tdbio_sync();
|
||||
if( rc )
|
||||
return rc;
|
||||
in_transaction = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
tdbio_end_transaction()
|
||||
{
|
||||
if( !in_transaction )
|
||||
log_bug("tdbio: no active transaction\n");
|
||||
in_transaction = 0;
|
||||
return tdbio_sync();
|
||||
}
|
||||
|
||||
int
|
||||
tdbio_cancel_transaction()
|
||||
{
|
||||
CACHE_CTRL r;
|
||||
|
||||
if( !in_transaction )
|
||||
log_bug("tdbio: no active transaction\n");
|
||||
|
||||
/* remove all dirty marked entries, so that the original ones
|
||||
* are read back the next time */
|
||||
if( cache_is_dirty ) {
|
||||
for( r = cache_list; r; r = r->next ) {
|
||||
if( r->flags.used && r->flags.dirty ) {
|
||||
r->flags.used = 0;
|
||||
cache_entries--;
|
||||
}
|
||||
}
|
||||
cache_is_dirty = 0;
|
||||
}
|
||||
|
||||
in_transaction = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -293,6 +390,7 @@ tdbio_set_dbname( const char *new_dbname, int create )
|
||||
fname, strerror(errno) );
|
||||
else
|
||||
log_info( _("%s: directory created\n"), fname );
|
||||
copy_options_file( fname );
|
||||
}
|
||||
else
|
||||
log_fatal( _("%s: directory does not exist!\n"), fname );
|
||||
|
@ -168,7 +168,11 @@ const char *tdbio_get_dbname(void);
|
||||
void tdbio_dump_record( TRUSTREC *rec, FILE *fp );
|
||||
int tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected );
|
||||
int tdbio_write_record( TRUSTREC *rec );
|
||||
int tdbio_is_dirty(void);
|
||||
int tdbio_sync(void);
|
||||
int tdbio_begin_transaction(void);
|
||||
int tdbio_end_transaction(void);
|
||||
int tdbio_cancel_transaction(void);
|
||||
int tdbio_delete_record( ulong recnum );
|
||||
ulong tdbio_new_recnum(void);
|
||||
int tdbio_search_dir_bypk( PKT_public_key *pk, TRUSTREC *rec );
|
||||
|
1389
g10/trustdb.c
1389
g10/trustdb.c
File diff suppressed because it is too large
Load Diff
@ -60,7 +60,7 @@ ulong lid_from_keyblock( KBNODE keyblock );
|
||||
int query_trust_record( PKT_public_key *pk );
|
||||
int clear_trust_checked_flag( PKT_public_key *pk );
|
||||
int insert_trust_record( PKT_public_key *pk );
|
||||
int update_trust_record( KBNODE keyblock );
|
||||
int update_trust_record( KBNODE keyblock, int *modified );
|
||||
int update_ownertrust( ulong lid, unsigned new_trust );
|
||||
|
||||
/*-- pkclist.c --*/
|
||||
|
@ -125,6 +125,8 @@ const char *strusage( int level );
|
||||
|
||||
|
||||
/*-- fileutil.c --*/
|
||||
char * make_basename(const char *filepath);
|
||||
char * make_dirname(const char *filepath);
|
||||
char *make_filename( const char *first_part, ... );
|
||||
int compare_filenames( const char *a, const char *b );
|
||||
const char *print_fname_stdin( const char *s );
|
||||
|
@ -1,3 +1,8 @@
|
||||
Thu Oct 22 16:25:49 1998 Michael Roth (mroth@nessie.de)
|
||||
|
||||
* fileutil.c (make_basename): New.
|
||||
(make_dirname): New.
|
||||
|
||||
Wed Oct 21 12:20:29 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* util.c (iobuf_flush): autoincreasing of a temp. iobuf
|
||||
|
@ -30,6 +30,61 @@
|
||||
#include "ttyio.h"
|
||||
|
||||
|
||||
/***************
|
||||
* Extract from a given path the filename component.
|
||||
*
|
||||
*/
|
||||
char *
|
||||
make_basename(const char *filepath)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if ( !(p=strrchr(filepath, '/')) )
|
||||
#ifdef __MINGW32__
|
||||
if ( !(p=strrchr(filepath, '\\')) )
|
||||
if ( !(p=strrchr(filepath, ':')) )
|
||||
#endif
|
||||
{
|
||||
return m_strdup(filepath);
|
||||
}
|
||||
|
||||
return m_strdup(p+1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************
|
||||
* Extract from a given filename the path prepended to it.
|
||||
* If their isn't a path prepended to the filename, a dot
|
||||
* is returned ('.').
|
||||
*
|
||||
*/
|
||||
char *
|
||||
make_dirname(const char *filepath)
|
||||
{
|
||||
char *dirname;
|
||||
int dirname_length;
|
||||
char *p;
|
||||
|
||||
if ( !(p=strrchr(filepath, '/')) )
|
||||
#ifdef __MINGW32__
|
||||
if ( !(p=strrchr(filepath, '\\')) )
|
||||
if ( !(p=strrchr(filepath, ':')) )
|
||||
#endif
|
||||
{
|
||||
return m_strdup(".");
|
||||
}
|
||||
|
||||
dirname_length = p-filepath;
|
||||
dirname = m_alloc(dirname_length+1);
|
||||
strncpy(dirname, filepath, dirname_length);
|
||||
dirname[dirname_length] = 0;
|
||||
|
||||
return dirname;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************
|
||||
* Construct a filename from the NULL terminated list of parts.
|
||||
* Tilde expansion is done here.
|
||||
|
Loading…
x
Reference in New Issue
Block a user