From 39410044c50eb9d7e472aaa201debd37ef2bc188 Mon Sep 17 00:00:00 2001 From: Damien Stuart Date: Fri, 7 Dec 2012 11:38:31 -0500 Subject: [PATCH] Set new libfko version. Client: allow dot (.) in validate_username, and display version and exit without creating an fko context. --- client/fwknop.c | 22 +++++++++------------- lib/Makefile.am | 2 +- lib/fko_user.c | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/client/fwknop.c b/client/fwknop.c index 9a18dddd..6fee5ce2 100644 --- a/client/fwknop.c +++ b/client/fwknop.c @@ -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) diff --git a/lib/Makefile.am b/lib/Makefile.am index 5e03c4b3..3426af81 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/fko_user.c b/lib/fko_user.c index c2d6a8b7..a98135eb 100644 --- a/lib/fko_user.c +++ b/lib/fko_user.c @@ -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;