--- ca.c.orig 2005-09-30 18:47:15.000000000 +0200 +++ ca.c 2006-07-13 18:03:51.000000000 +0200 @@ -187,6 +187,7 @@ #endif " -status serial - Shows certificate status given the serial number\n", " -updatedb - Updates db for expired certificates\n", +" -directupdate - Update the index.txt directly\n", NULL }; @@ -320,6 +321,7 @@ #endif char *tofree=NULL; DB_ATTR db_attr; + int directupdate=0; #ifdef EFENCE EF_PROTECT_FREE=1; @@ -537,6 +539,11 @@ engine= *(++argv); } #endif + else if (strcmp(*argv,"-directupdate") == 0) + { + directupdate=1; + } + else { bad: @@ -876,6 +883,9 @@ lookup_fail(section,ENV_DATABASE); goto err; } + + if(!directupdate) + { db = load_index(dbfile, &db_attr); if (db == NULL) goto err; @@ -940,6 +950,7 @@ } if (!index_index(db)) goto err; + } /*****************************************************************/ /* Update the db file for expired certificates */ @@ -1261,8 +1272,10 @@ BIO_printf(bio_err,"Write out database with %d new entries\n",sk_X509_num(cert_sk)); if (!save_serial(serialfile,"new",serial,NULL)) goto err; - - if (!save_index(dbfile, "new", db)) goto err; + if (!directupdate) + { + if (!save_index(dbfile, "new", db)) goto err; + } } if (verbose) @@ -1911,8 +1924,9 @@ BIO_printf(bio_err,"Memory allocation failure\n"); goto err; } - - if (db->attributes.unique_subject) +if (!directudates) +{ + if(db->attributes.unique_subject) { rrow=TXT_DB_get_by_index(db->db,DB_name,row); if (rrow != NULL) @@ -1963,6 +1977,7 @@ goto err; } + } /* We are now totally happy, lets make and sign the certificate */ if (verbose) BIO_printf(bio_err,"Everything appears to be ok, creating and signing the certificate\n"); @@ -2169,16 +2184,46 @@ } irow[DB_NUMBER]=NULL; - if (!TXT_DB_insert(db->db,irow)) - { - BIO_printf(bio_err,"failed to update database\n"); - BIO_printf(bio_err,"TXT_DB error number %ld\n",db->db->error); - goto err; - } + + if(directupdate) + { + char *dbfile=NULL; + + if ((dbfile=NCONF_get_string(conf,section,ENV_DATABASE)) == NULL) + { + lookup_fail(section,ENV_DATABASE); + goto err; + } + + FILE *Handle=fopen(dbfile,"a"); + if(Handle!=NULL) + { + fprintf(Handle,"%s\t%s\t\t%s\tunknown\t%s\n",irow[0],irow[1],irow[3],irow[5]); + fclose(Handle); + printf("Saved successfully!\n"); + } + else + { + printf("Error saving to database\n"); + } + //printf("%s\t%s\t%s\t%s\t%s\t%s\n",irow[0],irow[1],irow[2],irow[3],irow[5],irow[6]); + } + else + { + if (!TXT_DB_insert(db->db,irow)) + { + BIO_printf(bio_err,"failed to update database\n"); + BIO_printf(bio_err,"TXT_DB error number %ld\n",db->db->error); + goto err; + } + } ok=1; err: - for (i=0; i