1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

See ChangeLog: Tue Jun 29 21:44:25 CEST 1999 Werner Koch

This commit is contained in:
Werner Koch 1999-06-29 19:50:54 +00:00
parent 38c47646ea
commit 75ed03c960
29 changed files with 1025 additions and 1284 deletions

View file

@ -1,3 +1,20 @@
Tue Jun 29 21:44:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* trustdb.h (TRUST_FLAG_DISABLED): New.
* status.c (USE_CAPABILITIES): Capabilities support (Remi).
* tdbio.c : Added new fields to the DIR record.
(tdbio_write_record): Fixed the update of the hash tables.
(tdbio_delete_record): Drop the record from the hash tables.
(drop_from_hashtbl): New.
* status.c (cpr_get): Special online help mode.
* helptext.c ("keyedit.cmd"): Removed.
* keyedit.c (keyedit_menu): Use only help system.
(enable_disable_key): New bit doies not yet work.
Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>

View file

@ -146,10 +146,6 @@ static struct helptexts { const char *key; const char *help; } helptexts[] = {
},
{ N_("keyedit.cmd"),
"Please enter \"help\" to see the list of commands."
},
{ N_("keyedit.save.okay"),
"Answer \"yes\" or \"no\""
},

View file

@ -59,6 +59,7 @@ static int count_selected_uids( KBNODE keyblock );
static int count_selected_keys( KBNODE keyblock );
static int menu_revsig( KBNODE keyblock );
static int menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock );
static int enable_disable_key( KBNODE keyblock, int disable );
#define CONTROL_D ('D' - 'A' + 1)
@ -550,6 +551,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands )
cmdLSIGN, cmdREVSIG, cmdREVKEY, cmdDELSIG,
cmdDEBUG, cmdSAVE, cmdADDUID, cmdDELUID, cmdADDKEY, cmdDELKEY,
cmdTOGGLE, cmdSELKEY, cmdPASSWD, cmdTRUST, cmdPREF, cmdEXPIRE,
cmdENABLEKEY, cmdDISABLEKEY,
cmdNOP };
static struct { const char *name;
enum cmdids id;
@ -586,6 +588,8 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands )
{ N_("trust") , cmdTRUST , 0, N_("change the ownertrust") },
{ N_("revsig") , cmdREVSIG , 0, N_("revoke signatures") },
{ N_("revkey") , cmdREVKEY , 1, N_("revoke a secondary key") },
{ N_("disable") , cmdDISABLEKEY , 0, N_("disable a key") },
{ N_("enable") , cmdENABLEKEY , 0, N_("enable a key") },
{ NULL, cmdNONE } };
enum cmdids cmd;
@ -662,7 +666,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands )
have_commands = 0;
}
if( !have_commands ) {
answer = cpr_get("keyedit.cmd", _("Command> "));
answer = cpr_get("", _("Command> "));
cpr_kill_prompt();
}
trim_spaces(answer);
@ -842,12 +846,10 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands )
break;
case cmdADDKEY:
secmem_dump_stats();
if( generate_subkeypair( keyblock, sec_keyblock ) ) {
redisplay = 1;
sec_modified = modified = 1;
}
secmem_dump_stats();
break;
@ -934,6 +936,14 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands )
}
break;
case cmdENABLEKEY:
case cmdDISABLEKEY:
if( enable_disable_key( keyblock, cmd == cmdDISABLEKEY ) ) {
redisplay = 1;
modified = 1;
}
break;
default:
tty_printf("\n");
tty_printf(_("Invalid command (try \"help\")\n"));
@ -1859,3 +1869,15 @@ menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock )
}
static int
enable_disable_key( KBNODE keyblock, int disable )
{
int entire;
int changed = 0;
entire = !count_selected_keys( keyblock );
return changed;
}

View file

