Made private key regeneration after it has expired optional.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 10 Jun 2002 07:37:59 +0000 (07:37 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 10 Jun 2002 07:37:59 +0000 (07:37 +0000)
User can choose what whether to regenerate.

CHANGES
apps/irssi/src/silc/core/clientutil.c
configure.in.pre
includes/silcincludes.h

diff --git a/CHANGES b/CHANGES
index 6cf77e464cd71c308364130702e3d58f80259538..9cd0e8d6b837f221b774367483ccf9a48f4a9ac2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+Mon Jun 10 09:28:21 CEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * Made the private key generation after expiration optional.
+         If not created after expiration the old key will re-expire
+         at a later time (and thus key pair is not necessary to
+         change).  Affected file irssi/src/silc/core/clientutil.c.
+
 Sun Jun  9 18:58:25 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
 
        * The length arguments in bind() and connect() were wrong
index 59fb2bac7d82346128528c37fc7095b87c837e67..f9699738eeee47aa421b31106fbd9ac007aa3982 100644 (file)
@@ -408,6 +408,12 @@ int silc_client_check_silc_dir()
     }
   }
 
+  /* Check the owner of the public key */
+  if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { 
+    fprintf(stderr, "You don't seem to own your public key!?\n");
+    return FALSE;
+  }
+  
   if ((stat(file_private_key, &st)) == -1) {
     /* If file doesn't exist */
     if (errno == ENOENT) {
@@ -422,12 +428,6 @@ int silc_client_check_silc_dir()
     }
   }
     
-  /* Check the owner of the public key */
-  if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { 
-    fprintf(stderr, "You don't seem to own your public key!?\n");
-    return FALSE;
-  }
-  
   /* Check the owner of the private key */
   if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { 
     fprintf(stderr, "You don't seem to own your private key!?\n");
@@ -453,18 +453,34 @@ int silc_client_check_silc_dir()
     
   /* 86400 is seconds in a day. */
   if (curtime >= (86400 * SILC_CLIENT_KEY_EXPIRES)) {
+    char *answer;
+
     fprintf(stdout, 
-           "--------------------------------------------------\n"
+           "----------------------------------------------------\n"
            "Your private key has expired and needs to be\n" 
-           "recreated.  This will be done automatically now.\n"
-           "Your new key will expire in %d days from today.\n"
-           "--------------------------------------------------\n",
-           SILC_CLIENT_KEY_EXPIRES);
-
-    silc_client_create_key_pair(SILC_CLIENT_DEF_PKCS, 
-                               SILC_CLIENT_DEF_PKCS_LEN,
-                               file_public_key, 
-                               file_private_key, identifier, NULL, NULL);
+           "recreated.  Would you like to create a new key pair\n"
+           "now?  If you answer Yes, the new key will expire in\n"
+           "%d days from today.  If you answer No, the old key\n"
+           "will expire again in %d days from today.\n"
+           "----------------------------------------------------\n",
+           SILC_CLIENT_KEY_EXPIRES, SILC_CLIENT_KEY_EXPIRES);
+
+    answer = silc_get_input("Would you like to create a new key pair "
+                           "([y]/n)?: ", FALSE);
+    if (!answer || answer[0] == 'Y' || answer[0] == 'y') {
+      silc_client_create_key_pair(SILC_CLIENT_DEF_PKCS, 
+                                 SILC_CLIENT_DEF_PKCS_LEN,
+                                 file_public_key, 
+                                 file_private_key, identifier, NULL, NULL);
+    } else {
+#ifdef HAVE_UTIME
+      struct utimbuf utim;
+      utim.actime = time(NULL);
+      utim.modtime = time(NULL);
+      utime(file_private_key, &utim);
+#endif
+    }
+    silc_free(answer);
   }
   
   if (identifier)
index faca8c738841da48a4433879297333de64f50d8b..a118a41a95fed480ab5d7f5d7f341273e97a25f1 100644 (file)
@@ -70,7 +70,7 @@ AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
-AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
+AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h utime.h)
 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h)
 
 # Data type checking
@@ -293,7 +293,7 @@ AC_CHECK_FUNCS(fcntl setsockopt)
 AC_CHECK_FUNCS(getopt_long time)
 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid setgroups initgroups)
-AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
+AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove utime)
 AC_CHECK_FUNCS(pthread_create)
 
 # SIM support checking
index e18c6ca18e345ae989fe33a64c3e8546e0ada24f..8fe2ccfe2b03e32a1777ced8e481dfc9caa140aa 100644 (file)
@@ -197,6 +197,10 @@ extern "C" {
 #include <termios.h>
 #endif
 
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
+
 #endif                         /* !SILC_WIN32 */
 
 #ifndef HAVE_GETOPT_LONG