Set new libfko version. Client: allow dot (.) in validate_username, and display version and exit without creating an fko context.

This commit is contained in:
Damien Stuart 2012-12-07 11:38:31 -05:00
parent 88c66f647f
commit 39410044c5
3 changed files with 12 additions and 16 deletions

View File

@ -57,7 +57,7 @@ main(int argc, char **argv)
{
fko_ctx_t ctx, ctx2;
int res;
char *spa_data, *version;
char *spa_data;
char access_buf[MAX_LINE_LEN];
fko_cli_options_t options;
@ -75,6 +75,14 @@ main(int argc, char **argv)
else if (!options.no_save_args)
save_args(argc, argv);
/* Display version info and exit.
*/
if (options.version) {
fprintf(stdout, "fwknop client %s, FKO protocol version %s\n",
MY_VERSION, FKO_PROTOCOL_VERSION);
return(EXIT_SUCCESS);
}
/* Intialize the context
*/
res = fko_new(&ctx);
@ -84,18 +92,6 @@ main(int argc, char **argv)
return(EXIT_FAILURE);
}
/* Display version info and exit.
*/
if (options.version) {
fko_get_version(ctx, &version);
fprintf(stdout, "fwknop client %s, FKO protocol version %s\n",
MY_VERSION, version);
fko_destroy(ctx);
return(EXIT_SUCCESS);
}
/* Set client timeout
*/
if(options.fw_timeout >= 0)

View File

@ -12,7 +12,7 @@ libfko_source_files = \
libfko_la_SOURCES = $(libfko_source_files)
libfko_la_LIBADD = libfko_util.a
libfko_la_LDFLAGS = -version-info 0:4:0 $(GPGME_LIBS) -export-symbols-regex '^fko_'
libfko_la_LDFLAGS = -version-info 1:0:0 $(GPGME_LIBS) -export-symbols-regex '^fko_'
noinst_LIBRARIES = libfko_util.a
libfko_util_source_files = strlcpy.c strlcat.c fko_util.h

View File

@ -133,14 +133,14 @@ validate_username(const char *username)
if(username == NULL || strnlen(username, MAX_SPA_USERNAME_SIZE) == 0)
return(FKO_ERROR_INVALID_DATA);
/* Make sure it is just alpha-numeric chars, dashes, and underscores
/* Make sure it is just alpha-numeric chars, dashes, dots, and underscores
*/
if(isalnum(username[0]) == 0)
return(FKO_ERROR_INVALID_DATA);
for (i=1; i < (int)strnlen(username, MAX_SPA_USERNAME_SIZE); i++)
if((isalnum(username[i]) == 0)
&& username[i] != '-' && username[i] != '_')
&& username[i] != '-' && username[i] != '_' && username[i] != '.')
return(FKO_ERROR_INVALID_DATA);
return FKO_SUCCESS;