@ -25,6 +25,9 @@
#include <errno.h>
#include <unistd.h>
#ifdef USE_SHM_COPROCESSING
#ifdef USE_CAPABILITIES
#include <sys/capability.h>
#endif
#ifdef HAVE_SYS_IPC_H
#include <sys/ipc.h>
#endif
@ -165,6 +168,9 @@ init_shm_coprocessing ( ulong requested_shm_size, int lock_mem )
log_debug("mapped %uk shared memory at %p, id=%d\n",
(unsigned)shm_size/1024, shm_area, shm_id );
if( lock_mem ) {
#ifdef USE_CAPABILITIES
cap_set_proc( cap_from_text("cap_ipc_lock+ep") );
#endif
#ifdef IPC_HAVE_SHM_LOCK
if ( shmctl (shm_id, SHM_LOCK, 0) )
log_info("locking shared memory %d failed: %s\n",
@ -181,6 +187,9 @@ init_shm_coprocessing ( ulong requested_shm_size, int lock_mem )
#else
log_info("Locking shared memory %d failed: No way to do it\n", shm_id );
#endif
#ifdef USE_CAPABILITIES
cap_set_proc( cap_from_text("cap_ipc_lock+p") );
#endif
}
@ -279,7 +288,7 @@ cpr_get( const char *keyword, const char *prompt )
#endif
for(;;) {
p = tty_get( prompt );
if( *p == '?' && !p[1] ) {
if( *p=='?' && !p[1] && !(keyword && !*keyword)) {
m_free(p);
display_online_help( keyword );
}

View file

@ -69,8 +69,8 @@ struct cmp_krec_fpr_struct {
int fprlen;
};
/* a type used to pass infomation to cmp_sdir */
struct cmp_sdir_struct {
/* a type used to pass infomation to cmp_[s]dir */
struct cmp_xdir_struct {
int pubkey_algo;
u32 keyid[2];
};
@ -852,8 +852,9 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum )
return rc; /* ready */
}
else {
log_error( "hashtbl %lu points to an invalid record\n",
item);
log_error( "hashtbl %lu: %lu/%d points to an invalid record %lu\n",
table, hashrec, (msb % ITEMS_PER_HTBL_RECORD), item);
list_trustdb(NULL);
return G10ERR_TRUSTDB;
}
}
@ -862,6 +863,92 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum )
}
/****************
* Drop an entry from a hashtable
* table gives the start of the table, key and keylen is the key,
*/
static int
drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum )
{
TRUSTREC rec;
ulong hashrec, item;
int msb;
int level=0;
int rc, i;
hashrec = table;
next_level:
msb = key[level];
hashrec += msb / ITEMS_PER_HTBL_RECORD;
rc = tdbio_read_record( hashrec, &rec, RECTYPE_HTBL );
if( rc ) {
log_error( db_name, "drop_from_hashtable: read failed: %s\n",
g10_errstr(rc) );
return rc;
}
item = rec.r.htbl.item[msb % ITEMS_PER_HTBL_RECORD];
if( !item ) /* not found - forget about it */
return 0;
if( item == recnum ) { /* tables points direct to the record */
rec.r.htbl.item[msb % ITEMS_PER_HTBL_RECORD] = 0;
rc = tdbio_write_record( &rec );
if( rc )
log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n",
g10_errstr(rc) );
return rc;
}
rc = tdbio_read_record( item, &rec, 0 );
if( rc ) {
log_error( "drop_from_hashtable: read item failed: %s\n",
g10_errstr(rc) );
return rc;
}
if( rec.rectype == RECTYPE_HTBL ) {
hashrec = item;
level++;
if( level >= keylen ) {
log_error( "hashtable has invalid indirections.\n");
return G10ERR_TRUSTDB;
}
goto next_level;
}
if( rec.rectype == RECTYPE_HLST ) {
for(;;) {
for(i=0; i < ITEMS_PER_HLST_RECORD; i++ ) {
if( rec.r.hlst.rnum[i] == recnum ) {
rec.r.hlst.rnum[i] = 0; /* drop */
rc = tdbio_write_record( &rec );
if( rc )
log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n",
g10_errstr(rc) );
return rc;
}
}
if( rec.r.hlst.next ) {
rc = tdbio_read_record( rec.r.hlst.next,
&rec, RECTYPE_HLST);
if( rc ) {
log_error( "scan keyhashtbl read hlst failed: %s\n",
g10_errstr(rc) );
return rc;
}
}
else
return 0; /* key not in table */
}
}
log_error( "hashtbl %lu: %lu/%d points to wrong record %lu\n",
table, hashrec, (msb % ITEMS_PER_HTBL_RECORD), item);
return G10ERR_TRUSTDB;
}
/****************
* Lookup a record via the hashtable tablewith key/keylen and return the
@ -973,6 +1060,30 @@ update_sdirhashtbl( TRUSTREC *sr )
return upd_hashtable( get_sdirhashrec(), key, 8, sr->recnum );
}
/****************
* Drop the records from the key-hashtbl
*/
static int
drop_from_keyhashtbl( TRUSTREC *kr )
{
return drop_from_hashtable( get_keyhashrec(),
kr->r.key.fingerprint,
kr->r.key.fingerprint_len, kr->recnum );
}
/****************
* Drop record drom the shadow dir hashtbl
*/
static int
drop_from_sdirhashtbl( TRUSTREC *sr )
{
byte key[8];
u32tobuf( key , sr->r.sdir.keyid[0] );
u32tobuf( key+4 , sr->r.sdir.keyid[1] );
return drop_from_hashtable( get_sdirhashrec(), key, 8, sr->recnum );
}
@ -1009,6 +1120,8 @@ tdbio_dump_record( TRUSTREC *rec, FILE *fp )
if( rec->r.dir.valcheck )
fprintf( fp, ", v=%02x/%s", rec->r.dir.validity,
strtimestamp(rec->r.dir.valcheck) );
if( rec->r.dir.checkat )
fprintf( fp, ", a=%s", strtimestamp(rec->r.dir.checkat) );
if( rec->r.dir.dirflags & DIRF_CHECKED ) {
if( rec->r.dir.dirflags & DIRF_VALID )
fputs(", valid", fp );
@ -1071,7 +1184,8 @@ tdbio_dump_record( TRUSTREC *rec, FILE *fp )
fprintf(fp, " %lu:", rec->r.sig.sig[i].lid );
if( rec->r.sig.sig[i].flag & SIGF_CHECKED ) {
fprintf(fp,"%c%c%c",
(rec->r.sig.sig[i].flag & SIGF_VALID) ? 'V':'-',
(rec->r.sig.sig[i].flag & SIGF_VALID) ? 'V':
(rec->r.sig.sig[i].flag & SIGF_IGNORED) ? 'I':'-',
(rec->r.sig.sig[i].flag & SIGF_EXPIRED) ? 'E':'-',
(rec->r.sig.sig[i].flag & SIGF_REVOKED) ? 'R':'-');
}
@ -1196,6 +1310,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected )
rec->r.dir.dirflags = *p++;
rec->r.dir.validity = *p++;
rec->r.dir.valcheck = buftoulong(p); p += 4;
rec->r.dir.checkat = buftoulong(p); p += 4;
switch( rec->r.dir.validity ) {
case 0:
case TRUST_UNDEFINED:
@ -1346,6 +1461,7 @@ tdbio_write_record( TRUSTREC *rec )
*p++ = rec->r.dir.dirflags;
*p++ = rec->r.dir.validity;
ulongtobuf(p, rec->r.dir.valcheck); p += 4;
ulongtobuf(p, rec->r.dir.checkat); p += 4;
assert( rec->r.dir.lid == recnum );
break;
@ -1419,7 +1535,7 @@ tdbio_write_record( TRUSTREC *rec )
rc = put_record_into_cache( recnum, buf );
if( rc )
;
if( rec->rectype == RECTYPE_KEY )
else if( rec->rectype == RECTYPE_KEY )
rc = update_keyhashtbl( rec );
else if( rec->rectype == RECTYPE_SDIR )
rc = update_sdirhashtbl( rec );
@ -1433,6 +1549,19 @@ tdbio_delete_record( ulong recnum )
TRUSTREC vr, rec;
int rc;
/* Must read the record fist, so we can drop it from the hash tables */
rc = tdbio_read_record( recnum, &rec, 0 );
if( rc )
;
else if( rec.rectype == RECTYPE_KEY )
rc = drop_from_keyhashtbl( &rec );
else if( rec.rectype == RECTYPE_SDIR )
rc = drop_from_sdirhashtbl( &rec );
if( rc )
return rc;
/* now we can chnage it to a free record */
rc = tdbio_read_record( 0, &vr, RECTYPE_VER );
if( rc )
log_fatal( _("%s: error reading version record: %s\n"),
@ -1595,7 +1724,7 @@ tdbio_search_dir_byfpr( const byte *fingerprint, size_t fingerlen,
static int
cmp_sdir( void *dataptr, const TRUSTREC *rec )
{
const struct cmp_sdir_struct *d = dataptr;
const struct cmp_xdir_struct *d = dataptr;
return rec->rectype == RECTYPE_SDIR
&& ( !d->pubkey_algo || rec->r.sdir.pubkey_algo == d->pubkey_algo )
@ -1607,7 +1736,7 @@ cmp_sdir( void *dataptr, const TRUSTREC *rec )
int
tdbio_search_sdir( u32 *keyid, int pubkey_algo, TRUSTREC *rec )
{
struct cmp_sdir_struct cmpdata;
struct cmp_xdir_struct cmpdata;
int rc;
byte key[8];

View file

@ -66,6 +66,7 @@
#define SIGF_VALID 2 /* the signature is valid */
#define SIGF_EXPIRED 4 /* the key of this signature has expired */
#define SIGF_REVOKED 8 /* this signature has been revoked */
#define SIGF_IGNORED 64 /* this signature is ignored by the system */
#define SIGF_NOPUBKEY 128 /* there is no pubkey for this sig */
struct trust_record {
@ -97,8 +98,9 @@ struct trust_record {
ulong cacherec; /* the cache record */
byte ownertrust;
byte dirflags;
byte validity; /* calculated trustlevel over all uids */
ulong valcheck; /* timestamp of last validation check */
byte validity; /* calculated trustlevel over all uids */
ulong valcheck; /* timestamp of last validation check */
ulong checkat; /* Check key when this time has been reached*/
} dir;
struct { /* primary public key record */
ulong lid;
@ -187,6 +189,7 @@ ulong tdbio_new_recnum(void);
int tdbio_search_dir_bypk( PKT_public_key *pk, TRUSTREC *rec );
int tdbio_search_dir_byfpr( const byte *fingerprint, size_t fingerlen,
int pubkey_algo, TRUSTREC *rec );
int tdbio_search_dir( u32 *keyid, int pubkey_algo, TRUSTREC *rec );
int tdbio_search_sdir( u32 *keyid, int pubkey_algo, TRUSTREC *rec );
void tdbio_invalid(void);

File diff suppressed because it is too large Load diff

View file

@ -34,6 +34,7 @@
/* trust values not covered by the mask */
#define TRUST_FLAG_REVOKED 32 /* r: revoked */
#define TRUST_FLAG_SUB_REVOKED 64
#define TRUST_FLAG_DISABLED 128 /* d: key/uid disabled */
#define PREFTYPE_SYM 1