]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
updated the parameters of srpcrypt program. Other minor changes in included programs.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 4 Jul 2002 10:04:31 +0000 (10:04 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 4 Jul 2002 10:04:31 +0000 (10:04 +0000)
src/README.srpcrypt
src/crypt-gaa.c
src/crypt-gaa.h
src/crypt.gaa
src/serv.c

index 76a8154cce331896b8b68ffc06d3771c1dbc624c..53e7d5c27e93d1d1c4740292fb7a23cd1ae59918 100644 (file)
@@ -11,19 +11,19 @@ verifiers, and 'tpasswd.conf' which holds generators and primes.
 
 How to use srpcrypt:
 
-Run: srpcrypt --create_conf /etc/tpasswd.conf
+Run: srpcrypt --create-conf /etc/tpasswd.conf
 
 * This will create tpasswd.conf which holds the g and n values for
 SRP protocol (generator and a large prime).
 
-Run: srpcrypt --passwd /etc/tpasswd --passwd_conf /etc/tpasswd.conf -u test
+Run: srpcrypt --passwd /etc/tpasswd --passwd-conf /etc/tpasswd.conf -u test
 
 * This will create /etc/tpasswd and will add user 'test' (you will also
 be prompted for a password). Verifiers are stored by default in the
 way libsrp expects (using a modified SHA()). However using this tool you 
-may also specify blowfish srpcrypt instead of SHA (see --crypt parameter).
+may also specify blowfish crypt instead of SHA (see --crypt parameter).
 
-Run: srpcrypt --passwd /etc/tpasswd --passwd_conf /etc/tpasswd.conf --verify -u test
+Run: srpcrypt --passwd /etc/tpasswd --passwd-conf /etc/tpasswd.conf --verify -u test
 
 * You will be promted for a password, and if this password matches the one
 in /etc/tpasswd you will get an ok.
index 78e3a419e65675a587f092017ea1c27ee9cb4fe5..a6486638bb373dffb017117629f77fcaaf5f1b59 100644 (file)
@@ -1,5 +1,9 @@
+/* File generated by GAA 1.6.2
+ */
+#define GAA_NO_WIN32
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 #ifndef GAA_NO_WIN32
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
@@ -7,6 +11,16 @@
 #endif
 #endif
 
+void* gaa_malloc( size_t size) {
+void* ret;
+       ret = malloc(size);
+       if (ret==NULL) {
+               fprintf(stderr, "gaa: could not allocate memory");
+               exit(1);
+       }
+       return ret;
+}
+
 void __gaa_helpsingle(char short_name, char *name, 
        char *arg_desc, char *opt_help)
 {
@@ -100,18 +114,18 @@ void __gaa_helpsingle(char short_name, char *name,
      printf("\n");
 }
 
-void gaa_help()
+void gaa_help(void)
 {
-       printf("Srpcrypt help\nUsage : srpcrypt [options]""\n");
-       __gaa_helpsingle('u', "username", """username"" ", "specify username.");
-       __gaa_helpsingle('p', "passwd", """FILE"" ", "specify a password file.");
-       __gaa_helpsingle('i', "index", """INDEX"" ", "specify the index of the parameters in tpasswd.conf to use.");
-       __gaa_helpsingle('c', "crypt", """CRYPT"" ", "specify crypt algorithm (bcrypt/srpsha).");
-       __gaa_helpsingle('s', "salt", """SALT"" ", "specify salt/cost size for crypt algorithm.");
+       printf("Srpcrypt help\nUsage : srpcrypt [options]\n");
+       __gaa_helpsingle('u', "username", "username ", "specify username.");
+       __gaa_helpsingle('p', "passwd", "FILE ", "specify a password file.");
+       __gaa_helpsingle('i', "index", "INDEX ", "specify the index of the parameters in tpasswd.conf to use.");
+       __gaa_helpsingle('c', "crypt", "CRYPT ", "specify crypt algorithm (bcrypt/srpsha).");
+       __gaa_helpsingle('s', "salt", "SALT ", "specify salt/cost size for crypt algorithm.");
        __gaa_helpsingle(0, "verify", "", "just verify password.");
-       __gaa_helpsingle(0, "passwd_conf", """FILE"" ", "specify a password conf file.");
-       __gaa_helpsingle(0, "create_conf", """FILE"" ", "Generate a tpasswd.conf file.");
-       __gaa_helpsingle(0, "bits", """BITS"" ", "specify the number of bits for prime numbers (used only when create_conf option is specified).");
+       __gaa_helpsingle(0, "passwd-conf", "FILE ", "specify a password conf file.");
+       __gaa_helpsingle(0, "create-conf", "FILE ", "Generate a tpasswd.conf file.");
+       __gaa_helpsingle(0, "bits", "BITS ", "specify the number of bits for prime numbers (used only when create-conf option is specified).");
        __gaa_helpsingle('h', "help", "", "shows this help text");
 
 #line 100 "gaa.skel"
@@ -156,7 +170,7 @@ extern "C"
 
     int gaa(int argc, char *argv[], gaainfo *gaaval);
 
-    void gaa_help();
+    void gaa_help(void);
     
     int gaa_file(char *name, gaainfo *gaaval);
     
@@ -171,10 +185,10 @@ extern "C"
 
 /* C declarations */
 
-#define GAAERROR    \
+#define GAAERROR(x)    \
 {                   \
 gaa_error = 1;      \
-return;        \
+return x;        \
 }
 
 char *gaa_current_option;
@@ -277,12 +291,14 @@ num = 0; \
 if(!OK) \
 { \
 num = 0;                                                            \
-target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));  \
+target = NULL;                                                      \
+if ( gaa_last_non_option - gaa_index > 0)                           \
+  target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
 for(; gaa_index < gaa_last_non_option; gaa_index++)                 \
 {                                                                   \
     if(gaa_arg_used[gaa_index] == 0)                                \
     {                                                               \
-        GAA_FILL_2ARGS(target[num], func);                                \
+        GAA_FILL_2ARGS(target[num], func);                          \
         num++;                                                      \
     }                                                               \
 }                                                                   \
@@ -294,7 +310,9 @@ if(num == 0)                                                        \
 if(!OK) \
 { \
 num = 0;                                                            \
-target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));  \
+target = NULL;                                                      \
+if ( gaa_last_non_option - gaa_index > 0)                           \
+  target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
 for(; gaa_index < gaa_last_non_option; gaa_index++)                 \
 {                                                                   \
     if(gaa_arg_used[gaa_index] == 0)                                \
@@ -312,7 +330,7 @@ for(i = 0; i < strlen(str); i++)                                    \
     j = gaa_get_option_num(str + i, GAA_LETTER_OPTION);           \
     if(j == GAA_ERROR_NOMATCH)                                       \
     {                                                               \
-        printf("Error : invalid 'obligat' set\n");                  \
+        printf("Error: invalid 'obligat' set\n");                  \
         exit(-1);                                                   \
     }                                                               \
     if(opt_list[j] == 1)                                            \
@@ -334,7 +352,7 @@ for(i = 0; i < strlen(str); i++)                                    \
     j = gaa_get_option_num(str + i, GAA_LETTER_OPTION);           \
     if(j == GAA_ERROR_NOMATCH)                                      \
     {                                                               \
-        printf("Error : invalid 'obligat' set\n");                  \
+        printf("Error: invalid 'obligat' set\n");                  \
         exit(-1);                                                   \
     }                                                               \
     if(opt_list[j] == 1)                                            \
@@ -359,8 +377,8 @@ int gaa_getint(char *arg)
     char a;
     if(sscanf(arg, "%d%c", &tmp, &a) != 1)
     {
-        printf("Option %s : '%s' isn't an integer\n", gaa_current_option, arg);
-        GAAERROR;
+        printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg);
+        GAAERROR(-1);
     }
     return tmp;
 }
@@ -369,8 +387,8 @@ char gaa_getchar(char *arg)
 {
     if(strlen(arg) != 1)
     {
-        printf("Option %s : '%s' isn't an character\n", gaa_current_option, arg);
-        GAAERROR;
+        printf("Option %s: '%s' isn't an character\n", gaa_current_option, arg);
+        GAAERROR(-1);
     }
     return arg[0];
 }
@@ -385,8 +403,8 @@ float gaa_getfloat(char *arg)
     char a;
     if(sscanf(arg, "%f%c", &tmp, &a) != 1)
     {
-        printf("Option %s : '%s' isn't a float number\n", gaa_current_option, arg);
-        GAAERROR;
+        printf("Option %s: '%s' isn't a float number\n", gaa_current_option, arg);
+        GAAERROR(-1);
     }
     return tmp;
 }
@@ -487,8 +505,8 @@ int gaa_get_option_num(char *str, int status)
         case GAA_WORD_OPTION:
                        GAA_CHECKSTR("help", GAAOPTID_help);
                        GAA_CHECKSTR("bits", GAAOPTID_bits);
-                       GAA_CHECKSTR("create_conf", GAAOPTID_create_conf);
-                       GAA_CHECKSTR("passwd_conf", GAAOPTID_passwd_conf);
+                       GAA_CHECKSTR("create-conf", GAAOPTID_create_conf);
+                       GAA_CHECKSTR("passwd-conf", GAAOPTID_passwd_conf);
                        GAA_CHECKSTR("verify", GAAOPTID_verify);
                        GAA_CHECKSTR("salt", GAAOPTID_salt);
                        GAA_CHECKSTR("crypt", GAAOPTID_crypt);
@@ -645,7 +663,8 @@ int gaa(int argc, char **argv, gaainfo *gaaval)
     GAAargv = argv;
     GAAargc = argc;
 
-    opt_list = (char*) malloc(GAA_NB_OPTION + 1);
+    opt_list = (char*) gaa_malloc(GAA_NB_OPTION + 1);
+
     for(i = 0; i < GAA_NB_OPTION + 1; i++)
         opt_list[i] = 0;
     /* initialization */
@@ -660,7 +679,12 @@ int gaa(int argc, char **argv, gaainfo *gaaval)
     }
     inited = 1;
 #line 438 "gaa.skel"
-    gaa_arg_used = malloc(argc * sizeof(char));
+    gaa_arg_used = NULL;
+
+    if (argc > 0) {
+      gaa_arg_used = gaa_malloc(argc * sizeof(char));
+    }
+
     for(i = 1; i < argc; i++)
         gaa_arg_used[i] = 0;
     for(i = 1; i < argc; i++)
@@ -684,7 +708,7 @@ int gaa(int argc, char **argv, gaainfo *gaaval)
                 switch(gaa_try(tmp2, i+1, gaaval, opt_list))
                 {
                 case GAA_ERROR_NOTENOUGH_ARGS:
-                    printf("'%s' : not enough arguments\n",gaa_current_option);
+                    printf("'%s': not enough arguments\n",gaa_current_option);
                     return 0;
                 case GAA_ERROR_INVALID_ARG:
                     printf("Invalid arguments\n");
@@ -708,7 +732,7 @@ int gaa(int argc, char **argv, gaainfo *gaaval)
                     switch(gaa_try(tmp2, i+1, gaaval, opt_list))
                     {
                     case GAA_ERROR_NOTENOUGH_ARGS:
-                        printf("'%s' : not enough arguments\n",gaa_current_option);
+                        printf("'%s': not enough arguments\n",gaa_current_option);
                         return 0;
                     case GAA_ERROR_INVALID_ARG:
                         printf("Invalid arguments\n");
@@ -733,7 +757,7 @@ if(gaa_processing_file == 0)
     switch(gaa_try(GAA_REST, 1, gaaval, opt_list))
     {
     case GAA_ERROR_NOTENOUGH_ARGS:
-        printf("Rest : not enough arguments\n");
+        printf("Rest: not enough arguments\n");
         return 0;
     case GAA_ERROR_INVALID_ARG:
         printf("Invalid arguments\n");
@@ -772,8 +796,10 @@ int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
     char a;
     int i = 0, len = 0, newline = 0;
 
-    if(argc == 1)
+    if(argc == 1) {
         newline = 1;
+        len = 2;
+    }
     
     if(fscanf(file,"%c", &a) != 1) return 0;
 
@@ -795,8 +821,10 @@ int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
         len++;
         if(fscanf(file,"%c", &a) != 1) a = ' ';
     }
-    
-    tmp_str->str = malloc((len + 1) * sizeof(char));
+
+    len += 1;
+    tmp_str->str = gaa_malloc((len) * sizeof(char));
+
     if(newline == 1)
     {
         tmp_str->str[0] = '-';
@@ -819,11 +847,12 @@ int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
         tmp_str->str[i] = a;
         i++;
     }
-    while(a != ' ' && a != 9 && a != '\n');
+    while(a != ' ' && a != 9 && a != '\n' && i < len);
 
     tmp_str->str[i - 1] = 0;
 
     fseek(file,- 1, SEEK_CUR);
+/*    printf("%d\n", ftell(file)); */
     
     return -1;
 }
@@ -848,7 +877,8 @@ int gaa_file(char *name, gaainfo *gaaval)
     do
     {
         argc++;
-        *tmp_str = malloc(sizeof(gaa_str_node));
+        *tmp_str = gaa_malloc(sizeof(gaa_str_node));
+
         (*tmp_str)->str = NULL;
         (*tmp_str)->next = NULL;
 
@@ -860,7 +890,8 @@ int gaa_file(char *name, gaainfo *gaaval)
     if(rval == 1)
         return 0;
     
-    argv = malloc((1 + argc) * sizeof(char*));
+    argv = gaa_malloc((1 + argc) * sizeof(char*));
+
     tmp_str2 = first_str;
     argv[0] = "cfg";
     for(i = 1; i < argc; i++)
index 9ab2cd553871a2130232345113f488fa22585b39..13421f9d76c9bb82b1b98ddbc645efa73f819fe0 100644 (file)
@@ -37,7 +37,7 @@ extern "C"
 
     int gaa(int argc, char *argv[], gaainfo *gaaval);
 
-    void gaa_help();
+    void gaa_help(void);
     
     int gaa_file(char *name, gaainfo *gaaval);
     
index fc5b5e0dbd26effce5c90a52546f75e490dcc71d..4408a1d841e0066a8a8f8b307bdb53f7397be8cf 100644 (file)
@@ -19,13 +19,13 @@ option (s, salt) INT "SALT" { $salt = $1 } "specify salt/cost size for crypt alg
 option (verify) { $verify = 1 } "just verify password."
 
 #char *passwd_conf;
-option ( passwd_conf) STR "FILE" { $passwd_conf = $1 } "specify a password conf file."
+option ( passwd-conf) STR "FILE" { $passwd_conf = $1 } "specify a password conf file."
 
 #char *create_conf;
-option ( create_conf) STR "FILE" { $create_conf = $1 } "Generate a tpasswd.conf file."
+option ( create-conf) STR "FILE" { $create_conf = $1 } "Generate a tpasswd.conf file."
 
 #int bits;
-option (bits) INT "BITS" { $bits = $1 } "specify the number of bits for prime numbers (used only when create_conf option is specified)."
+option (bits) INT "BITS" { $bits = $1 } "specify the number of bits for prime numbers (used only when create-conf option is specified)."
 
 option (h, help) { gaa_help(); exit(0); } "shows this help text"
 
index 28997f404c6a6b952c0d564495f3ecaca2989b22..f2f39f632789ffae851b0aecaf749a777806f96d 100644 (file)
@@ -391,6 +391,7 @@ static void get_response(GNUTLS_STATE state, char *request, char **response, int
        *response = strdup( request);
        *response_length = strlen( *response);
     }
+    
     return;
 
   unimplemented:
@@ -428,6 +429,8 @@ int main(int argc, char **argv)
    char topbuf[512];
 //   int optval = 1;
    char name[256];
+   int accept_fd;
+   struct sockaddr_in client_address;
 
    signal(SIGPIPE, SIG_IGN);
    signal( SIGHUP, SIG_IGN);
@@ -586,8 +589,6 @@ int main(int argc, char **argv)
        if (FD_ISSET (h, &rd)) {
            unsigned int l;
            GNUTLS_STATE tstate;
-           int accept_fd;
-           struct sockaddr_in client_address;
 
            tstate = initialize_state ();
 
@@ -616,13 +617,12 @@ int main(int argc, char **argv)
                        ctt = ctime(&tt);
                        ctt[strlen(ctt)-1] = 0;
 
-//             printf ("- %s: connection from %s\n", ctt, inet_ntoa (client_address.sin_addr));
-
+/*
                        printf("- connection from %s, port %d\n",
                             inet_ntop(AF_INET, &client_address.sin_addr, topbuf,
                               sizeof(topbuf)), ntohs(client_address.sin_port));
+      */
 
-                       fflush(stdout);
                }
            }
        }
@@ -649,8 +649,13 @@ int main(int argc, char **argv)
                    } else if (r == 0) {
                        if ( gnutls_session_is_resumed( j->tstate)!=0 && quiet==0)
                          printf("*** This is a resumed session\n");
-//                     print_info(j->tstate);
 
+                       if (quiet == 0) {
+                             printf("- connection from %s, port %d\n",
+                                    inet_ntop(AF_INET, &client_address.sin_addr, topbuf,
+                                      sizeof(topbuf)), ntohs(client_address.sin_port));
+                             print_info( j->tstate);
+                       }
                        j->handshake_ok = 1;
                    }
                }
@@ -706,8 +711,12 @@ int main(int argc, char **argv)
                    } else if (r == 0) {
                        if ( gnutls_session_is_resumed( j->tstate)!=0 && quiet == 0)
                          printf("*** This is a resumed session\n");
-//                     print_info(j->tstate);
-
+                       if (quiet == 0) {
+                             printf("- connection from %s, port %d\n",
+                                    inet_ntop(AF_INET, &client_address.sin_addr, topbuf,
+                                      sizeof(topbuf)), ntohs(client_address.sin_port));
+                             print_info( j->tstate);
+                       }
                        j->handshake_ok = 1;
                    }
                }