diff options
| -rw-r--r-- | doc/tinyrad.conf-example.in | 1 | ||||
| -rw-r--r-- | include/tinyrad.h | 1 | ||||
| -rw-r--r-- | lib/libtinyrad/lconf.c | 10 | ||||
| -rw-r--r-- | lib/libtinyrad/lmemory.c | 16 |
4 files changed, 28 insertions, 0 deletions
diff --git a/doc/tinyrad.conf-example.in b/doc/tinyrad.conf-example.in index 4078ba1..a0adab8 100644 --- a/doc/tinyrad.conf-example.in +++ b/doc/tinyrad.conf-example.in | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #URI "radius://localhost/secret" | 8 | #URI "radius://localhost/secret" |
| 9 | #BIND_ADDRESS "::1 127.0.0.1" | 9 | #BIND_ADDRESS "::1 127.0.0.1" |
| 10 | #SECRET "RaDiUsSeCrEt" | 10 | #SECRET "RaDiUsSeCrEt" |
| 11 | #SECRET_FILE "%d/.tinyrad.secret" | ||
| 11 | 12 | ||
| 12 | #TIMEOUT 5 | 13 | #TIMEOUT 5 |
| 13 | #NETWORK_TIMEOUT 3 | 14 | #NETWORK_TIMEOUT 3 |
diff --git a/include/tinyrad.h b/include/tinyrad.h index e869624..80e9e3b 100644 --- a/include/tinyrad.h +++ b/include/tinyrad.h | |||
| @@ -223,6 +223,7 @@ | |||
| 223 | #define TRAD_OPT_SCHEME 12 | 223 | #define TRAD_OPT_SCHEME 12 |
| 224 | #define TRAD_OPT_DICTIONARY 13 | 224 | #define TRAD_OPT_DICTIONARY 13 |
| 225 | #define TRAD_OPT_SECRET 14 | 225 | #define TRAD_OPT_SECRET 14 |
| 226 | #define TRAD_OPT_SECRET_FILE 15 | ||
| 226 | 227 | ||
| 227 | // dictionary get options | 228 | // dictionary get options |
| 228 | #define TRAD_DICT_OPT_REF_COUNT 1 // used by TinyRadDict, TinyRadDictVendor and TinyRadDictAttr | 229 | #define TRAD_DICT_OPT_REF_COUNT 1 // used by TinyRadDict, TinyRadDictVendor and TinyRadDictAttr |
diff --git a/lib/libtinyrad/lconf.c b/lib/libtinyrad/lconf.c index 5421457..b178b8f 100644 --- a/lib/libtinyrad/lconf.c +++ b/lib/libtinyrad/lconf.c | |||
| @@ -202,6 +202,9 @@ tinyrad_conf_environment( | |||
| 202 | if ((value = getenv("TINYRAD_SECRET")) != NULL) | 202 | if ((value = getenv("TINYRAD_SECRET")) != NULL) |
| 203 | tinyrad_conf_opt(tr, dict, "secret", value); | 203 | tinyrad_conf_opt(tr, dict, "secret", value); |
| 204 | 204 | ||
| 205 | if ((value = getenv("TINYRAD_SECRET_FILE")) != NULL) | ||
| 206 | tinyrad_conf_opt(tr, dict, "secret_file", value); | ||
| 207 | |||
| 205 | if ((value = getenv("TINYRAD_TIMEOUT")) != NULL) | 208 | if ((value = getenv("TINYRAD_TIMEOUT")) != NULL) |
| 206 | tinyrad_conf_opt(tr, dict, "timeout", value); | 209 | tinyrad_conf_opt(tr, dict, "timeout", value); |
| 207 | 210 | ||
| @@ -341,6 +344,13 @@ tinyrad_conf_opt( | |||
| 341 | { | 344 | { |
| 342 | if ( (!(tr)) || ((tr->secret)) || (!(value)) ) | 345 | if ( (!(tr)) || ((tr->secret)) || (!(value)) ) |
| 343 | return(TRAD_SUCCESS); | 346 | return(TRAD_SUCCESS); |
| 347 | return(tinyrad_set_option(tr, TRAD_OPT_SECRET_FILE, value)); | ||
| 348 | }; | ||
| 349 | |||
| 350 | if (!(strcasecmp(name, "secret_file"))) | ||
| 351 | { | ||
| 352 | if ( (!(tr)) || ((tr->secret)) || (!(value)) ) | ||
| 353 | return(TRAD_SUCCESS); | ||
| 344 | return(tinyrad_set_option(tr, TRAD_OPT_SECRET, value)); | 354 | return(tinyrad_set_option(tr, TRAD_OPT_SECRET, value)); |
| 345 | }; | 355 | }; |
| 346 | 356 | ||
diff --git a/lib/libtinyrad/lmemory.c b/lib/libtinyrad/lmemory.c index de18bff..018db0c 100644 --- a/lib/libtinyrad/lmemory.c +++ b/lib/libtinyrad/lmemory.c | |||
| @@ -55,6 +55,7 @@ | |||
| 55 | 55 | ||
| 56 | #include "lconf.h" | 56 | #include "lconf.h" |
| 57 | #include "ldict.h" | 57 | #include "ldict.h" |
| 58 | #include "lfile.h" | ||
| 58 | #include "lstrings.h" | 59 | #include "lstrings.h" |
| 59 | 60 | ||
| 60 | 61 | ||
| @@ -250,6 +251,10 @@ tinyrad_get_option( | |||
| 250 | return(TRAD_ENOMEM); | 251 | return(TRAD_ENOMEM); |
| 251 | break; | 252 | break; |
| 252 | 253 | ||
| 254 | case TRAD_OPT_SECRET_FILE: | ||
| 255 | TinyRadDebug(TRAD_DEBUG_ARGS, " == %s( tr, TRAD_OPT_SECRET_FILE, outvalue )", __func__); | ||
| 256 | return(TRAD_EOPTERR); | ||
| 257 | |||
| 253 | case TRAD_OPT_SOCKET_BIND_ADDRESSES: | 258 | case TRAD_OPT_SOCKET_BIND_ADDRESSES: |
| 254 | TinyRadDebug(TRAD_DEBUG_ARGS, " == %s( tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, outvalue )", __func__); | 259 | TinyRadDebug(TRAD_DEBUG_ARGS, " == %s( tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, outvalue )", __func__); |
| 255 | inet_ntop(AF_INET, &tr->bind_sa->sin_addr, bind_buff, sizeof(struct sockaddr_in)); | 260 | inet_ntop(AF_INET, &tr->bind_sa->sin_addr, bind_buff, sizeof(struct sockaddr_in)); |
| @@ -431,6 +436,7 @@ tinyrad_set_option( | |||
| 431 | uint32_t opts; | 436 | uint32_t opts; |
| 432 | int rc; | 437 | int rc; |
| 433 | TinyRadURLDesc * trud; | 438 | TinyRadURLDesc * trud; |
| 439 | char buff[256]; | ||
| 434 | 440 | ||
| 435 | TinyRadDebugTrace(); | 441 | TinyRadDebugTrace(); |
| 436 | 442 | ||
| @@ -529,6 +535,16 @@ tinyrad_set_option( | |||
| 529 | return(TRAD_ENOMEM); | 535 | return(TRAD_ENOMEM); |
| 530 | break; | 536 | break; |
| 531 | 537 | ||
| 538 | case TRAD_OPT_SECRET_FILE: | ||
| 539 | TinyRadDebug(TRAD_DEBUG_ARGS, " == %s( tr, TRAD_OPT_SECRET_FILE, \"%s\" )", __func__, (const char *)invalue); | ||
| 540 | if ((rc = tinyrad_filetostr(buff, (const char *)invalue, sizeof(buff))) != TRAD_SUCCESS) | ||
| 541 | return(rc); | ||
| 542 | if ((tr->secret)) | ||
| 543 | free(tr->secret); | ||
| 544 | if ((tr->secret = tinyrad_strdup(buff)) == NULL) | ||
| 545 | return(TRAD_ENOMEM); | ||
| 546 | break; | ||
| 547 | |||
| 532 | case TRAD_OPT_SOCKET_BIND_ADDRESSES: | 548 | case TRAD_OPT_SOCKET_BIND_ADDRESSES: |
| 533 | TinyRadDebug(TRAD_DEBUG_ARGS, " == %s( tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, invalue )", __func__); | 549 | TinyRadDebug(TRAD_DEBUG_ARGS, " == %s( tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, invalue )", __func__); |
| 534 | if (tr->s != -1) | 550 | if (tr->s != -1) |
