diff options
| author | David M. Syzdek <david@syzdek.net> | 2022-06-02 15:59:11 -0800 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2022-06-02 15:59:11 -0800 |
| commit | 4455a566098a8861a965f7369c370cc0b11fe004 (patch) | |
| tree | ac17e2b86adef3bbae3df1b9259da4d286864ea5 | |
| parent | 7534ef7d4eadea0307de07651b99b138b4777df9 (diff) | |
| download | tinytac-4455a566098a8861a965f7369c370cc0b11fe004.tar.gz tinytac-4455a566098a8861a965f7369c370cc0b11fe004.tar.bz2 tinytac-4455a566098a8861a965f7369c370cc0b11fe004.tar.xz tinytac-4455a566098a8861a965f7369c370cc0b11fe004.zip | |
tinytac: adding ability to specify TACACS+ key on cli
| -rw-r--r-- | src/ttu/tinytacutil.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ttu/tinytacutil.c b/src/ttu/tinytacutil.c index 2ff5a8e..d27679d 100644 --- a/src/ttu/tinytacutil.c +++ b/src/ttu/tinytacutil.c | |||
| @@ -396,9 +396,10 @@ ttu_cli_arguments( | |||
| 396 | int opt; | 396 | int opt; |
| 397 | int ival; | 397 | int ival; |
| 398 | int rc; | 398 | int rc; |
| 399 | void * ptr; | ||
| 399 | 400 | ||
| 400 | // getopt options | 401 | // getopt options |
| 401 | static const char * short_opt = "+46a:dH:hVvqWw:y:"; | 402 | static const char * short_opt = "+46a:dH:hK:k:VvqWw:y:"; |
| 402 | static struct option long_opt[] = | 403 | static struct option long_opt[] = |
| 403 | { | 404 | { |
| 404 | {"help", no_argument, NULL, 'h' }, | 405 | {"help", no_argument, NULL, 'h' }, |
| @@ -462,6 +463,20 @@ ttu_cli_arguments( | |||
| 462 | ttu_usage(cnf); | 463 | ttu_usage(cnf); |
| 463 | return(-1); | 464 | return(-1); |
| 464 | 465 | ||
| 466 | case 'K': | ||
| 467 | if ((ptr = ttu_file2str(optarg)) == NULL) | ||
| 468 | return(ttu_error(cnf, 1, "%s: %s", optarg, strerror(errno))); | ||
| 469 | rc = tinytac_set_option(cnf->tt, TTAC_OPT_KEY, ptr); | ||
| 470 | free(ptr); | ||
| 471 | if (rc != TTAC_SUCCESS) | ||
| 472 | return(ttu_error(cnf, 1, "tinytac_set_option(TTAC_OPT_KEY): %s", tinytac_strerror(rc))); | ||
| 473 | break; | ||
| 474 | |||
| 475 | case 'k': | ||
| 476 | if ((rc = tinytac_set_option(cnf->tt, TTAC_OPT_KEY, optarg)) != TTAC_SUCCESS) | ||
| 477 | return(ttu_error(cnf, 1, "tinytac_set_option(TTAC_OPT_KEY): %s", tinytac_strerror(rc))); | ||
| 478 | break; | ||
| 479 | |||
| 465 | case 'q': | 480 | case 'q': |
| 466 | cnf->opts |= TTUTILS_OPT_QUIET; | 481 | cnf->opts |= TTUTILS_OPT_QUIET; |
| 467 | cnf->opts &= ~TTUTILS_OPT_VERBOSE; | 482 | cnf->opts &= ~TTUTILS_OPT_VERBOSE; |
