+/* 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)
#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)
{
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"
int gaa(int argc, char *argv[], gaainfo *gaaval);
- void gaa_help();
+ void gaa_help(void);
int gaa_file(char *name, gaainfo *gaaval);
/* C declarations */
-#define GAAERROR \
+#define GAAERROR(x) \
{ \
gaa_error = 1; \
-return; \
+return x; \
}
char *gaa_current_option;
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++; \
} \
} \
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) \
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) \
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) \
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;
}
{
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];
}
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;
}
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);
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 */
}
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++)
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");
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");
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");
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;
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] = '-';
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;
}
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;
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++)
*response = strdup( request);
*response_length = strlen( *response);
}
+
return;
unimplemented:
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);
if (FD_ISSET (h, &rd)) {
unsigned int l;
GNUTLS_STATE tstate;
- int accept_fd;
- struct sockaddr_in client_address;
tstate = initialize_state ();
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);
}
}
}
} 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;
}
}
} 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;
}
}