From 659dc314e38b231d0603d63453163774d3063b64 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Fri, 4 Dec 2015 23:50:22 +1000 Subject: [PATCH] * src/testutil.c : add scanning user & pass from input line --- src/testutil.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/testutil.c b/src/testutil.c index 1628901..f77eabc 100644 --- a/src/testutil.c +++ b/src/testutil.c @@ -6,7 +6,9 @@ #include "ldapauth.h" int main(int argc, char *argv[]) { - char buf[1024]; + char buf[128]; + char username[32]; + char password[32]; oal_config_t *config; if (argc < 2) { @@ -27,7 +29,16 @@ int main(int argc, char *argv[]) { } while (fgets(buf, sizeof(buf), stdin) != NULL) { - ; + if (sscanf(buf, "%31s %31s", username, password) != 2) { + fputs("fail: expected ' ' line\n", stdout); + continue; + } + if (oal_check_cred(config, username, password) == 0) { + fputs("ok\n", stdout); + } else { + fprintf(stderr, "fail: %s\n", config->error); + free(config->error); + } } free(config);