summaryrefslogtreecommitdiffstats
path: root/apps/ca.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2003-04-04 17:10:35 +0200
committerRichard Levitte <levitte@openssl.org>2003-04-04 17:10:35 +0200
commit4c771796d59f895c58e88bb7161fc0d711d05604 (patch)
tree9098508fbee315448d5ab02e4fbb64e303bb72a9 /apps/ca.c
parentAdd documentation on the added functionality in 'openssl ca'. (diff)
downloadopenssl-4c771796d59f895c58e88bb7161fc0d711d05604.tar.xz
openssl-4c771796d59f895c58e88bb7161fc0d711d05604.zip
Convert save_serial() to work like save_index(), and add a
rotate_serial() that works like rotate_index().
Diffstat (limited to 'apps/ca.c')
-rw-r--r--apps/ca.c45
1 files changed, 2 insertions, 43 deletions
diff --git a/apps/ca.c b/apps/ca.c
index 34b1507aee..618d88b2d0 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1243,21 +1243,7 @@ bad:
BIO_printf(bio_err,"Write out database with %d new entries\n",sk_X509_num(cert_sk));
- if(strlen(serialfile) > BSIZE-5 || strlen(dbfile) > BSIZE-5)
- {
- BIO_printf(bio_err,"file name too long\n");
- goto err;
- }
-
- strcpy(buf[0],serialfile);
-
-#ifdef OPENSSL_SYS_VMS
- strcat(buf[0],"-new");
-#else
- strcat(buf[0],".new");
-#endif
-
- if (!save_serial(buf[0],serial,NULL)) goto err;
+ if (!save_serial(serialfile,"new",serial,NULL)) goto err;
if (!save_index(dbfile, "new", db)) goto err;
}
@@ -1317,34 +1303,7 @@ bad:
if (sk_X509_num(cert_sk))
{
/* Rename the database and the serial file */
- strncpy(buf[2],serialfile,BSIZE-4);
- buf[2][BSIZE-4]='\0';
-
-#ifdef OPENSSL_SYS_VMS
- strcat(buf[2],"-old");
-#else
- strcat(buf[2],".old");
-#endif
-
- BIO_free(in);
- BIO_free_all(out);
- in=NULL;
- out=NULL;
- if (rename(serialfile,buf[2]) < 0)
- {
- BIO_printf(bio_err,"unable to rename %s to %s\n",
- serialfile,buf[2]);
- perror("reason");
- goto err;
- }
- if (rename(buf[0],serialfile) < 0)
- {
- BIO_printf(bio_err,"unable to rename %s to %s\n",
- buf[0],serialfile);
- perror("reason");
- rename(buf[2],serialfile);
- goto err;
- }
+ if (!rotate_serial(serialfile,"new","old")) goto err;
if (!rotate_index(dbfile,"new","old")) goto err;