From 1098f92d35a6aa473e70a6f2e28908334fbaf716 Mon Sep 17 00:00:00 2001 From: Jan Willamowius <jan@willamowius.de> Date: ćšć, 18 4æ 2019 00:35:32 +0800 Subject: [PATCH] don't generate new key, if key already exists --- src/tools/bootstrap/bootstrap.cpp | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/src/tools/bootstrap/bootstrap.cpp b/src/tools/bootstrap/bootstrap.cpp index 6b22d59..41f2e43 100644 --- a/src/tools/bootstrap/bootstrap.cpp +++ b/src/tools/bootstrap/bootstrap.cpp @@ -3,6 +3,7 @@ #include <string> #include <stdlib.h> #include <iostream> +#include <sys/stat.h> using namespace std; namespace license { @@ -73,6 +74,12 @@ } } +bool file_exists (const std::string & name) +{ + struct stat buffer; + return (stat (name.c_str(), &buffer) == 0); +} + int main(int argc, char** argv) { if (argc != 3) { @@ -87,6 +94,11 @@ string private_fname = string(argv[1]); string public_fname(argv[2]); + if (file_exists(private_fname) || file_exists(public_fname)) { + printf("Key file exist, skipping key generation. Do 'make clean' to generate new keys."); + exit(0); + } + license::generatePk(private_fname, public_fname); return 0; } -- Gitblit v1.9.1