(mu_radius_argp_parser): Only run init() if radius
auth is really required. (mu_radius_authenticate,mu_auth_radius_user_by_name) (mu_auth_radius_user_by_uid): Fail if the module was not initialized
Showing
1 changed file
with
30 additions
and
0 deletions
... | @@ -71,6 +71,15 @@ static grad_avp_t *getpwnam_request; | ... | @@ -71,6 +71,15 @@ static grad_avp_t *getpwnam_request; |
71 | static char *getpwuid_request_str; | 71 | static char *getpwuid_request_str; |
72 | static grad_avp_t *getpwuid_request; | 72 | static grad_avp_t *getpwuid_request; |
73 | 73 | ||
74 | /* Assume radius support is needed if any of the above requests is | ||
75 | defined. Actually, all of them should be, but it is the responsibility | ||
76 | of init to check for consistency of the configuration */ | ||
77 | |||
78 | #define NEED_RADIUS_P() \ | ||
79 | (auth_request_str||getpwnam_request_str||getpwuid_request_str) | ||
80 | |||
81 | static int radius_auth_enabled; | ||
82 | |||
74 | static int MU_User_Name; | 83 | static int MU_User_Name; |
75 | static int MU_UID; | 84 | static int MU_UID; |
76 | static int MU_GID; | 85 | static int MU_GID; |
... | @@ -180,6 +189,8 @@ init (struct argp_state *state) | ... | @@ -180,6 +189,8 @@ init (struct argp_state *state) |
180 | parse_pairlist (&auth_request, auth_request_str, state); | 189 | parse_pairlist (&auth_request, auth_request_str, state); |
181 | parse_pairlist (&getpwnam_request, getpwnam_request_str, state); | 190 | parse_pairlist (&getpwnam_request, getpwnam_request_str, state); |
182 | parse_pairlist (&getpwuid_request, getpwuid_request_str, state); | 191 | parse_pairlist (&getpwuid_request, getpwuid_request_str, state); |
192 | |||
193 | radius_auth_enabled = 1; | ||
183 | } | 194 | } |
184 | 195 | ||
185 | static error_t | 196 | static error_t |
... | @@ -204,6 +215,7 @@ mu_radius_argp_parser (int key, char *arg, struct argp_state *state) | ... | @@ -204,6 +215,7 @@ mu_radius_argp_parser (int key, char *arg, struct argp_state *state) |
204 | break; | 215 | break; |
205 | 216 | ||
206 | case ARGP_KEY_FINI: | 217 | case ARGP_KEY_FINI: |
218 | if (NEED_RADIUS_P()) | ||
207 | init (state); | 219 | init (state); |
208 | break; | 220 | break; |
209 | 221 | ||
... | @@ -443,6 +455,12 @@ mu_radius_authenticate (struct mu_auth_data **return_data ARG_UNUSED, | ... | @@ -443,6 +455,12 @@ mu_radius_authenticate (struct mu_auth_data **return_data ARG_UNUSED, |
443 | grad_request_t *reply; | 455 | grad_request_t *reply; |
444 | const struct mu_auth_data *auth_data = key; | 456 | const struct mu_auth_data *auth_data = key; |
445 | 457 | ||
458 | if (!radius_auth_enabled) | ||
459 | { | ||
460 | errno = ENOSYS; | ||
461 | return 1; | ||
462 | } | ||
463 | |||
446 | if (!auth_request) | 464 | if (!auth_request) |
447 | { | 465 | { |
448 | mu_error (_("--radius-auth-request is not specified")); | 466 | mu_error (_("--radius-auth-request is not specified")); |
... | @@ -464,6 +482,12 @@ mu_auth_radius_user_by_name (struct mu_auth_data **return_data, | ... | @@ -464,6 +482,12 @@ mu_auth_radius_user_by_name (struct mu_auth_data **return_data, |
464 | int rc = 1; | 482 | int rc = 1; |
465 | grad_request_t *reply; | 483 | grad_request_t *reply; |
466 | 484 | ||
485 | if (!radius_auth_enabled) | ||
486 | { | ||
487 | errno = ENOSYS; | ||
488 | return 1; | ||
489 | } | ||
490 | |||
467 | if (!getpwnam_request) | 491 | if (!getpwnam_request) |
468 | { | 492 | { |
469 | mu_error (_("--radius-getpwnam-request is not specified")); | 493 | mu_error (_("--radius-getpwnam-request is not specified")); |
... | @@ -492,6 +516,12 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, | ... | @@ -492,6 +516,12 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, |
492 | grad_request_t *reply; | 516 | grad_request_t *reply; |
493 | char uidstr[64]; | 517 | char uidstr[64]; |
494 | 518 | ||
519 | if (!radius_auth_enabled) | ||
520 | { | ||
521 | errno = ENOSYS; | ||
522 | return 1; | ||
523 | } | ||
524 | |||
495 | if (!key) | 525 | if (!key) |
496 | { | 526 | { |
497 | errno = EINVAL; | 527 | errno = EINVAL; | ... | ... |
-
Please register or sign in to post a comment